Fix for netperf install in glance image 97/2597/1
authorJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Fri, 16 Oct 2015 13:27:54 +0000 (15:27 +0200)
committerJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Fri, 16 Oct 2015 13:27:54 +0000 (15:27 +0200)
Fixes two issues in the chrooted environment:

- /proc must be mounted when installing certain packages.

- prevent services from starting when installing or updating
packages.

JIRA :-
Signed-off-by: Jo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Change-Id: Ia7180c190bf93c173ea93207ed323ca96662c029

tools/yardstick-img-modify

index 48462b8..ee9a457 100755 (executable)
@@ -78,7 +78,9 @@ setup() {
     loopdevice=$(kpartx -l $raw_imgfile | head -1 | cut -f1 -d ' ')
 
     kpartx -a $raw_imgfile
+
     mount /dev/mapper/$loopdevice $mountdir
+    mount -t proc none $mountdir/proc
 
     cp $cmd $mountdir/$(basename $cmd)
 }
@@ -89,15 +91,24 @@ modify() {
     nameserver_ip=$(grep -m 1 '^nameserver' \
         /etc/resolv.conf | awk '{ print $2 '})
 
+    # prevent init scripts from running during install
+    echo $'#!/bin/sh\nexit 101' >$mountdir/usr/sbin/policy-rc.d
+    chmod a+x $mountdir/usr/sbin/policy-rc.d
+
     chroot $mountdir /$(basename $cmd) $nameserver_ip
 
+    rm -rf $mountdir/usr/sbin/policy-rc.d
+
+    umount -f $mountdir/proc
     umount $mountdir
+
     qemu-img convert -c -o compat=0.10 -O qcow2 $raw_imgfile $imgfile
 }
 
 # cleanup (umount) the image
 cleanup() {
     # designed to be idempotent
+    mount | grep $mountdir/proc && umount $mountdir/proc
     mount | grep $mountdir && umount $mountdir
     if [ -f $raw_imgfile ]; then
         kpartx -d $raw_imgfile || true