summaryrefslogtreecommitdiff
path: root/www/php4
diff options
context:
space:
mode:
authorjdolecek <jdolecek@pkgsrc.org>2004-04-03 04:39:47 +0000
committerjdolecek <jdolecek@pkgsrc.org>2004-04-03 04:39:47 +0000
commit84f7588d1dc882cb9eab2b5152166a26e41d6b6f (patch)
tree33795f9cec176cab4e93b37a003472dca7f5e77a /www/php4
parent85bc7daddf378b686c276a24d1ee129e2b65efaf (diff)
downloadpkgsrc-84f7588d1dc882cb9eab2b5152166a26e41d6b6f.tar.gz
generate the PLIST for Pear packages using a helper PHP script, which
can use directly Pear facilities to acquire the necessary information
Diffstat (limited to 'www/php4')
-rw-r--r--www/php4/pear.mk25
-rw-r--r--www/php4/pear_plist.php50
2 files changed, 58 insertions, 17 deletions
diff --git a/www/php4/pear.mk b/www/php4/pear.mk
index eb0ac409c6e..3d37f64fab6 100644
--- a/www/php4/pear.mk
+++ b/www/php4/pear.mk
@@ -1,4 +1,4 @@
-# $NetBSD: pear.mk,v 1.4 2004/04/02 21:54:49 jdolecek Exp $
+# $NetBSD: pear.mk,v 1.5 2004/04/03 04:39:47 jdolecek Exp $
#
# This Makefile fragment is intended to be included by packages that build
# and install pear packages.
@@ -33,25 +33,16 @@ MASTER_SITES+= ${MASTER_SITE_PEAR_PACKAGE}
PEAR_CMD= ${PREFIX}/bin/pear
PEAR_LIB= lib/php
-_PEAR_PKG= ${DISTNAME:C/-.*//}
+# whether @dirrm for baseinstalldir should be included in PLIST
+PEAR_DIRRM_BASEDIR?= # empty
-# Changed to not use :tl modifier since that's currently NetBSD 1.6-only
-_PEAR_PKG_LC!= ${ECHO} ${_PEAR_PKG} | ${TR} '[A-Z]' '[a-z]'
-
-# Dynamic PLIST
-# The package.xml 'parsing' is a bit crude, but enough for now. Eventually
-# should write a small PHP script for this, using real XML parser.
+# Dynamic PLIST, generated via a helper PHP script, which parses the package
+# XML config file.
PEAR_GENERATE_PLIST= \
${ECHO} "@comment The following lines are automatically generated"; \
- ${ECHO} "${PEAR_LIB}/.registry/${_PEAR_PKG_LC}.reg"; \
- ${FGREP} '<file role="php"' ${WRKDIR}/package.xml | ${SED} -e 's,.*<file role="php",<,' -e 's,<.*baseinstalldir="\([^"]*\)",\1/<,' -e 's,<.* name=",,' -e 's,".*,,' -e "s,^/*,${PEAR_LIB}/,"; \
- ${FGREP} '<file role="php"' ${WRKDIR}/package.xml | ${SED} -e 's,.*<file role="php",<,' -e 's,<.*baseinstalldir="\([^"]*\)",\1/<,' -e 's,<.* name=",,' -e 's,".*,,' -e 's,//*,/,g' -e 's,/[^/]*$$,,' | ${FGREP} '/' | ${SORT} -ru | ${SED} -e "s,^,@dirrm ${PEAR_LIB},"; \
- ${FGREP} '<file role="doc"' ${WRKDIR}/package.xml | ${SED} -e 's,.*<file role="doc",<,' -e 's,<.*baseinstalldir="\([^"]*\)",\1/<,' -e 's,<.* name=",,' -e 's,".*,,' -e "s,^/*,${PEAR_LIB}/doc/${_PEAR_PKG}/,"; \
- ${FGREP} '<file role="doc"' ${WRKDIR}/package.xml | ${SED} -e 's,.*<file role="doc",<,' -e 's,<.*baseinstalldir="\([^"]*\)",\1/<,' -e 's,<.* name=",,' -e 's,".*,,' -e 's,//*,/,g' -e 's,/[^/]*$$,,' | ${FGREP} '/' | ${SORT} -ru | ${SED} -e "s,^,@dirrm ${PEAR_LIB}/doc/${_PEAR_PKG},"; \
- ${FGREP} -q '<file role="doc"' ${WRKDIR}/package.xml && echo "@dirrm ${PEAR_LIB}/doc/${_PEAR_PKG}"; \
- ${FGREP} '<file role="test"' ${WRKDIR}/package.xml | ${SED} -e 's,.*<file role="test",<,' -e 's,<.*baseinstalldir="\([^"]*\)",\1/<,' -e 's,<.* name=",,' -e 's,".*,,' -e "s,^/*,${PEAR_LIB}/test/${_PEAR_PKG}/,"; \
- ${FGREP} '<file role="test"' ${WRKDIR}/package.xml | ${SED} -e 's,.*<file role="test",<,' -e 's,<.*baseinstalldir="\([^"]*\)",\1/<,' -e 's,<.* name=",,' -e 's,".*,,' -e 's,//*,/,g' -e 's,/[^/]*$$,,' | ${FGREP} '/' | ${SORT} -ru | ${SED} -e "s,^,@dirrm ${PEAR_LIB}/test/${_PEAR_PKG},"; \
- ${FGREP} -q '<file role="test"' ${WRKDIR}/package.xml && echo "@dirrm ${PEAR_LIB}/test/${_PEAR_PKG}";
+ PEAR_LIB="${PEAR_LIB}" WRKSRC="${WRKSRC}" \
+ PEAR_DIRRM_BASEDIR="${PEAR_DIRRM_BASEDIR}" \
+ ${PREFIX}/bin/php ${PKGDIR}/../../www/php4/pear_plist.php;
GENERATE_PLIST+= ${PEAR_GENERATE_PLIST}
NO_BUILD= # defined
diff --git a/www/php4/pear_plist.php b/www/php4/pear_plist.php
new file mode 100644
index 00000000000..fc23bc99336
--- /dev/null
+++ b/www/php4/pear_plist.php
@@ -0,0 +1,50 @@
+<?php
+# $NetBSD: pear_plist.php,v 1.1 2004/04/03 04:39:47 jdolecek Exp $
+# Parses package XML file and outputs appropriate PLIST
+
+$PEAR_LIB = getenv('PEAR_LIB');
+$WRKSRC = getenv('WRKSRC');
+$PEAR_DIRRM_BASEDIR = getenv('PEAR_DIRRM_BASEDIR');
+$dirrm = array();
+
+include_once "PEAR/Common.php";
+$obj = &new PEAR_Common;
+$info = $obj->infoFromAny("$WRKSRC/package.xml");
+$pkg = $info['package'];
+
+// output list of package files, in same order as specified in package
+echo "$PEAR_LIB/.registry/".strtolower($pkg).".reg\n";
+foreach($info['filelist'] as $f => $v) {
+ switch($v['role']) {
+ case 'test':
+ case 'doc':
+ $prefix = "$v[role]/$pkg/";
+ $dirrm["$v[role]/$pkg"] = true;
+ break;
+
+ case 'php':
+ default:
+ if (!empty($v['baseinstalldir']) && $v['baseinstalldir'] != '/') {
+ $prefix = $v['baseinstalldir'] . '/';
+
+ if ($PEAR_DIRRM_BASEDIR)
+ $dirrm[$v['baseinstalldir']] = true;
+ } else
+ $prefix = '';
+ break;
+ }
+
+
+ echo "{$PEAR_LIB}/{$prefix}{$f}\n";
+
+ while(($f = dirname($f)) && $f != '.')
+ $dirrm["{$prefix}{$f}"] = true;
+}
+
+// output @dirrm directives, in reverse order so that deeper
+// directories are removed first
+$dirrm = array_keys($dirrm);
+rsort($dirrm);
+foreach($dirrm as $dir)
+ echo "@dirrm {$PEAR_LIB}/$dir\n";
+?>