Add initrd tools
This commit is contained in:
parent
dc89e6debd
commit
0e3fcf3170
6
path/wdvn-initrd-create
Executable file
6
path/wdvn-initrd-create
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
INPUT="$1"
|
||||
OUTPUT="$2"
|
||||
cd "$INPUT"
|
||||
find . | cpio -H newc -o | gzip -9 > "$OUTPUT"
|
25
path/wdvn-initrd-extract
Executable file
25
path/wdvn-initrd-extract
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
OLDPWD="$PWD"
|
||||
INPUT="$1"
|
||||
OUTPUT="$2"
|
||||
TEMP="$2.tmp"
|
||||
TYPE="$(file -b -L "$INPUT")"
|
||||
|
||||
mkdir -p "$TEMP/basic"
|
||||
|
||||
if [[ "$TYPE" == *"cpio archive"* ]]; then
|
||||
mkdir -p "$TEMP/microcode"
|
||||
cd "$TEMP/microcode"
|
||||
BLOCKS="$(cpio -i <"$INPUT" 2>&1 >/dev/null | tail -1)"
|
||||
BLOCKS="${BLOCKS%% *}"
|
||||
dd if="$INPUT" of="$TEMP/initrd.img" bs=512 skip=$BLOCKS
|
||||
cd "$TEMP/basic"
|
||||
zcat "$TEMP/initrd.img" | cpio -i
|
||||
rm "$TEMP/initrd.img"
|
||||
else
|
||||
cd "$TEMP/basic"
|
||||
zcat "$INPUT" | cpio -i
|
||||
fi
|
||||
|
||||
mv "$TEMP" "$OUTPUT"
|
Loading…
Reference in New Issue
Block a user