head	1.1;
access;
symbols
	pkgsrc-2026Q1:1.1.0.8
	pkgsrc-2026Q1-base:1.1
	pkgsrc-2025Q4:1.1.0.6
	pkgsrc-2025Q4-base:1.1
	pkgsrc-2025Q3:1.1.0.4
	pkgsrc-2025Q3-base:1.1
	pkgsrc-2025Q2:1.1.0.2
	pkgsrc-2025Q2-base:1.1;
locks; strict;
comment	@# @;


1.1
date	2025.06.16.09.21.45;	author jperkin;	state Exp;
branches;
next	;
commitid	IKHvWOn2XshX06ZF;


desc
@@


1.1
log
@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.
@
text
@$NetBSD$

Use pkgsrc layout.

--- src/PEAR/Start.php.orig	2025-06-11 14:08:51.952589560 +0000
+++ src/PEAR/Start.php
@@@@ -6,6 +6,7 @@@@ require_once 'phar://go-pear.phar/' . 'P
 require_once 'phar://go-pear.phar/' . 'PEAR/Common.php';
 class PEAR_Start extends PEAR
 {
+    var $destdir;
     var $bin_dir;
     var $data_dir;
     var $cfg_dir;
@@@@ -146,33 +147,19 @@@@ class PEAR_Start extends PEAR
                 }
             }
         } else {
-            $this->prefix = dirname(PHP_BINDIR);
-            $this->pear_conf = PEAR_CONFIG_SYSCONFDIR . '/pear.conf';
-            if ($this->getCurrentUser() != 'root') {
-                $this->prefix = $this->safeGetenv('HOME') . '/pear';
-                $this->pear_conf = $this->safeGetenv('HOME') . '.pearrc';
-            }
+            $this->destdir = getenv('DESTDIR');
+            $this->pear_conf = '@@WRKSRC@@/pear.conf';
+            $this->prefix = "@@PREFIX@@";
             $this->bin_dir   = '$prefix/bin';
-            $this->php_dir   = '$prefix/share/pear';
+            $this->php_dir   = '$prefix/@@PHP_LIBDIR@@';
             $this->temp_dir  = '/tmp/pear/install';
             $this->download_dir  = '/tmp/pear/install';
-            $this->doc_dir   = '$prefix/docs';
-            $this->www_dir   = '$prefix/www';
-            $this->cfg_dir   = '$prefix/cfg';
-            $this->data_dir  = '$prefix/data';
-            $this->test_dir  = '$prefix/tests';
-            $this->man_dir  = '$prefix/man';
-            // check if the user has installed PHP with PHP or GNU layout
-            if (@@is_dir("$this->prefix/lib/php/.registry")) {
-                $this->php_dir = '$prefix/lib/php';
-            } elseif (@@is_dir("$this->prefix/share/pear/lib/.registry")) {
-                $this->php_dir = '$prefix/share/pear/lib';
-                $this->doc_dir   = '$prefix/share/pear/docs';
-                $this->data_dir  = '$prefix/share/pear/data';
-                $this->test_dir  = '$prefix/share/pear/tests';
-            } elseif (@@is_dir("$this->prefix/share/php/.registry")) {
-                $this->php_dir = '$prefix/share/php';
-            }
+            $this->doc_dir   = '$php_dir/doc';
+            $this->www_dir   = '$php_dir/www';
+            $this->cfg_dir   = '$php_dir/cfg';
+            $this->data_dir  = '$php_dir/data';
+            $this->test_dir  = '$php_dir/test';
+            $this->man_dir  = '$prefix/@@PKGMANDIR@@';
         }
     }
 
@@@@ -335,6 +322,7 @@@@ class PEAR_Start extends PEAR
         $install = &PEAR_Command::factory('install', $this->PEARConfig);
         print "Preparing to install...\n";
         $options = array(
+            'packagingroot' => $this->destdir,
             'nodeps' => true,
             'force' => true,
             'upgrade' => true,
@@@@ -355,7 +343,7 @@@@ class PEAR_Start extends PEAR
         }
 
         foreach ($this->config as $var) {
-            $dir = $this->$var;
+            $dir = ($this->destdir ? $this->destdir : '').$this->$var;
 
             if (!preg_match('/_dir\\z/', $var)) {
                 continue;
@
