Your message dated Thu, 15 Dec 2016 23:13:03 +0000 with message-id <1481843583.2651.4.camel@decadent.org.uk> and subject line Re: initramfs-tools: Add command to unpack initramfs has caused the Debian Bug report #807457, regarding Add command to unpack initramfs to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@bugs.debian.org immediately.) -- 807457: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=807457 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: lsinitramfs(8): multiple-segmented initramfs supported
- From: Osamu Aoki <osamu@debian.org>
- Date: Sat, 27 Jun 2015 08:53:59 +0900
- Message-id: <20150626235359.GA7601@goofy.local>
Package: initramfs-tools Version: 0.120 Severity: normal Tags: patch >From initramfs-tools 0.118 (Oct. 2014): * [d5f4cd6] lsinitramfs: Parse and list files that include early microcode. Thanks to Brett Parker and Olivier Berger. (Closes: #717805) So the manpage description as the following is incorrect. | BUGS | lsinitramfs cannot deal with multiple-segmented initramfs images, such | as those created when an early (uncompressed) initramfs with system | firmware is prepended to the regular compressed initrams, or when over‐ | lay data is appended to the initramfs. So please knock off these lines. In addition to this, I wonder why not offer utility to extract the regular compressed initrams by using the same code with trivial changes. It is pain to manually extract the new initrd image content. I attach patch here one as example against the git master. Hmmm... https://wiki.debian.org/InitramfsDebug This needs to be updated.>From 25dd1b58987a8b2c9b4a0edf979fc98b8a0e6a16 Mon Sep 17 00:00:00 2001 From: Osamu Aoki <osamu@debian.org> Date: Sat, 27 Jun 2015 08:26:03 +0900 Subject: [PATCH 1/4] multi-segment initramfs supported --- lsinitramfs.8 | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lsinitramfs.8 b/lsinitramfs.8 index 798aa8d..b07ddeb 100644 --- a/lsinitramfs.8 +++ b/lsinitramfs.8 @@ -36,13 +36,6 @@ List content of two initramfs files in verbose mode: .PP .B lsinitramfs -l /boot/vmlinuz-2.6.31-grml64 /boot/vmlinuz-2.6.33-grml64 -.SH BUGS -.BR lsinitramfs -cannot deal with multiple-segmented initramfs images, such as those created -when an early (uncompressed) initramfs with system firmware is prepended to -the regular compressed initrams, or when overlay data is appended to the -initramfs. - .SH AUTHOR The initramfs-tools are written by Maximilian Attems <maks@debian.org> and numerous others. -- 2.1.4>From 8d0ad0ce10cde2d3f1c8a9013efa4f81b376d069 Mon Sep 17 00:00:00 2001 From: Osamu Aoki <osamu@debian.org> Date: Sat, 27 Jun 2015 08:28:05 +0900 Subject: [PATCH 2/4] getinitramfs command --- getinitramfs | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 getinitramfs diff --git a/getinitramfs b/getinitramfs new file mode 100755 index 0000000..34eb43c --- /dev/null +++ b/getinitramfs @@ -0,0 +1,88 @@ +#!/bin/sh + +set -eu + +usage() +{ + echo "Usage: $(basename $0) [-l] <initramfs file>" +} + +if [ "$#" -eq 0 ] ; then + usage >&2 + exit 1 +fi + +OPTIONS=`getopt -o h --long help -n "$0" -- "$@"` +# Check for non-GNU getopt +if [ $? != 0 ] ; then echo "W: non-GNU getopt" >&2 ; exit 1 ; fi + +eval set -- "$OPTIONS" + +while true; do + case "$1" in + -h|--help) + usage + exit 0 + ;; + --) + shift + break + ;; + *) + echo "Internal error!" >&2 + exit 1 + esac +done + +# Read bytes out of a file, checking that they are valid hex digits +readhex() +{ + dd < "$1" bs=1 skip="$2" count="$3" 2> /dev/null | \ + LANG=C grep -E "^[0-9A-Fa-f]{$3}\$" +} + +# Check for a zero byte in a file +checkzero() +{ + dd < "$1" bs=1 skip="$2" count=1 2> /dev/null | \ + LANG=C grep -q -z '^$' +} + +for initramfs in "$@" ; do + if ! [ -r "${initramfs}" ] ; then + echo "Specified file could not be read." >&2 + exit 1 + else + echo "${initramfs}" + + # There may be a prepended uncompressed archive. cpio + # won't tell us the true size of this so we have to + # parse the headers and padding ourselves. This is + # very roughly based on linux/lib/earlycpio.c + offset=0 + while true; do + if checkzero "$initramfs" $offset; then + offset=$((offset + 4)) + continue + fi + magic="$(readhex "$initramfs" $offset 6)" || break + test $magic = 070701 || test $magic = 070702 || break + namesize=0x$(readhex "$initramfs" $((offset + 94)) 8) + filesize=0x$(readhex "$initramfs" $((offset + 54)) 8) + offset=$(((offset + 110))) + offset=$(((offset + $namesize + 3) & ~3)) + offset=$(((offset + $filesize + 3) & ~3)) + done + + if [ $offset -ne 0 ]; then + # Extract main archive + echo "Multi-segmented initramfs image: $initramfs" + dd < "$initramfs" bs="$offset" skip=1 2> /dev/null \ + > $initramfs.main + echo " ==> Extracted main initramfs image: $initramfs.main" + else + echo "Simple initramfs image: $initramfs" + fi + + fi +done -- 2.1.4>From 14d809dd3c432994f720c2e9267a9a87e04c6eed Mon Sep 17 00:00:00 2001 From: Osamu Aoki <osamu@debian.org> Date: Sat, 27 Jun 2015 08:47:27 +0900 Subject: [PATCH 3/4] Add getinitramfs(8) --- getinitramfs.8 | 44 ++++++++++++++++++++++++++++++++++++++++++++ lsinitramfs.8 | 1 + mkinitramfs.8 | 1 + update-initramfs.8 | 3 ++- 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 getinitramfs.8 diff --git a/getinitramfs.8 b/getinitramfs.8 new file mode 100644 index 0000000..1734612 --- /dev/null +++ b/getinitramfs.8 @@ -0,0 +1,44 @@ +.TH GETINITRAMFS 8 "2010/06/16" "Linux" "getinitramfs manual" + +.SH NAME +getinitramfs \- extract the main initramfs image + +.SH SYNOPSIS +.B getinitramfs +.RI [ options ] " <initramfsfile> " [ <initramfsfile> ] +.br + +.SH DESCRIPTION +The modern multiple-segmented initramfs image consists of the early +uncompressed initramfs containing system firmware and the compressed main +initramfs, concatenated together. + +The +.B getinitramfs +command extracts the main initramfs image with suffix +.I .main +from given initramfs images. + +.SH OPTIONS + +.TP +.B -h +Display usage information and exit. + +.SH USAGE EXAMPLES + +Get the main initramfs of current running kernel: + +.PP +.B getinitramfs /boot/initrd.img-$(uname -r) + +.SH AUTHOR +The initramfs-tools are written by Maximilian Attems <maks@debian.org> +and numerous others. + +.SH SEE ALSO +.BR +.IR initramfs-tools (8), +.IR mkinitramfs (8), +.IR lsinitramfs (8), +.IR update-initramfs (8). diff --git a/lsinitramfs.8 b/lsinitramfs.8 index b07ddeb..226cec2 100644 --- a/lsinitramfs.8 +++ b/lsinitramfs.8 @@ -44,4 +44,5 @@ and numerous others. .BR .IR initramfs-tools (8), .IR mkinitramfs (8), +.IR getinitramfs (8), .IR update-initramfs (8). diff --git a/mkinitramfs.8 b/mkinitramfs.8 index 0a109f6..3bab90d 100644 --- a/mkinitramfs.8 +++ b/mkinitramfs.8 @@ -156,3 +156,4 @@ Jeff Bailey <jbailey@raspberryginger.com> and numerous others. .IR initramfs-tools (8), .IR update-initramfs (8), .IR lsinitramfs (8). +.IR getinitramfs (8). diff --git a/update-initramfs.8 b/update-initramfs.8 index 31f225d..34b2bf1 100644 --- a/update-initramfs.8 +++ b/update-initramfs.8 @@ -96,4 +96,5 @@ Jeff Bailey <jbailey@raspberryginger.com> and numerous others. .IR initramfs.conf (5), .IR initramfs-tools (8), .IR mkinitramfs (8), -.IR lsinitramfs (8). +.IR lsinitramfs (8), +.IR getinitramfs (8). -- 2.1.4>From cb921b5de0e82663176b245870beced8da02be25 Mon Sep 17 00:00:00 2001 From: Osamu Aoki <osamu@debian.org> Date: Sat, 27 Jun 2015 08:48:55 +0900 Subject: [PATCH 4/4] update packaging for getinitramfs --- debian/initramfs-tools.install | 1 + debian/initramfs-tools.manpages | 1 + 2 files changed, 2 insertions(+) diff --git a/debian/initramfs-tools.install b/debian/initramfs-tools.install index 25d7990..160f6c6 100644 --- a/debian/initramfs-tools.install +++ b/debian/initramfs-tools.install @@ -1,4 +1,5 @@ lsinitramfs usr/bin +getinitramfs usr/bin mkinitramfs usr/sbin init usr/share/initramfs-tools scripts usr/share/initramfs-tools diff --git a/debian/initramfs-tools.manpages b/debian/initramfs-tools.manpages index d56d0bd..57a48b1 100644 --- a/debian/initramfs-tools.manpages +++ b/debian/initramfs-tools.manpages @@ -1,4 +1,5 @@ lsinitramfs.8 +getinitramfs.8 mkinitramfs.8 initramfs.conf.5 initramfs-tools.8 -- 2.1.4
--- End Message ---
--- Begin Message ---
- To: 807457-done@bugs.debian.org
- Subject: Re: initramfs-tools: Add command to unpack initramfs
- From: Ben Hutchings <ben@decadent.org.uk>
- Date: Thu, 15 Dec 2016 23:13:03 +0000
- Message-id: <1481843583.2651.4.camel@decadent.org.uk>
- In-reply-to: <20160210041816.GA18527@kevinolos>
- References: <20150626235359.GA7601@goofy.local> <1449631391.2824.128.camel@decadent.org.uk> <20160210041816.GA18527@kevinolos>
Version: 0.126 On Tue, 9 Feb 2016 20:18:16 -0800 Kevin Locke <kevin@kevinlocke.name> wrote: > On Wed, 2015-12-09 at 03:23 +0000, Ben Hutchings wrote: > > Rather than duplicating code, please combine this with lsinitramfs > > (checking $0 to determine which command was invoked) or move the common > > code into a shell library. > > I've taken a slightly different tact and implemented uninitramfs as a > thin wrapper for cpio. It is designed as a drop-in replacement for > cpio wherever an initramfs may be present, and passes through all > options unmodified. With this, I changed lsinitramfs to call > uninitramfs instead of cpio. > > See what you think. I didn't like the way it passed all options through to cpio: - It's inconsistent with the other commands - It makes it difficult to implement any additional options - cpio's default of unpacking into the current directory is dangerous So I made the initramfs file and output directory arguments, and added sensible options to cpio. The --verbose option can be passed through, and if there are other important ones we can add those later. > P.S. I named it "uninitramfs" instead of "unmkinitramfs" since it > does not depend on mkinitramfs specifically, and it seemed to fit with > "lsinitramfs" and the "initramfs" format. But if you would prefer > "unmkinitramfs", I can change it. But it is meant to work with the initramfs images that mkinitramfs creates and doesn't support arbitrary concatenations of maybe- compressed cpio archives. So, unmkinitramfs it is. Ben. -- Ben Hutchings It is easier to change the specification to fit the program than vice versa.Attachment: signature.asc
Description: This is a digitally signed message part
--- End Message ---