Skip to content

Commit 8a03e33

Browse files
fix(scripts/Dockerfile): create termux-packages repo directory hierarchy under /tmp so that TERMUX_PKGS__BUILD__REPO_ROOT_DIR validation does not fail in properties.sh file and export TERMUX_PKGS__BUILD__IS_DOCKER_BUILD to skip reading repo.json into variables
The `TERMUX_PKGS__BUILD__REPO_ROOT_DIR` validation checks if `scripts/properties.sh` file exists, which wouldn't exist under `scripts` directory if proper hierarchy is not created under `/tmp` directory. Files above the `scripts` directory are not accessible during `cd scripts; docker build`, so `repo.json` cannot be copied to `tmp`, which is read by `properties.sh`. So skip reading its variables until it can be moved to under `scripts` directory in future during docker build.
1 parent 4c916b3 commit 8a03e33

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

scripts/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ FROM ubuntu:24.04
1010
ENV LANG=en_US.UTF-8
1111

1212
# Needed for setup:
13-
COPY ./llvm-snapshot.gpg.key ./properties.sh ./setup-android-sdk.sh ./setup-cgct.sh ./setup-ubuntu.sh /tmp/
14-
RUN mkdir /tmp/build
15-
COPY ./build/termux_download.sh /tmp/build/
13+
RUN rm -rf /tmp/termux-packages
14+
RUN mkdir -p /tmp/termux-packages
15+
RUN mkdir -p /tmp/termux-packages/scripts
16+
COPY ./llvm-snapshot.gpg.key ./properties.sh ./setup-android-sdk.sh ./setup-cgct.sh ./setup-ubuntu.sh /tmp/termux-packages/scripts/
17+
RUN mkdir -p /tmp/termux-packages/scripts/build
18+
COPY ./build/termux_download.sh /tmp/termux-packages/scripts/build/
1619

1720
# Setup needed packages and the Android SDK and NDK and the CGCT:
1821
RUN apt-get update && \
@@ -22,9 +25,9 @@ RUN apt-get update && \
2225
useradd -u 1001 -U -m -s /bin/bash builder && \
2326
echo "builder ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/builder && \
2427
chmod 0440 /etc/sudoers.d/builder && \
25-
chmod a+rx /tmp/*.sh /tmp/build/termux_download.sh && \
26-
su - builder -c /tmp/setup-ubuntu.sh && \
27-
su - builder -c /tmp/setup-android-sdk.sh && \
28+
chmod a+rx /tmp/termux-packages/scripts/*.sh /tmp/termux-packages/scripts/build/termux_download.sh && \
29+
su - builder -c "TERMUX_PKGS__BUILD__IS_DOCKER_BUILD='true' /tmp/termux-packages/scripts/setup-ubuntu.sh" && \
30+
su - builder -c "TERMUX_PKGS__BUILD__IS_DOCKER_BUILD='true' /tmp/termux-packages/scripts/setup-android-sdk.sh" && \
2831
# Removed unused parts to make a smaller Docker image:
2932
apt-get remove -yq --autoremove lsb-release software-properties-common && \
3033
apt-get clean && \

scripts/Dockerfile.cgct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
# This is done after changing this file or any of the
88
# scripts/setup-{ubuntu,android-sdk,cgct}.sh setup scripts.
99
FROM ghcr.io/termux/package-builder
10-
RUN /tmp/setup-cgct.sh
10+
RUN TERMUX_PKGS__BUILD__IS_DOCKER_BUILD='true' /tmp/termux-packages/scripts/setup-cgct.sh

scripts/properties.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,18 +2031,26 @@ TERMUX_REPO_URL=()
20312031
TERMUX_REPO_DISTRIBUTION=()
20322032
TERMUX_REPO_COMPONENT=()
20332033

2034-
export TERMUX_PACKAGES_DIRECTORIES
2035-
TERMUX_PACKAGES_DIRECTORIES=$(jq --raw-output 'del(.pkg_format) | keys | .[]' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json")
2034+
# FIXME: Move `repo.json` file to under `scripts/` directory and COPY it to `/tmp/termux-packages` in `Dockerfile`.
2035+
if [[ ! -f "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json" ]]; then
2036+
if [[ "${TERMUX_PKGS__BUILD__IS_DOCKER_BUILD:-}" != "true" ]]; then
2037+
echo "The 'repo.json' file not found at the '$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json' path." 1>&2
2038+
exit 1
2039+
fi
2040+
else
2041+
export TERMUX_PACKAGES_DIRECTORIES
2042+
TERMUX_PACKAGES_DIRECTORIES=$(jq --raw-output 'del(.pkg_format) | keys | .[]' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json")
20362043

2037-
for url in $(jq -r 'del(.pkg_format) | .[] | .url' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json"); do
2038-
TERMUX_REPO_URL+=("$url")
2039-
done
2040-
for distribution in $(jq -r 'del(.pkg_format) | .[] | .distribution' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json"); do
2041-
TERMUX_REPO_DISTRIBUTION+=("$distribution")
2042-
done
2043-
for component in $(jq -r 'del(.pkg_format) | .[] | .component' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json"); do
2044-
TERMUX_REPO_COMPONENT+=("$component")
2045-
done
2044+
for url in $(jq -r 'del(.pkg_format) | .[] | .url' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json"); do
2045+
TERMUX_REPO_URL+=("$url")
2046+
done
2047+
for distribution in $(jq -r 'del(.pkg_format) | .[] | .distribution' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json"); do
2048+
TERMUX_REPO_DISTRIBUTION+=("$distribution")
2049+
done
2050+
for component in $(jq -r 'del(.pkg_format) | .[] | .component' "$TERMUX_PKGS__BUILD__REPO_ROOT_DIR/repo.json"); do
2051+
TERMUX_REPO_COMPONENT+=("$component")
2052+
done
2053+
fi
20462054

20472055

20482056

0 commit comments

Comments
 (0)