From b6f1806e89cc2acbe58c19710c8f49233c6157b9 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Tue, 21 Feb 2017 15:40:17 +0300 Subject: [PATCH] Restore resolvconf functionality for the OS images --- configuration.sh | 2 +- debootstrap-ng.sh | 16 ++++++---------- distributions.sh | 21 +++++++++++++++++---- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/configuration.sh b/configuration.sh index d3f4c51da3..1d71456293 100644 --- a/configuration.sh +++ b/configuration.sh @@ -19,7 +19,7 @@ USEALLCORES=yes # Use all CPU cores for compiling EXIT_PATCHING_ERROR="" # exit patching if failed HOST="$BOARD" # set hostname to the board CACHEDIR=$DEST/cache -ROOTFSCACHE_VERSION=2 +ROOTFSCACHE_VERSION=3 [[ -z $ROOTFS_TYPE ]] && ROOTFS_TYPE=ext4 # default rootfs type is ext4 [[ "ext4 f2fs btrfs nfs fel" != *$ROOTFS_TYPE* ]] && exit_with_error "Unknown rootfs type" "$ROOTFS_TYPE" diff --git a/debootstrap-ng.sh b/debootstrap-ng.sh index c70751b6ec..13e79489b9 100644 --- a/debootstrap-ng.sh +++ b/debootstrap-ng.sh @@ -77,17 +77,9 @@ debootstrap_ng() # NOTE: installing too many packages may fill tmpfs mount customize_image - # stage: cleanup - rm -f $CACHEDIR/$SDCARD/sbin/initctl $CACHEDIR/$SDCARD/sbin/start-stop-daemon - chroot $CACHEDIR/$SDCARD /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/initctl" - chroot $CACHEDIR/$SDCARD /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/start-stop-daemon" - rm -f $CACHEDIR/$SDCARD/usr/sbin/policy-rc.d $CACHEDIR/$SDCARD/usr/bin/$QEMU_BINARY - + # clean up / prepare for making the image umount_chroot "$CACHEDIR/$SDCARD" - - # to prevent creating swap file on NFS (needs specific kernel options) - # and f2fs/btrfs (not recommended or needs specific kernel options) - [[ $ROOTFS_TYPE != ext4 ]] && touch $CACHEDIR/$SDCARD/var/swap + post_debootstrap_tweaks if [[ $ROOTFS_TYPE == fel ]]; then FEL_ROOTFS=$CACHEDIR/$SDCARD/ @@ -233,6 +225,10 @@ create_rootfs_cache() # stage: remove downloaded packages chroot $CACHEDIR/$SDCARD /bin/bash -c "apt-get clean" + # this is needed for the build process later since resolvconf generated file in /run is not saved + rm $CACHEDIR/$SDCARD/etc/resolv.conf + echo 'nameserver 8.8.8.8' >> $CACHEDIR/$SDCARD/etc/resolv.conf + # stage: make rootfs cache archive display_alert "Ending debootstrap process and preparing cache" "$RELEASE" "info" sync diff --git a/distributions.sh b/distributions.sh index 0d52a5ea64..3a0107afde 100644 --- a/distributions.sh +++ b/distributions.sh @@ -11,6 +11,7 @@ # Functions: # install_common # install_distribution_specific +# post_debootstrap_tweaks install_common() { @@ -89,10 +90,6 @@ install_common() echo $HOST > $CACHEDIR/$SDCARD/etc/hostname - # this is needed for ubuntu - rm $CACHEDIR/$SDCARD/etc/resolv.conf - echo "nameserver 8.8.8.8" >> $CACHEDIR/$SDCARD/etc/resolv.conf - # set hostname in hosts file cat <<-EOF > $CACHEDIR/$SDCARD/etc/hosts 127.0.0.1 localhost $HOST @@ -187,6 +184,10 @@ install_common() # Fix for PuTTY/KiTTY & ncurses-based dialogs (i.e. alsamixer) over serial # may break other terminals like screen #printf "[Service]\nEnvironment=TERM=xterm-256color" > $CACHEDIR/$SDCARD/etc/systemd/system/serial-getty@.service.d/10-term.conf + + # to prevent creating swap file on NFS (needs specific kernel options) + # and f2fs/btrfs (not recommended or needs specific kernel options) + [[ $ROOTFS_TYPE != ext4 ]] && touch $CACHEDIR/$SDCARD/var/swap } install_distribution_specific() @@ -238,3 +239,15 @@ install_distribution_specific() ;; esac } + +post_debootstrap_tweaks() +{ + # remove service start blockers and QEMU binary + rm -f $CACHEDIR/$SDCARD/sbin/initctl $CACHEDIR/$SDCARD/sbin/start-stop-daemon + chroot $CACHEDIR/$SDCARD /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/initctl" + chroot $CACHEDIR/$SDCARD /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/start-stop-daemon" + rm -f $CACHEDIR/$SDCARD/usr/sbin/policy-rc.d $CACHEDIR/$SDCARD/usr/bin/$QEMU_BINARY + + # reenable resolvconf managed resolv.conf + ln -sf /run/resolvconf/resolv.conf $CACHEDIR/$SDCARD/etc/resolv.conf +}