mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-01-22 22:49:13 +00:00
- simplify the process by having the riddler container build the rootfs and config - output tarred up rootfs and config.json as otherwise file ownership not preserved - allow easy build of a collection of container tarballs with another conversion script This makes it easy to choose which container images you want and just convert any set to a initrd image ``` tar cf - container1.tar container2.tar | docker run -i tartar2initrd > initrd.img ``` Next stage will use a manifest to select the ones to add for each edition. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
41 lines
669 B
Bash
Executable File
41 lines
669 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
mkdir -p /tmp/input0 /tmp/input
|
|
|
|
cd /tmp/input0
|
|
|
|
# outer tarball
|
|
bsdtar xf -
|
|
|
|
cd /tmp/input
|
|
|
|
# inner tarballs
|
|
find /tmp/input0 \( -name '*.tar' -or -name '*.tgz' -or -name '*.tar.gz' \) -exec bsdtar 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
|