Skip to content

Commit

Permalink
cmd-build: Add lockfile support
Browse files Browse the repository at this point in the history
First, we teach `build` to always output a lockfile, which we store into
the final build dir. Second, we also teach `build` to take a
`--lockfile` argument to enforce a specific lockfile.

This is the first step towards actually being able to make use of
lockfiles in the FCOS pipeline.
  • Loading branch information
jlebon committed Jun 11, 2019
1 parent c8cab23 commit 7958a03
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ EOF
}

# Parse options
LOCKFILE=
FORCE=
SKIP_PRUNE=0
rc=0
options=$(getopt --options hf --longoptions help,force,force-nocache,skip-prune -- "$@") || rc=$?
options=$(getopt --options hf --longoptions lockfile:,help,force,force-nocache,skip-prune -- "$@") || rc=$?
[ $rc -eq 0 ] || {
print_help
exit 1
Expand All @@ -45,6 +46,10 @@ while true; do
--skip-prune)
SKIP_PRUNE=1
;;
--lockfile)
shift
LOCKFILE=$1
;;
--)
shift
break
Expand Down Expand Up @@ -153,9 +158,13 @@ prepare_git_artifacts "${configdir_gitrepo}" "${PWD}/coreos-assembler-config.tar

# These need to be absolute paths right now for rpm-ostree
composejson=${PWD}/tmp/compose.json
# Put this under tmprepo so it gets automatically chown'ed if needed
lockfile_out=${tmprepo}/tmp/lockfile.json
# --cache-only is here since `fetch` is a separate verb.
runcompose --cache-only ${FORCE} --add-metadata-from-json "${commitmeta_input_json}" \
--write-composejson-to "${composejson}"
--write-composejson-to "${composejson}" \
--ex-write-lockfile-to "${lockfile_out}" \
${LOCKFILE:+--ex-lockfile ${LOCKFILE}}
# Very special handling for --write-composejson-to as rpm-ostree doesn't
# write it if the commit didn't change.
if [ -f "${changed_stamp}" ]; then
Expand Down Expand Up @@ -306,6 +315,9 @@ if [ -n "${ref_is_temp}" ]; then
mv meta.json{.new,}
fi

# Move lockfile into build dir
mv "${lockfile_out}" .

# And add the commit metadata itself, which includes notably the rpmdb pkglist
# in a format that'd be easy to generate diffs out of for higher level tools
"${dn}"/commitmeta_to_json "${tmprepo}" "${commit}" > commitmeta.json
Expand Down

0 comments on commit 7958a03

Please sign in to comment.