monorepo: apply changes suggested by buttaface

This commit is contained in:
Yaksh Bariya 2022-04-17 17:07:08 +05:30
parent 52c383b4d1
commit f0ea9b922b
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
7 changed files with 96 additions and 83 deletions

View File

@ -5,14 +5,14 @@ on:
branches: branches:
- master - master
paths: paths:
- 'main/**' - 'packages/**'
- 'x11/**' - 'root-packages/**'
- 'root/**' - 'x11-packages/**'
pull_request: pull_request:
paths: paths:
- 'main/**' - 'packages/**'
- 'x11/**' - 'root-packages/**'
- 'root/**' - 'x11-packages/**'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
packages: packages:
@ -78,32 +78,33 @@ jobs:
cd .. cd ..
fi fi
for repo in main x11 root; do for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do
local repo=$(jq --raw-output '.["'$repo_path'"]' < 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.
while read -r file; do while read -r file; do
if ! [[ $file == $repo/* ]]; then if ! [[ $file == $repo_path/* ]]; then
# This file does not belong to a package, so ignore it # This file does not belong to a package, so ignore it
continue continue
fi fi
if [[ $file =~ ^$repo/([.a-z0-9+-]*)/([.a-z0-9+-]*).subpackage.sh$ ]]; then if [[ $file =~ ^$repo_path/([.a-z0-9+-]*)/([.a-z0-9+-]*).subpackage.sh$ ]]; then
# A subpackage was modified, check if it was deleted or just updated # A subpackage was modified, check if it was deleted or just updated
pkg=${BASH_REMATCH[1]} pkg=${BASH_REMATCH[1]}
subpkg=${BASH_REMATCH[2]} subpkg=${BASH_REMATCH[2]}
if [ ! -f "${repo}/${pkg}/${subpkg}.subpackage.sh" ]; then if [ ! -f "${repo_path}/${pkg}/${subpkg}.subpackage.sh" ]; then
echo "$subpkg" >> ./deleted_$repo_packages.txt echo "$subpkg" >> ./deleted_$repo_packages.txt
fi fi
elif [[ $file =~ ^$repo/([.a-z0-9+-]*)/.*$ ]]; then elif [[ $file =~ ^$repo_path/([.a-z0-9+-]*)/.*$ ]]; then
# package, check if it was deleted or updated # package, check if it was deleted or updated
pkg=${BASH_REMATCH[1]} pkg=${BASH_REMATCH[1]}
if [ ! -d "${repo}/${pkg}" ]; then if [ ! -d "${repo_path}/${pkg}" ]; then
echo "$pkg" >> ./deleted_$repo_packages.txt echo "$pkg" >> ./deleted_$repo_packages.txt
else else
echo "$pkg" >> ./built_$repo_packages.txt echo "$pkg" >> ./built_$repo_packages.txt
# If there are subpackages we want to create a list of those # If there are subpackages we want to create a list of those
# as well # as well
for file in $(find "${repo}/${pkg}/" -maxdepth 1 -type f -name \*.subpackage.sh | sort); do for file in $(find "${repo_path}/${pkg}/" -maxdepth 1 -type f -name \*.subpackage.sh | sort); do
echo "$(basename "${file%%.subpackage.sh}")" >> ./built_$repo_subpackages.txt echo "$(basename "${file%%.subpackage.sh}")" >> ./built_$repo_subpackages.txt
done done
fi fi
@ -112,7 +113,8 @@ jobs:
done done
else else
for pkg in ${{ github.event.inputs.packages }}; do for pkg in ${{ github.event.inputs.packages }}; do
for repo in main x11 root; do for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do
local repo=$(jq --raw-output '.["'$repo_path'"]' < repo.json)
if [ -d "${repo}/${pkg}" ]; then if [ -d "${repo}/${pkg}" ]; then
echo "$pkg" >> ./built_$repo_packages.txt echo "$pkg" >> ./built_$repo_packages.txt
for subpkg in $(find "${repo}/${pkg}/" -maxdepth 1 -type f -name \*.subpackage.sh | sort); do for subpkg in $(find "${repo}/${pkg}/" -maxdepth 1 -type f -name \*.subpackage.sh | sort); do
@ -125,7 +127,7 @@ jobs:
done done
fi fi
for repo in main x11 root; 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
@ -154,9 +156,10 @@ jobs:
- name: Lint packages - name: Lint packages
run: | run: |
local package_recipes= local package_recipes=
for repo in main x11 root; do for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do
local repo=$(jq --raw-output '.["'$repo_path'"]' < repo.json)
if [ -f ./built_$repo_packages.txt ]; then if [ -f ./built_$repo_packages.txt ]; then
package_recipes+=$(cat ./built_$repo_packages.txt | repo=$repo awk '{print ENVIRON["repo"]"/"$1"/build.sh"}') package_recipes+=$(cat ./built_$repo_packages.txt | repo_path=$repo_path awk '{print ENVIRON["repo_path"]"/"$1"/build.sh"}')
fi fi
done done
@ -165,7 +168,9 @@ jobs:
- name: Build packages - name: Build packages
run: | run: |
local packages= local packages=
for repo in main x11 root; do for repo_path in $(jq --raw-output 'keys | .[]' < repo.json); do
local repo=$(jq --raw-output '.["'$repo_path'"]' < repo.json)
if [ -f ./built_$repo_packages.txt ]; then if [ -f ./built_$repo_packages.txt ]; then
packages+=$(cat ./build_$repo_packages.txt) packages+=$(cat ./build_$repo_packages.txt)
fi fi
@ -178,7 +183,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 main x11 root; do for repo in $(jq --raw-output '.[]' < repo.json); do
mkdir debs mkdir debs
# 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.
@ -223,7 +228,6 @@ jobs:
path: ./ path: ./
- name: Upload to packages.termux.org - name: Upload to packages.termux.org
env: env:
REPOSITORY_NAME: termux-main
REPOSITORY_DISTRIBUTION: stable REPOSITORY_DISTRIBUTION: stable
REPOSITORY_URL: https://packages.termux.org/aptly-api REPOSITORY_URL: https://packages.termux.org/aptly-api
run: | run: |
@ -233,8 +237,8 @@ jobs:
source scripts/aptly_api.sh source scripts/aptly_api.sh
for repo in main x11 root; do for repo in $(jq --raw-output '.[]' < repo.json); do
export REPOSITORY_NAME=termux-$repo export REPOSITORY_NAME=$repo
for archive in debs-*/debs-$repo-{aarch64,arm,i686,x86_64}-${{ github.sha }}.tar; do for archive in debs-*/debs-$repo-{aarch64,arm,i686,x86_64}-${{ github.sha }}.tar; do
tar xf "$archive" tar xf "$archive"
@ -284,8 +288,8 @@ jobs:
source scripts/aptly_api.sh source scripts/aptly_api.sh
for repo in main x11 root; do for repo in $(jq --raw-output '.[]' < repo.json); do
export REPOSITORY_NAME=termux-$repo export REPOSITORY_NAME=$repo
for archive in debs-*/debs-$repo-{aarch64,arm,i686,x86_64}-${{ github.sha }}.tar; do for archive in debs-*/debs-$repo-{aarch64,arm,i686,x86_64}-${{ github.sha }}.tar; do
tar xf "$archive" tar xf "$archive"

6
.gitignore vendored
View File

@ -18,6 +18,6 @@ scripts/.vagrant/
/build-tools/ /build-tools/
# Predownloaded packages sources. # Predownloaded packages sources.
/main/*/cache /packages/*/cache
/root/*/cache /root-packages/*/cache
/x11/*/cache /x11-packages/*/cache

View File

@ -39,6 +39,8 @@ 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)
# Special variable for internal use. It forces script to ignore # Special variable for internal use. It forces script to ignore
# lock file. # lock file.
: "${TERMUX_BUILD_IGNORE_LOCK:=false}" : "${TERMUX_BUILD_IGNORE_LOCK:=false}"
@ -451,23 +453,24 @@ for ((i=0; i<${#PACKAGE_LIST[@]}; i++)); do
# Check the package to build: # Check the package to build:
TERMUX_PKG_NAME=$(basename "${PACKAGE_LIST[i]}") TERMUX_PKG_NAME=$(basename "${PACKAGE_LIST[i]}")
export TERMUX_PKG_BUILDER_DIR=
if [[ ${PACKAGE_LIST[i]} == *"/"* ]]; then if [[ ${PACKAGE_LIST[i]} == *"/"* ]]; then
# Path to directory which may be outside this repo: # Path to directory which may be outside this repo:
if [ ! -d "${PACKAGE_LIST[i]}" ]; then termux_error_exit "'${PACKAGE_LIST[i]}' seems to be a path but is not a directory"; fi if [ ! -d "${PACKAGE_LIST[i]}" ]; then termux_error_exit "'${PACKAGE_LIST[i]}' seems to be a path but is not a directory"; fi
export TERMUX_PKG_BUILDER_DIR export TERMUX_PKG_BUILDER_DIR=$(realpath "${PACKAGE_LIST[i]}")
TERMUX_PKG_BUILDER_DIR=$(realpath "${PACKAGE_LIST[i]}")
else else
# Package name: # Package name:
if [ -d "${TERMUX_SCRIPTDIR}/main/${TERMUX_PKG_NAME}" ]; then for package_directory in $TERMUX_PACKAGES_DIRECTORIES; do
export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/main/$TERMUX_PKG_NAME if [ -d "${TERMUX_SCRIPTDIR}/${package_directory}/${TERMUX_PKG_NAME}" ]; then
elif [ -d "${TERMUX_SCRIPTDIR}/x11/${TERMUX_PKG_NAME}" ]; then export TERMUX_PKG_BUILDER_DIR=${TERMUX_SCRIPTDIR}/$package_directory/$TERMUX_PKG_NAME
export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/x11/$TERMUX_PKG_NAME break
elif [ -d "${TERMUX_SCRIPTDIR}/root/${TERMUX_PKG_NAME}" ]; then elif [ -n "${TERMUX_IS_DISABLED=""}" ] && [ -d "${TERMUX_SCRIPTDIR}/disabled-packages/${TERMUX_PKG_NAME}"]; then
export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/root/$TERMUX_PKG_NAME export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/disabled-packages/$TERMUX_PKG_NAME
elif [ -n "${TERMUX_IS_DISABLED=""}" ] && [ -d "${TERMUX_SCRIPTDIR}/disabled/${TERMUX_PKG_NAME}"]; then break
export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/disabled/$TERMUX_PKG_NAME fi
else done
termux_error_exit "No package $TERMUX_PKG_NAME found in any of the enabled repositories, if you are trying to set up your custom repository give a look at build-package.sh:460-470" if [ -z "${TERMUX_PKG_BUILDER_DIR}" ]; then
termux_error_exit "No package $TERMUX_PKG_NAME found in any of the enabled repositories. Are you trying to set up a custom repository?"
fi fi
fi fi
TERMUX_PKG_BUILDER_SCRIPT=$TERMUX_PKG_BUILDER_DIR/build.sh TERMUX_PKG_BUILDER_SCRIPT=$TERMUX_PKG_BUILDER_DIR/build.sh

5
repo.json Normal file
View File

@ -0,0 +1,5 @@
{
"packages": "termux-main",
"root-packages": "termux-root",
"x11-packages": "termux-x11"
}

View File

@ -7,7 +7,6 @@ termux_step_setup_variables() {
: "${TERMUX_INSTALL_DEPS:="false"}" : "${TERMUX_INSTALL_DEPS:="false"}"
: "${TERMUX_MAKE_PROCESSES:="$(nproc)"}" : "${TERMUX_MAKE_PROCESSES:="$(nproc)"}"
: "${TERMUX_NO_CLEAN:="false"}" : "${TERMUX_NO_CLEAN:="false"}"
: "${TERMUX_PACKAGES_DIRECTORIES:="main x11 root"}"
: "${TERMUX_PKG_API_LEVEL:="24"}" : "${TERMUX_PKG_API_LEVEL:="24"}"
: "${TERMUX_CONTINUE_BUILD:="false"}" : "${TERMUX_CONTINUE_BUILD:="false"}"
: "${TERMUX_QUIET_BUILD:="false"}" : "${TERMUX_QUIET_BUILD:="false"}"

View File

@ -86,7 +86,7 @@ termux_step_start_build() {
local TERMUX_ELF_CLEANER_SRC=$TERMUX_COMMON_CACHEDIR/termux-elf-cleaner.cpp local TERMUX_ELF_CLEANER_SRC=$TERMUX_COMMON_CACHEDIR/termux-elf-cleaner.cpp
local TERMUX_ELF_CLEANER_VERSION local TERMUX_ELF_CLEANER_VERSION
TERMUX_ELF_CLEANER_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/main/termux-elf-cleaner/build.sh; echo \$TERMUX_PKG_VERSION") TERMUX_ELF_CLEANER_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/termux-elf-cleaner/build.sh; echo \$TERMUX_PKG_VERSION")
termux_download \ termux_download \
"https://raw.githubusercontent.com/termux/termux-elf-cleaner/v$TERMUX_ELF_CLEANER_VERSION/termux-elf-cleaner.cpp" \ "https://raw.githubusercontent.com/termux/termux-elf-cleaner/v$TERMUX_ELF_CLEANER_VERSION/termux-elf-cleaner.cpp" \
"$TERMUX_ELF_CLEANER_SRC" \ "$TERMUX_ELF_CLEANER_SRC" \

View File

@ -59,48 +59,50 @@ rm -rf "${TERMUX_PKG_TMPDIR}"
) )
# Package sources. # Package sources.
for p in "$TERMUX_SCRIPTDIR"/{main,x11,root}/*; 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 (
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_step_get_source.sh . "$TERMUX_SCRIPTDIR"/scripts/properties.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_git_clone_src.sh . "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_step_get_source.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_download_src_archive.sh . "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_git_clone_src.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_unpack_src_archive.sh . "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_download_src_archive.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_unpack_src_archive.sh
# Disable archive extraction in termux_step_get_source.sh.
termux_extract_src_archive() { # Disable archive extraction in termux_step_get_source.sh.
: termux_extract_src_archive() {
} :
}
TERMUX_PKG_NAME=$(basename "$p")
TERMUX_PKG_BUILDER_DIR="${p}" TERMUX_PKG_NAME=$(basename "$p")
TERMUX_PKG_CACHEDIR="${p}/cache" TERMUX_PKG_BUILDER_DIR="${p}"
TERMUX_PKG_METAPACKAGE=false TERMUX_PKG_CACHEDIR="${p}/cache"
TERMUX_PKG_METAPACKAGE=false
# Set some variables to dummy values to avoid errors.
TERMUX_PKG_TMPDIR="${TERMUX_PKG_CACHEDIR}/.tmp" # Set some variables to dummy values to avoid errors.
TERMUX_PKG_SRCDIR="${TERMUX_PKG_CACHEDIR}/.src" TERMUX_PKG_TMPDIR="${TERMUX_PKG_CACHEDIR}/.tmp"
TERMUX_PKG_BUILDDIR="$TERMUX_PKG_SRCDIR" TERMUX_PKG_SRCDIR="${TERMUX_PKG_CACHEDIR}/.src"
TERMUX_PKG_HOSTBUILD_DIR=$TERMUX_PKG_TMPDIR TERMUX_PKG_BUILDDIR="$TERMUX_PKG_SRCDIR"
TERMUX_HOST_PLATFORM=aarch64-linux-android TERMUX_PKG_HOSTBUILD_DIR=$TERMUX_PKG_TMPDIR
TERMUX_ARCH_BITS=64 TERMUX_HOST_PLATFORM=aarch64-linux-android
TERMUX_BUILD_TUPLE=x86_64-pc-linux-gnu TERMUX_ARCH_BITS=64
TERMUX_PKG_GIT_BRANCH="" TERMUX_BUILD_TUPLE=x86_64-pc-linux-gnu
TERMUX_DEBUG_BUILD=false TERMUX_PKG_GIT_BRANCH=""
TERMUX_MAKE_PROCESSES=1 TERMUX_DEBUG_BUILD=false
TERMUX_MAKE_PROCESSES=1
mkdir -p "$TERMUX_PKG_CACHEDIR" "$TERMUX_PKG_TMPDIR" "$TERMUX_PKG_SRCDIR"
cd "$TERMUX_PKG_CACHEDIR" mkdir -p "$TERMUX_PKG_CACHEDIR" "$TERMUX_PKG_TMPDIR" "$TERMUX_PKG_SRCDIR"
cd "$TERMUX_PKG_CACHEDIR"
. "${p}"/build.sh || true
if ! ${TERMUX_PKG_METAPACKAGE}; then . "${p}"/build.sh || true
echo "Downloading sources for '$TERMUX_PKG_NAME'..." if ! ${TERMUX_PKG_METAPACKAGE}; then
termux_step_get_source echo "Downloading sources for '$TERMUX_PKG_NAME'..."
termux_step_get_source
# Delete dummy src and tmp directories.
rm -rf "$TERMUX_PKG_TMPDIR" "$TERMUX_PKG_SRCDIR" # Delete dummy src and tmp directories.
fi rm -rf "$TERMUX_PKG_TMPDIR" "$TERMUX_PKG_SRCDIR"
) fi
)
done
done done
# Mark to tell build-package.sh to enable offline mode. # Mark to tell build-package.sh to enable offline mode.