fixed to fail on unclean gencpio termination
This commit is contained in:
parent
8acfa120d5
commit
9e2ed8993a
21
mkinitfs
21
mkinitfs
@ -1,22 +1,29 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
out=$1
|
||||
shift
|
||||
PROG=mkinitfs
|
||||
|
||||
[ -n "$out" ] || {
|
||||
echo "Usage: mkinitfs outfile" >&2
|
||||
Fatal()
|
||||
{
|
||||
echo "$PROG: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
TEMP=
|
||||
|
||||
exit_handler()
|
||||
{
|
||||
local rc=$?
|
||||
trap - EXIT
|
||||
[ $rc -eq 0 ] || rm -f -- $out
|
||||
[ -z "$TEMP" ] || rm -f -- "$TEMP"
|
||||
[ $rc -eq 0 ] || rm -f -- "$OUT"
|
||||
exit $rc
|
||||
}
|
||||
|
||||
[ -n "$1" ] || Fatal "Usage: mkinitfs outfile"
|
||||
OUT="$1"; shift
|
||||
|
||||
trap exit_handler HUP PIPE INT TERM QUIT EXIT
|
||||
TEMP=`mktemp -t mkinitfs.XXXXXXXXXX` || Fatal "Failed to create temporary file."
|
||||
|
||||
(
|
||||
|
||||
@ -60,4 +67,6 @@ find /lib/mkinitrd/udev -type f|\
|
||||
sed -e 's,/lib/mkinitrd/udev,,' -e 's,^.\+$,file\t&\t/lib/mkinitrd/udev&\t0755\t0 0,g'
|
||||
find /etc/modprobe.d/ /etc/udev/rules.d -type f|\
|
||||
sed -e 's,^.\+$,file\t&\t&\t0644\t0 0,g'
|
||||
) | `pwd`/gencpio - |gzip -c > $out
|
||||
) | `pwd`/gencpio - > "$TEMP"
|
||||
|
||||
gzip -c < "$TEMP" > "$OUT"
|
||||
|
Loading…
Reference in New Issue
Block a user