From c0377bf3430766a60bbafc13f8985b76e0f38b98 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Mon, 16 Apr 2018 13:59:23 +0100 Subject: [PATCH] tools: Add mkimage-squashfs This utility image takes a tarball as input and places the contents into a read-only, compressed squashfs filesystem which is produced on stdout. Signed-off-by: Rolf Neugebauer --- tools/mkimage-squashfs/Dockerfile | 12 ++++++++++++ tools/mkimage-squashfs/build.yml | 1 + tools/mkimage-squashfs/make-squashfs | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tools/mkimage-squashfs/Dockerfile create mode 100644 tools/mkimage-squashfs/build.yml create mode 100755 tools/mkimage-squashfs/make-squashfs diff --git a/tools/mkimage-squashfs/Dockerfile b/tools/mkimage-squashfs/Dockerfile new file mode 100644 index 000000000..72d24f2f3 --- /dev/null +++ b/tools/mkimage-squashfs/Dockerfile @@ -0,0 +1,12 @@ +FROM linuxkit/alpine:f3cd219615428b2bd943411723eb28875275fae7 + +RUN \ + apk update && apk upgrade && \ + apk add --no-cache \ + libarchive-tools \ + squashfs-tools \ + && true + +COPY . . + +ENTRYPOINT [ "/make-squashfs" ] diff --git a/tools/mkimage-squashfs/build.yml b/tools/mkimage-squashfs/build.yml new file mode 100644 index 000000000..04ab0c5b1 --- /dev/null +++ b/tools/mkimage-squashfs/build.yml @@ -0,0 +1 @@ +image: mkimage-squashfs diff --git a/tools/mkimage-squashfs/make-squashfs b/tools/mkimage-squashfs/make-squashfs new file mode 100755 index 000000000..f48c0b0a5 --- /dev/null +++ b/tools/mkimage-squashfs/make-squashfs @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +mkdir -p /tmp/rootfs +cd /tmp/rootfs + +# input is a tarball of filesystem on stdin with the root filesytem +# output is a squashfs image on stdout + +# extract. BSD tar auto recognises compression, unlike GNU tar +# only if stdin is a tty, if so need files volume mounted... +[ -t 0 ] || bsdtar xzf - +cd /tmp + +# we want everything except the final result to stderr +( + exec 1>&2; + + mksquashfs rootfs ./rootfs.img +) +cat rootfs.img