Skip to content

Instantly share code, notes, and snippets.

@jaos

jaos/dockerimgbuild.sh

Last active Oct 5, 2020
Embed
What would you like to do?
slack minimal root filesystem tarballs for docker import
#!/bin/bash -ex
ROOT=/tmp/rfs
OUT=/tmp
function dobuild() {
set -ex
slackrel=${1:-slackware-15.0}
imgtype=${2:-minimal}
rm -rf $ROOT
mkdir -p ${ROOT}/etc/slapt-get
mkdir -p ${ROOT}/var/lib/pkgtools/packages
echo "WORKINGDIR=${ROOT}/var/cache/slapt-get" >> ${ROOT}/etc/slapt-get/slapt-getrc
case "$slackrel" in
slackware64-15.0)
echo "SOURCE=https://storage.googleapis.com/slackpacks.jaos.org/slackware64-15.0/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
echo "SOURCE=http://slackware.uk/slackware/slackware64-current/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
;;
slackware-15.0)
echo "SOURCE=https://storage.googleapis.com/slackpacks.jaos.org/slackware-15.0/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
echo "SOURCE=http://slackware.uk/slackware/slackware-current/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
;;
slackwarearm-15.0)
echo "SOURCE=https://storage.googleapis.com/slackpacks.jaos.org/slackwarearm-15.0/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
echo "SOURCE=http://slackware.uk/slackwarearm/slackwarearm-current/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
;;
slarm64-15.0)
echo "#SOURCE=http://dl.fail.pp.ua/slackware/slarm64-current/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
echo "SOURCE=https://slackware.uk/slarm64/slarm64-current/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
echo "SOURCE=https://storage.googleapis.com/slackpacks.jaos.org/slarm64-15.0/:OFFICIAL" >> ${ROOT}/etc/slapt-get/slapt-getrc
;;
esac
ROOT=${ROOT} slapt-get -c ${ROOT}/etc/slapt-get/slapt-getrc --update
CLEANUP=
case "$imgtype" in
"minimal")
ROOT=${ROOT} slapt-get -c ${ROOT}/etc/slapt-get/slapt-getrc --install aaa_base aaa_elflibs aaa_terminfo bash grep coreutils elvis etc bin file procps-ng findutils glibc-solibs gzip less openssl-solibs patch pkgtools sed tar util-linux xz which pcre2 gnupg slapt-get curl dialog gawk file libpsl nghttp2 libunistring libgcrypt gettext utempter diffutils hostname sqlite icu4c e2fsprogs brotli perl ca-certificates zstd
CLEANUP="binutils perl"
;;
"small")
ROOT=${ROOT} slapt-get -c ${ROOT}/etc/slapt-get/slapt-getrc --install aaa_base aaa_elflibs aaa_terminfo bash grep coreutils etc bin file procps-ng findutils glibc-solibs gzip less openssl-solibs patch pkgtools sed tar util-linux xz which pcre pcre2 gnupg slapt-get curl dialog gawk file time libpsl nghttp2 libunistring libgcrypt gettext utempter libcgroup diffutils tree hostname sqlite icu4c e2fsprogs brotli perl ca-certificates bzip2 lbzip2 cpio devs vim lzlib wget ncurses readline mpfr net-tools iproute2 iputils ntp openssh zstd
CLEANUP="binutils"
;;
"dev")
ROOT=${ROOT} slapt-get -c ${ROOT}/etc/slapt-get/slapt-getrc --install aaa_base aaa_elflibs aaa_terminfo bash grep coreutils etc bin file procps-ng findutils glibc-solibs gzip less openssl-solibs patch pkgtools sed tar util-linux xz which pcre pcre2 gnupg slapt-get curl dialog gawk file time libpsl nghttp2 libunistring libgcrypt gettext utempter libcgroup diffutils tree hostname sqlite icu4c e2fsprogs brotli openssl perl ca-certificates bzip2 lbzip2 cpio devs vim lzlib wget ncurses readline mpfr net-tools iproute2 iputils ntp openssh gcc gcc-g++ gc guile make autoconf git glibc kernel-headers autoconf automake libtool m4 gettext-tools pkg-config intltool atk glib2 gtk+2 pango zlib mesa libdrm libXxf86vm expat libxshmfence fribidi graphite2 libpthread-stubs xorgproto shared-mime-info gslapt slapt-src graphite2 fribidi shared-mime-info libmpc flex bison libxml2 python3 libglvnd font-misc-misc binutils texinfo adwaita-icon-theme hicolor-icon-theme libXtst at-spi2-atk at-spi2-core dbus gtk+3 libepoxy wayland wayland-protocols libxkbcommon check zstd libpng libXft liberation-fonts-ttf libcanberra gamin libvorbis libogg
pushd $ROOT/srv && for r in slapt-get slapt-src gslapt cpan2tgz slapt-update-service;do git clone "https://software.jaos.org/git/${r}" || true;done; popd
;;
esac
if [ -d $ROOT/lib64 ]; then
if [ ! -e $ROOT/lib64/libdl.so.2 ]; then pushd $ROOT/lib64; ln -s libdl-*.so libdl.so.2 ;popd;fi
if [ ! -e $ROOT/lib64/libc.so.6 ]; then pushd $ROOT/lib64; ln -s libc-*.so libc.so.6; popd;fi
else
if [ ! -e $ROOT/lib/libdl.so.2 ]; then pushd $ROOT/lib; ln -s libdl-*.so libdl.so.2 ;popd;fi
if [ ! -e $ROOT/lib/libc.so.6 ]; then pushd $ROOT/lib; ln -s libc-*.so libc.so.6; popd;fi
fi
chroot $ROOT ldconfig
chroot $ROOT /bin/bash -c "LANG=C /usr/sbin/update-ca-certificates" || true
chroot $ROOT /bin/bash -c "cd /etc/ssl/certs; LANG=C /usr/bin/perl /usr/bin/c_rehash . " || true
chroot $ROOT /bin/bash -c "/usr/bin/update-mime-database /usr/share/mime" || true
chroot $ROOT /bin/bash -c "/usr/bin/gdk-pixbuf-query-loaders \$(dirname \$(find /usr/lib/gdk-pixbuf* /usr/lib64/gdk-pixbuf* -type d -name loaders 2>/dev/null))/loaders.cache" || true
if [[ ${CLEANUP} ]]; then
ROOT=${ROOT} slapt-get -c ${ROOT}/etc/slapt-get/slapt-getrc --remove --no-dep -y ${CLEANUP} &>/dev/null
fi
sed -i -re "s|$ROOT||" ${ROOT}/etc/slapt-get/slapt-getrc
rm -rf ${ROOT}/var/cache/slapt-get
pushd ${ROOT}/root && ln -s ../etc/profile .bashrc; popd
pushd ${ROOT} && tar cf $OUT/${slackrel}-${imgtype}.tar *; popd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.