Skip to content

Commit 6d5a3a9

Browse files
committed
pear: Overhaul how the package is built.
Stop using go-pear, it performs network access during the install phase, and was a patched version from many years ago with undocumented changes, making it difficult to maintain. Instead use pearweb_phars which bundles all of the required packages and provides a newer installer. Tested on SmartOS, macOS, and NetBSD, with diffs performed between the resulting binaries. There are some additions to pear.conf as a result of us previously using a go-pear that hadn't been updated in over 10 years, but there do not appear to be any regressions. Bump PKGREVISION. Approved during freeze by Benny.
1 parent 6e788ad commit 6d5a3a9

7 files changed

Lines changed: 152 additions & 2437 deletions

File tree

lang/pear/Makefile

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
# $NetBSD: Makefile,v 1.68 2025/06/07 15:58:49 taca Exp $
1+
# $NetBSD: Makefile,v 1.69 2025/06/16 09:21:45 jperkin Exp $
2+
#
3+
# This is super confusing, but the PEAR tarball does not include an installer,
4+
# it is only available in a different installer package which bundles the PEAR
5+
# tarball along with its dependencies. So our distfile is pearweb_phars, and
6+
# we override the version to whatever PEAR it bundles.
27
#
38

4-
DISTNAME= PEAR-1.10.16
5-
PKGREVISION= 2
6-
PKGNAME= ${PHP_PKG_PREFIX}-${DISTNAME:S/PEAR/pear/}
9+
DISTNAME= pearweb_phars-1.10.24
10+
PKGREVISION= 3
11+
PKGNAME= ${PHP_PKG_PREFIX}-pear-1.10.16
712
CATEGORIES= lang
813
MASTER_SITES= http://download.pear.php.net/package/
914
EXTRACT_SUFX= .tgz
@@ -14,11 +19,6 @@ COMMENT= PEAR Base System for PHP
1419
LICENSE= 2-clause-bsd
1520

1621
USE_LANGUAGES= # none
17-
EXTRACT_ONLY= # none
18-
USE_TOOLS+= bsdtar gzcat
19-
20-
# go-pear.php fetch PEAR package information during install phase.
21-
ALLOW_NETWORK_ACCESS= yes
2222

2323
.include "../../lang/php/common.mk"
2424

@@ -28,61 +28,38 @@ PKG_SYSCONFVAR= php
2828
CONF_FILES= ${PREFIX}/${PHP_EGDIR}/pear.conf \
2929
${PKG_SYSCONFDIR}/pear.conf
3030

31-
BUNDLE= ${WRKSRC}/install/go-pear-bundle
32-
33-
# everything else that forms a part of the "base" PEAR install
34-
#
35-
PEAR_SRCS= ${DISTNAME}${EXTRACT_SUFX}
36-
DISTFILES+= ${PEAR_SRCS}
37-
EXTRACT_ONLY+= ${PEAR_SRCS}
38-
39-
ARCHIVE_SRCS= Archive_Tar-1.5.0${EXTRACT_SUFX}
40-
ARCHIVE_WRKSRC= ${WRKDIR}/${ARCHIVE_SRCS:S/${EXTRACT_SUFX}//}
41-
DISTFILES+= ${ARCHIVE_SRCS}
42-
EXTRACT_ONLY+= ${ARCHIVE_SRCS}
43-
44-
CONSOLE_SRCS= Console_Getopt-1.4.3${EXTRACT_SUFX}
45-
CONSOLE_WRKSRC= ${WRKDIR}/${CONSOLE_SRCS:S/${EXTRACT_SUFX}//}
46-
DISTFILES+= ${CONSOLE_SRCS}
47-
EXTRACT_ONLY+= ${CONSOLE_SRCS}
48-
49-
STRUCTURES_SRCS= Structures_Graph-1.2.0${EXTRACT_SUFX}
50-
DISTFILES+= ${STRUCTURES_SRCS}
51-
52-
XMLUTIL_SRCS= XML_Util-1.4.5${EXTRACT_SUFX}
53-
DISTFILES+= ${XMLUTIL_SRCS}
54-
55-
#
56-
# end of base components
57-
5831
SUBST_CLASSES+= config
5932
SUBST_STAGE.config= pre-configure
60-
SUBST_FILES.config= install/go-pear.php PEAR/Config.php
61-
SUBST_VARS.config+= PREFIX PHP_VER PHP_LIBDIR WRKSRC
33+
SUBST_FILES.config= src/PEAR/Start.php
34+
SUBST_VARS.config+= PHP_LIBDIR PKGMANDIR PREFIX WRKSRC
6235
SUBST_MESSAGE.config= Fixing configuration files.
6336

6437
PEAR_COMMANDS= pear peardev pecl
6538
INSTALLATION_DIRS+= ${PHP_EGDIR}
6639

67-
pre-patch:
68-
${RM} ${WRKSRC}/INSTALL
69-
${MKDIR} ${WRKSRC}/install
70-
${MKDIR} ${BUNDLE}
71-
${CP} ${FILESDIR}/go-pear.php ${WRKSRC}/install
72-
${CP} ${WRKSRC}/PEAR.php ${BUNDLE}
40+
# TODO: This should probably be set in lang/php
41+
PHPBIN= ${PREFIX}/bin/php${PHP_VER}
42+
43+
# Unpack the .phar archive so that we can patch the source files.
44+
post-extract:
45+
cd ${WRKSRC} && ${PHPBIN} -d phar.readonly=0 -r \
46+
'$$p = new Phar("go-pear.phar"); \
47+
$$p->extractTo("src");'
48+
${MV} ${WRKSRC}/go-pear.phar ${WRKSRC}/go-pear-orig.phar
7349

50+
# This does not actually build anything, just packs our patched source files
51+
# back to an updated .phar.
7452
do-build:
75-
.for f in ${DISTFILES}
76-
${GZCAT} ${DISTDIR}/${DIST_SUBDIR}/${f} > \
77-
${BUNDLE}/${f:S/${EXTRACT_SUFX}/.tar/}
78-
.endfor
79-
${CP} ${ARCHIVE_WRKSRC}/Archive/Tar.php ${BUNDLE}
80-
${CP} ${CONSOLE_WRKSRC}/Console/Getopt.php ${BUNDLE}
81-
cd ${WRKDIR} && bsdtar -u -f ${BUNDLE}/${DISTNAME}.tar \
82-
${DISTNAME}/PEAR/Config.php
53+
cd ${WRKSRC} && ${PHPBIN} -d phar.readonly=0 -r \
54+
'$$p = new Phar("go-pear.phar", 0, "go-pear.phar"); \
55+
$$p->buildFromDirectory(dirname(__FILE__) . "/src"); \
56+
$$p->setStub($$p->createDefaultStub("index.php"));'
57+
58+
INSTALL_ENV+= PHP_PEAR_PHP_BIN=${PHPBIN}
8359

8460
do-install:
85-
${SETENV} ${INSTALL_ENV} ${PREFIX}/bin/php${PHP_VER} ${WRKSRC}/install/go-pear.php local
61+
cd ${WRKSRC} && \
62+
${PKGSRC_SETENV} ${INSTALL_ENV} ${PHPBIN} go-pear.phar
8663
${INSTALL_DATA} ${WRKSRC}/pear.conf \
8764
${DESTDIR}${PREFIX}/${PHP_EGDIR}/pear.conf
8865

lang/pear/PLIST

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@comment $NetBSD: PLIST,v 1.13 2025/02/08 03:24:29 taca Exp $
1+
@comment $NetBSD: PLIST,v 1.14 2025/06/16 09:21:45 jperkin Exp $
22
bin/pear${PHP_VER}
33
bin/peardev${PHP_VER}
44
bin/pecl${PHP_VER}
@@ -9,8 +9,6 @@ ${PHP_LIBDIR}/.channels/__uri.reg
99
${PHP_LIBDIR}/.channels/doc.php.net.reg
1010
${PHP_LIBDIR}/.channels/pear.php.net.reg
1111
${PHP_LIBDIR}/.channels/pecl.php.net.reg
12-
${PHP_LIBDIR}/.depdb
13-
${PHP_LIBDIR}/.depdblock
1412
${PHP_LIBDIR}/.filemap
1513
${PHP_LIBDIR}/.lock
1614
${PHP_LIBDIR}/.registry/archive_tar.reg

lang/pear/distinfo

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
$NetBSD: distinfo,v 1.51 2025/02/08 03:24:29 taca Exp $
1+
$NetBSD: distinfo,v 1.52 2025/06/16 09:21:45 jperkin Exp $
22

3-
BLAKE2s (Archive_Tar-1.5.0.tgz) = 5002a313cbb8cbc4c614a70a05b71fa249e005a8ced26a4838a4870a92879a38
4-
SHA512 (Archive_Tar-1.5.0.tgz) = 2e586320ee53e05b94d0fd26185362ddd5f4bab5b8adcecc46388c6a10b98bbf187d5ce9156e2677320c319827273d537e33698c3cc27107b8d42f627c4f2880
5-
Size (Archive_Tar-1.5.0.tgz) = 22302 bytes
6-
BLAKE2s (Console_Getopt-1.4.3.tgz) = cfd6a6bffb4138a2273bdab60a7cfd4ea7ce2fc41d9141790811fc32f4e915f7
7-
SHA512 (Console_Getopt-1.4.3.tgz) = 7803e063576e9dac6833064b5a1479d22ca31c2a8ef8036ae530271e4e824fedb94e54d63266be8929f90f8df745b3ada7185dc98319b331f8dc5e9cac5445a0
8-
Size (Console_Getopt-1.4.3.tgz) = 5789 bytes
9-
BLAKE2s (PEAR-1.10.16.tgz) = f24408045867a932230286096be5e8e1ea88bedf0c21bbb8e4b6f0f4037d4b43
10-
SHA512 (PEAR-1.10.16.tgz) = 274e642a1c606e0caa9f4c9e4c5fcca69b92b8bcc952dfcb7b8bc1e249eaf04eed2d2caddafe3f722760a723fc1a7d851a404d32115a95f3c3157c91300f0b7b
11-
Size (PEAR-1.10.16.tgz) = 293781 bytes
12-
BLAKE2s (Structures_Graph-1.2.0.tgz) = 81409c9b91c63cd3121d7ddb30f129bb1b9f2d241d59918a5b35d16fd146d743
13-
SHA512 (Structures_Graph-1.2.0.tgz) = a256e6be4ac2011678942d97e39975973aed8b8dbab535325810ae97fb322a4aaac8daf1302f34f239a2b38649ddb39c1ae0a8c325aa1c6cbd90208adf9973dc
14-
Size (Structures_Graph-1.2.0.tgz) = 12507 bytes
15-
BLAKE2s (XML_Util-1.4.5.tgz) = c866e4cec481ea5ce876dfc4f5410fc389f5f2326e5fec638a51ac75eda02661
16-
SHA512 (XML_Util-1.4.5.tgz) = dd373c15ea8057e1a31953a10d75a4821bb9ad63d55ec5ccdbe17c114895ac9b9a57871d50f9f83bca7e3920b461417aa09063cb06051834996d4a8aebfa84c9
17-
Size (XML_Util-1.4.5.tgz) = 19191 bytes
18-
SHA1 (patch-PEAR_Config.php) = e67fe5191cf13ebd582c70944ad723bbbf676183
3+
BLAKE2s (pearweb_phars-1.10.24.tgz) = 6e6b480f76485871130f8a6974808f96957a8506feaa64e8435c3406d44f5c19
4+
SHA512 (pearweb_phars-1.10.24.tgz) = 64b81b84b815f46cabebd5bba57ce67e86fbec9208e19438997e70dde9fdeaab5f517d2fb92889954f51040627f3188e9a37d86fa796dd51c65d38d804309cc5
5+
Size (pearweb_phars-1.10.24.tgz) = 1205796 bytes
6+
SHA1 (patch-src_PEAR_Start.php) = d8038a23e5250e8b2c0a022ba5e8adfd73d1fcd7
7+
SHA1 (patch-src_PEAR_Start_CLI.php) = 8dbd68bde4cea2c7688a4dc0e650cff8ccdeda4c

0 commit comments

Comments
 (0)