dracut/0106-dracut-Enable-converting-of-directory-var-run-var-lo.patch
Thomas Renninger 9f28177407 Accepting request 293267 from home:trenn:branches:Base:System
- Update to dracut mainline version 041.
  Half of the patches got integrated mainline.
  Some others have been merged together when it made sense some have
  been left out, but are still in the repository as they need some special
  treating and mainline discussion whether/how they get added. These are
  also not urgently needed, but are debugging patches.
  I broke the rule here to mention every added/deleted/modified patch as
  every patch is touched and every 2nd  got removed (mainline integrated).
  I also re-ordered the patches in the PatchXY: area for easier merging them
  and get them discussed and posted mainline easier, topic by topic.

OBS-URL: https://build.opensuse.org/request/show/293267
OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=214
2015-03-31 14:12:12 +00:00

159 lines
4.8 KiB
Diff

From 6cadece6089ef4d4efbfebeb6b23ca3f2429b36c Mon Sep 17 00:00:00 2001
From: Thomas Renninger <trenn@suse.de>
Date: Tue, 8 Jul 2014 17:34:08 +0200
Subject: dracut: Enable converting of directory /var/run /var/lock to symlinks
to /run
If /var/run is a directory this module will be added.
After reboot /var/run and /var/lock will be symlinks.
Another initrd re-creation will not include convertfs module anymore.
bnc#877680
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
modules.d/30convertfs/convertfs.sh | 9 ------
modules.d/30convertfs/convertrunfs.sh | 54 +++++++++++++++++++++++++++++++++++
modules.d/30convertfs/do-convertfs.sh | 17 +++++++++++
modules.d/30convertfs/module-setup.sh | 10 +++++--
4 files changed, 79 insertions(+), 11 deletions(-)
create mode 100755 modules.d/30convertfs/convertrunfs.sh
Index: dracut-041/modules.d/30convertfs/convertfs.sh
===================================================================
--- dracut-041.orig/modules.d/30convertfs/convertfs.sh 2015-01-31 12:54:52.000000000 +0100
+++ dracut-041/modules.d/30convertfs/convertfs.sh 2015-03-17 17:37:15.774237322 +0100
@@ -62,15 +62,6 @@
fi
rm -f -- "$testfile"
-testfile="$ROOT/usr/.usrmovecheck$$"
-rm -f -- "$testfile"
-> "$testfile"
-if [[ ! -e "$testfile" ]]; then
- echo "Cannot write to $ROOT/usr/"
- exit 1
-fi
-rm -f -- "$testfile"
-
find_mount() {
local dev mnt etc wanted_dev
wanted_dev="$(readlink -e -q $1)"
Index: dracut-041/modules.d/30convertfs/convertrunfs.sh
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ dracut-041/modules.d/30convertfs/convertrunfs.sh 2015-03-17 17:37:15.778237383 +0100
@@ -0,0 +1,54 @@
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+ROOT="$1"
+
+if [[ ! -d "$ROOT" ]]; then
+ echo "Usage: $0 <rootdir>"
+ exit 1
+fi
+
+if [[ "$ROOT" -ef / ]]; then
+ echo "Can't convert the running system."
+ echo "Please boot with 'rd.convertfs' on the kernel command line,"
+ echo "to update with the help of the initramfs,"
+ echo "or run this script from a rescue system."
+ exit 1
+fi
+
+while [[ "$ROOT" != "${ROOT%/}" ]]; do
+ ROOT=${ROOT%/}
+done
+
+if findmnt "$ROOT" -O ro;then
+ WAS_RO=1
+ mount $ROOT -o remount,rw
+else
+ WAS_RO=0
+fi
+
+testfile="$ROOT/.usrmovecheck$$"
+rm -f -- "$testfile"
+> "$testfile"
+if [[ ! -e "$testfile" ]]; then
+ echo "Cannot write to $ROOT/"
+ exit 1
+fi
+rm -f -- "$testfile"
+
+if [ ! -L $ROOT/var/run -a -e $ROOT/var/run ]; then
+ echo "Converting /var/run to symlink"
+ mv -f $ROOT/var/run $ROOT/var/run.runmove~
+ ln -sfn ../run $ROOT/var/run
+fi
+
+if [ ! -L $ROOT/var/lock -a -e $ROOT/var/lock ]; then
+ echo "Converting /var/lock to symlink"
+ mv -f $ROOT/var/lock $ROOT/var/lock.lockmove~
+ ln -sfn ../run/lock $ROOT/var/lock
+fi
+
+if [ $WAS_RO -eq 1 ];then
+ mount $ROOT -o remount,ro
+fi
Index: dracut-041/modules.d/30convertfs/do-convertfs.sh
===================================================================
--- dracut-041.orig/modules.d/30convertfs/do-convertfs.sh 2015-03-17 17:31:01.441312547 +0100
+++ dracut-041/modules.d/30convertfs/do-convertfs.sh 2015-03-17 17:37:15.786237620 +0100
@@ -1,9 +1,26 @@
#!/bin/bash
+# This converts all, /usr/bin -> /bin, ... and /var/run -> /run
+# Do not enable by default!
if getargbool 0 rd.convertfs; then
+ info "Converting both /var/run to /run tmpfs and /usr/bin -> /bin"
if getargbool 0 rd.debug; then
bash -x convertfs "$NEWROOT" 2>&1 | vinfo
+ exit 0
else
convertfs "$NEWROOT" 2>&1 | vinfo
+ exit 0
+ fi
+fi
+
+# This only converts /var/run -> /run as tmpfs
+if ! test -L "$NEWROOT"/var/run;then
+ info "Converting /var/run to /run tmpfs"
+ if getargbool 0 rd.debug; then
+ bash -x convertrunfs "$NEWROOT" 2>&1 | vinfo
+ exit 0
+ else
+ convertrunfs "$NEWROOT" 2>&1 | vinfo
+ exit 0
fi
fi
Index: dracut-041/modules.d/30convertfs/module-setup.sh
===================================================================
--- dracut-041.orig/modules.d/30convertfs/module-setup.sh 2015-03-17 17:31:01.445312770 +0100
+++ dracut-041/modules.d/30convertfs/module-setup.sh 2015-03-17 17:37:15.786237620 +0100
@@ -2,8 +2,13 @@
# called by dracut
check() {
- [[ $mount_needs ]] && return 1
- return 255
+ # Only check for /var/run
+ if test -L /var/run;then
+ return 255
+ else
+ require_binaries bash find ldconfig mv rm cp ln || return 1
+ return 0
+ fi
}
# called by dracut
@@ -16,5 +21,6 @@
inst_multiple bash find ldconfig mv rm cp ln
inst_hook pre-pivot 99 "$moddir/do-convertfs.sh"
inst_script "$moddir/convertfs.sh" /usr/bin/convertfs
+ inst_script "$moddir/convertrunfs.sh" /usr/bin/convertrunfs
}