From 08eb151e82f2c4b8647e398b63c4998cede34c37 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sat, 15 Feb 2025 06:42:31 +0100 Subject: [PATCH] Fix importing multi-arch artifacts Convey architecture in artifact name --- .github/workflows/scheduled.yaml | 4 ++-- reprepro/import.sh | 37 +++++++++++++++++++------------- reprepro/server.py | 2 +- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/scheduled.yaml b/.github/workflows/scheduled.yaml index 3b1185b3..bf9781e4 100644 --- a/.github/workflows/scheduled.yaml +++ b/.github/workflows/scheduled.yaml @@ -26,7 +26,7 @@ jobs: EXTRA_DEB_SOURCES: "deb [signed-by=/etc/apt/keyrings/ros-one-keyring.gpg] https://ros.packages.techfak.net ${{matrix.DEB_DISTRO}}-testing main" # proceed from existing debs artifact if run_attempt > 1 DOWNLOAD_DEBS: ${{ github.run_attempt != '1' }} - DEBS_ARTIFACT_NAME: ${{ matrix.DEB_DISTRO }}-debs + DEBS_ARTIFACT_NAME: ${{ matrix.DEB_DISTRO }}-${{ matrix.ARCH }}-debs SKIP_EXISTING: true SKIP_KNOWN_FAILING: true CONTINUE_ON_ERROR: true @@ -46,4 +46,4 @@ jobs: - name: Import build artifacts to reprepro server uses: ./reprepro with: - url: "${{ vars.DEPLOY_URL }}?run_id=${{ github.run_id }}&arch=x64" + url: "${{ vars.DEPLOY_URL }}?run_id=${{ github.run_id }}" diff --git a/reprepro/import.sh b/reprepro/import.sh index 4df5ea29..ad73474c 100755 --- a/reprepro/import.sh +++ b/reprepro/import.sh @@ -7,21 +7,24 @@ fi # Sanity checks [ ! -d "$INCOMING_DIR" ] && echo "Invalid incoming directory" && exit 1 -[ -z "$ARCH" ] && echo "ARCH undefined" && exit 1 [ -z "$REPO" ] && echo "github repo undefined" && exit 1 -# Translate ARCH x64 -> amd64 -[ "$ARCH" == "x64" ] && ARCH="amd64" - function filter { grep -vE "Exporting indices...|Deleting files no longer referenced..." } function import { + [ -z "$1" ] && echo "DISTRO undefined" && exit 1 + [ -z "$2" ] && echo "ARCH undefined" && exit 1 + local distro="$1-testing" # operate on -testing distro + local arch="$2" + + # Translate arch x64 -> amd64 + [ "$arch" == "x64" ] && arch="amd64" # Import sources - if [ "$ARCH" == "amd64" ]; then + if [ "$arch" == "amd64" ]; then printf "\nImporting source packages\n" for f in "$INCOMING_DIR"/*.dsc; do [ -f "$f" ] || break # Handle case of no files found @@ -35,12 +38,12 @@ function import { for f in "$INCOMING_DIR"/*.deb; do [ -f "$f" ] || break # Handle case of no files found echo "${f#"$INCOMING_DIR/"}" - reprepro -A "$ARCH" includedeb "$distro" "$f" | filter + reprepro -A "$arch" includedeb "$distro" "$f" | filter done # Save log files - mkdir -p "log/${distro%-testing}.$ARCH" - mv "$INCOMING_DIR"/*.log "log/${distro%-testing}.$ARCH" + mkdir -p "log/${distro%-testing}.$arch" + mv "$INCOMING_DIR"/*.log "log/${distro%-testing}.$arch" # Cleanup files (cd "$INCOMING_DIR" || exit 1; rm -f ./*.log ./*.deb ./*.dsc ./*.tar.gz ./*.tar.xz ./*.changes ./*.buildinfo) @@ -53,7 +56,7 @@ function import { # remove .ddeb suffix f=${f%.ddeb} mv "${f}.ddeb" "${f}.deb" - reprepro -A "$ARCH" -C main-dbg includedeb "$distro" "${f}.deb" | filter + reprepro -A "$arch" -C main-dbg includedeb "$distro" "${f}.deb" | filter done (cd "$INCOMING_DIR" || exit 1; rm ./*.deb) @@ -70,9 +73,9 @@ function import { # Download debs artifact(s) if [ "$(ls -A "$INCOMING_DIR")" ]; then - [ -z "$DISTRO" ] && echo "Distribution undefined" && exit 1 echo "Importing existing files from incoming directory" - import "$DISTRO" + # shellcheck disable=SC2153 # DISTRO and ARCH might be unset + import "$DISTRO" "$ARCH" else if [ -z "$RUN_ID" ] ; then # Retrieve RUN_ID of latest workflow run @@ -83,11 +86,15 @@ else for a in $artifacts; do echo "Fetching artifact \"$a\" from https://github.com/$REPO/actions/runs/$RUN_ID" gh --repo "$REPO" run download --name "$a" --dir "$INCOMING_DIR" "$RUN_ID" || continue - if [ "$distro" == "debs" ]; then - distro=$DISTRO + + # parse distro and arch from artifact name --debs + if [[ $a =~ ([^-]+)-([^-]+)(-debs)? ]]; then + distro=${BASH_REMATCH[1]} + arch=${BASH_REMATCH[2]} else - distro=${a%-debs} # Remove -debs suffix from -debs artifact name + distro=$DISTRO + arch=$ARCH fi - import "$distro" + import "$distro" "$arch" done fi diff --git a/reprepro/server.py b/reprepro/server.py index 2f924c86..6be26885 100644 --- a/reprepro/server.py +++ b/reprepro/server.py @@ -80,7 +80,7 @@ def process(q: queue.Queue, distro: str, repo: str, arch: str, run_id: str): @app.get("/import") def reprepro_import( - request: Request, run_id: str, arch: str = "x64", distro: str = "jammy" + request: Request, run_id: str, arch: str = "", distro: str = "jammy" ): kwargs = dict( repo="ubi-agni/ros-builder-action", distro=distro, run_id=run_id, arch=arch