-
Notifications
You must be signed in to change notification settings - Fork 183
set up containers-storage in supermin cache #4286
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
base: main
Are you sure you want to change the base?
Changes from all commits
43c9c43
7e54598
57e8499
b9dbc5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,8 +101,6 @@ build_with_buildah() { | |
# This is analogous to the chmod we do in cmdlib.sh in the legacy path. | ||
chmod -R gu-s "${tempdir}/src" | ||
|
||
tmp_oci_archive_path=$(realpath "${tempdir}/out.ociarchive") | ||
|
||
initconfig="src/config.json" | ||
if [ -f "${initconfig}" ]; then | ||
variant="$(jq --raw-output '."coreos-assembler.config-variant"' "${initconfig}")" | ||
|
@@ -141,6 +139,7 @@ build_with_buildah() { | |
# For the source: check if there's only one remote, if so use it with get-url | ||
# For revision: rev-parse | ||
set -- build --security-opt=label=disable --cap-add=all --device /dev/fuse \ | ||
--pull=newer --layers=true \ | ||
--build-arg-file "$argsfile" -v "$(realpath "${tempdir}/src")":/run/src \ | ||
--build-arg VERSION="${VERSION}" \ | ||
--label org.opencontainers.image.source="${source}" \ | ||
|
@@ -162,40 +161,45 @@ build_with_buildah() { | |
fi | ||
|
||
if [ -d overrides ]; then | ||
if [[ -n $(ls overrides/rpm/*.rpm 2> /dev/null) ]]; then | ||
(cd overrides/rpm && rm -rf .repodata && createrepo_c .) | ||
if [ -d overrides/rpm ]; then | ||
# Clean up any previous repo metadata | ||
rm -rf overrides/rpm/repodata | ||
if [[ -n $(ls overrides/rpm/*.rpm 2> /dev/null) ]]; then | ||
# Generate new repo metadata since there are RPMs | ||
(cd overrides/rpm && createrepo_c .) | ||
fi | ||
fi | ||
set -- "$@" -v "$(realpath overrides)":/run/src/overrides | ||
fi | ||
|
||
if [ -n "$DIRECT" ]; then | ||
# turn on layer caching in the direct case; it wouldn't hurt in the | ||
# supermin path, but it'd be a waste of space on the rootfs | ||
set -- "$@" --layers=true | ||
# output to a tag since it's more convenient for development; | ||
# buildah doesn't support doing both at once | ||
# shellcheck disable=SC1090 | ||
osname=$(source "src/config/${argsfile}"; echo "${NAME}") | ||
final_ref="containers-storage:localhost/${osname}:${VERSION}" | ||
else | ||
# In the supermin path ensure the ociarchive gets compressed | ||
set -- "$@" --disable-compression=false | ||
final_ref="oci-archive:${tmp_oci_archive_path}" | ||
fi | ||
# We'll also copy to an intermediate ociarchive file before | ||
# passing that ociarchive to cosa import | ||
tmp_oci_archive="oci-archive:$(realpath "${tempdir}/out.ociarchive")" | ||
|
||
# and finally, add the tag and context dir | ||
set -- "$@" -t "${final_ref}" . | ||
# Set the output tag to be something unique | ||
# shellcheck disable=SC1090 | ||
osname=$(source "src/config/${argsfile}"; echo "${NAME}") | ||
final_ref="containers-storage:localhost/${osname}:${VERSION}" | ||
# and add the unique tag and context dir to the command | ||
set -- "$@" --tag "${final_ref}" . | ||
|
||
echo "Running:" buildah "$@" | ||
if [ -n "$DIRECT" ]; then | ||
env -C "${tempdir}/src" buildah "$@" | ||
cmd="bash" | ||
else | ||
/usr/lib/coreos-assembler/cmd-supermin-run --cache \ | ||
env -C "${tempdir}/src" TMPDIR="$(realpath cache)" buildah "$@" | ||
cmd="/usr/lib/coreos-assembler/cmd-supermin-run --cache" | ||
fi | ||
cat <<EOF > "${tempdir}/build-with-buildah-script.sh" | ||
set -euxo pipefail | ||
env -C ${tempdir}/src TMPDIR=$(realpath cache) buildah $@ | ||
dustymabe marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually wouldn't worry about spaces the way Gemini did, but there's an easy way I think to do this which is to use |
||
skopeo copy --quiet "${final_ref}" "${tmp_oci_archive}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
EOF | ||
chmod +x "${tempdir}/build-with-buildah-script.sh" | ||
$cmd "${tempdir}/build-with-buildah-script.sh" | ||
|
||
/usr/lib/coreos-assembler/cmd-import "${final_ref}" ${SKIP_PRUNE:+--skip-prune} | ||
|
||
# Finally import the ociarchive | ||
/usr/lib/coreos-assembler/cmd-import \ | ||
"${tmp_oci_archive}" ${SKIP_PRUNE:+--skip-prune} | ||
rm -rf "${tempdir}" | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't understand what exactly you were hitting.
Actually, is the bug here just
s/.repodata/repodata
? Though this was cargo-culted fromcoreos-assembler/src/cmdlib.sh
Line 447 in 6e863df