Skip to content

iso-remaster: improve samples, show how to add answerfile in ISO #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions scripts/iso-remaster/samples/patch-installimg.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
#!/bin/sh
set -e
set -ex

#HOME=/data

# unpacked rootfs to modify
INSTALLIMG="$1"

## Include a locally-modified version of the installer for testing
#HOSTINSTALLER=$HOME/src/xs/host-installer
## - if 8.2: copies a few files too much until we can "make install", but that's harmless
#cp -rv "$HOSTINSTALLER"/* "$INSTALLIMG/opt/xensource/installer/"
## - if 8.3
#make -C "$HOSTINSTALLER" DESTDIR="$INSTALLIMG" XS_MPATH_CONF="$HOME/src/xapi/sm/multipath/multipath.conf"
# # Include an answerfile (also needs answerfile=file:// in patch-iso)
# cp ~/my/preset.xml "$INSTALLIMG/"

# # Include a locally-modified version of the installer for testing
# HOSTINSTALLER=$HOME/src/xs/host-installer
# if [ -r "$HOSTINSTALLER"/Makefile ]; then
# # >= 8.3
# make -C "$HOSTINSTALLER" DESTDIR="$INSTALLIMG" XS_MPATH_CONF="$HOME/src/xapi/sm/multipath/multipath.conf"
# else
# # if 8.2: copies a few files too much until we can "make install", but that's harmless
# cp -rv "$HOSTINSTALLER"/* "$INSTALLIMG/opt/xensource/installer/"
# fi

## Install extra packages - use `rpm` not `yum`, as we had to use `rpm
## --nodeps` during image creation and `yum` will now go on strike.
## Luckily `yumdownloader` still works.
#
#DLDIR="$(mktemp -d)"
#trap "rm -r '$DLDIR'" EXIT INT
#
#yumdownloader --installroot="$INSTALLIMG" --destdir="$DLDIR" --resolve --enablerepo=epel ndisc6 -y
#fakechroot rpm --root="$INSTALLIMG" --install "$DLDIR/*.rpm"
# # Install extra packages - use `rpm` not `yum`, as we had to use `rpm
# # --nodeps` during image creation and `yum` will now go on strike.
# # Luckily `yumdownloader` still works.
# # FIXME: in its current form, his hackish snippet is only expected to work
# # in the xcp-ng build-env container
#
# DLDIR="$(cd $INSTALLIMG && mktemp -d)"
# trap "rm -r '$INSTALLIMG/$DLDIR'" EXIT INT
#
# yumdownloader --installroot="$INSTALLIMG" --destdir="$INSTALLIMG/$DLDIR" --resolve yum-utils -y
# RPMS=$(cd $INSTALLIMG/$DLDIR && echo *.rpm)
# fakechroot sh -c "cd $INSTALLIMG/$DLDIR && rpm --root='$INSTALLIMG' --install $RPMS"
73 changes: 24 additions & 49 deletions scripts/iso-remaster/samples/patch-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,37 @@ set -e

ISODIR="$1"

## remove existing repo sig
#rm -fv "$ISODIR/repodata/repomd.xml.asc"

## remove old repo metadata
#rm -r "$ISODIR/repodata/"

# patches to kernel commandline
SED_COMMANDS=()
# harmless no-op substitution in case no other is added
SED_COMMANDS+=(-e "s@^@@")

## example: customize theme
## remove old rpms
#for p in $(cat <<EOF
# xcp-ng-plymouth-theme-1.0.0-7.xcpng8.3.noarch.rpm
# xcp-ng-release-8.3.0-2.x86_64.rpm
# xcp-ng-release-config-8.3.0-2.x86_64.rpm
# xcp-ng-release-presets-8.3.0-2.x86_64.rpm
# xsconsole-10.1.13-1.xcpng8.3.x86_64.rpm
#EOF
# )
#do
# rm "$ISODIR/Packages/$p"
#done
#
## add the new ones
#for p in $(cat <<EOF
# xcp-ng-plymouth-theme-1.0.0-7.xcpng8.3+newtheme1.noarch.rpm
# xcp-ng-release-8.3.0-2+newtheme1.x86_64.rpm
# xcp-ng-release-config-8.3.0-2+newtheme1.x86_64.rpm
# xcp-ng-release-presets-8.3.0-2+newtheme1.x86_64.rpm
# xsconsole-10.1.13-1.xcpng8.3+newtheme2.x86_64.rpm
#EOF
# )
#do
# cp "$HOME/newtheme/$p" "$ISODIR/Packages/"
#done
#
## installer splash
#cp "$HOME/src/xcp/iso/8.3/boot/isolinux/splash.lss" "$ISODIR/boot/isolinux/"
# # update some RPMs:
# # * remove old repo metadata
# rm -r "$ISODIR/repodata/"
# # * replace RPMs
# cp -p ~/my/Packages/*.rpm "$ISODIR/Packages/"
# # * regenerate repo metadata
# createrepo_c "$ISODIR"
# # * add `no-repo-gpgcheck` so a modified repo will be accepted
# SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz no-repo-gpgcheck@")

# # prevent any reboot on installer error to allow investigating
# SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz atexit=shell@")

## regenerate repodata
#createrepo_c "$ISODIR"
# # activate ssh to installer with given password, eg. to collect logs
# SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz network_device=all sshpassword=passw0rd@")

## patches to kernel commandline
SED_COMMANDS=()
# harmless no-op substitution in case no other is added
SED_COMMANDS+=(-e "s@^@@")
# # get an answerfile over the network
# SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz install answerfile=http://pxe/configs/preset.xml@")

# add `no-repo-gpgcheck` so a modified repo will be accepted
#SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz no-repo-gpgcheck@")
#SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz network_device=lacp:members=eth0,eth1@")
#SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz install answerfile=http://pxe/configs/custom/ydi/lacp.xml@")
#SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz atexit=shell@")
# # get an answerfile from the ISO's install.img (also needs to copy preset in patch-installimg)
# SED_COMMANDS+=(-e "s@/vmlinuz@/vmlinuz install answerfile=file:///preset.xml@")

sed -i "${SED_COMMANDS[@]}" \
"$ISODIR"/*/*/grub*.cfg \
"$ISODIR"/boot/isolinux/isolinux.cfg

## sign with a different key
#gpg1 --armor --detach-sign "$ISODIR/repodata/repomd.xml"
#gpg1 --armor --export > "$ISODIR/RPM-GPG-KEY-xcpng"
# # sign with a different key (needs more work)
# gpg1 --armor --detach-sign "$ISODIR/repodata/repomd.xml"
# gpg1 --armor --export > "$ISODIR/RPM-GPG-KEY-xcpng"