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

WIP: build: Add support for "variants" #1459

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion src/buildextend-rojig-impl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ dn=$(dirname "$0")
# shellcheck source=src/cmdlib.sh
. "${dn}"/cmdlib.sh

manifest=$1
shift
commit=$1
shift
tmpdir=$1
Expand All @@ -27,7 +29,7 @@ if has_privileges; then
tmpdir=$(mktemp -d -p /var/tmp)
fi
sudo rpm-ostree ex commit2rojig --repo="$(pwd)/tmp/repo" --pkgcache-repo="$(pwd)/cache/pkgcache-repo" \
"${commit}" "$(pwd)/src/config/manifest.yaml" "${tmpdir}"
"${commit}" "$(pwd)/src/config/${manifest}.yaml" "${tmpdir}"
if ! [ -f /etc/cosa-supermin ]; then
sudo chown -R -h "${USER}:${USER}" "${tmpdir}"
else
Expand Down
21 changes: 19 additions & 2 deletions src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dn=$(dirname "$0")
print_help() {
cat 1>&2 <<'EOF'
Usage: coreos-assembler build --help
coreos-assembler build [--force] [--force-image] [--skip-prune] [--strict] [--tag TAG] [--version VERSION] [TARGET...]
coreos-assembler build [--force] [--force-image] [--skip-prune] [--strict] [--tag TAG] [--version VERSION] [-O/--variant VARIANT] [TARGET...]

Build OSTree and image base artifacts from previously fetched packages.
Accepted TARGET arguments:
Expand All @@ -30,9 +30,10 @@ SKIP_PRUNE=0
VERSION=
PARENT=
TAG=
VARIANT=
STRICT=
rc=0
options=$(getopt --options hft: --longoptions tag:,help,force,version:,parent:,force-nocache,force-image,skip-prune,strict -- "$@") || rc=$?
options=$(getopt --options hftO: --longoptions tag:,help,force,version:,parent:,variant:,force-nocache,force-image,skip-prune,strict -- "$@") || rc=$?
[ $rc -eq 0 ] || {
print_help
exit 1
Expand Down Expand Up @@ -64,6 +65,10 @@ while true; do
shift
PARENT=$1
;;
-O | --variant)
shift
VARIANT=$1
;;
-t | --tag)
shift
TAG=$1
Expand Down Expand Up @@ -107,6 +112,13 @@ build_followup_targets() {
}

prepare_build
if [ -n "${VARIANT}" ]; then
manifest=${workdir}/src/config/${VARIANT}.yaml
if ! [ -f "${manifest}" ]; then
fatal "Failed to find variant manifest ${manifest}"
fi
echo "Using variant manifest: ${manifest}"
fi

ostree --version
rpm-ostree --version
Expand Down Expand Up @@ -357,12 +369,17 @@ fi
#
# notice need to backslash escape double quotes in summary since the
# summary could have double quotes: https://github.com/coreos/coreos-assembler/issues/327
variantmeta=
if [ -n "${VARIANT}" ]; then
variantmeta='"variant": "'"${VARIANT}"'",'
fi
#
# shellcheck disable=SC2046 disable=SC2086
cat > tmp/buildmeta.json <<EOF
{
"name": "${name}",
"summary": "${summary//\"/\\\"}",
${variantmeta}
"coreos-assembler.build-timestamp": "${build_timestamp}",
"coreos-assembler.image-config-checksum": "${image_config_checksum}",
"coreos-assembler.image-input-checksum": "${image_input_checksum}",
Expand Down
3 changes: 2 additions & 1 deletion src/cmd-buildextend-rojig
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ print(f"Targeting build: {args.build}")
buildmeta_path = os.path.join(builddir, 'meta.json')
with open(buildmeta_path) as f:
buildmeta = json.load(f)
manifest = buildmeta.get('variant', 'manifest')
# Grab the commit hash for this build
buildmeta_commit = buildmeta['ostree-commit']
repo = os.path.join(workdir, 'tmp/repo')
pkgcache_repo = os.path.join(workdir, 'cache/pkgcache-repo')

with tempfile.TemporaryDirectory(prefix='rojig-', dir=f"{workdir}/tmp") as tmpd:
run_verbose(['/usr/lib/coreos-assembler/buildextend-rojig-impl', buildmeta_commit, os.path.abspath(tmpd)])
run_verbose(['/usr/lib/coreos-assembler/buildextend-rojig-impl', manifest, buildmeta_commit, os.path.abspath(tmpd)])
rojig_path = None
arch_destdir = os.path.join(tmpd, get_basearch())
if not os.path.isdir(arch_destdir):
Expand Down