update-initramfs: Always take over other initramfs images

In Debian, update-initramfs has always refused to overwrite or delete
an initramfs image that it didn't create, unless the -t option is
used.  On Ubuntu, this check is apparently disabled.  The commit log
doesn't provide much of a clue as to why.  Looking at the the state of
Debian and the linux-2.6 package at the time, I think the reasoning
must have been something like:

(1) Multiple initramfs/initrd generators were available and could be
coinstalled.  The configuration file /etc/kernel-img.conf specified
which one kernel packages should invoke ("ramdisk" variable).

(2) Packages that hooked into initramfs-tools would always run update-
initramfs if it existed, and it would immediately update the
initramfs, because triggers hadn't yet been invented.

(3) To keep the alternate initramfs generators working, update-
initramfs therefore had to either (a) check the configuration file to
find out whether initramfs-tools was meant to be used, or (b) keep
track of which initramfs images it created and therefore "owned".

At this point, (1) is no longer true; the "ramdisk" variable is not
honoured and the initramfs generator to be invoked is chosen by
installing one of several conflicting packages.  I think this means
that (3) no longer follows, and whichever of the automatic initramfs
generator packages is currently installed should be considered to
"own" /boot/initrd.img-<version> for all kernel versions.

This commit only disables the checks.  The state directory and the
state updates are retained for now, in case it becomes necessary to
revert this change.

Closes: #765750, #804295
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
This commit is contained in:
Ben Hutchings 2018-07-25 20:25:12 +08:00
parent 312393b0cf
commit c0ae42ba8e
2 changed files with 1 additions and 61 deletions

View File

@ -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()
{
@ -264,16 +251,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 +284,6 @@ update()
ro_boot_check
altered_check
backup_initramfs
generate_initramfs
@ -326,18 +301,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 +308,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 +335,7 @@ while getopts "k:cudyvtb:h?" flag; do
yes="1"
;;
t)
takeover="1"
# accepted for compatibility, but ignored
;;
b)
BOOTDIR="${OPTARG}"
@ -428,9 +375,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

View File

@ -53,10 +53,6 @@ This mode updates an existing initramfs.
\fB \-d
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