summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-07-26 03:11:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-07-26 03:11:45 +0000
commit5479bebd6fa84ae5b9afc48256ba2ecf35ad9ce0 (patch)
tree53e2b9e6223ddbd11b25f21d263f55e6a9fa51f3
parentReleasing progress-linux version 0.131-0+dschinn1. (diff)
downloadinitramfs-tools-5479bebd6fa84ae5b9afc48256ba2ecf35ad9ce0.zip
initramfs-tools-5479bebd6fa84ae5b9afc48256ba2ecf35ad9ce0.tar.xz
Merging upstream version 0.132.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--hook-functions29
-rwxr-xr-xhooks/resume43
-rwxr-xr-xmkinitramfs14
-rw-r--r--scripts/functions34
-rwxr-xr-xupdate-initramfs67
-rw-r--r--update-initramfs.84
6 files changed, 87 insertions, 104 deletions
diff --git a/hook-functions b/hook-functions
index c18652e..58f9e63 100644
--- a/hook-functions
+++ b/hook-functions
@@ -91,9 +91,9 @@ manual_add_modules()
fi
kmod_modname="${kmod##*/}"
- kmod_modname="${kmod_modname%.ko}"
+ kmod_modname="${kmod_modname%%.*}"
if grep -q "^$kmod_modname\\>" /proc/modules "${CONFDIR}/modules"; then
- echo "W: Possible missing firmware /lib/firmware/${firmware} for module $(basename ${kmod} .ko)" >&2
+ echo "W: Possible missing firmware /lib/firmware/${firmware} for module ${kmod_modname}" >&2
fi
continue
fi
@@ -197,7 +197,7 @@ copy_exec() {
# Copy entire subtrees to the initramfs
copy_modules_dir()
{
- local kmod exclude
+ local kmod first exclude
local modules=
local dir="$1"
shift
@@ -211,12 +211,21 @@ copy_modules_dir()
echo "(excluding $*)"
fi
fi
- while [ $# -ge 1 ]; do
- exclude="${exclude:-} -name $1 -prune -o "
- shift
+
+ # Build up an expression for find
+ first=true
+ for exclude in "$@"; do
+ # Change .ko suffix in exclusion to .ko*
+ if [ "${exclude%.ko}" != "${exclude}" ]; then
+ exclude="${exclude}*"
+ fi
+ $first && set --
+ set -- "$@" -name "${exclude}" -prune -o
+ first=false
done
- for kmod in $(find "${MODULESDIR}/${dir}" ${exclude:-} -name '*.ko' -printf '%f\n'); do
- modules="$modules ${kmod%.ko}"
+
+ for kmod in $(find "${MODULESDIR}/${dir}" "$@" -name '*.ko*' -printf '%f\n'); do
+ modules="$modules ${kmod%%.*}"
done
manual_add_modules $modules
}
@@ -610,11 +619,11 @@ hidden_dep_add_modules()
manual_add_modules $(
{
cat "${DESTDIR}/lib/modules/${version}/modules.builtin"
- find "${DESTDIR}/lib/modules/${version}/kernel" -name '*.ko'
+ find "${DESTDIR}/lib/modules/${version}/kernel" -name '*.ko*'
} |
while read module; do
module="${module##*/}"
- module="${module%.ko}"
+ module="${module%%.*}"
case "$module" in
libcrc32c)
echo crc32c
diff --git a/hooks/resume b/hooks/resume
index 1869119..df6cde8 100755
--- a/hooks/resume
+++ b/hooks/resume
@@ -39,23 +39,34 @@ report_auto()
test "$RESUME" = auto || echo >&2 "I: $*"
}
-# We need to be able to read the listed swap partitions
-if ischroot || [ ! -r /proc/swaps ]; then
- resume_auto=
-else
- # Try to autodetect the RESUME partition, using biggest swap?
- resume_auto=$(grep ^/dev/ /proc/swaps | sort -rnk3 | head -n 1 | cut -d " " -f 1)
- if [ -n "$resume_auto" ]; then
+# Try to autodetect the RESUME partition, using biggest swap device that
+# is not ephemeral. We need to be able to read the listed swap partitions.
+resume_auto=
+if ! ischroot && [ -r /proc/swaps ]; then
+ for resume_auto in $(grep ^/dev/ /proc/swaps | sort -rnk3 | cut -d " " -f 1); do
+ ephemeral=false
dm_name="$(dmsetup info -c --noheadings -o name "$resume_auto" 2>/dev/null)"
- fi
- if [ -n "$dm_name" ] && [ -e /etc/crypttab ]; then
- while read cryptdev srcdev keyfile junk; do
- if [ "$cryptdev" = "$dm_name" ] && [ "$keyfile" = /dev/urandom ]; then
- resume_auto=
- fi
- done < /etc/crypttab
- fi
- if [ -n "$resume_auto" ]; then
+
+ # dm-crypt is ephemeral if the key file is /dev/urandom
+ if [ -n "$dm_name" ] && [ -e /etc/crypttab ]; then
+ while read cryptdev srcdev keyfile junk; do
+ if [ "$cryptdev" = "$dm_name" ] && [ "$keyfile" = /dev/urandom ]; then
+ ephemeral=true
+ fi
+ done < /etc/crypttab
+ fi
+
+ # zram is ephemeral
+ case "$resume_auto" in
+ /dev/zram*)
+ ephemeral=true
+ ;;
+ esac
+
+ $ephemeral || break
+ done
+
+ if [ -n "$resume_auto" ] && ! $ephemeral; then
if [ -n "$dm_name" ]; then
resume_auto_canon="/dev/mapper/$dm_name"
elif UUID=$(blkid -s UUID -o value "$resume_auto"); then
diff --git a/mkinitramfs b/mkinitramfs
index 89a61a3..4394a3c 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -215,7 +215,13 @@ export __TMPCPIOGZ
# Private, used by 'prepend_earlyinitramfs'.
export __TMPEARLYCPIO
-for d in bin conf/conf.d etc lib/modules run sbin scripts ${MODULESDIR}; do
+# Create usr-merged filesystem layout, to avoid duplicates if the host
+# filesystem is usr-merged.
+for d in /bin /lib* /sbin; do
+ mkdir -p "${DESTDIR}/usr${d}"
+ ln -s "usr${d}" "${DESTDIR}${d}"
+done
+for d in conf/conf.d etc run scripts ${MODULESDIR}; do
mkdir -p "${DESTDIR}/${d}"
done
@@ -340,8 +346,10 @@ if ! ldconfig -r "$DESTDIR" ; then
fi
# The auxiliary cache is not reproducible and is always invalid at boot
# (see #845034)
-rm -f "${DESTDIR}"/var/cache/ldconfig/aux-cache
-rmdir --ignore-fail-on-non-empty "${DESTDIR}"/var/cache/ldconfig
+if [ -d "${DESTDIR}"/var/cache/ldconfig ]; then
+ rm -f "${DESTDIR}"/var/cache/ldconfig/aux-cache
+ rmdir --ignore-fail-on-non-empty "${DESTDIR}"/var/cache/ldconfig
+fi
# Apply DSDT to initramfs
if [ -e "${CONFDIR}/DSDT.aml" ]; then
diff --git a/scripts/functions b/scripts/functions
index 0b7ca10..7c6f8aa 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -180,6 +180,26 @@ get_fstype ()
return ${RET}
}
+_handle_device_vs_ip()
+{
+ # If the ip= parameter is present and is a colon-separated list,
+ # then:
+ # - If it specifies a device, use that in preference to any
+ # device name we already have
+ # - Otherwise, substitute in any device name we already have
+ local IFS=:
+ set -f
+ set -- ${IP}
+ set +f
+ if [ -n "$6" ]; then
+ DEVICE="$6"
+ elif [ $# -ge 2 ] && [ -n "${DEVICE}" ]; then
+ IP="$1:$2:$3:$4:$5:${DEVICE}"
+ shift 6 || shift $#
+ IP="${IP}:$*"
+ fi
+}
+
configure_networking()
{
if [ -n "${BOOTIF}" ]; then
@@ -218,6 +238,8 @@ configure_networking()
done
fi
+ _handle_device_vs_ip
+
# networking already configured thus bail out
[ -n "${DEVICE}" ] && [ -e /run/net-"${DEVICE}".conf ] && return 0
@@ -249,18 +271,6 @@ configure_networking()
;;
*)
ipconfig -t ${ROUNDTTT} -d $IP
-
- # grab device entry from ip option
- NEW_DEVICE=${IP#*:*:*:*:*:*}
- if [ "${NEW_DEVICE}" != "${IP}" ]; then
- NEW_DEVICE=${NEW_DEVICE%%:*}
- else
- # wrong parse, possibly only a partial string
- NEW_DEVICE=
- fi
- if [ -n "${NEW_DEVICE}" ]; then
- DEVICE="${NEW_DEVICE}"
- fi
;;
esac
done
diff --git a/update-initramfs b/update-initramfs
index d98aaa4..e3136dc 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -47,7 +47,6 @@ Options:
-c Create a new initramfs
-u Update an existing initramfs
-d Remove an existing initramfs
- -t Take over a custom initramfs with this one
-b directory Set alternate boot directory
-v Be verbose
-h This message
@@ -79,12 +78,6 @@ verbose()
fi
}
-version_exists()
-{
- [ -e "${STATEDIR}/${1}" ] && [ -e "${initramfs}" ]
- return $?
-}
-
set_initramfs()
{
initramfs="${BOOTDIR}/initrd.img-${version}"
@@ -179,12 +172,6 @@ run_bootloader()
fi
}
-compare_sha1()
-{
- sha1sum "${initramfs}" | diff "${STATEDIR}/${version}" - >/dev/null 2>&1
- return $?
-}
-
# Note that this must overwrite so that updates work.
set_sha1()
{
@@ -215,8 +202,13 @@ ro_boot_check()
get_sorted_versions()
{
- version_list="$(ls -1 "${STATEDIR}" | linux-version sort --reverse)"
-
+ version_list="$(
+ linux-version list |
+ while read version; do
+ test -e "${BOOTDIR}/initrd.img-$version" && echo "$version"
+ done |
+ linux-version sort --reverse
+ )"
verbose "Available versions: ${version_list}"
}
@@ -264,16 +256,6 @@ create()
set_initramfs
- if [ "${takeover}" = 0 ]; then
- if version_exists "${version}"; then
- panic "Cannot create version ${version}: already exists"
- fi
-
- if [ -e "${initramfs}" ]; then
- panic "${initramfs} already exists, cannot create."
- fi
- fi
-
generate_initramfs
run_bootloader
@@ -307,8 +289,6 @@ update()
ro_boot_check
- altered_check
-
backup_initramfs
generate_initramfs
@@ -326,18 +306,6 @@ delete()
set_initramfs
- if [ "${takeover}" = 0 ]; then
- if [ ! -e "${initramfs}" ]; then
- panic "Cannot delete ${initramfs}, doesn't exist."
- fi
-
- if ! version_exists "${version}"; then
- panic "Cannot delete version ${version}: Not created by this utility."
- fi
- fi
-
- altered_check
-
echo "update-initramfs: Deleting ${initramfs}"
delete_sha1
@@ -345,25 +313,9 @@ delete()
rm -f "${initramfs}" "${initramfs}.bak"
}
-# Check for update mode on existing and modified initramfs
-altered_check()
-{
- # No check on takeover
- [ "${takeover}" = 1 ] && return 0
- if [ ! -e "${initramfs}" ]; then
- mild_panic "${initramfs} does not exist. Cannot update."
- fi
- if ! compare_sha1; then
- echo "update-initramfs: ${initramfs} has been altered." >&2
- mild_panic "update-initramfs: Cannot update. Override with -t option."
- fi
-}
-
# Defaults
verbose=0
yes=0
-# We default to takeover=1 in Ubuntu, but not Debian
-takeover=0
##
@@ -388,7 +340,7 @@ while getopts "k:cudyvtb:h?" flag; do
yes="1"
;;
t)
- takeover="1"
+ # accepted for compatibility, but ignored
;;
b)
BOOTDIR="${OPTARG}"
@@ -428,9 +380,6 @@ if [ "${version}" = "all" ] \
if [ "${verbose}" = "1" ]; then
OPTS="${OPTS} -v"
fi
- if [ "${takeover}" = "1" ]; then
- OPTS="${OPTS} -t"
- fi
if [ "${yes}" = "1" ]; then
OPTS="${OPTS} -y"
fi
diff --git a/update-initramfs.8 b/update-initramfs.8
index 4bcf756..bb88499 100644
--- a/update-initramfs.8
+++ b/update-initramfs.8
@@ -54,10 +54,6 @@ This mode updates an existing initramfs.
This mode removes an existing initramfs.
.TP
-\fB \-t
-Allows one to take over an custom initramfs with a newer one.
-
-.TP
\fB \-v
This option increases the amount of information you are given during
the chosen action.