Skip to content

Commit 1e075ef

Browse files
flx423XX0
authored andcommitted
Add support for reproducible images/bundles
1 parent 5c34a33 commit 1e075ef

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/docker.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ docker::configure() {
235235
docker::import() (
236236
local -r uri="$1"
237237
local filename="$2" arch="$3"
238-
local layers=() config= image= registry= tag= user= tmpdir=
238+
local layers=() config= image= registry= tag= user= tmpdir= timestamp=()
239239

240240
common::checkcmd curl grep awk jq parallel tar "${ENROOT_GZIP_PROGRAM}" find mksquashfs zstd
241241

@@ -308,11 +308,15 @@ docker::import() (
308308
zstd -q -d -o config "${ENROOT_CACHE_PATH}/${config}"
309309
docker::configure "${PWD}/0" config "${arch}"
310310

311+
if [ -n "${SOURCE_DATE_EPOCH-}" ]; then
312+
timestamp=("-mkfs-time" "${SOURCE_DATE_EPOCH}" "-all-time" "${SOURCE_DATE_EPOCH}")
313+
fi
314+
311315
# Create the final squashfs filesystem by overlaying all the layers.
312316
common::log INFO "Creating squashfs filesystem..." NL
313317
mkdir rootfs
314318
MOUNTPOINT="${PWD}/rootfs" \
315-
enroot-mksquashovlfs "0:$(seq -s: 1 "${#layers[@]}")" "${filename}" -all-root ${TTY_OFF+-no-progress} -processors "${ENROOT_MAX_PROCESSORS}" ${ENROOT_SQUASH_OPTIONS} >&2
319+
enroot-mksquashovlfs "0:$(seq -s: 1 "${#layers[@]}")" "${filename}" ${timestamp[@]+"${timestamp[@]}"} -all-root ${TTY_OFF+-no-progress} -processors "${ENROOT_MAX_PROCESSORS}" ${ENROOT_SQUASH_OPTIONS} >&2
316320
)
317321

318322
docker::daemon::import() (

src/runtime.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ runtime::remove() {
559559

560560
runtime::bundle() (
561561
local image="$1" filename="$2" target="$3" desc="$4"
562-
local super= tmpdir= compress=
562+
local super= tmpdir= compress= timestamp=
563563

564564
common::checkcmd unsquashfs find awk grep
565565

@@ -625,8 +625,12 @@ runtime::bundle() (
625625
[ -d "${environ_dirs[1]}" ] && cp -Lpr "${environ_dirs[1]}" "${tmpdir}${bundle_usrconf_dir}"
626626
fi
627627

628+
if [ -n "${SOURCE_DATE_EPOCH-}" ]; then
629+
timestamp="--mtime=@${SOURCE_DATE_EPOCH}"
630+
fi
631+
628632
# Make a self-extracting archive with the entrypoint being our bundle script.
629-
enroot-makeself --tar-quietly --tar-extra '--numeric-owner --owner=0 --group=0 --ignore-failed-read' \
633+
enroot-makeself --tar-quietly --tar-extra "--numeric-owner --owner=0 --group=0 --ignore-failed-read ${timestamp}" \
630634
--nomd5 --nocrc ${ENROOT_BUNDLE_CHECKSUM:+--sha256} --header "${ENROOT_LIBRARY_PATH}/bundle.sh" "${compress}" \
631635
--target "${target}" "${tmpdir}" "${filename}" "${desc}" -- \
632636
"${bundle_bin_dir}" "${bundle_lib_dir}" "${bundle_envconf}" "${bundle_sysconf_dir}" "${bundle_usrconf_dir}" >&2

0 commit comments

Comments
 (0)