Skip to content

Commit b06af0d

Browse files
committed
Factor out apt .sources generation and consolidate metadata artifact
Address review feedback on the sources/metadata generation: - Extract the deb822 .sources stanza generation into lib/sources-common.sh and source it from both generate-sources-tar and generate-step-summary, so the machine-readable artifacts and the human-facing summary can no longer drift apart. The stanza now lists all components (main contrib non-free non-free-firmware), tracking e68a692. - generate-sources-tar now emits the baseline .sources for the resolved target workspace (qli or qli-staging) via DEBUSINE_TARGET_WORKSPACE, incorporating the qli-staging support from 7d6fd1b, instead of a hardcoded qli.sources. - Rename the metadata.json "package" key to "source-package" to disambiguate from binary packages. - Consolidate the two upload steps into a single artifact named "metadata" containing the .sources files and metadata.json. Signed-off-by: Vedant Rokad <vrokad@qti.qualcomm.com>
1 parent 9af63a3 commit b06af0d

4 files changed

Lines changed: 60 additions & 56 deletions

File tree

.github/workflows/debusine.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,26 +267,20 @@ jobs:
267267
DEBUSINE_USER: ${{ secrets.DEBUSINE_USER }}
268268
DEBUSINE_TOKEN: ${{ secrets.DEBUSINE_TOKEN }}
269269
DEBUSINE_WORKSPACE: ${{ steps.build.outputs.workspace }}
270+
DEBUSINE_TARGET_WORKSPACE: ${{ needs.resolve.outputs.debusine_target_workspace }}
270271
SUITE: ${{ needs.resolve.outputs.suite }}
271272
SRCPKG_NAME: ${{ needs.source-package.outputs.srcpkg_name }}
272273
SRCPKG_VERSION: ${{ needs.source-package.outputs.srcpkg_version }}
273274
run: |
274275
debusine-action/lib/generate-sources-tar
275276
276-
- name: Upload sources files
277+
- name: Upload metadata
277278
uses: actions/upload-artifact@v7
278279
with:
279-
name: qli-apt-sources
280+
name: metadata
280281
path: |
281-
qli.sources
282-
qli-ci.sources
283-
if-no-files-found: error
284-
285-
- name: Upload sources metadata
286-
uses: actions/upload-artifact@v7
287-
with:
288-
name: sources-metadata
289-
path: metadata.json
282+
*.sources
283+
metadata.json
290284
if-no-files-found: error
291285

292286
release:

lib/generate-sources-tar

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ set -ex
66

77
# Run on the host
88

9-
# Emits the real qli and qli-ci apt .sources files plus a separate structured
10-
# metadata.json, so that a downstream consumer (e.g. a Coral workflow) can
11-
# download them and copy the .sources files straight onto the target system
12-
# (into /etc/apt/sources.list.d/) without parsing JSON or scraping the
13-
# human-facing step summary.
9+
# Emits the real baseline (qli/qli-staging) and qli-ci apt .sources files plus a
10+
# separate structured metadata.json, so that a downstream consumer (e.g. a Coral
11+
# workflow) can download them and copy the .sources files straight onto the
12+
# target system (into /etc/apt/sources.list.d/) without parsing JSON or scraping
13+
# the human-facing step summary.
14+
15+
# The .sources stanzas are generated by lib/sources-common.sh, which is also
16+
# used by generate-step-summary so the artifacts and the human-facing
17+
# instructions stay in sync.
1418

1519
# Dependencies:
1620
# ca-certificates and curl packages: when you run this script
@@ -23,37 +27,19 @@ set -ex
2327
# DEBUSINE_USER
2428
# DEBUSINE_TOKEN
2529
# DEBUSINE_WORKSPACE
30+
# DEBUSINE_TARGET_WORKSPACE
2631
# SUITE
2732
# SRCPKG_NAME
2833
# SRCPKG_VERSION
2934

3035
# Outputs:
31-
# qli.sources, qli-ci.sources: apt .sources files
32-
# metadata.json: standalone JSON describing the package/version/suite
33-
34-
qli_uri="https://deb.${DEBUSINE_HOST}/${DEBUSINE_SCOPE}/qli/"
35-
ci_uri="https://deb.${DEBUSINE_HOST}/${DEBUSINE_SCOPE}/${DEBUSINE_WORKSPACE}/"
36+
# ${DEBUSINE_TARGET_WORKSPACE}.sources, qli-ci.sources: apt .sources files
37+
# metadata.json: standalone JSON describing the source package/version/suite
3638

37-
qli_public_key=$(curl -fsSu "${DEBUSINE_USER}:${DEBUSINE_TOKEN}" "${qli_uri}signing-keys.asc"|sed -e 's/^$/./;s/^/ /')
38-
ci_public_key=$(curl -fsSu "${DEBUSINE_USER}:${DEBUSINE_TOKEN}" "${ci_uri}signing-keys.asc"|sed -e 's/^$/./;s/^/ /')
39+
. "$(dirname "$0")/sources-common.sh"
3940

40-
cat > qli.sources <<END
41-
Types: deb deb-src
42-
URIs: ${qli_uri}
43-
Suites: ${SUITE}
44-
Components: main
45-
Signed-By:
46-
${qli_public_key}
47-
END
48-
49-
cat > qli-ci.sources <<END
50-
Types: deb deb-src
51-
URIs: ${ci_uri}
52-
Suites: ${SUITE}
53-
Components: main
54-
Signed-By:
55-
${ci_public_key}
56-
END
41+
emit_sources "${DEBUSINE_TARGET_WORKSPACE}" > "${DEBUSINE_TARGET_WORKSPACE}.sources"
42+
emit_sources "${DEBUSINE_WORKSPACE}" > qli-ci.sources
5743

5844
SRCPKG_NAME="$SRCPKG_NAME" SRCPKG_VERSION="$SRCPKG_VERSION" SUITE="$SUITE" \
5945
python3 - metadata.json <<'PY'
@@ -62,7 +48,7 @@ import os
6248
import sys
6349
6450
data = {
65-
"package": os.environ["SRCPKG_NAME"],
51+
"source-package": os.environ["SRCPKG_NAME"],
6652
"version": os.environ["SRCPKG_VERSION"],
6753
"suite": os.environ["SUITE"],
6854
}
@@ -71,4 +57,3 @@ with open(sys.argv[1], "w") as f:
7157
json.dump(data, f, indent=2)
7258
f.write("\n")
7359
PY
74-

lib/generate-step-summary

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ set -ex
2828

2929
: ${GITHUB_STEP_SUMMARY:=/dev/null}
3030

31+
. "$(dirname "$0")/sources-common.sh"
32+
3133
if [ "${BUILD_RESULT}" = "success" ]; then
3234
build_status="successful"
3335
else
3436
build_status="failed"
3537
fi
3638

3739
if [ "${BUILD_RESULT}" = "success" ]; then
38-
target_public_key=$(curl -fsSu "${DEBUSINE_USER}:${DEBUSINE_TOKEN}" "https://deb.${DEBUSINE_HOST}/${DEBUSINE_SCOPE}/${DEBUSINE_TARGET_WORKSPACE}/signing-keys.asc"|sed -e 's/^$/./;s/^/ /')
39-
ci_public_key=$(curl -fsSu "${DEBUSINE_USER}:${DEBUSINE_TOKEN}" "https://deb.${DEBUSINE_HOST}/${DEBUSINE_SCOPE}/${DEBUSINE_WORKSPACE}/signing-keys.asc"|sed -e 's/^$/./;s/^/ /')
40+
target_sources=$(emit_sources "${DEBUSINE_TARGET_WORKSPACE}")
41+
ci_sources=$(emit_sources "${DEBUSINE_WORKSPACE}")
4042
fi
4143

4244
cat > "$GITHUB_STEP_SUMMARY" <<END2
@@ -66,24 +68,14 @@ END
6668
## Create \`${DEBUSINE_TARGET_WORKSPACE}.sources\` for baseline apt repository access
6769
\`\`\`
6870
sudo sh -c 'cat > /etc/apt/sources.list.d/${DEBUSINE_TARGET_WORKSPACE}.sources' <<END
69-
Types: deb deb-src
70-
URIs: https://deb.${DEBUSINE_HOST}/${DEBUSINE_SCOPE}/${DEBUSINE_TARGET_WORKSPACE}/
71-
Suites: ${SUITE}
72-
Components: main contrib non-free non-free-firmware
73-
Signed-By:
74-
${target_public_key}
71+
${target_sources}
7572
END
7673
\`\`\`
7774
7875
## Create \`qli-ci.sources\` for build-specific apt repository access
7976
\`\`\`
8077
sudo sh -c 'cat > /etc/apt/sources.list.d/qli-ci.sources' <<END
81-
Types: deb deb-src
82-
URIs: https://deb.${DEBUSINE_HOST}/${DEBUSINE_SCOPE}/${DEBUSINE_WORKSPACE}/
83-
Suites: ${SUITE}
84-
Components: main contrib non-free non-free-firmware
85-
Signed-By:
86-
${ci_public_key}
78+
${ci_sources}
8779
END
8880
\`\`\`
8981
END2

lib/sources-common.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
# shellcheck shell=sh
4+
5+
# Shared helper for generating apt .sources stanzas, sourced by
6+
# generate-sources-tar (which writes them to files for artifact upload) and
7+
# generate-step-summary (which embeds them in the human-facing summary). Keeping
8+
# a single implementation ensures the machine-readable artifacts and the
9+
# instructions shown to users never drift apart.
10+
11+
# Inputs (from the environment):
12+
# DEBUSINE_HOST
13+
# DEBUSINE_SCOPE
14+
# DEBUSINE_USER
15+
# DEBUSINE_TOKEN
16+
# SUITE
17+
18+
# emit_sources WORKSPACE
19+
# Prints an apt deb822 .sources stanza for the given Debusine workspace to
20+
# stdout, embedding that workspace's signing key.
21+
emit_sources() {
22+
_workspace="$1"
23+
_uri="https://deb.${DEBUSINE_HOST}/${DEBUSINE_SCOPE}/${_workspace}/"
24+
_public_key=$(curl -fsSu "${DEBUSINE_USER}:${DEBUSINE_TOKEN}" "${_uri}signing-keys.asc"|sed -e 's/^$/./;s/^/ /')
25+
cat <<END
26+
Types: deb deb-src
27+
URIs: ${_uri}
28+
Suites: ${SUITE}
29+
Components: main contrib non-free non-free-firmware
30+
Signed-By:
31+
${_public_key}
32+
END
33+
}

0 commit comments

Comments
 (0)