-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
enhance(scripts/lint-packages.sh): optimize handling of version arrays #27095
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/lint-packages.sh): optimize handling of version arrays #27095
Conversation
|
using termux-apt on-device, I can't reproduce the exact error that truboxl saw which is reproducible by the command |
|
Is your on-device clone of the repo up to date? |
yes.
It appears that for some reason, termux-packages/packages/cabal-install/build.sh Lines 27 to 30 in e8a9bb6
|
|
It's probably regex related. |
|
Actually it's a sequencing error. termux-packages/scripts/lint-packages.sh Lines 84 to 95 in e8a9bb6
So we just need to move this block up above the heredoc check. termux-packages/scripts/lint-packages.sh Lines 97 to 101 in e8a9bb6
|
|
Judging from the comment on the heredoc block, this was intentional behavior, however it seems to be unintended as far as expectations are concerned. |
34285ba to
7666aca
Compare
6e4ed53 to
dc0c6d8
Compare
| # Also figure out if we have a `%ci:no-build` trailer in the commit range, | ||
| # we may skip some checks later if yes. | ||
| no_build="$(git log --fixed-strings --grep '%ci:no-build' --pretty=format:%H "$base_commit")" |
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.
I added support for the %ci:no-build commit trailer to the version check.
Looks like this in the output:
TERMUX_PKG_VERSION: SKIP - 3.14.1.1-1 ('%ci:no-build' trailer detected on commit 42942d0)We can also consider a %ci:no-lint trailer, which would probably warrant shuffling this up to the very top of the script.
|
Although, the CI itself doesn't seem to catch |
dc0c6d8 to
c65ef13
Compare
|
You need at least Android 14 to see my reported errors. I test on Android 15. |
|
My device is on Android 15, so I should be able to replicate the issue. |
Thank you, I will begin trying to find a solution. I have created this minimal reproducible example test script as the first step to work on creating a solution: #/usr/bin/env bash
heredoc_regex="[^\(/%#]<{2}-?\s*(['\"]?(\w*(\\\.)?)*['\"]?)"
if [[ "cat << 'EOF'\ntest\nEOF" =~ $heredoc_regex ]]; then
echo "ok" # android 13 reaches here
else
echo "bad" # android 14 reaches here
fiIt seems like the problem might be similar to this other problem that happened in the however, Tomjo2000 might not yet be familiar with the events that occurred in that issue, so maybe linking the issue can help Tomjo2000 understand what is happening. |
|
I have created and tested this change, which appears to work for me, at least I think it does: diff --git a/scripts/lint-packages.sh b/scripts/lint-packages.sh
index a7961d27d3..0e42ec404d 100755
--- a/scripts/lint-packages.sh
+++ b/scripts/lint-packages.sh
@@ -73,7 +73,7 @@ check_indentation() {
local pkg_script="$1"
local line='' heredoc_terminator='' in_array=0 i=0
local -a issues=('' '') bad_lines=('FAILED')
- local heredoc_regex="[^\(/%#]<{2}-?\s*(['\"]?(\w*(\\\.)?)*['\"]?)"
+ local heredoc_regex="[^\(/%#]<{2}-?[[:space:]]*(['\"]?([[:alnum:]_]*(\\\.)?)*['\"]?)"
# We don't wanna hit version constraints "(<< x.y.z)" with this, so don't match "(<<".
# We also wouldn't wanna hit parameter expansions "${var/<<}", ${var%<<}, ${var#<<}
|
|
Interesting. |
that is correct, but actually the original decision was made by the operating system FreeBSD, NetBSD's The upstream changes in NetBSD and FreeBSD seem confusing because they seem like they're adding support for The end result is just what we now observe, |
|
So Android gets its |
It appears that possibly, there may be significant-whitespace in the Heredocs of It appears, for example, that the
which, when combined with the changes in this PR, removes the significant-whitespace and results in an ill-formed There are several possible paths forward:
@MrAdityaAlok what do you think about this problem? |
|
Replacing But we should consider your second option. Languages like |
|
I personally think heredoc semantics are a hassle to deal with in any case, and when indentation matters it's probably best to add an extra file to the package directory. But allowing mixed indentation to account for white space sensitive formats might still be a good idea. |
1f6cc7e to
c1790c1
Compare
Can't quite do that.
We should definitely revisit that if it comes up as an issue in the future. I have previously stated by dislike for heredoc semantics, |
1862209 to
821a438
Compare
…th Android 14+ Upstream changes to `regcomp()`: AOSP - https://android-review.googlesource.com/c/platform/bionic/+/2290937 NetBSD - NetBSD/src@1ee269c FreeBSD - freebsd/freebsd-src@18a1e2e Co-authored-by: Robert Kirkman <rkirkman@termux.dev>
closes termux#27168 Co-authored-by: Robert Kirkman <rkirkman@termux.dev>
…tarting and stopping
c654ca5 to
07754ad
Compare
|
I'm gonna postpone the heredoc mixed indentation thing to another time, it's clearly breaking builds right now and that's something a linter change or linter compliance fix should never do. I'll add a comment to explicitly state that mixed indentation for heredocs is permissible since it's required for Haskell and potentially Nim. |
|
Alright, this is just tested and verified fixes now. I'm sure we'll be back here for another round of linter fixes. |
| fi | ||
|
|
||
| # Was the package modified in this branch? | ||
| git diff --no-merges --exit-code "${base_commit}" -- "${package_dir}" &> /dev/null && { |
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.
Writing a note here as a reminder that unfortunately, --no-merges here didn't work to fix anything.
However, it probably doesn't break anything either, so it's fine to leave like this.
CC: @Biswa96
This PR will prevent failure modes such as the one in https://github.com/termux/termux-packages/actions/runs/19025073645 by skipping the version checks past version validation for version arrays on all but index 0, since that is the
git diff, version compare, and sequential revision increase/proper revision reset checks only need to be run once.I'd like to additionally request @truboxl for review regarding the recent on-device issues with the linter.
This branch doesn't contain fixes for on-device usage in its initial state, however I plan to add these later today after concluding on-device testing of the linter.