Skip to content

Commit

Permalink
cmdlib: consistently commit layers with same options
Browse files Browse the repository at this point in the history
Make a helper for committing OSTree layers which contains all the
canonicalization flags. Notably `--timestamp` which ensures that we get
a consistent checksum for the same source git commit.

Fixes: openshift/os#712
Fixes: #2603
(cherry picked from commit 3fac918)

dustymabe: This cherry pick needed manual merge conflict resolution.
           No contentsets in 4.9.
  • Loading branch information
jlebon authored and dustymabe committed Nov 15, 2022
1 parent 344d1bd commit f25a0ac
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ prepare_build() {
export overrides_active_stamp
}

commit_ostree_layer() {
local rootfs=$1; shift
local branch=$1; shift
ostree commit --repo="${tmprepo}" --tree=dir="${rootfs}" -b "${branch}" \
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none \
--mode-ro-executables --timestamp "${git_timestamp}" "$@"
}

commit_overlay() {
local name path respath
name=$1
Expand All @@ -292,9 +300,7 @@ commit_overlay() {
# files, but we do.
touch "${TMPDIR}/overlay/statoverride"
echo -n "Committing ${name}: ${path} ... "
ostree commit --repo="${tmprepo}" --tree=dir="${TMPDIR}/overlay" -b "${name}" \
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none \
--mode-ro-executables --timestamp "${git_timestamp}" \
commit_ostree_layer "${TMPDIR}/overlay" "${name}" \
--statoverride <(sed -e '/^#/d' "${TMPDIR}/overlay/statoverride") \
--skip-list <(echo /statoverride)
}
Expand Down Expand Up @@ -406,9 +412,7 @@ EOF
if [[ -d "${rootfs_overrides}" && -n $(ls -A "${rootfs_overrides}") ]]; then
echo -n "Committing ${rootfs_overrides}... "
touch "${overrides_active_stamp}"
ostree commit --repo="${tmprepo}" --tree=dir="${rootfs_overrides}" -b cosa-overrides-rootfs \
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none \
--timestamp "${git_timestamp}"
commit_ostree_layer "${rootfs_overrides}" "cosa-overrides-rootfs"
cat >> "${override_manifest}" << EOF
ostree-override-layers:
- cosa-overrides-rootfs
Expand Down

0 comments on commit f25a0ac

Please sign in to comment.