github.com/rita33cool1/iot-system-gateway@v0.0.0-20200911033302-e65bde238cc5/docker-engine/contrib/mkimage-pld.sh (about) 1 #!/bin/sh 2 # 3 # Generate a minimal filesystem for PLD Linux and load it into the local docker as "pld". 4 # https://www.pld-linux.org/packages/docker 5 # 6 set -e 7 8 if [ "$(id -u)" != "0" ]; then 9 echo >&2 "$0: requires root" 10 exit 1 11 fi 12 13 image_name=pld 14 15 tmpdir=$(mktemp -d ${TMPDIR:-/var/tmp}/pld-docker-XXXXXX) 16 root=$tmpdir/rootfs 17 install -d -m 755 $root 18 19 # to clean up: 20 docker rmi $image_name || : 21 22 # build 23 rpm -r $root --initdb 24 25 set +e 26 install -d $root/dev/pts 27 mknod $root/dev/random c 1 8 -m 644 28 mknod $root/dev/urandom c 1 9 -m 644 29 mknod $root/dev/full c 1 7 -m 666 30 mknod $root/dev/null c 1 3 -m 666 31 mknod $root/dev/zero c 1 5 -m 666 32 mknod $root/dev/console c 5 1 -m 660 33 set -e 34 35 poldek -r $root --up --noask -u \ 36 --noignore \ 37 -O 'rpmdef=_install_langs C' \ 38 -O 'rpmdef=_excludedocs 1' \ 39 vserver-packages \ 40 bash iproute2 coreutils grep poldek 41 42 # fix netsharedpath, so containers would be able to install when some paths are mounted 43 sed -i -e 's;^#%_netsharedpath.*;%_netsharedpath /dev/shm:/sys:/proc:/dev:/etc/hostname;' $root/etc/rpm/macros 44 45 # no need for alternatives 46 poldek-config -c $root/etc/poldek/poldek.conf ignore systemd-init 47 48 # this makes initscripts to believe network is up 49 touch $root/var/lock/subsys/network 50 51 # cleanup large optional packages 52 remove_packages="ca-certificates" 53 for pkg in $remove_packages; do 54 rpm -r $root -q $pkg && rpm -r $root -e $pkg --nodeps 55 done 56 57 # cleanup more 58 rm -v $root/etc/ld.so.cache 59 rm -rfv $root/var/cache/hrmib/* 60 rm -rfv $root/usr/share/man/man?/* 61 rm -rfv $root/usr/share/locale/*/ 62 rm -rfv $root/usr/share/help/*/ 63 rm -rfv $root/usr/share/doc/* 64 rm -rfv $root/usr/src/examples/* 65 rm -rfv $root/usr/share/pixmaps/* 66 67 # and import 68 tar --numeric-owner --xattrs --acls -C $root -c . | docker import - $image_name 69 70 # and test 71 docker run -i -u root $image_name /bin/echo Success. 72 73 rm -r $tmpdir