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
loopdevice=$(kpartx -l $raw_imgfile | head -1 | cut -f1 -d ' ')
kpartx -a $raw_imgfile
loopdevice=$(kpartx -l $raw_imgfile | head -1 | cut -f1 -d ' ')
kpartx -a $raw_imgfile
mount /dev/mapper/$loopdevice $mountdir
mount /dev/mapper/$loopdevice $mountdir
+ mount -t proc none $mountdir/proc
cp $cmd $mountdir/$(basename $cmd)
}
cp $cmd $mountdir/$(basename $cmd)
}
nameserver_ip=$(grep -m 1 '^nameserver' \
/etc/resolv.conf | awk '{ print $2 '})
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
chroot $mountdir /$(basename $cmd) $nameserver_ip
+ rm -rf $mountdir/usr/sbin/policy-rc.d
+
+ umount -f $mountdir/proc
qemu-img convert -c -o compat=0.10 -O qcow2 $raw_imgfile $imgfile
}
# cleanup (umount) the image
cleanup() {
# designed to be idempotent
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
mount | grep $mountdir && umount $mountdir
if [ -f $raw_imgfile ]; then
kpartx -d $raw_imgfile || true