diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-04-06 18:49:45 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-04-06 18:49:45 +0100 |
commit | f2ac7c18a775dc10c3fa502f3de5ad01faa0efea (patch) | |
tree | 5a44d8b047ace40cebd5962c3dc054c5feedf32c /tests/guests | |
parent | 418a048215b17dcf1f0c74693831306cbcf0f194 (diff) | |
download | libguestfs-f2ac7c18a775dc10c3fa502f3de5ad01faa0efea.tar.gz libguestfs-f2ac7c18a775dc10c3fa502f3de5ad01faa0efea.tar.xz libguestfs-f2ac7c18a775dc10c3fa502f3de5ad01faa0efea.zip |
tests: Fix guest building so parallel 'make -jN check' works.
This means renaming various temporary files (eg. fstab.tmp) that
several of the scripts were using so they don't conflict
(eg. fstab.tmp.$$).
Also the rule:
fedora-md1.img fedora-md2.img: guest-aux/make-fedora-img.pl
causes the script to run twice in parallel when using 'make -jN'.
Replace this with a stamp file so it runs once:
fedora-md1.img fedora-md2.img: stamp-fedora-md.img
stamp-fedora-md.img: guest-aux/make-fedora-img.pl
Diffstat (limited to 'tests/guests')
-rw-r--r-- | tests/guests/Makefile.am | 8 | ||||
-rwxr-xr-x | tests/guests/guest-aux/make-debian-img.sh | 10 | ||||
-rwxr-xr-x | tests/guests/guest-aux/make-fedora-img.pl | 26 | ||||
-rwxr-xr-x | tests/guests/guest-aux/make-ubuntu-img.sh | 14 | ||||
-rwxr-xr-x | tests/guests/guest-aux/make-windows-img.sh | 4 |
5 files changed, 33 insertions, 29 deletions
diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index 960f708a..e20d91ca 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -40,7 +40,7 @@ EXTRA_DIST = \ # time and we need the tools we have built in order to make it. check_DATA = debian.img fedora.img fedora-md1.img fedora-md2.img ubuntu.img windows.img -CLEANFILES = $(check_DATA) +CLEANFILES = $(check_DATA) stamp-fedora-md.img # Make a (dummy) Fedora image. fedora.img: guest-aux/make-fedora-img.pl \ @@ -52,13 +52,17 @@ fedora.img: guest-aux/make-fedora-img.pl \ ../../run $< # Make a (dummy) Fedora image using md devices -fedora-md1.img fedora-md2.img: guest-aux/make-fedora-img.pl \ +fedora-md1.img fedora-md2.img: stamp-fedora-md.img + +stamp-fedora-md.img: guest-aux/make-fedora-img.pl \ guest-aux/fedora-name.db \ guest-aux/fedora-packages.db + rm -f $@ TMPDIR=$(top_builddir) \ SRCDIR=$(srcdir) \ LAYOUT=partitions-md \ ../../run $< + touch $@ guest-aux/fedora-name.db: guest-aux/fedora-name.db.txt rm -f $@ $@-t diff --git a/tests/guests/guest-aux/make-debian-img.sh b/tests/guests/guest-aux/make-debian-img.sh index f0c1597c..659e8ec5 100755 --- a/tests/guests/guest-aux/make-debian-img.sh +++ b/tests/guests/guest-aux/make-debian-img.sh @@ -22,7 +22,7 @@ export LANG=C set -e # fstab file. -cat > fstab.tmp <<EOF +cat > fstab.tmp.$$ <<EOF LABEL=BOOT /boot ext2 default 0 0 /dev/debian/root / ext2 default 0 0 /dev/debian/usr /usr ext2 default 1 2 @@ -32,7 +32,7 @@ EOF # Create a disk image. ../../run ../../fish/guestfish <<EOF -sparse debian.img.tmp 512M +sparse debian.img.tmp.$$ 512M run # Format the disk. @@ -76,7 +76,7 @@ mkdir /bin mkdir /etc mkdir-p /var/lib/dpkg -upload fstab.tmp /etc/fstab +upload fstab.tmp.$$ /etc/fstab write /etc/debian_version "5.0.1" write /etc/hostname "debian.invalid" @@ -88,5 +88,5 @@ mkdir /boot/grub touch /boot/grub/grub.conf EOF -rm fstab.tmp -mv debian.img.tmp debian.img +rm fstab.tmp.$$ +mv debian.img.tmp.$$ debian.img diff --git a/tests/guests/guest-aux/make-fedora-img.pl b/tests/guests/guest-aux/make-fedora-img.pl index fbc189da..a26a9fd7 100755 --- a/tests/guests/guest-aux/make-fedora-img.pl +++ b/tests/guests/guest-aux/make-fedora-img.pl @@ -38,9 +38,9 @@ foreach ('LAYOUT', 'SRCDIR') { } if ($ENV{LAYOUT} eq 'partitions') { - push (@images, 'fedora.img.tmp'); + push (@images, "fedora.img.tmp.$$"); - open(my $fstab, '>', 'fstab.tmp') or die; + open(my $fstab, '>', "fstab.tmp.$$") or die; print $fstab <<EOF; LABEL=BOOT /boot ext2 default 0 0 LABEL=ROOT / ext2 default 0 0 @@ -50,11 +50,11 @@ EOF $bootdev = '/dev/sda1'; $rootdev = '/dev/sda2'; - open(my $img, '>', 'fedora.img.tmp') or die; + open(my $img, '>', "fedora.img.tmp.$$") or die; truncate($img, 512*1024*1024) or die; close($img) or die; - $g->add_drive('fedora.img.tmp'); + $g->add_drive("fedora.img.tmp.$$"); $g->launch(); $g->part_init('/dev/sda', 'mbr'); @@ -63,9 +63,9 @@ EOF } elsif ($ENV{LAYOUT} eq 'partitions-md') { - push(@images, 'fedora-md1.img.tmp', 'fedora-md2.img.tmp'); + push(@images, "fedora-md1.img.tmp.$$", "fedora-md2.img.tmp.$$"); - open(my $fstab, '>', 'fstab.tmp') or die; + open(my $fstab, '>', "fstab.tmp.$$") or die; print $fstab <<EOF; /dev/md0 /boot ext2 default 0 0 LABEL=ROOT / ext2 default 0 0 @@ -95,7 +95,7 @@ EOF $g->md_create('boot', ['/dev/sda1', '/dev/sdb1']); $g->md_create('root', ['/dev/sda2', '/dev/sdb2']); - open(my $mdadm, '>', 'mdadm.tmp') or die; + open(my $mdadm, '>', "mdadm.tmp.$$") or die; print $mdadm <<EOF; MAILADDR root AUTO +imsm +1.x -all @@ -144,14 +144,14 @@ $g->mkdir('/etc/sysconfig'); $g->mkdir('/usr'); $g->mkdir_p('/var/lib/rpm'); -$g->upload('fstab.tmp', '/etc/fstab'); +$g->upload("fstab.tmp.$$", '/etc/fstab'); $g->write('/etc/redhat-release', 'Fedora release 14 (Phony)'); $g->write('/etc/fedora-release', 'Fedora release 14 (Phony)'); $g->write('/etc/sysconfig/network', 'HOSTNAME=fedora.invalid'); -if (-f 'mdadm.tmp') { - $g->upload('mdadm.tmp', '/etc/mdadm.conf'); - unlink('mdadm.tmp') or die; +if (-f "mdadm.tmp.$$") { + $g->upload("mdadm.tmp.$$", '/etc/mdadm.conf'); + unlink("mdadm.tmp.$$") or die; } $g->upload('guest-aux/fedora-name.db', '/var/lib/rpm/Name'); @@ -190,8 +190,8 @@ $g->mkfs_opts('ext2', '/dev/VG/LV2', blocksize => 1024); $g->mkfs_opts('ext2', '/dev/VG/LV3', blocksize => 2048); # Cleanup -unlink('fstab.tmp') or die; +unlink("fstab.tmp.$$") or die; foreach my $img (@images) { - $img =~ /^(.*)\.tmp$/ or die; + $img =~ /^(.*)\.tmp\.\d+$/ or die; rename($img, $1) or die; } diff --git a/tests/guests/guest-aux/make-ubuntu-img.sh b/tests/guests/guest-aux/make-ubuntu-img.sh index a2b4d173..62f3cc9f 100755 --- a/tests/guests/guest-aux/make-ubuntu-img.sh +++ b/tests/guests/guest-aux/make-ubuntu-img.sh @@ -22,13 +22,13 @@ export LANG=C set -e # fstab file. -cat > fstab.tmp <<EOF +cat > fstab.tmp.$$ <<EOF LABEL=BOOT /boot ext2 default 0 0 /dev/sda2 / ext2 default 1 2 EOF # lsb-release file. -cat > release.tmp <<'EOF' +cat > release.tmp.$$ <<'EOF' DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick @@ -37,7 +37,7 @@ EOF # Create a disk image. ../../run ../../fish/guestfish <<EOF -sparse ubuntu.img.tmp 512M +sparse ubuntu.img.tmp.$$ 512M run # Format the disk. @@ -64,9 +64,9 @@ mkdir /home mkdir /usr mkdir-p /var/lib/dpkg -upload fstab.tmp /etc/fstab +upload fstab.tmp.$$ /etc/fstab write /etc/debian_version "5.0.1" -upload release.tmp /etc/lsb-release +upload release.tmp.$$ /etc/lsb-release write /etc/hostname "ubuntu.invalid" upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status @@ -77,5 +77,5 @@ mkdir /boot/grub touch /boot/grub/grub.conf EOF -rm fstab.tmp release.tmp -mv ubuntu.img.tmp ubuntu.img +rm fstab.tmp.$$ release.tmp.$$ +mv ubuntu.img.tmp.$$ ubuntu.img diff --git a/tests/guests/guest-aux/make-windows-img.sh b/tests/guests/guest-aux/make-windows-img.sh index a6937a99..89a305cd 100755 --- a/tests/guests/guest-aux/make-windows-img.sh +++ b/tests/guests/guest-aux/make-windows-img.sh @@ -37,7 +37,7 @@ fi # Create a disk image. ../../run ../../fish/guestfish <<EOF -sparse windows.img.tmp 512M +sparse windows.img.tmp.$$ 512M run # Format the disk. @@ -68,4 +68,4 @@ touch /autoexec.bat EOF -mv windows.img.tmp windows.img +mv windows.img.tmp.$$ windows.img |