fix libguestfs.test.simple.create-opensuse-guest.sh
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=259
This commit is contained in:
parent
898c43d60f
commit
7792574f1e
@ -33,28 +33,44 @@ unset ${!LC_*}
|
|||||||
cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1`
|
cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1`
|
||||||
|
|
||||||
output_diskimage=/dev/shm/$LOGNAME/testcase.img
|
output_diskimage=/dev/shm/$LOGNAME/testcase.img
|
||||||
final_repo=http://download.opensuse.org/distribution/12.3/repo/oss/
|
final_repo=http://download.opensuse.org/distribution/13.1/repo/oss/
|
||||||
initial_repo=http://download.opensuse.org/distribution/13.1/repo/oss/
|
initial_repo=http://download.opensuse.org/distribution/12.3/repo/oss/
|
||||||
force=false
|
force=false
|
||||||
guest_zypper_in__pattern_name="base"
|
guest_zypper_in__pattern_name="base"
|
||||||
guest_zypper_in__package_list="less vim grub master-boot-code parted nfs-utils"
|
guest_zypper_in__package_list="less vim grub master-boot-code parted nfs-utils"
|
||||||
guest_root_password="root"
|
guest_root_password="root"
|
||||||
diskname_inside_vm=/dev/sda
|
diskname_inside_vm=/dev/sda
|
||||||
|
|
||||||
|
case "$0" in
|
||||||
|
/*) progname="$0" ;;
|
||||||
|
*) progname="$PWD/$0" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
_exit() {
|
_exit() {
|
||||||
echo "Exiting '$0 $*'."
|
echo "Exiting '$0 $*'."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_unrpm() {
|
||||||
|
CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories"
|
||||||
|
FILES="$@"
|
||||||
|
for f in $FILES; do
|
||||||
|
echo -ne "$f:\t"
|
||||||
|
rpm2cpio $f | cpio ${CPIO_OPTS}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
until test $# -lt 1
|
until test $# -lt 1
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
--unrpm) shift ; _unrpm "$@" ; exit 0 ;;
|
||||||
-n) diskname_inside_vm="$2" ; shift ;;
|
-n) diskname_inside_vm="$2" ; shift ;;
|
||||||
-o) output_diskimage="$2" ; shift ;;
|
-o) output_diskimage="$2" ; shift ;;
|
||||||
-R) initial_repo="$2" ; shift ;;
|
-R) initial_repo="$2" ; shift ;;
|
||||||
-r) final_repo="$2" ; shift ;;
|
-r) final_repo="$2" ; shift ;;
|
||||||
-f) force=true ;;
|
-f) force=true ;;
|
||||||
-x) set -x ;;
|
-x) set -x ;;
|
||||||
*) echo "Unknown option '$1'" exit 1 ;;
|
*) echo "Unknown option '$1'" ; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
@ -82,6 +98,11 @@ then
|
|||||||
_exit
|
_exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
zypper --version
|
||||||
|
cpio --version
|
||||||
|
guestfish --version
|
||||||
|
qemu-system-`uname -m` --version
|
||||||
|
|
||||||
mkdir -vp "${output_diskimage%/*}"
|
mkdir -vp "${output_diskimage%/*}"
|
||||||
td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}`
|
td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}`
|
||||||
tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}`
|
tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}`
|
||||||
@ -142,7 +163,7 @@ zypper \
|
|||||||
--download-only \
|
--download-only \
|
||||||
${packages}
|
${packages}
|
||||||
cd ${dir_root}
|
cd ${dir_root}
|
||||||
find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} unrpm
|
find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} bash "${progname}" --unrpm
|
||||||
mkdir -vp etc/zypp/repos.d
|
mkdir -vp etc/zypp/repos.d
|
||||||
grep -w search /etc/resolv.conf >> etc/resolv.conf
|
grep -w search /etc/resolv.conf >> etc/resolv.conf
|
||||||
echo nameserver 169.254.2.3 >> etc/resolv.conf
|
echo nameserver 169.254.2.3 >> etc/resolv.conf
|
||||||
@ -205,12 +226,31 @@ sh "cp --verbose --sparse=never --remove-destination --target-directory=/boot/gr
|
|||||||
sh "grub --batch --verbose < /etc/grub.conf" : \
|
sh "grub --batch --verbose < /etc/grub.conf" : \
|
||||||
sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||||
sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||||
sh "echo 'Password for root is ${guest_root_password}' >> /etc/issue" : \
|
sh "echo 'Password for User root is: ${guest_root_password}' >> /etc/issue" : \
|
||||||
cat /etc/fstab : \
|
cat /etc/fstab : \
|
||||||
quit
|
quit
|
||||||
ls -lhsS "${output_diskimage}"
|
ls -lhsS "${output_diskimage}"
|
||||||
|
|
||||||
qemu-kvm \
|
: ${diskname_inside_vm}
|
||||||
|
case "${diskname_inside_vm}" in
|
||||||
|
*vda*)
|
||||||
|
qemu_drive_options="
|
||||||
|
-drive file=${output_diskimage},cache=writeback,id=hd0,if=none \
|
||||||
|
-device virtio-blk-pci,drive=hd0 \
|
||||||
|
"
|
||||||
|
;;
|
||||||
|
*sda*)
|
||||||
|
qemu_drive_options="
|
||||||
|
-device virtio-scsi-pci,id=scsi \
|
||||||
|
-drive file=${output_diskimage},cache=unsafe,format=raw,id=hd0,if=none \
|
||||||
|
-device scsi-hd,drive=hd0 \
|
||||||
|
"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "${diskname_inside_vm} not handled"
|
||||||
|
_exit
|
||||||
|
esac
|
||||||
|
qemu-system-`uname -m` -enable-kvm \
|
||||||
-global virtio-blk-pci.scsi=off \
|
-global virtio-blk-pci.scsi=off \
|
||||||
-enable-fips \
|
-enable-fips \
|
||||||
-machine accel=kvm:tcg \
|
-machine accel=kvm:tcg \
|
||||||
@ -218,8 +258,7 @@ qemu-kvm \
|
|||||||
-m 500 \
|
-m 500 \
|
||||||
-no-reboot \
|
-no-reboot \
|
||||||
-no-hpet \
|
-no-hpet \
|
||||||
-drive file=${output_diskimage},cache=writeback,id=hd0,if=none \
|
${qemu_drive_options} \
|
||||||
-device virtio-blk-pci,drive=hd0 \
|
|
||||||
-device virtio-serial-pci \
|
-device virtio-serial-pci \
|
||||||
-serial stdio \
|
-serial stdio \
|
||||||
-device sga \
|
-device sga \
|
||||||
|
Loading…
Reference in New Issue
Block a user