pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/www/php4 generate the PLIST for Pear packages using a ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/1a491e36b78b
branches:  trunk
changeset: 472052:1a491e36b78b
user:      jdolecek <jdolecek%pkgsrc.org@localhost>
date:      Sat Apr 03 04:39:47 2004 +0000

description:
generate the PLIST for Pear packages using a helper PHP script, which
can use directly Pear facilities to acquire the necessary information

diffstat:

 www/php4/pear.mk        |  25 +++++++----------------
 www/php4/pear_plist.php |  50 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 17 deletions(-)

diffs (96 lines):

diff -r 232c602b3a5d -r 1a491e36b78b www/php4/pear.mk
--- a/www/php4/pear.mk  Fri Apr 02 23:41:50 2004 +0000
+++ b/www/php4/pear.mk  Sat Apr 03 04:39:47 2004 +0000
@@ -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 @@
 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 -r 232c602b3a5d -r 1a491e36b78b www/php4/pear_plist.php
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/www/php4/pear_plist.php   Sat Apr 03 04:39:47 2004 +0000
@@ -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";
+?>



Home | Main Index | Thread Index | Old Index