[arch-commits] Commit in perl/repos (12 files)

Levente Polyak anthraxx at gemini.archlinux.org
Sat Nov 13 21:04:34 UTC 2021


    Date: Saturday, November 13, 2021 @ 21:04:33
  Author: anthraxx
Revision: 428378

archrelease: copy trunk to testing-x86_64

Added:
  perl/repos/testing-x86_64/
  perl/repos/testing-x86_64/CVE-2016-2381_duplicate_env.diff
    (from rev 428377, perl/trunk/CVE-2016-2381_duplicate_env.diff)
  perl/repos/testing-x86_64/PKGBUILD
    (from rev 428377, perl/trunk/PKGBUILD)
  perl/repos/testing-x86_64/config.over
    (from rev 428377, perl/trunk/config.over)
  perl/repos/testing-x86_64/detect-old-perl-modules.hook
    (from rev 428377, perl/trunk/detect-old-perl-modules.hook)
  perl/repos/testing-x86_64/detect-old-perl-modules.sh
    (from rev 428377, perl/trunk/detect-old-perl-modules.sh)
  perl/repos/testing-x86_64/generate-rebuild-list.sh
    (from rev 428377, perl/trunk/generate-rebuild-list.sh)
  perl/repos/testing-x86_64/patchprov
    (from rev 428377, perl/trunk/patchprov)
  perl/repos/testing-x86_64/perlbin.csh
    (from rev 428377, perl/trunk/perlbin.csh)
  perl/repos/testing-x86_64/perlbin.fish
    (from rev 428377, perl/trunk/perlbin.fish)
  perl/repos/testing-x86_64/perlbin.sh
    (from rev 428377, perl/trunk/perlbin.sh)
  perl/repos/testing-x86_64/upgpkg
    (from rev 428377, perl/trunk/upgpkg)

----------------------------------+
 CVE-2016-2381_duplicate_env.diff |  104 ++++++++++++++
 PKGBUILD                         |  242 ++++++++++++++++++++++++++++++++++
 config.over                      |    5 
 detect-old-perl-modules.hook     |   10 +
 detect-old-perl-modules.sh       |   36 +++++
 generate-rebuild-list.sh         |   16 ++
 patchprov                        |  260 +++++++++++++++++++++++++++++++++++++
 perlbin.csh                      |   12 +
 perlbin.fish                     |   10 +
 perlbin.sh                       |   15 ++
 upgpkg                           |    4 
 11 files changed, 714 insertions(+)

Copied: perl/repos/testing-x86_64/CVE-2016-2381_duplicate_env.diff (from rev 428377, perl/trunk/CVE-2016-2381_duplicate_env.diff)
===================================================================
--- testing-x86_64/CVE-2016-2381_duplicate_env.diff	                        (rev 0)
+++ testing-x86_64/CVE-2016-2381_duplicate_env.diff	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,104 @@
+From 83e7ebed7afa79a2f50eca6b6330eae7c3a02d36 Mon Sep 17 00:00:00 2001
+From: Tony Cook <tony at develop-help.com>
+Date: Wed, 27 Jan 2016 11:52:15 +1100
+Subject: remove duplicate environment variables from environ
+
+If we see duplicate environment variables while iterating over
+environ[]:
+
+a) make sure we use the same value in %ENV that getenv() returns.
+
+Previously on a duplicate, %ENV would have the last entry for the name
+from environ[], but a typical getenv() would return the first entry.
+
+Rather than assuming all getenv() implementations return the first entry
+explicitly call getenv() to ensure they agree.
+
+b) remove duplicate entries from environ
+
+Previously if there was a duplicate definition for a name in environ[]
+setting that name in %ENV could result in an unsafe value being passed
+to a child process, so ensure environ[] has no duplicates.
+
+Patch-Name: fixes/CVE-2016-2381_duplicate_env.diff
+---
+ perl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 49 insertions(+), 2 deletions(-)
+
+diff --git a/perl.c b/perl.c
+index 80a76c2..ed25429 100644
+--- a/perl.c
++++ b/perl.c
+@@ -4303,23 +4303,70 @@ S_init_postdump_symbols(pTHX_ int argc, char **argv, char **env)
+ 	}
+ 	if (env) {
+ 	  char *s, *old_var;
++          STRLEN nlen;
+ 	  SV *sv;
++          HV *dups = newHV();
++
+ 	  for (; *env; env++) {
+ 	    old_var = *env;
+ 
+ 	    if (!(s = strchr(old_var,'=')) || s == old_var)
+ 		continue;
++            nlen = s - old_var;
+ 
+ #if defined(MSDOS) && !defined(DJGPP)
+ 	    *s = '\0';
+ 	    (void)strupr(old_var);
+ 	    *s = '=';
+ #endif
+-	    sv = newSVpv(s+1, 0);
+-	    (void)hv_store(hv, old_var, s - old_var, sv, 0);
++            if (hv_exists(hv, old_var, nlen)) {
++                const char *name = savepvn(old_var, nlen);
++
++                /* make sure we use the same value as getenv(), otherwise code that
++                   uses getenv() (like setlocale()) might see a different value to %ENV
++                 */
++                sv = newSVpv(PerlEnv_getenv(name), 0);
++
++                /* keep a count of the dups of this name so we can de-dup environ later */
++                if (hv_exists(dups, name, nlen))
++                    ++SvIVX(*hv_fetch(dups, name, nlen, 0));
++                else
++                    (void)hv_store(dups, name, nlen, newSViv(1), 0);
++
++                Safefree(name);
++            }
++            else {
++                sv = newSVpv(s+1, 0);
++            }
++	    (void)hv_store(hv, old_var, nlen, sv, 0);
+ 	    if (env_is_not_environ)
+ 	        mg_set(sv);
+ 	  }
++          if (HvKEYS(dups)) {
++              /* environ has some duplicate definitions, remove them */
++              HE *entry;
++              hv_iterinit(dups);
++              while ((entry = hv_iternext_flags(dups, 0))) {
++                  STRLEN nlen;
++                  const char *name = HePV(entry, nlen);
++                  IV count = SvIV(HeVAL(entry));
++                  IV i;
++                  SV **valp = hv_fetch(hv, name, nlen, 0);
++
++                  assert(valp);
++
++                  /* try to remove any duplicate names, depending on the
++                   * implementation used in my_setenv() the iteration might
++                   * not be necessary, but let's be safe.
++                   */
++                  for (i = 0; i < count; ++i)
++                      my_setenv(name, 0);
++
++                  /* and set it back to the value we set $ENV{name} to */
++                  my_setenv(name, SvPV_nolen(*valp));
++              }
++          }
++          SvREFCNT_dec_NN(dups);
+       }
+ #endif /* USE_ENVIRON_ARRAY */
+ #endif /* !PERL_MICRO */

Copied: perl/repos/testing-x86_64/PKGBUILD (from rev 428377, perl/trunk/PKGBUILD)
===================================================================
--- testing-x86_64/PKGBUILD	                        (rev 0)
+++ testing-x86_64/PKGBUILD	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,242 @@
+# Maintainer: Florian Pritz <bluewind at xinu.at>
+# Contributor: Angel Velasquez <angvp at archlinux.org>
+# Contributor: kevin <kevin.archlinux.org>
+# Contributor: judd <jvinet.zeroflux.org>
+# Contributor: francois <francois.archlinux.org>
+
+pkgname=perl
+pkgver=5.34.0
+_baseversion="${pkgver%.*}"
+pkgrel=3
+pkgdesc="A highly capable, feature-rich programming language"
+arch=(x86_64)
+license=('GPL' 'PerlArtistic')
+url="https://www.perl.org"
+depends=('gdbm>=1.17' 'db' 'glibc' 'libxcrypt' 'libcrypt.so')
+checkdepends=('procps-ng')
+# NOTE: This array is automatically generated by `./patchprov`.
+#       If you want to add entries, do so in the next array.
+provides=('perl-archive-tar=2.38'
+          'perl-attribute-handlers=1.01'
+          'perl-autodie=2.34'
+          'perl-autoloader=5.74'
+          'perl-autouse=1.11'
+          'perl-base=2.27'
+          'perl-bignum=0.51'
+          'perl-carp=1.52'
+          'perl-compress-raw-bzip2=2.101'
+          'perl-compress-raw-zlib=2.101'
+          'perl-config-perl-v=0.33'
+          'perl-constant=1.33'
+          'perl-cpan-meta-requirements=2.140'
+          'perl-cpan-meta-yaml=0.018'
+          'perl-cpan-meta=2.150010'
+          'perl-cpan=2.28'
+          'perl-data-dumper=2.179'
+          'perl-db_file=1.855'
+          'perl-devel-ppport=3.62'
+          'perl-devel-selfstubber=1.06'
+          'perl-digest-md5=2.58'
+          'perl-digest-sha=6.02'
+          'perl-digest=1.19'
+          'perl-dumpvalue=1.21'
+          'perl-encode=3.08'
+          'perl-encoding-warnings=0.13'
+          'perl-env=1.05'
+          'perl-experimental=0.024'
+          'perl-exporter=5.76'
+          'perl-extutils-cbuilder=0.280236'
+          'perl-extutils-constant=0.25'
+          'perl-extutils-install=2.20'
+          'perl-extutils-makemaker=7.62'
+          'perl-extutils-manifest=1.73'
+          'perl-extutils-parsexs=3.43'
+          'perl-extutils-pl2bat=0.004'
+          'perl-file-fetch=1.00'
+          'perl-file-path=2.18'
+          'perl-file-temp=0.2311'
+          'perl-filter-simple=0.96'
+          'perl-filter-util-call=1.60'
+          'perl-findbin=1.52'
+          'perl-getopt-long=2.52'
+          'perl-http-tiny=0.076'
+          'perl-i18n-collate=1.02'
+          'perl-i18n-langtags=0.45'
+          'perl-if=0.0609'
+          'perl-io-compress=2.102'
+          'perl-io-socket-ip=0.41'
+          'perl-io-zlib=1.11'
+          'perl-io=1.46'
+          'perl-ipc-cmd=1.04'
+          'perl-ipc-sysv=2.09'
+          'perl-json-pp=4.06'
+          'perl-lib=0.65'
+          'perl-libnet=3.13'
+          'perl-locale-maketext-simple=0.21_01'
+          'perl-locale-maketext=1.29'
+          'perl-math-bigint-fastcalc=0.5009'
+          'perl-math-bigint=1.999818'
+          'perl-math-bigrat=0.2614'
+          'perl-math-complex=1.5902'
+          'perl-memoize=1.03_01'
+          'perl-mime-base64=3.16'
+          'perl-module-corelist=5.20210520'
+          'perl-module-load-conditional=0.74'
+          'perl-module-load=0.36'
+          'perl-module-loaded=0.08'
+          'perl-module-metadata=1.000037'
+          'perl-net-ping=2.74'
+          'perl-params-check=0.38'
+          'perl-parent=0.238'
+          'perl-pathtools=3.80'
+          'perl-perl-ostype=1.010'
+          'perl-perlfaq=5.20210411'
+          'perl-perlio-via-quotedprint=0.09'
+          'perl-pod-checker=1.74'
+          'perl-pod-escapes=1.07'
+          'perl-pod-perldoc=3.2801'
+          'perl-pod-simple=3.42'
+          'perl-pod-usage=2.01'
+          'perl-podlators=5.008'
+          'perl-safe=2.43'
+          'perl-scalar-list-utils=1.55'
+          'perl-search-dict=1.07'
+          'perl-selfloader=1.26'
+          'perl-socket=2.031'
+          'perl-storable=3.23'
+          'perl-sys-syslog=0.36'
+          'perl-term-ansicolor=5.01'
+          'perl-term-cap=1.17'
+          'perl-term-complete=1.403'
+          'perl-term-readline=1.17'
+          'perl-test-harness=3.43'
+          'perl-test-simple=1.302183'
+          'perl-test=1.31'
+          'perl-text-abbrev=1.02'
+          'perl-text-balanced=2.04'
+          'perl-text-parsewords=3.30'
+          'perl-text-tabs=2013.0523'
+          'perl-thread-queue=3.14'
+          'perl-thread-semaphore=2.13'
+          'perl-threads-shared=1.62'
+          'perl-threads=2.26'
+          'perl-tie-file=1.06'
+          'perl-tie-refhash=1.40'
+          'perl-time-hires=1.9767'
+          'perl-time-local=1.30'
+          'perl-time-piece=1.3401'
+          'perl-unicode-collate=1.29'
+          'perl-unicode-normalize=1.28'
+          'perl-version=0.9928'
+          'perl-xsloader=0.30')
+# Add your own provides here
+provides=("${provides[@]}")
+source=(https://www.cpan.org/src/5.0/perl-${pkgver}.tar.xz
+        perl-18924.patch::https://github.com/Perl/perl5/pull/18924.patch
+        config.over
+        perlbin.sh
+        perlbin.csh
+        perlbin.fish
+        detect-old-perl-modules.sh
+        detect-old-perl-modules.hook)
+options=('makeflags' '!purge' 'emptydirs')
+sha512sums=('691b4b31eacec357191fba777612b4e3eae59e946a22998a50766697c0d61db1d42a9b3bc1e41abf0d1ca1893e4a7c06d7bf3290480cf03d7f79befd7a8a3267'
+            '58f99cfdc762270a41d85afe37239e9a9837142254e8c83bcd67386fabd71f60ede4a02b2b06e4afade7d5452e54f696b4640b76f48f8ec5599e8637b4fbedeb'
+            '1c924b5bf7413d097f62638a574d7decf36d98598b84cdb5fb31ff633b6f953371e14b004a2558a1a0b74b6b60b90b481af0f68555a49208fe6b226381fed79f'
+            '6ed5bc6dbdc47bc7f4c0fedbe18deaf35ab02a2e6700988beb545954bb1d0fe20ff1a4de39d6d9fc882ef1741f7bf6d85ba165d0cd8dc0d9939b789c894f48a1'
+            '53eb0cddfd637014f3d3a101665db8dcafe5ac5bf3d319a259974334eb89c1c405097518ae96b6d18e520194633c7be57c9b2cd9ae6398443eb08f1a2008d112'
+            '881e2efe05ba818cd7300f126800b56bb0685cb5c9c5fb7e67ef6aaf5abd17d2391a979d5d16d109c5111f4b35504ba83d19b0e6eda4431e8421fcbea19d2f1a'
+            'bd48af7a6209f2ad51aa1747a7238ecb11607a53f61460d873202bf14b55c3b7dd6f66f4a9f2cac8a24240313789a9a44dbc81b73587de46a6b1866bdfca5e26'
+            '063624b6fc3728339e4f352597e6913c476c4eaa8e1004b2a46c480b5cce9c42f3083d1e6960081202099acf2b7d0b5d13dc6b7ee0aa303c272826febdcd311e')
+# https://www.cpan.org/src/5.0/perl-$pkgver.tar.xz.sha256.txt
+
+prepare() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+
+  patch -p1 -i "$srcdir/perl-18924.patch"
+
+  # reproducible patchlevel_date
+  [ -n "${SOURCE_DATE_EPOCH}" ] && touch -h -d @$SOURCE_DATE_EPOCH patchlevel.h
+}
+
+build() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+
+  if [ "${CARCH}" = "x86_64" ]; then
+    # for x86_64
+    arch_opts="-Dcccdlflags='-fPIC'"
+  else
+    # for i686
+    arch_opts=""
+  fi
+
+  # reproducible builds overrides are only fully effective when loaded from file
+  cp ../config.over .
+
+  export TZ=UTC
+  ./Configure -des -Dusethreads -Duseshrplib -Doptimize="${CFLAGS}" \
+    -Dprefix=/usr -Dvendorprefix=/usr \
+    -Dprivlib=/usr/share/perl5/core_perl \
+    -Darchlib=/usr/lib/perl5/$_baseversion/core_perl \
+    -Dsitelib=/usr/share/perl5/site_perl \
+    -Dsitearch=/usr/lib/perl5/$_baseversion/site_perl \
+    -Dvendorlib=/usr/share/perl5/vendor_perl \
+    -Dvendorarch=/usr/lib/perl5/$_baseversion/vendor_perl \
+    -Dscriptdir=/usr/bin/core_perl \
+    -Dsitescript=/usr/bin/site_perl \
+    -Dvendorscript=/usr/bin/vendor_perl \
+    -Dinc_version_list=none \
+    -Dman1ext=1perl -Dman3ext=3perl ${arch_opts} \
+    -Dlddlflags="-shared ${LDFLAGS}" -Dldflags="${LDFLAGS}"
+  make
+}
+
+check() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+#  TEST_JOBS=$(echo "$MAKEFLAGS" | sed 's/.*-j\([0-9][0-9]*\).*/\1/') make test_harness
+  make test
+}
+
+package() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+  make DESTDIR="$pkgdir" install
+
+  ### Perl Settings ###
+  # Change man page extensions for site and vendor module builds.
+  # Set no mail address since bug reports should go to the bug tracker
+  # and not someone's email.
+  sed -e '/^man1ext=/ s/1perl/1p/' -e '/^man3ext=/ s/3perl/3pm/' \
+      -e "/^cf_email=/ s/'.*'/''/" \
+      -e "/^perladmin=/ s/'.*'/''/" \
+      -i "${pkgdir}/usr/lib/perl5/$_baseversion/core_perl/Config_heavy.pl"
+
+  ### CPAN Settings ###
+  # Set CPAN default config to use the site directories.
+  sed -e '/(makepl_arg =>/   s/""/"INSTALLDIRS=site"/' \
+      -e '/(mbuildpl_arg =>/ s/""/"installdirs=site"/' \
+      -i "${pkgdir}/usr/share/perl5/core_perl/CPAN/FirstTime.pm"
+
+  # Profile script to set paths to perl scripts.
+  install -D -m644 "${srcdir}/perlbin.sh" \
+                   "${pkgdir}/etc/profile.d/perlbin.sh"
+  # Profile script to set paths to perl scripts on csh. (FS#22441)
+  install -D -m644 "${srcdir}/perlbin.csh" \
+                  "${pkgdir}/etc/profile.d/perlbin.csh"
+  # Profile script to set paths to perl scripts on fish. (FS#51191)
+  install -D -m 755 "$srcdir/perlbin.fish" \
+                  "$pkgdir/usr/share/fish/vendor_conf.d/perlbin.fish"
+
+  # Add the dirs so new installs will already have them in PATH once they
+  # install their first perl programm
+  install -d -m755 "$pkgdir/usr/bin/vendor_perl"
+  install -d -m755 "$pkgdir/usr/bin/site_perl"
+
+  #(cd ${pkgdir}/usr/bin; mv perl${pkgver} perl)
+  rm "$pkgdir/usr/bin/perl$pkgver"
+
+  install -D -m755 -t "$pkgdir/usr/share/libalpm/scripts" "$srcdir/detect-old-perl-modules.sh"
+  install -D -m644 -t "$pkgdir/usr/share/libalpm/hooks" "$srcdir/detect-old-perl-modules.hook"
+
+  find "$pkgdir" -name perllocal.pod -delete
+  find "$pkgdir" -name .packlist -delete
+}

Copied: perl/repos/testing-x86_64/config.over (from rev 428377, perl/trunk/config.over)
===================================================================
--- testing-x86_64/config.over	                        (rev 0)
+++ testing-x86_64/config.over	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,5 @@
+#!/bin/sh
+osvers="5.12.15-arch1-1"
+myuname="archlinux"
+myhostname="archlinux"
+cf_time="`date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}"`"

Copied: perl/repos/testing-x86_64/detect-old-perl-modules.hook (from rev 428377, perl/trunk/detect-old-perl-modules.hook)
===================================================================
--- testing-x86_64/detect-old-perl-modules.hook	                        (rev 0)
+++ testing-x86_64/detect-old-perl-modules.hook	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,10 @@
+[Trigger]
+Operation = Install
+Operation = Upgrade
+Type = Path
+Target = usr/lib/perl5/*/
+
+[Action]
+Description = Warn about old perl modules
+When = PostTransaction
+Exec = /usr/share/libalpm/scripts/detect-old-perl-modules.sh

Copied: perl/repos/testing-x86_64/detect-old-perl-modules.sh (from rev 428377, perl/trunk/detect-old-perl-modules.sh)
===================================================================
--- testing-x86_64/detect-old-perl-modules.sh	                        (rev 0)
+++ testing-x86_64/detect-old-perl-modules.sh	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+basedir=/usr/lib/perl5
+perlver=$(perl -e '$v = $^V->{version}; print $v->[0].".".($v->[1]);')
+
+dir_empty() {
+	local dir=$1
+	[[ $(find $dir -maxdepth 0 -empty -exec echo empty \;) = "empty" ]] && return 0 || return 1
+}
+
+print_unowned_files() {
+	local dir=$1
+	LC_ALL=C find "$dir" -type f -exec pacman -Qqo {} + |& sed -n 's/^error: No package owns \(.*\)$/\1/p'
+}
+
+for dir in "$basedir/"*; do
+	if [[ "${dir##*/}" != "$perlver" ]]; then
+		if [[ -d "$dir" ]] && ! dir_empty "$dir"; then
+			pkgcount=$(pacman -Qqo "$dir" | wc -l)
+			if ((pkgcount > 0)); then
+				printf "WARNING: '%s' contains data from at least %d packages which will NOT be used by the installed perl interpreter.\n" "$dir" "$pkgcount"
+				printf " -> Run the following command to get a list of affected packages: pacman -Qqo '%s'\n" "$dir"
+			fi
+
+			unowned_count=$(print_unowned_files "$dir" | wc -l)
+			if ((unowned_count > 0)); then
+				printf "WARNING: %d file(s) in %s are not tracked by pacman and need to be rebuilt.\n" "$unowned_count" "$dir"
+				printf " -> These were most likely installed directly by cpan or a similar tool.\n"
+				printf "    Run the following command to get a list of these files:\n"
+				printf "    LC_ALL=C find \"%s\" -type f -exec pacman -Qqo {} + |& sed -n 's/^error: No package owns \(.*\)$/\\\1/p'\n" "$dir"
+			fi
+		fi
+	fi
+done
+
+

Copied: perl/repos/testing-x86_64/generate-rebuild-list.sh (from rev 428377, perl/trunk/generate-rebuild-list.sh)
===================================================================
--- testing-x86_64/generate-rebuild-list.sh	                        (rev 0)
+++ testing-x86_64/generate-rebuild-list.sh	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -euo pipefail
+
+echo "vim"
+
+pkgfile -rd "^/usr/lib/perl5/" | sed 's#^.*/##' | sort -u
+
+ssh build.archlinux.org sogrep -r
+for repo in core extra community multilib; do
+	ssh build.archlinux.org sogrep "$repo" libperl.so
+done
+
+# this one is optional
+#pkgfile -r '^/usr/share/perl5/'  | sed 's#^.*/##' | sort -u
+

Copied: perl/repos/testing-x86_64/patchprov (from rev 428377, perl/trunk/patchprov)
===================================================================
--- testing-x86_64/patchprov	                        (rev 0)
+++ testing-x86_64/patchprov	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,260 @@
+#!/usr/bin/perl
+##
+## Name:
+## patchprov
+##
+## Description:
+## Patch the provides list in the perl package PKGBUILD. Scan the appropriate
+## directories under the perl source tree for directories containing dists
+## similar to CPAN dists. Search the files in the distributions for VERSION
+## strings, which are perl expressions. Filters these version strings through
+## the perl interpreter, then transform the dist. names and versions into
+## package names and versions. Finally, we cut out the "provides" array from the
+## PKGBUILD and replace it with the newer version.
+##
+## Usage:
+## patchprov [path to perl source tree] [path to PKGBUILD]
+##
+## Caveats:
+## The path code is not platform independent and will only work in POSIX.
+##
+## Changelog:
+## 06/10/14 JD Rewrite from scratch for perl 5.20.0 and ArchLinux.
+##
+## Authors:
+## Justin "juster" Davis <jrcd83 at gmail.com>
+##
+
+use warnings;
+use strict;
+
+sub err
+{
+    print STDERR "patchprov: error: @_\n";
+    exit 1;
+}
+
+## Extract the dist. name from its containing directory.
+sub path_dist
+{
+    my($path) = @_;
+    $path =~ s{^.*/}{};
+    return $path;
+}
+
+## Create a path like $path/lib/Foo/Bar.pm for Foo::Bar.
+sub lib_modpath
+{
+    my($path, $modname) = @_;
+    $modname =~ s{::}{/}g;
+    return "$path/lib/$modname.pm";
+}
+
+## Create a path to a file in the containing directory, named after
+## the last segment of the module name, with suffix attached.
+sub dumb_modpath
+{
+    my($path, $modname, $suffix) = @_;
+    $modname =~ s{^.*::}{};
+    return "$path/$modname$suffix";
+}
+
+## Find a source file contained in the directory that we can scrape the
+## perl versions string from.
+my %distmods = (
+    'PathTools' => 'Cwd',
+    'Scalar-List-Utils' => 'List::Util',
+    'IO-Compress' => 'IO::Compress::Gzip',
+);
+sub dist_srcpath
+{
+    my($path) = @_;
+    my $distname = path_dist($path);
+    my $modname;
+    if(exists $distmods{$distname}){
+        $modname = $distmods{$distname};
+    }else{
+        $modname = $distname;
+        $modname =~ s/-/::/g;
+    }
+    my @srcpaths = (
+        lib_modpath($path, $modname),
+        dumb_modpath($path, $modname, '.pm'),
+        dumb_modpath($path, $modname, '_pm.PL'),
+        dumb_modpath($path, '__'.$modname.'__', '.pm'),
+        "$path/VERSION", # for podlators
+    );
+    for my $src (@srcpaths){
+        return $src if(-f $src);
+    }
+    return undef;
+}
+
+## Scrape the version string for the module file or Makefile.PL.
+sub scrape_verln
+{
+    my($srcpath) = @_;
+    open my $fh, '<', $srcpath or die "open: $!";
+    while(my $ln = <$fh>){
+        if($ln =~ s/^.*VERSION *=>? *//){
+            close $fh;
+            return $ln;
+        }
+    }
+    close $fh;
+    err("failed to find VERSION in $srcpath");
+}
+
+## Scrape the version string from the module source file.
+sub scrape_modver
+{
+    my($srcpath) = @_;
+    return scrape_verln($srcpath);
+}
+
+## Scrape the version string from the Makefile.PL. (for libnet)
+sub scrape_mkplver
+{
+    my($srcpath) = @_;
+    my $verln = scrape_verln($srcpath);
+    $verln =~ s/,/;/;
+    return $verln;
+}
+
+## Scrape the version string from a file inside the dist dir.
+sub distpath_ver
+{
+    my($distpath) = @_;
+    my $srcpath = dist_srcpath($distpath);
+    my $mkplpath = "$distpath/Makefile.PL";
+    if(defined $srcpath){
+        return scrape_modver($srcpath);
+    }elsif(-f $mkplpath){
+        return scrape_mkplver($mkplpath);
+    }else{
+        err("failed to scrape version from $distpath");
+    }
+}
+
+## Search the base path for the dist dirs and extract their respective
+## version strings.
+sub find_distvers
+{
+    my($basepath) = @_;
+    opendir my $dh, $basepath or die "opendir: $!";
+    my @dirs = grep { -d $_ } map { "$basepath/$_" } grep { !/^[.]/ } readdir $dh;
+    closedir $dh;
+
+    my @distvers;
+    for my $dpath (@dirs){
+        push @distvers, [ path_dist($dpath), distpath_ver($dpath) ];
+    }
+    return @distvers;
+}
+
+## Maps an aref of dist name/perl version strings (perl expressions) to
+## a package name and version string suitable for a PKGBUILD.
+sub pkgspec
+{
+    my($dist, $ver) = @$_;
+    $dist =~ tr/A-Z/a-z/;
+    $ver = eval $ver;
+    return "perl-$dist=$ver";
+}
+
+## Searches the perl source dir provided for a list of packages which
+## correspond to the core distributions bundled within in.
+sub perlcorepkgs
+{
+    my($perlpath) = @_;
+    my @dirs = ("$perlpath/cpan", "$perlpath/dist");
+    my @provs;
+    for my $d (@dirs){
+        if(!-d $d){
+            err("$d is not a valid directory");
+        }
+        push @provs, map pkgspec, find_distvers($d);
+    }
+    return @provs;
+}
+
+## Formats the provided lines into a neatly formatted bash array. The first arg
+## is the name of the bash variable to assign it to.
+sub basharray
+{
+    my $vname = shift;
+
+    ## Sort entries and surround with quotes.
+    my @lns = sort map { qq{'$_'} } @_;
+    $lns[0] = "$vname=($lns[0]";
+
+    ## Indent lines for OCD geeks.
+    if(@lns > 1){
+        my $ind = length($vname) + 2;
+        splice @lns, 1, @lns-1,
+            map { (' ' x $ind) . $_ } @lns[1 .. $#lns];
+    }
+
+    $lns[$#lns] .= ')';
+    return map { "$_\n" } @lns;
+}
+
+## Patch the PKGBUILD at the given path with a new provides array, overwriting
+## the old one.
+sub patchpb
+{
+    my $pbpath = shift;
+    open my $fh, '<', $pbpath or die "open: $!";
+    my @lines = <$fh>;
+    close $fh;
+
+    my($i, $j);
+    for($i = 0; $i < @lines; $i++){
+        last if($lines[$i] =~ /^provides=/);
+    }
+    if($i == @lines){
+        err("failed to find provides array in PKGBUILD");
+    }
+    for($j = $i; $j < @lines; $j++){
+        last if($lines[$j] =~ /[)]/);
+    }
+    if($j == @lines){
+        err("failed to find end of provides array");
+    }
+
+    splice @lines, $i, $j-$i+1,
+        basharray('provides', grep { !/win32|next/ } @_);
+
+    ## Avoid corrupting the existing PKGBUILD in case of a crash, etc.
+    if(-f "$pbpath.$$"){
+        err("pbpath.$$ temporary file already exists, please remove it.");
+    }
+    open $fh, '>', "$pbpath.$$" or die "open: $!";
+    print $fh @lines;
+    close $fh or die "close: $!";
+    rename "$pbpath.$$", "$pbpath" or die "rename: $!";
+
+    return;
+}
+
+## Program entrypoint.
+sub main
+{
+    if(@_ < 2){
+        print STDERR "usage: $0 [perl source path] [PKGBUILD path]\n";
+        exit 2;
+    }
+    my($perlpath, $pbpath) = @_;
+    if(!-f $pbpath){
+        err("$pbpath is not a valid file.");
+    }elsif(!-d $perlpath){
+        err("$perlpath is not a valid directory.");
+    }else{
+        patchpb($pbpath, perlcorepkgs($perlpath));
+    }
+    exit 0;
+}
+
+main(@ARGV);
+
+# EOF

Copied: perl/repos/testing-x86_64/perlbin.csh (from rev 428377, perl/trunk/perlbin.csh)
===================================================================
--- testing-x86_64/perlbin.csh	                        (rev 0)
+++ testing-x86_64/perlbin.csh	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,12 @@
+# Set path to perl scriptdirs if they exist
+# https://wiki.archlinux.org/index.php/Perl_Policy#Binaries_and_scripts
+# Added /usr/bin/*_perl dirs for scripts
+
+[ -d /usr/bin/site_perl ] && setenv PATH ${PATH}:/usr/bin/site_perl
+
+[ -d /usr/bin/vendor_perl ] && setenv PATH ${PATH}:/usr/bin/vendor_perl
+
+[ -d /usr/bin/core_perl ] && setenv PATH ${PATH}:/usr/bin/core_perl
+
+# If you have modules in non-standard directories you can add them here.
+#export PERLLIB=dir1:dir2

Copied: perl/repos/testing-x86_64/perlbin.fish (from rev 428377, perl/trunk/perlbin.fish)
===================================================================
--- testing-x86_64/perlbin.fish	                        (rev 0)
+++ testing-x86_64/perlbin.fish	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,10 @@
+# Set path to perl scriptdirs if they exist
+# https://wiki.archlinux.org/index.php/Perl_Policy#Binaries_and_scripts
+
+if status --is-login
+    for perldir in /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl
+        if test -d $perldir; and not contains $perldir $PATH
+            set PATH $PATH $perldir
+        end
+    end
+end

Copied: perl/repos/testing-x86_64/perlbin.sh (from rev 428377, perl/trunk/perlbin.sh)
===================================================================
--- testing-x86_64/perlbin.sh	                        (rev 0)
+++ testing-x86_64/perlbin.sh	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,15 @@
+# Set path to perl scriptdirs if they exist
+# https://wiki.archlinux.org/index.php/Perl_Policy#Binaries_and_scripts
+# Added /usr/bin/*_perl dirs for scripts
+
+[ -d /usr/bin/site_perl ] && append_path '/usr/bin/site_perl'
+
+[ -d /usr/bin/vendor_perl ] && append_path '/usr/bin/vendor_perl'
+
+[ -d /usr/bin/core_perl ] && append_path '/usr/bin/core_perl'
+
+export PATH
+
+# If you have modules in non-standard directories you can add them here.
+#export PERLLIB=dir1:dir2
+

Copied: perl/repos/testing-x86_64/upgpkg (from rev 428377, perl/trunk/upgpkg)
===================================================================
--- testing-x86_64/upgpkg	                        (rev 0)
+++ testing-x86_64/upgpkg	2021-11-13 21:04:33 UTC (rev 428378)
@@ -0,0 +1,4 @@
+upgpkg_build() {
+  makepkg -o
+  ./patchprov src/perl-$pkgver PKGBUILD
+}



More information about the arch-commits mailing list