diff --git a/0001-dracut-install.c-try-clone-ioctl-for-more-speed.patch b/0001-dracut-install.c-try-clone-ioctl-for-more-speed.patch new file mode 100644 index 0000000..a19caf9 --- /dev/null +++ b/0001-dracut-install.c-try-clone-ioctl-for-more-speed.patch @@ -0,0 +1,113 @@ +From 85854b245e1090970d566d6432dabc315e17461c Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 09:06:13 +0200 +Subject: [PATCH] dracut-install.c: try clone ioctl for more speed + +--- + install/dracut-install.c | 64 ++++++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 59 insertions(+), 5 deletions(-) + +diff --git a/install/dracut-install.c b/install/dracut-install.c +index ccd4ba4..86c32db 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -39,6 +39,7 @@ + #include + #include + #include ++#include + + #include "log.h" + #include "hashmap.h" +@@ -163,25 +164,78 @@ static int ln_r(const char *src, const char *dst) + return 0; + } + ++/* Perform the O(1) btrfs clone operation, if possible. ++ Upon success, return 0. Otherwise, return -1 and set errno. */ ++static inline int clone_file(int dest_fd, int src_fd) ++{ ++#undef BTRFS_IOCTL_MAGIC ++#define BTRFS_IOCTL_MAGIC 0x94 ++#undef BTRFS_IOC_CLONE ++#define BTRFS_IOC_CLONE _IOW (BTRFS_IOCTL_MAGIC, 9, int) ++ return ioctl(dest_fd, BTRFS_IOC_CLONE, src_fd); ++} ++ ++static bool use_clone = true; ++ + static int cp(const char *src, const char *dst) + { + int pid; +- int status; ++ int ret; ++ ++ if(use_clone) { ++ struct stat sb; ++ int dest_desc, source_desc; ++ ++ if (lstat(src, &sb) != 0) ++ goto normal_copy; ++ ++ if (S_ISLNK(sb.st_mode)) ++ goto normal_copy; ++ ++ source_desc = open(src, O_RDONLY | O_CLOEXEC); ++ if (source_desc < 0) ++ goto normal_copy; + ++ dest_desc = ++ open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, ++ (sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)); ++ ++ if (dest_desc < 0) { ++ close(source_desc); ++ goto normal_copy; ++ } ++ ++ ret = clone_file(dest_desc, source_desc); ++ close(source_desc); ++ if (ret == 0) { ++ if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0) ++ fchown(dest_desc, -1, sb.st_gid); ++ close(dest_desc); ++ return ret; ++ } ++ close(dest_desc); ++ ++ /* clone did not work, remove the file */ ++ unlink(dst); ++ /* do not try clone again */ ++ use_clone = false; ++ } ++ ++ normal_copy: + pid = fork(); + if (pid == 0) { + execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode", "-fL", src, dst, NULL); + _exit(EXIT_FAILURE); + } + +- while (waitpid(pid, &status, 0) < 0) { ++ while (waitpid(pid, &ret, 0) < 0) { + if (errno != EINTR) { +- status = -1; ++ ret = -1; + break; + } + } + +- return status; ++ return ret; + } + + static int resolve_deps(const char *src) +@@ -643,7 +697,7 @@ static int install_all(int argc, char **argv) + free(dest); + } + +- if ((ret != 0) && (!arg_optional)) { ++ if ((ret != 0) && (!arg_optional)) { + log_error("ERROR: installing '%s'", argv[i]); + r = EXIT_FAILURE; + } diff --git a/0002-move-dracut-install-to-dracutbasedir.patch b/0002-move-dracut-install-to-dracutbasedir.patch new file mode 100644 index 0000000..aca1164 --- /dev/null +++ b/0002-move-dracut-install-to-dracutbasedir.patch @@ -0,0 +1,408 @@ +From f4031e8a9a7734fbb94e7350a814a5446c5cef5c Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 09:12:35 +0200 +Subject: [PATCH] move dracut-install to dracutbasedir + +We do not want to install dracut-install to /usr/bin until all +interfaces are set to stone and the manpage is written. Until then the +tool is dracut internal. +--- + Makefile | 25 ++++++++--- + dracut-functions.sh | 121 +++++++++++++++++++++++++++++---------------------- + dracut.sh | 4 +- + dracut.spec | 9 +++- + install/Makefile | 18 ++------ + 5 files changed, 102 insertions(+), 75 deletions(-) + +diff --git a/Makefile b/Makefile +index 5488f8e..1d5531d 100644 +--- a/Makefile ++++ b/Makefile +@@ -13,10 +13,25 @@ manpages = dracut.8 dracut.cmdline.7 dracut.conf.5 dracut-catimages.8 + + .PHONY: install clean archive rpm testimage test all check AUTHORS doc + +-all: syncheck dracut-version.sh install/dracut-install ++all: syncheck dracut-version.sh dracut-install + +-install/dracut-install: +- $(MAKE) -C install dracut-install ++DRACUT_INSTALL_SOURCE = \ ++ install/dracut-install.c \ ++ install/hashmap.c\ ++ install/log.c \ ++ install/util.c ++ ++DRACUT_INSTALL_HEADER = \ ++ install/hashmap.h \ ++ install/log.h \ ++ install/macro.h \ ++ install/util.h ++ ++dracut-install: $(DRACUT_INSTALL_SOURCE) $(DRACUT_INSTALL_HEADER) ++ gcc -std=gnu99 -O2 -g -Wall -o dracut-install $(DRACUT_INSTALL_SOURCE) ++ ++indent: ++ indent -i8 -nut -br -linux -l120 install/dracut-install.c + + doc: $(manpages) dracut.html + +@@ -74,7 +89,7 @@ install: doc dracut-version.sh + ln -s ../dracut-shutdown.service \ + $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \ + fi +- $(MAKE) -C install install ++ install $(strip) -m 0755 dracut-install $(DESTDIR)$(pkglibdir)/dracut-install + + dracut-version.sh: + @echo "DRACUT_VERSION=$(VERSION)-$(GITVERSION)" > dracut-version.sh +@@ -85,9 +100,9 @@ clean: + $(RM) */*/*~ + $(RM) test-*.img + $(RM) dracut-*.rpm dracut-*.tar.bz2 ++ $(RM) dracut-install + $(RM) $(manpages) dracut.html + $(MAKE) -C test clean +- $(MAKE) -C install clean + + archive: dracut-$(VERSION)-$(GITVERSION).tar.bz2 + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index 3fca456..5acf6f6 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -20,11 +20,30 @@ + # along with this program. If not, see . + # + +-[[ -d "$initdir/.kernelmodseen" ]] || mkdir -p "$initdir/.kernelmodseen" ++ ++if [[ $DRACUT_KERNEL_LAZY ]] && ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then ++ if ! [[ -d "$initdir/.kernelmodseen" ]]; then ++ mkdir -p "$initdir/.kernelmodseen" ++ fi ++ DRACUT_KERNEL_LAZY_HASHDIR="$initdir/.kernelmodseen" ++fi + + # Generic substring function. If $2 is in $1, return 0. + strstr() { [[ $1 = *$2* ]]; } + ++# find a binary. If we were not passed the full path directly, ++# search in the usual places to find the binary. ++find_binary() { ++ if [[ -z ${1##/*} ]]; then ++ if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then ++ echo $1 ++ return 0 ++ fi ++ fi ++ ++ type -P $1 ++} ++ + if ! [[ $dracutbasedir ]]; then + dracutbasedir=${BASH_SOURCE[0]%/*} + [[ $dracutbasedir = "dracut-functions" ]] && dracutbasedir="." +@@ -32,6 +51,14 @@ if ! [[ $dracutbasedir ]]; then + dracutbasedir="$(readlink -f $dracutbasedir)" + fi + ++if ! [[ $DRACUT_INSTALL ]]; then ++ DRACUT_INSTALL=$(find_binary dracut-install) ++fi ++ ++if ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/dracut-install ]]; then ++ DRACUT_INSTALL=$dracutbasedir/dracut-install ++fi ++ + # Detect lib paths + if ! [[ $libdirs ]] ; then + if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \ +@@ -391,56 +418,56 @@ check_vol_slaves() { + return 1 + } + +-if [[ -x /usr/bin/dracut-install ]]; then ++if [[ $DRACUT_INSTALL ]]; then + [[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1 + inst_dir() { + [[ -e ${initdir}/"$1" ]] && return 0 # already there +- dracut-install ${initdir+-D "$initdir"} -d "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} -d "$@" || : ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} -d "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} -d "$@" || : + } + + inst() { + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there +- #dinfo "dracut-install -l $@" +- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : ++ #dinfo "$DRACUT_INSTALL -l $@" ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : + } + + inst_simple() { + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there + [[ -e $1 ]] || return 1 # no source +- dracut-install ${initdir+-D "$initdir"} "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} "$@" || : ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} "$@" || : + } + + inst_symlink() { + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there + [[ -L $1 ]] || return 1 +- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : + } + + dracut_install() { +- #dinfo "initdir=$initdir dracut-install -l $@" +- dracut-install ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : ++ #dinfo "initdir=$initdir $DRACUT_INSTALL -l $@" ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : + } + + inst_library() { + [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there + [[ -e $1 ]] || return 1 # no source +- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : + } + + inst_binary() { +- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : + } + + inst_script() { +- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" +- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : ++ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" ++ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || : + } + + else +@@ -664,19 +691,6 @@ rev_lib_symlinks() { + echo "${links}" + } + +-# find a binary. If we were not passed the full path directly, +-# search in the usual places to find the binary. +-find_binary() { +- if [[ -z ${1##/*} ]]; then +- if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then +- echo $1 +- return 0 +- fi +- fi +- +- type -P $1 +-} +- + # attempt to install any programs specified in a udev rule + inst_rule_programs() { + local _prog _bin +@@ -1112,8 +1126,8 @@ install_kmod_with_fw() { + [[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \ + && return 0 + +- if [[ -e "$initdir/.kernelmodseen/${1##*/}" ]]; then +- read ret < "$initdir/.kernelmodseen/${1##*/}" ++ if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && [[ -e "$DRACUT_KERNEL_LAZY_HASHDIR/${1##*/}" ]]; then ++ read ret < "$DRACUT_KERNEL_LAZY_HASHDIR/${1##*/}" + return $ret + fi + +@@ -1133,8 +1147,9 @@ install_kmod_with_fw() { + + inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" + ret=$? +- [ -d "$initdir/.kernelmodseen" ] && \ +- echo $ret > "$initdir/.kernelmodseen/${1##*/}" ++ [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \ ++ [[ -d "$DRACUT_KERNEL_LAZY_HASHDIR" ]] && \ ++ echo $ret > "$DRACUT_KERNEL_LAZY_HASHDIR/${1##*/}" + (($ret != 0)) && return $ret + + local _modname=${1##*/} _fwdir _found _fw +@@ -1181,38 +1196,38 @@ for_each_kmod_dep() { + dracut_kernel_post() { + local _moddirname=${srcmods%%/lib/modules/*} + +- if [[ -f "$initdir/.kernelmodseen/lazylist" ]]; then ++ if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && [[ -f "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" ]]; then + xargs modprobe -a ${_moddirname+-d ${_moddirname}/} --ignore-install --show-depends \ +- < "$initdir/.kernelmodseen/lazylist" 2>/dev/null \ ++ < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" 2>/dev/null \ + | sort -u \ + | while read _cmd _modpath _options; do + [[ $_cmd = insmod ]] || continue + echo "$_modpath" +- done > "$initdir/.kernelmodseen/lazylist.dep" ++ done > "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" + + ( +- if [[ -x /usr/bin/dracut-install ]] && [[ -z $_moddirname ]]; then +- xargs dracut-install ${initdir+-D "$initdir"} -a < "$initdir/.kernelmodseen/lazylist.dep" ++ if [[ -x $DRACUT_INSTALL ]] && [[ -z $_moddirname ]]; then ++ xargs $DRACUT_INSTALL ${initdir+-D "$initdir"} -a < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" + else + while read _modpath; do + local _destpath=$_modpath + [[ $_moddirname ]] && _destpath=${_destpath##$_moddirname/} + _destpath=${_destpath##*/lib/modules/$kernel/} + inst_simple "$_modpath" "/lib/modules/$kernel/${_destpath}" || exit $? +- done < "$initdir/.kernelmodseen/lazylist.dep" ++ done < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" + fi + ) & + + +- if [[ -x /usr/bin/dracut-install ]]; then +- xargs modinfo -k $kernel -F firmware < "$initdir/.kernelmodseen/lazylist.dep" \ ++ if [[ -x $DRACUT_INSTALL ]]; then ++ xargs modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" \ + | while read line; do + for _fwdir in $fw_dir; do + echo $_fwdir/$line; + done; +- done |xargs dracut-install ${initdir+-D "$initdir"} -a -o ++ done |xargs $DRACUT_INSTALL ${initdir+-D "$initdir"} -a -o + else +- for _fw in $(xargs modinfo -k $kernel -F firmware < "$initdir/.kernelmodseen/lazylist.dep"); do ++ for _fw in $(xargs modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"); do + for _fwdir in $fw_dir; do + if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then + inst_simple "$_fwdir/$_fw" "/lib/firmware/$_fw" +@@ -1243,7 +1258,7 @@ dracut_kernel_post() { + exit 1 + fi + +- rm -fr "$initdir/.kernelmodseen" ++ [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr "$DRACUT_KERNEL_LAZY_HASHDIR" + } + + find_kernel_modules_by_path () ( +@@ -1296,8 +1311,9 @@ instmods() { + _mod=${_mod##*/} + # if we are already installed, skip this module and go on + # to the next one. +- if [[ -f "$initdir/.kernelmodseen/${_mod%.ko}.ko" ]]; then +- read _ret <"$initdir/.kernelmodseen/${_mod%.ko}.ko" ++ if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \ ++ [[ -f "$DRACUT_KERNEL_LAZY_HASHDIR/${_mod%.ko}.ko" ]]; then ++ read _ret <"$DRACUT_KERNEL_LAZY_HASHDIR/${_mod%.ko}.ko" + return $_ret + fi + +@@ -1312,7 +1328,7 @@ instmods() { + && ! [[ "$add_drivers" =~ " ${_mod} " ]] \ + && return 0 + +- if [[ "$_check" = "yes" ]] || ! [[ $DRACUT_KERNEL_LAZY ]]; then ++ if [[ "$_check" = "yes" ]] || ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then + # We use '-d' option in modprobe only if modules prefix path + # differs from default '/'. This allows us to use Dracut with + # old version of modprobe which doesn't have '-d' option. +@@ -1325,7 +1341,8 @@ instmods() { + --set-version $kernel ${_moddirname} $_mpargs + ((_ret+=$?)) + else +- echo $_mod >> "$initdir/.kernelmodseen/lazylist" ++ [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \ ++ echo $_mod >> "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" + fi + ;; + esac +diff --git a/dracut.sh b/dracut.sh +index 335f08b..1dc8cee 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -820,12 +820,12 @@ if [[ $kernel_only != yes ]]; then + cat $f >> "${initdir}/etc/fstab" + done + +- if [[ $DRACUT_RESOLVE_LAZY ]] && [[ -x /usr/bin/dracut-install ]]; then ++ if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then + dinfo "*** Resolving executable dependencies ***" + find "$initdir" -type f \ + '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \ + -not -path '*.ko' -print0 \ +- | xargs -0 dracut-install ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} ++ | xargs -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} + dinfo "*** Resolving executable dependencies done***" + fi + +diff --git a/dracut.spec b/dracut.spec +index 96dbc9c..06d8139 100644 +--- a/dracut.spec ++++ b/dracut.spec +@@ -19,8 +19,13 @@ Group: System Environment/Base + %if 0%{?suse_version} + Group: System/Base + %endif +-License: GPLv2+ ++ ++# The entire source code is GPLv2+ ++# except install/* which is LGPLv2.1+ ++License: GPLv2+ and LGPLv2.1+ ++ + URL: https://dracut.wiki.kernel.org/ ++ + # Source can be generated by + # http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz + Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2 +@@ -235,7 +240,6 @@ rm -rf $RPM_BUILD_ROOT + %if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999 + %{_bindir}/mkinitrd + %{_bindir}/lsinitrd +-%{_bindir}/dracut-install + %endif + %dir %{dracutlibdir} + %dir %{dracutlibdir}/modules.d +@@ -244,6 +248,7 @@ rm -rf $RPM_BUILD_ROOT + %{dracutlibdir}/dracut-version.sh + %{dracutlibdir}/dracut-logger.sh + %{dracutlibdir}/dracut-initramfs-restore ++%{dracutlibdir}/dracut-install + %config(noreplace) /etc/dracut.conf + %if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} + %config /etc/dracut.conf.d/01-dist.conf +diff --git a/install/Makefile b/install/Makefile +index 59532a8..5332f25 100644 +--- a/install/Makefile ++++ b/install/Makefile +@@ -1,17 +1,7 @@ +-prefix ?= /usr +-bindir ?= ${prefix}/bin +-strip ?= -s +- +-all: dracut-install +- +-dracut-install: dracut-install.c hashmap.c log.c util.c +- gcc -std=gnu99 -O2 -g -Wall -o dracut-install dracut-install.c hashmap.c log.c util.c +- +-install: dracut-install +- install $(strip) -m 0755 dracut-install $(DESTDIR)$(bindir)/dracut-install ++all: ++ $(MAKE) -C .. + + clean: +- rm -f dracut-install *~ ++ $(MAKE) -C .. clean + +-indent: +- indent -i8 -nut -br -linux -l120 dracut-install.c ++.PHONY: all clean diff --git a/0003-98usrmount-force-mounting-usr-read-only-option-rd.us.patch b/0003-98usrmount-force-mounting-usr-read-only-option-rd.us.patch new file mode 100644 index 0000000..63cf733 --- /dev/null +++ b/0003-98usrmount-force-mounting-usr-read-only-option-rd.us.patch @@ -0,0 +1,47 @@ +From 2ee48b4b4b07e28980ff851991d2884d8c76c12c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= +Date: Fri, 29 Jun 2012 13:58:18 +0200 +Subject: [PATCH] 98usrmount: force mounting /usr read-only option + (rd.usrmount.ro) + +--- + dracut.cmdline.7.asc | 5 +++++ + modules.d/98usrmount/mount-usr.sh | 9 +++++++-- + 2 files changed, 12 insertions(+), 2 deletions(-) + +diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc +index 883223c..5669700 100644 +--- a/dracut.cmdline.7.asc ++++ b/dracut.cmdline.7.asc +@@ -76,6 +76,11 @@ resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7 + ---- + + ++**rd.usrmount.ro**: ++ force mounting _/usr_ read-only. Use this option if your init system ++ performs remount of _/usr_ the same as it does with rootfs. ++ ++ + Misc + ~~~~ + **rd.driver.blacklist=**_[,,...]_:: +diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh +index 92638d1..748ac01 100755 +--- a/modules.d/98usrmount/mount-usr.sh ++++ b/modules.d/98usrmount/mount-usr.sh +@@ -68,8 +68,13 @@ mount_usr() + _ret=$? + echo $_ret >/run/initramfs/usr-fsck + if [ $_ret -ne 255 ]; then +- info "Mounting /usr" +- mount "$NEWROOT/usr" 2>&1 | vinfo ++ if getargbool 0 rd.usrmount.ro; then ++ info "Mounting /usr (read-only forced)" ++ mount -r "$NEWROOT/usr" 2>&1 | vinfo ++ else ++ info "Mounting /usr" ++ mount "$NEWROOT/usr" 2>&1 | vinfo ++ fi + fi + fi + } diff --git a/0004-99base-don-t-require-fs-lib-to-detect-rootfstype.patch b/0004-99base-don-t-require-fs-lib-to-detect-rootfstype.patch new file mode 100644 index 0000000..1371bdf --- /dev/null +++ b/0004-99base-don-t-require-fs-lib-to-detect-rootfstype.patch @@ -0,0 +1,25 @@ +From e42b6f9e1504290f54be0074eb51a025c812e84f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= +Date: Fri, 29 Jun 2012 13:58:19 +0200 +Subject: [PATCH] 99base: don't require fs-lib to detect rootfstype + +If fs-lib is not included, no rootfs autodetection is performed. +--- + modules.d/99base/mount-hook.sh | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/modules.d/99base/mount-hook.sh b/modules.d/99base/mount-hook.sh +index dcf1415..db07866 100755 +--- a/modules.d/99base/mount-hook.sh ++++ b/modules.d/99base/mount-hook.sh +@@ -4,7 +4,9 @@ + + PATH=/usr/sbin:/usr/bin:/sbin:/bin + type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh +-type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh ++type det_fs >/dev/null 2>&1 || [ -f /lib/fs-lib.sh ] && . /lib/fs-lib.sh ++# If fs-lib is not included use following det_fs replacement. ++type det_fs >/dev/null 2>&1 || det_fs() { echo "${2:-auto}"; } + + mountpoint="$1" + ismounted "$mountpoint" && exit 0 diff --git a/0005-new-option-rd.skipfsck-to-skip-fsck-for-rootfs-and-u.patch b/0005-new-option-rd.skipfsck-to-skip-fsck-for-rootfs-and-u.patch new file mode 100644 index 0000000..3e2ee16 --- /dev/null +++ b/0005-new-option-rd.skipfsck-to-skip-fsck-for-rootfs-and-u.patch @@ -0,0 +1,68 @@ +From 9fb01d49d6fa9772caed7eaa184072ff365b7d80 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= +Date: Fri, 29 Jun 2012 13:58:20 +0200 +Subject: [PATCH] new option: rd.skipfsck to skip fsck for rootfs and /usr + +--- + dracut.cmdline.7.asc | 4 ++++ + modules.d/95rootfs-block/mount-root.sh | 4 +++- + modules.d/98usrmount/mount-usr.sh | 15 ++++++++------- + 3 files changed, 15 insertions(+), 8 deletions(-) + +diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc +index 5669700..3bfb53a 100644 +--- a/dracut.cmdline.7.asc ++++ b/dracut.cmdline.7.asc +@@ -75,6 +75,10 @@ resume=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 + resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7 + ---- + ++**rd.skipfsck**:: ++ skip fsck for rootfs and _/usr_. If you're mounting _/usr_ read-only and ++ the init system performs fsck before remount, you might want to use this ++ option to avoid duplication. + + **rd.usrmount.ro**: + force mounting _/usr_ read-only. Use this option if your init system +diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh +index 2cae526..9109638 100755 +--- a/modules.d/95rootfs-block/mount-root.sh ++++ b/modules.d/95rootfs-block/mount-root.sh +@@ -103,7 +103,9 @@ mount_root() { + # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab + + ran_fsck=0 +- if [ -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then ++ if [ -z "$fastboot" -a "$READONLY" != "yes" ] && \ ++ ! strstr "${rflags},${rootopts}" _netdev && \ ++ ! getargbool 0 rd.skipfsck; then + umount "$NEWROOT" + fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions" + _ret=$? +diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh +index 748ac01..5798777 100755 +--- a/modules.d/98usrmount/mount-usr.sh ++++ b/modules.d/98usrmount/mount-usr.sh +@@ -60,14 +60,15 @@ mount_usr() + + if [ "x$_usr_found" != "x" ]; then + # we have to mount /usr +- if [ "0" != "${_passno:-0}" ]; then +- fsck_usr "$_dev" "$_fs" "$_opts" +- else +- : ++ _fsck_ret=0 ++ if ! getargbool 0 rd.skipfsck; then ++ if [ "0" != "${_passno:-0}" ]; then ++ fsck_usr "$_dev" "$_fs" "$_opts" ++ _fsck_ret=$? ++ echo $_fsck_ret >/run/initramfs/usr-fsck ++ fi + fi +- _ret=$? +- echo $_ret >/run/initramfs/usr-fsck +- if [ $_ret -ne 255 ]; then ++ if [ $_fsck_ret -ne 255 ]; then + if getargbool 0 rd.usrmount.ro; then + info "Mounting /usr (read-only forced)" + mount -r "$NEWROOT/usr" 2>&1 | vinfo diff --git a/0006-95rootfs-block-skip-checks-rel.-to-fsck-if-rd.skipfs.patch b/0006-95rootfs-block-skip-checks-rel.-to-fsck-if-rd.skipfs.patch new file mode 100644 index 0000000..5130b3c --- /dev/null +++ b/0006-95rootfs-block-skip-checks-rel.-to-fsck-if-rd.skipfs.patch @@ -0,0 +1,51 @@ +From 965c2d8760cd862eff1c0401db57cadb0e1b4eed Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= +Date: Fri, 29 Jun 2012 13:58:21 +0200 +Subject: [PATCH] 95rootfs-block: skip checks rel. to fsck if rd.skipfsck is + supplied + +--- + modules.d/95rootfs-block/mount-root.sh | 29 ++++++++++++++++------------- + 1 file changed, 16 insertions(+), 13 deletions(-) + +diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh +index 9109638..19f59fa 100755 +--- a/modules.d/95rootfs-block/mount-root.sh ++++ b/modules.d/95rootfs-block/mount-root.sh +@@ -54,20 +54,23 @@ mount_root() { + fsckoptions=$(cat "$NEWROOT"/fsckoptions) + fi + +- if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then +- fsckoptions="-f $fsckoptions" +- elif [ -f "$NEWROOT"/.autofsck ]; then +- [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && . "$NEWROOT"/etc/sysconfig/autofsck +- if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then +- AUTOFSCK_OPT="$AUTOFSCK_OPT -f" +- fi +- if [ -n "$AUTOFSCK_SINGLEUSER" ]; then +- warn "*** Warning -- the system did not shut down cleanly. " +- warn "*** Dropping you to a shell; the system will continue" +- warn "*** when you leave the shell." +- emergency_shell ++ if ! getargbool 0 rd.skipfsck; then ++ if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then ++ fsckoptions="-f $fsckoptions" ++ elif [ -f "$NEWROOT"/.autofsck ]; then ++ [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && \ ++ . "$NEWROOT"/etc/sysconfig/autofsck ++ if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then ++ AUTOFSCK_OPT="$AUTOFSCK_OPT -f" ++ fi ++ if [ -n "$AUTOFSCK_SINGLEUSER" ]; then ++ warn "*** Warning -- the system did not shut down cleanly. " ++ warn "*** Dropping you to a shell; the system will continue" ++ warn "*** when you leave the shell." ++ emergency_shell ++ fi ++ fsckoptions="$AUTOFSCK_OPT $fsckoptions" + fi +- fsckoptions="$AUTOFSCK_OPT $fsckoptions" + fi + + rootopts= diff --git a/0007-dracut-functions.sh-set-LC_ALL-C-to-get-correct-pars.patch b/0007-dracut-functions.sh-set-LC_ALL-C-to-get-correct-pars.patch new file mode 100644 index 0000000..0c841cc --- /dev/null +++ b/0007-dracut-functions.sh-set-LC_ALL-C-to-get-correct-pars.patch @@ -0,0 +1,23 @@ +From 0e95d84892d06ff14e4d6b321dad05344724934e Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 11:27:36 +0200 +Subject: [PATCH] dracut-functions.sh: set LC_ALL=C to get correct parsing + information + +--- + dracut-functions.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index 5acf6f6..cd9426e 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -19,7 +19,7 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + # +- ++export LC_ALL=C + + if [[ $DRACUT_KERNEL_LAZY ]] && ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then + if ! [[ -d "$initdir/.kernelmodseen" ]]; then diff --git a/0008-do-not-umount-root-remount-it.-do-not-mount-ro-if-no.patch b/0008-do-not-umount-root-remount-it.-do-not-mount-ro-if-no.patch new file mode 100644 index 0000000..710d882 --- /dev/null +++ b/0008-do-not-umount-root-remount-it.-do-not-mount-ro-if-no.patch @@ -0,0 +1,117 @@ +From 7209df9e912c73318dcb380838bc1dbe24a43a4b Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 11:29:30 +0200 +Subject: [PATCH] do not umount root, remount it. do not mount ro if not + specified + +also mount /usr readonly if "ro" is specified on the command line +if /usr is a btrfs subvolume of root, use the same mount options +--- + modules.d/95rootfs-block/mount-root.sh | 20 +++++++++----------- + modules.d/98usrmount/mount-usr.sh | 9 +++++++++ + modules.d/99base/parse-root-opts.sh | 6 ++++-- + 3 files changed, 22 insertions(+), 13 deletions(-) + +diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh +index 19f59fa..932571a 100755 +--- a/modules.d/95rootfs-block/mount-root.sh ++++ b/modules.d/95rootfs-block/mount-root.sh +@@ -15,7 +15,6 @@ filter_rootopts() { + local v + while [ $# -gt 0 ]; do + case $1 in +- rw|ro);; + defaults);; + *) + v="$v,${1}";; +@@ -82,7 +81,7 @@ mount_root() { + # the root filesystem, + # remount it with the proper options + rootopts="defaults" +- while read dev mp fs opts rest; do ++ while read dev mp fs opts dump fsck; do + # skip comments + [ "${dev%%#*}" != "$dev" ] && continue + +@@ -90,6 +89,7 @@ mount_root() { + # sanity - determine/fix fstype + rootfs=$(det_fs "${root#block:}" "$fs") + rootopts=$opts ++ rootfsck=$fsck + break + fi + done < "$NEWROOT/etc/fstab" +@@ -99,28 +99,26 @@ mount_root() { + + # we want rootflags (rflags) to take precedence so prepend rootopts to + # them; rflags is guaranteed to not be empty +- rflags="${rootopts:+"${rootopts},"}${rflags}" ++ rflags="${rootopts:+${rootopts},}${rflags}" + + # backslashes are treated as escape character in fstab + # esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g') + # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab + + ran_fsck=0 +- if [ -z "$fastboot" -a "$READONLY" != "yes" ] && \ +- ! strstr "${rflags},${rootopts}" _netdev && \ ++ if [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \ ++ ! strstr "${rflags}" _netdev && \ + ! getargbool 0 rd.skipfsck; then +- umount "$NEWROOT" + fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions" + _ret=$? + [ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck + ran_fsck=1 + fi + +- if [ -n "$rootopts" -o "$ran_fsck" = "1" ]; then +- info "Remounting ${root#block:} with -o ${rflags}" +- umount "$NEWROOT" &>/dev/null +- mount -t "$rootfs" -o "$rflags" "${root#block:}" "$NEWROOT" 2>&1 | vinfo +- fi ++ echo "${root#block:} $NEWROOT $rootfs ${rflags:-defaults} 0 $rootfsck" >> /etc/fstab ++ ++ info "Remounting ${root#block:} with -o ${rflags}" ++ mount -o remount "$NEWROOT" 2>&1 | vinfo + + [ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null + [ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null +diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh +index 5798777..5cf4eb8 100755 +--- a/modules.d/98usrmount/mount-usr.sh ++++ b/modules.d/98usrmount/mount-usr.sh +@@ -52,6 +52,15 @@ mount_usr() + _dev="/dev/disk/by-uuid/${_dev#UUID=}" + ;; + esac ++ if strstr "$_opts" "subvol=" && \ ++ [ "${root#block:}" -ef $_dev ] ++ [ -n "$rflags" ]; then ++ # for btrfs subvolumes we have to mount /usr with the same rflags ++ _opts="${_opts:+${_opts},}${rflags}" ++ elif getarg ro; then ++ # if "ro" is specified, we want /usr to be readonly, too ++ _opts="${_opts:+${_opts},}ro" ++ fi + echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_freq $_passno" + _usr_found="1" + break +diff --git a/modules.d/99base/parse-root-opts.sh b/modules.d/99base/parse-root-opts.sh +index 2f427aa..44dcc09 100755 +--- a/modules.d/99base/parse-root-opts.sh ++++ b/modules.d/99base/parse-root-opts.sh +@@ -5,9 +5,11 @@ + root=$(getarg root=) + + if rflags="$(getarg rootflags=)"; then +- getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro" ++ getarg rw && rflags="${rflags},rw" ++ getarg ro && rflags="${rflags},ro" + else +- getarg rw && rflags=rw || rflags=ro ++ getarg rw && rflags=rw ++ getarg ro && rflags=ro + fi + + fstype="$(getarg rootfstype=)" diff --git a/0009-dracut-install.c-give-info-that-SOURCE-argument-is-m.patch b/0009-dracut-install.c-give-info-that-SOURCE-argument-is-m.patch new file mode 100644 index 0000000..5f969b7 --- /dev/null +++ b/0009-dracut-install.c-give-info-that-SOURCE-argument-is-m.patch @@ -0,0 +1,21 @@ +From 34e43ceb0df05081b737f932b0bc2f0426fb5276 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 11:31:38 +0200 +Subject: [PATCH] dracut-install.c: give info that SOURCE argument is missing + +--- + install/dracut-install.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/install/dracut-install.c b/install/dracut-install.c +index 86c32db..778881a 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -601,6 +601,7 @@ static int parse_argv(int argc, char *argv[]) + } + + if (!optind || optind == argc) { ++ log_error("No SOURCE argument given"); + usage(EXIT_FAILURE); + } + diff --git a/0010-dracut.sh-do-not-lazy-resolve-include-directories.patch b/0010-dracut.sh-do-not-lazy-resolve-include-directories.patch new file mode 100644 index 0000000..c1e0ce3 --- /dev/null +++ b/0010-dracut.sh-do-not-lazy-resolve-include-directories.patch @@ -0,0 +1,67 @@ +From 998bf6e0888d93443278c2ff5335fc594d318e4b Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 11:33:19 +0200 +Subject: [PATCH] dracut.sh: do not lazy resolve "include" directories + +--- + dracut.sh | 40 +++++++++++++++++++++------------------- + 1 file changed, 21 insertions(+), 19 deletions(-) + +diff --git a/dracut.sh b/dracut.sh +index 1dc8cee..c4562e6 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -783,6 +783,27 @@ if [[ $no_kernel != yes ]]; then + dinfo "*** Installing kernel module dependencies and firmware done ***" + fi + ++if [[ $kernel_only != yes ]]; then ++ (( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]} ++ ++ while pop fstab_lines line; do ++ echo "$line 0 0" >> "${initdir}/etc/fstab" ++ done ++ ++ for f in $add_fstab; do ++ cat $f >> "${initdir}/etc/fstab" ++ done ++ ++ if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then ++ dinfo "*** Resolving executable dependencies ***" ++ find "$initdir" -type f \ ++ '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \ ++ -not -path '*.ko' -print0 \ ++ | xargs -r -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} ++ dinfo "*** Resolving executable dependencies done***" ++ fi ++fi ++ + while pop include_src src && pop include_target tgt; do + if [[ $src && $tgt ]]; then + if [[ -f $src ]]; then +@@ -810,25 +831,6 @@ while pop include_src src && pop include_target tgt; do + done + + if [[ $kernel_only != yes ]]; then +- (( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]} +- +- while pop fstab_lines line; do +- echo "$line 0 0" >> "${initdir}/etc/fstab" +- done +- +- for f in $add_fstab; do +- cat $f >> "${initdir}/etc/fstab" +- done +- +- if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then +- dinfo "*** Resolving executable dependencies ***" +- find "$initdir" -type f \ +- '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \ +- -not -path '*.ko' -print0 \ +- | xargs -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} +- dinfo "*** Resolving executable dependencies done***" +- fi +- + # make sure that library links are correct and up to date + for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do + [[ -f $f ]] && inst_simple "$f" diff --git a/0011-dracut-functions.sh-dracut.sh-use-xargs-with-r.patch b/0011-dracut-functions.sh-dracut.sh-use-xargs-with-r.patch new file mode 100644 index 0000000..8a11e8c --- /dev/null +++ b/0011-dracut-functions.sh-dracut.sh-use-xargs-with-r.patch @@ -0,0 +1,77 @@ +From 73575f11a9255704643b47ad0494cd2aabdce04c Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 11:34:13 +0200 +Subject: [PATCH] dracut-functions.sh,dracut.sh: use xargs with "-r" + +--- + dracut-functions.sh | 17 ++++++++--------- + dracut.sh | 2 +- + 2 files changed, 9 insertions(+), 10 deletions(-) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index cd9426e..80b022f 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -1197,7 +1197,7 @@ dracut_kernel_post() { + local _moddirname=${srcmods%%/lib/modules/*} + + if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && [[ -f "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" ]]; then +- xargs modprobe -a ${_moddirname+-d ${_moddirname}/} --ignore-install --show-depends \ ++ xargs -r modprobe -a ${_moddirname+-d ${_moddirname}/} --ignore-install --show-depends \ + < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" 2>/dev/null \ + | sort -u \ + | while read _cmd _modpath _options; do +@@ -1206,8 +1206,8 @@ dracut_kernel_post() { + done > "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" + + ( +- if [[ -x $DRACUT_INSTALL ]] && [[ -z $_moddirname ]]; then +- xargs $DRACUT_INSTALL ${initdir+-D "$initdir"} -a < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" ++ if [[ $DRACUT_INSTALL ]] && [[ -z $_moddirname ]]; then ++ xargs -r $DRACUT_INSTALL ${initdir+-D "$initdir"} -a < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" + else + while read _modpath; do + local _destpath=$_modpath +@@ -1218,16 +1218,15 @@ dracut_kernel_post() { + fi + ) & + +- +- if [[ -x $DRACUT_INSTALL ]]; then +- xargs modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" \ ++ if [[ $DRACUT_INSTALL ]]; then ++ xargs -r modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" \ + | while read line; do + for _fwdir in $fw_dir; do + echo $_fwdir/$line; + done; +- done |xargs $DRACUT_INSTALL ${initdir+-D "$initdir"} -a -o ++ done | xargs -r $DRACUT_INSTALL ${initdir+-D "$initdir"} -a -o + else +- for _fw in $(xargs modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"); do ++ for _fw in $(xargs -r modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"); do + for _fwdir in $fw_dir; do + if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then + inst_simple "$_fwdir/$_fw" "/lib/firmware/$_fw" +@@ -1273,7 +1272,7 @@ find_kernel_modules_by_path () ( + IFS=$_OLDIFS + else + ( cd /sys/module; echo *; ) \ +- | xargs modinfo -F filename -k $kernel 2>/dev/null ++ | xargs -r modinfo -F filename -k $kernel 2>/dev/null + fi + return 0 + ) +diff --git a/dracut.sh b/dracut.sh +index c4562e6..7ca3e8d 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -879,7 +879,7 @@ if [[ $do_strip = yes ]] ; then + find "$initdir" -type f \ + '(' -perm -0100 -or -perm -0010 -or -perm -0001 \ + -or -path '*/lib/modules/*.ko' ')' -print0 \ +- | xargs -0 strip -g 2>/dev/null ++ | xargs -r -0 strip -g 2>/dev/null + dinfo "*** Stripping files done ***" + fi + diff --git a/0012-add-hardlink-nohardlink-options.patch b/0012-add-hardlink-nohardlink-options.patch new file mode 100644 index 0000000..4e98a78 --- /dev/null +++ b/0012-add-hardlink-nohardlink-options.patch @@ -0,0 +1,92 @@ +From 04d18f558743aa5b3430fe71fc8f9d7facd489ea Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 11:34:46 +0200 +Subject: [PATCH] add "--hardlink" "--nohardlink" options + +--- + dracut.8.asc | 10 ++++++++-- + dracut.sh | 20 ++++++++++++++------ + 2 files changed, 22 insertions(+), 8 deletions(-) + +diff --git a/dracut.8.asc b/dracut.8.asc +index bab5996..196e2e8 100644 +--- a/dracut.8.asc ++++ b/dracut.8.asc +@@ -183,10 +183,16 @@ example: + inhibit installation of any fsck tools + + **--strip**:: +- strip binaries in the initramfs (default) ++ strip binaries in the initramfs + + **--nostrip**:: +- do not strip binaries in the initramfs ++ do not strip binaries in the initramfs (default) ++ ++**--hardlink**:: ++ hardlink files in the initramfs (default) ++ ++**--nohardlink**:: ++ do not hardlink files in the initramfs + + **--prefix** __:: + prefix initramfs files with the specified directory +diff --git a/dracut.sh b/dracut.sh +index 7ca3e8d..4a6d5c7 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -65,6 +65,8 @@ Creates initial ramdisk images for preloading modules + --no-kernel Do not install kernel drivers and firmware files + --strip Strip binaries in the initramfs + --nostrip Do not strip binaries in the initramfs (default) ++ --hardlink Hardlink files in the initramfs (default) ++ --nohardlink Do not hardlink files in the initramfs + --prefix [DIR] Prefix initramfs files with [DIR] + --noprefix Do not prefix initramfs files (default) + --mdadmconf Include local /etc/mdadm.conf +@@ -251,6 +253,8 @@ while (($# > 0)); do + --no-kernel) kernel_only="no"; no_kernel="yes";; + --strip) do_strip_l="yes";; + --nostrip) do_strip_l="no";; ++ --hardlink) do_hardlink_l="yes";; ++ --nohardlink) do_hardlink_l="no";; + --noprefix) prefix_l="/";; + --mdadmconf) mdadmconf_l="yes";; + --nomdadmconf) mdadmconf_l="no";; +@@ -434,6 +438,9 @@ stdloglvl=$((stdloglvl + verbosity_mod_l)) + + [[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l + [[ $do_strip_l ]] && do_strip=$do_strip_l ++[[ $do_strip ]] || do_strip=no ++[[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l ++[[ $do_hardlink ]] || do_hardlink=yes + [[ $prefix_l ]] && prefix=$prefix_l + [[ $prefix = "/" ]] && unset prefix + [[ $hostonly_l ]] && hostonly=$hostonly_l +@@ -444,7 +451,6 @@ stdloglvl=$((stdloglvl + verbosity_mod_l)) + [[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware" + [[ $tmpdir_l ]] && tmpdir="$tmpdir_l" + [[ $tmpdir ]] || tmpdir=/var/tmp +-[[ $do_strip ]] || do_strip=no + [[ $compress_l ]] && compress=$compress_l + [[ $show_modules_l ]] && show_modules=$show_modules_l + [[ $nofscks_l ]] && nofscks="yes" +@@ -883,11 +889,13 @@ if [[ $do_strip = yes ]] ; then + dinfo "*** Stripping files done ***" + fi + +-type hardlink &>/dev/null && { +- dinfo "*** hardlinking files ***" +- hardlink "$initdir" 2>&1 +- dinfo "*** hardlinking files done ***" +-} ++if [[ $do_hardlink = yes ]] ; then ++ type hardlink &>/dev/null && { ++ dinfo "*** hardlinking files ***" ++ hardlink "$initdir" 2>&1 ++ dinfo "*** hardlinking files done ***" ++ } ++fi + + dinfo "*** Creating image file ***" + if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \ diff --git a/0013-new-testsuite-test-TEST-03-USR-MOUNT.patch b/0013-new-testsuite-test-TEST-03-USR-MOUNT.patch new file mode 100644 index 0000000..ae0dd20 --- /dev/null +++ b/0013-new-testsuite-test-TEST-03-USR-MOUNT.patch @@ -0,0 +1,295 @@ +From ef9b54cfe652c19ad38f19bf4fd13a9e7a9705b2 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 11:38:24 +0200 +Subject: [PATCH] new testsuite test TEST-03-USR-MOUNT + +mounts /usr as a btrfs subvolume and should respect "rw" and "ro" kernel +command line arguments properly. +--- + test/TEST-03-USR-MOUNT/99-idesymlinks.rules | 8 ++ + test/TEST-03-USR-MOUNT/Makefile | 10 ++ + test/TEST-03-USR-MOUNT/create-root.sh | 29 ++++++ + test/TEST-03-USR-MOUNT/cryptroot-ask.sh | 6 ++ + test/TEST-03-USR-MOUNT/fstab | 2 + + test/TEST-03-USR-MOUNT/hard-off.sh | 3 + + test/TEST-03-USR-MOUNT/test-init.sh | 31 +++++++ + test/TEST-03-USR-MOUNT/test.sh | 132 +++++++++++++++++++++++++++ + 8 files changed, 221 insertions(+) + create mode 100644 test/TEST-03-USR-MOUNT/99-idesymlinks.rules + create mode 100644 test/TEST-03-USR-MOUNT/Makefile + create mode 100755 test/TEST-03-USR-MOUNT/create-root.sh + create mode 100755 test/TEST-03-USR-MOUNT/cryptroot-ask.sh + create mode 100644 test/TEST-03-USR-MOUNT/fstab + create mode 100755 test/TEST-03-USR-MOUNT/hard-off.sh + create mode 100755 test/TEST-03-USR-MOUNT/test-init.sh + create mode 100755 test/TEST-03-USR-MOUNT/test.sh + +diff --git a/test/TEST-03-USR-MOUNT/99-idesymlinks.rules b/test/TEST-03-USR-MOUNT/99-idesymlinks.rules +new file mode 100644 +index 0000000..d557790 +--- /dev/null ++++ b/test/TEST-03-USR-MOUNT/99-idesymlinks.rules +@@ -0,0 +1,8 @@ ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}" +diff --git a/test/TEST-03-USR-MOUNT/Makefile b/test/TEST-03-USR-MOUNT/Makefile +new file mode 100644 +index 0000000..bc0ddb6 +--- /dev/null ++++ b/test/TEST-03-USR-MOUNT/Makefile +@@ -0,0 +1,10 @@ ++all: ++ @make -s --no-print-directory -C ../.. all ++ @basedir=../.. testdir=../ ./test.sh --all ++setup: ++ @make --no-print-directory -C ../.. all ++ @basedir=../.. testdir=../ ./test.sh --setup ++clean: ++ @basedir=../.. testdir=../ ./test.sh --clean ++run: ++ @basedir=../.. testdir=../ ./test.sh --run +diff --git a/test/TEST-03-USR-MOUNT/create-root.sh b/test/TEST-03-USR-MOUNT/create-root.sh +new file mode 100755 +index 0000000..6662bca +--- /dev/null ++++ b/test/TEST-03-USR-MOUNT/create-root.sh +@@ -0,0 +1,29 @@ ++#!/bin/sh ++# don't let udev and this script step on eachother's toes ++for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do ++ > "/etc/udev/rules.d/$x" ++done ++rm /etc/lvm/lvm.conf ++udevadm control --reload-rules ++set -e ++# save a partition at the beginning for future flagging purposes ++sfdisk -C 5120 -H 2 -S 32 -L /dev/sda </dev/sda1 ++sync ++poweroff -f ++ +diff --git a/test/TEST-03-USR-MOUNT/cryptroot-ask.sh b/test/TEST-03-USR-MOUNT/cryptroot-ask.sh +new file mode 100755 +index 0000000..db27c5b +--- /dev/null ++++ b/test/TEST-03-USR-MOUNT/cryptroot-ask.sh +@@ -0,0 +1,6 @@ ++#!/bin/sh ++ ++[ -b /dev/mapper/$2 ] && exit 0 ++echo -n test >/keyfile ++/sbin/cryptsetup luksOpen $1 $2 /dev/watchdog ++export PATH=/sbin:/bin:/usr/sbin:/usr/bin ++strstr() { [ "${1#*$2*}" != "$1" ]; } ++CMDLINE=$(while read line; do echo $line;done < /proc/cmdline) ++plymouth --quit ++exec /dev/console 2>&1 ++ ++ismounted() { ++ while read a m a; do ++ [ "$m" = "$1" ] && return 0 ++ done < /proc/mounts ++ return 1 ++} ++ ++if ismounted /usr; then ++ echo "dracut-root-block-success" >/dev/sdb ++fi ++export TERM=linux ++export PS1='initramfs-test:\w\$ ' ++[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab ++[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab ++stty sane ++echo "made it to the rootfs!" ++if strstr "$CMDLINE" "rd.shell"; then ++ strstr "$(setsid --help)" "control" && CTTY="-c" ++ setsid $CTTY sh -i ++fi ++echo "Powering down." ++mount -n -o remount,ro / ++poweroff -f +diff --git a/test/TEST-03-USR-MOUNT/test.sh b/test/TEST-03-USR-MOUNT/test.sh +new file mode 100755 +index 0000000..34a120f +--- /dev/null ++++ b/test/TEST-03-USR-MOUNT/test.sh +@@ -0,0 +1,132 @@ ++#!/bin/bash ++ ++TEST_DESCRIPTION="root filesystem on a btrfs filesystem with /usr subvolume" ++ ++KVERSION=${KVERSION-$(uname -r)} ++ ++# Uncomment this to debug failures ++#DEBUGFAIL="rd.shell rd.break" ++ ++client_run() { ++ local test_name="$1"; shift ++ local client_opts="$*" ++ ++ echo "CLIENT TEST START: $test_name" ++ ++ dd if=/dev/zero of=$TESTDIR/result bs=1M count=1 ++ $testdir/run-qemu \ ++ -hda $TESTDIR/root.btrfs \ ++ -hdb $TESTDIR/result \ ++ -m 256M -nographic \ ++ -net none -kernel /boot/vmlinuz-$KVERSION \ ++ -watchdog ib700 -watchdog-action poweroff \ ++ -append "root=LABEL=dracut $client_opts quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \ ++ -initrd $TESTDIR/initramfs.testing ++ ++ if (($? != 0)); then ++ echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" ++ return 1 ++ fi ++ ++ if ! grep -m 1 -q dracut-root-block-success $TESTDIR/result; then ++ echo "CLIENT TEST END: $test_name [FAILED]" ++ return 1 ++ fi ++ echo "CLIENT TEST END: $test_name [OK]" ++ ++} ++ ++test_run() { ++ client_run "no option specified, should fail" && return 1 ++ client_run "readonly root" "ro" || return 1 ++ client_run "writeable root" "rw" || return 1 ++ return 0 ++} ++ ++test_setup() { ++ rm -f $TESTDIR/root.btrfs ++ # Create the blank file to use as a root filesystem ++ dd if=/dev/null of=$TESTDIR/root.btrfs bs=1M seek=160 ++ ++ kernel=$KVERSION ++ # Create what will eventually be our root filesystem onto an overlay ++ ( ++ initdir=$TESTDIR/overlay/source ++ mkdir -p $initdir ++ . $basedir/dracut-functions.sh ++ dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ ++ mount dmesg ifconfig dhclient mkdir cp ping dhclient \ ++ umount strace less setsid ++ for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do ++ [ -f ${_terminfodir}/l/linux ] && break ++ done ++ dracut_install -o ${_terminfodir}/l/linux ++ inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script" ++ inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup" ++ dracut_install grep ++ inst_simple ./fstab /etc/fstab ++ inst ./test-init.sh /sbin/init ++ find_binary plymouth >/dev/null && dracut_install plymouth ++ (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) ++ cp -a /etc/ld.so.conf* $initdir/etc ++ sudo ldconfig -r "$initdir" ++ ) ++ ++ # second, install the files needed to make the root filesystem ++ ( ++ initdir=$TESTDIR/overlay ++ . $basedir/dracut-functions.sh ++ dracut_install sfdisk mkfs.btrfs btrfs poweroff cp umount sync ++ inst_hook initqueue 01 ./create-root.sh ++ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ++ ) ++ ++ # create an initramfs that will create the target root filesystem. ++ # We do it this way so that we do not risk trashing the host mdraid ++ # devices, volume groups, encrypted partitions, etc. ++ $basedir/dracut.sh -l -i $TESTDIR/overlay / \ ++ -m "dash udev-rules btrfs base rootfs-block kernel-modules" \ ++ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \ ++ --nomdadmconf \ ++ --nohardlink \ ++ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 ++ ++ # Invoke KVM and/or QEMU to actually create the target filesystem. ++ ++# echo $TESTDIR/overlay ++# echo $TESTDIR/initramfs.makeroot ++#exit 1 ++ rm -rf $TESTDIR/overlay ++ ++ $testdir/run-qemu \ ++ -hda $TESTDIR/root.btrfs \ ++ -m 256M -nographic -net none \ ++ -kernel "/boot/vmlinuz-$kernel" \ ++ -append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \ ++ -initrd $TESTDIR/initramfs.makeroot || return 1 ++ grep -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1 ++ ++ ++ ( ++ initdir=$TESTDIR/overlay ++ . $basedir/dracut-functions.sh ++ dracut_install poweroff shutdown ++ inst_hook emergency 000 ./hard-off.sh ++ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ++ ) ++ sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \ ++ -a "debug watchdog" \ ++ -o "network" \ ++ -d "piix ide-gd_mod ata_piix btrfs sd_mod ib700wdt" \ ++ -f $TESTDIR/initramfs.testing $KVERSION || return 1 ++ ++ rm -rf $TESTDIR/overlay ++ ++# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm" ++} ++ ++test_cleanup() { ++ return 0 ++} ++ ++. $testdir/test-functions diff --git a/0014-TEST-01-BASIC-grow-the-root-disk.patch b/0014-TEST-01-BASIC-grow-the-root-disk.patch new file mode 100644 index 0000000..f344dc5 --- /dev/null +++ b/0014-TEST-01-BASIC-grow-the-root-disk.patch @@ -0,0 +1,36 @@ +From 47057875e753786cc439be665859ae3ac0ee72a1 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 12:14:12 +0200 +Subject: [PATCH] TEST-01-BASIC: grow the root disk + +--- + test/TEST-01-BASIC/create-root.sh | 2 +- + test/TEST-01-BASIC/test.sh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/test/TEST-01-BASIC/create-root.sh b/test/TEST-01-BASIC/create-root.sh +index 046bfb9..ce900ad 100755 +--- a/test/TEST-01-BASIC/create-root.sh ++++ b/test/TEST-01-BASIC/create-root.sh +@@ -7,7 +7,7 @@ rm /etc/lvm/lvm.conf + udevadm control --reload-rules + set -e + # save a partition at the beginning for future flagging purposes +-sfdisk -C 1280 -H 2 -S 32 -L /dev/sda < +Date: Sat, 30 Jun 2012 12:15:04 +0200 +Subject: [PATCH] fs-lib/fs-lib.sh: skip fsck for xfs and btrfs. remount is + enough + +--- + modules.d/99fs-lib/fs-lib.sh | 28 +++++++++++++++------------- + 1 file changed, 15 insertions(+), 13 deletions(-) + +diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh +index d1b7a9d..b274935 100755 +--- a/modules.d/99fs-lib/fs-lib.sh ++++ b/modules.d/99fs-lib/fs-lib.sh +@@ -32,15 +32,17 @@ fsck_tail() { + # note: this function sets _drv of the caller + fsck_able() { + case "$1" in +- xfs) { +- type xfs_db && +- type xfs_repair && +- type xfs_check && +- type mount && +- type umount +- } >/dev/null 2>&1 && +- _drv="_drv=none fsck_drv_xfs" && +- return 0 ++ xfs) ++ # { ++ # type xfs_db && ++ # type xfs_repair && ++ # type xfs_check && ++ # type mount && ++ # type umount ++ # } >/dev/null 2>&1 && ++ # _drv="_drv=none fsck_drv_xfs" && ++ # return 0 ++ return 1 + ;; + ext?) + type e2fsck >/dev/null 2>&1 && +@@ -58,9 +60,10 @@ fsck_able() { + return 0 + ;; + btrfs) +- type btrfsck >/dev/null 2>&1 && +- _drv="_drv=none fsck_drv_btrfs" && +- return 0 ++ # type btrfsck >/dev/null 2>&1 && ++ # _drv="_drv=none fsck_drv_btrfs" && ++ # return 0 ++ return 1 + ;; + nfs*) + # nfs can be a nop, returning success +@@ -89,7 +92,6 @@ fsck_drv_btrfs() { + return 0 + } + +- + # common code for checkers that follow usual subset of options and return codes + fsck_drv_com() { + local _ret diff --git a/0016-rootfs-block-mount-root.sh-warn-if-ro-mount-failed-a.patch b/0016-rootfs-block-mount-root.sh-warn-if-ro-mount-failed-a.patch new file mode 100644 index 0000000..ed2cd33 --- /dev/null +++ b/0016-rootfs-block-mount-root.sh-warn-if-ro-mount-failed-a.patch @@ -0,0 +1,56 @@ +From 5113a3efff522664b85a75d67f674d218035696c Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 12:15:42 +0200 +Subject: [PATCH] rootfs-block/mount-root.sh: warn if ro mount failed and + remount + +remount the root filesystem, if it was not unmounted +--- + modules.d/95rootfs-block/mount-root.sh | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh +index 932571a..e61b0e8 100755 +--- a/modules.d/95rootfs-block/mount-root.sh ++++ b/modules.d/95rootfs-block/mount-root.sh +@@ -29,7 +29,10 @@ mount_root() { + local _ret + # sanity - determine/fix fstype + rootfs=$(det_fs "${root#block:}" "$fstype") +- mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT" ++ while ! mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT"; do ++ warn "Failed to mount -t ${rootfs} -o $rflags,ro ${root#block:} $NEWROOT" ++ fsck_ask_err ++ done + + READONLY= + fsckoptions= +@@ -106,9 +109,11 @@ mount_root() { + # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab + + ran_fsck=0 +- if [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \ ++ if fsck_able "$rootfs" && \ ++ [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \ + ! strstr "${rflags}" _netdev && \ + ! getargbool 0 rd.skipfsck; then ++ umount "$NEWROOT" + fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions" + _ret=$? + [ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck +@@ -117,8 +122,13 @@ mount_root() { + + echo "${root#block:} $NEWROOT $rootfs ${rflags:-defaults} 0 $rootfsck" >> /etc/fstab + +- info "Remounting ${root#block:} with -o ${rflags}" +- mount -o remount "$NEWROOT" 2>&1 | vinfo ++ if ! ismounted "$NEWROOT"; then ++ info "Mounting ${root#block:} with -o ${rflags}" ++ mount "$NEWROOT" 2>&1 | vinfo ++ else ++ info "Remounting ${root#block:} with -o ${rflags}" ++ mount -o remount "$NEWROOT" 2>&1 | vinfo ++ fi + + [ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null + [ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null diff --git a/0017-TEST-02-SYSTEMD-enlarge-the-root-disk.patch b/0017-TEST-02-SYSTEMD-enlarge-the-root-disk.patch new file mode 100644 index 0000000..bbba865 --- /dev/null +++ b/0017-TEST-02-SYSTEMD-enlarge-the-root-disk.patch @@ -0,0 +1,36 @@ +From 1d59e3e592066bd739e8c34290b87fbe97310d0d Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Sat, 30 Jun 2012 12:17:34 +0200 +Subject: [PATCH] TEST-02-SYSTEMD: enlarge the root disk + +--- + test/TEST-02-SYSTEMD/create-root.sh | 2 +- + test/TEST-02-SYSTEMD/test.sh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/test/TEST-02-SYSTEMD/create-root.sh b/test/TEST-02-SYSTEMD/create-root.sh +index 0e91ab5..fe2ce12 100755 +--- a/test/TEST-02-SYSTEMD/create-root.sh ++++ b/test/TEST-02-SYSTEMD/create-root.sh +@@ -7,7 +7,7 @@ rm /etc/lvm/lvm.conf + udevadm control --reload-rules + set -e + # save a partition at the beginning for future flagging purposes +-sfdisk -C 1280 -H 2 -S 32 -L /dev/sda < +Date: Sat, 30 Jun 2012 12:46:55 +0200 +Subject: [PATCH] dracut-functions.sh: create $initdir, if it does not exist + +--- + dracut-functions.sh | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index 80b022f..eabbb0d 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -28,6 +28,10 @@ if [[ $DRACUT_KERNEL_LAZY ]] && ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then + DRACUT_KERNEL_LAZY_HASHDIR="$initdir/.kernelmodseen" + fi + ++if [[ $initdir ]] && ! [[ -d $initdir ]]; then ++ mkdir -p "$initdir" ++fi ++ + # Generic substring function. If $2 is in $1, return 0. + strstr() { [[ $1 = *$2* ]]; } + diff --git a/0019-dracut-install.c-for-lazy-install-shebangs-do-not-ch.patch b/0019-dracut-install.c-for-lazy-install-shebangs-do-not-ch.patch new file mode 100644 index 0000000..8d03b9d --- /dev/null +++ b/0019-dracut-install.c-for-lazy-install-shebangs-do-not-ch.patch @@ -0,0 +1,140 @@ +From e74944eee578532bc7286b54ce5eccc715ed90c1 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Mon, 2 Jul 2012 18:46:48 +0200 +Subject: [PATCH] dracut-install.c: for lazy install shebangs, do not check + for existence + +--- + install/dracut-install.c | 35 +++++++++++++++++++---------------- + 1 file changed, 19 insertions(+), 16 deletions(-) + +diff --git a/install/dracut-install.c b/install/dracut-install.c +index 778881a..1d5748d 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -57,7 +57,7 @@ static char *destrootdir = NULL; + static Hashmap *items = NULL; + static Hashmap *items_failed = NULL; + +-static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps); ++static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst); + + static size_t dir_len(char const *file) + { +@@ -260,7 +260,7 @@ static int resolve_deps(const char *src) + for (q = p; *q && (!isspace(*q)); q++) ; + *q = '\0'; + log_debug("Script install: '%s'", p); +- ret = dracut_install(p, p, false, true); ++ ret = dracut_install(p, p, false, true, false); + if (ret != 0) + log_error("ERROR: failed to install '%s'", p); + return ret; +@@ -287,7 +287,7 @@ static int resolve_deps(const char *src) + int r; + for (q = p; *q && *q != ' ' && *q != '\n'; q++) ; + *q = '\0'; +- r = dracut_install(p, p, false, false); ++ r = dracut_install(p, p, false, false, true); + if (r != 0) + log_error("ERROR: failed to install '%s' for '%s'", p, src); + else +@@ -301,7 +301,7 @@ static int resolve_deps(const char *src) + *q = '\0'; + + /* ignore errors for base lib symlink */ +- if (dracut_install(p, p, false, false) == 0) ++ if (dracut_install(p, p, false, false, true) == 0) + log_debug("Lib install: '%s'", p); + } + } +@@ -328,7 +328,7 @@ static int hmac_install(const char *src, const char *dst) + asprintf(&srchmacname, "%s/.%s.hmac", srcpath, &src[dlen + 1]); + asprintf(&dsthmacname, "%s/.%s.hmac", dstpath, &src[dlen + 1]); + log_debug("hmac cp '%s' '%s')", srchmacname, dsthmacname); +- dracut_install(srchmacname, dsthmacname, false, false); ++ dracut_install(srchmacname, dsthmacname, false, false, true); + free(dsthmacname); + free(srchmacname); + free(srcpath); +@@ -336,7 +336,7 @@ static int hmac_install(const char *src, const char *dst) + return 0; + } + +-static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps) ++static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst) + { + struct stat sb, db; + char *dname = NULL; +@@ -356,11 +356,13 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + } + } + +- existing = hashmap_get(items, dst); +- if (existing) { +- if (strcmp(existing, dst) == 0) { +- log_debug("hash hit items for '%s'", dst); +- return 0; ++ if (hashdst) { ++ existing = hashmap_get(items, dst); ++ if (existing) { ++ if (strcmp(existing, dst) == 0) { ++ log_debug("hash hit items for '%s'", dst); ++ return 0; ++ } + } + } + +@@ -374,6 +376,7 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + } + } + ++ + i = strdup(dst); + hashmap_put(items, i, i); + +@@ -408,7 +411,7 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + log_debug("dest dir '%s' does not exist", fulldstdir); + dname = strdup(dst); + dname[dir_len(dname)] = '\0'; +- ret = dracut_install(dname, dname, true, false); ++ ret = dracut_install(dname, dname, true, false, true); + + free(dname); + +@@ -442,7 +445,7 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + if (abspath == NULL) + return 1; + +- if (dracut_install(abspath, abspath, false, resolvedeps)) { ++ if (dracut_install(abspath, abspath, false, resolvedeps, hashdst)) { + log_debug("'%s' install error", abspath); + return 1; + } +@@ -683,7 +686,7 @@ static int install_all(int argc, char **argv) + dest = strdup(newsrc); + + log_debug("dracut_install '%s'", newsrc); +- ret = dracut_install(newsrc, dest, arg_createdir, arg_resolvedeps); ++ ret = dracut_install(newsrc, dest, arg_createdir, arg_resolvedeps, true); + if (ret == 0) { + end = true; + log_debug("dracut_install '%s' OK", newsrc); +@@ -694,7 +697,7 @@ static int install_all(int argc, char **argv) + free(path); + } else { + char *dest = strdup(argv[i]); +- ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps); ++ ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true); + free(dest); + } + +@@ -764,7 +767,7 @@ int main(int argc, char **argv) + r = install_all(argc - optind, &argv[optind]); + } else { + /* simple "inst src dst" */ +- r = dracut_install(argv[optind], argv[optind + 1], arg_createdir, arg_resolvedeps); ++ r = dracut_install(argv[optind], argv[optind + 1], arg_createdir, arg_resolvedeps, true); + if ((r != 0) && (!arg_optional)) { + log_error("ERROR: installing '%s' to '%s'", argv[optind], argv[optind + 1]); + r = EXIT_FAILURE; diff --git a/0020-usrmount-mount-usr.sh-give-emergency_shell-if-usr-mo.patch b/0020-usrmount-mount-usr.sh-give-emergency_shell-if-usr-mo.patch new file mode 100644 index 0000000..5859478 --- /dev/null +++ b/0020-usrmount-mount-usr.sh-give-emergency_shell-if-usr-mo.patch @@ -0,0 +1,45 @@ +From f225f180e363a42307dfcdb962e751476dd1a210 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Mon, 2 Jul 2012 18:51:20 +0200 +Subject: [PATCH] usrmount/mount-usr.sh: give emergency_shell if /usr mount + failed + +--- + modules.d/98usrmount/mount-usr.sh | 22 +++++++++++++--------- + 1 file changed, 13 insertions(+), 9 deletions(-) + +diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh +index 5cf4eb8..3173241 100755 +--- a/modules.d/98usrmount/mount-usr.sh ++++ b/modules.d/98usrmount/mount-usr.sh +@@ -74,17 +74,21 @@ mount_usr() + if [ "0" != "${_passno:-0}" ]; then + fsck_usr "$_dev" "$_fs" "$_opts" + _fsck_ret=$? +- echo $_fsck_ret >/run/initramfs/usr-fsck ++ [ $_fsck_ret -ne 255 ] && echo $_fsck_ret >/run/initramfs/usr-fsck + fi + fi +- if [ $_fsck_ret -ne 255 ]; then +- if getargbool 0 rd.usrmount.ro; then +- info "Mounting /usr (read-only forced)" +- mount -r "$NEWROOT/usr" 2>&1 | vinfo +- else +- info "Mounting /usr" +- mount "$NEWROOT/usr" 2>&1 | vinfo +- fi ++ if getargbool 0 rd.usrmount.ro; then ++ info "Mounting /usr (read-only forced)" ++ mount -r "$NEWROOT/usr" 2>&1 | vinfo ++ else ++ info "Mounting /usr" ++ mount "$NEWROOT/usr" 2>&1 | vinfo ++ fi ++ if ! ismounted /usr; then ++ warn "Mounting /usr to $NEWROOT/usr failed" ++ warn "*** Dropping you to a shell; the system will continue" ++ warn "*** when you leave the shell." ++ emergency_shell + fi + fi + } diff --git a/dracut.spec b/dracut.spec index 24d09dd..5676437 100644 --- a/dracut.spec +++ b/dracut.spec @@ -10,7 +10,7 @@ Name: dracut Version: 020 -Release: 1%{?dist} +Release: 21.git20120702%{?dist} Summary: Initramfs generator using udev %if 0%{?fedora} || 0%{?rhel} @@ -19,11 +19,36 @@ Group: System Environment/Base %if 0%{?suse_version} Group: System/Base %endif -License: GPLv2+ + +# The entire source code is GPLv2+ +# except install/* which is LGPLv2.1+ +License: GPLv2+ and LGPLv2.1+ + URL: https://dracut.wiki.kernel.org/ + # Source can be generated by # http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2 +Patch1: 0001-dracut-install.c-try-clone-ioctl-for-more-speed.patch +Patch2: 0002-move-dracut-install-to-dracutbasedir.patch +Patch3: 0003-98usrmount-force-mounting-usr-read-only-option-rd.us.patch +Patch4: 0004-99base-don-t-require-fs-lib-to-detect-rootfstype.patch +Patch5: 0005-new-option-rd.skipfsck-to-skip-fsck-for-rootfs-and-u.patch +Patch6: 0006-95rootfs-block-skip-checks-rel.-to-fsck-if-rd.skipfs.patch +Patch7: 0007-dracut-functions.sh-set-LC_ALL-C-to-get-correct-pars.patch +Patch8: 0008-do-not-umount-root-remount-it.-do-not-mount-ro-if-no.patch +Patch9: 0009-dracut-install.c-give-info-that-SOURCE-argument-is-m.patch +Patch10: 0010-dracut.sh-do-not-lazy-resolve-include-directories.patch +Patch11: 0011-dracut-functions.sh-dracut.sh-use-xargs-with-r.patch +Patch12: 0012-add-hardlink-nohardlink-options.patch +Patch13: 0013-new-testsuite-test-TEST-03-USR-MOUNT.patch +Patch14: 0014-TEST-01-BASIC-grow-the-root-disk.patch +Patch15: 0015-fs-lib-fs-lib.sh-skip-fsck-for-xfs-and-btrfs.-remoun.patch +Patch16: 0016-rootfs-block-mount-root.sh-warn-if-ro-mount-failed-a.patch +Patch17: 0017-TEST-02-SYSTEMD-enlarge-the-root-disk.patch +Patch18: 0018-dracut-functions.sh-create-initdir-if-it-does-not-ex.patch +Patch19: 0019-dracut-install.c-for-lazy-install-shebangs-do-not-ch.patch +Patch20: 0020-usrmount-mount-usr.sh-give-emergency_shell-if-usr-mo.patch BuildRequires: dash bash git @@ -236,7 +261,6 @@ rm -rf $RPM_BUILD_ROOT %if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999 %{_bindir}/mkinitrd %{_bindir}/lsinitrd -%{_bindir}/dracut-install %endif %dir %{dracutlibdir} %dir %{dracutlibdir}/modules.d @@ -245,6 +269,7 @@ rm -rf $RPM_BUILD_ROOT %{dracutlibdir}/dracut-version.sh %{dracutlibdir}/dracut-logger.sh %{dracutlibdir}/dracut-initramfs-restore +%{dracutlibdir}/dracut-install %config(noreplace) /etc/dracut.conf %if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} %config /etc/dracut.conf.d/01-dist.conf @@ -347,6 +372,10 @@ rm -rf $RPM_BUILD_ROOT %dir /var/lib/dracut/overlay %changelog +* Mon Jul 02 2012 Harald Hoyer 020-21.git20120702 +- moved /usr/bin/dracut-install to /usr/lib +- more speedups + * Fri Jun 29 2012 Harald Hoyer 020-1 - version 020 - new /usr/bin/dracut-install tool