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

Auto updates: add support for source arrays. #23678

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TomJo2000
Copy link
Member

@TomJo2000 TomJo2000 commented Mar 8, 2025

I'd also like to try and make an auto-update function for this.
But I'll need to think of a good way to query the latest major version of the Kernel for that.
Maybe git ls-remote on Linus' tree?

@TomJo2000 TomJo2000 requested a review from Grimler91 as a code owner March 8, 2025 16:09
@TomJo2000 TomJo2000 force-pushed the mp613 branch 2 times, most recently from 387e623 to e6f8dd3 Compare March 8, 2025 19:08
@@ -69,7 +69,7 @@ termux_pkg_upgrade_version() {
echo "INFO: package being updated to ${LATEST_VERSION}."

sed \
-e "s/^\(TERMUX_PKG_VERSION=\)\(.*\)\$/\1\"${EPOCH}${LATEST_VERSION}\"/g" \
-e "s/^\(TERMUX_PKG_VERSION=\(?\)\(.*\)\$/\1\"${EPOCH}${LATEST_VERSION}\"/g" \
Copy link
Member Author

Choose a reason for hiding this comment

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

scripts/updates/utils/termux_pkg_upgrade_version.sh doesn't currently "support" version arrays.
So this works by adding a stupid little work around to make it work with the first line of an array.
I'll borrow some code from lint-packages when I add array support "properly".

check_indentation() {
local pkg_script="$1"
local line='' heredoc_terminator='' in_array=0 i=0
local -a issues=('' '') bad_lines=('FAILED')
# parse leading whitespace
while IFS=$'\n' read -r line; do
((i++))
# make sure it's a heredoc, not a herestring
if ! [[ "$line" == *'<<<'* ]]; then
# Skip this check in entirely within heredocs
# (see packages/ghc-libs for an example of why)
[[ "$line" =~ [^\(]\<{2}-?[\'\"]?([^\'\"]+) ]] && {
heredoc_terminator="${BASH_REMATCH[1]}"
}
(( ${#heredoc_terminator} )) && \
grep -qP "^\s*${heredoc_terminator}" <<< "$line" && {
heredoc_terminator=''
}
(( ${#heredoc_terminator} )) && continue
fi
# check for mixed indentation
grep -qP '^(\t+ +| +\t+)' <<< "$line" && {
issues[0]='Mixed indentation'
bad_lines[$i]="${pkg_script}:${i}:$line"
}
[[ "$line" == *'=('* ]] && in_array=1
if (( ! in_array )); then # spaces for indentation are okay for aligning arrays
grep -qP '^ +' <<< "$line" && { # check for spaces as indentation
issues[1]='Use tabs for indentation'
bad_lines[$i]="${pkg_script}:${i}:$line"
}
fi
[[ "$line" == *')' ]] && in_array=0
done < "$pkg_script"
# if we found problems print them out and throw an error
(( ${#issues[0]} || ${#issues[1]} )) && {
printf '%s\n' "${bad_lines[@]}"
printf '%s\n' "${issues[@]}"
return 1
}
return 0
}

@TomJo2000 TomJo2000 force-pushed the mp613 branch 2 times, most recently from ebe8798 to 0d59482 Compare March 8, 2025 19:15
@TomJo2000 TomJo2000 marked this pull request as draft March 8, 2025 19:18
@TomJo2000
Copy link
Member Author

Making this a draft since apparently this has turned into "add array support to auto updates".

@TomJo2000 TomJo2000 changed the title bump(main/manpages): 6.13 Auto updates: add support for source arrays. Mar 8, 2025
Comment on lines +49 to +67
local latest_kernel_major
latest_kernel_major="$(git ls-remote --tags https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git \
| grep -oP "refs/tags/v\K${TERMUX_PKG_UPDATE_VERSION_REGEXP}$" \
| sort -V \
| tail -n1)"

# No new major release.
if [[ "${latest_kernel_major}" == "${TERMUX_PKG_VERSION[0]}" ]]; then
echo "INFO: No update needed. Already at version '${TERMUX_PKG_VERSION[0]}'."
return
fi

# Verify that this major updated the man pages
curl -fsSL "https://www.kernel.org/pub/linux/docs/man-pages/man-pages-${latest_kernel_major}.tar.sign" &> /dev/null || {
echo "Info: Not updating. Linux ${latest_kernel_major} doesn't seem to have updates the man pages."
}

termux_pkg_upgrade_version "${latest_kernel_major}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
local latest_kernel_major
latest_kernel_major="$(git ls-remote --tags https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git \
| grep -oP "refs/tags/v\K${TERMUX_PKG_UPDATE_VERSION_REGEXP}$" \
| sort -V \
| tail -n1)"
# No new major release.
if [[ "${latest_kernel_major}" == "${TERMUX_PKG_VERSION[0]}" ]]; then
echo "INFO: No update needed. Already at version '${TERMUX_PKG_VERSION[0]}'."
return
fi
# Verify that this major updated the man pages
curl -fsSL "https://www.kernel.org/pub/linux/docs/man-pages/man-pages-${latest_kernel_major}.tar.sign" &> /dev/null || {
echo "Info: Not updating. Linux ${latest_kernel_major} doesn't seem to have updates the man pages."
}
termux_pkg_upgrade_version "${latest_kernel_major}"
# get the page, find all filenames, sort by version and get the last line
local latest="$(curl -s https://www.kernel.org/pub/linux/docs/man-pages/ \
| grep -oP 'man-pages-\K[0-9]+(\.[0-9]+)*' \
| sort -V -u \
| tail -n1)"
termux_pkg_upgrade_version "${latest}"

Copy link
Member

Choose a reason for hiding this comment

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

Heh.

Suggested change
local latest_kernel_major
latest_kernel_major="$(git ls-remote --tags https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git \
| grep -oP "refs/tags/v\K${TERMUX_PKG_UPDATE_VERSION_REGEXP}$" \
| sort -V \
| tail -n1)"
# No new major release.
if [[ "${latest_kernel_major}" == "${TERMUX_PKG_VERSION[0]}" ]]; then
echo "INFO: No update needed. Already at version '${TERMUX_PKG_VERSION[0]}'."
return
fi
# Verify that this major updated the man pages
curl -fsSL "https://www.kernel.org/pub/linux/docs/man-pages/man-pages-${latest_kernel_major}.tar.sign" &> /dev/null || {
echo "Info: Not updating. Linux ${latest_kernel_major} doesn't seem to have updates the man pages."
}
termux_pkg_upgrade_version "${latest_kernel_major}"
read -r latest < <(curl -fsSL https://www.kernel.org/pub/linux/docs/man-pages/ | sed -rn 's/.*man-pages-([0-9]+(\.[0-9]+)*).*/\1/p' | sort -Vr);
termux_pkg_upgrade_version "${latest}"

Comment on lines +71 to 90
sed -r \
-e "s/^(TERMUX_PKG_VERSION=\(?)(.*)\$/\1\"${EPOCH}${LATEST_VERSION}\"/g" \
-e "/TERMUX_PKG_REVISION=/d" \
-i "${TERMUX_PKG_BUILDER_DIR}/build.sh"
Copy link
Member

@twaik twaik Apr 29, 2025

Choose a reason for hiding this comment

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

Probably I found it out, but it is a literal nightmare.

Suggested change
sed -r \
-e "s/^(TERMUX_PKG_VERSION=\(?)(.*)\$/\1\"${EPOCH}${LATEST_VERSION}\"/g" \
-e "/TERMUX_PKG_REVISION=/d" \
-i "${TERMUX_PKG_BUILDER_DIR}/build.sh"
sed -z -r \
-e "s/(TERMUX_PKG_VERSION=\(?[[:space:]]*)[^[:space:]\)]+/\1\"${EPOCH}${LATEST_VERSION}\"/" \
-e "s/(^|\n)TERMUX_PKG_REVISION=[^\n]*(\n|$)/\1/" \
-i "${TERMUX_PKG_BUILDER_DIR}/build.sh"

Or it you think perl is better

perl -0777 -i -pe '
  s/^TERMUX_PKG_REVISION=.*\n//mg;
  s{(TERMUX_PKG_VERSION=\(?\s*)[^)\s]+}{
     qq{$1"'"${EPOCH}${LATEST_VERSION}"'"}
  }em
' "${TERMUX_PKG_BUILDER_DIR}/build.sh"
tests.sh

Not my best work but it did the job.

#!/bin/bash
temp_dir=$(mktemp -d) || { echo failed to create temp directory; exit 1; }

cd "${temp_dir}"

LATEST_VERSION=6.18
EPOCH01=
cat << EOF > build.sh.01
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(6.13
                    2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.01
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=("6.18"
                    2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH02=
cat << EOF > build.sh.02
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.02
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=("6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH03=
cat << EOF > build.sh.03
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
6.13
2017
)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.03
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18"
2017
)
TERMUX_PKG_SHA256=(
EOF

EPOCH04=
cat << EOF > build.sh.04
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
		6.13
        2017
)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.04
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
		"6.18"
        2017
)
TERMUX_PKG_SHA256=(
EOF

EPOCH05=
cat << EOF > build.sh.05
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
6.13 2017
)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.05
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18" 2017
)
TERMUX_PKG_SHA256=(
EOF

EPOCH06=
cat << EOF > build.sh.06
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.06
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH07=
cat << EOF > build.sh.07
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.13" 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.07
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH08=3:
cat << EOF > build.sh.08
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
3:6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.08
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"3:6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH09=3:
cat << EOF > build.sh.09
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						3:6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.09
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH10=3:
cat << EOF > build.sh.10
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						3:6.13 2017
	)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.10
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.18" 2017
	)
TERMUX_PKG_SHA256=(
EOF

EPOCH11=3:
cat << EOF > build.sh.11
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.13" 2017
	)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.11
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.18" 2017
	)
TERMUX_PKG_SHA256=(
EOF

EPOCH12=3:
cat << EOF > build.sh.12
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3:6.13"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.12
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3:6.18"
TERMUX_PKG_SHA256=(
EOF

EPOCH13=3:
cat << EOF > build.sh.13
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=3:6.13
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.13
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3:6.18"
TERMUX_PKG_SHA256=(
EOF

for i in build.sh.*; do
var="EPOCH${i##*.}"
EPOCH="${!var}"

false && \
perl -0777 -i -pe '
  s/^TERMUX_PKG_REVISION=.*\n//mg;
  s{(TERMUX_PKG_VERSION=\(?\s*)[^)\s]+}{
     qq{$1"'"${EPOCH}${LATEST_VERSION}"'"}
  }em
' "$i"

sed -z -r -i \
  -e "s/(TERMUX_PKG_VERSION=\(?[[:space:]]*)[^[:space:]\)]+/\1\"${EPOCH}${LATEST_VERSION}\"/" \
  -e "s/(^|\n)TERMUX_PKG_REVISION=[^\n]*(\n|$)/\1/" \
  "$i"

if diff -Naur "$i" "expected.$i"; then
	echo "test ${i##*.} passed"
else
	echo "test ${i##*.} failed"
fi
done

cd - &>-
rm -rf "${temp_dir}"

Copy link
Member

Choose a reason for hiding this comment

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

But I did not test the sed and perl commands on real buildscripts, only in this synthetic test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably I found it out, but it is a literal nightmare.

Suggested change
sed -r \
-e "s/^(TERMUX_PKG_VERSION=\(?)(.*)\$/\1\"${EPOCH}${LATEST_VERSION}\"/g" \
-e "/TERMUX_PKG_REVISION=/d" \
-i "${TERMUX_PKG_BUILDER_DIR}/build.sh"
sed -z -r \
-e "s/(TERMUX_PKG_VERSION=\(?[[:space:]]*)[^[:space:]\)]+/\1\"${EPOCH}${LATEST_VERSION}\"/" \
-e "s/(^|\n)TERMUX_PKG_REVISION=[^\n]*(\n|$)/\1/" \
-i "${TERMUX_PKG_BUILDER_DIR}/build.sh"

Or it you think perl is better

perl -0777 -i -pe '
  s/^TERMUX_PKG_REVISION=.*\n//mg;
  s{(TERMUX_PKG_VERSION=\(?\s*)[^)\s]+}{
     qq{$1"'"${EPOCH}${LATEST_VERSION}"'"}
  }em
' "${TERMUX_PKG_BUILDER_DIR}/build.sh"
tests.sh

Not my best work but it did the job.

#!/bin/bash
temp_dir=$(mktemp -d) || { echo failed to create temp directory; exit 1; }

cd "${temp_dir}"

LATEST_VERSION=6.18
EPOCH01=
cat << EOF > build.sh.01
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(6.13
                    2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.01
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=("6.18"
                    2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH02=
cat << EOF > build.sh.02
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.02
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=("6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH03=
cat << EOF > build.sh.03
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
6.13
2017
)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.03
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18"
2017
)
TERMUX_PKG_SHA256=(
EOF

EPOCH04=
cat << EOF > build.sh.04
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
		6.13
        2017
)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.04
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
		"6.18"
        2017
)
TERMUX_PKG_SHA256=(
EOF

EPOCH05=
cat << EOF > build.sh.05
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
6.13 2017
)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.05
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18" 2017
)
TERMUX_PKG_SHA256=(
EOF

EPOCH06=
cat << EOF > build.sh.06
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.06
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH07=
cat << EOF > build.sh.07
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.13" 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.07
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH08=3:
cat << EOF > build.sh.08
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
3:6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.08
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
"3:6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH09=3:
cat << EOF > build.sh.09
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						3:6.13 2017)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.09
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.18" 2017)
TERMUX_PKG_SHA256=(
EOF

EPOCH10=3:
cat << EOF > build.sh.10
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						3:6.13 2017
	)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.10
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.18" 2017
	)
TERMUX_PKG_SHA256=(
EOF

EPOCH11=3:
cat << EOF > build.sh.11
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.13" 2017
	)
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.11
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=(
						"3:6.18" 2017
	)
TERMUX_PKG_SHA256=(
EOF

EPOCH12=3:
cat << EOF > build.sh.12
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3:6.13"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.12
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3:6.18"
TERMUX_PKG_SHA256=(
EOF

EPOCH13=3:
cat << EOF > build.sh.13
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=3:6.13
TERMUX_PKG_REVISION=1
TERMUX_PKG_SHA256=(
EOF

cat << EOF > expected.build.sh.13
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3:6.18"
TERMUX_PKG_SHA256=(
EOF

for i in build.sh.*; do
var="EPOCH${i##*.}"
EPOCH="${!var}"

false && \
perl -0777 -i -pe '
  s/^TERMUX_PKG_REVISION=.*\n//mg;
  s{(TERMUX_PKG_VERSION=\(?\s*)[^)\s]+}{
     qq{$1"'"${EPOCH}${LATEST_VERSION}"'"}
  }em
' "$i"

sed -z -r -i \
  -e "s/(TERMUX_PKG_VERSION=\(?[[:space:]]*)[^[:space:]\)]+/\1\"${EPOCH}${LATEST_VERSION}\"/" \
  -e "s/(^|\n)TERMUX_PKG_REVISION=[^\n]*(\n|$)/\1/" \
  "$i"

if diff -Naur "$i" "expected.$i"; then
	echo "test ${i##.*} passed"
else
	echo "test ${i##.*} failed"
fi
done

cd - &>-
rm -rf "${temp_dir}"

As Apollo pointed out in the other PR.
I'd like to avoid adding perl as an additional dependency to our build scripts.

Copy link
Member

Choose a reason for hiding this comment

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

In this case you can test the sed solution. Or I can try it when I get home.

Also as Robert mentioned perl is a dependency of at least autoconf autogen automake build-essential gobject-introspection gobject-introspection-bin git which are extensively used in our buildscripts so I hardly believe it will not be present on build host.
#24518 (comment)

Copy link
Member

@twaik twaik Apr 29, 2025

Choose a reason for hiding this comment

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

Sooooo
I found all packages like manpages with

$ grep -nr TERMUX_PKG_VERSION= --include=build.sh . | grep -v -E -e '="' -e '=[0-9]+' -e '=\$'
./packages/maxima/build.sh:5:TERMUX_PKG_VERSION=()
./packages/ncurses/build.sh:15:TERMUX_PKG_VERSION=(6.5.20240831
./packages/glulxe/build.sh:5:TERMUX_PKG_VERSION=(0.6.1
./packages/libandroid-support/build.sh:4:TERMUX_PKG_VERSION=(29
./packages/softether-vpn/build.sh:5:TERMUX_PKG_VERSION=(5.02.5180)
./packages/unar/build.sh:5:TERMUX_PKG_VERSION=()
./packages/perl/build.sh:12:TERMUX_PKG_VERSION=(5.38.2
./packages/hilbish/build.sh:5:TERMUX_PKG_VERSION=(
./packages/manpages/build.sh:6:TERMUX_PKG_VERSION=(6.13
./packages/ldc/build.sh:5:TERMUX_PKG_VERSION=(1.30.0)
./sample/build.sh:9:TERMUX_PKG_VERSION=
./disabled-packages/mingw-w64-crt/build.sh:6:TERMUX_PKG_VERSION=(10.0.0)
./disabled-packages/mingw-w64-gcc-libs/build.sh:5:TERMUX_PKG_VERSION=(12.2.0)
./disabled-packages/libmusicbrainz/build.sh:5:TERMUX_PKG_VERSION=()
./x11-packages/tigervnc/build.sh:5:TERMUX_PKG_VERSION=(1.15.0
./root-packages/zmap/build.sh:5:TERMUX_PKG_VERSION=(1:4.3.2

So I checked ncurses, glulxe, libandroid-support, softether-vpn, perl, hilbish, ldc, tigervnc and zmap and it works there as well so I assume it works fine. And version replacing on regular packages was not broken.

Copy link
Member

Choose a reason for hiding this comment

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

Actually 13 lines of code since it removes revision separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the headache I guess...
I'll look into it.

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why by update-checksums replaces all checksums in the checksums array so it is not the same case as in here. But there are a few things that can be refactored.

Copy link
Member Author

Choose a reason for hiding this comment

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

Twaik.
Can you get me done with one headache before adding another?
I'm looking at it. I'll hear more suggestions when I'm done with this one.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry.

@TomJo2000
Copy link
Member Author

(This was just resolving the merge conflict, actual changes will be in the next change)

@TomJo2000
Copy link
Member Author

Latest push isn't quite a working state yet, but I'm tired and I have a headache.
That new helper script is a doozy.
I'll write some documentation for it later.

tl;dr It turns sed substitutions into localized patches.

Comment on lines +62 to 74
dl_tmpdir="$(mktemp -d "${TMPDIR-/tmp}/termux.src.dl.XXXXXXXX")"

if [[ -d "${dl_tmpdir}" ]]; then
if ! curl --fail --location --retry 3 --output "${dl_tmpdir}/source-bundle" "$url"; then
rm -rf "${dl_tmpdir}"
fi

if [[ -f "${dl_tmpdir}/source-bundle" ]]; then
sha256sum "${dl_tmpdir}/source-bundle" | awk '{ print $1 }'
fi

if [[ -d "${dl_tmpdir}" ]]; then
if ! curl --fail --location --retry 3 --output "${dl_tmpdir}/source-bundle" "$url"; then
rm -rf "${dl_tmpdir}"
fi
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dl_tmpdir="$(mktemp -d "${TMPDIR-/tmp}/termux.src.dl.XXXXXXXX")"
if [[ -d "${dl_tmpdir}" ]]; then
if ! curl --fail --location --retry 3 --output "${dl_tmpdir}/source-bundle" "$url"; then
rm -rf "${dl_tmpdir}"
fi
if [[ -f "${dl_tmpdir}/source-bundle" ]]; then
sha256sum "${dl_tmpdir}/source-bundle" | awk '{ print $1 }'
fi
if [[ -d "${dl_tmpdir}" ]]; then
if ! curl --fail --location --retry 3 --output "${dl_tmpdir}/source-bundle" "$url"; then
rm -rf "${dl_tmpdir}"
fi
curl --fail --location --retry 3 --output - "$url" | sha256sum | awk '{ print $1 }'
if (( PIPESTATUS[0] )); then
echo "ERROR: Download failed, can not proceed." >&2
exit 1
fi

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.

2 participants