diff --git a/.github/actions/abi_checker/action.yml b/.github/actions/abi_checker/action.yml new file mode 100644 index 0000000..9d52ac0 --- /dev/null +++ b/.github/actions/abi_checker/action.yml @@ -0,0 +1,109 @@ +name: Check ABI Against Previous Package Version +description: | + This Github Actions checks the ABI of a newly built package against the latest + [or possibly a fixed] version of that same package stored a repository. + +inputs: + version: + description: The specific version to run the ABI checker against. If not defined, defaults to latest + requred: false + +runs: + using: "composite" + + steps: + - name : List All The Versions Of The Built Packages Contained In The Staging PPA + shell: bash + run: | + set +e + ./qcom-build-utils/scripts/ppa_interface.py \ + --operation list-versions \ + --apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \ + --package-name ${{env.BUILT_PACKAGE_NAME}} + + RET=$? + set -e + + # TODO modify the ABI checker script to remove the logic that downloads the newest version of the package + # in order to simplify the code. + - name : Download Latest Version Of The Built Package From PPA To Compare ABI Against + shell: bash + run: | + set +e + ./qcom-build-utils/scripts/ppa_interface.py \ + --operation download \ + --apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \ + --package-name ${{env.BUILT_PACKAGE_NAME}} + + RET=$? + set -e + + if (( RET == 0 )); then + echo "✅ Successfully downloaded latest version" + fi + + # TODO deal with other return values + + - name: ABI Check + shell: bash + run: | + set +e + + ./qcom-build-utils/scripts/deb_abi_checker.py \ + --new-package-dir ./build-area \ + --apt-server-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \ + --result-file ./results.txt + + RET=$? + set -e + + echo "ABI check returned $RET" + + # (0): RETURN_ABI_NO_DIFF + # Bit 0 (1): RETURN_ABI_COMPATIBLE_DIFF + # Bit 1 (2): RETURN_ABI_INCOMPATIBLE_DIFF + # Bit 2 (4): RETURN_ABI_STRIPPED_PACKAGE + # Bit 3 (8): RETURN_PPA_PACKAGE_NOT_FOUND + # Bit 4 (16): RETURN_PPA_ERROR + + if (( RET == 0 )); then + echo "✅ ABI check returned NO_DIFF" + fi + + if (( RET & 1 )); then + echo "⚠️ ABI check returned COMPATIBLE DIFF" + fi + + if (( RET & 2 )); then + echo "⚠️ ABI check returned INCOMPATIBLE DIFF" + fi + + if (( RET & 4 )); then + echo "❌ ABI check returned STRIPPED PACKAGE" + exit 1 + fi + + if (( RET & 8 )); then + echo "⚠️ ABI check failed because the PPA did not contained an old version for the package." + echo "Assumption is that this is the first time the package was build." + echo "INITIAL_UPLOAD_TO_PPA=true" >> $GITHUB_ENV + fi + + if (( RET & 16 )); then + echo "❌ ABI check failed because there was an error on the PPA" + exit 1 + fi + + - name: Package Version Increment Check + shell: bash + run: | + echo "Run package version check here with ret value" + echo "Content of result file :" + cat ./results.txt + + if grep -qE '^\s*-\s*Version:\s*.*FAIL' ./results.txt; then + echo "❌ Test failed: At least one FAIL found in - Version: line" + exit 1 + else + echo "✅ Test passed: All versions are PASS" + fi \ No newline at end of file diff --git a/.github/actions/push_to_repo/action.yml b/.github/actions/push_to_repo/action.yml new file mode 100644 index 0000000..6d108db --- /dev/null +++ b/.github/actions/push_to_repo/action.yml @@ -0,0 +1,114 @@ +name: Push Built Package To Repo If Need Be +description: | + This Github Actions pushes the newly built package to a repository + +inputs: + token: + description: PAT token + required: true + + force-override: + description: If the version of the package already exists, override it. + default: false + +env: + BUILT_PACKAGE_NAME: null + BUILT_PACKAGE_VERSION: null + +runs: + using: "composite" + + steps: + + + - name: Extract built package name + shell: bash + run: | + changes_file=$(find ./build-area -maxdepth 1 -name '*.changes' | head -n 1) + + main_binary=$(grep '^Binary:' "$changes_file" | sed 's/^Binary: //' | tr ' ' '\n' | grep -v -- '-dev' | head -n 1) + version=$(grep '^Version:' "$changes_file" | sed 's/^Version: //') + + echo "BUILT_PACKAGE_NAME=$main_binary" >> $GITHUB_ENV + echo "BUILT_PACKAGE_VERSION=$version" >> $GITHUB_ENV + + echo "Built package name : $main_binary" + echo "Built package version : $version" + + - name : List All The Versions Of The Built Packages Contained In The Staging PPA + shell: bash + run: | + set +e + ./qcom-build-utils/scripts/ppa_interface.py \ + --operation list-versions \ + --apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \ + --package-name ${{env.BUILT_PACKAGE_NAME}} + + RET=$? + set -e + + - name: Check If Need To Upload To Repo + id: check-version + shell: bash + run: | + echo "Checking if the repo already contains the built version" + + set +e + ./qcom-build-utils/scripts/ppa_interface.py \ + --operation contains-version \ + --apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \ + --package-name ${{env.BUILT_PACKAGE_NAME}} \ + --version ${{env.BUILT_PACKAGE_VERSION}} + + RET=$? + set -e + + echo "do_upload=true" >> $GITHUB_OUTPUT + + if [[ "$RET" == "0" && "${{inputs.force-override}}" == "false" ]]; then + echo "Package version already exists in the repo and force-override is set to false. We are therefore done here." + echo "do_upload=false" >> $GITHUB_OUTPUT + elif [[ "$RET" == "0" && "${{inputs.force-override}}" == "true" ]]; then + echo "Package version already exists in the repo, but force-override is set to true. Proceeding to override the package" + else + echo "The package version does not exist in the repo. Proceeding to uploat it." + fi + + - name: Checkout Staging Repo + if: steps.check-version.outputs.do_upload == 'true' + uses: actions/checkout@v4 + with: + repository: ${{env.REPO_NAME}} + ref: main + token: ${{inputs.token}} + path: ./pkg-oss-staging-repo + fetch-depth: 1 + + # TODO Improve the commit messgae to include what are the packages that have been added + - name: Upload Debian Packages To Staging Repo + if: steps.check-version.outputs.do_upload == 'true' + shell: bash + run: | + ./qcom-build-utils/scripts/ppa_organizer.py --build-dir ./build-area --output-dir ./pkg-oss-staging-repo/pool/${{env.UBUNTU_CODENAME}}/stable/main + + cd ./pkg-oss-staging-repo + + PPA_PACKAGES_FILE_REPO_PATH=dists/${{env.UBUNTU_CODENAME}}/stable/main/binary-${{env.ARCH}} + + dpkg-scanpackages --multiversion pool/${{env.UBUNTU_CODENAME}} > $PPA_PACKAGES_FILE_REPO_PATH/Packages + dpkg-scanpackages --type ddeb --multiversion pool/${{env.UBUNTU_CODENAME}} >> $PPA_PACKAGES_FILE_REPO_PATH/Packages + + gzip -k -f $PPA_PACKAGES_FILE_REPO_PATH/Packages + + cat $PPA_PACKAGES_FILE_REPO_PATH/Packages + + git add . + + git config user.name "Github Service Bot" + git config user.email "githubservice@qti.qualcomm.com" + + git commit -s -m "Uploaded Package ${{env.BUILT_PACKAGE_NAME}} at version ${{env.BUILT_PACKAGE_VERSION}} for distro ${{env.UBUNTU_CODENAME}}" + + git remote set-url origin https://x-access-token:${{inputs.token}}@github.com/${{env.REPO_NAME}}.git + + git push origin \ No newline at end of file diff --git a/.github/workflows/qcom-build-debian-package-reusable-workflow.yml b/.github/workflows/qcom-build-debian-package-reusable-workflow.yml index 934e4bf..89e4b59 100644 --- a/.github/workflows/qcom-build-debian-package-reusable-workflow.yml +++ b/.github/workflows/qcom-build-debian-package-reusable-workflow.yml @@ -13,18 +13,33 @@ on: required: true debian-ref: - description: The debian ref to build. For example "debian/latest", the ref would be "latest". Or for "debian/1.0.0-1" the ref would be "1.0.0-1 " + description: The debian ref to build. For example branch "debian/latest" or tag "debian/1.0.0-1" type: string required: true default: debian/latest + ubuntu-codename: + description: The ubuntu codename to build for. Ex noble, jammy, etc + type: string + default: noble + + run-lintian: + description: Run lintian or not during the build + type: boolean + default: false + abi-checker: description: Run the ABI checker or not type: boolean default: false + push-to-repo: + description: Whether or not to push the built package to the repository if the compiled version is not already in it + type: boolean + default: false + secrets: - PAT: + TOKEN: required: true permissions: @@ -32,18 +47,12 @@ permissions: security-events: write env: - PPA_URL: https://qualcomm-linux.github.io/pkg-oss-staging-repo/ - - # This variable is set to true below if the ABI check is not able to find an initial - # version of the package in the PPA. - INITIAL_UPLOAD_TO_PPA: 'false' - ABI_CHECK_RETURN_VALUE: 0 + REPO_URL: https://qualcomm-linux.github.io/pkg-oss-staging-repo/ + REPO_NAME: qualcomm-linux/pkg-oss-staging-repo - PRODUCT_DISTRO: null - PRODUCT_CODENAME: null - PRODUCT_ARCH: null - - PPA_PACKAGES_FILE_REPO_PATH: null + UBUNTU_CODENAME: ${{inputs.ubuntu-codename}} + DISTRO: ubuntu + ARCH: arm64 jobs: build-debian-package: @@ -69,17 +78,17 @@ jobs: uses: actions/checkout@v4 with: repository: qualcomm-linux/qcom-build-utils - ref: ${{ inputs.qcom-build-utils-ref }} - token: ${{ secrets.PAT }} + ref: ${{inputs.qcom-build-utils-ref}} + token: ${{secrets.TOKEN}} path: ./qcom-build-utils fetch-depth: 1 - name: Checkout Repository uses: actions/checkout@v4 with: - ref: ${{ inputs.debian-ref }} + ref: ${{inputs.debian-ref}} clean: false # A rm -rf * was done first, don't clean otherwise this would delete qcom-build-utils cloned above - token: ${{ secrets.PAT }} + token: ${{secrets.TOKEN}} path: ./package-repo fetch-depth: 1 @@ -89,36 +98,18 @@ jobs: cd ./package-repo git fetch --depth=1 origin "+refs/heads/*:refs/remotes/origin/*" "+refs/tags/*:refs/tags/*" - - name: Exctract Product Configuration From qcom-product.conf - run: | - CONFIG_FILE="package-repo/qcom-distro-ubuntu/qcom-product.conf" - - DISTRO=ubuntu #$(grep '^Distro:' "$CONFIG_FILE" | cut -d':' -f2 | xargs) - CODENAME=noble #$(grep '^Codename:' "$CONFIG_FILE" | cut -d':' -f2 | xargs) - ARCH=arm64 #$(grep '^Arch:' "$CONFIG_FILE" | cut -d':' -f2 | xargs) - - echo "Distro: $DISTRO" - echo "Codename: $CODENAME" - echo "Arch: $ARCH" - - echo "PRODUCT_DISTRO=${DISTRO}" >> $GITHUB_ENV - echo "PRODUCT_CODENAME=${CODENAME}" >> $GITHUB_ENV - echo "PRODUCT_ARCH=${ARCH}" >> $GITHUB_ENV - - echo "PPA_PACKAGES_FILE_REPO_PATH=dists/$CODENAME/stable/main/binary-$ARCH" >> $GITHUB_ENV - - name: Validate Or Create Chroot Environment run: | ./qcom-build-utils/scripts/prep_chroot_env.py \ - --arch ${{ env.PRODUCT_ARCH }} \ - --os-codename ${{ env.PRODUCT_CODENAME }} \ - --suffix ${{ env.PRODUCT_DISTRO }} + --arch ${{env.ARCH}} \ + --os-codename ${{env.UBUNTU_CODENAME}} \ + --suffix ${{env.DISTRO}} - name: Prepare Workspace Structure For The Build run: | echo "Listing the content of the workspace :"; tree - mkdir build + mkdir build-area if grep -q 'quilt' ./package-repo/debian/source/format; then echo "Source format is quilt" @@ -129,26 +120,30 @@ jobs: exit 1 fi - # Run lintian to see if the package is well formatted - # TODO make it fail if there are errors, and perhaps add a -Werror kind of input - - name: Run lintian - run: | - set +e - cd package-repo - gbp buildpackage --git-builder="lintian" - set -e - - name: Build Debian Packages run: | - set +e cd package-repo + + if [[ "${{inputs.run-lintian}}" == "true" ]]; then + lintian_flag="--run-lintian" + else + lintian_flag="--no-run-lintian" + fi + + if curl -sfI "http://pkg.qualcomm.com/dists/${{env.UBUNTU_CODENAME}}/Release" > /dev/null; then + EXTRA_REPO="--extra-repository='deb [arch=${{env.ARCH}} trusted=yes] http://pkg.qualcomm.com ${{env.UBUNTU_CODENAME}}/stable main'" + else + EXTRA_REPO="" + fi + + set +e gbp buildpackage --git-ignore-branch \ - --git-builder="sbuild --arch=arm64 \ - --dist=noble-arm64-ubuntu \ - --no-run-lintian \ - --build-dir ../build \ + --git-builder="sbuild --arch=${{env.ARCH}} \ + --dist=${{env.UBUNTU_CODENAME}}-${{env.ARCH}}-${{env.DISTRO}} \ + $lintian_flag \ + --build-dir ../build-area \ --build-dep-resolver=apt \ - --extra-repository='deb [arch=arm64 trusted=yes] http://pkg.qualcomm.com noble/stable main'" + $EXTRA_REPO" RET=$? set -e @@ -157,153 +152,18 @@ jobs: echo "✅ Successfully built package" else # Print the real .build log, not the symlink - tail -n 500 $(find ../build -maxdepth 1 -name "*.build" ! -type l) + tail -n 500 $(find ../build-area -maxdepth 1 -name "*.build" ! -type l) echo "❌ Build failed, printed the last 500 lines of the build log file" exit 1 fi - - name : List All The Versions Of The Built Packages Contained In The Staging PPA - run: | - set +e - ./qcom-build-utils/scripts/ppa_interface.py \ - --operation list-versions \ - --apt-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \ - --package-name libqcom-example1 - - RET=$? - set -e - - # TODO : For now, this step is completely skipped over (if false below). - # Next step is to activate it and download the latest version. - # Then, modify the ABI checker script to remove the logic that downloads the newest version of the package - # in order to simplify the code. - - name : Download Latest Version Of The Built Package From PPA To Compare ABI Against - if: ${{ false }} - run: | - set +e - ./qcom-build-utils/scripts/ppa_interface.py \ - --operation download \ - --apt-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \ - --package-name libqcom-example1 - - RET=$? - set -e - - if (( RET == 0 )); then - echo "✅ Successfully downloaded latest version" - fi - - # TODO deal with other return values - - - name: ABI Check - if: ${{ inputs.abi-checker == true }} - run: | - set +e - - ./qcom-build-utils/scripts/deb_abi_checker.py \ - --new-package-dir ./build \ - --apt-server-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \ - --result-file ./results.txt - - RET=$? - set -e - - echo "ABI check returned $RET" - - # (0): RETURN_ABI_NO_DIFF - # Bit 0 (1): RETURN_ABI_COMPATIBLE_DIFF - # Bit 1 (2): RETURN_ABI_INCOMPATIBLE_DIFF - # Bit 2 (4): RETURN_ABI_STRIPPED_PACKAGE - # Bit 3 (8): RETURN_PPA_PACKAGE_NOT_FOUND - # Bit 4 (16): RETURN_PPA_ERROR - - if (( RET == 0 )); then - echo "✅ ABI check returned NO_DIFF" - fi - - if (( RET & 1 )); then - echo "⚠️ ABI check returned COMPATIBLE DIFF" - fi - - if (( RET & 2 )); then - echo "⚠️ ABI check returned INCOMPATIBLE DIFF" - fi - - if (( RET & 4 )); then - echo "❌ ABI check returned STRIPPED PACKAGE" - exit 1 - fi - - if (( RET & 8 )); then - echo "⚠️ ABI check failed because the PPA did not contained an old version for the package." - echo "Assumption is that this is the first time the package was build." - echo "INITIAL_UPLOAD_TO_PPA=true" >> $GITHUB_ENV - fi + - name: Run ABI Check + if: ${{inputs.abi-checker == true}} + uses: ./qcom-build-utils/.github/actions/abi_checker - if (( RET & 16 )); then - echo "❌ ABI check failed because there was an error on the PPA" - exit 1 - fi - - echo "ABI_CHECK_RETURN_VALUE=${RET}" >> $GITHUB_ENV - - - name: Package Version Increment Check - if: ${{ inputs.abi-checker == true && env.INITIAL_UPLOAD_TO_PPA == 'false' }} - run: | - echo "Run package version check here with ret value ${{ env.ABI_CHECK_RETURN_VALUE }}" - echo "Content of result file :" - cat ./results.txt - - if grep -qE '^\s*-\s*Version:\s*.*FAIL' ./results.txt; then - echo "❌ Test failed: At least one FAIL found in - Version: line" - exit 1 - else - echo "✅ Test passed: All versions are PASS" - fi - - # TODO Complete this in order to check if the version we just compiled exists in the PPA or not - # in order to know it we need to execute the upload steps below - # Use env.INITIAL_UPLOAD_TO_PPA in the logic also - - name: Check If Need To Upload To PPA - if: ${{ inputs.abi-checker == true && false }} - run: | - set +e - ./qcom-build-utils/scripts/ppa_interface.py \ - --operation contains-version \ - --apt-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \ - --package-name libqcom-example1 - --version 1.1.0 - - RET=$? - set -e - - - name: Checkout PPA staging repo - if: ${{ inputs.abi-checker == true && env.INITIAL_UPLOAD_TO_PPA == 'true' }} - uses: actions/checkout@v4 + - name: Push package to repo + if: ${{inputs.push-to-repo == true}} + uses: ./qcom-build-utils/.github/actions/push_to_repo with: - repository: qualcomm-linux/qcom-oss-staging-ppa - ref: main - ssh-key: ${{ secrets.ACTIONS_SSH_KEY }} - path: ./qcom-oss-staging-ppa - fetch-depth: 1 - - # TODO Improve the commit messgae to include what are the packages that have been added - - name: Upload Debian Packages To PPA Server If First Build - if: ${{ inputs.abi-checker == true && env.INITIAL_UPLOAD_TO_PPA == 'true' }} - run: | - ./qcom-build-utils/scripts/ppa_organizer.py --build-dir ./build --output-dir ./qcom-oss-staging-ppa/pool/${{env.PRODUCT_CODENAME}}/stable/main - - cd ./qcom-oss-staging-ppa - - dpkg-scanpackages --multiversion pool/${{ env.PRODUCT_CODENAME }} > ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages - dpkg-scanpackages --type ddeb --multiversion pool/${{ env.PRODUCT_CODENAME }} >> ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages - - gzip -k -f ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages - - cat ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages - - git add . - - git commit -s -m "Uploaded Packages" - - git push \ No newline at end of file + force-override: false + token: ${{secrets.TOKEN}} \ No newline at end of file diff --git a/.github/workflows/qcom-pkg-build-pr-check-reusable-workflow.yml b/.github/workflows/qcom-pkg-build-pr-check-reusable-workflow.yml new file mode 100644 index 0000000..27fb7c3 --- /dev/null +++ b/.github/workflows/qcom-pkg-build-pr-check-reusable-workflow.yml @@ -0,0 +1,61 @@ +name: Package Build PR Check Reusable Workflow +description: | + This reusable workflow is called by an upstream repo PR to verify that what + is attempted to be merged won't break the package + +on: + workflow_call: + inputs: + qcom-build-utils-ref: + description: The ref name that was used to invoke this reusable workflow + type: string + required: true + + upstream-repo: + description: The upstream github repository name that triggered this workflow + type: string + required: true + + upstream-repo-ref: + description: The upstream github ref that triggered the build + type: string + required: true + + pkg-repo: + description: The upstream package repo against which to try the build + type: string + required: true + + secrets: + TOKEN: + required: true + +permissions: + contents: read + security-events: write + +jobs: + pkg-build-pr-check: + + runs-on: [self-hosted, Linux, ARM64] +# runs-on: [self-hosted, lecore-stg-u2404-arm64-xlrg-od-ephem] + +# container: +# image: ubuntu:noble +# options: --volume /srv/chroot:/srv/chroot + + steps: + +# - name: Install dependencies +# run: | +# apt-get update +# apt-get install -y git git-buildpackage sbuild debootstrap tree + + - name: Ensure Workspace Is Clean + run: rm -rf * + + - name: Print caller info + run: | + echo "upstream-repo : ${{inputs.upstream-repo}}" + echo "upstream-repo-ref : ${{inputs.upstream-repo-ref}}" + echo "pkg-repo : ${{inputs.pkg-repo}}" diff --git a/.github/workflows/qcom-promote-upstream-reusable-workflow.yml b/.github/workflows/qcom-promote-upstream-reusable-workflow.yml index d447892..226491b 100644 --- a/.github/workflows/qcom-promote-upstream-reusable-workflow.yml +++ b/.github/workflows/qcom-promote-upstream-reusable-workflow.yml @@ -36,7 +36,7 @@ on: default: false secrets: - PAT: + TOKEN: required: true permissions: @@ -69,9 +69,9 @@ jobs: # Normalizing a tag : (e.g ) v1.0.0 -> 1.0.0 - name: Normalize Tag Version run: | - echo "ℹ️Input upstream-tag is : ${{ inputs.upstream-tag }}" + echo "ℹ️Input upstream-tag is : ${{inputs.upstream-tag}}" - NORMALIZED_VERSION=$(echo "${{ inputs.upstream-tag }}" | sed 's/^v//') + NORMALIZED_VERSION=$(echo "${{inputs.upstream-tag}}" | sed 's/^v//') echo "NORMALIZED_VERSION=$NORMALIZED_VERSION" >> $GITHUB_ENV echo "ℹ️Normalized version : $NORMALIZED_VERSION" @@ -80,8 +80,8 @@ jobs: uses: actions/checkout@v4 with: repository: qualcomm-linux/qcom-build-utils - ref: ${{ inputs.qcom-build-utils-ref }} - token: ${{ secrets.PAT }} + ref: ${{inputs.qcom-build-utils-ref}} + token: ${{secrets.TOKEN}} path: ./qcom-build-utils fetch-depth: 1 @@ -91,7 +91,7 @@ jobs: ref: debian/latest clean: false # A rm -rf * was done first, don't clean otherwise this would delete qcom-build-utils cloned above #submodules: 'recursive' # Make sure all submodules are recursively checked out - token: ${{ secrets.PAT }} # Add SSH key for cloning private repos + token: ${{secrets.TOKEN}} path: ./package-repo fetch-depth: 1 @@ -109,7 +109,7 @@ jobs: run: | cd ./package-repo - if (git tag --list | grep "${{ inputs.upstream-tag }}"); then + if (git tag --list | grep "${{inputs.upstream-tag}}"); then echo "❌ The supplied upstream tag is wrong as it pertains to this repo already." exit 1 fi @@ -118,8 +118,8 @@ jobs: run: | cd ./package-repo - if (git tag --list | grep "upstream/${{ env.NORMALIZED_VERSION }}"); then - echo "❌ It appears like this repo has already integrated the upstream tag '${{ inputs.upstream-tag }}'" \ + if (git tag --list | grep "upstream/${{env.NORMALIZED_VERSION}}"); then + echo "❌ It appears like this repo has already integrated the upstream tag '${{inputs.upstream-tag}}'" \ " because a local tag 'upstream/$NORMALIZED_VERSION' already exists." exit 1 else @@ -129,15 +129,15 @@ jobs: - name: Add Upstream Link As A Remote And Fetch Tags run: | cd ./package-repo - git remote add upstream-source git@github.com:${{ inputs.upstream-repo }}.git + git remote add upstream-source git@github.com:${{inputs.upstream-repo}}.git git fetch upstream-source "+refs/tags/*:refs/tags/*" - name: Clone Upstream Repo At Specified Tag uses: actions/checkout@v4 with: - repository: ${{ inputs.upstream-repo }} - ref: ${{ inputs.upstream-tag }} - ssh-key: ${{ secrets.ACTIONS_SSH_KEY }} + repository: ${{inputs.upstream-repo}} + ref: ${{inputs.upstream-tag}} + token: ${{secrets.TOKEN}} path: ./upstream-repo fetch-depth: 1 @@ -145,44 +145,49 @@ jobs: run: | cd ./package-repo + git config user.name "Github Service Bot" + git config user.email "githubservice@qti.qualcomm.com" + gbp import-orig --upstream-branch=upstream/latest \ --debian-branch=debian/latest \ --no-pristine-tar \ - --upstream-vcs-tag=${{ inputs.upstream-tag }} \ - --upstream-version=${{ env.NORMALIZED_VERSION }} \ + --upstream-vcs-tag=${{inputs.upstream-tag}} \ + --upstream-version=${{env.NORMALIZED_VERSION}} \ --upstream-tag="upstream/%(version)s" \ --filter=.git \ --filter=.github \ --filter=debian \ ../upstream-repo - # TODO : Export right EMAIL (get either user that triggered the workflow, or github bot) - # TODO : deal with the --distribution parameter in dch command. This is actually not right + + #TODO : Think about how to promote the distro -1 version, and if we push the tag or not - name: Promote Changelog - if: ${{ inputs.promote-changelog == true }} + if: ${{inputs.promote-changelog == true}} run: | cd ./package-repo - export DEBFULLNAME="Github Bot" - export DEBEMAIL=githubbot@qti.qualcomm.com + export DEBFULLNAME="Github Service Bot" + export DEBEMAIL=githubservice@qti.qualcomm.com gbp dch --commit \ --debian-branch=debian/latest \ - --distribution=${{ env.DISTRIBUTION }} - #--new-version=${{ env.NORMALIZED_VERSION }}-1 \ + --distribution=${{env.DISTRIBUTION}} + #--new-version=${{env.NORMALIZED_VERSION}}-1 \ echo "Show the changes in debian/changelog :" git diff --cached debian/changelog #git add debian/changelog #git commit -m "Populate changelog" - git tag debian/${{ env.NORMALIZED_VERSION }}-1 + git tag debian/${{env.NORMALIZED_VERSION}}-1 - name: Push On Success - if: ${{ inputs.push-on-success == true }} + if: ${{inputs.push-on-success == true}} run: | cd ./package-repo - git push origin upstream/${{ env.NORMALIZED_VERSION }} - git push origin debian/${{ env.NORMALIZED_VERSION }}-1 + git push origin upstream/${{env.NORMALIZED_VERSION}} + if "${{inputs.promote-changelog}}" == "true"; then + git push origin debian/${{env.NORMALIZED_VERSION}}-1 + fi git push origin upstream/latest git push origin debian/latest \ No newline at end of file diff --git a/scripts/ppa_interface.py b/scripts/ppa_interface.py index ec81197..b840cfa 100755 --- a/scripts/ppa_interface.py +++ b/scripts/ppa_interface.py @@ -144,7 +144,7 @@ def list_versions() : def contains_version(version : str) -> bool : logger.debug(f"[PPA_INTERFACE]/[CONTAINS_VERSION]/{PACKAGE_NAME}: Checking if PPA contains version : {version}") - command = f"apt-cache policy {PACKAGE_NAME} {OPT}" + command = f"apt list -a {PACKAGE_NAME} {OPT}" apt_ret = subprocess.run(command, cwd=TEMP_DIR, shell=True, capture_output=True) @@ -154,15 +154,14 @@ def contains_version(version : str) -> bool : logger.info(f"stderr :\n{apt_ret.stderr}") sys.exit(1) - for line in apt_ret.stdout.decode().splitlines(): - if line.startswith(" Candidate:"): - versions = line.split("Candidate: ")[1] - if version in versions.split(" "): - logger.info(f"Found version : {version}") - sys.exit(0) + logger.debug(f"apt list stdout:\n{apt_ret.stdout.decode()}") + + if version in apt_ret.stdout.decode(): + logger.info(f"Found version : {version}") + sys.exit(0) logger.warning(f"Did not find version : {version}") - sys.exit(0) + sys.exit(1) def main(): diff --git a/scripts/ppa_organizer.py b/scripts/ppa_organizer.py index 398cbb2..547e522 100755 --- a/scripts/ppa_organizer.py +++ b/scripts/ppa_organizer.py @@ -112,11 +112,11 @@ def reorganize(build_dir : str, output_dir : str): for package_name in package_names: - output_dir = os.path.join(output_dir, package_name) + output_dir_pkg = os.path.join(output_dir, package_name) # Do not delete if the directory exists, it may very well contain the same package, but with older versions # We want to copy the newly built packages alongside the other versions - create_new_directory(output_dir, delete_if_exists=False) + create_new_directory(output_dir_pkg, delete_if_exists=False) logger.debug(f"Re-organizing outputs of package: {package_name}") @@ -126,30 +126,30 @@ def reorganize(build_dir : str, output_dir : str): dbg_package = next((file for file in dbg_files if package_name in file), None) if dsc_package is not None: - shutil.copy(os.path.join(build_dir, dsc_package), os.path.join(output_dir, dsc_package)) - logger.info(f'Copied {dsc_package} to {output_dir}') + shutil.copy(os.path.join(build_dir, dsc_package), os.path.join(output_dir_pkg, dsc_package)) + logger.info(f'Copied {dsc_package} to {output_dir_pkg}') dsc_files.remove(deb_package) else: logger.debug(f"No .dsc package found for {package_name}") if deb_package is not None: - shutil.copy(os.path.join(build_dir, deb_package), os.path.join(output_dir, deb_package)) - logger.info(f'Copied {deb_package} to {output_dir}') + shutil.copy(os.path.join(build_dir, deb_package), os.path.join(output_dir_pkg, deb_package)) + logger.info(f'Copied {deb_package} to {output_dir_pkg}') deb_files.remove(deb_package) else: logger.debug(f"No .deb package found for {package_name}") if dev_package is not None: - shutil.copy(os.path.join(build_dir, dev_package), os.path.join(output_dir, dev_package)) - logger.info(f'Copied {dev_package} to {output_dir}') + shutil.copy(os.path.join(build_dir, dev_package), os.path.join(output_dir_pkg, dev_package)) + logger.info(f'Copied {dev_package} to {output_dir_pkg}') dev_files.remove(dev_package) else: logger.debug(f"No -dev.deb package found for {package_name}") if dbg_package is not None: - shutil.copy(os.path.join(build_dir, dbg_package), os.path.join(output_dir, dbg_package)) - logger.info(f'Copied {dbg_package} to {output_dir}') + shutil.copy(os.path.join(build_dir, dbg_package), os.path.join(output_dir_pkg, dbg_package)) + logger.info(f'Copied {dbg_package} to {output_dir_pkg}') dbg_files.remove(dbg_package) else: logger.debug(f"No -dbgsym.ddeb package found for {package_name}")