From 1435f6e48d33ed76b242ea4dabfcecd707a37c44 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Fri, 14 Jun 2013 14:32:14 +0100 Subject: [PATCH] Make the finalise_base function less Ubuntu-ish. The finalise_base function was creating a broken link at /etc/resolv.conf when building a non ubuntu image. Change-Id: I974d43fd6db365dbff9c85195e3b72950f3409da --- lib/img-functions | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/img-functions b/lib/img-functions index f7ac4781e..654143655 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -69,13 +69,8 @@ function create_base () { # Configure Image # Setup resolv.conf so we can chroot to install some packages - # XXXX: Should store the old state rather than unlink; then restore later. - if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] ; then - sudo unlink $TMP_MOUNT_PATH/etc/resolv.conf - fi - - if [ -f $TMP_MOUNT_PATH/etc/resolv.conf ] ; then - sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf + if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf ] ; then + sudo mv $TMP_MOUNT_PATH/etc/resolv.conf $TMP_MOUNT_PATH/etc/resolv.conf.ORIG fi # Recreate resolv.conf @@ -136,10 +131,12 @@ function prepare_first_boot () { function finalise_base () { TARGET_ROOT=$TMP_MOUNT_PATH run_d cleanup - # Now remove the resolv.conf we created above + # Remove the resolv.conf we created above sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf - # The we need to recreate it as a link - sudo ln -sf ../run/resolvconf/resolv.conf $TMP_MOUNT_PATH/etc/resolv.conf + # Move the original back + if [ -L $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] ; then + sudo mv $TMP_MOUNT_PATH/etc/resolv.conf.ORIG $TMP_MOUNT_PATH/etc/resolv.conf + fi } function compress_image () {