Skip to content

Instantly share code, notes, and snippets.

@jaos jaos/dockerimgbuild.sh

Last active May 3, 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=http://mirrors.slackware.bg/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 pcre pcre2 gnupg slapt-get curl dialog gawk file time libpsl nghttp2 libunistring libgcrypt gettext utempter libcgroup diffutils tree hostname sqlite icu4c e2fsprogs brotli ca-certificates
CLEANUP="binutils"
;;
"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 ca-certificates bzip2 lbzip2 cpio devs vim lzlib wget ncurses readline mpfr net-tools iproute2 iputils ntp openssh
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 libcroco 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
pushd $ROOT/root && for r in slapt-get slapt-src gslapt cpan2tgz slapt-update-service;do git clone https://software.jaos.org/git/$r;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/sh -c "LANG=C update-ca-certificates" || true
pushd ${ROOT}/etc/ssl/certs && c_rehash . ; popd
if [ -n "${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
echo "update-mime-database /usr/share/mime 2>/dev/null || true" >> ${ROOT}/etc/profile.d/jaos.sh
echo "gdk-pixbuf-query-loaders-64 2>/dev/null > /usr/lib64/gdk-pixbuf-2.0/2.10.0/loaders.cache || true" >> ${ROOT}/etc/profile.d/jaos.sh
chmod +x ${ROOT}/etc/profile.d/jaos.sh
pushd ${ROOT} && tar cf $OUT/${slackrel}-${imgtype}.tar *
}
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.