From 56dbb9cf8037eebbe1c65a28fc78b5c47925221c Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Wed, 20 Apr 2022 14:04:33 +0200 Subject: [PATCH] CI: specify distribution in repo.json as well x11-repo uses distribution x11, and root-repo distribution root. Store this information in the json file as well, and parse it to set both REPOSITORY_NAME and REPOSITORY_DISTRIBUTION. Also remove unnecessary `< repo.json` from jq command, jq accepts the file as an argument. This fixes upload issues to x11-repo and root-repo. --- .github/workflows/packages.yml | 38 ++++++++++++++++----------------- build-package.sh | 2 +- repo.json | 6 +++--- scripts/bin/check-auto-update | 2 +- scripts/bin/revbump | 2 +- scripts/bin/update-checksum | 2 +- scripts/bin/update-packages | 4 ++-- scripts/lint-packages.sh | 2 +- scripts/setup-offline-bundle.sh | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index d66b1e8c8..be30aedd7 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -78,8 +78,8 @@ jobs: cd .. fi - for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do - repo=$(jq --raw-output '.["'${repo_path}'"]' < repo.json) + for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do + repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) # Parse changed files and identify new packages and deleted packages. # Create lists of those packages that will be passed to upload job for # further processing. @@ -113,10 +113,10 @@ jobs: done else for pkg in ${{ github.event.inputs.packages }}; do - repo_paths=$(jq --raw-output 'keys | .[]' < repo.json) + repo_paths=$(jq --raw-output 'keys | .[]' repo.json) found=false for repo_path in $repo_paths; do - repo=$(jq --raw-output '.["'${repo_path}'"]' < repo.json) + repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) if [ -d "${repo_path}/${pkg}" ]; then found=true echo "$pkg" >> ./built_${repo}_packages.txt @@ -132,7 +132,7 @@ jobs: done fi - for repo in $(jq --raw-output '.[]' < repo.json); do + for repo in $(jq --raw-output '.[]' repo.json); do # Fix so that lists do not contain duplicates if [ -f ./built_${repo}_packages.txt ]; then uniq ./built_${repo}_packages.txt > ./built_${repo}_packages.txt.tmp @@ -161,8 +161,8 @@ jobs: - name: Lint packages run: | declare -a package_recipes - for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do - repo=$(jq --raw-output '.["'${repo_path}'"]' < repo.json) + for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do + repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) if [ -f ./built_${repo}_packages.txt ]; then package_recipes="$package_recipes $(cat ./built_${repo}_packages.txt | repo_path=${repo_path} awk '{print ENVIRON["repo_path"]"/"$1"/build.sh"}')" fi @@ -175,8 +175,8 @@ jobs: - name: Build packages run: | declare -a packages - for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do - repo=$(jq --raw-output '.["'${repo_path}'"]' < repo.json) + for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do + repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) if [ -f ./built_${repo}_packages.txt ]; then packages="$packages $(cat ./built_${repo}_packages.txt)" @@ -192,7 +192,7 @@ jobs: run: | test -d termux-packages/output && mv termux-packages/output/* ./output/ - for repo in $(jq --raw-output '.[]' < repo.json); do + for repo in $(jq --raw-output '.[].name' repo.json); do # Put package lists into directory with *.deb files so they will be transferred to # upload job. test -f ./built_${repo}_packages.txt && mv ./built_${repo}_packages.txt ./debs/ @@ -235,7 +235,6 @@ jobs: path: ./ - name: Upload to packages.termux.org env: - REPOSITORY_DISTRIBUTION: stable REPOSITORY_URL: https://packages.termux.org/aptly-api run: | GITHUB_SHA=${{ github.sha }} @@ -248,13 +247,14 @@ jobs: tar xf "$archive" done - for repo in $(jq --raw-output '.[]' < repo.json); do - export REPOSITORY_NAME=$repo + for repo in $(jq --raw-output 'keys | .[]' repo.json); do + export REPOSITORY_NAME=$(jq --raw-output '.["'$repo'"].name' repo.json) + export REPOSITORY_DISTRIBUTION=$(jq --raw-output '.["'$repo'"].distribution' repo.json) # Upload file to temporary directory. uploaded_files=false shopt -s nullglob - for filename in $(cat debs/built_${repo}_packages.txt | sed -E 's/(..*)/debs\/\1_\*.deb debs\/\1-static_\*.deb/g'); do + for filename in $(cat debs/built_${REPOSITORY_NAME}_packages.txt | sed -E 's/(..*)/debs\/\1_\*.deb debs\/\1-static_\*.deb/g'); do if ! aptly_upload_file "$filename"; then exit 1 fi @@ -262,7 +262,7 @@ jobs: uploaded_files=true done shopt -u nullglob - + # Publishing repository changes. if [ "$uploaded_files" = "true" ]; then if ! aptly_add_to_repo; then @@ -282,7 +282,6 @@ jobs: # Run even if upload to packages.termux.org failed: if: always() env: - REPOSITORY_DISTRIBUTION: stable REPOSITORY_URL: https://aptly-api.grimler.se run: | GITHUB_SHA=${{ github.sha }} @@ -291,13 +290,14 @@ jobs: source scripts/aptly_api.sh - for repo in $(jq --raw-output '.[]' < repo.json); do - export REPOSITORY_NAME=$repo + for repo in $(jq --raw-output 'keys | .[]' repo.json); do + export REPOSITORY_NAME=$(jq --raw-output '.["'$repo'"].name' repo.json) + export REPOSITORY_DISTRIBUTION=$(jq --raw-output '.["'$repo'"].distribution' repo.json) # Upload file to temporary directory. uploaded_files=false shopt -s nullglob - for filename in $(cat debs/built_${repo}_packages.txt | sed -E 's/(..*)/debs\/\1_\*.deb debs\/\1-static_\*.deb/g'); do + for filename in $(cat debs/built_${REPOSITORY_NAME}_packages.txt | sed -E 's/(..*)/debs\/\1_\*.deb debs\/\1-static_\*.deb/g'); do if ! aptly_upload_file "$filename"; then exit 1 fi diff --git a/build-package.sh b/build-package.sh index 5ef3bc660..e4515afd5 100755 --- a/build-package.sh +++ b/build-package.sh @@ -39,7 +39,7 @@ if [ ! -e "$TERMUX_BUILD_LOCK_FILE" ]; then touch "$TERMUX_BUILD_LOCK_FILE" fi -export TERMUX_PACKAGES_DIRECTORIES=$(jq --raw-output 'keys | .[]' < ${TERMUX_SCRIPTDIR}/repo.json) +export TERMUX_PACKAGES_DIRECTORIES=$(jq --raw-output 'keys | .[]' ${TERMUX_SCRIPTDIR}/repo.json) # Special variable for internal use. It forces script to ignore # lock file. diff --git a/repo.json b/repo.json index 6a3fcb319..06f32507a 100644 --- a/repo.json +++ b/repo.json @@ -1,5 +1,5 @@ { - "packages": "termux-main", - "root-packages": "termux-root", - "x11-packages": "termux-x11" + "packages": { "name" : "termux-main", "distribution" : "stable" }, + "root-packages": { "name" : "termux-root", "distribution" : "root" }, + "x11-packages": { "name" : "termux-x11", "distribution" : "x11" } } diff --git a/scripts/bin/check-auto-update b/scripts/bin/check-auto-update index 18e4ad049..00c62a0c9 100755 --- a/scripts/bin/check-auto-update +++ b/scripts/bin/check-auto-update @@ -178,7 +178,7 @@ check() { if [ -d "${PKG_NAME}" ] && [ -f "${PKG_NAME}/build.sh" ]; then build_sh="${PKG_NAME}/build.sh" else - for repo_dir in $(jq --raw-output 'keys | .[]' < $TERMUX_SCRIPTDIR/repo.json); do + for repo_dir in $(jq --raw-output 'keys | .[]' $TERMUX_SCRIPTDIR/repo.json); do if [ -f $TERMUX_SCRIPTDIR/$repo_dir/$PKG_NAME/build.sh ]; then build_sh=$TERMUX_SCRIPTDIR/$repo_dir/$PKG_NAME/build.sh fi diff --git a/scripts/bin/revbump b/scripts/bin/revbump index 2ca61a15f..9eb39cb09 100755 --- a/scripts/bin/revbump +++ b/scripts/bin/revbump @@ -34,7 +34,7 @@ fi for package in "${@}"; do package="${package%%/}" buildsh_path= - for repo in $(jq --raw-output 'keys | .[]' < ${REPO_ROOT}/repo.json); do + for repo in $(jq --raw-output 'keys | .[]' ${REPO_ROOT}/repo.json); do _buildsh_path="${REPO_ROOT}/${repo}/${package}/build.sh" echo $_buildsh_path diff --git a/scripts/bin/update-checksum b/scripts/bin/update-checksum index 7f6a8a272..29df3edf5 100755 --- a/scripts/bin/update-checksum +++ b/scripts/bin/update-checksum @@ -39,7 +39,7 @@ for package in "${@}"; do buildsh_path="${package}/build.sh" package=$(basename ${package}) else - for repo_path in $(jq --raw-output 'keys | . []' < $REPO_ROOT/repo.json); do + for repo_path in $(jq --raw-output 'keys | .[]' $REPO_ROOT/repo.json); do if [ -d "${repo_path}/${package}" ] && [ -f "${repo_path}/${package}/build.sh" ]; then buildsh_path="${repo_path}/${package}/build.sh" package=$(basename ${package}) diff --git a/scripts/bin/update-packages b/scripts/bin/update-packages index 83e6a5432..4f72f088d 100755 --- a/scripts/bin/update-packages +++ b/scripts/bin/update-packages @@ -130,7 +130,7 @@ main() { echo "INFO: Running update for: $*" if [[ "$1" == "@all" ]]; then - for repo_dir in $(jq --raw-output 'keys | .[]' < ${TERMUX_SCRIPTDIR}/repo.json); do + for repo_dir in $(jq --raw-output 'keys | .[]' ${TERMUX_SCRIPTDIR}/repo.json); do for pkg_dir in $repo_dir/*; do _run_update "${pkg_dir}" done @@ -138,7 +138,7 @@ main() { else for pkg in "$@"; do if [ ! -d "${pkg}" ]; then - for repo_dir in $(jq --raw-output 'keys | .[]' < ${TERMUX_SCRIPTDIR}/repo.json); do + for repo_dir in $(jq --raw-output 'keys | .[]' ${TERMUX_SCRIPTDIR}/repo.json); do if [ -d "${repo_dir}/${pkg}" ]; then pkg="${repo_dir}/${pkg}" break diff --git a/scripts/lint-packages.sh b/scripts/lint-packages.sh index 4963c9a4d..af96695c8 100755 --- a/scripts/lint-packages.sh +++ b/scripts/lint-packages.sh @@ -453,7 +453,7 @@ linter_main() { } if [ $# -eq 0 ]; then - for repo_dir in $(jq --raw-output 'keys | .[]' < $REPO_DIR/repo.json); do + for repo_dir in $(jq --raw-output 'keys | .[]' $REPO_DIR/repo.json); do linter_main $repo_dir/*/build.sh done || exit 1 else diff --git a/scripts/setup-offline-bundle.sh b/scripts/setup-offline-bundle.sh index ae44c617f..11aacb53c 100755 --- a/scripts/setup-offline-bundle.sh +++ b/scripts/setup-offline-bundle.sh @@ -59,7 +59,7 @@ rm -rf "${TERMUX_PKG_TMPDIR}" ) # Package sources. -for repo_path in $(jq --raw-output 'keys | .[]' < $TERMUX_SCRIPTDIR/repo.json); do +for repo_path in $(jq --raw-output 'keys | .[]' $TERMUX_SCRIPTDIR/repo.json); do for p in "$TERMUX_SCRIPTDIR"/$repo_path/*; do ( . "$TERMUX_SCRIPTDIR"/scripts/properties.sh