Skip to content

Commit

Permalink
Adding support for specifying migration arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
rdoxenham authored and laenion committed Sep 3, 2024
1 parent 09ae7a7 commit 05692eb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
11 changes: 9 additions & 2 deletions man/transactional-update.8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,19 @@ for more information.
<refsect3 id='i_pkg_commands'><title>Interactive Package Commands</title>
<variablelist>
<varlistentry>
<term><option>migration</option></term>
<term><option>migration</option> <replaceable>arguments</replaceable></term>
<listitem>
<para>
On systems which are registered against the SUSE Customer Center (SCC)
or SMT, a migration to a new version of the installed products can be
made with this option.
made with this option. This command calls <command>zypper migration</command>
with the given <replaceable>arguments</replaceable>.
</para>
<para>
These arguments can be any
<citerefentry project='zypper-migration'><refentrytitle>zypper-migration</refentrytitle><manvolnum>8</manvolnum></citerefentry>
argument, with the exception of "--root", as this is handled by
transactional-update dynamically.
</para>
</listitem>
</varlistentry>
Expand Down
46 changes: 29 additions & 17 deletions sbin/transactional-update.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export DISABLE_SNAPPER_ZYPP_PLUGIN=1
EXITCODE=0
VERBOSITY=2
ZYPPER_ARG=""
ZYPPER_ARG_EXTRA=()
ZYPPER_NONINTERACTIVE="-y --auto-agree-with-product-licenses"
ZYPPER_ARG_PKGS=()
REWRITE_BOOTLOADER=0
REWRITE_GRUB_CFG=0
REWRITE_INITRD=0
Expand Down Expand Up @@ -155,7 +155,7 @@ usage() {
echo "dup Call 'zypper dup' (n)"
echo "up Call 'zypper up' (n)"
echo "patch Call 'zypper patch' (n)"
echo "migration Updates systems registered via SCC / SMT (i)"
echo "migration ... Updates systems registered via SCC / SMT (i)"
echo "pkg install ... Install individual packages (i)"
echo "pkg remove ... Remove individual packages (i)"
echo "pkg update ... Updates individual packages (i)"
Expand Down Expand Up @@ -750,6 +750,21 @@ show_snapshot_status() {

ORIG_ARGS=("$@")

parse_zypper_args_extra() {
while [ 1 ]; do
if [ $# -eq 0 ]; then
break;
else
if [ "$1" == "--root" ]; then
log_error "ERROR: You cannot set '--root' in transactional-update."
quit 1
fi
ZYPPER_ARG_EXTRA+=("$1");
shift
fi
done
}

while [ 1 ]; do
if [ $# -eq 0 ]; then
break
Expand Down Expand Up @@ -818,14 +833,8 @@ while [ 1 ]; do
usage 1
fi

while [ 1 ]; do
if [ $# -eq 0 ]; then
break;
else
ZYPPER_ARG_PKGS+=("$1");
shift
fi
done
parse_zypper_args_extra "$@"
break
;;
migration)
TELEM_CLASS="migration"
Expand All @@ -840,6 +849,9 @@ while [ 1 ]; do
ZYPPER_NONINTERACTIVE=""
fi
shift

parse_zypper_args_extra "$@"
break
;;
bootloader)
test -z "$TELEM_CLASS" && TELEM_CLASS="bootloader"
Expand Down Expand Up @@ -1032,9 +1044,9 @@ if [ "${SETUP_SELINUX}" -eq 1 ]; then
fi
# Check if we need to install packages
for pkg in selinux-policy-targeted container-selinux; do
rpm -q --quiet ${pkg} || ZYPPER_ARG_PKGS+=("${pkg}")
rpm -q --quiet ${pkg} || ZYPPER_ARG_EXTRA+=("${pkg}")
done
if [ ${#ZYPPER_ARG_PKGS[@]} -ne 0 ]; then
if [ ${#ZYPPER_ARG_EXTRA[@]} -ne 0 ]; then
ZYPPER_ARG="install"
fi
REWRITE_INITRD=1
Expand All @@ -1053,9 +1065,9 @@ if [ ${SETUP_KDUMP} -eq 1 ]; then
fi
# Check if we need to install packages
for pkg in kdump; do
rpm -q --quiet ${pkg} || ZYPPER_ARG_PKGS+=("${pkg}")
rpm -q --quiet ${pkg} || ZYPPER_ARG_EXTRA+=("${pkg}")
done
if [ ${#ZYPPER_ARG_PKGS[@]} -ne 0 ]; then
if [ ${#ZYPPER_ARG_EXTRA[@]} -ne 0 ]; then
ZYPPER_ARG="install"
fi
REBUILD_KDUMP_INITRD=1
Expand Down Expand Up @@ -1346,7 +1358,7 @@ if [ -n "${ZYPPER_ARG}" -o ${REWRITE_GRUB_CFG} -eq 1 \
if [ ${DO_MIGRATION} -eq 1 ]; then
# transactional-update migration
export DISABLE_RESTART_ON_UPDATE=yes
tukit ${TUKIT_OPTS} callext "${SNAPSHOT_ID}" zypper ${ZYPPER_ARG} --root {} ${ZYPPER_NONINTERACTIVE} "${ZYPPER_ARG_PKGS[@]}" |& tee -a ${LOGFILE} 1>&${origstdout}
tukit ${TUKIT_OPTS} callext "${SNAPSHOT_ID}" zypper ${ZYPPER_ARG} --root {} ${ZYPPER_NONINTERACTIVE} "${ZYPPER_ARG_EXTRA[@]}" |& tee -a ${LOGFILE} 1>&${origstdout}
RETVAL=${PIPESTATUS[0]}
else
if [ ${DO_CALLEXT} -eq 1 ]; then
Expand All @@ -1356,7 +1368,7 @@ if [ -n "${ZYPPER_ARG}" -o ${REWRITE_GRUB_CFG} -eq 1 \
fi
# Check if there are updates at all.
TMPFILE=`mktemp ${TMPDIR}/transactional-update.XXXXXXXXXX`
${zypper_cmd} --xmlout ${ZYPPER_ARG} -y --auto-agree-with-product-licenses --dry-run "${ZYPPER_ARG_PKGS[@]}" > ${TMPFILE}
${zypper_cmd} --xmlout ${ZYPPER_ARG} -y --auto-agree-with-product-licenses --dry-run "${ZYPPER_ARG_EXTRA[@]}" > ${TMPFILE}
PACKAGE_UPDATES=`grep "install-summary download-size" ${TMPFILE} | sed -e 's|.*install-summary download-size=\"\(.*\)\" space-usage-diff.*|\1|g'`
SIZE_OF_UPDATES=`grep "install-summary.*space-usage-diff" ${TMPFILE} | sed -e 's|.*install-summary.*space-usage-diff=\"\([^"]*\)\".*|\1|g'`
NUM_OF_UPDATES=`grep "install-summary.*packages-to-change" ${TMPFILE} | sed -e 's|.*install-summary.*packages-to-change=\"\([^"]*\)\".*|\1|g'`
Expand All @@ -1374,7 +1386,7 @@ if [ -n "${ZYPPER_ARG}" -o ${REWRITE_GRUB_CFG} -eq 1 \
fi

export DISABLE_RESTART_ON_UPDATE=yes
${zypper_cmd} ${ZYPPER_ARG} ${ZYPPER_NONINTERACTIVE} "${ZYPPER_ARG_PKGS[@]}" |& tee -a ${LOGFILE} 1>&${origstdout}
${zypper_cmd} ${ZYPPER_ARG} ${ZYPPER_NONINTERACTIVE} "${ZYPPER_ARG_EXTRA[@]}" |& tee -a ${LOGFILE} 1>&${origstdout}
RETVAL=${PIPESTATUS[0]}
if [ \( $RETVAL -eq 0 -o $RETVAL -eq 102 -o $RETVAL -eq 103 \) -a -n "${INCLUDES_KERNEL_PACKAGES}" ]; then
${zypper_cmd} -n purge-kernels |& tee -a ${LOGFILE}
Expand Down

0 comments on commit 05692eb

Please sign in to comment.