49 lines
873 B
Bash
Executable file
49 lines
873 B
Bash
Executable file
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
NAME="$1"
|
|
|
|
if [ "$NAME" = "" ]; then
|
|
echo 'no name supplied, stopping.' >&2
|
|
exit 1
|
|
fi
|
|
|
|
PACKER_JSON="$NAME.json"
|
|
INITRAMFS_FILE="$NAME.initramfs"
|
|
LINUX_FILE="$NAME.linux"
|
|
SQUASHFS_FILE="$NAME"
|
|
|
|
packer build "$PACKER_JSON"
|
|
|
|
mkdir -p build/rootfs
|
|
tar xf build/rootfs.tar -C build/rootfs
|
|
|
|
mv build/rootfs/artifacts/initramfs "/images/$INITRAMFS_FILE"
|
|
mv build/rootfs/artifacts/linux "/images/$LINUX_FILE"
|
|
|
|
rm -rf build/rootfs/artifacts
|
|
|
|
rm -- \
|
|
build/rootfs/.dockerenv \
|
|
build/rootfs/initrd.* \
|
|
build/rootfs/vmlinuz*
|
|
|
|
if [ -e "/images/$SQUASHFS_FILE" ]; then
|
|
rm "/images/$SQUASHFS_FILE"
|
|
fi
|
|
|
|
mksquashfs build/rootfs "/images/$SQUASHFS_FILE" \
|
|
-comp lzo \
|
|
-Xcompression-level 9
|
|
|
|
rm -rf build
|
|
|
|
if [ "$user" != "" ] && [ "$group" != "" ]; then
|
|
chown $user:$group \
|
|
"/images/$INITRAMFS_FILE" \
|
|
"/images/$LINUX_FILE" \
|
|
"/images/$SQUASHFS_FILE"
|
|
fi
|
|
|
|
|