diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 387: do not explode if /etc/resolv.conf is missing in the testrootfs

Message ID 20120920213514.23103.10152.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Sept. 20, 2012, 9:35 p.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/resolv.conf-forgiveness-bug-1052373/+merge/125398
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Andy Doan (doanac)
------------------------------------------------------------
revno: 387 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Fri 2012-09-21 09:34:50 +1200
message:
  do not explode if /etc/resolv.conf is missing in the testrootfs
modified:
  lava_dispatcher/client/master.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/master.py'
--- lava_dispatcher/client/master.py	2012-09-20 21:34:24 +0000
+++ lava_dispatcher/client/master.py	2012-09-20 21:34:50 +0000
@@ -764,8 +764,8 @@ 
             master_session.run('mount /dev/disk/by-label/%s %s' % (
                 partition, directory))
             master_session.run(
-                'cp -f %s/etc/resolv.conf %s/etc/resolv.conf.bak' % (
-                    directory, directory))
+                '[ -e %s/etc/resolv.conf ] && cp -f %s/etc/resolv.conf %s/etc/resolv.conf.bak' % (
+                    directory, directory, directory))
             master_session.run('cp -L /etc/resolv.conf %s/etc' % directory)
             #eliminate warning: Can not write log, openpty() failed
             #                   (/dev/pts not mounted?), does not work
@@ -775,8 +775,8 @@ 
                     'chroot ' + directory, self.proc, self.master_str)
             finally:
                 master_session.run(
-                    'cp -f %s/etc/resolv.conf.bak %s/etc/resolv.conf' % (
-                        directory, directory))
+                    '[ -e %s/etc/resolv.conf.bak ] && cp -f %s/etc/resolv.conf.bak %s/etc/resolv.conf || rm %s/etc/resolv.conf' % (
+                        directory, directory, directory, directory))
                 cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^%s/dev"'
                        '| sort -r | xargs umount' % directory)
                 master_session.run(cmd)