Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test-data: phony-guests: Don't use *.tmp.* temporary files.
  • Loading branch information
rwmjones committed Nov 5, 2015
1 parent 458d7c0 commit 8a72616
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 40 deletions.
3 changes: 1 addition & 2 deletions test-data/phony-guests/Makefile.am
Expand Up @@ -63,8 +63,7 @@ check_DATA = $(disk_images) guests-all-good.xml
CLEANFILES = \
$(check_DATA) \
guests-all-good.xml \
stamp-fedora-md.img \
*.tmp.*
stamp-fedora-md.img

# Make several different blank images. These are not guests, but we
# include them in the libvirt fake XML to make sure that virt-df and
Expand Down
4 changes: 2 additions & 2 deletions test-data/phony-guests/make-archlinux-img.sh
Expand Up @@ -23,7 +23,7 @@ set -e

# Create a disk image.
guestfish <<EOF
sparse archlinux.img.tmp.$$ 512M
sparse archlinux.img-t 512M
run
# Format the disk.
Expand Down Expand Up @@ -55,4 +55,4 @@ mkdir /boot/grub
touch /boot/grub/grub.conf
EOF

mv archlinux.img.tmp.$$ archlinux.img
mv archlinux.img-t archlinux.img
10 changes: 5 additions & 5 deletions test-data/phony-guests/make-coreos-img.sh
Expand Up @@ -22,7 +22,7 @@ export LANG=C
set -e

# lsb-release file.
cat > release.tmp.$$ <<'EOF'
cat > archlinux.release <<'EOF'
DISTRIB_ID=CoreOS
DISTRIB_RELEASE=647.0.0
DISTRIB_CODENAME="Red Dog"
Expand All @@ -31,7 +31,7 @@ EOF

# Create a disk image.
guestfish <<EOF
sparse coreos.img.tmp.$$ 512M
sparse coreos.img-t 512M
run
part-init /dev/sda gpt
Expand Down Expand Up @@ -73,11 +73,11 @@ mkdir /root
mkdir /home
write /etc/coreos/update.conf "GROUP=stable"
upload release.tmp.$$ /usr/share/coreos/lsb-release
upload archlinux.release /usr/share/coreos/lsb-release
ln-s ../usr/share/coreos/lsb-release /etc/lsb-release
write /etc/hostname "coreos.invalid"
EOF

rm release.tmp.$$
mv coreos.img.tmp.$$ coreos.img
rm archlinux.release
mv coreos.img-t coreos.img
10 changes: 5 additions & 5 deletions test-data/phony-guests/make-debian-img.sh
Expand Up @@ -22,7 +22,7 @@ export LANG=C
set -e

# fstab file.
cat > fstab.tmp.$$ <<EOF
cat > debian.fstab <<EOF
LABEL=BOOT /boot ext2 default 0 0
/dev/debian/root / ext2 default 0 0
/dev/debian/usr /usr ext2 default 1 2
Expand All @@ -32,7 +32,7 @@ EOF

# Create a disk image.
guestfish <<EOF
sparse debian.img.tmp.$$ 512M
sparse debian.img-t 512M
run
# Format the disk.
Expand Down Expand Up @@ -78,7 +78,7 @@ mkdir-p /var/lib/dpkg
mkdir /var/lib/urandom
mkdir /var/log
upload fstab.tmp.$$ /etc/fstab
upload debian.fstab /etc/fstab
write /etc/debian_version "5.0.1"
write /etc/hostname "debian.invalid"
Expand All @@ -92,5 +92,5 @@ mkdir /boot/grub
touch /boot/grub/grub.conf
EOF

rm fstab.tmp.$$
mv debian.img.tmp.$$ debian.img
rm debian.fstab
mv debian.img-t debian.img
34 changes: 17 additions & 17 deletions test-data/phony-guests/make-fedora-img.pl
Expand Up @@ -49,9 +49,9 @@
}

if ($ENV{LAYOUT} eq 'partitions') {
push (@images, "fedora.img.tmp.$$");
push (@images, "fedora.img-t");

open (my $fstab, '>', "fstab.tmp.$$") or die;
open (my $fstab, '>', "fedora.fstab") or die;
print $fstab <<EOF;
LABEL=BOOT /boot ext2 default 0 0
LABEL=ROOT / ext2 default 0 0
Expand All @@ -60,9 +60,9 @@

$bootdev = '/dev/sda1';

$g->disk_create ("fedora.img.tmp.$$", "raw", $IMAGE_SIZE);
$g->disk_create ("fedora.img-t", "raw", $IMAGE_SIZE);

$g->add_drive ("fedora.img.tmp.$$");
$g->add_drive ("fedora.img-t");
$g->launch ();

$g->part_init ('/dev/sda', 'mbr');
Expand All @@ -74,9 +74,9 @@
}

elsif ($ENV{LAYOUT} eq 'partitions-md') {
push (@images, "fedora-md1.img.tmp.$$", "fedora-md2.img.tmp.$$");
push (@images, "fedora-md1.img-t", "fedora-md2.img-t");

open (my $fstab, '>', "fstab.tmp.$$") or die;
open (my $fstab, '>', "fedora.fstab") or die;
print $fstab <<EOF;
/dev/md0 /boot ext2 default 0 0
LABEL=ROOT / ext2 default 0 0
Expand All @@ -103,7 +103,7 @@
$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, '>', "fedora.mdadm") or die;
print $mdadm <<EOF;
MAILADDR root
AUTO +imsm +1.x -all
Expand All @@ -123,9 +123,9 @@
}

elsif ($ENV{LAYOUT} eq 'btrfs') {
push (@images, "fedora-btrfs.img.tmp.$$");
push (@images, "fedora-btrfs.img-t");

open (my $fstab, '>', "fstab.tmp.$$") or die;
open (my $fstab, '>', "fedora.fstab") or die;
print $fstab <<EOF;
LABEL=BOOT /boot ext2 default 0 0
LABEL=ROOT / btrfs subvol=root 0 0
Expand All @@ -135,9 +135,9 @@

$bootdev = '/dev/sda1';

$g->disk_create ("fedora-btrfs.img.tmp.$$", "raw", $IMAGE_SIZE);
$g->disk_create ("fedora-btrfs.img-t", "raw", $IMAGE_SIZE);

$g->add_drive ("fedora-btrfs.img.tmp.$$");
$g->add_drive ("fedora-btrfs.img-t");
$g->launch ();

$g->part_init ('/dev/sda', 'mbr');
Expand Down Expand Up @@ -206,15 +206,15 @@ sub init_lvm_root {
$g->lsetxattr ('security.selinux', "system_u:object_r:shadow_t:s0\0", 30,
'/etc/shadow');

$g->upload ("fstab.tmp.$$", '/etc/fstab');
$g->upload ("fedora.fstab", '/etc/fstab');
$g->write ('/etc/motd', "Welcome to Fedora release 14 (Phony)\n");
$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 "fedora.mdadm") {
$g->upload ("fedora.mdadm", '/etc/mdadm.conf');
unlink ("fedora.mdadm") or die;
}

$g->upload ($ENV{SRCDIR}.'/fedora-name.db', '/var/lib/rpm/Name');
Expand Down Expand Up @@ -252,8 +252,8 @@ sub init_lvm_root {
$g->shutdown ();
$g->close ();

unlink ("fstab.tmp.$$") or die;
unlink ("fedora.fstab") or die;
foreach my $img (@images) {
$img =~ /^(.*)\.tmp\.\d+$/ or die;
$img =~ /^(.*)-t$/ or die;
rename ($img, $1) or die;
}
14 changes: 7 additions & 7 deletions test-data/phony-guests/make-ubuntu-img.sh
Expand Up @@ -22,7 +22,7 @@ export LANG=C
set -e

# fstab file.
cat > fstab.tmp.$$ <<EOF
cat > ubuntu.fstab <<EOF
LABEL=BOOT /boot ext2 default 0 0
/dev/sda2 / ext2 default 1 2
Expand All @@ -31,7 +31,7 @@ LABEL=BOOT /boot ext2 default 0 0
EOF

# lsb-release file.
cat > release.tmp.$$ <<'EOF'
cat > ubuntu.release <<'EOF'
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
Expand All @@ -40,7 +40,7 @@ EOF

# Create a disk image.
guestfish <<EOF
sparse ubuntu.img.tmp.$$ 512M
sparse ubuntu.img-t 512M
run
# Format the disk.
Expand Down Expand Up @@ -68,9 +68,9 @@ mkdir /usr
mkdir-p /var/lib/dpkg
mkdir /var/lib/urandom
upload fstab.tmp.$$ /etc/fstab
upload ubuntu.fstab /etc/fstab
write /etc/debian_version "5.0.1"
upload release.tmp.$$ /etc/lsb-release
upload ubuntu.release /etc/lsb-release
write /etc/hostname "ubuntu.invalid"
upload $SRCDIR/debian-packages /var/lib/dpkg/status
Expand All @@ -81,5 +81,5 @@ mkdir /boot/grub
touch /boot/grub/grub.conf
EOF

rm fstab.tmp.$$ release.tmp.$$
mv ubuntu.img.tmp.$$ ubuntu.img
rm ubuntu.fstab ubuntu.release
mv ubuntu.img-t ubuntu.img
4 changes: 2 additions & 2 deletions test-data/phony-guests/make-windows-img.sh
Expand Up @@ -37,7 +37,7 @@ fi

# Create a disk image.
guestfish <<EOF
sparse windows.img.tmp.$$ 512M
sparse windows.img-t 512M
run
# Format the disk.
Expand Down Expand Up @@ -69,4 +69,4 @@ touch /autoexec.bat
EOF

mv windows.img.tmp.$$ windows.img
mv windows.img-t windows.img

0 comments on commit 8a72616

Please sign in to comment.