Skip to content

Commit

Permalink
cmdlib.sh: Use git timestamp for OSTree layers
Browse files Browse the repository at this point in the history
That way the commit checksum itself is completely stable when
recomposing on the same git commit (modulo a dirty directory, but then
the checksum will change anyway).

Doesn't really matter for now (except for the good feelsies of always
getting the same commit hash between invocations), though it will if we
want to start recording more information about constituent layers in the
compose.
  • Loading branch information
jlebon committed Jun 12, 2019
1 parent 7f879c2 commit 0416c89
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ runcompose() {
local overridesdir=${workdir}/overrides
local tmp_overridesdir=${TMPDIR}/override
local override_manifest="${tmp_overridesdir}"/coreos-assembler-override-manifest.yaml

local git_timestamp="January 1 1970"
if [ -d "${configdir_gitrepo}/.git" ]; then
git_timestamp=$(git -C "${configdir_gitrepo}" show -s --format=%ci HEAD)
fi
if [ -d "${overridesdir}" ] || [ -n "${ref_is_temp}" ] || [ -d "${configdir}/overlay" ]; then
mkdir "${tmp_overridesdir}"
cat > "${override_manifest}" <<EOF
Expand All @@ -256,7 +261,8 @@ EOF
if [ -d "${configdir}/overlay" ]; then
echo -n "Committing ${configdir}/overlay... "
ostree commit --repo="${tmprepo}" --tree=dir="${configdir}/overlay" -b "${name}-overlay" \
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none \
--timestamp "${git_timestamp}"
cat >> "${override_manifest}" <<EOF
ostree-layers:
- ${name}-overlay
Expand All @@ -280,7 +286,8 @@ EOF
if [ -d "${rootfs_overlay}" ]; then
echo -n "Committing ${rootfs_overlay}... "
ostree commit --repo="${tmprepo}" --tree=dir="${rootfs_overlay}" -b cosa-bin-overlay \
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none \
--timestamp "${git_timestamp}"
cat >> "${override_manifest}" << EOF
ostree-override-layers:
- cosa-bin-overlay
Expand Down

0 comments on commit 0416c89

Please sign in to comment.