diff --git a/Archive_Tar-1.4.14.tgz b/Archive_Tar-1.4.14.tgz new file mode 100644 index 0000000..3bfc635 Binary files /dev/null and b/Archive_Tar-1.4.14.tgz differ diff --git a/Console_Getopt-1.4.3.tgz b/Console_Getopt-1.4.3.tgz new file mode 100644 index 0000000..f77a49d Binary files /dev/null and b/Console_Getopt-1.4.3.tgz differ diff --git a/PEAR-1.10.12.tgz b/PEAR-1.10.12.tgz new file mode 100644 index 0000000..8cdd9bd Binary files /dev/null and b/PEAR-1.10.12.tgz differ diff --git a/PEAR_Manpages-1.10.0.tgz b/PEAR_Manpages-1.10.0.tgz new file mode 100644 index 0000000..64c195f Binary files /dev/null and b/PEAR_Manpages-1.10.0.tgz differ diff --git a/Structures_Graph-1.1.1.tgz b/Structures_Graph-1.1.1.tgz new file mode 100644 index 0000000..b870266 Binary files /dev/null and b/Structures_Graph-1.1.1.tgz differ diff --git a/XML_Util-1.4.5.tgz b/XML_Util-1.4.5.tgz new file mode 100644 index 0000000..2a22592 Binary files /dev/null and b/XML_Util-1.4.5.tgz differ diff --git a/cleanup.php b/cleanup.php new file mode 100644 index 0000000..9dde7c8 --- /dev/null +++ b/cleanup.php @@ -0,0 +1,33 @@ + [ + 'pecl.php.net' => [ + 'doc_dir' => "$data/doc/pecl", + 'test_dir' => "$data/tests/pecl", + ] + ] +]; + +$input = file_get_contents($file); +list($header, $config) = explode("\n", $input); +$config = unserialize($config); + +foreach ($remove as $key) unset($config[$key]); +$config = array_merge($config, $add); +$config = serialize($config); + +file_put_contents($file, "$header\n$config"); + diff --git a/install-pear.php b/install-pear.php new file mode 100644 index 0000000..3d2bb37 --- /dev/null +++ b/install-pear.php @@ -0,0 +1,343 @@ +getLayers(); +foreach ($config_layers as $layer) { + if ($layer == 'default') continue; + $config->removeLayer($layer); +} +$keys = $config->getKeys(); +if ($debug) { + $config->set('verbose', 5, 'default'); +} else { + $config->set('verbose', 0, 'default'); +} +// PEAR executables +if (!empty($bin_dir)) { + $config->set('bin_dir', $bin_dir, 'default'); +} + +// Cache files +if (!empty($cache_dir)) { + $config->set('cache_dir', $cache_dir, 'default'); +} + +// Config files +if (!empty($cfg_dir)) { + $config->set('cfg_dir', $cfg_dir, 'default'); +} + +// Web files +if (!empty($www_dir)) { + $config->set('www_dir', $www_dir, 'default'); +} + +// Manual pages +if (!empty($man_dir)) { + $config->set('man_dir', $man_dir, 'default'); +} + +// Downloaded files +if (!empty($download_dir)) { + $config->set('download_dir', $download_dir, 'default'); +} + +// Temporary files +if (!empty($temp_dir)) { + $config->set('temp_dir', $temp_dir, 'default'); +} + +// Documentation files +if (!empty($doc_dir)) { + $config->set('doc_dir', $doc_dir, 'default'); +} + +// Data files +if (!empty($data_dir)) { + $config->set('data_dir', $data_dir, 'default'); +} + +// Unit tests +if (!empty($test_dir)) { + $config->set('test_dir', $test_dir, 'default'); +} + +// User supplied a dir prefix +if (!empty($with_dir)) { + $ds = DIRECTORY_SEPARATOR; + $config->set('php_dir', $with_dir, 'default'); + + // Metadata + if (!empty($metadata_dir)) { + $config->set('metadata_dir', $metadata_dir, 'default'); + } + if (empty($doc_dir)) { + $config->set('doc_dir', $with_dir . $ds . 'doc', 'default'); + } + if (empty($data_dir)) { + $config->set('data_dir', $with_dir . $ds . 'data', 'default'); + } + if (empty($test_dir)) { + $config->set('test_dir', $with_dir . $ds . 'test', 'default'); + } + if (empty($www_dir)) { + $config->set('www_dir', $with_dir . $ds . 'htdocs', 'default'); + } + if (empty($cfg_dir)) { + $config->set('cfg_dir', $with_dir . $ds . 'cfg', 'default'); + } + if (empty($man_dir)) { + $config->set('man_dir', $with_dir . $ds . 'local' . $ds . 'man', 'default'); + } + if (!is_writable($config->get('cache_dir'))) { + include_once 'System.php'; + $cdir = System::mktemp(array('-d', 'pear')); + if (PEAR::isError($cdir)) { + $ui->outputData("[PEAR] cannot make new temporary directory: " . $cdir); + die(1); + } + $oldcachedir = $config->get('cache_dir'); + $config->set('cache_dir', $cdir); + } +} + +// PHP executable +if (!empty($php_bin)) { + $config->set('php_bin', $php_bin); +} + +// PHP prefix +if (isset($prefix)) { + if ($prefix != 'a') { + if ($prefix[0] == 'a') { + $prefix = substr($prefix, 1); + } + $config->set('php_prefix', $prefix, 'system'); + } +} + +// PHP suffix +if (isset($suffix)) { + if ($suffix != 'a') { + if ($suffix[0] == 'a') { + $suffix = substr($suffix, 1); + } + $config->set('php_suffix', $suffix, 'system'); + } +} + +/* Print PEAR Conf (useful for debugging do NOT REMOVE) */ +if ($debug) { + sort($keys); + foreach ($keys as $key) { + echo $key . ' ' . + $config->getPrompt($key) . ": " . $config->get($key, null, 'default') . "\n"; + } + if ($debug == 2) { // extreme debugging + exit; + } +} +// end print + +$php_dir = $config->get('php_dir'); +$options = array(); +$options['upgrade'] = true; +$install_root = getenv('INSTALL_ROOT'); +if (!empty($install_root)) { + $options['packagingroot'] = $install_root; + $reg = new PEAR_Registry($options['packagingroot'], false, false, $metadata_dir); +} else { + $reg = $config->getRegistry('default'); +} + +$ui = PEAR_Frontend::singleton('PEAR_Frontend_CLI'); +if (PEAR::isError($ui)) { + die($ui->getMessage()); +} +$installer = new PEAR_Installer($ui); +$pkg = new PEAR_PackageFile($config, $debug); + +foreach ($install_files as $package => $instfile) { + $info = $pkg->fromAnyFile($instfile, PEAR_VALIDATE_INSTALLING); + if (PEAR::isError($info)) { + if (is_array($info->getUserInfo())) { + foreach ($info->getUserInfo() as $err) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err['message'])); + } + } + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage())); + continue; + } + $new_ver = $info->getVersion(); + $downloaderpackage = new PEAR_Downloader_Package($installer); + $err = $downloaderpackage->initialize($instfile); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + if ($reg->packageExists($package)) { + $old_ver = $reg->packageInfo($package, 'version'); + if (version_compare($new_ver, $old_ver, 'gt')) { + $installer->setOptions($options); + $dp = array($downloaderpackage); + $installer->setDownloadedPackages($dp); + $err = $installer->install($downloaderpackage, $options); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + $ui->outputData(sprintf("[PEAR] %-15s- upgraded: %s", $package, $new_ver)); + } else { + if ($force) { + $options['force'] = true; + $installer->setOptions($options); + $dp = array($downloaderpackage); + $installer->setDownloadedPackages($dp); + $err = $installer->install($downloaderpackage, $options); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver)); + } else { + $ui->outputData(sprintf("[PEAR] %-15s- already installed: %s", $package, $old_ver)); + } + } + } else { + $options['nodeps'] = true; + $installer->setOptions($options); + $dp = array($downloaderpackage); + $installer->setDownloadedPackages($dp); + $err = $installer->install($downloaderpackage, $options); + if (PEAR::isError($err)) { + $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); + continue; + } + $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver)); + } + if ($package == 'PEAR') { + if (is_file($ufile = $config->getConfFile('user'))) { + $ui->outputData('Warning! a PEAR user config file already exists from ' . + 'a previous PEAR installation at ' . + "'$ufile'. You may probably want to remove it."); + } + $config->set('verbose', 1, 'default'); + if (isset($oldcachedir)) { + $config->set('cache_dir', $oldcachedir); + } + $data = array(); + foreach ($config->getKeys() as $key) { + $data[$key] = $config->get($key); + } + $cnf_file = $config->getConfFile('system'); + if (!empty($install_root)) { + $cnf_file = $install_root . DIRECTORY_SEPARATOR . $cnf_file; + } + $config->writeConfigFile($cnf_file, 'system', $data); + $ui->outputData('Wrote PEAR system config file at: ' . $cnf_file); + $ui->outputData('You may want to add: ' . $config->get('php_dir') . ' to your php.ini include_path'); + } +} +?> diff --git a/macros.pear b/macros.pear new file mode 100644 index 0000000..83fad9d --- /dev/null +++ b/macros.pear @@ -0,0 +1,36 @@ +# +# Define full path to pear/pecl commands to be used in scriptlets: +# +%__pear @BINDIR@/pear +%__pecl @BINDIR@/pecl + +# +# Define PEAR directories used in php-pear-* spec files +# +%pear_phpdir %(%{__pear} config-get php_dir 2> /dev/null || echo undefined) +%pear_docdir %(%{__pear} config-get doc_dir 2> /dev/null || echo undefined) +%pear_testdir %(%{__pear} config-get test_dir 2> /dev/null || echo undefined) +%pear_datadir %(%{__pear} config-get data_dir 2> /dev/null || echo undefined) +%pear_cfgdir %(%{__pear} config-get cfg_dir 2> /dev/null || echo undefined) +%pear_wwwdir %(%{__pear} config-get www_dir 2> /dev/null || echo undefined) +%pear_metadir %(%{__pear} config-get metadata_dir 2> /dev/null || echo undefined) + +# +# Define PECL directories used in php-pecl-* spec files: +# +%pecl_phpdir %(%{__pecl} config-get php_dir 2> /dev/null || echo undefined) +%pecl_docdir %(%{__pecl} config-get doc_dir 2> /dev/null || echo undefined) +%pecl_testdir %(%{__pecl} config-get test_dir 2> /dev/null || echo undefined) +%pecl_datadir %(%{__pecl} config-get data_dir 2> /dev/null || echo undefined) + +# +# Define XML directories to store PEAR package registration information: +# pecl_xmldir is now defined in macros.php (from php-devel) +# +%pear_xmldir @LIBDIR@/pear/pkgxml + +# +# Define noop macros for old scriplets used in php-pecl-* spec files: +# +%pecl_install : +%pecl_uninstall : diff --git a/pear.sh b/pear.sh new file mode 100644 index 0000000..218014a --- /dev/null +++ b/pear.sh @@ -0,0 +1,12 @@ +#!/bin/sh +exec /usr/bin/php -C \ + -d include_path=/usr/share/pear \ + -d date.timezone=UTC \ + -d output_buffering=1 \ + -d variables_order=EGPCS \ + -d safe_mode=0 \ + -d register_argc_argv="On" \ + -d open_basedir="" \ + -d auto_prepend_file="" \ + -d auto_append_file="" \ + /usr/share/pear/pearcmd.php "$@" diff --git a/peardev.sh b/peardev.sh new file mode 100644 index 0000000..340c31b --- /dev/null +++ b/peardev.sh @@ -0,0 +1,13 @@ +#!/bin/sh +exec /usr/bin/php -C -q \ + -d memory_limit="-1" \ + -d include_path=/usr/share/pear \ + -d date.timezone=UTC \ + -d output_buffering=1 \ + -d variables_order=EGPCS \ + -d safe_mode=0 \ + -d register_argc_argv="On" \ + -d open_basedir="" \ + -d auto_prepend_file="" \ + -d auto_append_file="" \ + /usr/share/pear/pearcmd.php "$@" diff --git a/pecl.sh b/pecl.sh new file mode 100644 index 0000000..f150dd0 --- /dev/null +++ b/pecl.sh @@ -0,0 +1,9 @@ +#!/bin/sh +exec /usr/bin/php -C \ + -d include_path=/usr/share/pear \ + -d date.timezone=UTC \ + -d output_buffering=1 \ + -d variables_order=EGPCS \ + -d safe_mode=0 \ + -d register_argc_argv="On" \ + /usr/share/pear/peclcmd.php "$@" diff --git a/php-pear.spec b/php-pear.spec new file mode 100644 index 0000000..9c22355 --- /dev/null +++ b/php-pear.spec @@ -0,0 +1,195 @@ +%global peardir %{_datadir}/pear +%global metadir %{_localstatedir}/lib/pear +%global getoptver 1.4.3 +%global arctarver 1.4.14 +%global structver 1.1.1 +%global xmlutil 1.4.5 +%global manpages 1.10.0 +%global with_tests 0%{?_with_tests:1} +%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) +%{!?pecl_xmldir: %global pecl_xmldir %{_sharedstatedir}/php/peclxml} +Summary: PHP Extension and Application Repository framework +Name: php-pear +Version: 1.10.12 +Release: 1 +Epoch: 1 +License: BSD and LGPLv3+ +URL: http://pear.php.net/package/PEAR +Source0: http://download.pear.php.net/package/PEAR-%{version}%{?pearprever}.tgz +Source1: install-pear.php +Source3: cleanup.php +Source10: pear.sh +Source11: pecl.sh +Source12: peardev.sh +Source13: macros.pear +Source21: http://pear.php.net/get/Archive_Tar-%{arctarver}.tgz +Source22: http://pear.php.net/get/Console_Getopt-%{getoptver}.tgz +Source23: http://pear.php.net/get/Structures_Graph-%{structver}.tgz +Source24: http://pear.php.net/get/XML_Util-%{xmlutil}.tgz +Source25: http://pear.php.net/get/PEAR_Manpages-%{manpages}.tgz +BuildArch: noarch +BuildRequires: php(language) > 5.4 php-cli php-xml %{_bindir}/gpg php-devel +%if %{with_tests} +BuildRequires: %{_bindir}/phpunit +%endif + +Provides: php-pear(Console_Getopt) = %{getoptver} +Provides: php-pear(Archive_Tar) = %{arctarver} +Provides: php-pear(PEAR) = %{version} +Provides: php-pear(Structures_Graph) = %{structver} +Provides: php-pear(XML_Util) = %{xmlutil} +Provides: php-pear(PEAR_Manpages) = %{manpages} +Provides: php-composer(pear/console_getopt) = %{getoptver} +Provides: php-composer(pear/archive_tar) = %{arctarver} +Provides: php-composer(pear/pear-core-minimal) = %{version} +Provides: php-composer(pear/structures_graph) = %{structver} +Provides: php-composer(pear/xml_util) = %{xmlutil} +Requires: php(language) > 5.4 php-cli php-ftp php-pcre php-posix php-tokenizer php-xml +Requires: php-zlib php-bz2 httpd-filesystem + +%description +PEAR is a framework and distribution system for reusable PHP +components. This package contains the basic PEAR components. + +%prep +%setup -cT +for archive in %{SOURCE0} %{SOURCE21} %{SOURCE22} %{SOURCE23} %{SOURCE24} %{SOURCE25} +do + tar xzf $archive --strip-components 1 || tar xzf $archive --strip-path 1 + file=${archive##*/} + [ -f LICENSE ] && mv LICENSE LICENSE-${file%%-*} + [ -f README ] && mv README README-${file%%-*} + tar xzf $archive 'package*xml' + [ -f package2.xml ] && mv package2.xml ${file%%-*}.xml \ + || mv package.xml ${file%%-*}.xml +done +cp %{SOURCE1} . +sed -e 's:@BINDIR@:%{_bindir}:' \ + -e 's:@LIBDIR@:%{_localstatedir}/lib:' \ + %{SOURCE13} > macros.pear + +%build +# This is an empty build section. + +%install +export PHP_PEAR_SYSCONF_DIR=%{_sysconfdir} +export PHP_PEAR_SIG_KEYDIR=%{_sysconfdir}/pearkeys +export PHP_PEAR_SIG_BIN=%{_bindir}/gpg +export PHP_PEAR_INSTALL_DIR=%{peardir} +export PHP_PEAR_CACHE_DIR=${PWD}%{_localstatedir}/cache/php-pear +export PHP_PEAR_TEMP_DIR=/var/tmp +install -d %{buildroot}%{peardir} \ + %{buildroot}%{_localstatedir}/cache/php-pear \ + %{buildroot}%{_localstatedir}/www/html \ + %{buildroot}%{_localstatedir}/lib/pear/pkgxml \ + %{buildroot}%{_sysconfdir}/pear +export INSTALL_ROOT=%{buildroot} +%{_bindir}/php --version +%{_bindir}/php -dmemory_limit=64M -dshort_open_tag=0 -dsafe_mode=0 \ + -d 'error_reporting=E_ALL&~E_DEPRECATED' -ddetect_unicode=0 \ + install-pear.php --force \ + --dir %{peardir} \ + --cache %{_localstatedir}/cache/php-pear \ + --config %{_sysconfdir}/pear \ + --bin %{_bindir} \ + --www %{_localstatedir}/www/html \ + --doc %{_docdir}/pear \ + --test %{_datadir}/tests/pear \ + --data %{_datadir}/pear-data \ + --metadata %{metadir} \ + --man %{_mandir} \ + %{SOURCE0} %{SOURCE21} %{SOURCE22} %{SOURCE23} %{SOURCE24} %{SOURCE25} +install -m 755 %{SOURCE10} %{buildroot}%{_bindir}/pear +install -m 755 %{SOURCE11} %{buildroot}%{_bindir}/pecl +install -m 755 %{SOURCE12} %{buildroot}%{_bindir}/peardev +%{_bindir}/php %{SOURCE3} %{buildroot}%{_sysconfdir}/pear.conf %{_datadir} +%{_bindir}/php -r "print_r(unserialize(substr(file_get_contents('%{buildroot}%{_sysconfdir}/pear.conf'),17)));" +install -m 644 -D macros.pear \ + %{buildroot}%{macrosdir}/macros.pear +pushd %{buildroot}%{peardir} +: no patch +popd +rm -rf %{buildroot}/.depdb* %{buildroot}/.lock %{buildroot}/.channels %{buildroot}/.filemap +install -m 644 *.xml %{buildroot}%{_localstatedir}/lib/pear/pkgxml + +%check +grep %{buildroot} %{buildroot}%{_sysconfdir}/pear.conf && exit 1 +grep %{_libdir} %{buildroot}%{_sysconfdir}/pear.conf && exit 1 +grep '"/tmp"' %{buildroot}%{_sysconfdir}/pear.conf && exit 1 +grep /usr/local %{buildroot}%{_sysconfdir}/pear.conf && exit 1 +grep -rl %{buildroot} %{buildroot} && exit 1 +%if %{with_tests} +cp /etc/php.ini . +echo "include_path=.:%{buildroot}%{peardir}:/usr/share/php" >>php.ini +export PHPRC=$PWD/php.ini +LOG=$PWD/rpmlog +ret=0 +cd %{buildroot}%{_datadir}/tests/pear/Structures_Graph/tests +phpunit \ + AllTests || ret=1 +cd %{buildroot}%{_datadir}/tests/pear/XML_Util/tests +phpunit \ + --bootstrap=/usr/share/pear/XML/Util/autoload.php \ + --test-suffix .php . || ret=1 +cd %{buildroot}%{_datadir}/tests/pear/Console_Getopt/tests +%{_bindir}/php \ + %{buildroot}/usr/share/pear/pearcmd.php \ + run-tests \ + | tee -a $LOG +grep "FAILED TESTS" $LOG && ret=1 +exit $ret +%else +echo 'Test suite disabled (missing "--with tests" option)' +%endif +%transfiletriggerin -- %{pecl_xmldir} +while read file; do + %{_bindir}/pecl install --nodeps --soft --force --register-only --nobuild "$file" >/dev/null || : +done +%transfiletriggerun -- %{pecl_xmldir} +%{_bindir}/php -r ' +while ($file=fgets(STDIN)) { + $file = trim($file); + $xml = simplexml_load_file($file); + if (isset($xml->channel) && isset($xml->name)) { + printf("%s/%s\n", $xml->channel, $xml->name); + } else { + fputs(STDERR, "Bad pecl package file ($file)\n"); + } +}' | while read name; do + %{_bindir}/pecl uninstall --nodeps --ignore-errors --register-only "$name" >/dev/null || : +done + +%postun +if [ $1 -eq 0 -a -d %{metadir}/.registry ] ; then + rm -rf %{metadir}/.registry +fi + +%files +%{peardir} +%dir %{metadir} +%{metadir}/.channels +%verify(not mtime size md5) %{metadir}/.depdb +%verify(not mtime) %{metadir}/.depdblock +%verify(not mtime size md5) %{metadir}/.filemap +%verify(not mtime) %{metadir}/.lock +%{metadir}/.registry +%{metadir}/pkgxml +%{_bindir}/* +%config(noreplace) %{_sysconfdir}/pear.conf +%{macrosdir}/macros.pear +%dir %{_localstatedir}/cache/php-pear +%dir %{_sysconfdir}/pear +%license LICENSE* +%doc README* +%dir %{_docdir}/pear +%doc %{_docdir}/pear/* +%{_datadir}/tests/pear +%{_datadir}/pear-data +%{_mandir}/man1/pear.1* +%{_mandir}/man1/pecl.1* +%{_mandir}/man1/peardev.1* +%{_mandir}/man5/pear.conf.5* + +%changelog +* Tue Sep 7 2021 zhengyaohui - 1.10.12-1 +- package init