Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/bug-1050033 into lp:maas.

Commit message:
Fix “cp: cannot stat” errors in maas-import-ephemerals (as run by 
maas-import-pxe-files) after upgrade from Precise to Quantal.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1050033 in MAAS: "maas-import-pxe-files has copying errors after package 
upgrade"
  https://bugs.launchpad.net/maas/+bug/1050033

For more details, see:
https://code.launchpad.net/~jtv/maas/bug-1050033/+merge/128685

The cause of the problem was that maas-import-ephemerals will install boot 
images from its iSCSI directories, but some of the pre-quantal boot images may 
have files “kernel” and “initrd,” which nowadays we call “linux” and 
“initrd.gz” respectively.

You may wonder why I'm blithely renaming initrd to initrd.gz, instead of 
compressing it.  That's because behind the scenes, initrd is already a gzipped 
file.


Jeroen
-- 
https://code.launchpad.net/~jtv/maas/bug-1050033/+merge/128685
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~jtv/maas/bug-1050033 into lp:maas.
=== modified file 'scripts/maas-import-ephemerals'
--- scripts/maas-import-ephemerals	2012-10-02 16:59:29 +0000
+++ scripts/maas-import-ephemerals	2012-10-09 11:31:24 +0000
@@ -269,6 +269,27 @@
 }
 
 
+copy_first_available() {
+    # Copy file $2 or $3 (the first that is available) to destination $1.
+    local destination="$1" preferred_file="$2" alternate_file="$3"
+    local actual=""
+
+    if [ -f "${preferred_file}" ]; then
+        actual="${preferred_file}"
+    elif [ -f "${alternate_file}" ]; then
+        actual="${alternate_file}"
+    else
+        error "Could not copy to ${destination}."
+        error "Neither ${preferred_file} nor ${alternate_file} exists."
+        return 1
+    fi
+
+    cp -- "${actual}" "${destination}" ||
+        { error "Could not copy ${actual} to ${destination}."; return 1; }
+    return 0
+}
+
+
 install_tftp_image() {
     # Make image in directory $1, for architecture $2 and subarchitecture $3,
     # and OS release $4, available over TFTP for netbooting nodes.  Only the
@@ -280,11 +301,10 @@
     # deletes it.
     tmpdir="$(mktemp -d)"
 
-    for filename in linux initrd.gz
-    do
-        cp -- "$src/$filename" "$tmpdir/" ||
-            { error "cp of $filename from $src failed"; return 1; }
-    done
+    copy_first_available "$tmpdir/linux" "$src/linux" "$src/kernel" ||
+        return 1
+    copy_first_available "$tmpdir/initrd.gz" "$src/initrd.gz" "$src/initrd" ||
+        return 1
 
     local cmd out=""
     cmd=( maas-provision install-pxe-image

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to