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
|
#!/bin/sh -e
|
||||||
|
|
||||||
out=$1
|
PROG=mkinitfs
|
||||||
shift
|
|
||||||
|
|
||||||
[ -n "$out" ] || {
|
Fatal()
|
||||||
echo "Usage: mkinitfs outfile" >&2
|
{
|
||||||
|
echo "$PROG: $*" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEMP=
|
||||||
|
|
||||||
exit_handler()
|
exit_handler()
|
||||||
{
|
{
|
||||||
local rc=$?
|
local rc=$?
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
[ $rc -eq 0 ] || rm -f -- $out
|
[ -z "$TEMP" ] || rm -f -- "$TEMP"
|
||||||
|
[ $rc -eq 0 ] || rm -f -- "$OUT"
|
||||||
exit $rc
|
exit $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ -n "$1" ] || Fatal "Usage: mkinitfs outfile"
|
||||||
|
OUT="$1"; shift
|
||||||
|
|
||||||
trap exit_handler HUP PIPE INT TERM QUIT EXIT
|
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'
|
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|\
|
find /etc/modprobe.d/ /etc/udev/rules.d -type f|\
|
||||||
sed -e 's,^.\+$,file\t&\t&\t0644\t0 0,g'
|
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