termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

[DO NOT MERGE] [TRACKER] Apt 3.1.x

Open TomJo2000 opened this issue 8 months ago • 106 comments

Currently fails with:

FAILED: apt-pkg/CMakeFiles/apt-pkg.dir/edsp.cc.o 
/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/clang++ --target=aarch64-none-linux-android --gcc-toolchain=/home/builder/.termux-build/_cache/android-r27c-api-24-v1 --sysroot=/home/builder/.termux-build/_cache/android-r27c-api-24-v1/sysroot -D_WITH_GETLINE=1 -Dapt_pkg_EXPORTS -I/home/builder/.termux-build/apt/build/include -I/home/builder/.termux-build/apt/build/include/apt-pkg -fstack-protector-strong -Oz -Wno-c++11-narrowing --target=aarch64-linux-android24  -isystem/data/data/com.termux/files/usr/include/c++/v1 -isystem/data/data/com.termux/files/usr/include -O3 -DNDEBUG -std=gnu++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wcast-align -Wredundant-decls -Wmissing-declarations -Wctor-dtor-privacy -Wdisabled-optimization -Winit-self -Wmissing-include-dirs -Wsign-promo -Wundef -Wdouble-promotion -Wsuggest-override -Werror=suggest-override -Werror=return-type -Wp,-D_GLIBCXX_ASSERTIONS -MD -MT apt-pkg/CMakeFiles/apt-pkg.dir/edsp.cc.o -MF apt-pkg/CMakeFiles/apt-pkg.dir/edsp.cc.o.d -o apt-pkg/CMakeFiles/apt-pkg.dir/edsp.cc.o -c /home/builder/.termux-build/apt/src/apt-pkg/edsp.cc
In file included from /home/builder/.termux-build/apt/src/apt-pkg/edsp.cc:10:
In file included from /home/builder/.termux-build/apt/build/include/apt-pkg/algorithms.h:32:
In file included from /home/builder/.termux-build/apt/build/include/apt-pkg/cachefilter.h:9:
/home/builder/.termux-build/apt/build/include/apt-pkg/pkgcache.h:638:39: warning: unknown attribute 'unavailable' ignored [-Wunknown-attributes]
  638 |    map_pointer<Version> VersionList [[gnu::unavailable("not yet available")]];
      |                                       ^~~~~~~~~~~~~~~~
/home/builder/.termux-build/apt/build/include/apt-pkg/pkgcache.h:639:51: warning: unknown attribute 'unavailable' ignored [-Wunknown-attributes]
  639 |    map_pointer<SourceVersion> NextSourceVersion [[gnu::unavailable("not yet available")]];
      |                                                   ^~~~~~~~~~~~~~~~
  • Supercedes #20029
  • Closes #24199, closes #24160, closes #26782

TomJo2000 avatar Apr 08 '25 23:04 TomJo2000

That part of apt-pkg/pkgcache.h does seem to have changed between 2.8.1 (which we ship now) and 3.0.0, here's the hunk:

@@ -611,8 +619,27 @@ struct pkgCache::DescFile
    map_pointer<DescFile> NextFile;
    /** \brief position in the file */
    map_filesize_t Offset;         // File offset
-   /** @TODO document pkgCache::DescFile::Size */
-   map_filesize_t Size;
+};
+									/*}}}*/
+// SourceVersion structure					 	/*{{{*/
+/** \brief information for a single version of a source package
+
+    The version list is always sorted from highest version to lowest
+    version by the generator. Equal version numbers are either merged
+    or handled as separate versions based on the Hash value. */
+struct pkgCache::SourceVersion
+{
+   /** \brief unique sequel ID */
+   map_id_t ID;
+   /** \brief Group the source package belongs too */
+   map_pointer<pkgCache::Group> Group;
+   /** \brief complete version string */
+   map_stringitem_t VerStr;
+   map_pointer<Version> VersionList [[gnu::unavailable("not yet available")]];
+   map_pointer<SourceVersion> NextSourceVersion [[gnu::unavailable("not yet available")]];
+
+   /** \brief Private pointer */
+   map_pointer<void> d;
https://salsa.debian.org/apt-team/apt/-/blob/3.0.0/apt-pkg/pkgcache.h?ref_type=tags#L638

TomJo2000 avatar Apr 08 '25 23:04 TomJo2000

Thanks for the help @licy183, I just saw this now.

TomJo2000 avatar Apr 12 '25 11:04 TomJo2000

I'm doing on-device testing with the DEBs from this PR now.

I have already encountered one issue.

Warning: Could not execute pager - PagerSetup (2: No such file or directory)

Edit: Okay this is "newly" introduced in 2.9.18^1, and defaults to pager, which we don't ship. Should be as simple as passing a build option. Making it default to less seems sensible.

TomJo2000 avatar Apr 12 '25 17:04 TomJo2000

Okay, that fixed apt-file but now I'm getting the following two things.

~$ pkg up                                                                                                                                                          
Checking availability of current mirror:
[*] https://packages-cf.termux.dev/apt/termux-main: ok
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/apt/methods/https": library "libseccomp.so" not found: needed by main executable
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/apt/methods/https": library "libseccomp.so" not found: needed by main executable
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/apt/methods/https": library "libseccomp.so" not found: needed by main executable
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/apt/methods/https": library "libseccomp.so" not found: needed by main executable
Error: Method https has died unexpectedly!
Error: Sub-process https returned an error code (1)
Error: Method /data/data/com.termux/files/usr/lib/apt/methods/https did not start correctly
Error: Method https has died unexpectedly!
Error: Sub-process https returned an error code (1)
Error: Method /data/data/com.termux/files/usr/lib/apt/methods/https did not start correctly
Error: Method https has died unexpectedly!
Error: Sub-process https returned an error code (1)
Error: Method /data/data/com.termux/files/usr/lib/apt/methods/https did not start correctly
Error: Method https has died unexpectedly!
Error: Sub-process https returned an error code (1)
Error: Method /data/data/com.termux/files/usr/lib/apt/methods/https did not start correctly
Error: Failed to fetch https://packages-cf.termux.dev/apt/termux-main/dists/stable/InRelease  
Error: Failed to fetch https://packages-cf.termux.dev/apt/termux-root/dists/root/InRelease  
Error: Failed to fetch https://tur.kcubeterm.com/dists/tur-packages/InRelease  
Error: Failed to fetch https://packages-cf.termux.dev/apt/termux-x11/dists/x11/InRelease  
Error: Some index files failed to download. They have been ignored, or old ones used instead.
Notice: Some sources can be modernized. Run 'apt modernize-sources' to do so.

Edit: looks like a missing dependency.

~$ apt modernize-sources 
The following files need modernizing:
  - /data/data/com.termux/files/usr/etc/apt/sources.list
  - /data/data/com.termux/files/usr/etc/apt/sources.list.d/root.list
  - /data/data/com.termux/files/usr/etc/apt/sources.list.d/tur.list
  - /data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list

Modernizing will replace .list files with the new .sources format,
add Signed-By values where they can be determined automatically,
and save the old files into .list.bak files.

This command supports the 'signed-by' and 'trusted' options. If you
have specified other options inside [] brackets, please transfer them
manually to the output files; see sources.list(5) for a mapping.

For a simulation, respond N in the following prompt.
Rewrite 4 sources? [Y/n] N
Simulating only...
Modernizing /data/data/com.termux/files/usr/etc/apt/sources.list...

# Would write to: /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources
# Modernized from /data/data/com.termux/files/usr/etc/apt/sources.list
Types: deb
URIs: https://packages-cf.termux.dev/apt/termux-main/
Suites: stable
Components: main 
Signed-By: 
Warning: Could not determine Signed-By for URIs: https://packages-cf.termux.dev/apt/termux-main/, Suites: stable

Modernizing /data/data/com.termux/files/usr/etc/apt/sources.list.d/root.list...

# Would write to: /data/data/com.termux/files/usr/etc/apt/sources.list.d/root.sources
Types: deb
URIs: https://packages-cf.termux.dev/apt/termux-root/
Suites: root
Components: stable 
Signed-By: 
Warning: Could not determine Signed-By for URIs: https://packages-cf.termux.dev/apt/termux-root/, Suites: root

Modernizing /data/data/com.termux/files/usr/etc/apt/sources.list.d/tur.list...

# Would write to: /data/data/com.termux/files/usr/etc/apt/sources.list.d/tur.sources
Types: deb
URIs: https://tur.kcubeterm.com/
Suites: tur-packages
Components: tur  tur-on-device tur-continuous
Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/tur.gpg

Modernizing /data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list...

# Would write to: /data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.sources
Types: deb
URIs: https://packages-cf.termux.dev/apt/termux-x11/
Suites: x11
Components: main 
Signed-By: 
Warning: Could not determine Signed-By for URIs: https://packages-cf.termux.dev/apt/termux-x11/, Suites: x11

Edit: gonna have to look into that, we'll probably wanna migrate the repo files.

TomJo2000 avatar Apr 23 '25 16:04 TomJo2000

CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/apt/methods/https": library "libseccomp.so" not found: needed by main executable

Probably, seccomp need to be removed from cmake https://salsa.debian.org/apt-team/apt/-/blob/3.0.0/CMakeLists.txt?ref_type=tags#L137

Biswa96 avatar Apr 23 '25 16:04 Biswa96

CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/apt/methods/https": library "libseccomp.so" not found: needed by main executable

Probably, seccomp need to be removed from cmake https://salsa.debian.org/apt-team/apt/-/blob/3.0.0/CMakeLists.txt?ref_type=tags#L137

It was missing as a dependency. Works after I manually installed it.

TomJo2000 avatar Apr 23 '25 16:04 TomJo2000

It was missing as a dependency.

libseccomp is still downloaded in CI and cmake picks it up.

Biswa96 avatar Apr 23 '25 16:04 Biswa96

It was missing as a dependency.

libseccomp is still downloaded in CI and cmake picks it up.

Yes. I force pushed the branch to fix that. https://github.com/termux/termux-packages/compare/52fdcd8e0051a4dc1272a58828fb8c89116bc542..8bd692dd9f45492681947d39f4938553113fab7a

TomJo2000 avatar Apr 23 '25 16:04 TomJo2000

I'm having some trouble wrapping my head around the new deb822 format for package sources (e.g. repos). https://repolib.readthedocs.io/en/latest/deb822-format.html#deb822-style-format

If I run apt modernize-sources it converts all the $repo.list files into $repo.sources files But there is still a $TERMUX__PREFIX/etc/apt/sources.list file (and it places a termux-main-stable.sources into sources.list.d).

# ~$ tree $TERMUX__PREFIX/etc/apt
/data/data/com.termux/files/usr/etc/apt
├── apt.conf.d
│   └── 50apt-file.conf
├── preferences.d
├── sources.list
├── sources.list.bak
├── sources.list.d
│   ├── root.list.bak
│   ├── root.sources
│   ├── termux-main-stable.sources
│   ├── tur.list.bak
│   ├── tur.sources
│   ├── x11.list.bak
│   └── x11.sources
├── sources.list.dpkg-old
├── trusted.gpg
└── trusted.gpg.d
    ├── 2096779623.gpg -> /data/data/com.termux/files/usr/share/termux-keyring/2096779623.gpg
    ├── agnostic-apollo.gpg -> /data/data/com.termux/files/usr/share/termux-keyring/agnostic-apollo.gpg
    ├── grimler.gpg -> /data/data/com.termux/files/usr/share/termux-keyring/grimler.gpg
    ├── kcubeterm.gpg -> /data/data/com.termux/files/usr/share/termux-keyring/kcubeterm.gpg
    ├── landfillbaby.gpg -> /data/data/com.termux/files/usr/share/termux-keyring/landfillbaby.gpg
    ├── mradityaalok.gpg -> /data/data/com.termux/files/usr/share/termux-keyring/mradityaalok.gpg
    ├── termux-autobuilds.gpg -> /data/data/com.termux/files/usr/share/termux-keyring/termux-autobuilds.gpg
    └── tur.gpg

5 directories, 20 files

And it's complaining about duplicates and missing Signed-By entries.

Checking availability of current mirror:
[*] https://packages-cf.termux.dev/apt/termux-main: ok
Hit:1 https://turdl.kcubeterm.com tur-packages InRelease                     
Hit:2 https://packages-cf.termux.dev/apt/termux-main stable InRelease
Hit:3 https://packages-cf.termux.dev/apt/termux-root root InRelease
Hit:4 https://packages-cf.termux.dev/apt/termux-x11 x11 InRelease
All packages are up to date.    
Warning: Target Packages (main/binary-aarch64/Packages) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Warning: Target Packages (main/binary-all/Packages) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Warning: Target Contents-deb (main/Contents-aarch64) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Warning: Target Contents-deb (main/Contents-all) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Warning: Target Packages (main/binary-aarch64/Packages) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Warning: Target Packages (main/binary-all/Packages) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Warning: Target Contents-deb (main/Contents-aarch64) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Warning: Target Contents-deb (main/Contents-all) is configured multiple times in /data/data/com.termux/files/usr/etc/apt/sources.list:1 and /data/data/com.termux/files/usr/etc/apt/sources.list.d/termux-main-stable.sources:1
Notice: Missing Signed-By in the sources.list(5) entry for 'https://packages-cf.termux.dev/apt/termux-main'
Notice: Missing Signed-By in the sources.list(5) entry for 'https://packages-cf.termux.dev/apt/termux-root'
Notice: Missing Signed-By in the sources.list(5) entry for 'https://packages-cf.termux.dev/apt/termux-x11'
Summary:                        
  Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0

TomJo2000 avatar Apr 23 '25 17:04 TomJo2000

We'll probably need to change the apt sources handling in:

  • termux-tools/scripts/termux-info.in https://github.com/termux/termux-tools/blob/a62f7b21bc6cdfb343c319d920097ad69b814134/scripts/termux-info.in#L46-L71
  • termux-app/termux-shared/src/main/res/raw/apt_info_script.sh https://github.com/termux/termux-app/blob/bc321d0a7c4f5391aa83ecf315cb8a47ff4cf090/termux-shared/src/main/res/raw/apt_info_script.sh#L5
  • proot-distro (for distros using Apt, although that can probably wait some time)
  • termux-tools/scripts/pkg.in https://github.com/termux/termux-tools/blob/a62f7b21bc6cdfb343c319d920097ad69b814134/scripts/pkg.in#L181

I'll prep a PR for termux-tools.

TomJo2000 avatar Apr 23 '25 17:04 TomJo2000

That's the repos moved over to deb822.

TomJo2000 avatar Apr 23 '25 21:04 TomJo2000

Also updated dpkg as part of this PR now.

TomJo2000 avatar May 04 '25 09:05 TomJo2000

dpkg and libapt-pkg-perl are now being built from tarballs provided from Debian's upstream GitLab instance. This should help avoid build failures due to versions having been removed from http://ftp.debian.org/debian/pool/main/

TomJo2000 avatar May 04 '25 10:05 TomJo2000

Almost forgot the glibc-repo.

I've also standardized the postinst scripts for all of the *-repo packages.

TomJo2000 avatar May 04 '25 11:05 TomJo2000

Since that is a major version bumping of infrastructure-critical package we should preserve current versions of affected packages and create some script for fast environment recovery just for the case if this update will break package installing for anyone.

twaik avatar May 04 '25 12:05 twaik

Fixed up the Suites: entries for each repo. Must have messed those up when copy pasting.

TomJo2000 avatar May 04 '25 22:05 TomJo2000

  • We should probably figure out what we wanna do with the old .list one-line sources.
  • We definitely should not be removing or modifying sources not provided by a given repo package. E.g. apt shouldn't move or remove tur.list. It should only touch $PREFIX/etc/apt/sources.list.
  • We probably just wanna move them to $repo_name.list.dpkg-old files. But I wanna reiterate again that repo packages should only deprecate/replace their own .list file.

A lot of users, for better or worse, are still using the its-pointless repo or similar unofficial Termux repositories. While we do not support these officially, we shouldn't break them on purpose.

TomJo2000 avatar May 04 '25 22:05 TomJo2000

I've just finished some additional testing.

  • nala is gonna need a rebuild against Apt 3.0.x
  • synaptic more than likely also needs one.

TomJo2000 avatar May 05 '25 13:05 TomJo2000

I'm updating synaptic to 0.91.7 while we're here. Minor patch adjustments due to moving the config file to $XDG_CONFIG_HOME. But nothing too grim. I'll go into more details once I have it building. The bigger build issue seems to be Apt 3.0.0 related. And there isn't currently merged support for the deb822 format yet.

TomJo2000 avatar May 05 '25 17:05 TomJo2000

Since this PR supersedes #24199 I updated first post to make this PR close #24199 after merging.

twaik avatar May 07 '25 04:05 twaik

Since this PR supersedes #24199 I updated first post to make this PR close #24199 after merging.

In theory yes. In practice I still can't get the the Apt 3.0.x apt-pkg headers to be detected by synaptic.

TomJo2000 avatar May 07 '25 11:05 TomJo2000

apt 3.0.1 was included too soon on Termux's Google Store version and broke apt-file; https://github.com/termux-play-store/termux-apps/issues/74 Do you know how to go back? Must build&install old version from source?

SwuduSusuwu avatar May 09 '25 10:05 SwuduSusuwu

apt 3.0.1 was included too soon on Termux's Google Store version and broke apt-file; termux-play-store/termux-apps#74 Do you know how to go back? Must build&install old version from source?

Ask the play store maintainer to provide debs of old versions that you can install. Issue is off-topic in this thread, please wait for a response in the issue you opened.

Grimler91 avatar May 10 '25 09:05 Grimler91

apt 3.0.1 ... broke apt-file; termux-play-store/termux-apps#74 Do you know how to go back? Must build&install old version from source?

Ask the play store maintainer to provide debs of old versions that you can install. Issue is off-topic in this thread, please wait for a response in the issue you opened.

What this has to do with stock Termux:

  • Can't use apt-file with apt broken.
  • Since Google Store's Termux has apt broken, have considered to switch to stock Termux.
    • This pull request tracks the broken version of apt; want to know that that won't go into stock Termux (if it does, there is no reason to switch to stock Termux, unless can revert to old package).

SwuduSusuwu avatar May 10 '25 20:05 SwuduSusuwu

What this has to do with stock Termux:

  • Can't use apt-file with apt broken.

  • Since Google Store's Termux has apt broken, have considered to switch to stock Termux.

    • This pull request tracks the broken version of apt; want to know that that won't go into stock Termux (if it does, there is no reason to switch to stock Termux, unless can revert to old package).

Just to confirm you are running into these issues with:

  • apt 3.0.1
  • apt-file 3.3-1
  • libapt-pkg-perl 0.1.42

Installed from the artifacts of this PR? You can check the versions using apt show apt apt-file libapt-pkg-perl.

TomJo2000 avatar May 10 '25 20:05 TomJo2000

I can reproduce the apt-file error if and only if libapt-pkg-perl is not updated. With libapt-pkg-perl 0.1.42 installed it works fine.

Grimler91 avatar May 10 '25 21:05 Grimler91

Well yeah, libapt-pkg-perl is apt-file's backend. And it needs to be updated in order to support Apt 3.0.x, hence why it is part of this PR.

TomJo2000 avatar May 10 '25 21:05 TomJo2000

Also, now I tested using the synaptic GUI to search for a package, mark it for installation and install it, then mark it for uninstallation and remove it, and that worked.

robertkirkman avatar May 12 '25 01:05 robertkirkman

Alright, I've double checked the finished preinst and postinst scripts. Here's the ones for x11-repo as an example.

preinst

#!/data/data/com.termux/files/usr/bin/sh
[ "$#" -ge 2 ] || exit 0
[ "$1" = "install" ] || exit 0

[ -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" ] && {
echo
echo "================================"
echo "Legacy repo file found for 'x11' repository."
echo "The legacy 'sources.list.d/x11.list' entry will be migrated"
echo "to 'sources.list.d/x11.sources' as part of the update."
cp -vaf \
"/data/data/com.termux/files/usr"/etc/apt/sources.list.d/x11.list \
"/data/data/com.termux/files/usr"/etc/apt/sources.list.d/x11.list.dpkg-old
echo "A backup copy of the old x11.list repo file"
echo "has been saved to /data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list.dpkg-old"
echo "================================"
echo
}
exit 0
postinst

#!/data/data/com.termux/files/usr/bin/sh
[ "$1" = "configure" ] || exit 0

[ -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" ] && rm "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list"

echo "Downloading updated package list ..."
if [ -d "/data/data/com.termux/files/usr/etc/termux/chosen_mirrors" ] || [ -f "/data/data/com.termux/files/usr/etc/termux/chosen_mirrors" ]; then
pkg --check-mirror update
else
apt update
fi
exit 0

TomJo2000 avatar May 12 '25 20:05 TomJo2000

Alright, I've double checked the finished preinst and postinst scripts. Here's the ones for x11-repo as an example.

preinst postinst

Here's those same maintainer scripts again. But now refactored.

preinst

#!/data/data/com.termux/files/usr/bin/sh

if [ "$1" = "install" ] && [ "$#" -ge 2 ]; then
	if [ -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" ]; then
		echo
		echo "================================"
		echo "Legacy repo file found for 'x11' repository."
		echo "The legacy 'sources.list.d/x11.list' entry will be migrated"
		echo "to 'sources.list.d/x11.sources' as part of the update."
		cp -vaf \
			"/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" \
			"/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list.dpkg-old"
		echo "A backup copy of the old sources.list.d/x11.list repo file"
		echo "has been saved to /data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list.dpkg-old"
		echo "================================"
		echo
	fi
fi

postinst

#!/data/data/com.termux/files/usr/bin/sh
if [ "$1" = "configure" ]; then
	rm -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list"
fi

And the diffs against the old versions.

diff --git a/preinst.old b/preinst
index 7ed499f..cc6b2d4 100644
--- a/preinst.old
+++ b/preinst
@@ -1,20 +1,19 @@
 #!/data/data/com.termux/files/usr/bin/sh
-[ "$#" -ge 2 ] || exit 0
-[ "$1" = "install" ] || exit 0
 
-[ -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" ] && {
-echo
-echo "================================"
-echo "Legacy repo file found for 'x11' repository."
-echo "The legacy 'sources.list.d/x11.list' entry will be migrated"
-echo "to 'sources.list.d/x11.sources' as part of the update."
-cp -vaf \
-"/data/data/com.termux/files/usr"/etc/apt/sources.list.d/x11.list \
-"/data/data/com.termux/files/usr"/etc/apt/sources.list.d/x11.list.dpkg-old
-echo "A backup copy of the old x11.list repo file"
-echo "has been saved to /data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list.dpkg-old"
-echo "================================"
-echo
-}
-exit 0
+if [ "$1" = "install" ] && [ "$#" -ge 2 ]; then
+	if [ -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" ]; then
+		echo
+		echo "================================"
+		echo "Legacy repo file found for 'x11' repository."
+		echo "The legacy 'sources.list.d/x11.list' entry will be migrated"
+		echo "to 'sources.list.d/x11.sources' as part of the update."
+		cp -vaf \
+			"/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" \
+			"/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list.dpkg-old"
+		echo "A backup copy of the old sources.list.d/x11.list repo file"
+		echo "has been saved to /data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list.dpkg-old"
+		echo "================================"
+		echo
+	fi
+fi
diff --git a/postinst.old b/postinst
index 285cc27..1483e22 100644
--- a/postinst.old
+++ b/postinst
@@ -1,13 +1,5 @@
 #!/data/data/com.termux/files/usr/bin/sh
-[ "$1" = "configure" ] || exit 0
-
-[ -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list" ] && rm "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list"
-
-echo "Downloading updated package list ..."
-if [ -d "/data/data/com.termux/files/usr/etc/termux/chosen_mirrors" ] || [ -f "/data/data/com.termux/files/usr/etc/termux/chosen_mirrors" ]; then
-pkg --check-mirror update
-else
-apt update
+if [ "$1" = "configure" ]; then
+	rm -f "/data/data/com.termux/files/usr/etc/apt/sources.list.d/x11.list"
 fi
-exit 0

Edit: Ah right, the *-repo packages have the mirror check in the postinst, need to re-add that. We can probably just add that to the postinst.sh.in in the apt package directory.

This means that it's also run for glibc-repo, tur-repo and apt (main repo). Which shouldn't have any negative impact. glibc-repo and tur-repo already run apt update as part of the postinst. https://github.com/termux/termux-packages/blob/2547e3e8c9009392b85305b5f0e0136b61c712ca/packages/glibc-repo/build.sh#L20-L26 https://github.com/termux/termux-packages/blob/2547e3e8c9009392b85305b5f0e0136b61c712ca/packages/tur-repo/build.sh#L18-L24 And apt (main repo) should probably just run pkg --check-mirror update as part of postinst as well.

TomJo2000 avatar May 20 '25 01:05 TomJo2000