Add support for building images on CentOS 32/1432/5
authorJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Wed, 9 Sep 2015 08:56:40 +0000 (10:56 +0200)
committerJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Wed, 9 Sep 2015 16:51:47 +0000 (18:51 +0200)
This is a workaround for building on CentOS.

CentOS don't have nbd so guestfstool is used to mount the
ubuntu image.

The http sources has been changed to ftp as the apt-get
tool inside the Ubuntu image dont work well with http
sources when running on CentOS.

Change-Id: I23679ff034ea76782dcc73d3283cb70ebace5ee8
JIRA: YARDSTICK-136
Signed-off-by: Jo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
tools/ubuntu-server-cloudimg-modify.sh
tools/yardstick-img-modify

index 41d654a..0e9bb41 100755 (executable)
@@ -25,6 +25,10 @@ fi
 # iperf3 only available for trusty in backports
 grep trusty /etc/apt/sources.list && \
     echo "deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
+
+# Workaround for building on CentOS (apt-get is not working with http sources)
+sed -i 's/http/ftp/' /etc/apt/sources.list
+
 apt-get update
 apt-get install -y \
     fio \
index eba8547..c900272 100755 (executable)
@@ -66,15 +66,22 @@ download() {
     cd -
 }
 
-# mount image using qemu-nbd
+# mount image
 setup() {
-    modprobe nbd max_part=16
-    qemu-nbd -c /dev/nbd0 $imgfile
-    partprobe /dev/nbd0
-
     mkdir -p $mountdir
-    mount /dev/nbd0p1 $mountdir
-
+    if [ -f /etc/centos-release ]; then
+        # CentOS, mount image using guestmount.
+        # (needs libguestfs-tools installed)
+        export LIBGUESTFS_BACKEND=direct
+        guestmount -a $imgfile -i --rw $mountdir
+    else
+        # mount image using qemu-nbd
+        modprobe nbd max_part=16
+        qemu-nbd -c /dev/nbd0 $imgfile
+        partprobe /dev/nbd0
+
+        mount /dev/nbd0p1 $mountdir
+    fi
     cp $cmd $mountdir/$(basename $cmd)
 }