这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions packages/apt-show-versions/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
TERMUX_PKG_HOMEPAGE=https://salsa.debian.org/debian/apt-show-versions
TERMUX_PKG_DESCRIPTION="Lists available package versions with distribution"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="0.22.16"
TERMUX_PKG_SRCURL="https://salsa.debian.org/debian/apt-show-versions/-/archive/$TERMUX_PKG_VERSION/apt-show-versions-$TERMUX_PKG_VERSION.tar.gz"
TERMUX_PKG_SHA256=15308503b113209a551e495f9ca8cf002acf8d3e4ce31df58e1fcc4fa7713310
TERMUX_PKG_DEPENDS="apt, libapt-pkg-perl, perl"
TERMUX_PKG_PLATFORM_INDEPENDENT=true
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
PREFIX=$TERMUX_PREFIX
INSTALLSITEMAN1DIR=$TERMUX_PREFIX/share/man/man1
INSTALLSITEMAN3DIR=$TERMUX_PREFIX/share/man/man3
"

# for some reason, make install installs some weird files in lib,
# then before the package is finalized, the lib folder needs to be removed.
# this behavior and build process is identifiable as intended, since it is
# ported directly from the behavior of the Debian build script:
# https://salsa.debian.org/debian/apt-show-versions/-/blob/c500448e886a96f75770bbb59570e95c8e77802c/debian/rules#L61
TERMUX_PKG_RM_AFTER_INSTALL="lib"
# install step may pollute lib folder with weird perl files
TERMUX_PKG_ON_DEVICE_BUILD_NOT_SUPPORTED=true

# the original creator of perl.makemaker decided in 2003 that formal accomodation
# of distros like Termux that can be described as "distros with timestamp-based packaging systems"
# is undesirable because such a distro was either unheard of to them at the time, or
# they imagined the hypothetical possibility of the present or future existence of such a distro
# as an unsupportable edge case,
# so the Makefile that perl.makemaker generates will not reliably install everything
# unless all desired files are forcibly removed before make install is invoked
# https://www.nntp.perl.org/group/perl.makemaker/2003/04/msg1092.html

# files that should be in $TERMUX_PREFIX after make install
_MAKE_INSTALL_PROVIDED_FILES="
bin/apt-show-versions
share/man/man1/apt-show-versions.1p
"

termux_step_pre_configure() {
pushd "$TERMUX_PREFIX"
rm -f $_MAKE_INSTALL_PROVIDED_FILES
popd
}

# termux_step_configure() for Makefile.PLs based on package perl-rename
termux_step_configure() {
perl Makefile.PL $TERMUX_PKG_EXTRA_CONFIGURE_ARGS
}

termux_step_post_make_install() {
install -D --mode=644 "$TERMUX_PKG_SRCDIR/debian/apt-show-versions.apt.conf" \
"$TERMUX_PREFIX/etc/apt/apt.conf.d/20apt-show-versions"

install -D --mode=644 "$TERMUX_PKG_SRCDIR/debian/apt-show-versions.bash-completion" \
"$TERMUX_PREFIX/share/bash-completion/completions/apt-show-versions"
}

termux_step_create_debscripts() {
cat <<- POSTINST_EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh
if [ "$TERMUX_PACKAGE_FORMAT" = "debian" ] && [ "\$1" != "configure" ]; then
exit 0
fi
echo "** initializing cache. This may take a while **"
apt-show-versions -i
exit 0
POSTINST_EOF

cat <<- PRERM_EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh
if [ "$TERMUX_PACKAGE_FORMAT" = "debian" ] && [ "\$1" != "remove" ]; then
exit 0
fi
rm -rf $TERMUX_PREFIX/var/cache/apt-show-versions
exit 0
PRERM_EOF
}
74 changes: 74 additions & 0 deletions packages/apt-show-versions/termux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
--- a/apt-show-versions
+++ b/apt-show-versions
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!@TERMUX_PREFIX@/bin/perl -w

# apt-show-versions - Lists available package versions with distribution

@@ -33,9 +33,9 @@ use strict;
use Getopt::Long;
use Storable qw(nstore retrieve);

-my $apackagescachefile="/var/cache/apt-show-versions/apackages-multiarch";
-my $ipackagescachefile="/var/cache/apt-show-versions/ipackages-multiarch";
-my $filescachefile="/var/cache/apt-show-versions/files";
+my $apackagescachefile="@TERMUX_PREFIX@/var/cache/apt-show-versions/apackages-multiarch";
+my $ipackagescachefile="@TERMUX_PREFIX@/var/cache/apt-show-versions/ipackages-multiarch";
+my $filescachefile="@TERMUX_PREFIX@/var/cache/apt-show-versions/files";
my $cachefilemode=0644;

use AptPkg::Cache;
@@ -134,9 +134,9 @@ Usage:

Options:
-stf|--status-file=<file> Use <file> as the dpkg status file instead
- of /var/lib/dpkg/status
+ of @TERMUX_PREFIX@/var/lib/dpkg/status
-ld|list-dir=<directory> Use <directory> as path to apt's list files instead
- of /var/state/apt/lists/ or /var/lib/apt/lists/
+ of @TERMUX_PREFIX@/var/state/apt/lists/ or @TERMUX_PREFIX@/var/lib/apt/lists/
-p|--package=<package> Print versions for <package>.
-r|--regex Read package with -p as regex
-R|--regex-all Like --regex, but also show not installed packages.
@@ -162,7 +162,7 @@ else {
}

# Path to dpkg status file
-my $status_file = $opts{'status-file'} || "/var/lib/dpkg/status";
+my $status_file = $opts{'status-file'} || "@TERMUX_PREFIX@/var/lib/dpkg/status";
my @files;
my $filesref;

@@ -572,7 +572,7 @@ sub parse_file {
my ($key, $value, $package, $packages);

my $release = &determine_pkgfile_release($file);
- open FILE, "/usr/lib/apt/apt-helper cat-file $file|" or &die("Can't open file $file: $!\n");
+ open FILE, "@TERMUX_PREFIX@/lib/apt/apt-helper cat-file $file|" or &die("Can't open file $file: $!\n");
if ($opts{'verbose'}) {print "Parsing $file...";};
while (<FILE>) {
if (/^$/){
@@ -902,12 +902,12 @@ package and via a cron.daily job.

=item B<-stf> I<file>, B<--status-file>=I<file>

-Use I<file> as the dpkg status file instead of /var/lib/dpkg/status
+Use I<file> as the dpkg status file instead of @TERMUX_PREFIX@/var/lib/dpkg/status

=item B<-ld> I<directory>, B<--list-dir>=I<directory>

Use I<directory> as path to apt's list files instead of
-/var/state/apt/lists/ or /var/lib/apt/lists/
+@TERMUX_PREFIX@/var/state/apt/lists/ or @TERMUX_PREFIX@/var/lib/apt/lists/

=item B<-h>, B<--help>

--- a/debian/apt-show-versions.apt.conf
+++ b/debian/apt-show-versions.apt.conf
@@ -1,4 +1,4 @@
// When Apt's cache is updated (i.e. apt-get update)
APT::Update::Post-Invoke-Success {
-"test -x /usr/bin/apt-show-versions || exit 0 ; apt-show-versions -i";
+"test -x @TERMUX_PREFIX@/bin/apt-show-versions || exit 0 ; apt-show-versions -i";
};