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.
This commit is contained in:
Henrik Grimler 2022-04-20 14:04:33 +02:00
parent 6d6f0c91f3
commit 56dbb9cf80
No known key found for this signature in database
GPG Key ID: B0076E490B71616B
9 changed files with 30 additions and 30 deletions

View File

@ -78,8 +78,8 @@ jobs:
cd .. cd ..
fi fi
for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"]' < repo.json) repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
# Parse changed files and identify new packages and deleted packages. # Parse changed files and identify new packages and deleted packages.
# Create lists of those packages that will be passed to upload job for # Create lists of those packages that will be passed to upload job for
# further processing. # further processing.
@ -113,10 +113,10 @@ jobs:
done done
else else
for pkg in ${{ github.event.inputs.packages }}; do 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 found=false
for repo_path in $repo_paths; do 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 if [ -d "${repo_path}/${pkg}" ]; then
found=true found=true
echo "$pkg" >> ./built_${repo}_packages.txt echo "$pkg" >> ./built_${repo}_packages.txt
@ -132,7 +132,7 @@ jobs:
done done
fi 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 # Fix so that lists do not contain duplicates
if [ -f ./built_${repo}_packages.txt ]; then if [ -f ./built_${repo}_packages.txt ]; then
uniq ./built_${repo}_packages.txt > ./built_${repo}_packages.txt.tmp uniq ./built_${repo}_packages.txt > ./built_${repo}_packages.txt.tmp
@ -161,8 +161,8 @@ jobs:
- name: Lint packages - name: Lint packages
run: | run: |
declare -a package_recipes declare -a package_recipes
for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"]' < repo.json) repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then 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"}')" package_recipes="$package_recipes $(cat ./built_${repo}_packages.txt | repo_path=${repo_path} awk '{print ENVIRON["repo_path"]"/"$1"/build.sh"}')"
fi fi
@ -175,8 +175,8 @@ jobs:
- name: Build packages - name: Build packages
run: | run: |
declare -a packages declare -a packages
for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"]' < repo.json) repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt)" packages="$packages $(cat ./built_${repo}_packages.txt)"
@ -192,7 +192,7 @@ jobs:
run: | run: |
test -d termux-packages/output && mv termux-packages/output/* ./output/ 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 # Put package lists into directory with *.deb files so they will be transferred to
# upload job. # upload job.
test -f ./built_${repo}_packages.txt && mv ./built_${repo}_packages.txt ./debs/ test -f ./built_${repo}_packages.txt && mv ./built_${repo}_packages.txt ./debs/
@ -235,7 +235,6 @@ jobs:
path: ./ path: ./
- name: Upload to packages.termux.org - name: Upload to packages.termux.org
env: env:
REPOSITORY_DISTRIBUTION: stable
REPOSITORY_URL: https://packages.termux.org/aptly-api REPOSITORY_URL: https://packages.termux.org/aptly-api
run: | run: |
GITHUB_SHA=${{ github.sha }} GITHUB_SHA=${{ github.sha }}
@ -248,13 +247,14 @@ jobs:
tar xf "$archive" tar xf "$archive"
done done
for repo in $(jq --raw-output '.[]' < repo.json); do for repo in $(jq --raw-output 'keys | .[]' repo.json); do
export REPOSITORY_NAME=$repo 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. # Upload file to temporary directory.
uploaded_files=false uploaded_files=false
shopt -s nullglob 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 if ! aptly_upload_file "$filename"; then
exit 1 exit 1
fi fi
@ -262,7 +262,7 @@ jobs:
uploaded_files=true uploaded_files=true
done done
shopt -u nullglob shopt -u nullglob
# Publishing repository changes. # Publishing repository changes.
if [ "$uploaded_files" = "true" ]; then if [ "$uploaded_files" = "true" ]; then
if ! aptly_add_to_repo; then if ! aptly_add_to_repo; then
@ -282,7 +282,6 @@ jobs:
# Run even if upload to packages.termux.org failed: # Run even if upload to packages.termux.org failed:
if: always() if: always()
env: env:
REPOSITORY_DISTRIBUTION: stable
REPOSITORY_URL: https://aptly-api.grimler.se REPOSITORY_URL: https://aptly-api.grimler.se
run: | run: |
GITHUB_SHA=${{ github.sha }} GITHUB_SHA=${{ github.sha }}
@ -291,13 +290,14 @@ jobs:
source scripts/aptly_api.sh source scripts/aptly_api.sh
for repo in $(jq --raw-output '.[]' < repo.json); do for repo in $(jq --raw-output 'keys | .[]' repo.json); do
export REPOSITORY_NAME=$repo 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. # Upload file to temporary directory.
uploaded_files=false uploaded_files=false
shopt -s nullglob 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 if ! aptly_upload_file "$filename"; then
exit 1 exit 1
fi fi

View File

@ -39,7 +39,7 @@ if [ ! -e "$TERMUX_BUILD_LOCK_FILE" ]; then
touch "$TERMUX_BUILD_LOCK_FILE" touch "$TERMUX_BUILD_LOCK_FILE"
fi 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 # Special variable for internal use. It forces script to ignore
# lock file. # lock file.

View File

@ -1,5 +1,5 @@
{ {
"packages": "termux-main", "packages": { "name" : "termux-main", "distribution" : "stable" },
"root-packages": "termux-root", "root-packages": { "name" : "termux-root", "distribution" : "root" },
"x11-packages": "termux-x11" "x11-packages": { "name" : "termux-x11", "distribution" : "x11" }
} }

View File

@ -178,7 +178,7 @@ check() {
if [ -d "${PKG_NAME}" ] && [ -f "${PKG_NAME}/build.sh" ]; then if [ -d "${PKG_NAME}" ] && [ -f "${PKG_NAME}/build.sh" ]; then
build_sh="${PKG_NAME}/build.sh" build_sh="${PKG_NAME}/build.sh"
else 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 if [ -f $TERMUX_SCRIPTDIR/$repo_dir/$PKG_NAME/build.sh ]; then
build_sh=$TERMUX_SCRIPTDIR/$repo_dir/$PKG_NAME/build.sh build_sh=$TERMUX_SCRIPTDIR/$repo_dir/$PKG_NAME/build.sh
fi fi

View File

@ -34,7 +34,7 @@ fi
for package in "${@}"; do for package in "${@}"; do
package="${package%%/}" package="${package%%/}"
buildsh_path= 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" _buildsh_path="${REPO_ROOT}/${repo}/${package}/build.sh"
echo $_buildsh_path echo $_buildsh_path

View File

@ -39,7 +39,7 @@ for package in "${@}"; do
buildsh_path="${package}/build.sh" buildsh_path="${package}/build.sh"
package=$(basename ${package}) package=$(basename ${package})
else 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 if [ -d "${repo_path}/${package}" ] && [ -f "${repo_path}/${package}/build.sh" ]; then
buildsh_path="${repo_path}/${package}/build.sh" buildsh_path="${repo_path}/${package}/build.sh"
package=$(basename ${package}) package=$(basename ${package})

View File

@ -130,7 +130,7 @@ main() {
echo "INFO: Running update for: $*" echo "INFO: Running update for: $*"
if [[ "$1" == "@all" ]]; then 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 for pkg_dir in $repo_dir/*; do
_run_update "${pkg_dir}" _run_update "${pkg_dir}"
done done
@ -138,7 +138,7 @@ main() {
else else
for pkg in "$@"; do for pkg in "$@"; do
if [ ! -d "${pkg}" ]; then 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 if [ -d "${repo_dir}/${pkg}" ]; then
pkg="${repo_dir}/${pkg}" pkg="${repo_dir}/${pkg}"
break break

View File

@ -453,7 +453,7 @@ linter_main() {
} }
if [ $# -eq 0 ]; then 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 linter_main $repo_dir/*/build.sh
done || exit 1 done || exit 1
else else

View File

@ -59,7 +59,7 @@ rm -rf "${TERMUX_PKG_TMPDIR}"
) )
# Package sources. # 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 for p in "$TERMUX_SCRIPTDIR"/$repo_path/*; do
( (
. "$TERMUX_SCRIPTDIR"/scripts/properties.sh . "$TERMUX_SCRIPTDIR"/scripts/properties.sh