diff --git a/packages/pacman/add.c.patch b/packages/pacman/add.c.patch new file mode 100644 index 000000000..562edc9fe --- /dev/null +++ b/packages/pacman/add.c.patch @@ -0,0 +1,41 @@ +diff -uNr pacman-6.0.0/lib/libalpm/add.c pacman-termux/lib/libalpm/add.c +--- pacman-6.0.0/lib/libalpm/add.c 2021-05-20 06:38:45.938120000 +0300 ++++ pacman-termux/lib/libalpm/add.c 2021-10-04 16:00:39.000000000 +0300 +@@ -132,6 +132,9 @@ + return 1; + } + ++ archive_entry_set_uid(entry, getuid()); ++ archive_entry_set_gid(entry, getgid()); ++ + archive_write_disk_set_options(archive_writer, archive_flags); + + ret = archive_read_extract2(archive, entry, archive_writer); +@@ -242,7 +245,6 @@ + * 3,4- conflict checks should have caught this. either overwrite + * or backup the file. + * 5- file replacing directory- don't allow it. +- * 6- skip extraction, dir already exists. + */ + + isnewfile = llstat(filename, &lsbuf) != 0; +@@ -254,19 +256,6 @@ + gid_t entrygid = archive_entry_gid(entry); + #endif + +- /* case 6: existing dir, ignore it */ +- if(lsbuf.st_mode != entrymode) { +- /* if filesystem perms are different than pkg perms, warn user */ +- mode_t mask = 07777; +- _alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n" +- "filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask, +- entrymode & mask); +- alpm_logaction(handle, ALPM_CALLER_PREFIX, +- "warning: directory permissions differ on %s\n" +- "filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask, +- entrymode & mask); +- } +- + #if 0 + /* Disable this warning until our user management in packages has improved. + Currently many packages have to create users in post_install and chown the diff --git a/packages/pacman/build.sh b/packages/pacman/build.sh new file mode 100644 index 000000000..5805752ef --- /dev/null +++ b/packages/pacman/build.sh @@ -0,0 +1,25 @@ +TERMUX_PKG_HOMEPAGE=https://archlinux.org/pacman/ +TERMUX_PKG_DESCRIPTION="a simple library-based package manager" +TERMUX_PKG_LICENSE="GPL-2.0" +TERMUX_PKG_MAINTAINER="@Maxython" +TERMUX_PKG_VERSION=6.0.0 +TERMUX_PKG_SRCURL=https://sources.archlinux.org/other/pacman/pacman-${TERMUX_PKG_VERSION}.tar.xz +TERMUX_PKG_SHA256=004448085a7747bdc7a0a4dd5d1fb7556c6b890111a06e029ab088f9905d4808 +TERMUX_PKG_DEPENDS="bash, libarchive, curl, gpgme" +TERMUX_PKG_BUILD_DEPENDS="doxygen, asciidoc, nettle" +TERMUX_PKG_GROUPS="base-devel" + +# A temporary solution to the problem with compiling the documentation. +# https://github.com/termux/termux-packages/pull/7759#issuecomment-945664581 +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +-Ddoc=disabled +" + +termux_step_pre_configure() { + rm -f ./scripts/libmakepkg/executable/sudo.sh.in + rm -f ./scripts/libmakepkg/executable/fakeroot.sh.in +} + +termux_step_post_configure() { + sed -i 's/$ARGS -o $out $in $LINK_ARGS/$ARGS -o $out $in $LINK_ARGS -landroid-glob/' ${TERMUX_TOPDIR}/pacman/build/build.ninja +} diff --git a/packages/pacman/doc_meson.build.patch b/packages/pacman/doc_meson.build.patch new file mode 100644 index 000000000..6576f9005 --- /dev/null +++ b/packages/pacman/doc_meson.build.patch @@ -0,0 +1,12 @@ +diff -uNr pacman-6.0.0/doc/meson.build pacman-termux/doc/meson.build +--- pacman-6.0.0/doc/meson.build 2021-05-20 06:38:45.938120000 +0300 ++++ pacman-termux/doc/meson.build 2021-10-04 16:00:39.000000000 +0300 +@@ -101,7 +101,7 @@ + endforeach + + run_target('html', +- command : ['/bin/true'], ++ command : ['@TERMUX_PREFIX@/bin/true'], + depends : html_targets) + + custom_target( diff --git a/packages/pacman/executable_meson.build.patch b/packages/pacman/executable_meson.build.patch new file mode 100644 index 000000000..9f7f42b35 --- /dev/null +++ b/packages/pacman/executable_meson.build.patch @@ -0,0 +1,16 @@ +diff -uNr pacman-6.0.0/scripts/libmakepkg/executable/meson.build pacman-termux/scripts/libmakepkg/executable/meson.build +--- pacman-6.0.0/scripts/libmakepkg/executable/meson.build 2021-05-20 06:38:45.948119900 +0300 ++++ pacman-termux/scripts/libmakepkg/executable/meson.build 2021-10-04 16:00:39.000000000 +0300 +@@ -4,12 +4,10 @@ + 'ccache.sh.in', + 'checksum.sh.in', + 'distcc.sh.in', +- 'fakeroot.sh.in', + 'gpg.sh.in', + 'gzip.sh.in', + 'pacman.sh.in', + 'strip.sh.in', +- 'sudo.sh.in', + 'vcs.sh.in', + ] + diff --git a/packages/pacman/makepkg.conf.in.patch b/packages/pacman/makepkg.conf.in.patch new file mode 100644 index 000000000..15c2f0827 --- /dev/null +++ b/packages/pacman/makepkg.conf.in.patch @@ -0,0 +1,48 @@ +diff -uNr pacman-6.0.0/etc/makepkg.conf.in pacman-termux/etc/makepkg.conf.in +--- pacman-6.0.0/etc/makepkg.conf.in 2021-05-20 06:38:45.938120000 +0300 ++++ pacman-termux/etc/makepkg.conf.in 2021-10-04 16:00:39.000000000 +0300 +@@ -9,17 +9,17 @@ + # + #-- The download utilities that makepkg should use to acquire sources + # Format: 'protocol::agent' +-DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u' +- 'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' +- 'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' +- 'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' +- 'rsync::/usr/bin/rsync --no-motd -z %u %o' +- 'scp::/usr/bin/scp -C %u %o') ++DLAGENTS=('file::@TERMUX_PREFIX@/bin/curl -gqC - -o %o %u' ++ 'ftp::@TERMUX_PREFIX@/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' ++ 'http::@TERMUX_PREFIX@/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' ++ 'https::@TERMUX_PREFIX@/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' ++ 'rsync::@TERMUX_PREFIX@/bin/rsync --no-motd -z %u %o' ++ 'scp::@TERMUX_PREFIX@/bin/scp -C %u %o') + + # Other common tools: +-# /usr/bin/snarf +-# /usr/bin/lftpget -c +-# /usr/bin/wget ++# @TERMUX_PREFIX@/bin/snarf ++# @TERMUX_PREFIX@/bin/lftpget -c0 ++# @TERMUX_PREFIX@/bin/wget + + #-- The package required by makepkg to download VCS sources + # Format: 'protocol::package' +@@ -92,7 +92,7 @@ + OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug !lto) + + #-- File integrity checks to use. Valid: ck, md5, sha1, sha224, sha256, sha384, sha512, b2 +-INTEGRITY_CHECK=(ck) ++INTEGRITY_CHECK=(sha256) + #-- Options to be used when stripping binaries. See `man strip' for details. + STRIP_BINARIES="@STRIP_BINARIES@" + #-- Options to be used when stripping shared libraries. See `man strip' for details. +@@ -106,7 +106,7 @@ + #-- Files to be removed from all packages (if purge is specified) + PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) + #-- Directory to store source code in for debug packages +-DBGSRCDIR="/usr/src/debug" ++DBGSRCDIR="@TERMUX_PREFIX@/src/debug" + + ######################################################################### + # PACKAGE OUTPUT diff --git a/packages/pacman/makepkg.sh.in.patch b/packages/pacman/makepkg.sh.in.patch new file mode 100644 index 000000000..8376dc3bf --- /dev/null +++ b/packages/pacman/makepkg.sh.in.patch @@ -0,0 +1,164 @@ +diff -uNr pacman-6.0.0/scripts/makepkg.sh.in pacman-termux/scripts/makepkg.sh.in +--- pacman-6.0.0/scripts/makepkg.sh.in 2021-05-20 06:38:45.954786500 +0300 ++++ pacman-termux/scripts/makepkg.sh.in 2021-10-04 16:00:39.000000000 +0300 +@@ -26,7 +26,7 @@ + + # makepkg uses quite a few external programs during its execution. You + # need to have at least the following installed for makepkg to function: +-# awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, file, find (findutils), ++# awk, bsdtar (libarchive), bzip2, coreutils, file, find (findutils), + # gettext, gpg, grep, gzip, sed, tput (ncurses), xz + + # gettext initialization +@@ -59,7 +59,7 @@ + GENINTEG=0 + HOLDVER=0 + IGNOREARCH=0 +-INFAKEROOT=0 ++PKGCREATION=0 + INSTALL=0 + LOGGING=0 + NEEDED=0 +@@ -105,7 +105,7 @@ + trap_exit() { + local signal=$1; shift + +- if (( ! INFAKEROOT )); then ++ if (( ! PKGCREATION )); then + echo + error "$@" + fi +@@ -123,7 +123,7 @@ + clean_up() { + local EXIT_CODE=$? + +- if (( INFAKEROOT )); then ++ if (( PKGCREATION )); then + # Don't clean up when leaving fakeroot, we're not done yet. + return 0 + fi +@@ -179,9 +179,9 @@ + fi + } + +-enter_fakeroot() { +- msg "$(gettext "Entering %s environment...")" "fakeroot" +- fakeroot -- bash -$- "${BASH_SOURCE[0]}" -F "${ARGLIST[@]}" || exit $? ++pkg_creation() { ++ msg "$(gettext "Package creation...")" ++ "${BASH_SOURCE[0]}" -F "${ARGLIST[@]}" || exit $? + } + + # Automatically update pkgver variable if a pkgver() function is provided +@@ -237,10 +237,6 @@ + else + cmd=("${PACMAN_AUTH[@]}" "${cmd[@]}") + fi +- elif type -p sudo >/dev/null; then +- cmd=(sudo "${cmd[@]}") +- else +- cmd=(su root -c "$cmdescape") + fi + local lockfile="$(pacman-conf DBPath)/db.lck" + while [[ -f $lockfile ]]; do +@@ -597,7 +593,6 @@ + merge_arch_attrs + + printf "# Generated by makepkg %s\n" "$makepkg_version" +- printf "# using %s\n" "$(fakeroot -v)" + + write_kv_pair "pkgname" "$pkgname" + write_kv_pair "pkgbase" "$pkgbase" +@@ -939,7 +934,7 @@ + + run_single_packaging() { + local pkgdir="$pkgdirbase/$pkgname" +- mkdir "$pkgdir" ++ mkdir -p "$terdir" + if [[ -n $1 ]] || (( PKGFUNC )); then + run_package $1 + fi +@@ -1071,7 +1066,7 @@ + -d|--nodeps) NODEPS=1 ;; + -e|--noextract) NOEXTRACT=1 ;; + -f|--force) FORCE=1 ;; +- -F) INFAKEROOT=1 ;; ++ -F) PKGCREATION=1 ;; + # generating integrity checks does not depend on architecture + -g|--geninteg) BUILDPKG=0 GENINTEG=1 IGNOREARCH=1;; + --holdver) HOLDVER=1 ;; +@@ -1186,17 +1181,10 @@ + exit $E_FS_PERMISSIONS + fi + +-if (( ! INFAKEROOT )); then +- if (( EUID == 0 )); then +- error "$(gettext "Running %s as root is not allowed as it can cause permanent,\n\ ++if (( EUID == 0 )); then ++ error "$(gettext "Running %s as root is not allowed as it can cause permanent,\n\ + catastrophic damage to your system.")" "makepkg" +- exit $E_ROOT +- fi +-else +- if [[ -z $FAKEROOTKEY ]]; then +- error "$(gettext "Do not use the %s option. This option is only for internal use by %s.")" "'-F'" "makepkg" +- exit $E_INVALID_OPTION +- fi ++ exit $E_ROOT + fi + + unset pkgname "${pkgbuild_schema_strings[@]}" "${pkgbuild_schema_arrays[@]}" +@@ -1252,6 +1240,13 @@ + # set pkgdir to something "sensible" for (not recommended) use during build() + pkgdir="$pkgdirbase/$pkgbase" + ++# the second pkgdir but from the termux system directory ++terdir="$pkgdir/@TERMUX_BASE_DIR@" ++ ++# adding home and prefix to compile correctly ++prefix="@TERMUX_PREFIX@" ++home="@TERMUX_HOME@" ++ + if (( GENINTEG )); then + mkdir -p "$srcdir" + chmod a-s "$srcdir" +@@ -1320,10 +1315,10 @@ + fi + + # Run the bare minimum in fakeroot +-if (( INFAKEROOT )); then ++if (( PKGCREATION )); then + if (( SOURCEONLY )); then + create_srcpackage +- msg "$(gettext "Leaving %s environment.")" "fakeroot" ++ msg "$(gettext "Package creation.")" + exit $E_OK + fi + +@@ -1338,7 +1333,7 @@ + + create_debug_package + +- msg "$(gettext "Leaving %s environment.")" "fakeroot" ++ msg "$(gettext "Package creation.")" + exit $E_OK + fi + +@@ -1365,7 +1360,7 @@ + check_source_integrity all + cd_safe "$startdir" + +- enter_fakeroot ++ pkg_creation + + if [[ $SIGNPKG = 'y' ]]; then + msg "$(gettext "Signing package...")" +@@ -1467,7 +1462,7 @@ + cd_safe "$startdir" + fi + +- enter_fakeroot ++ pkg_creation + + create_package_signatures || exit $E_PRETTY_BAD_PRIVACY + fi diff --git a/packages/pacman/meson.build.patch b/packages/pacman/meson.build.patch new file mode 100644 index 000000000..84c7d2073 --- /dev/null +++ b/packages/pacman/meson.build.patch @@ -0,0 +1,32 @@ +diff -uNr pacman-6.0.0/meson.build pacman-termux/meson.build +--- pacman-6.0.0/meson.build 2021-05-20 06:38:45.948119900 +0300 ++++ pacman-termux/meson.build 2021-10-04 16:00:39.000000000 +0300 +@@ -4,9 +4,9 @@ + license : 'GPLv2+', + default_options : [ + 'c_std=gnu99', +- 'prefix=/usr', +- 'sysconfdir=/etc', +- 'localstatedir=/var', ++ 'prefix=@TERMUX_PREFIX@', ++ 'sysconfdir=@TERMUX_PREFIX@/etc', ++ 'localstatedir=@TERMUX_PREFIX@/var', + ], + meson_version : '>= 0.51') + +@@ -76,15 +76,6 @@ + conf.set_quoted('ROOTDIR', ROOTDIR) + + libintl = dependency('', required: false) +-if get_option('i18n') +- if not cc.has_function('ngettext') +- libintl = cc.find_library('intl', required : false, static: get_option('buildstatic')) +- if not libintl.found() +- error('ngettext not found but NLS support requested') +- endif +- endif +- conf.set('ENABLE_NLS', 1) +-endif + + # dependencies + libarchive = dependency('libarchive', diff --git a/packages/pacman/meson_options.txt.patch b/packages/pacman/meson_options.txt.patch new file mode 100644 index 000000000..58f8079d7 --- /dev/null +++ b/packages/pacman/meson_options.txt.patch @@ -0,0 +1,32 @@ +diff -uNr pacman-6.0.0/meson_options.txt pacman-termux/meson_options.txt +--- pacman-6.0.0/meson_options.txt 2021-05-20 06:38:45.948119900 +0300 ++++ pacman-termux/meson_options.txt 2021-10-04 16:00:39.000000000 +0300 +@@ -8,16 +8,16 @@ + option('root-dir', type : 'string', value : '/', + description : 'set the location of the root operating directory') + +-option('pkg-ext', type : 'string', value : '.pkg.tar.gz', ++option('pkg-ext', type : 'string', value : '.pkg.tar.xz', + description : 'set the file extension used by packages') + + option('src-ext', type : 'string', value : '.src.tar.gz', + description : 'set the file extension used by source packages') + +-option('scriptlet-shell', type : 'string', value : '/bin/sh', ++option('scriptlet-shell', type : 'string', value : '@TERMUX_PREFIX@/bin/bash', + description : 'The full path of the shell used to run install scriptlets') + +-option('ldconfig', type : 'string', value : '/sbin/ldconfig', ++option('ldconfig', type : 'string', value : '@TERMUX_PREFIX@/bin/ldconfig', + description : 'set the full path to ldconfig') + + option('buildscript', type : 'string', value : 'PKGBUILD', +@@ -26,7 +26,7 @@ + option('datarootdir', type : 'string', value : 'share', + description : 'FIXME') + +-option('makepkg-template-dir', type : 'string', value : '/usr/share/makepkg-template', ++option('makepkg-template-dir', type : 'string', value : '@TERMUX_PREFIX@/share/makepkg-template', + description : 'template dir used by makepkg-template') + + option('debug-suffix', type : 'string', value : 'debug', diff --git a/packages/pacman/pacman-key.sh.in.patch b/packages/pacman/pacman-key.sh.in.patch new file mode 100644 index 000000000..7aea5bf7e --- /dev/null +++ b/packages/pacman/pacman-key.sh.in.patch @@ -0,0 +1,15 @@ +diff -uNr pacman-6.0.0/scripts/pacman-key.sh.in pacman-termux/scripts/pacman-key.sh.in +--- pacman-6.0.0/scripts/pacman-key.sh.in 2021-05-20 06:38:45.954786500 +0300 ++++ pacman-termux/scripts/pacman-key.sh.in 2021-10-04 16:00:39.000000000 +0300 +@@ -670,11 +670,6 @@ + exit 1 + fi + +-if (( (ADD || DELETE || EDITKEY || IMPORT || IMPORT_TRUSTDB || INIT || LSIGNKEY || POPULATE || RECEIVE || REFRESH || UPDATEDB) && EUID != 0 )); then +- error "$(gettext "%s needs to be run as root for this operation.")" "pacman-key" +- exit 1 +-fi +- + CONFIG=${CONFIG:-@sysconfdir@/pacman.conf} + if [[ ! -r "${CONFIG}" ]]; then + error "$(gettext "%s configuration file '%s' not found.")" "pacman" "$CONFIG" diff --git a/packages/pacman/pacman.c.patch b/packages/pacman/pacman.c.patch new file mode 100644 index 000000000..3c9ef01bf --- /dev/null +++ b/packages/pacman/pacman.c.patch @@ -0,0 +1,25 @@ +diff -uNr pacman-6.0.0/src/pacman/pacman.c pacman-termux/src/pacman/pacman.c +--- pacman-6.0.0/src/pacman/pacman.c 2021-05-20 06:38:45.964786500 +0300 ++++ pacman-termux/src/pacman/pacman.c 2021-10-04 16:00:39.000000000 +0300 +@@ -1131,8 +1131,8 @@ + } + + /* check if we have sufficient permission for the requested operation */ +- if(myuid > 0 && needs_root()) { +- pm_printf(ALPM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n")); ++ if(myuid == 0) { ++ pm_printf(ALPM_LOG_ERROR, _("blocking operation, you can not run from the root of the user.\n")); + cleanup(EXIT_FAILURE); + } + +@@ -1236,9 +1236,7 @@ + } + + /* Log command line */ +- if(needs_root()) { +- cl_to_log(argc, argv); +- } ++ cl_to_log(argc, argv); + + /* start the requested operation */ + switch(config->op) { diff --git a/packages/pacman/pacman.conf.in.patch b/packages/pacman/pacman.conf.in.patch new file mode 100644 index 000000000..dda68c734 --- /dev/null +++ b/packages/pacman/pacman.conf.in.patch @@ -0,0 +1,80 @@ +diff -uNr pacman-6.0.0/etc/pacman.conf.in pacman-termux/etc/pacman.conf.in +--- pacman-6.0.0/etc/pacman.conf.in 2021-05-20 06:38:45.938120000 +0300 ++++ pacman-termux/etc/pacman.conf.in 2021-10-04 16:03:29.000000000 +0300 +@@ -9,20 +9,20 @@ + [options] + # The following paths are commented out with their default values listed. + # If you wish to use different paths, uncomment and update the paths. +-#RootDir = @ROOTDIR@ ++#RootDir = / + #DBPath = @localstatedir@/lib/pacman/ + #CacheDir = @localstatedir@/cache/pacman/pkg/ + #LogFile = @localstatedir@/log/pacman.log + #GPGDir = @sysconfdir@/pacman.d/gnupg/ + #HookDir = @sysconfdir@/pacman.d/hooks/ +-HoldPkg = pacman glibc +-#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +-#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u ++#XferCommand = @TERMUX_PREFIX@/bin/curl -L -C - -f -o %o %u ++#XferCommand = @TERMUX_PREFIX@/bin/wget --passive-ftp -c -O %o %u ++HoldPkg = pacman + #CleanMethod = KeepInstalled + Architecture = auto + + # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup + #IgnorePkg = + #IgnoreGroup = + + #NoUpgrade = +@@ -30,16 +30,21 @@ + + # Misc options + #UseSyslog +-#Color ++Color + #NoProgressBar + CheckSpace + #VerbosePkgLists + ParallelDownloads = 5 + +-# PGP signature checking +-#SigLevel = Optional +-#LocalFileSigLevel = Optional +-#RemoteFileSigLevel = Optional ++# By default, pacman accepts packages signed by keys that its local keyring ++# trusts (see pacman-key and its man page), as well as unsigned packages. ++SigLevel = Never ++LocalFileSigLevel = Optional ++#RemoteFileSigLevel = Required ++ ++# NOTE: You must run `pacman-key --init` before first using pacman; the local ++# keyring can then be populated with the keys of all official Arch Linux ARM ++# packagers with `pacman-key --populate archlinuxarm`. + + # + # REPOSITORIES +@@ -60,18 +65,9 @@ + # uncommented to enable the repo. + # + +-# An example of a disabled remote package repository with multiple servers +-# available. To enable, uncomment the following lines. You can add preferred +-# servers immediately after the header and they will be used before the +-# default mirrors. +-#[core] +-#SigLevel = Required +-#Server = ftp://ftp.example.com/foobar/$repo/os/$arch/ +-# The file referenced here should contain a list of 'Server = ' lines. +-#Include = @sysconfdir@/pacman.d/mirrorlist +- +-# An example of a custom package repository. See the pacman manpage for +-# tips on creating your own repositories. +-#[custom] +-#SigLevel = Optional TrustAll +-#Server = file:///home/custompkgs ++# The testing repositories are disabled by default. To enable, uncomment the ++# repo name header and Include lines. You can add preferred servers immediately ++# after the header, and they will be used before the default mirrors. ++ ++[main] ++Server = https://maxython.github.io/termux-packages-in-pacman-format/main/$arch diff --git a/packages/pacman/repo-add.sh.in.patch b/packages/pacman/repo-add.sh.in.patch new file mode 100644 index 000000000..1e0b76fb2 --- /dev/null +++ b/packages/pacman/repo-add.sh.in.patch @@ -0,0 +1,12 @@ +diff -uNr pacman-6.0.0/scripts/repo-add.sh.in pacman-termux/scripts/repo-add.sh.in +--- pacman-6.0.0/scripts/repo-add.sh.in 2021-05-20 06:38:45.961453200 +0300 ++++ pacman-termux/scripts/repo-add.sh.in 2021-10-04 16:00:39.000000000 +0300 +@@ -585,7 +585,7 @@ + exit 1 + fi + +-tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/repo-tools.XXXXXXXXXX") || (\ ++tmpdir=$(mktemp -d "${TMPDIR:-@TERMUX_PREFIX@/tmp}/repo-tools.XXXXXXXXXX") || (\ + error "$(gettext "Cannot create temp directory for database building.")"; \ + exit 1) + diff --git a/packages/pacman/trans.c.patch b/packages/pacman/trans.c.patch new file mode 100644 index 000000000..74ec20dfe --- /dev/null +++ b/packages/pacman/trans.c.patch @@ -0,0 +1,22 @@ +diff -uNr pacman-6.0.0/lib/libalpm/trans.c pacman-termux/lib/libalpm/trans.c +--- pacman-6.0.0/lib/libalpm/trans.c 2021-05-20 06:38:45.948119900 +0300 ++++ pacman-termux/lib/libalpm/trans.c 2021-10-04 16:00:39.000000000 +0300 +@@ -353,14 +353,14 @@ + strcpy(arg0, SCRIPTLET_SHELL); + strcpy(arg1, "-c"); + +- /* create a directory in $root/tmp/ for copying/extracting the scriptlet */ +- len = strlen(handle->root) + strlen("tmp/alpm_XXXXXX") + 1; ++ /* create a directory in @TERMUX_PREFIX@/tmp/ for copying/extracting the scriptlet */ ++ len = strlen("@TERMUX_PREFIX@/tmp/alpm_XXXXXX") + 1; + MALLOC(tmpdir, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); +- snprintf(tmpdir, len, "%stmp/", handle->root); ++ snprintf(tmpdir, len, "@TERMUX_PREFIX@/tmp/"); + if(access(tmpdir, F_OK) != 0) { + _alpm_makepath_mode(tmpdir, 01777); + } +- snprintf(tmpdir, len, "%stmp/alpm_XXXXXX", handle->root); ++ snprintf(tmpdir, len, "@TERMUX_PREFIX@/tmp/alpm_XXXXXX"); + if(mkdtemp(tmpdir) == NULL) { + _alpm_log(handle, ALPM_LOG_ERROR, _("could not create temp directory\n")); + free(tmpdir); diff --git a/packages/pacman/util.c.patch b/packages/pacman/util.c.patch new file mode 100644 index 000000000..0de1d0e34 --- /dev/null +++ b/packages/pacman/util.c.patch @@ -0,0 +1,32 @@ +diff -uNr pacman-6.0.0/lib/libalpm/util.c pacman-termux/lib/libalpm/util.c +--- pacman-6.0.0/lib/libalpm/util.c 2021-05-20 06:38:45.948119900 +0300 ++++ pacman-termux/lib/libalpm/util.c 2021-10-04 16:00:39.000000000 +0300 +@@ -650,10 +650,6 @@ + } + + /* use fprintf instead of _alpm_log to send output through the parent */ +- if(chroot(handle->root) != 0) { +- fprintf(stderr, _("could not change the root directory (%s)\n"), strerror(errno)); +- exit(1); +- } + if(chdir("/") != 0) { + fprintf(stderr, _("could not change directory to %s (%s)\n"), + "/", strerror(errno)); +@@ -669,7 +665,7 @@ + /* this code runs for the parent only (wait on the child) */ + int status; + char obuf[PIPE_BUF]; /* writes <= PIPE_BUF are guaranteed atomic */ +- char ibuf[LINE_MAX]; ++ char ibuf[PATH_MAX]; + ssize_t olen = 0, ilen = 0; + nfds_t nfds = 2; + struct pollfd fds[2], *child2parent = &(fds[0]), *parent2child = &(fds[1]); +@@ -897,7 +893,7 @@ + if((tmpdir = getenv("TMPDIR")) && stat(tmpdir, &buf) && S_ISDIR(buf.st_mode)) { + /* TMPDIR was good, we can use it */ + } else { +- tmpdir = "/tmp"; ++ tmpdir = "@TERMUX_PREFIX@/tmp"; + } + alpm_option_add_cachedir(handle, tmpdir); + cachedir = handle->cachedirs->prev->data;