From d25a930baf317eb55a1b250fc488725f925890de Mon Sep 17 00:00:00 2001 From: Andrew Clemons Date: Wed, 17 Aug 2022 19:02:45 +0900 Subject: [PATCH 1/4] Make image pruning code optional. It still defaults to minimising the image, but allow building an image which does not have any files from existing packages removed. --- mkimage-slackware.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mkimage-slackware.sh b/mkimage-slackware.sh index 12ec98c..b8336e4 100755 --- a/mkimage-slackware.sh +++ b/mkimage-slackware.sh @@ -18,6 +18,7 @@ RELEASE=${RELEASE:-"${RELEASENAME}-${VERSION}"} MIRROR=${MIRROR:-"http://slackware.osuosl.org"} CACHEFS=${CACHEFS:-"/tmp/${BUILD_NAME}/${RELEASE}"} ROOTFS=${ROOTFS:-"/tmp/rootfs-${RELEASE}"} +MINIMAL=${MINIMAL:-yes} CWD=$(pwd) base_pkgs="a/aaa_base \ @@ -200,9 +201,11 @@ if [ ! -e ./root/.gnupg ] ; then fi set -x -echo "export TERM=linux" >> etc/profile.d/term.sh -chmod +x etc/profile.d/term.sh -echo ". /etc/profile" > .bashrc +if [ "$MINIMAL" = "yes" ] || [ "$MINIMAL" = "1" ] ; then + echo "export TERM=linux" >> etc/profile.d/term.sh + chmod +x etc/profile.d/term.sh + echo ". /etc/profile" > .bashrc +fi echo "${MIRROR}/${RELEASE}/" >> etc/slackpkg/mirrors sed -i 's/DIALOG=on/DIALOG=off/' etc/slackpkg/slackpkg.conf sed -i 's/POSTINST=on/POSTINST=off/' etc/slackpkg/slackpkg.conf @@ -225,9 +228,11 @@ fi # now some cleanup of the minimal image set +x -rm -rf usr/share/locale/* -rm -rf usr/man/* -find usr/share/terminfo/ -type f ! -name 'linux' -a ! -name 'xterm' -a ! -name 'screen.linux' -exec rm -f "{}" \; +if [ "$MINIMAL" = "yes" ] || [ "$MINIMAL" = "1" ] ; then + rm -rf usr/share/locale/* + rm -rf usr/man/* + find usr/share/terminfo/ -type f ! -name 'linux' -a ! -name 'xterm' -a ! -name 'screen.linux' -exec rm -f "{}" \; +fi umount $ROOTFS/dev rm -f dev/* # containers should expect the kernel API (`mount -t devtmpfs none /dev`) From 3923fbe9ac447930f6c630472cc996fe185a1d6c Mon Sep 17 00:00:00 2001 From: Andrew Clemons Date: Sun, 11 Sep 2022 20:08:59 +0900 Subject: [PATCH 2/4] Support slackware 12.x (and possibly older). --- mkimage-slackware.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mkimage-slackware.sh b/mkimage-slackware.sh index b8336e4..5331fb0 100755 --- a/mkimage-slackware.sh +++ b/mkimage-slackware.sh @@ -132,7 +132,12 @@ fi # an update in upgradepkg during the 14.2 -> 15.0 cycle changed/broke this root_env="" -root_flag="--root /mnt" +root_flag="" +if [ -f ./sbin/upgradepkg ] && grep -qw -- '"--root"' ./sbin/upgradepkg ; then + root_flag="--root /mnt" +elif [ -f ./usr/lib/setup/installpkg ] && grep -qw -- '"-root"' ./usr/lib/setup/installpkg ; then + root_flag="-root /mnt" +fi if [ "$VERSION" = "current" ] || [ "${VERSION}" = "15.0" ]; then root_env='ROOT=/mnt' root_flag='' @@ -206,15 +211,12 @@ if [ "$MINIMAL" = "yes" ] || [ "$MINIMAL" = "1" ] ; then chmod +x etc/profile.d/term.sh echo ". /etc/profile" > .bashrc fi -echo "${MIRROR}/${RELEASE}/" >> etc/slackpkg/mirrors -sed -i 's/DIALOG=on/DIALOG=off/' etc/slackpkg/slackpkg.conf -sed -i 's/POSTINST=on/POSTINST=off/' etc/slackpkg/slackpkg.conf -sed -i 's/SPINNING=on/SPINNING=off/' etc/slackpkg/slackpkg.conf -if [ "$VERSION" = "current" ] ; then - mkdir -p var/lib/slackpkg - touch var/lib/slackpkg/current +if [ -e etc/slackpkg/mirrors ] ; then + echo "${MIRROR}/${RELEASE}/" >> etc/slackpkg/mirrors + sed -i 's/DIALOG=on/DIALOG=off/' etc/slackpkg/slackpkg.conf + sed -i 's/POSTINST=on/POSTINST=off/' etc/slackpkg/slackpkg.conf + sed -i 's/SPINNING=on/SPINNING=off/' etc/slackpkg/slackpkg.conf fi - if [ ! -f etc/rc.d/rc.local ] ; then mkdir -p etc/rc.d cat >> etc/rc.d/rc.local < Date: Thu, 15 Sep 2022 21:29:40 +0900 Subject: [PATCH 3/4] Add support for slackwarearm and slackwareaarch64. --- get_paths.sh | 27 ++++++++++++++++--------- mkimage-slackware.sh | 47 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/get_paths.sh b/get_paths.sh index b00a852..914798c 100755 --- a/get_paths.sh +++ b/get_paths.sh @@ -12,7 +12,7 @@ _usage() { } _release_base() { - echo "${1}" | cut -d - -f 1 + echo "${1}" | cut -d - -f 1 | sed 's/armedslack/slackware/;s/slackwarearm/slackware/;s/slackwareaarch64/slackware/' } _fetch_file_list() { @@ -84,21 +84,30 @@ main() { esac done shift $((OPTIND-1)) - + tmp_dir="$(mktemp -d)" tmp_file_list="${tmp_dir}/FILE_LIST" if [ -n "${fetch_patches}" ] ; then _fetch_file_list "${mirror}" "${release}" "patches" >> "${tmp_file_list}" + ret=$? + if [ $ret -ne 0 ] ; then + echo "ERROR fetching FILE_LIST" >&2 + exit $ret + fi elif [ -n "${fetch_extra}" ] ; then _fetch_file_list "${mirror}" "${release}" "extra" >> "${tmp_file_list}" + ret=$? + if [ $ret -ne 0 ] ; then + echo "ERROR fetching FILE_LIST" >&2 + exit $ret + fi else _fetch_file_list "${mirror}" "${release}" "$(_release_base "${release}")" > "${tmp_file_list}" - fi - - ret=$? - if [ $ret -ne 0 ] ; then - echo "ERROR fetching FILE_LIST" >&2 - exit $ret + ret=$? + if [ $ret -ne 0 ] ; then + echo "ERROR fetching FILE_LIST" >&2 + exit $ret + fi fi if [ -n "${fetch_tagfiles}" ] ; then @@ -112,7 +121,7 @@ main() { done fi - grep '\.t.z$' "${tmp_file_list}" | awk '{ print $8 }' | sed -e 's|\./\(.*\.t.z\)$|\1|g' + grep '\.t.z$' "${tmp_file_list}" | awk '{ print $(NF) }' | sed -e 's|\./\(.*\.t.z\)$|\1|g' } _is_sourced || main "${@}" diff --git a/mkimage-slackware.sh b/mkimage-slackware.sh index 5331fb0..445c5d0 100755 --- a/mkimage-slackware.sh +++ b/mkimage-slackware.sh @@ -7,6 +7,7 @@ if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH="" ;; arm*) ARCH=arm ;; + aarch64) ARCH=aarch64 ;; *) ARCH=64 ;; esac fi @@ -15,7 +16,13 @@ BUILD_NAME=${BUILD_NAME:-"slackware"} VERSION=${VERSION:="current"} RELEASENAME=${RELEASENAME:-"slackware${ARCH}"} RELEASE=${RELEASE:-"${RELEASENAME}-${VERSION}"} -MIRROR=${MIRROR:-"http://slackware.osuosl.org"} +if [ -z "$MIRROR" ]; then + if [ "$ARCH" = "arm" ] || [ "$ARCH" = "aarch64" ] ; then + MIRROR=${MIRROR:-"http://slackware.uk/slackwarearm"} + else + MIRROR=${MIRROR:-"http://slackware.osuosl.org"} + fi +fi CACHEFS=${CACHEFS:-"/tmp/${BUILD_NAME}/${RELEASE}"} ROOTFS=${ROOTFS:-"/tmp/rootfs-${RELEASE}"} MINIMAL=${MINIMAL:-yes} @@ -31,6 +38,7 @@ base_pkgs="a/aaa_base \ a/pam \ a/cracklib \ a/libpwquality \ + a/lzlib \ a/e2fsprogs \ a/nvi \ a/pkgtools \ @@ -91,16 +99,35 @@ function cacheit() { mkdir -p $ROOTFS $CACHEFS -cacheit "isolinux/initrd.img" +if [ -z "$INITRD" ]; then + if [ "$ARCH" = "arm" ] ; then + case "$VERSION" in + 12*|13*|14.0|14.1) INITRD=initrd-versatile.img ;; + *) INITRD=initrd-armv7.img ;; + esac + elif [ "$ARCH" = "aarch64" ] ; then + INITRD=initrd-armv8.img + else + INITRD=initrd.img + fi +fi + +if [ "$ARCH" = "aarch64" ] ; then + cacheit "installer/$INITRD" + mv ${CACHEFS}/installer ${CACHEFS}/isolinux + cacheit "installer/$INITRD" +else + cacheit "isolinux/$INITRD" +fi cd $ROOTFS # extract the initrd to the current rootfs ## ./slackware64-14.2/isolinux/initrd.img: gzip compressed data, last modified: Fri Jun 24 21:14:48 2016, max compression, from Unix, original size 68600832 ## ./slackware64-current/isolinux/initrd.img: XZ compressed data -if $(file ${CACHEFS}/isolinux/initrd.img | grep -wq XZ) ; then - xzcat "${CACHEFS}/isolinux/initrd.img" | cpio -idvm --null --no-absolute-filenames +if file ${CACHEFS}/isolinux/$INITRD | grep -wq XZ ; then + xzcat "${CACHEFS}/isolinux/$INITRD" | cpio -idvm --null --no-absolute-filenames else - zcat "${CACHEFS}/isolinux/initrd.img" | cpio -idvm --null --no-absolute-filenames + zcat "${CACHEFS}/isolinux/$INITRD" | cpio -idvm --null --no-absolute-filenames fi if stat -c %F $ROOTFS/cdrom | grep -q "symbolic link" ; then @@ -143,9 +170,9 @@ if [ "$VERSION" = "current" ] || [ "${VERSION}" = "15.0" ]; then root_flag='' fi -relbase=$(echo ${RELEASE} | cut -d- -f1) +relbase=$(echo ${RELEASE} | cut -d- -f1 | sed 's/armedslack/slackware/;s/slackwarearm/slackware/;s/slackwareaarch64/slackware/') if [ ! -f ${CACHEFS}/paths ] ; then - bash ${CWD}/get_paths.sh -r ${RELEASE} > ${CACHEFS}/paths + bash ${CWD}/get_paths.sh -r ${RELEASE} -m ${MIRROR} > ${CACHEFS}/paths fi if [ ! -f ${CACHEFS}/paths-patches ] ; then bash ${CWD}/get_paths.sh -r ${RELEASE} -m ${MIRROR} -p > ${CACHEFS}/paths-patches @@ -216,6 +243,10 @@ if [ -e etc/slackpkg/mirrors ] ; then sed -i 's/DIALOG=on/DIALOG=off/' etc/slackpkg/slackpkg.conf sed -i 's/POSTINST=on/POSTINST=off/' etc/slackpkg/slackpkg.conf sed -i 's/SPINNING=on/SPINNING=off/' etc/slackpkg/slackpkg.conf + if [ "$VERSION" = "current" ] ; then + mkdir -p var/lib/slackpkg + touch var/lib/slackpkg/current + fi fi if [ ! -f etc/rc.d/rc.local ] ; then mkdir -p etc/rc.d @@ -246,5 +277,3 @@ for dir in cdrom dev sys proc ; do umount $ROOTFS/$dir fi done - - From 2b596e07b6bbe390b740a8b7600a64c380b7cbc6 Mon Sep 17 00:00:00 2001 From: Andrew Clemons Date: Thu, 22 Sep 2022 19:21:00 +0900 Subject: [PATCH 4/4] Add permanent fix for arm faccessat2 issue. As described previously in https://github.com/aclemons/slackware-dockerfiles/commit/a2d9688a550ad4255592ebe114e7175eb78d3ab2, Stuart has kindly patched this in 15.0, but the installer has of course not changed. I have updated the builder code to patch the installer after extracting it. --- mkimage-slackware.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mkimage-slackware.sh b/mkimage-slackware.sh index 445c5d0..868b3de 100755 --- a/mkimage-slackware.sh +++ b/mkimage-slackware.sh @@ -87,6 +87,11 @@ base_pkgs="a/aaa_base \ n/iproute2 \ n/openssl" +if [ "$VERSION" = "15.0" ] && [ "$ARCH" = "arm" ] ; then + base_pkgs="installer_fix \ + $base_pkgs" +fi + function cacheit() { file=$1 if [ ! -f "${CACHEFS}/${file}" ] ; then @@ -182,6 +187,12 @@ if [ ! -f ${CACHEFS}/paths-extra ] ; then fi for pkg in ${base_pkgs} do + installer_fix=false + if [ "$pkg" = "installer_fix" ] ; then + # see slackwarearm-15.0 ChangeLog entry from Thu Sep 15 08:08:08 UTC 2022 + installer_fix=true + pkg=a/aaa_glibc-solibs + fi path=$(grep "^packages/$(basename "${pkg}")-" ${CACHEFS}/paths-patches | cut -d : -f 1) if [ ${#path} -eq 0 ] ; then path=$(grep ^${pkg}- ${CACHEFS}/paths | cut -d : -f 1) @@ -199,7 +210,17 @@ do else l_pkg=$(cacheit patches/$path) fi - if [ -e ./sbin/upgradepkg ] ; then + if $installer_fix ; then + echo PATH=/bin:/sbin:/usr/bin:/usr/sbin \ + chroot . /bin/tar-1.13 -xvf ${l_pkg} lib/incoming/libc-2.33.so + PATH=/bin:/sbin:/usr/bin:/usr/sbin \ + chroot . /bin/tar -xvf ${l_pkg} lib/incoming/libc-2.33.so + mv lib/incoming/libc-2.33.so lib && rm -rf lib/incoming + echo PATH=/bin:/sbin:/usr/bin:/usr/sbin \ + chroot . /bin/test -x /bin/sh + PATH=/bin:/sbin:/usr/bin:/usr/sbin \ + chroot . /bin/test -x /bin/sh # confirm bug is fixed + elif [ -e ./sbin/upgradepkg ] ; then echo PATH=/bin:/sbin:/usr/bin:/usr/sbin \ ROOT=/mnt \ chroot . /sbin/upgradepkg ${root_flag} ${install_args} ${l_pkg}