这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@agnostic-apollo
Copy link
Member

Related pull termux/termux-exec-package#24

DO NOT MERGE UNTIL CHANGES HAVE BEEN MERGED WITH termux-exec MASTER

@agnostic-apollo agnostic-apollo force-pushed the termux-constants-and-exec branch 2 times, most recently from 87d9faa to b12bdb3 Compare December 31, 2023 23:36
@agnostic-apollo agnostic-apollo force-pushed the termux-constants-and-exec branch from b12bdb3 to db3ef28 Compare January 4, 2024 04:37
agnostic-apollo pushed a commit to t184256/termux-tools that referenced this pull request Aug 13, 2024
…AGE@`

TODO when termux/termux-packages#18872 gets merged:
- Replace `@TERMUX_APP_PACKAGE@/@TERMUX_APP_PACKAGE@.app.*` with respective component name variables.
- Replace `com.termux.termuxam.Am` with `TERMUX_AM__AM_CLASS__CLASS_NAME`.
agnostic-apollo pushed a commit to termux/termux-tools that referenced this pull request Aug 13, 2024
…AGE@`

TODO when termux/termux-packages#18872 gets merged:
- Replace `@TERMUX_APP_PACKAGE@/@TERMUX_APP_PACKAGE@.app.*` with respective component name variables.
- Replace `com.termux.termuxam.Am` with `TERMUX_AM__AM_CLASS__CLASS_NAME`.
@agnostic-apollo agnostic-apollo force-pushed the termux-constants-and-exec branch from db3ef28 to 9dde787 Compare December 20, 2024 20:55
@agnostic-apollo agnostic-apollo force-pushed the termux-constants-and-exec branch 2 times, most recently from c6e89df to f60666c Compare December 20, 2024 22:39
for variable_name in TERMUX__PREFIX TERMUX_APP__DATA_DIR CGCT_DIR; do
variable_value="${!variable_name:-}"
if [[ ! "$variable_value" =~ ^(/[^/]+)+$ ]]; then
echo "The $variable_name '$variable_value' is not an absolute path under rootfs '/' while running 'clean.sh'." 1>&2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these two could use a rename.
And probably also a comment because I just had to reference the man page to remember that ${!var} is an indirection, not a key lookup (${!arr[i]}).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which two and comment what? ${!var} is pretty common and loop items are clearly variable names anyways being expanded to a value.

@agnostic-apollo agnostic-apollo force-pushed the termux-constants-and-exec branch 3 times, most recently from 3f2bff4 to 34a804f Compare December 20, 2024 23:52
@agnostic-apollo
Copy link
Member Author

The libllvm package is getting built including all packages being built with DOCKER_BUILD=false because of a patch file changed in c86229d, but it does not change the build.sh file to build the package. The /built_${repo}_packages.txt logic does not check which file got changed.

elif [[ $file =~ ^${repo_path}/([.a-z0-9+-]*)/.*$ ]]; then
# package, check if it was deleted or updated
pkg=${BASH_REMATCH[1]}
if [ -d "${repo_path}/${pkg}" ]; then
echo "$pkg" >> ./built_${repo}_packages.txt
# If there are subpackages we want to create a list of those
# as well
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
done
else
echo "$pkg" >> ./deleted_${repo}_packages
fi
fi

@agnostic-apollo agnostic-apollo changed the title bump(main/termux-exec): 2.0.0 bump|addpkg(main/{termux-core,termux-exec,tudo,sudo}) Dec 21, 2024
@agnostic-apollo agnostic-apollo force-pushed the termux-constants-and-exec branch 9 times, most recently from a02f745 to 5c94e60 Compare December 22, 2024 09:45
@agnostic-apollo
Copy link
Member Author

I have removed the c86229d commit so that libllvm and android-tools packages do not get built as they take too long, will add them later, testers can use debs from https://github.com/termux/termux-packages/actions/runs/12440122067?pr=18872 run.

The termux-core, termux-exec, tudo and sudo packages can be tested now from the https://github.com/termux/termux-packages/actions/runs/12453170903?pr=18872 run.

…directory set in `$TERMUX_PKG_SRCURL` if its in the format `file:///path/to/source/dir`

The `/path/to/source/dir` must be an absolute and normalized path to a source directory on the local file system.

Whatever was the current state of the local source directory when build was started, that is what will be built, without any changes to any `git` branches/tags. Any uncommitted changes to current `git` branch will also get built. Any value for `TERMUX_PKG_GIT_BRANCH` in the `build.sh` of the package will be ignored since a `tar` file will be created from the source directory and it will be used as is. No checksum checks like one set in `$TERMUX_PKG_SHA256` will be done, and a tar for source directory will be created every time package is built, assuming `-f/-F` flags are passed for rebuilds, and the `-r` flag (to be added later) will not be required.

Note that to build from a local git repo, the `git+file:///path/to/source` format must be used with the `git+` prefix.
…in `$TERMUX_PKG_SRCURL` if its in the format `git+file:///path/to/source/git/dir`

This got broken a while ago due to changes in pulling sources, although current format wasn't mandated.

The `$TERMUX_PKG_SRCURL` must start with `git+` prefix like already used for other git `http` urls, followed by a `file://` url, where `/path/to/source/git/dir` is an absolute and normalized path to a source git directory on the local file system, with a `.git` sub directory.

If the source directory has been cloned already in a previous build, then it will NOT be cloned again if `-f/-F` flags are passed for rebuilds, and the `-r` flag (to be added later) will be required to clone latest sources again/every time.

Any uncommitted changes to `git` branch will NOT get built.

An additional requirement is that the local git repository must have its `origin` url in `.git/config` as a `https` URL instead of a `ssh` (`git@`) URL if running in termux-packages docker container and `$TERMUX_PKG_GIT_BRANCH` is set, as it doesn't have `ssh` installed by default and `git fetch` would fail otherwise. So if local git repository needs to be cloned from an upstream git url itself, like GitHub, then use `https://github.com/org/repo.git` to clone instead of `git@github.com:org/repo.git`. Or you can install `ssh` inside docker and set up ssh keys manually.
…UILD__RM_ALL_PKGS_BUILT_MARKER_AND_INSTALL_FILES`
…ocess if `-a all` is passed

The `${parameter+word}` expansion will substitute word if "parameter is Set and Not Null" and also if "parameter is Set But Null". So if a variable is unset, or if set to any random value or empty string, even if its "false", then the flag will get passed.

For example running `TERMUX_DEBUG_BUILD= ./build-package.sh -I -f -r -a all termux-tools` or `TERMUX_DEBUG_BUILD=false ./build-package.sh -I -f -r -a all termux-tools` will pass the `-f` flag, even though it should not be. Ideally, command option variables should set to their default values before command options are parsed.

Additionally, the `${parameter:=word}` expansion will assign the word to the variable itself if "parameter is Set But Null" or "parameter is Unset", instead of just substituting temporarily, which would then cause potential problems when default value is to be set to the variables later in "current" build-package.sh process depending on some variable dependent logic, as variables would already be set. The "sub" build-package.sh process should not be passed `debian` and `bionic` as defaults, it should set its own default variables.

Also pass the `-i` and `-I` flag appropriately depending on what was originally passed instead of always passing the `-i` flag if `$TERMUX_INSTALL_DEPS` is set (to whatever), which would wipe TERMUX_PREFIX and built-packages dir.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
…dependent directories that `-f/-F` flags alone would not remove

This includes the package cache directory (`$TERMUX_PKG_CACHEDIR`) containing package sources and host build directory (`$TERMUX_PKG_HOSTBUILD_DIR`). The `-r` flag is ignored if `-f/-F` flags are not passed.

With `-f/-F` flags alone, latest package sources will not be re-downloaded on rebuilds if `$TERMUX_PKG_SRCURL` refers to `git+` URL, i.e for a branch (like `master`) that's being continuously updated on a remote git repository (`git+https://`) or in a local git repository directory (`git+file://`).
…` for checking built packages and quote variables for all related functions
…cond stage has already been run before" error if `ln` process used to create lock file got killed instead of failing to create lock file if it already existed

Related termux/termux-app#4219
…it could be a different path than `/data` that is critical for build host like Termux docker

Either delete entire `TERMUX_APP__DATA_DIR` if `TERMUX__PREFIX` directory exists under it, or only delete `TERMUX__PREFIX` directory itself if it exists outside it.
…ermux_step_elf_cleaner` for packages to hook into

Packages may not want specific elf files to be stripped, like for debug `-g` test binaries, or may have elf files under different non-standard directories.
…function to file and provide `termux_step_create_debscripts__copy_from_dir()` for packages to copy debscripts from a custom directory into the current `DEBIAN` working directory

For example:

```shell
termux_step_create_debscripts() {
	termux_step_create_debscripts__copy_from_dir "$TERMUX_PKG_SRCDIR/build/output/packaging/debian" .
}
```
…for `output` and `debs/built_${repo}_packages.txt`
… variables

The `package` and `package_recipes` bash indexed array being used are using the `$var` expansion like `$packages` in the for loop while adding additional values, which will only expand to the first value of the array.

Global arrays must always be unset with `=()` on initialization as `declare -a` alone will not unset them and old values with remain in case array variable is reused for a different logic.

Package names should not be used in regexes without escaping them as they can contain special characters like `.`. Use fixed string line match `-Fx` with `grep` instead.
…ath for setting ownership of `TERMUX__PREFIX` and create `TERMUX_APP__DATA_DIR` as well in case `TERMUX__PREFIX` is not under it

Ownership of `TERMUX__PREFIX` must be fixed before `TERMUX_APP__DATA_DIR` if its under it, otherwise `TERMUX__ROOTFS` will not have its ownership fixed and following error would occur during package dependency extraction.

`tar: data/data/com.termux/files: Cannot change mode to rwxr-xr-x: Operation not permitted`
…chy 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.
@agnostic-apollo agnostic-apollo force-pushed the termux-constants-and-exec branch from ae953b1 to 8a03e33 Compare March 22, 2025 00:50
@agnostic-apollo agnostic-apollo merged commit 8a03e33 into master Mar 22, 2025
9 checks passed
@Grimler91 Grimler91 deleted the termux-constants-and-exec branch March 23, 2025 11:25
robertkirkman added a commit to robertkirkman/termux-generator that referenced this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants