Skip to content

Commit

Permalink
Add sysprep & sparsify
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel committed Oct 19, 2023
1 parent de032fb commit f07e2b6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions guestfish/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ DIR_CURR=$(dirname "$0")
GUESTFISH_WORKING_DIR=$DIR_BUILD/_guestfish/$DISTRO
mkdir -p "$GUESTFISH_WORKING_DIR"

# Create image working copy
TMP_IMG="$GUESTFISH_WORKING_DIR/$DISTRO.qcow2"
cp "$SRC_IMG" "$TMP_IMG"

#------------------------------------------------------------------------------
# Guestfish -- run custom scripts
#------------------------------------------------------------------------------
if [ -d "${DIR_CURR}/$DISTRO/scripts" ]; then
# distro specific scripts
SCRIPTS="$(echo ${DIR_CURR}/$DISTRO/scripts/*.sh)"
Expand Down Expand Up @@ -38,6 +42,22 @@ $RUN_SCRIPTS_CMD \

$GUESTFISH_CMD


#------------------------------------------------------------------------------
# Sysprep the image
#------------------------------------------------------------------------------
virt-sysprep --add ${TMP_IMG} \
--selinux-relabel \
--root-password disabled \
--hostname localhost.localdomain \
--run-command 'truncate -s0 -c /etc/machine-id' \
--delete /etc/resolv.conf


#------------------------------------------------------------------------------
# Sparsify and export to destination, cleanup
#------------------------------------------------------------------------------
virt-sparsify --in-place ${TMP_IMG}
qemu-img convert -c -O qcow2 ${TMP_IMG} ${DST_IMG}

rm $TMP_IMG
Expand Down

0 comments on commit f07e2b6

Please sign in to comment.