-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhance(scripts/generate-bootstraps.sh): add caching support #11491
base: master
Are you sure you want to change the base?
Conversation
5297acc
to
60a4818
Compare
60a4818
to
50e1526
Compare
a897335
to
d34339b
Compare
* format the script too
d34339b
to
5367b1d
Compare
Will merge this soon if no objection If we do enable caching in generate bootstrap ci, we should be able to cut down fetching the same
which should save |
After months of commits, are you sure you are done? ;) It's a good idea to cache for people who have space, so thanks. But there are changes required. |
# Optional caching of downloaded packages in output directory | ||
# Apt only for now | ||
TERMUX_PACKAGE_DOWNLOAD_CACHE=false | ||
TERMUX_PACKAGE_DOWNLOAD_CACHE_DIR="$PWD/output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be named cache
instead of output
.
The TERMUX_PACKAGE_DOWNLOAD_CACHE_DIR
does not include TERMUX_APP_PACKAGE
, which will result in mixing of packages with different prefixes if cache dir is not cleaned manually if repo url is changed.
Moreover, the generate-bootstrap.sh
script is not checking if TERMUX_REPO_PACKAGE
equals TERMUX_APP_PACKAGE
. It would be better to replace REPO_BASE_URLS
and -r
format to <package_name>:<repo_url>
so that caching is correctly done as you want.
termux-packages/scripts/properties.sh
Lines 35 to 38 in 8e8b1a4
# Package name for the packages hosted on the repo. | |
# This must only equal TERMUX_APP_PACKAGE if using custom repo that | |
# has packages that were built with same package name. | |
TERMUX_REPO_PACKAGE="com.termux" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also consider adding a --clean-cache-dir
option which clears the cache dir for TERMUX_APP_PACKAGE
and redownloads the packages.
package_url="$REPO_BASE_URL/$(echo "${PACKAGE_METADATA[${package_name}]}" | grep -i "^Filename:" | awk '{ print $2 }')" | ||
package_file=$(echo "$package_url" | sed -e 's|\(.*\)\/\(.*\).deb$|\2.deb|') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using basename
should work fine.
@@ -295,6 +322,11 @@ show_usage() { | |||
echo " Multiple packages should be passed as" | |||
echo " comma-separated list." | |||
echo | |||
echo " -c, --cache [DIR] Enable caching. Downloaded package files will be" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally separate parameters should be used for enabling cache and passing custom cache dir in case other options need to be added in future, like -c/--cache
and --cache-dir
.
@@ -382,23 +421,38 @@ while (($# > 0)); do | |||
done | |||
|
|||
if [[ "$TERMUX_PACKAGE_MANAGER" == *" "* ]] || [[ " ${TERMUX_PACKAGE_MANAGERS[*]} " != *" $TERMUX_PACKAGE_MANAGER "* ]]; then | |||
echo "[!] Invalid package manager '$TERMUX_PACKAGE_MANAGER'" 1>&2 | |||
echo "Supported package managers: '${TERMUX_PACKAGE_MANAGERS[*]}'" 1>&2 | |||
echo "[!] Invalid package manager '$TERMUX_PACKAGE_MANAGER'" >&2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific need to remove 1
here and other places. Current way makes it explicitly clear what is being redirected to what. Will also require changes in build-bootstrap.sh
if you do.
for package_arch in "${TERMUX_ARCHITECTURES[@]}"; do | ||
BOOTSTRAP_ROOTFS="$BOOTSTRAP_TMPDIR/rootfs-${package_arch}" | ||
BOOTSTRAP_PKGDIR="$BOOTSTRAP_TMPDIR/packages-${package_arch}" | ||
|
||
# Create initial directories for $TERMUX_PREFIX | ||
if ! ${BOOTSTRAP_ANDROID10_COMPATIBLE}; then | ||
if [ ${TERMUX_PACKAGE_MANAGER} = "apt" ]; then | ||
if [ "$TERMUX_PACKAGE_MANAGER" = apt ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remove double quotes. apt
is a string and not a keyword. It's convention to always use double quotes around variables and strings.
https://google.github.io/styleguide/shellguide.html#testing-strings
@@ -144,10 +150,31 @@ pull_package() { | |||
unset dep | |||
fi | |||
|
|||
if [ "$TERMUX_PACKAGE_DOWNLOAD_CACHE" = true ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rm -f "$package_tmpdir/package.deb"
should be moved before this. Shouldn't attempt to use any existing deb file at location, unless a valid cached one is linked to it.
This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is this still relevant/in progress? There are unresolved reviews and the branch is out of date. |
Since
build-bootstraps.sh
is out of commission and pending a rewrite (#10462 (comment)), I decided to just improvegenerate-bootstraps.sh
which already does not include extra packages when generating bootstraps to begin with.With the optional caching turned on, it gained a tiny bit of speed up.
Time lost most of which is spend on downloading the same
*_all.deb
files again thrice.But subsequent runs will show massive speed up since files are stored and cached.
With caching also allows building for custom arches.
For my arm vfpv3-d16 project, I can imagine triggering multiple parallel CI running
./scripts/run-docker.sh ./build-package.sh -a arm one-bootstrap-package-per-CI
and then pass all deb files to
./scripts/run-docker.sh ./scripts/generate-bootstraps.sh -c --architectures arm
for processing and not rely on
build-bootstraps.sh
anymore...Note that file lists are not cached.