Restore resolvconf functionality for the OS images

This commit is contained in:
zador-blood-stained 2017-02-21 15:40:17 +03:00
parent 473ea67fda
commit b6f1806e89
3 changed files with 24 additions and 15 deletions

View File

@ -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"

View File

@ -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

View File

@ -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
}