Skip to content

Commit a196f15

Browse files
committed
Merge remote-tracking branch 'termux/master'
2 parents bf8105c + 1694d07 commit a196f15

1,524 files changed

Lines changed: 83473 additions & 8241 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/zram/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ runs:
7373
sudo cp scripts/zram.ko.zst ${{ steps.kernel-info.outputs.modules_dir }}/kernel/
7474
sudo depmod
7575
sudo modprobe zram
76-
sudo zramctl ${{ inputs.device_name }} --algorithm ${{ inputs.algorithm }} --size ${{ inputs.size }}
76+
set +e
77+
sudo swapoff ${{ inputs.device_name }} || true
78+
sudo zramctl --reset ${{ inputs.device_name }} || true
79+
set -e
80+
sudo zramctl --find --algorithm ${{ inputs.algorithm }} --size ${{ inputs.size }}
7781
sudo mkswap -U clear ${{ inputs.device_name }}
7882
sudo swapon --discard --priority ${{ inputs.priority }} ${{ inputs.device_name }}
7983

.github/workflows/docker_image.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,52 @@ jobs:
3333
steps:
3434
- name: Clone repository
3535
uses: actions/checkout@v6
36+
37+
# Skip building the Docker image on scheduled runs if the last successful
38+
# image build (the one tagged "latest") is less than IMAGE_MIN_INTERVAL_DAYS old.
39+
- name: Optionally skip building image
40+
if: github.event_name == 'schedule'
41+
id: skip-build
42+
env:
43+
IMAGE_MIN_INTERVAL_DAYS: 30
44+
run: |
45+
LAST_TIMESTAMP=$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
46+
-H "Accept: application/vnd.github+json" \
47+
"https://api.github.com/users/termux/packages/container/package-builder/versions" |
48+
jq --raw-output 'map(select(.metadata.container.tags | contains(["latest"])))[0].created_at')
49+
LAST_UNIX_TIME=$(date -d "$LAST_TIMESTAMP" +%s)
50+
CURRENT_UNIX_TIME=$(date +%s)
51+
if (( "$CURRENT_UNIX_TIME" - "$LAST_UNIX_TIME" < $IMAGE_MIN_INTERVAL_DAYS*24*60*60 )); then
52+
echo "Skipping building Docker image: last successful build was done on $LAST_TIMESTAMP (< $IMAGE_MIN_INTERVAL_DAYS days)"
53+
echo "skip-build=true" >> "$GITHUB_OUTPUT"
54+
fi
55+
3656
- name: Build
57+
if: ${{ steps.skip-build.outputs.skip-build != 'true' }}
3758
run: |
3859
docker build --tag termux/package-builder:latest scripts/
3960
docker tag termux/package-builder:latest ghcr.io/termux/package-builder:latest
4061
- name: Build (CGCT)
62+
if: ${{ steps.skip-build.outputs.skip-build != 'true' }}
4163
run: |
4264
docker build --tag termux/package-builder-cgct:latest --file scripts/Dockerfile.cgct scripts/
4365
docker tag termux/package-builder-cgct:latest ghcr.io/termux/package-builder-cgct:latest
4466
- name: Login to GHCR
45-
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-packages'
67+
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-packages' && steps.skip-build.outputs.skip-build != 'true'
68+
4669
uses: docker/login-action@v3
4770
with:
4871
registry: ghcr.io
4972
username: ${{ github.actor }}
5073
password: ${{ secrets.GITHUB_TOKEN }}
5174
- name: Login to Docker Hub
52-
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-packages'
75+
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-packages' && steps.skip-build.outputs.skip-build != 'true'
5376
uses: docker/login-action@v3
5477
with:
5578
username: grimler
5679
password: ${{ secrets.DOCKER_TOKEN }}
5780
- name: Push
58-
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-packages'
81+
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'termux/termux-packages' && steps.skip-build.outputs.skip-build != 'true'
5982
run: |
6083
# ghcr.io seem to be unstable sometimes. It may suddenly drop connection
6184
# during docker push when some layers are already uploaded. The workaround

.github/workflows/golang_validation.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,18 @@ jobs:
4343
uses: actions/checkout@v6
4444
with:
4545
fetch-depth: 1
46-
- name: Set process id limit for 32-bit builds depending on aosp-libs
47-
run: echo 65535 | sudo tee /proc/sys/kernel/pid_max
4846
- name: Enable zram
49-
if: ${{ steps.build-info.outputs.skip-building != 'true' }}
5047
uses: ./.github/actions/zram
5148
with:
5249
algorithm: zstd
5350
size: 16G
5451
priority: 100
5552
device_name: /dev/zram0
56-
- name: Prepare environment
53+
- name: Load Docker image
54+
run: |
55+
./scripts/run-docker.sh true
56+
- name: Free additional disk space
5757
run: |
58-
./scripts/setup-ubuntu.sh
59-
./scripts/setup-android-sdk.sh
60-
sudo apt install ninja-build
6158
./scripts/free-space.sh
6259
- name: Golang validation
6360
run: ./scripts/bin/validation ${{ matrix.target_arch }} golang ${{ matrix.batch }} || exit 1

.github/workflows/package_updates.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,29 @@ jobs:
104104
with:
105105
fetch-depth: 0
106106
token: ${{ secrets.TERMUXBOT2_TOKEN }}
107-
- name: Set process id limit for 32-bit builds depending on aosp-libs
108-
run: echo 65535 | sudo tee /proc/sys/kernel/pid_max
109107
- name: Enable zram
110108
uses: ./.github/actions/zram
111109
with:
112110
algorithm: zstd
113111
size: 16G
114112
priority: 100
115113
device_name: /dev/zram0
114+
- name: Load Docker image
115+
run: |
116+
./scripts/run-docker.sh true
116117
- name: Free additional disk space
117-
run: CLEAN_DOCKER_IMAGES=false ./scripts/free-space.sh
118+
run: ./scripts/free-space.sh
119+
- name: Install needed dependencies for package updates
120+
run: |
121+
sudo apt-get update
122+
sudo apt-get install -y --no-install-recommends \
123+
curl \
124+
python3 \
125+
jq
118126
- name: Process package updates
119127
env:
120128
GITHUB_TOKEN: ${{ secrets.TERMUXBOT2_TOKEN }}
121129
BUILD_PACKAGES: "true"
122-
TERMUX_DOCKER__CONTAINER_EXEC_COMMAND__PRE_CHECK_IF_WILL_BUILD_PACKAGES: "true"
123130
CREATE_ISSUE: "true"
124131
GIT_COMMIT_PACKAGES: "true"
125132
GIT_PUSH_PACKAGES: "true"

.github/workflows/packages.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
packages:
2020
description: "A space-separated names of packages selected for rebuilding"
2121
required: true
22+
free-space:
23+
description: "Free space even if not building large package (useful when building a large number of packages)"
24+
type: boolean
25+
default: false
2226

2327
permissions: {} # none
2428

@@ -42,8 +46,6 @@ jobs:
4246
uses: actions/checkout@v6
4347
with:
4448
fetch-depth: 1000
45-
- name: Set process id limit for 32-bit builds depending on aosp-libs
46-
run: echo 65535 | sudo tee /proc/sys/kernel/pid_max
4749

4850
- name: Gather build summary
4951
id: build-info
@@ -97,7 +99,6 @@ jobs:
9799
# Forces CI to cancel current build with status 'passed'
98100
if grep -qiP '^\s*%ci:no-build\s*$' <(git log --format="%B" -n 1 --no-merges "HEAD"); then
99101
tar cf artifacts/debs-${{ matrix.target_arch }}.tar debs
100-
echo "docker-build=true" >> $GITHUB_OUTPUT
101102
echo "[!] Force exiting as tag '%ci:no-build' was applied to HEAD commit message."
102103
exit 0
103104
fi
@@ -185,31 +186,33 @@ jobs:
185186
186187
echo "packages: ${packages[*]}"
187188
188-
docker='true'
189+
free_space='false'
190+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
191+
free_space=${{ github.event.inputs.free-space }}
192+
else
193+
if grep -qiP '^\s*%ci:free-disk\s*$' <(git log --format="%B" -n 1 --no-merges "HEAD"); then
194+
free_space=true
195+
fi
196+
fi
189197
if [[ "${#packages[@]}" -gt 0 ]]; then
190198
for pkg in "${packages[@]}"; do
191199
if grep -qFx "$pkg" ./scripts/big-pkgs.list; then
192-
docker='false'
200+
free_space='true'
193201
break
194202
fi
195203
done
196204
fi
205+
echo "free-space=$free_space" >> $GITHUB_OUTPUT
197206
198-
echo "docker-build=$docker" >> $GITHUB_OUTPUT
207+
needs_docker_build=false
199208
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
200209
# Build local Docker image if setup scripts were changed.
201210
# Useful for pull requests submitting changes for both build environment and packages.
202211
if grep -qP '^scripts/(Dockerfile|properties\.sh|setup-android-sdk\.sh|setup-ubuntu\.sh)$' <<< "$CHANGED_FILES"; then
203-
echo "Detected changes for environment setup scripts. Building custom Docker image now."
204-
if [ $docker == 'false' ]; then
205-
echo "Skipping due to building large packages."
206-
exit 0
207-
fi
208-
cd ./scripts
209-
docker build -t ghcr.io/termux/package-builder:latest .
210-
cd ..
212+
needs_docker_build=true
211213
fi
212214
fi
215+
echo "needs-docker-build=$needs_docker_build" >> $GITHUB_OUTPUT
213216
214217
- name: Lint packages
215218
run: |
@@ -234,22 +237,24 @@ jobs:
234237
priority: 100
235238
device_name: /dev/zram0
236239

240+
- name: Build docker image
241+
if: ${{ steps.build-info.outputs.needs-docker-build == 'true' }}
242+
run: |
243+
docker build -t ghcr.io/termux/package-builder:latest scripts/
244+
docker buildx prune -af
245+
246+
- name: Load Docker image
247+
if: ${{ steps.build-info.outputs.free-space == 'true' && steps.build-info.outputs.skip-building != 'true' }}
248+
run: |
249+
./scripts/run-docker.sh true
250+
237251
- name: Free additional disk space (if needed)
238-
if: ${{ steps.build-info.outputs.docker-build == 'false' && steps.build-info.outputs.skip-building != 'true' }}
252+
if: ${{ steps.build-info.outputs.free-space == 'true' && steps.build-info.outputs.skip-building != 'true' }}
239253
run: |
240-
./scripts/setup-ubuntu.sh
241-
# need to unset these for setup-android-sdk.sh.
242-
unset NDK ANDROID_HOME
243-
./scripts/setup-android-sdk.sh
244-
rm -f ${HOME}/lib/ndk-*.zip ${HOME}/lib/sdk-*.zip
245-
sudo apt install ninja-build
246254
./scripts/free-space.sh
247255
248256
- name: Build packages
249257
if: ${{ steps.build-info.outputs.skip-building != 'true' }}
250-
env:
251-
DOCKER_BUILD: ${{ steps.build-info.outputs.docker-build }}
252-
TERMUX_DOCKER__CONTAINER_EXEC_COMMAND__PRE_CHECK_IF_WILL_BUILD_PACKAGES: "true"
253258
run: |
254259
declare -a packages=()
255260
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
@@ -262,16 +267,7 @@ jobs:
262267
echo "packages: ${packages[*]}"
263268
264269
if [[ "${#packages[@]}" -gt 0 ]]; then
265-
if [ "$DOCKER_BUILD" == 'false' ]; then
266-
# these need to be unset a second time again for ./build-package.sh
267-
# when it is run outside of Docker, because GitHub Actions does not
268-
# support permanently unsetting variables at time of writing.
269-
# https://github.com/actions/runner/issues/1126
270-
unset NDK ANDROID_HOME
271-
./build-package.sh -I -C -a "${{ matrix.target_arch }}" "${packages[@]}"
272-
else
273-
./scripts/run-docker.sh ./build-package.sh -I -C -a "${{ matrix.target_arch }}" "${packages[@]}"
274-
fi
270+
./scripts/run-docker.sh -d ./build-package.sh -I -C -a "${{ matrix.target_arch }}" "${packages[@]}"
275271
fi
276272
277273
- name: Generate build artifacts
@@ -316,6 +312,10 @@ jobs:
316312
with:
317313
name: debs-${{ matrix.target_arch }}-${{ github.sha }}
318314
path: ./artifacts
315+
- name: AppArmor Logs
316+
if: always()
317+
run: |
318+
sudo dmesg | grep apparmor
319319
320320
test-buildorder-random:
321321
permissions:

.github/workflows/zig_validation.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,18 @@ jobs:
4343
uses: actions/checkout@v6
4444
with:
4545
fetch-depth: 1
46-
- name: Set process id limit for 32-bit builds depending on aosp-libs
47-
run: echo 65535 | sudo tee /proc/sys/kernel/pid_max
4846
- name: Enable zram
49-
if: ${{ steps.build-info.outputs.skip-building != 'true' }}
5047
uses: ./.github/actions/zram
5148
with:
5249
algorithm: zstd
5350
size: 16G
5451
priority: 100
5552
device_name: /dev/zram0
56-
- name: Prepare environment
53+
- name: Load Docker image
54+
run: |
55+
./scripts/run-docker.sh true
56+
- name: Free additional disk space
5757
run: |
58-
./scripts/setup-ubuntu.sh
59-
./scripts/setup-android-sdk.sh
6058
./scripts/free-space.sh
6159
- name: Zig validation
6260
run: ./scripts/bin/validation ${{ matrix.target_arch }} zig ${{ matrix.batch }} || exit 1

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ Session.vim
66
.netrwhist
77
*~
88

9-
# Vagrant
10-
scripts/.vagrant/
11-
129
# Logs
1310
scripts/*.log
1411
/*.log

CODEOWNERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
/scripts/ @Grimler91 @thunder-coding
1616
/repo.json @Grimler91 @thunder-coding
1717

18+
# Docker security profiles
19+
/scripts/profile.json @thunder-coding @licy183
20+
/scripts/*.apparmor @thunder-coding
21+
1822
# Build script linter
1923
/scripts/lint-packages.sh @TomJo2000
2024

@@ -28,6 +32,10 @@
2832
# Nodejs setup script
2933
/scripts/build/setup/termux_setup_nodejs.sh @thunder-coding
3034

35+
# Python setup scripts
36+
/scripts/build/setup/termux_setup_python_pip.sh @thunder-coding
37+
/scripts/build/setup/termux_setup_build_python.sh @thunder-coding
38+
3139
# Packages owned by @finagolfin
3240
/packages/libdispatch/ @finagolfin
3341
/packages/libllvm/ @finagolfin
@@ -84,6 +92,7 @@
8492
/packages/nodejs/ @thunder-coding
8593
/packages/nodejs-lts/ @thunder-coding
8694
/packages/npm/ @thunder-coding
95+
/packages/python/ @thunder-coding
8796
/packages/silicon/ @thunder-coding
8897
/packages/slides/ @thunder-coding
8998

build-package.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_ldc.sh"
149149
# shellcheck source=scripts/build/setup/termux_setup_no_integrated_as.sh
150150
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_no_integrated_as.sh"
151151

152+
# Utility function for setting up build-python for cross-compilation of Python and crossenv
153+
# shellcheck source=scripts/build/setup/termux_setup_build_python.sh
154+
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_build_python.sh"
155+
152156
# Utility function for python packages to setup a python.
153157
# shellcheck source=scripts/build/setup/termux_setup_python_pip.sh
154158
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_python_pip.sh"
@@ -656,7 +660,7 @@ for (( i=0; i < ${#PACKAGE_LIST[@]}; i++ )); do
656660
if [[ "$TERMUX_BUILD_IGNORE_LOCK" != "true" ]]; then
657661
flock -n 5 || termux_error_exit "Another build is already running within same environment."
658662
fi
659-
663+
(
660664
# Handle 'all' arch:
661665
if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" && -n "${TERMUX_ARCH+x}" && "${TERMUX_ARCH}" == 'all' ]]; then
662666
_SELF_ARGS=()
@@ -787,6 +791,7 @@ for (( i=0; i < ${#PACKAGE_LIST[@]}; i++ )); do
787791
fi
788792
termux_add_package_to_built_packages_list "$TERMUX_PKG_NAME"
789793
termux_step_finish_build
794+
) 5>&-
790795
) 5< "$TERMUX_BUILD_LOCK_FILE"
791796
done
792797

clean.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,16 @@ fi
9393
rm -Rf "/data/data/.built-packages"
9494
fi
9595

96-
rm -Rf "$TERMUX_TOPDIR"
96+
# unmount overlayfs before we remove the parent directory
97+
[ -d "$TERMUX_TOPDIR" ] && for dir in $(find "$TERMUX_TOPDIR" -type d); do
98+
if mountpoint -q "$dir"; then
99+
umount "$dir"
100+
fi
101+
done
102+
103+
# We can't use rm -Rf "$TERMUX_TOPDIR" in case the "$TERMUX_TOPDIR" is mounted as a Docker volume
104+
if [ -d "$TERMUX_TOPDIR" ]; then
105+
find "$TERMUX_TOPDIR" -type f,l,b,c -delete
106+
find "$TERMUX_TOPDIR" -type d ! -path "$TERMUX_TOPDIR" -delete
107+
fi
97108
} 5< "$TERMUX_BUILD_LOCK_FILE"

0 commit comments

Comments
 (0)