@ -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 $? |
@ -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: |
||||||
|
# <mount-ID> <parent-ID> <major>:<minor> <root> <mount point> <options> <optional fields> ... - <fstype> <source> <super options> |
||||||
|
# |
||||||
|
# This loops assumes that $NEWROOT is a mount point and that we can |
||||||
|
# ignore <root>, 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 |
@ -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" |
||||||
|
} |
@ -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 |
@ -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 |
@ -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 |
||||||
|
|
@ -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 |
@ -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 |
@ -0,0 +1,38 @@ |
|||||||
|
system-upgrade |
||||||
|
============== |
||||||
|
Will Woods <wwoods@redhat.com> |
||||||
|
// 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`. |
@ -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 |
@ -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 |
||||||
|
} |
||||||
|
|
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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. |
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.> |
||||||
|
Copyright (C) <year> <name of author> |
||||||
|
|
||||||
|
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. |
||||||
|
|
||||||
|
<signature of Ty Coon>, 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. |
@ -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 |
@ -0,0 +1,66 @@ |
|||||||
|
powerel-upgrade-dracut - initramfs environment for PEL Upgrades |
||||||
|
================================================================ |
||||||
|
Toshaan Bharvani <toshaan@vantosh.com> |
||||||
|
|
||||||
|
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 <wwoods@redhat.com> |
||||||
|
|
||||||
|
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: |
@ -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 |
@ -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 <http://www.gnu.org/licenses/>. |
||||||
|
# |
||||||
|
# Author: Will Woods <wwoods@redhat.com> |
||||||
|
|
||||||
|
|
||||||
|
# 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 |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 870 B |
After Width: | Height: | Size: 131 B |
After Width: | Height: | Size: 367 B |
After Width: | Height: | Size: 1.9 KiB |
@ -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 |
@ -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 |
After Width: | Height: | Size: 323 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 374 B |
After Width: | Height: | Size: 372 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 374 B |
After Width: | Height: | Size: 373 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 374 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 375 B |