]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
templates: add squashfs support to lxc-ubuntu-cloud.in
authorPo-Hsu Lin <po-hsu.lin@canonical.com>
Thu, 10 Nov 2016 08:48:29 +0000 (16:48 +0800)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 18 Nov 2016 01:42:48 +0000 (20:42 -0500)
Add squashfs format file support for lxc-ubuntu-cloud.in

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
templates/lxc-ubuntu-cloud.in

index d277feccf6a84bb6c1e4af6fba50e21f295098fd..5cb8f15e085e372c920accbaf130a3a4a4a1682a 100644 (file)
@@ -299,7 +299,11 @@ else
         [ "$stream" = "daily" ] || echo "You may try with '--stream=daily'"
         exit 1
     fi
-    url2=`echo $url1 | sed -e 's/.tar.gz/-root\0/' -e 's/.tar.gz/.tar.xz/'`
+    if [ "$release" = "precise" ] || [ "$release" = "trusty" ]; then
+        url2=`echo $url1 | sed -e 's/.tar.gz/-root\0/' -e 's/.tar.gz/.tar.xz/'`
+    else
+        url2=`echo $url1 | sed -e 's/.tar.gz/.squashfs/'`
+    fi
 fi
 
 filename=`basename $url2`
@@ -329,11 +333,15 @@ do_extract_rootfs() {
     echo "Extracting container rootfs"
     mkdir -p $rootfs
     cd $rootfs
-    if [ $in_userns -eq 1 ]; then
-        tar --anchored --exclude="dev/*" --numeric-owner -xpf "$cache/$filename"
-        mkdir -p $rootfs/dev/pts/
+    if [ "${filename##*.}" = "squashfs" ]; then
+        unsquashfs -n -f -d "$rootfs" "$cache/$filename"
     else
-        tar --numeric-owner -xpf "$cache/$filename"
+        if [ $in_userns -eq 1 ]; then
+            tar --anchored --exclude="dev/*" --numeric-owner -xpf "$cache/$filename"
+            mkdir -p $rootfs/dev/pts/
+        else
+            tar --numeric-owner -xpf "$cache/$filename"
+        fi
     fi
 }