Skip to content

Commit c0c4728

Browse files
author
Laszlo Ersek
committed
Makefile.am: factor out "make-physical-machine.sh"
Extract and somewhat generalize the recipe for the $(PHYSICAL_MACHINE) target to a separate shell script. In preparation for the multiple steps we're going to introduce later, redirect virt-builder to a temp file at first (placed in the same directory as the finally expected disk image), and rename that file upon success. Signed-off-by: Laszlo Ersek <[email protected]> Message-Id: <[email protected]> Reviewed-by: Richard W.M. Jones <[email protected]>
1 parent a1eeb11 commit c0c4728

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Makefile.in
4141
/m4/ltsugar.m4
4242
/m4/ltversion.m4
4343
/p2v-config.h
44+
/physical-machine.tmp.*
4445
/podwrapper.pl
4546
/run
4647
/stamp-h1

Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ EXTRA_DIST = \
4141
kiwi-config.xml.in \
4242
launch-virt-p2v \
4343
libguestfs/README \
44+
make-physical-machine.sh \
4445
miniexpect/README \
4546
p2v.ks.in \
4647
p2v.service \
@@ -66,6 +67,7 @@ CLEANFILES += \
6667
$(generated_sources) \
6768
$(PHYSICAL_MACHINE) $(BLANK_DISK) \
6869
about-authors.c \
70+
physical-machine.tmp.* \
6971
stamp-test-virt-p2v-pxe-data-files \
7072
stamp-test-virt-p2v-pxe-kernel \
7173
test-virt-p2v-pxe.authorized_keys \
@@ -255,6 +257,7 @@ if HAVE_LIBGUESTFS
255257
check_DATA += \
256258
$(PHYSICAL_MACHINE) \
257259
$(BLANK_DISK)
260+
check_SCRIPTS = make-physical-machine.sh
258261
endif HAVE_LIBGUESTFS
259262

260263
run-virt-p2v-directly: $(PHYSICAL_MACHINE)
@@ -317,7 +320,7 @@ run-virt-p2v-non-gui-conversion: $(PHYSICAL_MACHINE) stamp-test-virt-p2v-pxe-dat
317320
SLOW=1 $(top_builddir)/run ./test-virt-p2v-pxe.sh
318321

319322
$(PHYSICAL_MACHINE):
320-
$(top_builddir)/run virt-builder --format raw -o $@ fedora-35
323+
$(top_builddir)/run ./make-physical-machine.sh $@
321324

322325
$(BLANK_DISK):
323326
$(top_builddir)/run guestfish -N $@=part exit

make-physical-machine.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash -
2+
# Copyright (C) 2022 Red Hat Inc.
3+
#
4+
# This program is free software; you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation; either version 2 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
set -e -u -C
18+
19+
disk=
20+
21+
cleanup()
22+
{
23+
set +e
24+
if test -n "$disk"; then
25+
rm -f -- "$disk"
26+
disk=
27+
fi
28+
}
29+
30+
trap cleanup EXIT
31+
32+
output=$1
33+
outdir=$(dirname -- "$output")
34+
disk=$(mktemp -p "$outdir" physical-machine.tmp.XXXXXXXXXX)
35+
virt-builder --format raw -o "$disk" fedora-35
36+
mv -- "$disk" "$output"
37+
disk=

0 commit comments

Comments
 (0)