commit 8ce04dae17d8724b32b031b93a35c266f01987fd Author: Toshaan Bharvani Date: Wed Feb 21 21:33:51 2018 +0100 initial push Signed-off-by: Toshaan Bharvani diff --git a/85system-upgrade-powerel/do-upgrade.sh b/85system-upgrade-powerel/do-upgrade.sh new file mode 100644 index 0000000..23acdf3 --- /dev/null +++ b/85system-upgrade-powerel/do-upgrade.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# actually perform the upgrade, using UPGRADEBIN (set in /etc/conf.d) + +do_upgrade() { + local args="" rv=0 + getargbool 0 rd.upgrade.test && args="$args --testing" + getargbool 0 rd.upgrade.verbose && args="$args --verbose" + getargbool 0 rd.upgrade.debug && args="$args --debug" + + # enable plymouth output unless specifically disabled + getargbool 1 plymouth.enable && args="$args --plymouth" + + # Force selinux into permissive mode unless booted with 'enforcing=1'. + # FIXME: THIS IS A BIG STUPID HAMMER AND WE SHOULD ACTUALLY SOLVE THE ROOT + # PROBLEMS RATHER THAN JUST PAPERING OVER THE WHOLE THING. But this is what + # Anaconda did, and upgrades don't seem to work otherwise, so... + if [ -f /sys/fs/selinux/enforce ]; then + enforce=$(< /sys/fs/selinux/enforce) + getargbool 0 enforcing || echo 0 > /sys/fs/selinux/enforce + fi + # Some bugs this works around: + # https://bugzilla.redhat.com/show_bug.cgi?id=841451 + # https://bugzilla.redhat.com/show_bug.cgi?id=844167 + # others to be filed (mysterious initramfs without kernel modules, etc.) + + # and off we go... + $UPGRADEBIN --root=/sysroot $args + rv=$? + + # backup old product id certificates + chroot $NEWROOT /bin/sh -c 'mkdir /etc/pki/product_old; mv -f /etc/pki/product/*.pem /etc/pki/product_old/' + + # install new product id certificates + chroot $NEWROOT /bin/sh -c 'mv -f /system-upgrade/*.pem /etc/pki/product/' + + # restore things twiddled by workarounds above. TODO: remove! + if [ -f /sys/fs/selinux/enforce ]; then + echo $enforce > /sys/fs/selinux/enforce + fi + return $rv +} + +[ ! -x "$UPGRADEBIN" ] && warn "upgrade binary '$UPGRADEBIN' missing!" && return + +do_upgrade || exit $? diff --git a/85system-upgrade-powerel/keep-initramfs.sh b/85system-upgrade-powerel/keep-initramfs.sh new file mode 100644 index 0000000..678ad62 --- /dev/null +++ b/85system-upgrade-powerel/keep-initramfs.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +die() { warn "$*"; exit 1; } + +upgradedir="${NEWROOT}/system-upgrade-root" + +[ -d "$upgradedir" ] || die "'$upgradedir' doesn't exist" + +echo "saving initramfs to $upgradedir" + +mount -t tmpfs -o mode=755 tmpfs "$upgradedir" \ + || die "Can't mount tmpfs for $upgradedir" + +cp -ax / "$upgradedir" || die "failed to save initramfs to $upgradedir" + +# switch off initrd mode +rm -f "$upgradedir/etc/initrd-release" +# make sure we have os-release +ln -sf "system-upgrade-release" "$upgradedir/etc/os-release" + +create_newroot_dir() { + local newdir="$1" + + # Save the current mount options + # mountinfo consists of lines of the form: + # : ... - + # + # This loops assumes that $NEWROOT is a mount point and that we can + # ignore , since nothing should be mounted in a chroot jail yet + local old_opts="" + local mount_id parent_id major_minor root mount_point options rest + while read -r mount_id parent_id major_minor root mount_point options \ + rest ; do + if [ "$mount_point" = "$NEWROOT" ]; then + old_opts="$options" + break + fi + done < /proc/self/mountinfo + if [ -z "$old_opts" ]; then + old_opts="defaults" + fi + + if [ ! -d "$NEWROOT/$newdir" ]; then + # attempt to create the dir if it's not already present. + # NOTE: this is somewhat unreliable and should be avoided if possible, + # e.g. by making sure the required dirs exist before reboot + mount -o remount,rw "$NEWROOT" + mkdir -p "$NEWROOT/$newdir" + mount -o remount,"$old_opts" "$NEWROOT" + fi +} + +bind_into_newroot() { + local dir="$1" + echo "making /$dir available inside $NEWROOT" + create_newroot_dir "$dir" + mount --bind $upgradedir/$dir $NEWROOT/$dir \ + || warn "failed to bind /$dir into $NEWROOT" + # leave a note for upgrade-prep.service + > $NEWROOT/$dir/.please-unmount +} + +# make our kernel modules available inside the system so we can load drivers +bind_into_newroot lib/modules/$(uname -r) + +# plymouthd will crash if it tries to load a plymouth module from a previous +# version that was ABI-incompatible (e.g. F17 label.so in F18 plymouthd). +plydir=lib/plymouth +[ -d /$plydir ] || plydir=lib64/plymouth +bind_into_newroot $plydir + +# Create /run in $NEWROOT if not already available +create_newroot_dir run + +# If $NEWROOT does not use systemd, mask out initrd-udevadm-cleanup-db since +# nothing will be repopulating the data +[ -x "$NEWROOT/usr/lib/systemd/systemd" ] || \ + ln -sf /dev/null /etc/systemd/system/initrd-udevadm-cleanup-db.service diff --git a/85system-upgrade-powerel/module-setup.sh.in b/85system-upgrade-powerel/module-setup.sh.in new file mode 100644 index 0000000..cf36aeb --- /dev/null +++ b/85system-upgrade-powerel/module-setup.sh.in @@ -0,0 +1,67 @@ +#!/bin/bash + +UPGRADEBIN=@LIBEXECDIR@/system-upgrade-powerel +TOOL_VERSION=@VERSION@ + +check() { + [ -x $UPGRADEBIN ] || return 1 + return 255 +} + +depends() { + echo plymouth +} + +install() { + # write our version info somewhere + { + echo NAME=\"powerel-upgrade-tool\" + echo VERSION=\"$TOOL_VERSION\" + echo ID=powerel-upgrade-dracut + echo VERSION_ID=$TOOL_VERSION + echo PRETTY_NAME=\"powerel-upgrade-dracut-$TOOL_VERSION\" + echo ANSI_COLOR=\"0\;36\" + } > $initdir/etc/system-upgrade-release + # stuff we need for initial boot + # ------------------------------ + # SELinux policy and contexts + dracut_install /etc/selinux/config + dracut_install /etc/selinux/*/policy/* + dracut_install $(find /etc/selinux/*/contexts) + # script to save initramfs at UPGRADEROOT + inst_hook pre-pivot 99 "$moddir/keep-initramfs.sh" + # remove the plymouth text plugin so we get either graphics or details + rm -r ${initdir}/$(plymouth --get-splash-plugin-path)text.so \ + ${initdir}/usr/share/plymouth/themes/text/* + + + # stuff we use in upgrade hook(s) + # ------------------------------- + # upgrader binary + inst_binary $UPGRADEBIN + # config file so we can find it + mkdir -p "${initdir}/etc/conf.d" + echo "UPGRADEBIN=$UPGRADEBIN" > "${initdir}/etc/conf.d/powerel-upgrade-tool.conf" + + # RPM hash/sig checks (via NSS) don't work without these + inst_libdir_file "libfreebl*" "libsqlite*" "libsoftokn*" + + # RPM can't find the rpmdb without rpmconfig + rpmconfig=$(find /etc/rpm /usr/lib/rpm -name "rpmrc" -o -name "macros*") + dracut_install $rpmconfig + + # script to run before the upgrade + inst_hook upgrade-pre 50 "$moddir/prepare-rootfs.sh" + + # script to actually run the upgrader binary + inst_hook upgrade 50 "$moddir/do-upgrade.sh" + + # Run scripts generated by preupgrade-assistant after upgrade + inst_hook upgrade-post 50 "$moddir/preupgrade-postupgrade.sh" + + # clean up after upgrade + inst_hook upgrade-post 70 "$moddir/upgrade-cleanup.sh" + + # save the journal/logs after we're done + inst_hook upgrade-post 99 "$moddir/save-journal.sh" +} diff --git a/85system-upgrade-powerel/move-journal.sh b/85system-upgrade-powerel/move-journal.sh new file mode 100644 index 0000000..63b3906 --- /dev/null +++ b/85system-upgrade-powerel/move-journal.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ -e /var/log/journal ]; then + echo '/var/log/journal exists; not moving journal' + return +fi + +echo "switching journal output to disk" + +journal=/sysroot/var/log/upgrade.journal + +# back up old journal, if present +[ -e $journal ] && rm -rf $journal.old && mv $journal $journal.old + +# make output dir and link to it +mkdir -p $journal /var/log +ln -sf $journal /var/log/journal + +# tell journald to start writing to /var/log/journal +systemctl kill --kill-who=main --signal=SIGUSR1 systemd-journald.service diff --git a/85system-upgrade-powerel/prepare-rootfs.sh b/85system-upgrade-powerel/prepare-rootfs.sh new file mode 100644 index 0000000..68e4932 --- /dev/null +++ b/85system-upgrade-powerel/prepare-rootfs.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +die() { warn "$*"; exit 1; } + +# Check whether converts needs to be run +if [ ! -L "${NEWROOT}/bin" ]; then + convertfs "${NEWROOT}" || die "Unable to convert root filesystem" +fi diff --git a/85system-upgrade-powerel/preupgrade-postupgrade.sh b/85system-upgrade-powerel/preupgrade-postupgrade.sh new file mode 100644 index 0000000..b85cd06 --- /dev/null +++ b/85system-upgrade-powerel/preupgrade-postupgrade.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +POSTUPGRADE_DIR="/root/preupgrade/postupgrade.d" + +echo "Running postupgrade scripts..." + +if [ -d "${NEWROOT}/${POSTUPGRADE_DIR}" ]; then + ( cd $NEWROOT ; + + find "./${POSTUPGRADE_DIR}" -type f -perm /u+x -exec ls -1 {} + | \ + while read -r script ; do + echo "Running ${script##./}..." + scriptdir="$(echo "${script}" | sed 's|^\(.*\)/\([^/]*\)$|\1|')" + scriptbase="$(echo "${script}" | sed 's|^\(.*\)/\([^/]*\)$|\2|')" + chroot . /bin/sh -c "cd \"${scriptdir}\" && ./\"${scriptbase}\"" + done + ) +else + echo "No postupgrade scripts found." +fi + diff --git a/85system-upgrade-powerel/save-journal.sh b/85system-upgrade-powerel/save-journal.sh new file mode 100644 index 0000000..7c61e69 --- /dev/null +++ b/85system-upgrade-powerel/save-journal.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +echo "all upgrade scripts finished" +echo "writing logs to disk and rebooting" + +logfile=/sysroot/var/log/upgrade.log + +# back up old logfile, if present +[ -e $logfile ] && rm -rf $logfile.old && mv $logfile $logfile.old + +# write out the logfile +journalctl -a -m > $logfile diff --git a/85system-upgrade-powerel/upgrade-cleanup.sh b/85system-upgrade-powerel/upgrade-cleanup.sh new file mode 100644 index 0000000..3ecbdc7 --- /dev/null +++ b/85system-upgrade-powerel/upgrade-cleanup.sh @@ -0,0 +1,4 @@ +#!/bin/sh +getargbool 0 rd.upgrade.test && return # skip cleanup if we were just testing +[ "$UPGRADE_STATE" == failed ] && return # skip cleanup on failure +chroot $NEWROOT powerel-upgrade-tool-cli --clean diff --git a/90system-upgrade/README.txt b/90system-upgrade/README.txt new file mode 100644 index 0000000..b38c403 --- /dev/null +++ b/90system-upgrade/README.txt @@ -0,0 +1,38 @@ +system-upgrade +============== +Will Woods +// vim: syn=asciidoc tw=78: + +This module adds targets suitable for system upgrades. + +The upgrade workflow is something like this: + +. Using the *new* distro version, create an initramfs with `system-upgrade`. + * Any other module starting with `system-upgrade-` will be included, e.g.: + * distro-specific upgrade tool + * distro-specific migration scripts + * package-specific migration scripts +. Boot the *new* kernel + initramfs on the system to be upgraded. + * root device is discovered + * distro-specific filesystem migration tasks happen here, using + the `pre-mount` hook + * root device is mounted at `$NEWROOT` + * initramfs copies the `$NEWROOT/system-upgrade` symlink to + `/run/system-upgrade` + * initramfs contents will be copied to `$NEWROOT/system-upgrade-root` + * initramfs does a `switch-root` to the "real" root filesystem +. The system mounts its local disks. +. The system prepares `/system-upgrade-root` + * Mounted filesystems are bind-mounted to `/system-upgrade-root/sysroot` + * distros can unpack their `upgrade.img` into `/system-upgrade-root` here +. The system does a `switch-root` back into the initramfs + * This time we're going to `upgrade.target` instead +. The `upgrade-pre` service/hook runs + * After=`upgrade.target` +. The `upgrade` service/hook runs + * distro-specific upgrade tools should run here +. The `upgrade-post` service/hook runs +. The system is rebooted. + +It's probably a good idea to take a filesystem snapshot in `pre-mount` or +`pre-pivot`. If anything goes wrong, restore the snapshot in `upgrade-post`. diff --git a/90system-upgrade/initrd-system-upgrade-generator b/90system-upgrade/initrd-system-upgrade-generator new file mode 100755 index 0000000..777f773 --- /dev/null +++ b/90system-upgrade/initrd-system-upgrade-generator @@ -0,0 +1,8 @@ +#!/bin/sh + +[ -d "$2" ] || exit 1 + +system_upgrade=$(readlink /sysroot/system-upgrade) +if [ -L /sysroot/system-upgrade -a -d /sysroot/$system_upgrade ]; then + ln -sf /etc/systemd/system/upgrade.target "$2/default.target" +fi diff --git a/90system-upgrade/module-setup.sh b/90system-upgrade/module-setup.sh new file mode 100644 index 0000000..8bad6c3 --- /dev/null +++ b/90system-upgrade/module-setup.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# ex: ts=8 sw=4 sts=4 et filetype=sh + +upgrade_hooks="upgrade-pre upgrade upgrade-post" + +check() { + hookdirs+="$upgrade_hooks " + return 255 +} + +depends() { + echo "systemd" + # pull in any other "system-upgrade-*" modules that exist + local mod_dir mod + for mod_dir in $dracutbasedir/modules.d/[0-9][0-9]*; do + [ -d $mod_dir ] || continue + mod=${mod_dir##*/[0-9][0-9]} + strstr "$mod" "system-upgrade-" && echo $mod + done + return 0 +} + +install() { + # Set UPGRADE env variable + inst_hook cmdline 01 "$moddir/upgrade-init.sh" + # Save copy of $NEWROOT/system-upgrade to /run + inst_hook pre-pivot 99 "$moddir/upgrade-pre-pivot.sh" + + # NOTE: 98systemd copies units from here to /run/systemd/system so systemd + # won't lose our units after switch-root. + unitdir="/etc/systemd/system" + + # Set up systemd target and units + upgrade_wantsdir="${initdir}${unitdir}/upgrade.target.wants" + + inst_simple "$moddir/upgrade.target" "$unitdir/upgrade.target" + + mkdir -p "$upgrade_wantsdir" + for s in $upgrade_hooks; do + inst_simple "$moddir/$s.service" "$unitdir/$s.service" + inst_script "$moddir/$s.sh" "/bin/$s" + ln -sf "../$s.service" $upgrade_wantsdir + done + + # generator to switch to upgrade.target when we return to initrd + generatordir="/usr/lib/systemd/system-generators" + mkdir -p "${initdir}${generatordir}" + inst_script "$moddir/initrd-system-upgrade-generator" \ + "$generatordir/initrd-system-upgrade-generator" + + # upgrade shell service + sysinit_wantsdir="${initdir}${unitdir}/sysinit.target.wants" + mkdir -p $sysinit_wantsdir + inst_simple "$moddir/system-upgrade-shell.service" \ + "$unitdir/system-upgrade-shell.service" + ln -sf "../system-upgrade-shell.service" $sysinit_wantsdir +} + diff --git a/90system-upgrade/system-upgrade-shell.service b/90system-upgrade/system-upgrade-shell.service new file mode 100644 index 0000000..4d32559 --- /dev/null +++ b/90system-upgrade/system-upgrade-shell.service @@ -0,0 +1,26 @@ +[Unit] +Description=Debug shell on tty2 +DefaultDependencies=no +Conflicts=shutdown.target +ConditionKernelCommandLine=!rd.upgrade.noshell + +[Service] +Environment=TERM=linux PS1=system-upgrade:\w\$\x20 +ExecStart=/bin/bash -i -l +Restart=always +RestartSec=0 +StandardInput=tty +TTYPath=/dev/tty2 +TTYReset=yes +TTYVHangup=yes +KillMode=process +IgnoreSIGPIPE=no +# bash ignores SIGTERM +KillSignal=SIGHUP + +# Unset locale for the console getty since the console has problems +# displaying some internationalized messages. +Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION= + +[Install] +WantedBy=sysinit.target diff --git a/90system-upgrade/upgrade-init.sh b/90system-upgrade/upgrade-init.sh new file mode 100644 index 0000000..e4a8127 --- /dev/null +++ b/90system-upgrade/upgrade-init.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +export UPGRADE=1 diff --git a/90system-upgrade/upgrade-post.service b/90system-upgrade/upgrade-post.service new file mode 100644 index 0000000..b8443b8 --- /dev/null +++ b/90system-upgrade/upgrade-post.service @@ -0,0 +1,16 @@ +[Unit] +Description=System Upgrade (post) +Documentation=man:upgrade-post.service(8) +DefaultDependencies=no +After=upgrade.target +After=upgrade.service + +[Service] +Type=oneshot +ExecStart=-/bin/upgrade-post +ExecStopPost=-/usr/bin/systemctl --no-block isolate reboot.target +StandardInput=null +StandardOutput=journal+console +StandardError=journal+console +KillMode=process +KillSignal=SIGHUP diff --git a/90system-upgrade/upgrade-post.sh b/90system-upgrade/upgrade-post.sh new file mode 100755 index 0000000..85492d8 --- /dev/null +++ b/90system-upgrade/upgrade-post.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# upgrade-post hook: last-minute fixes, cleanups, etc. +echo "starting upgrade-post hook" + +export DRACUT_SYSTEMD=1 +if [ -f /dracut-state.sh ]; then + . /dracut-state.sh 2>/dev/null +fi +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +source_conf /etc/conf.d + +getarg 'rd.upgrade.break=post' 'rd.break=upgrade-post' && \ + emergency_shell -n upgrade-post "Break before upgrade-post hook" +source_hook upgrade-post + +exit 0 diff --git a/90system-upgrade/upgrade-pre-pivot.sh b/90system-upgrade/upgrade-pre-pivot.sh new file mode 100644 index 0000000..ab99dec --- /dev/null +++ b/90system-upgrade/upgrade-pre-pivot.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# pause the progress meter - we'll start it back up when the upgrade starts +plymouth pause-progress + +# make a backup copy of the link itself +cp -P ${NEWROOT}/system-upgrade /run/system-upgrade diff --git a/90system-upgrade/upgrade-pre.service b/90system-upgrade/upgrade-pre.service new file mode 100644 index 0000000..dafb930 --- /dev/null +++ b/90system-upgrade/upgrade-pre.service @@ -0,0 +1,15 @@ +[Unit] +Description=System Upgrade (pre) +Documentation=man:upgrade-pre.service(8) +DefaultDependencies=no +After=upgrade.target plymouth-start.service +Before=upgrade.service + +[Service] +Type=oneshot +ExecStart=-/bin/upgrade-pre +StandardInput=null +StandardOutput=journal+console +StandardError=journal+console +KillMode=process +KillSignal=SIGHUP diff --git a/90system-upgrade/upgrade-pre.sh b/90system-upgrade/upgrade-pre.sh new file mode 100755 index 0000000..e4a87ac --- /dev/null +++ b/90system-upgrade/upgrade-pre.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# upgrade-pre hook: before the upgrade, but after the disks are mounted +echo "starting upgrade-pre hook" + +export DRACUT_SYSTEMD=1 +if [ -f /dracut-state.sh ]; then + . /dracut-state.sh 2>/dev/null +fi +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +source_conf /etc/conf.d + +plymouth change-mode --updates && plymouth system-update --progress=0 + +getarg 'rd.upgrade.break=pre' 'rd.break=upgrade-pre' && \ + emergency_shell -n upgrade-pre "Break before upgrade-pre hook" +source_hook upgrade-pre + +exit 0 diff --git a/90system-upgrade/upgrade.service b/90system-upgrade/upgrade.service new file mode 100644 index 0000000..bbefb7e --- /dev/null +++ b/90system-upgrade/upgrade.service @@ -0,0 +1,16 @@ +[Unit] +Description=System Upgrade +Documentation=man:upgrade.service(8) +DefaultDependencies=no +After=upgrade.target +OnFailure=emergency.target +OnFailureIsolate=yes + +[Service] +Type=oneshot +ExecStart=/bin/upgrade +StandardInput=null +StandardOutput=journal+console +StandardError=journal+console +KillMode=process +KillSignal=SIGHUP diff --git a/90system-upgrade/upgrade.sh b/90system-upgrade/upgrade.sh new file mode 100755 index 0000000..159b20c --- /dev/null +++ b/90system-upgrade/upgrade.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# upgrade hook: distro-specific modules will add their upgrade tasks here +echo "starting upgrade hook" + +export DRACUT_SYSTEMD=1 +if [ -f /dracut-state.sh ]; then + . /dracut-state.sh 2>/dev/null +fi +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +source_conf /etc/conf.d + +getarg 'rd.upgrade.break=upgrade' 'rd.break=upgrade' && \ + emergency_shell -n upgrade "Break before upgrade" + +setstate() { + export UPGRADE_STATE="$*" + echo "$UPGRADE_STATE" > $NEWROOT/var/tmp/system-upgrade.state +} + +setstate running + +trap 'setstate failed' EXIT +source_hook upgrade +trap - EXIT + +setstate finished + +exit 0 diff --git a/90system-upgrade/upgrade.target b/90system-upgrade/upgrade.target new file mode 100644 index 0000000..d1f7932 --- /dev/null +++ b/90system-upgrade/upgrade.target @@ -0,0 +1,6 @@ +[Unit] +Description=System Upgrade +Documentation=man:upgrade.target(7) +Requires=sysinit.target sockets.target +After=sysinit.target sockets.target +AllowIsolate=yes diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dd24a42 --- /dev/null +++ b/Makefile @@ -0,0 +1,101 @@ +VERSION=0.8.9 +INSTALL=install -p +SED=sed +LIBEXECDIR=/usr/libexec +DRACUTMODDIR=/usr/lib/dracut/modules.d + +dracut_DIR = $(DRACUTMODDIR)/90system-upgrade +dracut_SCRIPTS = 90system-upgrade/module-setup.sh \ + 90system-upgrade/upgrade-init.sh \ + 90system-upgrade/upgrade-pre-pivot.sh \ + 90system-upgrade/upgrade-pre.sh \ + 90system-upgrade/upgrade.sh \ + 90system-upgrade/upgrade-post.sh \ + 90system-upgrade/initrd-system-upgrade-generator +dracut_DATA = 90system-upgrade/README.txt \ + 90system-upgrade/upgrade.target \ + 90system-upgrade/upgrade-pre.service \ + 90system-upgrade/upgrade.service \ + 90system-upgrade/upgrade-post.service \ + 90system-upgrade/system-upgrade-shell.service + +upgrade_DIR = $(DRACUTMODDIR)/85system-upgrade-powerel +upgrade_BIN = system-upgrade-powerel +upgrade_SCRIPTS = 85system-upgrade-powerel/module-setup.sh \ + 85system-upgrade-powerel/keep-initramfs.sh \ + 85system-upgrade-powerel/prepare-rootfs.sh \ + 85system-upgrade-powerel/do-upgrade.sh \ + 85system-upgrade-powerel/upgrade-cleanup.sh \ + 85system-upgrade-powerel/save-journal.sh \ + 85system-upgrade-powerel/preupgrade-postupgrade.sh + +THEMENAME=powerel-upgrade-tool +THEMESDIR=$(shell pkg-config ply-splash-graphics --variable=themesdir) +plymouth_DIR = $(THEMESDIR)$(THEMENAME) +plymouth_DATA = plymouth/*.png +plymouth_THEME = plymouth/powerel-upgrade-tool.plymouth + +GENFILES = 85system-upgrade-powerel/module-setup.sh powerel-upgrade-dracut.spec + +SCRIPTS = $(dracut_SCRIPTS) $(upgrade_SCRIPTS) +DATA = $(dracut_DATA) $(plymouth_DATA) $(plymouth_THEME) +BIN = $(upgrade_BIN) + +all: $(SCRIPTS) $(DATA) $(BIN) + +PACKAGES=glib-2.0 rpm ply-boot-client + +$(BIN): %: %.c + $(CC) $(shell pkg-config $(PACKAGES) --cflags --libs) $(CFLAGS) $< -o $@ + +$(GENFILES): %: %.in + $(SED) -e 's,@LIBEXECDIR@,$(LIBEXECDIR),g' \ + -e 's,@VERSION@,$(VERSION),g' \ + $< > $@ + +clean: + rm -f $(BIN) $(GENFILES) $(ARCHIVE) upgrade.img + rm -rf rpm + +install: $(BIN) $(SCRIPTS) $(DATA) + $(INSTALL) -d $(DESTDIR)$(LIBEXECDIR) + $(INSTALL) $(BIN) $(DESTDIR)$(LIBEXECDIR) + $(INSTALL) -d $(DESTDIR)$(dracut_DIR) + $(INSTALL) $(dracut_SCRIPTS) $(DESTDIR)$(dracut_DIR) + $(INSTALL) -m644 $(dracut_DATA) $(DESTDIR)$(dracut_DIR) + $(INSTALL) -d $(DESTDIR)$(upgrade_DIR) + $(INSTALL) $(upgrade_SCRIPTS) $(DESTDIR)$(upgrade_DIR) + $(INSTALL) -d $(DESTDIR)$(plymouth_DIR) + $(INSTALL) -m644 $(plymouth_DATA) $(DESTDIR)$(plymouth_DIR) + $(INSTALL) -m644 $(plymouth_THEME) \ + $(DESTDIR)$(plymouth_DIR)/$(THEMENAME).plymouth + +ARCHIVE = powerel-upgrade-dracut-$(VERSION).tar.xz +archive: $(ARCHIVE) +$(ARCHIVE): + git archive --format=tar --prefix=powerel-upgrade-dracut-$(VERSION)/ HEAD \ + | xz -c > $@ || rm $@ + +rpm: $(ARCHIVE) powerel-upgrade-dracut.spec + mkdir -p rpm/build + rpmbuild -ba powerel-upgrade-dracut.spec \ + --define '_specdir $(PWD)' \ + --define '_sourcedir $(PWD)' \ + --define '_specdir $(PWD)' \ + --define '_srcrpmdir $(PWD)/rpm' \ + --define '_rpmdir $(PWD)/rpm' \ + --define '_builddir $(PWD)/rpm/build' + +repo: make-powerel-upgrade-repo + mkdir repo + ./make-powerel-upgrade-repo repo || rm -rf repo + +upgrade.img: + PLYMOUTH_THEME_NAME=$(THEMENAME) \ + dracut --conf /dev/null --confdir /var/empty --add "system-upgrade" \ + --no-hostonly --nolvmconf --nomdadmconf --force --verbose \ + upgrade.img + + + +.PHONY: all clean archive install diff --git a/README.asciidoc b/README.asciidoc new file mode 100644 index 0000000..c8bb5a7 --- /dev/null +++ b/README.asciidoc @@ -0,0 +1,66 @@ +powerel-upgrade-dracut - initramfs environment for PEL Upgrades +================================================================ +Toshaan Bharvani + +This is 'powerel-upgrade-dracut', the initramfs environment for PEL Upgrades. + +This tool is forked from/based upon 'redhat-upgrade-dracut' with original +author Will Woods + +Components +---------- + +It has the following parts: + +`90system-upgrade/` +~~~~~~~~~~~~~~~~~~~ +This module provides a (distro-neutral) framework for running upgrades. + +* Adds three dracut hooks: `upgrade-pre`, `upgrade`, and `upgrade-post`. +* Adds `upgrade.target`, which runs the above hooks (in order) +* Automatically includes any other modules named `system-upgrade-*` +* 'BONUS:' adds system-upgrade-shell.service + +`85system-upgrade-powerel/` +~~~~~~~~~~~~~~~~~~~~~~~~~~ +This is the PEL 'system-upgrade' implementation. + +* Includes upgrade tool, SELinux policy, plymouth, etc. +* Copies initramfs to `$NEWROOT/system-upgrade-root` +* Runs 'system-upgrade-powerel' binary in the `upgrade` hook +* Save log & journal to `/var/log/upgrade.{log,journal}` before reboot + +`system-upgrade-powerel.c` +~~~~~~~~~~~~~~~~~~~~~~~~~ +The actual upgrade tool. + +* Upgrades system using packages from `$UPGRADELINK` +* Sends progress updates to `plymouthd` +* Sends status output to console + journal + +The actual upgrade setup is handled in the main 'powerel-upgrade-tool' package. +Based upon the 'redhat-upgrade-tool', which can be found here: +https://github.com/dashea/powerel-upgrade-tool + +Building +-------- + +You'll want to build the initramfs on the _newer_ distro version. + +. Install build requirements + * 'rpm-devel' >= 4.10.0 + * 'plymouth-devel' >= 0.8.6 + * 'systemd' >= 195 + * 'glib2-devel' +. Install dracut modules + * `make install`, or + .. `make archive` + .. `rpmbuild -ta redhat-upgrade-dracut*.tar.xz` + .. +rpm -ivh '[freshly-built RPMs]'+ +. Build upgrade initramfs + * `OLDTHEME=$(plymouth-set-default-theme)` + * `plymouth-set-default-theme powerel-upgrade-tool` + * `dracut --add system-upgrade upgrade.img` + * `plymouth-set-default-theme $OLDTHEME` + +// vim: set syn=asciidoc tw=78: diff --git a/TODO.asciidoc b/TODO.asciidoc new file mode 100644 index 0000000..351d1c3 --- /dev/null +++ b/TODO.asciidoc @@ -0,0 +1,29 @@ +i18n:: + * Mark strings for translation in `system-upgrade-redhat.c` + +Docs:: + * man pages like whoa + * document boot args (rd.upgrade.*) + +Improve progress reporting:: + * change /etc/*-release so "Welcome to XXX" message says "Welcome to redhat-upgrade-tool" + * count %posttrans scripts, take %posttrans into account for upgrade progress + ** although actually posttrans is only like 1.3% of elapsed time... + * warn user about long-running %post scripts + ** in a perfect world the scripts should do that for us + * use RPMCALLBACK_*_PROGRESS for finer-grained progress + * invoke a callback during pre-transaction RPM header scanning + * Fancier plymouth theme + +Error detection / reporting / handling:: + * Fail if some packages are missing + ** Allow override via commandline arg? + * Add a 'upgrade-failure' callback (for e.g. restoring a backup) + +Upstreaming:: + * get 90system-upgrade upstream + * get save-initramfs.sh into upstream dracut + +Backup/restore:: + * If possible, take LVM/btrfs snapshot before upgrade + * On failure, restore snapshot diff --git a/make-powerel-upgrade-repo b/make-powerel-upgrade-repo new file mode 100755 index 0000000..fe41e53 --- /dev/null +++ b/make-powerel-upgrade-repo @@ -0,0 +1,128 @@ +#!/bin/bash +# +# make-redhat-upgrade-repo - quick script to make a redhat-upgrade-tool usable +# instrepo for testing +# +# Copyright (C) 2012 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# Author: Will Woods + + +# constants and helper functions! +# ------------------------------- +export PLYMOUTH_THEME_NAME=powerel-upgrade-tool +KERNELPATH=vmlinuz +UPGRADEPATH=upgrade.img +die() { echo $(basename $0): error: $@ >&2; exit 1; } +sha256() { set -- $(sha256sum $1); echo "sha256:$1"; } + + +# argument validation stuff! +# -------------------------- +repodir="$1" +kver="${2:-$(uname -r)}" + +[ -z "$1" ] && echo "usage: make-redhat-upgrade-repo REPODIR [KERNELVER]" && exit 1 +[ -d "$repodir" ] || die "directory $repodir doesn't exist. create it first." +[ -f $repodir/repodata/repomd.xml ] || createrepo=1 + +source /etc/os-release 2>/dev/null + +kernel="/boot/vmlinuz-$kver" # NOTE: distro-specific + +# sanity checks! +# -------------- +[ -f "$kernel" ] || die "can't find kernel $kernel" +[ -d "/lib/modules/$kver" ] || die "can't find modules for kernel $kver" + +command -v dracut >/dev/null || die "can't find dracut" +dracut --list-modules 2>/dev/null | grep -q system-upgrade || \ + die "dracut can't find system-upgrade module. install redhat-upgrade-dracut." + +if [ $createrepo ]; then + command -v createrepo >/dev/null || die "can't find createrepo" +fi + + +# actual repo creation! +# --------------------- +[ $(id -u) = 0 ] || die "be root." +# make leading dirs +echo "creating redhat-upgrade-tool-capable repo at $repodir" +mkdir -p "$repodir/$(dirname $KERNELPATH)" \ + "$repodir/$(dirname $UPGRADEPATH)" || \ + die "failed to make required directories." + +# copy kernel into place +echo "* copying kernel to $KERNELPATH" +cp -f $kernel "$repodir/$KERNELPATH" || \ + die "couldn't copy kernel." + +# build upgrade.img +echo "* building $UPGRADEPATH (this will take a moment..)" +dracut --conf /dev/null --confdir $repodir \ + --no-hostonly --nolvmconf --nomdadmconf \ + --add "system-upgrade plymouth-label convertfs" \ + --xz --force "$repodir/$UPGRADEPATH" "$kver" || \ + die "dracut failed to build upgrade.img." + +# write .treeinfo +echo "* writing .treeinfo" +arch=$(uname -m) +cat > $repodir/.treeinfo << __EOT__ || die "couldn't write .treeinfo" +[general] +family = redhat-upgrade-tool +timestamp = $(date '+%s') +arch = $arch +version = ${VERSION_ID:-0} + +[images-$arch] +kernel = $KERNELPATH +upgrade = $UPGRADEPATH + +[checksums] +$KERNELPATH = $(sha256 "$repodir/$KERNELPATH") +$UPGRADEPATH = $(sha256 "$repodir/$UPGRADEPATH") +__EOT__ + + +# create repodata if necessary +if [ $createrepo ]; then + echo "* creating repodata" + createrepo $repodir >/dev/null || die "createrepo failed." +else + echo "* repodata exists, skipping createrepo" +fi + +chmod -R a+r $repodir + +cat > $repodir/serve << '__EOT__' +#!/bin/bash +echo "This repo will be reachable at:" +echo +for ip in $(ip addr | sed -rn 's| *inet ([0-9.]+)/.*|\1|p'); do + echo " http://$ip:${1:-8000}/" +done +echo +python -m SimpleHTTPServer $1 +__EOT__ +chmod 0755 $repodir/serve + +echo "done." + +if [ -z "$VERSION_ID" ]; then + echo "You should probably set 'version' in $repodir/.treeinfo" +fi diff --git a/plymouth/animation-000.png b/plymouth/animation-000.png new file mode 100644 index 0000000..c25229e Binary files /dev/null and b/plymouth/animation-000.png differ diff --git a/plymouth/animation-001.png b/plymouth/animation-001.png new file mode 100644 index 0000000..ceae358 Binary files /dev/null and b/plymouth/animation-001.png differ diff --git a/plymouth/animation-002.png b/plymouth/animation-002.png new file mode 100644 index 0000000..1616345 Binary files /dev/null and b/plymouth/animation-002.png differ diff --git a/plymouth/animation-003.png b/plymouth/animation-003.png new file mode 100644 index 0000000..356c9ec Binary files /dev/null and b/plymouth/animation-003.png differ diff --git a/plymouth/animation-004.png b/plymouth/animation-004.png new file mode 100644 index 0000000..1616345 Binary files /dev/null and b/plymouth/animation-004.png differ diff --git a/plymouth/animation-005.png b/plymouth/animation-005.png new file mode 100644 index 0000000..ceae358 Binary files /dev/null and b/plymouth/animation-005.png differ diff --git a/plymouth/animation-006.png b/plymouth/animation-006.png new file mode 100644 index 0000000..c25229e Binary files /dev/null and b/plymouth/animation-006.png differ diff --git a/plymouth/box.png b/plymouth/box.png new file mode 100644 index 0000000..54876e6 Binary files /dev/null and b/plymouth/box.png differ diff --git a/plymouth/bullet.png b/plymouth/bullet.png new file mode 100644 index 0000000..87ddfe8 Binary files /dev/null and b/plymouth/bullet.png differ diff --git a/plymouth/entry.png b/plymouth/entry.png new file mode 100644 index 0000000..37217b6 Binary files /dev/null and b/plymouth/entry.png differ diff --git a/plymouth/lock.png b/plymouth/lock.png new file mode 100644 index 0000000..a0f8c12 Binary files /dev/null and b/plymouth/lock.png differ diff --git a/plymouth/powerel-upgrade-tool-throb.plymouth b/plymouth/powerel-upgrade-tool-throb.plymouth new file mode 100644 index 0000000..a6cc783 --- /dev/null +++ b/plymouth/powerel-upgrade-tool-throb.plymouth @@ -0,0 +1,13 @@ +[Plymouth Theme] +Name=PowerEL Upgrade Tool +Description=A pulsing progress bar intended for use during system upgrades. +ModuleName=throbgress + +[throbgress] +ImageDir=/usr/share/plymouth/themes/powerel-upgrade-tool +HorizontalAlignment=.5 +VerticalAlignment=.75 +Transition=none +TransitionDuration=0.0 +BackgroundStartColor=0x111111 +BackgroundEndColor=0x111111 diff --git a/plymouth/powerel-upgrade-tool.plymouth b/plymouth/powerel-upgrade-tool.plymouth new file mode 100644 index 0000000..c54542f --- /dev/null +++ b/plymouth/powerel-upgrade-tool.plymouth @@ -0,0 +1,13 @@ +[Plymouth Theme] +Name=PowerEL Upgrade Tool +Description=A pulsing progress bar intended for use during system upgrades. +ModuleName=two-step + +[two-step] +ImageDir=/usr/share/plymouth/themes/powerel-upgrade-tool +HorizontalAlignment=.5 +VerticalAlignment=.5 +Transition=none +TransitionDuration=0.0 +BackgroundStartColor=0x111111 +BackgroundEndColor=0x111111 diff --git a/plymouth/progress-000.png b/plymouth/progress-000.png new file mode 100644 index 0000000..5a5bbc2 Binary files /dev/null and b/plymouth/progress-000.png differ diff --git a/plymouth/progress-001.png b/plymouth/progress-001.png new file mode 100644 index 0000000..b594936 Binary files /dev/null and b/plymouth/progress-001.png differ diff --git a/plymouth/progress-002.png b/plymouth/progress-002.png new file mode 100644 index 0000000..fa40185 Binary files /dev/null and b/plymouth/progress-002.png differ diff --git a/plymouth/progress-003.png b/plymouth/progress-003.png new file mode 100644 index 0000000..53a6d1f Binary files /dev/null and b/plymouth/progress-003.png differ diff --git a/plymouth/progress-004.png b/plymouth/progress-004.png new file mode 100644 index 0000000..04941e9 Binary files /dev/null and b/plymouth/progress-004.png differ diff --git a/plymouth/progress-005.png b/plymouth/progress-005.png new file mode 100644 index 0000000..8b29d50 Binary files /dev/null and b/plymouth/progress-005.png differ diff --git a/plymouth/progress-006.png b/plymouth/progress-006.png new file mode 100644 index 0000000..0840f76 Binary files /dev/null and b/plymouth/progress-006.png differ diff --git a/plymouth/progress-007.png b/plymouth/progress-007.png new file mode 100644 index 0000000..3c955ad Binary files /dev/null and b/plymouth/progress-007.png differ diff --git a/plymouth/progress-008.png b/plymouth/progress-008.png new file mode 100644 index 0000000..9f38c7d Binary files /dev/null and b/plymouth/progress-008.png differ diff --git a/plymouth/progress-009.png b/plymouth/progress-009.png new file mode 100644 index 0000000..a3ee6dc Binary files /dev/null and b/plymouth/progress-009.png differ diff --git a/plymouth/progress-010.png b/plymouth/progress-010.png new file mode 100644 index 0000000..4a2d1d0 Binary files /dev/null and b/plymouth/progress-010.png differ diff --git a/plymouth/progress-011.png b/plymouth/progress-011.png new file mode 100644 index 0000000..8dddfdc Binary files /dev/null and b/plymouth/progress-011.png differ diff --git a/plymouth/progress-012.png b/plymouth/progress-012.png new file mode 100644 index 0000000..db9d7f8 Binary files /dev/null and b/plymouth/progress-012.png differ diff --git a/plymouth/progress-013.png b/plymouth/progress-013.png new file mode 100644 index 0000000..2d3f652 Binary files /dev/null and b/plymouth/progress-013.png differ diff --git a/plymouth/progress-014.png b/plymouth/progress-014.png new file mode 100644 index 0000000..fbcea85 Binary files /dev/null and b/plymouth/progress-014.png differ diff --git a/plymouth/progress-015.png b/plymouth/progress-015.png new file mode 100644 index 0000000..d672a96 Binary files /dev/null and b/plymouth/progress-015.png differ diff --git a/plymouth/progress-016.png b/plymouth/progress-016.png new file mode 100644 index 0000000..bbe53c1 Binary files /dev/null and b/plymouth/progress-016.png differ diff --git a/plymouth/progress-017.png b/plymouth/progress-017.png new file mode 100644 index 0000000..ce6ac84 Binary files /dev/null and b/plymouth/progress-017.png differ diff --git a/plymouth/progress-018.png b/plymouth/progress-018.png new file mode 100644 index 0000000..88b63ad Binary files /dev/null and b/plymouth/progress-018.png differ diff --git a/plymouth/progress-019.png b/plymouth/progress-019.png new file mode 100644 index 0000000..cd7b89d Binary files /dev/null and b/plymouth/progress-019.png differ diff --git a/plymouth/progress-020.png b/plymouth/progress-020.png new file mode 100644 index 0000000..b59fd74 Binary files /dev/null and b/plymouth/progress-020.png differ diff --git a/plymouth/progress-021.png b/plymouth/progress-021.png new file mode 100644 index 0000000..d205df2 Binary files /dev/null and b/plymouth/progress-021.png differ diff --git a/plymouth/progress-022.png b/plymouth/progress-022.png new file mode 100644 index 0000000..10f2cbd Binary files /dev/null and b/plymouth/progress-022.png differ diff --git a/plymouth/progress-023.png b/plymouth/progress-023.png new file mode 100644 index 0000000..5ed5cdb Binary files /dev/null and b/plymouth/progress-023.png differ diff --git a/plymouth/progress-024.png b/plymouth/progress-024.png new file mode 100644 index 0000000..2acbde6 Binary files /dev/null and b/plymouth/progress-024.png differ diff --git a/plymouth/progress-025.png b/plymouth/progress-025.png new file mode 100644 index 0000000..839cb52 Binary files /dev/null and b/plymouth/progress-025.png differ diff --git a/plymouth/progress-026.png b/plymouth/progress-026.png new file mode 100644 index 0000000..c3a6838 Binary files /dev/null and b/plymouth/progress-026.png differ diff --git a/plymouth/progress-027.png b/plymouth/progress-027.png new file mode 100644 index 0000000..36e49da Binary files /dev/null and b/plymouth/progress-027.png differ diff --git a/plymouth/progress-028.png b/plymouth/progress-028.png new file mode 100644 index 0000000..8b67215 Binary files /dev/null and b/plymouth/progress-028.png differ diff --git a/plymouth/progress-029.png b/plymouth/progress-029.png new file mode 100644 index 0000000..97411b5 Binary files /dev/null and b/plymouth/progress-029.png differ diff --git a/plymouth/progress-030.png b/plymouth/progress-030.png new file mode 100644 index 0000000..943ccf8 Binary files /dev/null and b/plymouth/progress-030.png differ diff --git a/plymouth/progress-031.png b/plymouth/progress-031.png new file mode 100644 index 0000000..c417351 Binary files /dev/null and b/plymouth/progress-031.png differ diff --git a/plymouth/progress-032.png b/plymouth/progress-032.png new file mode 100644 index 0000000..02e1fd0 Binary files /dev/null and b/plymouth/progress-032.png differ diff --git a/plymouth/progress-033.png b/plymouth/progress-033.png new file mode 100644 index 0000000..461109c Binary files /dev/null and b/plymouth/progress-033.png differ diff --git a/plymouth/progress-034.png b/plymouth/progress-034.png new file mode 100644 index 0000000..ef002cc Binary files /dev/null and b/plymouth/progress-034.png differ diff --git a/plymouth/progress-035.png b/plymouth/progress-035.png new file mode 100644 index 0000000..0fbefe6 Binary files /dev/null and b/plymouth/progress-035.png differ diff --git a/plymouth/progress-036.png b/plymouth/progress-036.png new file mode 100644 index 0000000..f951b93 Binary files /dev/null and b/plymouth/progress-036.png differ diff --git a/plymouth/progress-037.png b/plymouth/progress-037.png new file mode 100644 index 0000000..d63d4f0 Binary files /dev/null and b/plymouth/progress-037.png differ diff --git a/plymouth/progress-038.png b/plymouth/progress-038.png new file mode 100644 index 0000000..29526bf Binary files /dev/null and b/plymouth/progress-038.png differ diff --git a/plymouth/progress-039.png b/plymouth/progress-039.png new file mode 100644 index 0000000..43b7a71 Binary files /dev/null and b/plymouth/progress-039.png differ diff --git a/plymouth/progress-040.png b/plymouth/progress-040.png new file mode 100644 index 0000000..4a33787 Binary files /dev/null and b/plymouth/progress-040.png differ diff --git a/plymouth/progress-041.png b/plymouth/progress-041.png new file mode 100644 index 0000000..b6944bc Binary files /dev/null and b/plymouth/progress-041.png differ diff --git a/plymouth/progress-042.png b/plymouth/progress-042.png new file mode 100644 index 0000000..3db11c8 Binary files /dev/null and b/plymouth/progress-042.png differ diff --git a/plymouth/progress-043.png b/plymouth/progress-043.png new file mode 100644 index 0000000..05e360f Binary files /dev/null and b/plymouth/progress-043.png differ diff --git a/plymouth/progress-044.png b/plymouth/progress-044.png new file mode 100644 index 0000000..0a95b64 Binary files /dev/null and b/plymouth/progress-044.png differ diff --git a/plymouth/progress-045.png b/plymouth/progress-045.png new file mode 100644 index 0000000..0f5150c Binary files /dev/null and b/plymouth/progress-045.png differ diff --git a/plymouth/progress-046.png b/plymouth/progress-046.png new file mode 100644 index 0000000..6725988 Binary files /dev/null and b/plymouth/progress-046.png differ diff --git a/plymouth/progress-047.png b/plymouth/progress-047.png new file mode 100644 index 0000000..5582380 Binary files /dev/null and b/plymouth/progress-047.png differ diff --git a/plymouth/progress-048.png b/plymouth/progress-048.png new file mode 100644 index 0000000..d422bcf Binary files /dev/null and b/plymouth/progress-048.png differ diff --git a/plymouth/progress-049.png b/plymouth/progress-049.png new file mode 100644 index 0000000..68a73dc Binary files /dev/null and b/plymouth/progress-049.png differ diff --git a/plymouth/progress-050.png b/plymouth/progress-050.png new file mode 100644 index 0000000..33e9bc3 Binary files /dev/null and b/plymouth/progress-050.png differ diff --git a/plymouth/progress-051.png b/plymouth/progress-051.png new file mode 100644 index 0000000..c968643 Binary files /dev/null and b/plymouth/progress-051.png differ diff --git a/plymouth/progress-052.png b/plymouth/progress-052.png new file mode 100644 index 0000000..e997293 Binary files /dev/null and b/plymouth/progress-052.png differ diff --git a/plymouth/progress-053.png b/plymouth/progress-053.png new file mode 100644 index 0000000..3ec758a Binary files /dev/null and b/plymouth/progress-053.png differ diff --git a/plymouth/progress-054.png b/plymouth/progress-054.png new file mode 100644 index 0000000..2f97a87 Binary files /dev/null and b/plymouth/progress-054.png differ diff --git a/plymouth/progress-055.png b/plymouth/progress-055.png new file mode 100644 index 0000000..135a132 Binary files /dev/null and b/plymouth/progress-055.png differ diff --git a/plymouth/progress-056.png b/plymouth/progress-056.png new file mode 100644 index 0000000..22f2e4a Binary files /dev/null and b/plymouth/progress-056.png differ diff --git a/plymouth/progress-057.png b/plymouth/progress-057.png new file mode 100644 index 0000000..5df9c55 Binary files /dev/null and b/plymouth/progress-057.png differ diff --git a/plymouth/progress-058.png b/plymouth/progress-058.png new file mode 100644 index 0000000..1c42970 Binary files /dev/null and b/plymouth/progress-058.png differ diff --git a/plymouth/progress-059.png b/plymouth/progress-059.png new file mode 100644 index 0000000..ce0a386 Binary files /dev/null and b/plymouth/progress-059.png differ diff --git a/plymouth/progress-060.png b/plymouth/progress-060.png new file mode 100644 index 0000000..bc37b2f Binary files /dev/null and b/plymouth/progress-060.png differ diff --git a/plymouth/progress-061.png b/plymouth/progress-061.png new file mode 100644 index 0000000..09d37f9 Binary files /dev/null and b/plymouth/progress-061.png differ diff --git a/plymouth/progress-062.png b/plymouth/progress-062.png new file mode 100644 index 0000000..8125c17 Binary files /dev/null and b/plymouth/progress-062.png differ diff --git a/plymouth/progress-063.png b/plymouth/progress-063.png new file mode 100644 index 0000000..825fe07 Binary files /dev/null and b/plymouth/progress-063.png differ diff --git a/plymouth/progress-064.png b/plymouth/progress-064.png new file mode 100644 index 0000000..59e865d Binary files /dev/null and b/plymouth/progress-064.png differ diff --git a/plymouth/progress-065.png b/plymouth/progress-065.png new file mode 100644 index 0000000..c448ceb Binary files /dev/null and b/plymouth/progress-065.png differ diff --git a/plymouth/progress-066.png b/plymouth/progress-066.png new file mode 100644 index 0000000..e52f944 Binary files /dev/null and b/plymouth/progress-066.png differ diff --git a/plymouth/progress-067.png b/plymouth/progress-067.png new file mode 100644 index 0000000..9c5e806 Binary files /dev/null and b/plymouth/progress-067.png differ diff --git a/plymouth/progress-068.png b/plymouth/progress-068.png new file mode 100644 index 0000000..494ddb8 Binary files /dev/null and b/plymouth/progress-068.png differ diff --git a/plymouth/progress-069.png b/plymouth/progress-069.png new file mode 100644 index 0000000..665a7b6 Binary files /dev/null and b/plymouth/progress-069.png differ diff --git a/plymouth/progress-070.png b/plymouth/progress-070.png new file mode 100644 index 0000000..6e1e260 Binary files /dev/null and b/plymouth/progress-070.png differ diff --git a/plymouth/progress-071.png b/plymouth/progress-071.png new file mode 100644 index 0000000..30cce82 Binary files /dev/null and b/plymouth/progress-071.png differ diff --git a/plymouth/progress-072.png b/plymouth/progress-072.png new file mode 100644 index 0000000..5a9b9f3 Binary files /dev/null and b/plymouth/progress-072.png differ diff --git a/plymouth/progress-073.png b/plymouth/progress-073.png new file mode 100644 index 0000000..6c6cf4d Binary files /dev/null and b/plymouth/progress-073.png differ diff --git a/plymouth/progress-074.png b/plymouth/progress-074.png new file mode 100644 index 0000000..f05f8c9 Binary files /dev/null and b/plymouth/progress-074.png differ diff --git a/plymouth/progress-075.png b/plymouth/progress-075.png new file mode 100644 index 0000000..2ed7702 Binary files /dev/null and b/plymouth/progress-075.png differ diff --git a/plymouth/progress-076.png b/plymouth/progress-076.png new file mode 100644 index 0000000..dae8550 Binary files /dev/null and b/plymouth/progress-076.png differ diff --git a/plymouth/progress-077.png b/plymouth/progress-077.png new file mode 100644 index 0000000..f64cc0f Binary files /dev/null and b/plymouth/progress-077.png differ diff --git a/plymouth/progress-078.png b/plymouth/progress-078.png new file mode 100644 index 0000000..446eda8 Binary files /dev/null and b/plymouth/progress-078.png differ diff --git a/plymouth/progress-079.png b/plymouth/progress-079.png new file mode 100644 index 0000000..4501fe8 Binary files /dev/null and b/plymouth/progress-079.png differ diff --git a/plymouth/progress-080.png b/plymouth/progress-080.png new file mode 100644 index 0000000..d2c939d Binary files /dev/null and b/plymouth/progress-080.png differ diff --git a/plymouth/progress-081.png b/plymouth/progress-081.png new file mode 100644 index 0000000..399ae5a Binary files /dev/null and b/plymouth/progress-081.png differ diff --git a/plymouth/progress-082.png b/plymouth/progress-082.png new file mode 100644 index 0000000..e7fd9b9 Binary files /dev/null and b/plymouth/progress-082.png differ diff --git a/plymouth/progress-083.png b/plymouth/progress-083.png new file mode 100644 index 0000000..eb9d89c Binary files /dev/null and b/plymouth/progress-083.png differ diff --git a/plymouth/progress-084.png b/plymouth/progress-084.png new file mode 100644 index 0000000..a60b34b Binary files /dev/null and b/plymouth/progress-084.png differ diff --git a/plymouth/progress-085.png b/plymouth/progress-085.png new file mode 100644 index 0000000..65dbaec Binary files /dev/null and b/plymouth/progress-085.png differ diff --git a/plymouth/progress-086.png b/plymouth/progress-086.png new file mode 100644 index 0000000..6921920 Binary files /dev/null and b/plymouth/progress-086.png differ diff --git a/plymouth/progress-087.png b/plymouth/progress-087.png new file mode 100644 index 0000000..bdb2d03 Binary files /dev/null and b/plymouth/progress-087.png differ diff --git a/plymouth/progress-088.png b/plymouth/progress-088.png new file mode 100644 index 0000000..03ad81c Binary files /dev/null and b/plymouth/progress-088.png differ diff --git a/plymouth/progress-089.png b/plymouth/progress-089.png new file mode 100644 index 0000000..cfc21a5 Binary files /dev/null and b/plymouth/progress-089.png differ diff --git a/plymouth/progress-090.png b/plymouth/progress-090.png new file mode 100644 index 0000000..08617c4 Binary files /dev/null and b/plymouth/progress-090.png differ diff --git a/plymouth/progress-091.png b/plymouth/progress-091.png new file mode 100644 index 0000000..bd75860 Binary files /dev/null and b/plymouth/progress-091.png differ diff --git a/plymouth/progress-092.png b/plymouth/progress-092.png new file mode 100644 index 0000000..2c0f67c Binary files /dev/null and b/plymouth/progress-092.png differ diff --git a/plymouth/progress-093.png b/plymouth/progress-093.png new file mode 100644 index 0000000..0153fd0 Binary files /dev/null and b/plymouth/progress-093.png differ diff --git a/plymouth/progress-094.png b/plymouth/progress-094.png new file mode 100644 index 0000000..c32b60c Binary files /dev/null and b/plymouth/progress-094.png differ diff --git a/plymouth/progress-095.png b/plymouth/progress-095.png new file mode 100644 index 0000000..bcd3e55 Binary files /dev/null and b/plymouth/progress-095.png differ diff --git a/plymouth/progress-096.png b/plymouth/progress-096.png new file mode 100644 index 0000000..8dc9d5b Binary files /dev/null and b/plymouth/progress-096.png differ diff --git a/plymouth/progress-097.png b/plymouth/progress-097.png new file mode 100644 index 0000000..bf68cac Binary files /dev/null and b/plymouth/progress-097.png differ diff --git a/plymouth/progress-098.png b/plymouth/progress-098.png new file mode 100644 index 0000000..c5172f2 Binary files /dev/null and b/plymouth/progress-098.png differ diff --git a/plymouth/progress-099.png b/plymouth/progress-099.png new file mode 100644 index 0000000..af33b68 Binary files /dev/null and b/plymouth/progress-099.png differ diff --git a/plymouth/progress-100.png b/plymouth/progress-100.png new file mode 100644 index 0000000..d370a28 Binary files /dev/null and b/plymouth/progress-100.png differ diff --git a/plymouth/progress-101.png b/plymouth/progress-101.png new file mode 100644 index 0000000..95f4ade Binary files /dev/null and b/plymouth/progress-101.png differ diff --git a/plymouth/progress-102.png b/plymouth/progress-102.png new file mode 100644 index 0000000..3bcab97 Binary files /dev/null and b/plymouth/progress-102.png differ diff --git a/plymouth/progress-103.png b/plymouth/progress-103.png new file mode 100644 index 0000000..3cce191 Binary files /dev/null and b/plymouth/progress-103.png differ diff --git a/plymouth/progress-104.png b/plymouth/progress-104.png new file mode 100644 index 0000000..7399d58 Binary files /dev/null and b/plymouth/progress-104.png differ diff --git a/plymouth/progress-105.png b/plymouth/progress-105.png new file mode 100644 index 0000000..8b7abff Binary files /dev/null and b/plymouth/progress-105.png differ diff --git a/plymouth/progress-106.png b/plymouth/progress-106.png new file mode 100644 index 0000000..200a508 Binary files /dev/null and b/plymouth/progress-106.png differ diff --git a/plymouth/progress-107.png b/plymouth/progress-107.png new file mode 100644 index 0000000..e0184e5 Binary files /dev/null and b/plymouth/progress-107.png differ diff --git a/plymouth/progress-108.png b/plymouth/progress-108.png new file mode 100644 index 0000000..dc9a0e1 Binary files /dev/null and b/plymouth/progress-108.png differ diff --git a/plymouth/progress-109.png b/plymouth/progress-109.png new file mode 100644 index 0000000..50d432a Binary files /dev/null and b/plymouth/progress-109.png differ diff --git a/plymouth/progress-110.png b/plymouth/progress-110.png new file mode 100644 index 0000000..18b6f31 Binary files /dev/null and b/plymouth/progress-110.png differ diff --git a/plymouth/progress-111.png b/plymouth/progress-111.png new file mode 100644 index 0000000..c7e3fd9 Binary files /dev/null and b/plymouth/progress-111.png differ diff --git a/plymouth/progress-112.png b/plymouth/progress-112.png new file mode 100644 index 0000000..6afb4a5 Binary files /dev/null and b/plymouth/progress-112.png differ diff --git a/plymouth/progress-113.png b/plymouth/progress-113.png new file mode 100644 index 0000000..760ac65 Binary files /dev/null and b/plymouth/progress-113.png differ diff --git a/plymouth/progress-114.png b/plymouth/progress-114.png new file mode 100644 index 0000000..b2868cb Binary files /dev/null and b/plymouth/progress-114.png differ diff --git a/plymouth/progress-115.png b/plymouth/progress-115.png new file mode 100644 index 0000000..046f8eb Binary files /dev/null and b/plymouth/progress-115.png differ diff --git a/plymouth/progress-116.png b/plymouth/progress-116.png new file mode 100644 index 0000000..5c4a2c2 Binary files /dev/null and b/plymouth/progress-116.png differ diff --git a/plymouth/progress-117.png b/plymouth/progress-117.png new file mode 100644 index 0000000..f33abd9 Binary files /dev/null and b/plymouth/progress-117.png differ diff --git a/plymouth/progress-118.png b/plymouth/progress-118.png new file mode 100644 index 0000000..fb0654b Binary files /dev/null and b/plymouth/progress-118.png differ diff --git a/plymouth/progress-119.png b/plymouth/progress-119.png new file mode 100644 index 0000000..0682e68 Binary files /dev/null and b/plymouth/progress-119.png differ diff --git a/plymouth/progress-120.png b/plymouth/progress-120.png new file mode 100644 index 0000000..7124ea5 Binary files /dev/null and b/plymouth/progress-120.png differ diff --git a/plymouth/progress-121.png b/plymouth/progress-121.png new file mode 100644 index 0000000..c8bd5f2 Binary files /dev/null and b/plymouth/progress-121.png differ diff --git a/plymouth/progress-122.png b/plymouth/progress-122.png new file mode 100644 index 0000000..5f90ff4 Binary files /dev/null and b/plymouth/progress-122.png differ diff --git a/plymouth/progress-123.png b/plymouth/progress-123.png new file mode 100644 index 0000000..4290025 Binary files /dev/null and b/plymouth/progress-123.png differ diff --git a/plymouth/progress-124.png b/plymouth/progress-124.png new file mode 100644 index 0000000..e4926bb Binary files /dev/null and b/plymouth/progress-124.png differ diff --git a/plymouth/throbber-000.png b/plymouth/throbber-000.png new file mode 100644 index 0000000..6179cab Binary files /dev/null and b/plymouth/throbber-000.png differ diff --git a/plymouth/throbber-001.png b/plymouth/throbber-001.png new file mode 100644 index 0000000..400d776 Binary files /dev/null and b/plymouth/throbber-001.png differ diff --git a/plymouth/throbber-002.png b/plymouth/throbber-002.png new file mode 100644 index 0000000..8a12dd8 Binary files /dev/null and b/plymouth/throbber-002.png differ diff --git a/plymouth/throbber-003.png b/plymouth/throbber-003.png new file mode 100644 index 0000000..e9e0ca7 Binary files /dev/null and b/plymouth/throbber-003.png differ diff --git a/plymouth/throbber-004.png b/plymouth/throbber-004.png new file mode 100644 index 0000000..fe5b074 Binary files /dev/null and b/plymouth/throbber-004.png differ diff --git a/plymouth/throbber-005.png b/plymouth/throbber-005.png new file mode 100644 index 0000000..44b8630 Binary files /dev/null and b/plymouth/throbber-005.png differ diff --git a/plymouth/throbber-006.png b/plymouth/throbber-006.png new file mode 100644 index 0000000..b65e60c Binary files /dev/null and b/plymouth/throbber-006.png differ diff --git a/plymouth/throbber-007.png b/plymouth/throbber-007.png new file mode 100644 index 0000000..100de65 Binary files /dev/null and b/plymouth/throbber-007.png differ diff --git a/plymouth/throbber-008.png b/plymouth/throbber-008.png new file mode 100644 index 0000000..ebed5f3 Binary files /dev/null and b/plymouth/throbber-008.png differ diff --git a/plymouth/throbber-009.png b/plymouth/throbber-009.png new file mode 100644 index 0000000..e54a38d Binary files /dev/null and b/plymouth/throbber-009.png differ diff --git a/plymouth/throbber-010.png b/plymouth/throbber-010.png new file mode 100644 index 0000000..79656fa Binary files /dev/null and b/plymouth/throbber-010.png differ diff --git a/plymouth/throbber-011.png b/plymouth/throbber-011.png new file mode 100644 index 0000000..10c56d7 Binary files /dev/null and b/plymouth/throbber-011.png differ diff --git a/plymouth/throbber-012.png b/plymouth/throbber-012.png new file mode 100644 index 0000000..9c5a35b Binary files /dev/null and b/plymouth/throbber-012.png differ diff --git a/plymouth/throbber-013.png b/plymouth/throbber-013.png new file mode 100644 index 0000000..5e75a5c Binary files /dev/null and b/plymouth/throbber-013.png differ diff --git a/plymouth/throbber-014.png b/plymouth/throbber-014.png new file mode 100644 index 0000000..ddebc63 Binary files /dev/null and b/plymouth/throbber-014.png differ diff --git a/plymouth/throbber-015.png b/plymouth/throbber-015.png new file mode 100644 index 0000000..1432c4f Binary files /dev/null and b/plymouth/throbber-015.png differ diff --git a/plymouth/throbber-016.png b/plymouth/throbber-016.png new file mode 100644 index 0000000..ddebc63 Binary files /dev/null and b/plymouth/throbber-016.png differ diff --git a/plymouth/throbber-017.png b/plymouth/throbber-017.png new file mode 100644 index 0000000..5e75a5c Binary files /dev/null and b/plymouth/throbber-017.png differ diff --git a/plymouth/throbber-018.png b/plymouth/throbber-018.png new file mode 100644 index 0000000..9c5a35b Binary files /dev/null and b/plymouth/throbber-018.png differ diff --git a/plymouth/throbber-019.png b/plymouth/throbber-019.png new file mode 100644 index 0000000..10c56d7 Binary files /dev/null and b/plymouth/throbber-019.png differ diff --git a/plymouth/throbber-020.png b/plymouth/throbber-020.png new file mode 100644 index 0000000..79656fa Binary files /dev/null and b/plymouth/throbber-020.png differ diff --git a/plymouth/throbber-021.png b/plymouth/throbber-021.png new file mode 100644 index 0000000..e54a38d Binary files /dev/null and b/plymouth/throbber-021.png differ diff --git a/plymouth/throbber-022.png b/plymouth/throbber-022.png new file mode 100644 index 0000000..ebed5f3 Binary files /dev/null and b/plymouth/throbber-022.png differ diff --git a/plymouth/throbber-023.png b/plymouth/throbber-023.png new file mode 100644 index 0000000..100de65 Binary files /dev/null and b/plymouth/throbber-023.png differ diff --git a/plymouth/throbber-024.png b/plymouth/throbber-024.png new file mode 100644 index 0000000..b65e60c Binary files /dev/null and b/plymouth/throbber-024.png differ diff --git a/plymouth/throbber-025.png b/plymouth/throbber-025.png new file mode 100644 index 0000000..44b8630 Binary files /dev/null and b/plymouth/throbber-025.png differ diff --git a/plymouth/throbber-026.png b/plymouth/throbber-026.png new file mode 100644 index 0000000..fe5b074 Binary files /dev/null and b/plymouth/throbber-026.png differ diff --git a/plymouth/throbber-027.png b/plymouth/throbber-027.png new file mode 100644 index 0000000..e9e0ca7 Binary files /dev/null and b/plymouth/throbber-027.png differ diff --git a/plymouth/throbber-028.png b/plymouth/throbber-028.png new file mode 100644 index 0000000..8a12dd8 Binary files /dev/null and b/plymouth/throbber-028.png differ diff --git a/plymouth/throbber-029.png b/plymouth/throbber-029.png new file mode 100644 index 0000000..400d776 Binary files /dev/null and b/plymouth/throbber-029.png differ diff --git a/system-upgrade-powerel.c b/system-upgrade-powerel.c new file mode 100644 index 0000000..308e6a3 --- /dev/null +++ b/system-upgrade-powerel.c @@ -0,0 +1,676 @@ +/* system-upgrade-redhat.c: upgrade a RHEL system + * + * Copyright © 2012 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * Author(s): Will Woods + */ + +#include + +#include +#include + +#include +#include +#include /* rpmShowProgress */ + +/* i18n */ +#define GETTEXT_PACKAGE "redhat-upgrade-tool" +#include +#include + +/* File names and locations */ +#define UPGRADE_SYMLINK "system-upgrade" +#define UPGRADE_FILELIST "package.list" + +/* How much of the progress bar should each phase use? */ +#define SETUP_PERCENT 4 +#define TRANS_PERCENT 2 +#define INSTALL_BASE_PERCENT (SETUP_PERCENT+TRANS_PERCENT) +#define INSTALL_PERCENT 70 +#define ERASE_PERCENT 24 +/* TODO: add POSTTRANS_PERCENT */ + +/* globals */ +gchar *packagedir = NULL; /* target of UPGRADE_SYMLINK */ +guint installcount = 0; /* number of installs in transaction */ +guint erasecount = 0; /* number of erases in transaction */ + +/* commandline options */ +static gboolean testing = FALSE; +static gboolean plymouth = FALSE; +static gboolean plymouth_verbose = FALSE; +static gboolean debug = FALSE; +static gchar *root = "/"; + +static GOptionEntry options[] = +{ + { "testing", 'n', 0, G_OPTION_ARG_NONE, &testing, + "Test mode - don't actually install anything", NULL }, + { "root", 'r', 0, G_OPTION_ARG_FILENAME, &root, + "Top level directory for upgrade (default: \"/\")", NULL }, + { "plymouth", 'p', 0, G_OPTION_ARG_NONE, &plymouth, + "Show progress on plymouth splash screen", NULL }, + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &plymouth_verbose, + "Show detailed info on plymouth splash screen", NULL }, + { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, + "Print copious debugging info", NULL }, + { NULL } +}; + +/****************** + * Plymouth stuff * + ******************/ + +#include "ply-boot-client.h" + +typedef struct +{ + ply_boot_client_t *client; + ply_event_loop_t *loop; +} ply_t; + +ply_t ply = { 0 }; + +/* callback handlers */ +void ply_success(void *user_data, ply_boot_client_t *client) { + ply_event_loop_exit(ply.loop, TRUE); +} +void ply_failure(void *user_data, ply_boot_client_t *client) { + ply_event_loop_exit(ply.loop, FALSE); +} +void ply_disconnect(void *user_data) { + g_warning("unexpectedly disconnected from plymouth"); + plymouth = FALSE; + ply_event_loop_exit(ply.loop, FALSE); + /* TODO: attempt reconnect? */ +} + +/* display-message */ +gboolean set_plymouth_message(const gchar *message) { + if (!plymouth) + return TRUE; + ply_boot_client_attach_to_event_loop(ply.client, ply.loop); + if (message == NULL || *message == '\0') + ply_boot_client_tell_daemon_to_hide_message(ply.client, message, + ply_success, ply_failure, &ply); + else + ply_boot_client_tell_daemon_to_display_message(ply.client, message, + ply_success, ply_failure, &ply); + return ply_event_loop_run(ply.loop); +} + +/* system-update */ +gboolean set_plymouth_percent(const guint percent) { + gchar *percentstr; + if (!plymouth) + return TRUE; + percentstr = g_strdup_printf("%u", percent); + ply_boot_client_attach_to_event_loop(ply.client, ply.loop); + ply_boot_client_system_update(ply.client, percentstr, + ply_success, ply_failure, &ply); + g_free(percentstr); /* this is OK - plymouth strdups percentstr */ + return ply_event_loop_run(ply.loop); +} + +gboolean plymouth_setup(void) { + gboolean plymouth_ok = FALSE; + + ply.loop = ply_event_loop_new(); + ply.client = ply_boot_client_new(); + + if (!ply_boot_client_connect(ply.client, + (ply_boot_client_disconnect_handler_t) ply_disconnect, + &ply)) { + g_warning("Couldn't connect to plymouth"); + return FALSE; + } + + ply_boot_client_attach_to_event_loop(ply.client, ply.loop); + ply_boot_client_ping_daemon(ply.client, ply_success, ply_failure, &ply); + plymouth_ok = ply_event_loop_run(ply.loop); + + if (!plymouth_ok) + ply_boot_client_free(ply.client); + return plymouth_ok; +} + +void plymouth_finish(void) { + set_plymouth_percent(100); + ply_boot_client_free(ply.client); + ply_event_loop_free(ply.loop); +} + +/************************* + * RPM transaction stuff * + *************************/ + +/* decide whether to upgrade or install the given pkg */ +int installonly(Header hdr) { + /* installonly pkgs are more bane than boon between RHEL versions, + * so always upgrade + */ + return 0; +} + +/* Add the given file to the given RPM transaction */ +int add_upgrade(rpmts ts, gchar *file) { + FD_t fd = NULL; + Header hdr = NULL; + gchar *fullfile = NULL; + gint rc = 1; + + fullfile = g_build_filename(packagedir, file, NULL); + if (fullfile == NULL) { + g_warning("failed to allocate memory"); + goto out; + } + + /* open package file */ + fd = Fopen(fullfile, "r.ufdio"); + if (fd == NULL) { + g_warning("failed to open file %s", fullfile); + goto out; + } + + /* get the RPM header */ + rc = rpmReadPackageFile(ts, fd, fullfile, &hdr); + if (rc != RPMRC_OK) { + g_warning("unable to read package %s", file); + goto out; + } + + /* add it to the transaction. + * last two args are 'upgrade' and 'relocs' */ + rc = rpmtsAddInstallElement(ts, hdr, file, installonly(hdr) ? 0 : 1, NULL); + g_debug("added %s to transaction", file); + if (rc) { + g_warning("failed to add %s to transaction", file); + goto out; + } + + rc = 0; /* success */ + +out: + if (fd != NULL) + Fclose(fd); + if (hdr != NULL) + headerFree(hdr); + if (fullfile != NULL) + g_free(fullfile); + return rc; +} + +/* Set up the RPM transaction using the list of packages to install */ +rpmts setup_transaction(gchar *files[]) { + rpmts ts = NULL; + rpmps probs = NULL; + rpmtsi tsi = NULL; + rpmte te = NULL; + gchar **file = NULL; + gint rc = 1; + guint numfiles = 0; + guint setup=0, prevpercent=0, percent=0; + + /* Read config and initialize transaction */ + rpmReadConfigFiles(NULL, NULL); + ts = rpmtsCreate(); + rpmtsSetRootDir(ts, root); + + /* Disable signature checking, as anaconda did */ + rpmtsSetVSFlags(ts, rpmtsVSFlags(ts) | _RPMVSF_NOSIGNATURES); + + /* Make plymouth progress bar show signs of life */ + set_plymouth_percent(1); + + /* Populate the transaction */ + numfiles = g_strv_length(files); + g_message("found %u packages to install", numfiles); + g_message("building RPM transaction, one moment..."); + for (file = files; *file && **file; file++) { + if (add_upgrade(ts, *file)) + g_warning("couldn't add %s to the transaction", *file); + percent = (++setup*SETUP_PERCENT) / numfiles; + if (percent > prevpercent) + set_plymouth_percent(percent); + /* Ignore errors, just like anaconda did */ + } + + /* get some transaction info */ + tsi = rpmtsiInit(ts); + while ((te = rpmtsiNext(tsi, 0)) != NULL) { + if (rpmteType(te) == TR_ADDED) + installcount++; + else + erasecount++; + } + g_message("%u packages to install, %u to erase", installcount, erasecount); + tsi = rpmtsiFree(tsi); + + if (installcount == 0) { + g_warning("nothing to upgrade"); + goto fail; + } + + /* We should be finished with the time-consuming bits of setup here. */ + set_plymouth_percent(SETUP_PERCENT); + + /* Check transaction */ + g_message("checking RPM transaction..."); + rc = rpmtsCheck(ts); + if (rc) { + g_warning("transaction check failed (couldn't open rpmdb)"); + goto fail; + } + + /* Log any transaction problems encountered */ + probs = rpmtsProblems(ts); + if (probs != NULL) { + g_message("non-fatal problems with RPM transaction:"); + /* FIXME: ignore anything but RPMPROB_{CONFLICT,REQUIRES} */ + rpmpsPrint(stdout, probs); + rpmpsFree(probs); + } + /* Continue on, ignoring errors, as is anaconda tradition... */ + + /* Order transaction */ + rc = rpmtsOrder(ts); + if (rc > 0) { + /* this should never happen */ + g_warning("rpm transaction ordering failed"); + goto fail; + } + + /* Clean transaction */ + rpmtsClean(ts); + + /* All ready! Return the ts. */ + return ts; + +fail: + rpmtsFree(ts); + return NULL; +} + +/* tag -> string helper (copied from rpm/lib/rpmscript.c) */ +const char *script_type(rpmTagVal tag) { + switch (tag) { + case RPMTAG_PRETRANS: return "%pretrans"; + case RPMTAG_TRIGGERPREIN: return "%triggerprein"; + case RPMTAG_PREIN: return "%pre"; + case RPMTAG_POSTIN: return "%post"; + case RPMTAG_TRIGGERIN: return "%triggerin"; + case RPMTAG_TRIGGERUN: return "%triggerun"; + case RPMTAG_PREUN: return "%preun"; + case RPMTAG_POSTUN: return "%postun"; + case RPMTAG_POSTTRANS: return "%posttrans"; + case RPMTAG_TRIGGERPOSTUN: return "%triggerpostun"; + case RPMTAG_VERIFYSCRIPT: return "%verify"; + default: break; + } + return "%unknownscript"; +} + +/* Transaction callback handler, to display RPM progress */ +void *rpm_trans_callback(const void *arg, + const rpmCallbackType what, + const rpm_loff_t amount, + const rpm_loff_t total, + fnpyKey key, + void *data) +{ + Header hdr = (Header) arg; + static guint percent; + static guint prevpercent; + static guint installed = 0; + static guint erased = 0; + gchar *pkgfile; + static guint cb_seen = 0; + gchar *nvr = NULL; + gchar *file = (gchar *)key; + void *retval = NULL; + + /* + * The upgrade transaction goes through three phases: + * prep: TRANS_START, TRANS_PROGRESS, TRANS_STOP + * duration: basically negligible + * install: INST_START, INST_OPEN_FILE, INST_STOP, INST_CLOSE_FILE + * duration: very roughly 2/3 the transaction + * cleanup: UNINST_START, UNINST_STOP + * duration: the remainder + */ + + switch (what) { + + /* prep phase: (start, progress..., stop), just once */ + case RPMCALLBACK_TRANS_START: + g_debug("trans_start()"); + g_message("preparing RPM transaction, one moment..."); + break; + case RPMCALLBACK_TRANS_PROGRESS: + /* FIXME: track progress from SETUP_PERCENT to INSTALL_BASE_PERCENT */ + break; + case RPMCALLBACK_TRANS_STOP: + g_debug("trans_stop()"); + break; + + /* install phase: (open, start, progress..., stop, close) for each pkg */ + case RPMCALLBACK_INST_OPEN_FILE: + /* NOTE: hdr is NULL (because we haven't opened the file yet) */ + g_debug("inst_open_file(\"%s\")", file); + pkgfile = g_build_filename(packagedir, file, NULL); + retval = rpmShowProgress(arg, what, amount, total, pkgfile, NULL); + g_free(pkgfile); + break; + case RPMCALLBACK_INST_START: + g_debug("inst_start(\"%s\")", file); + nvr = headerGetAsString(hdr, RPMTAG_NVR); + g_message("[%u/%u] (%u%%) installing %s...", + installed+1, installcount, percent, nvr); + rfree(nvr); + break; + case RPMCALLBACK_INST_PROGRESS: + break; + case RPMCALLBACK_INST_STOP: + g_debug("inst_stop(\"%s\")", file); + break; + case RPMCALLBACK_INST_CLOSE_FILE: + g_debug("inst_close_file(\"%s\")", file); + rpmShowProgress(arg, what, amount, total, key, NULL); + /* NOTE: we do this here 'cuz test transactions don't do start/stop */ + installed++; + percent = INSTALL_BASE_PERCENT + \ + ((INSTALL_PERCENT*installed) / installcount); + if (percent > prevpercent) { + set_plymouth_percent(percent); + prevpercent = percent; + } + break; + + /* cleanup phase: (start, progress..., stop) for each cleanup */ + /* NOTE: file is NULL */ + case RPMCALLBACK_UNINST_START: + nvr = headerGetAsString(hdr, RPMTAG_NVR); + g_debug("uninst_start(\"%s\")", nvr); + g_message("[%u/%u] (%u%%) cleaning %s...", + erased+1, erasecount, percent, nvr); + rfree(nvr); + break; + case RPMCALLBACK_UNINST_PROGRESS: + break; + case RPMCALLBACK_UNINST_STOP: + nvr = headerGetAsString(hdr, RPMTAG_NVR); + g_debug("uninst_stop(\"%s\")", nvr); + erased++; + percent = INSTALL_BASE_PERCENT + INSTALL_PERCENT + \ + ((ERASE_PERCENT*erased) / erasecount); + if (percent > prevpercent) { + set_plymouth_percent(percent); + prevpercent = percent; + } + rfree(nvr); + break; + + /* + * SCRIPT CALLBACKS (rpm >= 4.10) - happen all throughout the transaction. + * hdr and file/key are both usable. + * amount is the script type (RPMTAG_PREIN, RPMTAG_POSTIN, ...) + * total is the script exit value (see comments below) + * Ordering is: START; STOP; ERROR if script retval != RPMRC_OK + */ + case RPMCALLBACK_SCRIPT_START: + /* no exit value here, obviously */ + nvr = headerGetAsString(hdr, RPMTAG_NVR); + g_debug("%s_start(\"%s\")", script_type(amount), nvr); + /* NOTE: %posttrans usually takes a while - report progress! */ + if (amount == RPMTAG_POSTTRANS) + g_message("running %s script for %s", script_type(amount), nvr); + break; + case RPMCALLBACK_SCRIPT_STOP: + /* RPMRC_OK: scriptlet succeeded + * RPMRC_NOTFOUND: scriptlet failed non-fatally (warning) + * other: scriptlet failed, preventing install/erase + * (this only happens for PREIN/PREUN/PRETRANS) */ + nvr = headerGetAsString(hdr, RPMTAG_NVR); + g_debug("%s_stop(\"%s\")", script_type(amount), nvr); + break; + case RPMCALLBACK_SCRIPT_ERROR: + /* RPMRC_OK: scriptlet failed non-fatally (warning) + * other: scriptlet failed, preventing install/erase */ + nvr = headerGetAsString(hdr, RPMTAG_NVR); + g_debug("%s_error(\"%s\"): %lu", script_type(amount), nvr, total); + g_warning("%s %s scriptlet failure in %s (exit code %lu)", + total == RPMRC_OK ? "non-fatal" : "fatal", + script_type(amount), nvr, total); + /* TODO: show the script contents? */ + break; + + /* these are probably fatal, and there's not much we can do about it.. + * the RPM test transaction should catch nearly all of these well before + * we end up here, though. */ + case RPMCALLBACK_UNPACK_ERROR: + case RPMCALLBACK_CPIO_ERROR: + g_warning("error unpacking %s! file may be corrupt!", file); + break; + + default: + if (!(what & cb_seen)) { + g_debug("unhandled callback number %u", what); + cb_seen |= what; + } + break; + } + return retval; +} + +rpmps run_transaction(rpmts ts, gint tsflags) { + /* probFilter seems odd, but that's what anaconda used to do... */ + gint probFilter = ~RPMPROB_FILTER_DISKSPACE; + gint rc; + rpmps probs = NULL; + + /* send scriptlet stderr somewhere useful. */ + rpmtsSetScriptFd(ts, fdDup(STDOUT_FILENO)); + /* rpmSetVerbosity(RPMLOG_INFO) would give us script stdout, if we cared */ + + rpmtsSetNotifyCallback(ts, rpm_trans_callback, NULL); + rpmtsSetFlags(ts, rpmtsFlags(ts)|tsflags); + rc = rpmtsRun(ts, NULL, (rpmprobFilterFlags)probFilter); + g_debug("transaction finished"); + if (rc > 0) + probs = rpmtsProblems(ts); + if (rc < 0) + g_message("Upgrade finished with non-fatal errors."); + /* AFAICT probs would be empty here, so that's all we can say.. */ + return probs; +} + +/******************* + * logging handler * + *******************/ + +void log_handler(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer user_data) +{ + switch (log_level & G_LOG_LEVEL_MASK) { + /* NOTE: ERROR is still handled by the default handler. */ + case G_LOG_LEVEL_CRITICAL: + g_printf("ERROR: %s\n", message); + exit(1); + break; + case G_LOG_LEVEL_WARNING: + /* TODO: once the journal problems are fixed, send warnings and + * scriptlet stderr to stderr. + * see https://bugzilla.redhat.com/show_bug.cgi?id=869061 */ + g_printf("Warning: %s\n", message); + break; + case G_LOG_LEVEL_MESSAGE: + g_printf("%s\n", message); + if (plymouth_verbose) + set_plymouth_message(message); + break; + case G_LOG_LEVEL_INFO: + if (debug) + g_printf("%s\n", message); + break; + case G_LOG_LEVEL_DEBUG: + if (debug) + g_printf("DEBUG: %s\n", message); + break; + } + fflush(stdout); +} + +/******************** + * helper functions * + ********************/ + +/* read a list of filenames out of the given file */ +gchar **read_filelist(gchar *path, gchar *name) { + GError *error = NULL; + gchar *filelist_path = NULL; + gchar *filelist_data = NULL; + gchar **files = NULL; + + filelist_path = g_build_filename(path, name, NULL); + if (!g_file_get_contents(filelist_path, &filelist_data, NULL, &error)) + g_critical(error->message); + + /* parse the data into a list of files */ + g_strchomp(filelist_data); + files = g_strsplit(filelist_data, "\n", -1); + + g_free(filelist_path); + g_free(filelist_data); + + return files; +} + +/**************** + * main program * + ****************/ + +/* Total runtime for my test system (F17->F18) is ~70m. */ +int main(int argc, char* argv[]) { + gchar *symlink = NULL; + gchar *link_target = NULL; + gchar *origroot = NULL; + gchar **files = NULL; + GError *error = NULL; + rpmts ts = NULL; + rpmps probs = NULL; + gint tsflags = RPMTRANS_FLAG_NONE; + gint retval = EXIT_FAILURE; + GOptionContext *context; + + /* setup */ + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, "/usr/share/locale"); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + g_log_set_handler(NULL, G_LOG_LEVEL_MASK, log_handler, NULL); + + + /* parse commandline */ + context = g_option_context_new("upgrade a RHEL system"); + g_option_context_add_main_entries(context, options, GETTEXT_PACKAGE); + if (!g_option_context_parse(context, &argc, &argv, &error)) + g_critical("option_parsing failed: %s", error->message); + + if (getuid() != 0 || geteuid() != 0) + g_critical("This program must be run as root."); + + if (g_getenv("UPGRADE_TEST") != NULL) + testing = TRUE; + + if (plymouth) { + if (!plymouth_setup()) { + g_warning("Disabling plymouth output"); + plymouth = FALSE; + } + } + + if (!plymouth) + plymouth_verbose = FALSE; + + if (!g_path_is_absolute(root)) { + origroot = root; + root = realpath(origroot, NULL); + g_debug("root is \"%s\"", root); + } + if ((root == NULL) || (!g_file_test(root, G_FILE_TEST_IS_DIR))) + g_critical("--root: \"%s\" is not a directory", origroot); + + + /* read the magic symlink */ + symlink = g_build_filename(root, UPGRADE_SYMLINK, NULL); + + link_target = g_file_read_link(symlink, &error); + if (link_target == NULL) + g_critical(error->message); + + packagedir = g_build_filename(root, link_target, NULL); + g_debug("%s -> %s", symlink, packagedir); + + g_free(symlink); + g_free(link_target); + + + /* read filelist from packagedir */ + files = read_filelist(packagedir, UPGRADE_FILELIST); + + /* set up RPM transaction - this takes ~90s (~2% total duration) */ + g_message("preparing for upgrade..."); + ts = setup_transaction(files); + if (ts == NULL) + goto out; + + /* don't actually run the transaction if we're just testing */ + if (testing) + tsflags |= RPMTRANS_FLAG_TEST; + + + /* LET'S ROCK. 98% of the program runtime is here. */ + g_message("starting upgrade..."); + probs = run_transaction(ts, tsflags); + + + /* check for failures */ + if (probs != NULL) { + g_message("ERROR: upgrade failed due to the following problems:"); + rpmpsPrint(stdout, probs); + } else { + g_message("upgrade finished."); + retval = EXIT_SUCCESS; + } + + if (plymouth) + plymouth_finish(); + + /* cleanup */ + g_debug("cleaning up..."); + rpmpsFree(probs); + rpmtsFree(ts); + rpmFreeMacros(NULL); + rpmFreeRpmrc(); + +out: + if (packagedir != NULL) + g_free(packagedir); + if (files != NULL) + g_strfreev(files); + return retval; +}