erofs output (#4162)

* add erofs as output option

Signed-off-by: Avi Deitcher <avi@deitcher.net>

* unify nearly identical functions

Signed-off-by: Avi Deitcher <avi@deitcher.net>

---------

Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
Avi Deitcher
2025-08-28 10:34:53 +03:00
committed by GitHub
parent 506d11f06d
commit c3228fb526
6 changed files with 84 additions and 60 deletions

View File

@@ -0,0 +1,15 @@
FROM linuxkit/alpine:6090baae063eb5023c9601966e88df831f789a70 AS mirror
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
RUN apk add --no-cache --initdb -p /out \
alpine-baselayout \
busybox \
libarchive-tools \
erofs-utils \
&& true
RUN mv /out/etc/apk/repositories.upstream /out/etc/apk/repositories
FROM scratch
WORKDIR /
COPY --from=mirror /out/ /
COPY . .
ENTRYPOINT [ "/make-erofs" ]

View File

@@ -0,0 +1 @@
image: mkimage-erofs

22
tools/mkimage-erofs/make-erofs Executable file
View File

@@ -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;
mkfs.erofs ./rootfs.img rootfs
)
cat rootfs.img