Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reading and writing lockfiles #553

Merged
merged 1 commit into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,23 @@ EOF

prepare_git_artifacts "${configdir_gitrepo}" "${PWD}/coreos-assembler-config.tar.gz" "${PWD}/coreos-assembler-config-git.json"

lock_arg=
if [ -f "${manifest_lock}" ]; then
lock_arg="--ex-lockfile=${manifest_lock}"
echo "Building from lockfile ${manifest_lock}"
sleep 1
fi

# 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/manifest-lock.generated.json
# --cache-only is here since `fetch` is a separate verb.
# shellcheck disable=SC2086
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}" \
${lock_arg}
# 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 +318,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
27 changes: 24 additions & 3 deletions src/cmd-fetch
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ dn=$(dirname "$0")
print_help() {
cat 1>&2 <<'EOF'
Usage: coreos-assembler fetch --help
coreos-assembler fetch
coreos-assembler fetch [--update-lockfile]

Fetch and import the latest packages.
EOF
}

UPDATE_LOCKFILE=
rc=0
options=$(getopt --options h --longoptions help -- "$@") || rc=$?
options=$(getopt --options h --longoptions help,update-lockfile -- "$@") || rc=$?
[ $rc -eq 0 ] || {
print_help
exit 1
Expand All @@ -27,6 +28,9 @@ while true; do
print_help
exit 0
;;
--update-lockfile)
UPDATE_LOCKFILE=1
;;
--)
shift
break
Expand All @@ -46,4 +50,21 @@ if [ $# -ne 0 ]; then
fi

prepare_build
runcompose --download-only

lock_arg=
if [ -n "${UPDATE_LOCKFILE}" ]; then
# Put this under tmprepo so it gets automatically chown'ed if needed
lock_arg="--ex-write-lockfile-to=${tmprepo}/tmp/manifest-lock.json"
elif [ -f "${manifest_lock}" ]; then
lock_arg="--ex-lockfile=${manifest_lock}"
echo "Fetching RPMs from lockfile ${manifest_lock}"
sleep 1
fi

# shellcheck disable=SC2086
runcompose --download-only ${lock_arg}

if [ -n "${UPDATE_LOCKFILE}" ]; then
mv "${tmprepo}/tmp/manifest-lock.json" "${manifest_lock}"
echo "Updated lockfile ${manifest_lock}"
fi
3 changes: 2 additions & 1 deletion src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ prepare_build() {
workdir="$(pwd)"
configdir=${workdir}/src/config
manifest=${configdir}/manifest.yaml
export workdir configdir manifest
manifest_lock=${configdir}/manifest-lock.json
export workdir configdir manifest manifest_lock

if ! [ -f "${manifest}" ]; then
fatal "Failed to find ${manifest}"
Expand Down