[arch-projects] [mkinitcpio][PATCH 1/3] mkinitcpio: catch more buildtime errors
Move the unsetting of the errtrace and ERR trap flags to after the image has been built. This lets us capture errors during module installation to the build root and the call to depmod. Either of these steps failing could be hazardous and should prompt a failure. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- mkinitcpio | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index 677f608..a865770 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -335,9 +335,8 @@ for var in cfg_{MODULES,BINARIES,FILES}; do done parse_hook -# unset errtrace and trap -set +E -trap ERR +# reset the trap to catch all errors +trap '(( ++builderrors ))' ERR if (( ${#ADDED_MODULES[*]} )); then mkdir -p "${MODPATHS[@]%/*}" @@ -358,6 +357,10 @@ else warning "No modules were added to the image. This is probably not what you want." fi +# unset errtrace and trap +set +E +trap ERR + declare -i status=0 declare -a pipesave if [[ "${GENIMG}" ]]; then -- 1.7.9.1
depmod doesn't care where modules are, within reason, and separating modules into the respective hierarchies only serves to irritate users who go looking for modules in the rootfs (aka me). Forget all this and dump everything into the kernel/ dir. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- mkinitcpio | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index a865770..f79fbcb 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -200,7 +200,7 @@ workdir=$(TMPDIR=$TMPDIR mktemp -d --tmpdir mkinitcpio.XXXXXX) BUILDROOT=$workdir/root # explicitly create the buildroot -mkdir "$BUILDROOT" +mkdir -p "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" # use preset $PRESET if [[ $PRESET ]]; then @@ -339,11 +339,7 @@ parse_hook trap '(( ++builderrors ))' ERR if (( ${#ADDED_MODULES[*]} )); then - mkdir -p "${MODPATHS[@]%/*}" - - pushd "${BASEDIR:-/}" >/dev/null - cp --parents "${MODPATHS[@]/#$BASEDIR/.}" "$BUILDROOT" - popd >/dev/null + cp "${MODPATHS[@]}" "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" msg "Generating module dependencies" install -m644 -t "$BUILDROOT/lib/modules/$KERNELVERSION" \ -- 1.7.9.1
From: Tom Gunderson <teg@jklm.no> This increases compression efficiency, which might be useful on an image containing a lot of modules. For the usecase I had in mind, this reduced the size by about a quarter. Signed-off-by: Tom Gundersen <teg@jklm.no> Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- Resending this as its rebased/rewritten with Tom's name on it. mkinitcpio | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index f79fbcb..637795f 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -341,6 +341,9 @@ trap '(( ++builderrors ))' ERR if (( ${#ADDED_MODULES[*]} )); then cp "${MODPATHS[@]}" "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" + # unzip modules prior to recompression + gzip -dr "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" + msg "Generating module dependencies" install -m644 -t "$BUILDROOT/lib/modules/$KERNELVERSION" \ "$BASEDIR/lib/modules/$KERNELVERSION"/modules.{builtin,order} -- 1.7.9.1
[Thursday 16 February 2012] [17:35:34] <falconindy> tomegun: im forging your name on a mkinitcpio patch On Fri, Feb 17, 2012 at 3:06 PM, Dave Reisner <d@falconindy.com> wrote:
From: Tom Gunderson <teg@jklm.no> [...] Signed-off-by: Tom Gundersen <teg@jklm.no>
Not a very impressive forgery, but apart from that no objections. -t
On Fri, Feb 17, 2012 at 09:06:01AM -0500, Dave Reisner wrote:
From: Tom Gunderson <teg@jklm.no>
This increases compression efficiency, which might be useful on an image containing a lot of modules.
For the usecase I had in mind, this reduced the size by about a quarter.
Signed-off-by: Tom Gundersen <teg@jklm.no> ^ borka, bork bork
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- Resending this as its rebased/rewritten with Tom's name on it.
mkinitcpio | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/mkinitcpio b/mkinitcpio index f79fbcb..637795f 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -341,6 +341,9 @@ trap '(( ++builderrors ))' ERR if (( ${#ADDED_MODULES[*]} )); then cp "${MODPATHS[@]}" "$BUILDROOT/lib/modules/$KERNELVERSION/kernel"
+ # unzip modules prior to recompression + gzip -dr "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" + msg "Generating module dependencies" install -m644 -t "$BUILDROOT/lib/modules/$KERNELVERSION" \ "$BASEDIR/lib/modules/$KERNELVERSION"/modules.{builtin,order} -- 1.7.9.1
participants (2)
-
Dave Reisner
-
Tom Gundersen