mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-12-03 07:02:52 +00:00
35 lines
504 B
Bash
Executable File
35 lines
504 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
mkdir -p /tmp/input
|
|
|
|
cd /tmp/input
|
|
|
|
tar xf -
|
|
|
|
find . | cpio -H newc -o | gzip -9 > ../initrd.img
|
|
|
|
cd /tmp
|
|
|
|
SIZE=$(stat -c "%s" initrd.img)
|
|
SIZE4=$(( $SIZE / 4 \* 4 ))
|
|
DIFF=$(( $SIZE - $SIZE4 ))
|
|
[ $DIFF -ne 0 ] && DIFF=$(( 4 - $DIFF ))
|
|
|
|
dd if=/dev/zero bs=1 count=$DIFF of=zeropad 2>/dev/null
|
|
|
|
cat zeropad >> initrd.img
|
|
|
|
SIZE=$(stat -c "%s" initrd.img)
|
|
SIZE4=$(( $SIZE / 4 \* 4 ))
|
|
DIFF=$(( $SIZE - $SIZE4 ))
|
|
|
|
if [ $DIFF -ne 0 ]
|
|
then
|
|
echo "Bad alignment" >2
|
|
exit 1
|
|
fi
|
|
|
|
cat initrd.img
|