mirror of
https://github.com/php/php-src.git
synced 2026-03-29 19:52:20 +02:00
- these files are outdated, /pear-core is the repository for pear and
respectivelly /pear for other pacakges. The install procedure has to be changed as well, as planed. (#1 out 2)
This commit is contained in:
1601
pear/Archive/Tar.php
1601
pear/Archive/Tar.php
File diff suppressed because it is too large
Load Diff
@@ -1,424 +0,0 @@
|
||||
Documentation for class Archive_Tar
|
||||
===================================
|
||||
Last update : 2001-08-15
|
||||
|
||||
|
||||
|
||||
Overview :
|
||||
----------
|
||||
|
||||
The Archive_Tar class helps in creating and managing GNU TAR format
|
||||
files compressed by GNU ZIP or not.
|
||||
The class offers basic functions like creating an archive, adding
|
||||
files in the archive, extracting files from the archive and listing
|
||||
the archive content.
|
||||
It also provide advanced functions that allow the adding and
|
||||
extraction of files with path manipulation.
|
||||
|
||||
|
||||
Sample :
|
||||
--------
|
||||
|
||||
// ----- Creating the object (uncompressed archive)
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
|
||||
|
||||
// ----- Creating the archive
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/";
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->create($v_list);
|
||||
|
||||
// ----- Adding files
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/";
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
|
||||
// ----- Adding more files
|
||||
$tar_object->add("release/newfile.log release/readme.txt");
|
||||
|
||||
// ----- Listing the content
|
||||
if (($v_list = $tar_object->listContent()) != 0)
|
||||
for ($i=0; $i<sizeof($v_list); $i++)
|
||||
{
|
||||
echo "Filename :'".$v_list[$i][filename]."'<br>";
|
||||
echo " .size :'".$v_list[$i][size]."'<br>";
|
||||
echo " .mtime :'".$v_list[$i][mtime]."' (".date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
|
||||
echo " .mode :'".$v_list[$i][mode]."'<br>";
|
||||
echo " .uid :'".$v_list[$i][uid]."'<br>";
|
||||
echo " .gid :'".$v_list[$i][gid]."'<br>";
|
||||
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
|
||||
}
|
||||
|
||||
// ----- Extracting the archive in directory "install"
|
||||
$tar_object->extract("install");
|
||||
|
||||
|
||||
Public arguments :
|
||||
------------------
|
||||
|
||||
None
|
||||
|
||||
|
||||
Public Methods :
|
||||
----------------
|
||||
|
||||
Method : Archive_Tar($p_tarname, $compress = false)
|
||||
Description :
|
||||
Archive_Tar Class constructor. This flavour of the constructor only
|
||||
declare a new Archive_Tar object, identifying it by the name of the
|
||||
tar file.
|
||||
If the compress argument is set the tar will be read or created as a
|
||||
gzip compressed TAR file.
|
||||
Arguments :
|
||||
$p_tarname : A valid filename for the tar archive file.
|
||||
$p_compress : true/false. Indicate if the archive need to be
|
||||
compressed or not.
|
||||
Return value :
|
||||
The Archive_Tar object.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object_compressed = new Archive_Tar("tarname.tgz", true);
|
||||
How it works :
|
||||
Initialize the object.
|
||||
|
||||
Method : create($p_filelist)
|
||||
Description :
|
||||
This method creates the archive file and add the files / directories
|
||||
that are listed in $p_filelist.
|
||||
If the file already exists and is writable, it is replaced by the
|
||||
new tar. It is a create and not an add. If the file exists and is
|
||||
read-only or is a directory it is not replaced. The method return
|
||||
false and a PEAR error text.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
See also createModify() method for more details.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/"; (Optional '/' at the end)
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->create($v_list);
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$tar_object->create("file.txt data/ file.log");
|
||||
How it works :
|
||||
Just calling the createModify() method with the right parameters.
|
||||
|
||||
Method : createModify($p_filelist, $p_add_dir, $p_remove_dir = "")
|
||||
Description :
|
||||
This method creates the archive file and add the files / directories
|
||||
that are listed in $p_filelist.
|
||||
If the file already exists and is writable, it is replaced by the
|
||||
new tar. It is a create and not an add. If the file exists and is
|
||||
read-only or is a directory it is not replaced. The method return
|
||||
false and a PEAR error text.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
The path indicated in $p_remove_dir will be removed from the
|
||||
memorized path of each file / directory listed when this path
|
||||
exists. By default nothing is removed (empty path "")
|
||||
The path indicated in $p_add_dir will be added at the beginning of
|
||||
the memorized path of each file / directory listed. However it can
|
||||
be set to empty "". The adding of a path is done after the removing
|
||||
of path.
|
||||
The path add/remove ability enables the user to prepare an archive
|
||||
for extraction in a different path than the origin files are.
|
||||
See also addModify() method for file adding properties.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_add_dir : A string which contains a path to be added to the
|
||||
memorized path of each element in the list.
|
||||
$p_remove_dir : A string which contains a path to be removed from
|
||||
the memorized path of each element in the list, when
|
||||
relevant.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/"; (Optional '/' at the end)
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->createModify($v_list, "install");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/file.log
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->createModify($v_list, "install", "dev");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/log/file.log
|
||||
How it works :
|
||||
Open the file in write mode (erasing the existing one if one),
|
||||
call the _addList() method for adding the files in an empty archive,
|
||||
add the tar footer (512 bytes block), close the tar file.
|
||||
|
||||
|
||||
Method : addModify($p_filelist, $p_add_dir, $p_remove_dir="")
|
||||
Description :
|
||||
This method add the files / directories listed in $p_filelist at the
|
||||
end of the existing archive. If the archive does not yet exists it
|
||||
is created.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
The path indicated in $p_remove_dir will be removed from the
|
||||
memorized path of each file / directory listed when this path
|
||||
exists. By default nothing is removed (empty path "")
|
||||
The path indicated in $p_add_dir will be added at the beginning of
|
||||
the memorized path of each file / directory listed. However it can
|
||||
be set to empty "". The adding of a path is done after the removing
|
||||
of path.
|
||||
The path add/remove ability enables the user to prepare an archive
|
||||
for extraction in a different path than the origin files are.
|
||||
If a file/dir is already in the archive it will only be added at the
|
||||
end of the archive. There is no update of the existing archived
|
||||
file/dir. However while extracting the archive, the last file will
|
||||
replace the first one. This results in a none optimization of the
|
||||
archive size.
|
||||
If a file/dir does not exist the file/dir is ignored. However an
|
||||
error text is send to PEAR error.
|
||||
If a file/dir is not readable the file/dir is ignored. However an
|
||||
error text is send to PEAR error.
|
||||
If the resulting filename/dirname (after the add/remove option or
|
||||
not) string is greater than 99 char, the file/dir is
|
||||
ignored. However an error text is send to PEAR error.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_add_dir : A string which contains a path to be added to the
|
||||
memorized path of each element in the list.
|
||||
$p_remove_dir : A string which contains a path to be removed from
|
||||
the memorized path of each element in the list, when
|
||||
relevant.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->addModify($v_list, "install");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/file.log
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->addModify($v_list, "install", "dev");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/log/file.log
|
||||
How it works :
|
||||
If the archive does not exists it create it and add the files.
|
||||
If the archive does exists and is not compressed, it open it, jump
|
||||
before the last empty 512 bytes block (tar footer) and add the files
|
||||
at this point.
|
||||
If the archive does exists and is compressed, a temporary copy file
|
||||
is created. This temporary file is then 'gzip' read block by block
|
||||
until the last empty block. The new files are then added in the
|
||||
compressed file.
|
||||
The adding of files is done by going through the file/dir list,
|
||||
adding files per files, in a recursive way through the
|
||||
directory. Each time a path need to be added/removed it is done
|
||||
before writing the file header in the archive.
|
||||
|
||||
Method : add($p_filelist)
|
||||
Description :
|
||||
This method add the files / directories listed in $p_filelist at the
|
||||
end of the existing archive. If the archive does not yet exists it
|
||||
is created.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
See addModify() method for details and limitations.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tgz", true);
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
How it works :
|
||||
Simply call the addModify() method with the right parameters.
|
||||
|
||||
Method : extract($p_path = "")
|
||||
Description :
|
||||
This method extract all the content of the archive in the directory
|
||||
indicated by $p_path.If $p_path is optional, if not set the archive
|
||||
is extracted in the current directory.
|
||||
While extracting a file, if the directory path does not exists it is
|
||||
created.
|
||||
See extractModify() for details and limitations.
|
||||
Arguments :
|
||||
$p_path : Optional path where the files/dir need to by extracted.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extract();
|
||||
How it works :
|
||||
Simply call the extractModify() method with appropriate parameters.
|
||||
|
||||
Method : extractModify($p_path, $p_remove_path)
|
||||
Description :
|
||||
This method extract all the content of the archive in the directory
|
||||
indicated by $p_path. When relevant the memorized path of the
|
||||
files/dir can be modified by removing the $p_remove_path path at the
|
||||
beginning of the file/dir path.
|
||||
While extracting a file, if the directory path does not exists it is
|
||||
created.
|
||||
While extracting a file, if the file already exists it is replaced
|
||||
without looking for last modification date.
|
||||
While extracting a file, if the file already exists and is write
|
||||
protected, the extraction is aborted.
|
||||
While extracting a file, if a directory with the same name already
|
||||
exists, the extraction is aborted.
|
||||
While extracting a directory, if a file with the same name already
|
||||
exists, the extraction is aborted.
|
||||
While extracting a file/directory if the destination directory exist
|
||||
and is write protected, or does not exist but can not be created,
|
||||
the extraction is aborted.
|
||||
If after extraction an extracted file does not show the correct
|
||||
stored file size, the extraction is aborted.
|
||||
When the extraction is aborted, a PEAR error text is set and false
|
||||
is returned. However the result can be a partial extraction that may
|
||||
need to be manually cleaned.
|
||||
Arguments :
|
||||
$p_path : The path of the directory where the files/dir need to by
|
||||
extracted.
|
||||
$p_remove_path : Part of the memorized path that can be removed if
|
||||
present at the beginning of the file/dir path.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
// Imagine tarname.tar with files :
|
||||
// dev/data/file.txt
|
||||
// dev/data/log.txt
|
||||
// readme.txt
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extractModify("install", "dev");
|
||||
// Files will be extracted there :
|
||||
// install/data/file.txt
|
||||
// install/data/log.txt
|
||||
// install/readme.txt
|
||||
How it works :
|
||||
Open the archive and call a more generic function that can extract
|
||||
only a part of the archive or all the archive.
|
||||
See extractList() method for more details.
|
||||
|
||||
Method : listContent()
|
||||
Description :
|
||||
This method returns an array of arrays that describe each
|
||||
file/directory present in the archive.
|
||||
The array is not sorted, so it show the position of the file in the
|
||||
archive.
|
||||
The file informations are :
|
||||
$file[filename] : Name and path of the file/dir.
|
||||
$file[mode] : File permissions (result of fileperms())
|
||||
$file[uid] : user id
|
||||
$file[gid] : group id
|
||||
$file[size] : filesize
|
||||
$file[mtime] : Last modification time (result of filemtime())
|
||||
$file[typeflag] : "" for file, "5" for directory
|
||||
Arguments :
|
||||
Return value :
|
||||
An array of arrays or 0 on error.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
if (($v_list = $tar_object->listContent()) != 0)
|
||||
for ($i=0; $i<sizeof($v_list); $i++)
|
||||
{
|
||||
echo "Filename :'".$v_list[$i][filename]."'<br>";
|
||||
echo " .size :'".$v_list[$i][size]."'<br>";
|
||||
echo " .mtime :'".$v_list[$i][mtime]."' (".
|
||||
date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
|
||||
echo " .mode :'".$v_list[$i][mode]."'<br>";
|
||||
echo " .uid :'".$v_list[$i][uid]."'<br>";
|
||||
echo " .gid :'".$v_list[$i][gid]."'<br>";
|
||||
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
|
||||
}
|
||||
How it works :
|
||||
Call the same function as an extract however with a flag to only go
|
||||
through the archive without extracting the files.
|
||||
|
||||
Method : extractList($p_filelist, $p_path = "", $p_remove_path = "")
|
||||
Description :
|
||||
This method extract from the archive only the files indicated in the
|
||||
$p_filelist. These files are extracted in the current directory or
|
||||
in the directory indicated by the optional $p_path parameter.
|
||||
If indicated the $p_remove_path can be used in the same way as it is
|
||||
used in extractModify() method.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_path : The path of the directory where the files/dir need to by
|
||||
extracted.
|
||||
$p_remove_path : Part of the memorized path that can be removed if
|
||||
present at the beginning of the file/dir path.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
// Imagine tarname.tar with files :
|
||||
// dev/data/file.txt
|
||||
// dev/data/log.txt
|
||||
// readme.txt
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extractList("dev/data/file.txt readme.txt", "install",
|
||||
"dev");
|
||||
// Files will be extracted there :
|
||||
// install/data/file.txt
|
||||
// install/readme.txt
|
||||
How it works :
|
||||
Go through the archive and extract only the files present in the
|
||||
list.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
===========================================================================
|
||||
| PEAR Coding Standards |
|
||||
===========================================================================
|
||||
|
||||
$Id$
|
||||
|
||||
This document is no longer maintained, see
|
||||
http://pear.php.net/manual/en/standards.php instead.
|
||||
@@ -1,22 +0,0 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
peardir=$(PEAR_INSTALLDIR)
|
||||
|
||||
# Skip all php.ini files altogether
|
||||
PEAR_INSTALL_FLAGS = -n -dshort_open_tag=0 -dsafe_mode=0
|
||||
|
||||
install-pear-installer: $(top_builddir)/sapi/cli/php
|
||||
@$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" -b "$(bindir)" $(srcdir)/package-*.xml
|
||||
|
||||
install-pear-packages: $(top_builddir)/sapi/cli/php
|
||||
@$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" -b "$(bindir)" $(srcdir)/packages/*.tar
|
||||
|
||||
install-pear:
|
||||
@echo "Installing PEAR environment: $(INSTALL_ROOT)$(peardir)/"
|
||||
@if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \
|
||||
$(MAKE) -s install-pear-installer install-pear-packages; \
|
||||
else \
|
||||
cat $(srcdir)/install-pear.txt; \
|
||||
exit 5; \
|
||||
fi
|
||||
|
||||
1055
pear/PEAR.php
1055
pear/PEAR.php
File diff suppressed because it is too large
Load Diff
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Stig Bakken <ssb@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once "PEAR/Command/Common.php";
|
||||
require_once "PEAR/Remote.php";
|
||||
require_once "PEAR/Config.php";
|
||||
|
||||
/**
|
||||
* PEAR commands for managing configuration data.
|
||||
*
|
||||
*/
|
||||
class PEAR_Command_Auth extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'login' => array(
|
||||
'summary' => 'Connects and authenticates to remote server',
|
||||
'shortcut' => 'li',
|
||||
'function' => 'doLogin',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Log in to the remote server. To use remote functions in the installer
|
||||
that require any kind of privileges, you need to log in first. The
|
||||
username and password you enter here will be stored in your per-user
|
||||
PEAR configuration (~/.pearrc on Unix-like systems). After logging
|
||||
in, your username and password will be sent along in subsequent
|
||||
operations on the remote server.',
|
||||
),
|
||||
'logout' => array(
|
||||
'summary' => 'Logs out from the remote server',
|
||||
'shortcut' => 'lo',
|
||||
'function' => 'doLogout',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Logs out from the remote server. This command does not actually
|
||||
connect to the remote server, it only deletes the stored username and
|
||||
password from your user configuration.',
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Auth constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Auth(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doLogin()
|
||||
|
||||
/**
|
||||
* Execute the 'login' command.
|
||||
*
|
||||
* @param string $command command name
|
||||
*
|
||||
* @param array $options option_name => value
|
||||
*
|
||||
* @param array $params list of additional parameters
|
||||
*
|
||||
* @return bool TRUE on success, FALSE for unknown commands, or
|
||||
* a PEAR error on failure
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function doLogin($command, $options, $params)
|
||||
{
|
||||
$server = $this->config->get('master_server');
|
||||
$remote = new PEAR_Remote($this->config);
|
||||
$username = $this->config->get('username');
|
||||
if (empty($username)) {
|
||||
$username = @$_ENV['USER'];
|
||||
}
|
||||
$this->ui->outputData("Logging in to $server.", $command);
|
||||
|
||||
list($username, $password) = $this->ui->userDialog(
|
||||
$command,
|
||||
array('Username', 'Password'),
|
||||
array('text', 'password'),
|
||||
array($username, '')
|
||||
);
|
||||
$username = trim($username);
|
||||
$password = trim($password);
|
||||
|
||||
$this->config->set('username', $username);
|
||||
$this->config->set('password', $password);
|
||||
|
||||
$remote->expectError(401);
|
||||
$ok = $remote->call('logintest');
|
||||
$remote->popExpect();
|
||||
if ($ok === true) {
|
||||
$this->ui->outputData("Logged in.", $command);
|
||||
$this->config->store();
|
||||
} else {
|
||||
return $this->raiseError("Login failed!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doLogout()
|
||||
|
||||
/**
|
||||
* Execute the 'logout' command.
|
||||
*
|
||||
* @param string $command command name
|
||||
*
|
||||
* @param array $options option_name => value
|
||||
*
|
||||
* @param array $params list of additional parameters
|
||||
*
|
||||
* @return bool TRUE on success, FALSE for unknown commands, or
|
||||
* a PEAR error on failure
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function doLogout($command, $options, $params)
|
||||
{
|
||||
$server = $this->config->get('master_server');
|
||||
$this->ui->outputData("Logging out from $server.", $command);
|
||||
$this->config->remove('username');
|
||||
$this->config->remove('password');
|
||||
$this->config->store();
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Stig Bakken <ssb@php.net> |
|
||||
// | Tomas V.V.Cox <cox@idecnet.com> |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once "PEAR/Command/Common.php";
|
||||
require_once "PEAR/Builder.php";
|
||||
|
||||
/**
|
||||
* PEAR commands for building extensions.
|
||||
*
|
||||
*/
|
||||
class PEAR_Command_Build extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'build' => array(
|
||||
'summary' => 'Build an Extension From C Source',
|
||||
'function' => 'doBuild',
|
||||
'shortcut' => 'b',
|
||||
'options' => array(),
|
||||
'doc' => '[package.xml]
|
||||
Builds one or more extensions contained in a package.'
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Build constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Build(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doBuild()
|
||||
|
||||
function doBuild($command, $options, $params)
|
||||
{
|
||||
if (sizeof($params) < 1) {
|
||||
$params[0] = 'package.xml';
|
||||
}
|
||||
$builder = &new PEAR_Builder($this->ui);
|
||||
$this->debug = $this->config->get('verbose');
|
||||
$err = $builder->build($params[0], array(&$this, 'buildCallback'));
|
||||
if (PEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ buildCallback()
|
||||
|
||||
function buildCallback($what, $data)
|
||||
{
|
||||
if (($what == 'cmdoutput' && $this->debug > 1) ||
|
||||
($what == 'output' && $this->debug > 0)) {
|
||||
$this->ui->outputData(rtrim($data), 'build');
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Stig Sæther Bakken <ssb@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once "PEAR.php";
|
||||
|
||||
class PEAR_Command_Common extends PEAR
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* PEAR_Config object used to pass user system and configuration
|
||||
* on when executing commands
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
var $config;
|
||||
|
||||
/**
|
||||
* User Interface object, for all interaction with the user.
|
||||
* @var object
|
||||
*/
|
||||
var $ui;
|
||||
|
||||
var $_deps_rel_trans = array(
|
||||
'lt' => '<',
|
||||
'le' => '<=',
|
||||
'eq' => '=',
|
||||
'ne' => '!=',
|
||||
'gt' => '>',
|
||||
'ge' => '>=',
|
||||
'has' => '=='
|
||||
);
|
||||
|
||||
var $_deps_type_trans = array(
|
||||
'pkg' => 'package',
|
||||
'extension' => 'extension',
|
||||
'php' => 'PHP',
|
||||
'prog' => 'external program',
|
||||
'ldlib' => 'external library for linking',
|
||||
'rtlib' => 'external runtime library',
|
||||
'os' => 'operating system',
|
||||
'websrv' => 'web server',
|
||||
'sapi' => 'SAPI backend'
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Common constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Common(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR();
|
||||
$this->config = &$config;
|
||||
$this->ui = &$ui;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ getCommands()
|
||||
|
||||
/**
|
||||
* Return a list of all the commands defined by this class.
|
||||
* @return array list of commands
|
||||
* @access public
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
$ret = array();
|
||||
foreach (array_keys($this->commands) as $command) {
|
||||
$ret[$command] = $this->commands[$command]['summary'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getShortcuts()
|
||||
|
||||
/**
|
||||
* Return a list of all the command shortcuts defined by this class.
|
||||
* @return array shortcut => command
|
||||
* @access public
|
||||
*/
|
||||
function getShortcuts()
|
||||
{
|
||||
$ret = array();
|
||||
foreach (array_keys($this->commands) as $command) {
|
||||
if (isset($this->commands[$command]['shortcut'])) {
|
||||
$ret[$this->commands[$command]['shortcut']] = $command;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getOptions()
|
||||
|
||||
function getOptions($command)
|
||||
{
|
||||
return @$this->commands[$command]['options'];
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getGetoptArgs()
|
||||
|
||||
function getGetoptArgs($command, &$short_args, &$long_args)
|
||||
{
|
||||
$short_args = "";
|
||||
$long_args = array();
|
||||
if (empty($this->commands[$command])) {
|
||||
return;
|
||||
}
|
||||
reset($this->commands[$command]);
|
||||
while (list($option, $info) = each($this->commands[$command]['options'])) {
|
||||
$larg = $sarg = '';
|
||||
if (isset($info['arg'])) {
|
||||
if ($info['arg']{0} == '(') {
|
||||
$larg = '==';
|
||||
$sarg = '::';
|
||||
$arg = substr($info['arg'], 1, -1);
|
||||
} else {
|
||||
$larg = '=';
|
||||
$sarg = ':';
|
||||
$arg = $info['arg'];
|
||||
}
|
||||
}
|
||||
if (isset($info['shortopt'])) {
|
||||
$short_args .= $info['shortopt'] . $sarg;
|
||||
}
|
||||
$long_args[] = $option . $larg;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getHelp()
|
||||
/**
|
||||
* Returns the help message for the given command
|
||||
*
|
||||
* @param string $command The command
|
||||
* @return mixed A fail string if the command does not have help or
|
||||
* a two elements array containing [0]=>help string,
|
||||
* [1]=> help string for the accepted cmd args
|
||||
*/
|
||||
function getHelp($command)
|
||||
{
|
||||
$config = &PEAR_Config::singleton();
|
||||
$help = @$this->commands[$command]['doc'];
|
||||
if (empty($help)) {
|
||||
// XXX (cox) Fallback to summary if there is no doc (show both?)
|
||||
if (!$help = @$this->commands[$command]['summary']) {
|
||||
return "No help for command \"$command\"";
|
||||
}
|
||||
}
|
||||
if (preg_match_all('/{config\s+([^\}]+)}/e', $help, $matches)) {
|
||||
foreach($matches[0] as $k => $v) {
|
||||
$help = preg_replace("/$v/", $config->get($matches[1][$k]), $help);
|
||||
}
|
||||
}
|
||||
return array($help, $this->getHelpArgs($command));
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getHelpArgs()
|
||||
/**
|
||||
* Returns the help for the accepted arguments of a command
|
||||
*
|
||||
* @param string $command
|
||||
* @return string The help string
|
||||
*/
|
||||
function getHelpArgs($command)
|
||||
{
|
||||
if (isset($this->commands[$command]['options']) &&
|
||||
count($this->commands[$command]['options']))
|
||||
{
|
||||
$help = "Options:\n";
|
||||
foreach ($this->commands[$command]['options'] as $k => $v) {
|
||||
if (isset($v['arg'])) {
|
||||
if ($v['arg']{0} == '(') {
|
||||
$arg = substr($v['arg'], 1, -1);
|
||||
$sapp = " [$arg]";
|
||||
$lapp = "[=$arg]";
|
||||
} else {
|
||||
$sapp = " $v[arg]";
|
||||
$lapp = "=$v[arg]";
|
||||
}
|
||||
} else {
|
||||
$sapp = $lapp = "";
|
||||
}
|
||||
if (isset($v['shortopt'])) {
|
||||
$s = $v['shortopt'];
|
||||
@$help .= " -$s$sapp, --$k$lapp\n";
|
||||
} else {
|
||||
@$help .= " --$k$lapp\n";
|
||||
}
|
||||
$p = " ";
|
||||
$doc = rtrim(str_replace("\n", "\n$p", $v['doc']));
|
||||
$help .= " $doc\n";
|
||||
}
|
||||
return $help;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ run()
|
||||
|
||||
function run($command, $options, $params)
|
||||
{
|
||||
$func = @$this->commands[$command]['function'];
|
||||
if (empty($func)) {
|
||||
// look for shortcuts
|
||||
foreach (array_keys($this->commands) as $cmd) {
|
||||
if (@$this->commands[$cmd]['shortcut'] == $command) {
|
||||
$command = $cmd;
|
||||
$func = @$this->commands[$command]['function'];
|
||||
if (empty($func)) {
|
||||
return $this->raiseError("unknown command `$command'");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->$func($command, $options, $params);
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,225 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Stig Bakken <ssb@php.net> |
|
||||
// | Tomas V.V.Cox <cox@idecnet.com> |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once "PEAR/Command/Common.php";
|
||||
require_once "PEAR/Config.php";
|
||||
|
||||
/**
|
||||
* PEAR commands for managing configuration data.
|
||||
*
|
||||
*/
|
||||
class PEAR_Command_Config extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'config-show' => array(
|
||||
'summary' => 'Show All Settings',
|
||||
'function' => 'doConfigShow',
|
||||
'shortcut' => 'csh',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Displays all configuration values. An optional argument
|
||||
may be used to tell which configuration layer to display. Valid
|
||||
configuration layers are "user", "system" and "default".
|
||||
',
|
||||
),
|
||||
'config-get' => array(
|
||||
'summary' => 'Show One Setting',
|
||||
'function' => 'doConfigGet',
|
||||
'shortcut' => 'cg',
|
||||
'options' => array(),
|
||||
'doc' => '<parameter> [layer]
|
||||
Displays the value of one configuration parameter. The
|
||||
first argument is the name of the parameter, an optional second argument
|
||||
may be used to tell which configuration layer to look in. Valid configuration
|
||||
layers are "user", "system" and "default". If no layer is specified, a value
|
||||
will be picked from the first layer that defines the parameter, in the order
|
||||
just specified.
|
||||
',
|
||||
),
|
||||
'config-set' => array(
|
||||
'summary' => 'Change Setting',
|
||||
'function' => 'doConfigSet',
|
||||
'shortcut' => 'cs',
|
||||
'options' => array(),
|
||||
'doc' => '<parameter> <value> [layer]
|
||||
Sets the value of one configuration parameter. The first argument is
|
||||
the name of the parameter, the second argument is the new value. Some
|
||||
parameters are subject to validation, and the command will fail with
|
||||
an error message if the new value does not make sense. An optional
|
||||
third argument may be used to specify in which layer to set the
|
||||
configuration parameter. The default layer is "user".
|
||||
',
|
||||
),
|
||||
'config-help' => array(
|
||||
'summary' => 'Show Information About Setting',
|
||||
'function' => 'doConfigHelp',
|
||||
'shortcut' => 'ch',
|
||||
'options' => array(),
|
||||
'doc' => '[parameter]
|
||||
Displays help for a configuration parameter. Without arguments it
|
||||
displays help for all configuration parameters.
|
||||
',
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Config constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Config(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doConfigShow()
|
||||
|
||||
function doConfigShow($command, $options, $params)
|
||||
{
|
||||
// $params[0] -> the layer
|
||||
if ($error = $this->_checkLayer(@$params[0])) {
|
||||
return $this->raiseError($error);
|
||||
}
|
||||
$keys = $this->config->getKeys();
|
||||
sort($keys);
|
||||
$data = array('caption' => 'Configuration:');
|
||||
foreach ($keys as $key) {
|
||||
$type = $this->config->getType($key);
|
||||
$value = $this->config->get($key, @$params[0]);
|
||||
if ($type == 'password' && $value) {
|
||||
$value = '********';
|
||||
}
|
||||
if ($value === false) {
|
||||
$value = 'false';
|
||||
} elseif ($value === true) {
|
||||
$value = 'true';
|
||||
}
|
||||
$data['data'][$this->config->getGroup($key)][] = array($this->config->getPrompt($key) , $key, $value);
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doConfigGet()
|
||||
|
||||
function doConfigGet($command, $options, $params)
|
||||
{
|
||||
// $params[0] -> the parameter
|
||||
// $params[1] -> the layer
|
||||
if ($error = $this->_checkLayer(@$params[1])) {
|
||||
return $this->raiseError($error);
|
||||
}
|
||||
if (sizeof($params) < 1 || sizeof($params) > 2) {
|
||||
return $this->raiseError("config-get expects 1 or 2 parameters");
|
||||
} elseif (sizeof($params) == 1) {
|
||||
$this->ui->outputData($this->config->get($params[0]), $command);
|
||||
} else {
|
||||
$data = $this->config->get($params[0], $params[1]);
|
||||
$this->ui->outputData($data, $command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doConfigSet()
|
||||
|
||||
function doConfigSet($command, $options, $params)
|
||||
{
|
||||
// $param[0] -> a parameter to set
|
||||
// $param[1] -> the value for the parameter
|
||||
// $param[2] -> the layer
|
||||
$failmsg = '';
|
||||
if (sizeof($params) < 2 || sizeof($params) > 3) {
|
||||
$failmsg .= "config-set expects 2 or 3 parameters";
|
||||
return PEAR::raiseError($failmsg);
|
||||
}
|
||||
if ($error = $this->_checkLayer(@$params[2])) {
|
||||
$failmsg .= $error;
|
||||
return PEAR::raiseError($failmsg);
|
||||
}
|
||||
if (!call_user_func_array(array(&$this->config, 'set'), $params))
|
||||
{
|
||||
$failmsg = "config-set (" . implode(", ", $params) . ") failed";
|
||||
} else {
|
||||
$this->config->store();
|
||||
}
|
||||
if ($failmsg) {
|
||||
return $this->raiseError($failmsg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doConfigHelp()
|
||||
|
||||
function doConfigHelp($command, $options, $params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
$params = $this->config->getKeys();
|
||||
}
|
||||
$data['caption'] = "Config help" . ((count($params) == 1) ? " for $params[0]" : '');
|
||||
$data['headline'] = array('Name', 'Type', 'Description');
|
||||
$data['border'] = true;
|
||||
foreach ($params as $name) {
|
||||
$type = $this->config->getType($name);
|
||||
$docs = $this->config->getDocs($name);
|
||||
if ($type == 'set') {
|
||||
$docs = rtrim($docs) . "\nValid set: " .
|
||||
implode(' ', $this->config->getSetValues($name));
|
||||
}
|
||||
$data['data'][] = array($name, $type, $docs);
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _checkLayer()
|
||||
|
||||
/**
|
||||
* Checks if a layer is defined or not
|
||||
*
|
||||
* @param string $layer The layer to search for
|
||||
* @return mixed False on no error or the error message
|
||||
*/
|
||||
function _checkLayer($layer = null)
|
||||
{
|
||||
if (!empty($layer) && $layer != 'default') {
|
||||
$layers = $this->config->getLayers();
|
||||
if (!in_array($layer, $layers)) {
|
||||
return " only the layers: \"" . implode('" or "', $layers) . "\" are supported";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,470 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Stig Sæther Bakken <ssb@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once "PEAR/Command/Common.php";
|
||||
require_once "PEAR/Installer.php";
|
||||
|
||||
/**
|
||||
* PEAR commands for installation or deinstallation/upgrading of
|
||||
* packages.
|
||||
*
|
||||
*/
|
||||
class PEAR_Command_Install extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'install' => array(
|
||||
'summary' => 'Install Package',
|
||||
'function' => 'doInstall',
|
||||
'shortcut' => 'i',
|
||||
'options' => array(
|
||||
'force' => array(
|
||||
'shortopt' => 'f',
|
||||
'doc' => 'will overwrite newer installed packages',
|
||||
),
|
||||
'nodeps' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'ignore dependencies, install anyway',
|
||||
),
|
||||
'register-only' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'do not install files, only register the package as installed',
|
||||
),
|
||||
'soft' => array(
|
||||
'shortopt' => 's',
|
||||
'doc' => 'soft install, fail silently, or upgrade if already installed',
|
||||
),
|
||||
'nobuild' => array(
|
||||
'shortopt' => 'B',
|
||||
'doc' => 'don\'t build C extensions',
|
||||
),
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'request uncompressed files when downloading',
|
||||
),
|
||||
'installroot' => array(
|
||||
'shortopt' => 'R',
|
||||
'arg' => 'DIR',
|
||||
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
||||
),
|
||||
'ignore-errors' => array(
|
||||
'doc' => 'force install even if there were errors',
|
||||
),
|
||||
'alldeps' => array(
|
||||
'shortopt' => 'a',
|
||||
'doc' => 'install all required and optional dependencies',
|
||||
),
|
||||
'onlyreqdeps' => array(
|
||||
'shortopt' => 'o',
|
||||
'doc' => 'install all required dependencies',
|
||||
),
|
||||
),
|
||||
'doc' => '<package> ...
|
||||
Installs one or more PEAR packages. You can specify a package to
|
||||
install in four ways:
|
||||
|
||||
"Package-1.0.tgz" : installs from a local file
|
||||
|
||||
"http://example.com/Package-1.0.tgz" : installs from
|
||||
anywhere on the net.
|
||||
|
||||
"package.xml" : installs the package described in
|
||||
package.xml. Useful for testing, or for wrapping a PEAR package in
|
||||
another package manager such as RPM.
|
||||
|
||||
"Package" : queries your configured server
|
||||
({config master_server}) and downloads the newest package with
|
||||
the preferred quality/state ({config preferred_state}).
|
||||
|
||||
More than one package may be specified at once. It is ok to mix these
|
||||
four ways of specifying packages.
|
||||
'),
|
||||
'upgrade' => array(
|
||||
'summary' => 'Upgrade Package',
|
||||
'function' => 'doInstall',
|
||||
'shortcut' => 'up',
|
||||
'options' => array(
|
||||
'force' => array(
|
||||
'shortopt' => 'f',
|
||||
'doc' => 'overwrite newer installed packages',
|
||||
),
|
||||
'nodeps' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'ignore dependencies, upgrade anyway',
|
||||
),
|
||||
'register-only' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'do not install files, only register the package as upgraded',
|
||||
),
|
||||
'nobuild' => array(
|
||||
'shortopt' => 'B',
|
||||
'doc' => 'don\'t build C extensions',
|
||||
),
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'request uncompressed files when downloading',
|
||||
),
|
||||
'installroot' => array(
|
||||
'shortopt' => 'R',
|
||||
'arg' => 'DIR',
|
||||
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
||||
),
|
||||
'ignore-errors' => array(
|
||||
'doc' => 'force install even if there were errors',
|
||||
),
|
||||
'alldeps' => array(
|
||||
'shortopt' => 'a',
|
||||
'doc' => 'install all required and optional dependencies',
|
||||
),
|
||||
'onlyreqdeps' => array(
|
||||
'shortopt' => 'o',
|
||||
'doc' => 'install all required dependencies',
|
||||
),
|
||||
),
|
||||
'doc' => '<package> ...
|
||||
Upgrades one or more PEAR packages. See documentation for the
|
||||
"install" command for ways to specify a package.
|
||||
|
||||
When upgrading, your package will be updated if the provided new
|
||||
package has a higher version number (use the -f option if you need to
|
||||
upgrade anyway).
|
||||
|
||||
More than one package may be specified at once.
|
||||
'),
|
||||
'upgrade-all' => array(
|
||||
'summary' => 'Upgrade All Packages',
|
||||
'function' => 'doInstall',
|
||||
'shortcut' => 'ua',
|
||||
'options' => array(
|
||||
'nodeps' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'ignore dependencies, upgrade anyway',
|
||||
),
|
||||
'register-only' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'do not install files, only register the package as upgraded',
|
||||
),
|
||||
'nobuild' => array(
|
||||
'shortopt' => 'B',
|
||||
'doc' => 'don\'t build C extensions',
|
||||
),
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'request uncompressed files when downloading',
|
||||
),
|
||||
'installroot' => array(
|
||||
'shortopt' => 'R',
|
||||
'arg' => 'DIR',
|
||||
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
||||
),
|
||||
'ignore-errors' => array(
|
||||
'doc' => 'force install even if there were errors',
|
||||
),
|
||||
),
|
||||
'doc' => '
|
||||
Upgrades all packages that have a newer release available. Upgrades are
|
||||
done only if there is a release available of the state specified in
|
||||
"preferred_state" (currently {config preferred_state}), or a state considered
|
||||
more stable.
|
||||
'),
|
||||
'uninstall' => array(
|
||||
'summary' => 'Un-install Package',
|
||||
'function' => 'doUninstall',
|
||||
'shortcut' => 'un',
|
||||
'options' => array(
|
||||
'nodeps' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'ignore dependencies, uninstall anyway',
|
||||
),
|
||||
'register-only' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'do not remove files, only register the packages as not installed',
|
||||
),
|
||||
'installroot' => array(
|
||||
'shortopt' => 'R',
|
||||
'arg' => 'DIR',
|
||||
'doc' => 'root directory used when installing files (ala PHP\'s INSTALL_ROOT)',
|
||||
),
|
||||
'ignore-errors' => array(
|
||||
'doc' => 'force install even if there were errors',
|
||||
),
|
||||
),
|
||||
'doc' => '<package> ...
|
||||
Uninstalls one or more PEAR packages. More than one package may be
|
||||
specified at once.
|
||||
'),
|
||||
'bundle' => array(
|
||||
'summary' => 'Unpacks a Pecl Package',
|
||||
'function' => 'doBundle',
|
||||
'shortcut' => 'bun',
|
||||
'options' => array(
|
||||
'destination' => array(
|
||||
'shortopt' => 'd',
|
||||
'arg' => 'DIR',
|
||||
'doc' => 'Optional destination directory for unpacking (defaults to current path or "ext" if exists)',
|
||||
),
|
||||
'force' => array(
|
||||
'shortopt' => 'f',
|
||||
'doc' => 'Force the unpacking even if there were errors in the package',
|
||||
),
|
||||
),
|
||||
'doc' => '<package>
|
||||
Unpacks a Pecl Package into the selected location. It will download the
|
||||
package if needed.
|
||||
'),
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Install constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Install(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doInstall()
|
||||
|
||||
function doInstall($command, $options, $params)
|
||||
{
|
||||
require_once 'PEAR/Downloader.php';
|
||||
if (empty($this->installer)) {
|
||||
$this->installer = &new PEAR_Installer($this->ui);
|
||||
}
|
||||
if ($command == 'upgrade') {
|
||||
$options['upgrade'] = true;
|
||||
}
|
||||
if ($command == 'upgrade-all') {
|
||||
include_once "PEAR/Remote.php";
|
||||
$options['upgrade'] = true;
|
||||
$remote = &new PEAR_Remote($this->config);
|
||||
$state = $this->config->get('preferred_state');
|
||||
if (empty($state) || $state == 'any') {
|
||||
$latest = $remote->call("package.listLatestReleases");
|
||||
} else {
|
||||
$latest = $remote->call("package.listLatestReleases", $state);
|
||||
}
|
||||
if (PEAR::isError($latest)) {
|
||||
return $latest;
|
||||
}
|
||||
$reg = new PEAR_Registry($this->config->get('php_dir'));
|
||||
$installed = array_flip($reg->listPackages());
|
||||
$params = array();
|
||||
foreach ($latest as $package => $info) {
|
||||
$package = strtolower($package);
|
||||
if (!isset($installed[$package])) {
|
||||
// skip packages we don't have installed
|
||||
continue;
|
||||
}
|
||||
$inst_version = $reg->packageInfo($package, 'version');
|
||||
if (version_compare("$info[version]", "$inst_version", "le")) {
|
||||
// installed version is up-to-date
|
||||
continue;
|
||||
}
|
||||
$params[] = $package;
|
||||
$this->ui->outputData(array('data' => "Will upgrade $package"), $command);
|
||||
}
|
||||
}
|
||||
$this->downloader = &new PEAR_Downloader($this->ui, $options, $this->config);
|
||||
$errors = array();
|
||||
$downloaded = array();
|
||||
$this->downloader->download($params);
|
||||
$errors = $this->downloader->getErrorMsgs();
|
||||
if (count($errors)) {
|
||||
$err['data'] = array($errors);
|
||||
$err['headline'] = 'Install Errors';
|
||||
$this->ui->outputData($err);
|
||||
return $this->raiseError("$command failed");
|
||||
}
|
||||
$downloaded = $this->downloader->getDownloadedPackages();
|
||||
$this->installer->sortPkgDeps($downloaded);
|
||||
foreach ($downloaded as $pkg) {
|
||||
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$info = $this->installer->install($pkg['file'], $options, $this->config);
|
||||
PEAR::popErrorHandling();
|
||||
if (PEAR::isError($info)) {
|
||||
$this->ui->outputData('ERROR: ' .$info->getMessage());
|
||||
continue;
|
||||
}
|
||||
if (is_array($info)) {
|
||||
if ($this->config->get('verbose') > 0) {
|
||||
$label = "$info[package] $info[version]";
|
||||
$out = array('data' => "$command ok: $label");
|
||||
if (isset($info['release_warnings'])) {
|
||||
$out['release_warnings'] = $info['release_warnings'];
|
||||
}
|
||||
$this->ui->outputData($out, $command);
|
||||
}
|
||||
} else {
|
||||
return $this->raiseError("$command failed");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doUninstall()
|
||||
|
||||
function doUninstall($command, $options, $params)
|
||||
{
|
||||
if (empty($this->installer)) {
|
||||
$this->installer = &new PEAR_Installer($this->ui);
|
||||
}
|
||||
if (sizeof($params) < 1) {
|
||||
return $this->raiseError("Please supply the package(s) you want to uninstall");
|
||||
}
|
||||
include_once 'PEAR/Registry.php';
|
||||
$reg = new PEAR_Registry($this->config->get('php_dir'));
|
||||
$newparams = array();
|
||||
$badparams = array();
|
||||
foreach ($params as $pkg) {
|
||||
$info = $reg->packageInfo($pkg);
|
||||
if ($info === null) {
|
||||
$badparams[] = $pkg;
|
||||
} else {
|
||||
$newparams[] = $info;
|
||||
}
|
||||
}
|
||||
$this->installer->sortPkgDeps($newparams, true);
|
||||
$params = array();
|
||||
foreach($newparams as $info) {
|
||||
$params[] = $info['info']['package'];
|
||||
}
|
||||
$params = array_merge($params, $badparams);
|
||||
foreach ($params as $pkg) {
|
||||
if ($this->installer->uninstall($pkg, $options)) {
|
||||
if ($this->config->get('verbose') > 0) {
|
||||
$this->ui->outputData("uninstall ok: $pkg", $command);
|
||||
}
|
||||
} else {
|
||||
return $this->raiseError("uninstall failed: $pkg");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
|
||||
// }}}
|
||||
// {{{ doBundle()
|
||||
/*
|
||||
(cox) It just downloads and untars the package, does not do
|
||||
any check that the PEAR_Installer::_installFile() does.
|
||||
*/
|
||||
|
||||
function doBundle($command, $options, $params)
|
||||
{
|
||||
if (empty($this->installer)) {
|
||||
$this->installer = &new PEAR_Downloader($this->ui);
|
||||
}
|
||||
$installer = &$this->installer;
|
||||
if (sizeof($params) < 1) {
|
||||
return $this->raiseError("Please supply the package you want to bundle");
|
||||
}
|
||||
$pkgfile = $params[0];
|
||||
$need_download = false;
|
||||
if (preg_match('#^(http|ftp)://#', $pkgfile)) {
|
||||
$need_download = true;
|
||||
} elseif (!@is_file($pkgfile)) {
|
||||
if ($installer->validPackageName($pkgfile)) {
|
||||
$pkgfile = $installer->getPackageDownloadUrl($pkgfile);
|
||||
$need_download = true;
|
||||
} else {
|
||||
if (strlen($pkgfile)) {
|
||||
return $this->raiseError("Could not open the package file: $pkgfile");
|
||||
} else {
|
||||
return $this->raiseError("No package file given");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Download package -----------------------------------------------
|
||||
if ($need_download) {
|
||||
$downloaddir = $installer->config->get('download_dir');
|
||||
if (empty($downloaddir)) {
|
||||
if (PEAR::isError($downloaddir = System::mktemp('-d'))) {
|
||||
return $downloaddir;
|
||||
}
|
||||
$installer->log(2, '+ tmp dir created at ' . $downloaddir);
|
||||
}
|
||||
$callback = $this->ui ? array(&$installer, '_downloadCallback') : null;
|
||||
$file = $installer->downloadHttp($pkgfile, $this->ui, $downloaddir, $callback);
|
||||
if (PEAR::isError($file)) {
|
||||
return $this->raiseError($file);
|
||||
}
|
||||
$pkgfile = $file;
|
||||
}
|
||||
|
||||
// Parse xml file -----------------------------------------------
|
||||
$pkginfo = $installer->infoFromTgzFile($pkgfile);
|
||||
if (PEAR::isError($pkginfo)) {
|
||||
return $this->raiseError($pkginfo);
|
||||
}
|
||||
$installer->validatePackageInfo($pkginfo, $errors, $warnings);
|
||||
// XXX We allow warnings, do we have to do it?
|
||||
if (count($errors)) {
|
||||
if (empty($options['force'])) {
|
||||
return $this->raiseError("The following errors where found:\n".
|
||||
implode("\n", $errors));
|
||||
} else {
|
||||
$this->log(0, "warning : the following errors were found:\n".
|
||||
implode("\n", $errors));
|
||||
}
|
||||
}
|
||||
$pkgname = $pkginfo['package'];
|
||||
|
||||
// Unpacking -------------------------------------------------
|
||||
|
||||
if (isset($options['destination'])) {
|
||||
if (!is_dir($options['destination'])) {
|
||||
System::mkdir('-p ' . $options['destination']);
|
||||
}
|
||||
$dest = realpath($options['destination']);
|
||||
} else {
|
||||
$pwd = getcwd();
|
||||
if (is_dir($pwd . DIRECTORY_SEPARATOR . 'ext')) {
|
||||
$dest = $pwd . DIRECTORY_SEPARATOR . 'ext';
|
||||
} else {
|
||||
$dest = $pwd;
|
||||
}
|
||||
}
|
||||
$dest .= DIRECTORY_SEPARATOR . $pkgname;
|
||||
$orig = $pkgname . '-' . $pkginfo['version'];
|
||||
|
||||
$tar = new Archive_Tar($pkgfile);
|
||||
if (!@$tar->extractModify($dest, $orig)) {
|
||||
return $this->raiseError("unable to unpack $pkgfile");
|
||||
}
|
||||
$this->ui->outputData("Package ready at '$dest'");
|
||||
// }}}
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alexander Merz <alexmerz@php.net> |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once "PEAR/Command/Common.php";
|
||||
require_once "PEAR/Command.php";
|
||||
require_once "PEAR/Remote.php";
|
||||
require_once "PEAR.php";
|
||||
|
||||
/**
|
||||
* PEAR commands for providing file mirrors
|
||||
*
|
||||
*/
|
||||
class PEAR_Command_Mirror extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'download-all' => array(
|
||||
'summary' => 'Downloads each available package from master_server',
|
||||
'function' => 'doDownloadAll',
|
||||
'shortcut' => 'da',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Requests a list of available packages from the package server
|
||||
(master_server) and downloads them to current working directory'
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Mirror constructor.
|
||||
*
|
||||
* @access public
|
||||
* @param object PEAR_Frontend a reference to an frontend
|
||||
* @param object PEAR_Config a reference to the configuration data
|
||||
*/
|
||||
function PEAR_Command_Mirror(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doDownloadAll()
|
||||
/**
|
||||
* retrieves a list of avaible Packages from master server
|
||||
* and downloads them
|
||||
*
|
||||
* @access public
|
||||
* @param string $command the command
|
||||
* @param array $options the command options before the command
|
||||
* @param array $params the stuff after the command name
|
||||
* @return bool true if succesful
|
||||
* @throw PEAR_Error
|
||||
*/
|
||||
function doDownloadAll($command, $options, $params)
|
||||
{
|
||||
$this->config->set("php_dir", ".");
|
||||
$remote = &new PEAR_Remote($this->config);
|
||||
$remoteInfo = $remote->call("package.listAll");
|
||||
if (PEAR::isError($remoteInfo)) {
|
||||
return $remoteInfo;
|
||||
}
|
||||
$cmd = &PEAR_Command::factory("download", $this->config);
|
||||
if (PEAR::isError($cmd)) {
|
||||
return $cmd;
|
||||
}
|
||||
foreach ($remoteInfo as $pkgn => $pkg) {
|
||||
/**
|
||||
* Error handling not neccesary, because already done by
|
||||
* the download command
|
||||
*/
|
||||
$cmd->run("download", array(), array($pkgn));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
@@ -1,818 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Stig Bakken <ssb@php.net> |
|
||||
// | Martin Jansen <mj@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once 'PEAR/Common.php';
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
class PEAR_Command_Package extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'package' => array(
|
||||
'summary' => 'Build Package',
|
||||
'function' => 'doPackage',
|
||||
'shortcut' => 'p',
|
||||
'options' => array(
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'Do not gzip the package file'
|
||||
),
|
||||
'showname' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'Print the name of the packaged file.',
|
||||
),
|
||||
),
|
||||
'doc' => '[descfile]
|
||||
Creates a PEAR package from its description file (usually called
|
||||
package.xml).
|
||||
'
|
||||
),
|
||||
'package-validate' => array(
|
||||
'summary' => 'Validate Package Consistency',
|
||||
'function' => 'doPackageValidate',
|
||||
'shortcut' => 'pv',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
',
|
||||
),
|
||||
'cvsdiff' => array(
|
||||
'summary' => 'Run a "cvs diff" for all files in a package',
|
||||
'function' => 'doCvsDiff',
|
||||
'shortcut' => 'cd',
|
||||
'options' => array(
|
||||
'quiet' => array(
|
||||
'shortopt' => 'q',
|
||||
'doc' => 'Be quiet',
|
||||
),
|
||||
'reallyquiet' => array(
|
||||
'shortopt' => 'Q',
|
||||
'doc' => 'Be really quiet',
|
||||
),
|
||||
'date' => array(
|
||||
'shortopt' => 'D',
|
||||
'doc' => 'Diff against revision of DATE',
|
||||
'arg' => 'DATE',
|
||||
),
|
||||
'release' => array(
|
||||
'shortopt' => 'R',
|
||||
'doc' => 'Diff against tag for package release REL',
|
||||
'arg' => 'REL',
|
||||
),
|
||||
'revision' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'Diff against revision REV',
|
||||
'arg' => 'REV',
|
||||
),
|
||||
'context' => array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'Generate context diff',
|
||||
),
|
||||
'unified' => array(
|
||||
'shortopt' => 'u',
|
||||
'doc' => 'Generate unified diff',
|
||||
),
|
||||
'ignore-case' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'Ignore case, consider upper- and lower-case letters equivalent',
|
||||
),
|
||||
'ignore-whitespace' => array(
|
||||
'shortopt' => 'b',
|
||||
'doc' => 'Ignore changes in amount of white space',
|
||||
),
|
||||
'ignore-blank-lines' => array(
|
||||
'shortopt' => 'B',
|
||||
'doc' => 'Ignore changes that insert or delete blank lines',
|
||||
),
|
||||
'brief' => array(
|
||||
'doc' => 'Report only whether the files differ, no details',
|
||||
),
|
||||
'dry-run' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'Don\'t do anything, just pretend',
|
||||
),
|
||||
),
|
||||
'doc' => '<package.xml>
|
||||
Compares all the files in a package. Without any options, this
|
||||
command will compare the current code with the last checked-in code.
|
||||
Using the -r or -R option you may compare the current code with that
|
||||
of a specific release.
|
||||
',
|
||||
),
|
||||
'cvstag' => array(
|
||||
'summary' => 'Set CVS Release Tag',
|
||||
'function' => 'doCvsTag',
|
||||
'shortcut' => 'ct',
|
||||
'options' => array(
|
||||
'quiet' => array(
|
||||
'shortopt' => 'q',
|
||||
'doc' => 'Be quiet',
|
||||
),
|
||||
'reallyquiet' => array(
|
||||
'shortopt' => 'Q',
|
||||
'doc' => 'Be really quiet',
|
||||
),
|
||||
'slide' => array(
|
||||
'shortopt' => 'F',
|
||||
'doc' => 'Move (slide) tag if it exists',
|
||||
),
|
||||
'delete' => array(
|
||||
'shortopt' => 'd',
|
||||
'doc' => 'Remove tag',
|
||||
),
|
||||
'dry-run' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'Don\'t do anything, just pretend',
|
||||
),
|
||||
),
|
||||
'doc' => '<package.xml>
|
||||
Sets a CVS tag on all files in a package. Use this command after you have
|
||||
packaged a distribution tarball with the "package" command to tag what
|
||||
revisions of what files were in that release. If need to fix something
|
||||
after running cvstag once, but before the tarball is released to the public,
|
||||
use the "slide" option to move the release tag.
|
||||
',
|
||||
),
|
||||
'run-tests' => array(
|
||||
'summary' => 'Run Regression Tests',
|
||||
'function' => 'doRunTests',
|
||||
'shortcut' => 'rt',
|
||||
'options' => array(
|
||||
'recur' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'Run tests in child directories, recursively. 4 dirs deep maximum',
|
||||
),
|
||||
'ini' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'actual string of settings to pass to php in format " -d setting=blah"',
|
||||
'arg' => 'SETTINGS'
|
||||
),
|
||||
'realtimelog' => array(
|
||||
'shortopt' => 'l',
|
||||
'doc' => 'Log test runs/results as they are run',
|
||||
),
|
||||
),
|
||||
'doc' => '[testfile|dir ...]
|
||||
Run regression tests with PHP\'s regression testing script (run-tests.php).',
|
||||
),
|
||||
'package-dependencies' => array(
|
||||
'summary' => 'Show package dependencies',
|
||||
'function' => 'doPackageDependencies',
|
||||
'shortcut' => 'pd',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
List all depencies the package has.'
|
||||
),
|
||||
'sign' => array(
|
||||
'summary' => 'Sign a package distribution file',
|
||||
'function' => 'doSign',
|
||||
'shortcut' => 'si',
|
||||
'options' => array(),
|
||||
'doc' => '<package-file>
|
||||
Signs a package distribution (.tar or .tgz) file with GnuPG.',
|
||||
),
|
||||
'makerpm' => array(
|
||||
'summary' => 'Builds an RPM spec file from a PEAR package',
|
||||
'function' => 'doMakeRPM',
|
||||
'shortcut' => 'rpm',
|
||||
'options' => array(
|
||||
'spec-template' => array(
|
||||
'shortopt' => 't',
|
||||
'arg' => 'FILE',
|
||||
'doc' => 'Use FILE as RPM spec file template'
|
||||
),
|
||||
'rpm-pkgname' => array(
|
||||
'shortopt' => 'p',
|
||||
'arg' => 'FORMAT',
|
||||
'doc' => 'Use FORMAT as format string for RPM package name, %s is replaced
|
||||
by the PEAR package name, defaults to "PEAR::%s".',
|
||||
),
|
||||
),
|
||||
'doc' => '<package-file>
|
||||
|
||||
Creates an RPM .spec file for wrapping a PEAR package inside an RPM
|
||||
package. Intended to be used from the SPECS directory, with the PEAR
|
||||
package tarball in the SOURCES directory:
|
||||
|
||||
$ pear makerpm ../SOURCES/Net_Socket-1.0.tgz
|
||||
Wrote RPM spec file PEAR::Net_Geo-1.0.spec
|
||||
$ rpm -bb PEAR::Net_Socket-1.0.spec
|
||||
...
|
||||
Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
|
||||
',
|
||||
),
|
||||
);
|
||||
|
||||
var $output;
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Package constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Package(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ _displayValidationResults()
|
||||
|
||||
function _displayValidationResults($err, $warn, $strict = false)
|
||||
{
|
||||
foreach ($err as $e) {
|
||||
$this->output .= "Error: $e\n";
|
||||
}
|
||||
foreach ($warn as $w) {
|
||||
$this->output .= "Warning: $w\n";
|
||||
}
|
||||
$this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n",
|
||||
sizeof($err), sizeof($warn));
|
||||
if ($strict && sizeof($err) > 0) {
|
||||
$this->output .= "Fix these errors and try again.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doPackage()
|
||||
|
||||
function doPackage($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
include_once 'PEAR/Packager.php';
|
||||
if (sizeof($params) < 1) {
|
||||
$params[0] = "package.xml";
|
||||
}
|
||||
$pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
|
||||
$packager =& new PEAR_Packager();
|
||||
$err = $warn = array();
|
||||
$dir = dirname($pkginfofile);
|
||||
$compress = empty($options['nocompress']) ? true : false;
|
||||
$result = $packager->package($pkginfofile, $compress);
|
||||
if (PEAR::isError($result)) {
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return $this->raiseError($result);
|
||||
}
|
||||
// Don't want output, only the package file name just created
|
||||
if (isset($options['showname'])) {
|
||||
$this->output = $result;
|
||||
}
|
||||
if (PEAR::isError($result)) {
|
||||
$this->output .= "Package failed: ".$result->getMessage();
|
||||
}
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doPackageValidate()
|
||||
|
||||
function doPackageValidate($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
if (sizeof($params) < 1) {
|
||||
$params[0] = "package.xml";
|
||||
}
|
||||
$obj = new PEAR_Common;
|
||||
$info = null;
|
||||
if ($fp = @fopen($params[0], "r")) {
|
||||
$test = fread($fp, 5);
|
||||
fclose($fp);
|
||||
if ($test == "<?xml") {
|
||||
$info = $obj->infoFromDescriptionFile($params[0]);
|
||||
}
|
||||
}
|
||||
if (empty($info)) {
|
||||
$info = $obj->infoFromTgzFile($params[0]);
|
||||
}
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$obj->validatePackageInfo($info, $err, $warn);
|
||||
$this->_displayValidationResults($err, $warn);
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doCvsTag()
|
||||
|
||||
function doCvsTag($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
$_cmd = $command;
|
||||
if (sizeof($params) < 1) {
|
||||
$help = $this->getHelp($command);
|
||||
return $this->raiseError("$command: missing parameter: $help[0]");
|
||||
}
|
||||
$obj = new PEAR_Common;
|
||||
$info = $obj->infoFromDescriptionFile($params[0]);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$err = $warn = array();
|
||||
$obj->validatePackageInfo($info, $err, $warn);
|
||||
if (!$this->_displayValidationResults($err, $warn, true)) {
|
||||
$this->ui->outputData($this->output, $command);
|
||||
break;
|
||||
}
|
||||
$version = $info['version'];
|
||||
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version);
|
||||
$cvstag = "RELEASE_$cvsversion";
|
||||
$files = array_keys($info['filelist']);
|
||||
$command = "cvs";
|
||||
if (isset($options['quiet'])) {
|
||||
$command .= ' -q';
|
||||
}
|
||||
if (isset($options['reallyquiet'])) {
|
||||
$command .= ' -Q';
|
||||
}
|
||||
$command .= ' tag';
|
||||
if (isset($options['slide'])) {
|
||||
$command .= ' -F';
|
||||
}
|
||||
if (isset($options['delete'])) {
|
||||
$command .= ' -d';
|
||||
}
|
||||
$command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]);
|
||||
foreach ($files as $file) {
|
||||
$command .= ' ' . escapeshellarg($file);
|
||||
}
|
||||
if ($this->config->get('verbose') > 1) {
|
||||
$this->output .= "+ $command\n";
|
||||
}
|
||||
$this->output .= "+ $command\n";
|
||||
if (empty($options['dry-run'])) {
|
||||
$fp = popen($command, "r");
|
||||
while ($line = fgets($fp, 1024)) {
|
||||
$this->output .= rtrim($line)."\n";
|
||||
}
|
||||
pclose($fp);
|
||||
}
|
||||
$this->ui->outputData($this->output, $_cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doCvsDiff()
|
||||
|
||||
function doCvsDiff($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
if (sizeof($params) < 1) {
|
||||
$help = $this->getHelp($command);
|
||||
return $this->raiseError("$command: missing parameter: $help[0]");
|
||||
}
|
||||
$obj = new PEAR_Common;
|
||||
$info = $obj->infoFromDescriptionFile($params[0]);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$files = array_keys($info['filelist']);
|
||||
$cmd = "cvs";
|
||||
if (isset($options['quiet'])) {
|
||||
$cmd .= ' -q';
|
||||
unset($options['quiet']);
|
||||
}
|
||||
if (isset($options['reallyquiet'])) {
|
||||
$cmd .= ' -Q';
|
||||
unset($options['reallyquiet']);
|
||||
}
|
||||
if (isset($options['release'])) {
|
||||
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $options['release']);
|
||||
$cvstag = "RELEASE_$cvsversion";
|
||||
$options['revision'] = $cvstag;
|
||||
unset($options['release']);
|
||||
}
|
||||
$execute = true;
|
||||
if (isset($options['dry-run'])) {
|
||||
$execute = false;
|
||||
unset($options['dry-run']);
|
||||
}
|
||||
$cmd .= ' diff';
|
||||
// the rest of the options are passed right on to "cvs diff"
|
||||
foreach ($options as $option => $optarg) {
|
||||
$arg = @$this->commands[$command]['options'][$option]['arg'];
|
||||
$short = @$this->commands[$command]['options'][$option]['shortopt'];
|
||||
$cmd .= $short ? " -$short" : " --$option";
|
||||
if ($arg && $optarg) {
|
||||
$cmd .= ($short ? '' : '=') . escapeshellarg($optarg);
|
||||
}
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
$cmd .= ' ' . escapeshellarg($file);
|
||||
}
|
||||
if ($this->config->get('verbose') > 1) {
|
||||
$this->output .= "+ $cmd\n";
|
||||
}
|
||||
if ($execute) {
|
||||
$fp = popen($cmd, "r");
|
||||
while ($line = fgets($fp, 1024)) {
|
||||
$this->output .= rtrim($line)."\n";
|
||||
}
|
||||
pclose($fp);
|
||||
}
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doRunTests()
|
||||
|
||||
function doRunTests($command, $options, $params)
|
||||
{
|
||||
include_once 'PEAR/RunTest.php';
|
||||
$log = new PEAR_Common;
|
||||
$log->ui = &$this->ui; // slightly hacky, but it will work
|
||||
$run = new PEAR_RunTest($log);
|
||||
$tests = array();
|
||||
if (isset($options['recur'])) {
|
||||
$depth = 4;
|
||||
} else {
|
||||
$depth = 1;
|
||||
}
|
||||
if (!count($params)) {
|
||||
$params[] = '.';
|
||||
}
|
||||
foreach ($params as $p) {
|
||||
if (is_dir($p)) {
|
||||
$dir = System::find(array($p, '-type', 'f',
|
||||
'-maxdepth', $depth,
|
||||
'-name', '*.phpt'));
|
||||
$tests = array_merge($tests, $dir);
|
||||
} else {
|
||||
if (!@file_exists($p)) {
|
||||
if (!preg_match('/\.phpt$/', $p)) {
|
||||
$p .= '.phpt';
|
||||
}
|
||||
$dir = System::find(array(dirname($p), '-type', 'f',
|
||||
'-maxdepth', $depth,
|
||||
'-name', $p));
|
||||
$tests = array_merge($tests, $dir);
|
||||
} else {
|
||||
$tests[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ini_settings = '';
|
||||
if (isset($options['ini'])) {
|
||||
$ini_settings .= $options['ini'];
|
||||
}
|
||||
if (isset($_ENV['TEST_PHP_INCLUDE_PATH'])) {
|
||||
$ini_settings .= " -d include_path={$_ENV['TEST_PHP_INCLUDE_PATH']}";
|
||||
}
|
||||
if ($ini_settings) {
|
||||
$this->ui->outputData('Using INI settings: "' . $ini_settings . '"');
|
||||
}
|
||||
$skipped = $passed = $failed = array();
|
||||
$this->ui->outputData('Running ' . count($tests) . ' tests', $command);
|
||||
$start = time();
|
||||
if (isset($options['realtimelog'])) {
|
||||
@unlink('run-tests.log');
|
||||
}
|
||||
foreach ($tests as $t) {
|
||||
if (isset($options['realtimelog'])) {
|
||||
$fp = @fopen('run-tests.log', 'a');
|
||||
if ($fp) {
|
||||
fwrite($fp, "Running test $t...");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
$result = $run->run($t, $ini_settings);
|
||||
if (OS_WINDOWS) {
|
||||
for($i=0;$i<2000;$i++) {
|
||||
$i = $i; // delay - race conditions on windows
|
||||
}
|
||||
}
|
||||
if (isset($options['realtimelog'])) {
|
||||
$fp = @fopen('run-tests.log', 'a');
|
||||
if ($fp) {
|
||||
fwrite($fp, "$result\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
if ($result == 'FAILED') {
|
||||
$failed[] = $t;
|
||||
}
|
||||
if ($result == 'PASSED') {
|
||||
$passed[] = $t;
|
||||
}
|
||||
if ($result == 'SKIPPED') {
|
||||
$skipped[] = $t;
|
||||
}
|
||||
}
|
||||
$total = date('i:s', time() - $start);
|
||||
if (count($failed)) {
|
||||
$output = "TOTAL TIME: $total\n";
|
||||
$output .= count($passed) . " PASSED TESTS\n";
|
||||
$output .= count($skipped) . " SKIPPED TESTS\n";
|
||||
$output .= count($failed) . " FAILED TESTS:\n";
|
||||
foreach ($failed as $failure) {
|
||||
$output .= $failure . "\n";
|
||||
}
|
||||
if (isset($options['realtimelog'])) {
|
||||
$fp = @fopen('run-tests.log', 'a');
|
||||
} else {
|
||||
$fp = @fopen('run-tests.log', 'w');
|
||||
}
|
||||
if ($fp) {
|
||||
fwrite($fp, $output, strlen($output));
|
||||
fclose($fp);
|
||||
$this->ui->outputData('wrote log to "' . realpath('run-tests.log') . '"', $command);
|
||||
}
|
||||
} elseif (@file_exists('run-tests.log') && !@is_dir('run-tests.log')) {
|
||||
@unlink('run-tests.log');
|
||||
}
|
||||
$this->ui->outputData('TOTAL TIME: ' . $total);
|
||||
$this->ui->outputData(count($passed) . ' PASSED TESTS', $command);
|
||||
$this->ui->outputData(count($skipped) . ' SKIPPED TESTS', $command);
|
||||
if (count($failed)) {
|
||||
$this->ui->outputData(count($failed) . ' FAILED TESTS:', $command);
|
||||
foreach ($failed as $failure) {
|
||||
$this->ui->outputData($failure, $command);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doPackageDependencies()
|
||||
|
||||
function doPackageDependencies($command, $options, $params)
|
||||
{
|
||||
// $params[0] -> the PEAR package to list its information
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("bad parameter(s), try \"help $command\"");
|
||||
}
|
||||
|
||||
$obj = new PEAR_Common();
|
||||
if (PEAR::isError($info = $obj->infoFromAny($params[0]))) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
|
||||
if (is_array($info['release_deps'])) {
|
||||
$data = array(
|
||||
'caption' => 'Dependencies for ' . $info['package'],
|
||||
'border' => true,
|
||||
'headline' => array("Type", "Name", "Relation", "Version"),
|
||||
);
|
||||
|
||||
foreach ($info['release_deps'] as $d) {
|
||||
|
||||
if (isset($this->_deps_rel_trans[$d['rel']])) {
|
||||
$rel = $this->_deps_rel_trans[$d['rel']];
|
||||
} else {
|
||||
$rel = $d['rel'];
|
||||
}
|
||||
|
||||
if (isset($this->_deps_type_trans[$d['type']])) {
|
||||
$type = ucfirst($this->_deps_type_trans[$d['type']]);
|
||||
} else {
|
||||
$type = $d['type'];
|
||||
}
|
||||
|
||||
if (isset($d['name'])) {
|
||||
$name = $d['name'];
|
||||
} else {
|
||||
$name = '';
|
||||
}
|
||||
|
||||
if (isset($d['version'])) {
|
||||
$version = $d['version'];
|
||||
} else {
|
||||
$version = '';
|
||||
}
|
||||
|
||||
$data['data'][] = array($type, $name, $rel, $version);
|
||||
}
|
||||
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fallback
|
||||
$this->ui->outputData("This package does not have any dependencies.", $command);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doSign()
|
||||
|
||||
function doSign($command, $options, $params)
|
||||
{
|
||||
// should move most of this code into PEAR_Packager
|
||||
// so it'll be easy to implement "pear package --sign"
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("bad parameter(s), try \"help $command\"");
|
||||
}
|
||||
if (!file_exists($params[0])) {
|
||||
return $this->raiseError("file does not exist: $params[0]");
|
||||
}
|
||||
$obj = new PEAR_Common;
|
||||
$info = $obj->infoFromTgzFile($params[0]);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
include_once "Archive/Tar.php";
|
||||
include_once "System.php";
|
||||
$tar = new Archive_Tar($params[0]);
|
||||
$tmpdir = System::mktemp('-d pearsign');
|
||||
if (!$tar->extractList('package.xml package.sig', $tmpdir)) {
|
||||
return $this->raiseError("failed to extract tar file");
|
||||
}
|
||||
if (file_exists("$tmpdir/package.sig")) {
|
||||
return $this->raiseError("package already signed");
|
||||
}
|
||||
@unlink("$tmpdir/package.sig");
|
||||
$input = $this->ui->userDialog($command,
|
||||
array('GnuPG Passphrase'),
|
||||
array('password'));
|
||||
$gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output $tmpdir/package.sig $tmpdir/package.xml 2>/dev/null", "w");
|
||||
if (!$gpg) {
|
||||
return $this->raiseError("gpg command failed");
|
||||
}
|
||||
fwrite($gpg, "$input[0]\r");
|
||||
if (pclose($gpg) || !file_exists("$tmpdir/package.sig")) {
|
||||
return $this->raiseError("gpg sign failed");
|
||||
}
|
||||
$tar->addModify("$tmpdir/package.sig", '', $tmpdir);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doMakeRPM()
|
||||
|
||||
/*
|
||||
|
||||
(cox)
|
||||
|
||||
TODO:
|
||||
|
||||
- Fill the rpm dependencies in the template file.
|
||||
|
||||
IDEAS:
|
||||
|
||||
- Instead of mapping the role to rpm vars, perhaps it's better
|
||||
|
||||
to use directly the pear cmd to install the files by itself
|
||||
|
||||
in %postrun so:
|
||||
|
||||
pear -d php_dir=%{_libdir}/php/pear -d test_dir=.. <package>
|
||||
|
||||
*/
|
||||
|
||||
function doMakeRPM($command, $options, $params)
|
||||
{
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("bad parameter(s), try \"help $command\"");
|
||||
}
|
||||
if (!file_exists($params[0])) {
|
||||
return $this->raiseError("file does not exist: $params[0]");
|
||||
}
|
||||
include_once "Archive/Tar.php";
|
||||
include_once "PEAR/Installer.php";
|
||||
include_once "System.php";
|
||||
$tar = new Archive_Tar($params[0]);
|
||||
$tmpdir = System::mktemp('-d pear2rpm');
|
||||
$instroot = System::mktemp('-d pear2rpm');
|
||||
$tmp = $this->config->get('verbose');
|
||||
$this->config->set('verbose', 0);
|
||||
$installer = new PEAR_Installer($this->ui);
|
||||
$info = $installer->install($params[0],
|
||||
array('installroot' => $instroot,
|
||||
'nodeps' => true));
|
||||
$pkgdir = "$info[package]-$info[version]";
|
||||
$info['rpm_xml_dir'] = '/var/lib/pear';
|
||||
$this->config->set('verbose', $tmp);
|
||||
if (!$tar->extractList("package.xml", $tmpdir, $pkgdir)) {
|
||||
return $this->raiseError("failed to extract $params[0]");
|
||||
}
|
||||
if (!file_exists("$tmpdir/package.xml")) {
|
||||
return $this->raiseError("no package.xml found in $params[0]");
|
||||
}
|
||||
if (isset($options['spec-template'])) {
|
||||
$spec_template = $options['spec-template'];
|
||||
} else {
|
||||
$spec_template = $this->config->get('data_dir') .
|
||||
'/PEAR/template.spec';
|
||||
}
|
||||
if (isset($options['rpm-pkgname'])) {
|
||||
$rpm_pkgname_format = $options['rpm-pkgname'];
|
||||
} else {
|
||||
$rpm_pkgname_format = "PEAR::%s";
|
||||
}
|
||||
|
||||
$info['extra_headers'] = '';
|
||||
$info['doc_files'] = '';
|
||||
$info['files'] = '';
|
||||
$info['rpm_package'] = sprintf($rpm_pkgname_format, $info['package']);
|
||||
$srcfiles = 0;
|
||||
foreach ($info['filelist'] as $name => $attr) {
|
||||
|
||||
if (!isset($attr['role'])) {
|
||||
continue;
|
||||
}
|
||||
$name = preg_replace('![/:\\\\]!', '/', $name);
|
||||
if ($attr['role'] == 'doc') {
|
||||
$info['doc_files'] .= " $name";
|
||||
|
||||
// Map role to the rpm vars
|
||||
} else {
|
||||
|
||||
$c_prefix = '%{_libdir}/php/pear';
|
||||
|
||||
switch ($attr['role']) {
|
||||
|
||||
case 'php':
|
||||
|
||||
$prefix = $c_prefix; break;
|
||||
|
||||
case 'ext':
|
||||
|
||||
$prefix = '%{_libdir}/php'; break; // XXX good place?
|
||||
|
||||
case 'src':
|
||||
|
||||
$srcfiles++;
|
||||
|
||||
$prefix = '%{_includedir}/php'; break; // XXX good place?
|
||||
|
||||
case 'test':
|
||||
|
||||
$prefix = "$c_prefix/tests/" . $info['package']; break;
|
||||
|
||||
case 'data':
|
||||
|
||||
$prefix = "$c_prefix/data/" . $info['package']; break;
|
||||
|
||||
case 'script':
|
||||
|
||||
$prefix = '%{_bindir}'; break;
|
||||
|
||||
}
|
||||
|
||||
$name = str_replace('\\', '/', $name);
|
||||
$info['files'] .= "$prefix/$name\n";
|
||||
|
||||
}
|
||||
}
|
||||
if ($srcfiles > 0) {
|
||||
include_once "OS/Guess.php";
|
||||
$os = new OS_Guess;
|
||||
$arch = $os->getCpu();
|
||||
} else {
|
||||
$arch = 'noarch';
|
||||
}
|
||||
$cfg = array('master_server', 'php_dir', 'ext_dir', 'doc_dir',
|
||||
'bin_dir', 'data_dir', 'test_dir');
|
||||
foreach ($cfg as $k) {
|
||||
$info[$k] = $this->config->get($k);
|
||||
}
|
||||
$info['arch'] = $arch;
|
||||
$fp = @fopen($spec_template, "r");
|
||||
if (!$fp) {
|
||||
return $this->raiseError("could not open RPM spec file template $spec_template: $php_errormsg");
|
||||
}
|
||||
$spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\1"]', fread($fp, filesize($spec_template)));
|
||||
fclose($fp);
|
||||
$spec_file = "$info[rpm_package]-$info[version].spec";
|
||||
$wp = fopen($spec_file, "wb");
|
||||
if (!$wp) {
|
||||
return $this->raiseError("could not write RPM spec file $spec_file: $php_errormsg");
|
||||
}
|
||||
fwrite($wp, $spec_contents);
|
||||
fclose($wp);
|
||||
$this->ui->outputData("Wrote RPM spec file $spec_file", $command);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,351 +0,0 @@
|
||||
<?php
|
||||
// /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Stig Bakken <ssb@php.net> |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
require_once 'PEAR/Registry.php';
|
||||
require_once 'PEAR/Config.php';
|
||||
|
||||
class PEAR_Command_Registry extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'list' => array(
|
||||
'summary' => 'List Installed Packages',
|
||||
'function' => 'doList',
|
||||
'shortcut' => 'l',
|
||||
'options' => array(),
|
||||
'doc' => '[package]
|
||||
If invoked without parameters, this command lists the PEAR packages
|
||||
installed in your php_dir ({config php_dir)). With a parameter, it
|
||||
lists the files in that package.
|
||||
',
|
||||
),
|
||||
'shell-test' => array(
|
||||
'summary' => 'Shell Script Test',
|
||||
'function' => 'doShellTest',
|
||||
'shortcut' => 'st',
|
||||
'options' => array(),
|
||||
'doc' => '<package> [[relation] version]
|
||||
Tests if a package is installed in the system. Will exit(1) if it is not.
|
||||
<relation> The version comparison operator. One of:
|
||||
<, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
|
||||
<version> The version to compare with
|
||||
'),
|
||||
'info' => array(
|
||||
'summary' => 'Display information about a package',
|
||||
'function' => 'doInfo',
|
||||
'shortcut' => 'in',
|
||||
'options' => array(),
|
||||
'doc' => '<package>
|
||||
Displays information about a package. The package argument may be a
|
||||
local package file, an URL to a package file, or the name of an
|
||||
installed package.'
|
||||
)
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Registry constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Registry(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doList()
|
||||
|
||||
function _sortinfo($a, $b)
|
||||
{
|
||||
return strcmp($a['package'], $b['package']);
|
||||
}
|
||||
|
||||
function doList($command, $options, $params)
|
||||
{
|
||||
$reg = new PEAR_Registry($this->config->get('php_dir'));
|
||||
if (sizeof($params) == 0) {
|
||||
$installed = $reg->packageInfo();
|
||||
usort($installed, array(&$this, '_sortinfo'));
|
||||
$i = $j = 0;
|
||||
$data = array(
|
||||
'caption' => 'Installed packages:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Version', 'State')
|
||||
);
|
||||
foreach ($installed as $package) {
|
||||
$data['data'][] = array($package['package'],
|
||||
$package['version'],
|
||||
@$package['release_state']);
|
||||
}
|
||||
if (count($installed)==0) {
|
||||
$data = '(no packages installed)';
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
} else {
|
||||
if (file_exists($params[0]) && !is_dir($params[0])) {
|
||||
include_once "PEAR/Common.php";
|
||||
$obj = &new PEAR_Common;
|
||||
$info = $obj->infoFromAny($params[0]);
|
||||
$headings = array('Package File', 'Install Path');
|
||||
$installed = false;
|
||||
} else {
|
||||
$info = $reg->packageInfo($params[0]);
|
||||
$headings = array('Type', 'Install Path');
|
||||
$installed = true;
|
||||
}
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
if ($info === null) {
|
||||
return $this->raiseError("`$params[0]' not installed");
|
||||
}
|
||||
$list = $info['filelist'];
|
||||
if ($installed) {
|
||||
$caption = 'Installed Files For ' . $params[0];
|
||||
} else {
|
||||
$caption = 'Contents of ' . basename($params[0]);
|
||||
}
|
||||
$data = array(
|
||||
'caption' => $caption,
|
||||
'border' => true,
|
||||
'headline' => $headings);
|
||||
foreach ($list as $file => $att) {
|
||||
if ($installed) {
|
||||
if (empty($att['installed_as'])) {
|
||||
continue;
|
||||
}
|
||||
$data['data'][] = array($att['role'], $att['installed_as']);
|
||||
} else {
|
||||
if (isset($att['baseinstalldir'])) {
|
||||
$dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR .
|
||||
$file;
|
||||
} else {
|
||||
$dest = $file;
|
||||
}
|
||||
switch ($att['role']) {
|
||||
case 'test':
|
||||
case 'data':
|
||||
if ($installed) {
|
||||
break 2;
|
||||
}
|
||||
$dest = '-- will not be installed --';
|
||||
break;
|
||||
case 'doc':
|
||||
$dest = $this->config->get('doc_dir') . DIRECTORY_SEPARATOR .
|
||||
$dest;
|
||||
break;
|
||||
case 'php':
|
||||
default:
|
||||
$dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR .
|
||||
$dest;
|
||||
}
|
||||
$dest = preg_replace('!/+!', '/', $dest);
|
||||
$file = preg_replace('!/+!', '/', $file);
|
||||
$data['data'][] = array($file, $dest);
|
||||
}
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doShellTest()
|
||||
|
||||
function doShellTest($command, $options, $params)
|
||||
{
|
||||
$this->pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$reg = &new PEAR_Registry($this->config->get('php_dir'));
|
||||
// "pear shell-test Foo"
|
||||
if (sizeof($params) == 1) {
|
||||
if (!$reg->packageExists($params[0])) {
|
||||
exit(1);
|
||||
}
|
||||
// "pear shell-test Foo 1.0"
|
||||
} elseif (sizeof($params) == 2) {
|
||||
$v = $reg->packageInfo($params[0], 'version');
|
||||
if (!$v || !version_compare("$v", "{$params[1]}", "ge")) {
|
||||
exit(1);
|
||||
}
|
||||
// "pear shell-test Foo ge 1.0"
|
||||
} elseif (sizeof($params) == 3) {
|
||||
$v = $reg->packageInfo($params[0], 'version');
|
||||
if (!$v || !version_compare("$v", "{$params[2]}", $params[1])) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$this->popErrorHandling();
|
||||
$this->raiseError("$command: expects 1 to 3 parameters");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doInfo
|
||||
|
||||
function doInfo($command, $options, $params)
|
||||
{
|
||||
// $params[0] The package for showing info
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("This command only accepts one param: ".
|
||||
"the package you want information");
|
||||
}
|
||||
if (@is_file($params[0])) {
|
||||
$obj = &new PEAR_Common();
|
||||
$info = $obj->infoFromAny($params[0]);
|
||||
} else {
|
||||
$reg = &new PEAR_Registry($this->config->get('php_dir'));
|
||||
$info = $reg->packageInfo($params[0]);
|
||||
}
|
||||
if (PEAR::isError($info)) {
|
||||
return $info;
|
||||
}
|
||||
if (empty($info)) {
|
||||
$this->raiseError("Nothing found for `$params[0]'");
|
||||
return;
|
||||
}
|
||||
unset($info['filelist']);
|
||||
unset($info['changelog']);
|
||||
$keys = array_keys($info);
|
||||
$longtext = array('description', 'summary');
|
||||
foreach ($keys as $key) {
|
||||
if (is_array($info[$key])) {
|
||||
switch ($key) {
|
||||
case 'maintainers': {
|
||||
$i = 0;
|
||||
$mstr = '';
|
||||
foreach ($info[$key] as $m) {
|
||||
if ($i++ > 0) {
|
||||
$mstr .= "\n";
|
||||
}
|
||||
$mstr .= $m['name'] . " <";
|
||||
if (isset($m['email'])) {
|
||||
$mstr .= $m['email'];
|
||||
} else {
|
||||
$mstr .= $m['handle'] . '@php.net';
|
||||
}
|
||||
$mstr .= "> ($m[role])";
|
||||
}
|
||||
$info[$key] = $mstr;
|
||||
break;
|
||||
}
|
||||
case 'release_deps': {
|
||||
$i = 0;
|
||||
$dstr = '';
|
||||
foreach ($info[$key] as $d) {
|
||||
if (isset($this->_deps_rel_trans[$d['rel']])) {
|
||||
$rel = $this->_deps_rel_trans[$d['rel']];
|
||||
} else {
|
||||
$rel = $d['rel'];
|
||||
}
|
||||
if (isset($this->_deps_type_trans[$d['type']])) {
|
||||
$type = ucfirst($this->_deps_type_trans[$d['type']]);
|
||||
} else {
|
||||
$type = $d['type'];
|
||||
}
|
||||
if (isset($d['name'])) {
|
||||
$name = $d['name'] . ' ';
|
||||
} else {
|
||||
$name = '';
|
||||
}
|
||||
if (isset($d['version'])) {
|
||||
$version = $d['version'] . ' ';
|
||||
} else {
|
||||
$version = '';
|
||||
}
|
||||
$dstr .= "$type $name$rel $version\n";
|
||||
}
|
||||
$info[$key] = $dstr;
|
||||
break;
|
||||
}
|
||||
case 'provides' : {
|
||||
$debug = $this->config->get('verbose');
|
||||
if ($debug < 2) {
|
||||
$pstr = 'Classes: ';
|
||||
} else {
|
||||
$pstr = '';
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($info[$key] as $p) {
|
||||
if ($debug < 2 && $p['type'] != "class") {
|
||||
continue;
|
||||
}
|
||||
// Only print classes when verbosity mode is < 2
|
||||
if ($debug < 2) {
|
||||
if ($i++ > 0) {
|
||||
$pstr .= ", ";
|
||||
}
|
||||
$pstr .= $p['name'];
|
||||
} else {
|
||||
if ($i++ > 0) {
|
||||
$pstr .= "\n";
|
||||
}
|
||||
$pstr .= ucfirst($p['type']) . " " . $p['name'];
|
||||
if (isset($p['explicit']) && $p['explicit'] == 1) {
|
||||
$pstr .= " (explicit)";
|
||||
}
|
||||
}
|
||||
}
|
||||
$info[$key] = $pstr;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$info[$key] = implode(", ", $info[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($key == '_lastmodified') {
|
||||
$hdate = date('Y-m-d', $info[$key]);
|
||||
unset($info[$key]);
|
||||
$info['Last Modified'] = $hdate;
|
||||
} else {
|
||||
$info[$key] = trim($info[$key]);
|
||||
if (in_array($key, $longtext)) {
|
||||
$info[$key] = preg_replace('/ +/', ' ', $info[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$caption = 'About ' . $info['package'] . '-' . $info['version'];
|
||||
$data = array(
|
||||
'caption' => $caption,
|
||||
'border' => true);
|
||||
foreach ($info as $key => $value) {
|
||||
$key = ucwords(trim(str_replace('_', ' ', $key)));
|
||||
$data['data'][] = array($key, $value);
|
||||
}
|
||||
$data['raw'] = $info;
|
||||
|
||||
$this->ui->outputData($data, 'package-info');
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,435 +0,0 @@
|
||||
<?php
|
||||
// /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Stig Bakken <ssb@php.net> |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
require_once 'PEAR/Common.php';
|
||||
require_once 'PEAR/Remote.php';
|
||||
require_once 'PEAR/Registry.php';
|
||||
|
||||
class PEAR_Command_Remote extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ command definitions
|
||||
|
||||
var $commands = array(
|
||||
'remote-info' => array(
|
||||
'summary' => 'Information About Remote Packages',
|
||||
'function' => 'doRemoteInfo',
|
||||
'shortcut' => 'ri',
|
||||
'options' => array(),
|
||||
'doc' => '<package>
|
||||
Get details on a package from the server.',
|
||||
),
|
||||
'list-upgrades' => array(
|
||||
'summary' => 'List Available Upgrades',
|
||||
'function' => 'doListUpgrades',
|
||||
'shortcut' => 'lu',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
List releases on the server of packages you have installed where
|
||||
a newer version is available with the same release state (stable etc.).'
|
||||
),
|
||||
'remote-list' => array(
|
||||
'summary' => 'List Remote Packages',
|
||||
'function' => 'doRemoteList',
|
||||
'shortcut' => 'rl',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Lists the packages available on the configured server along with the
|
||||
latest stable release of each package.',
|
||||
),
|
||||
'search' => array(
|
||||
'summary' => 'Search remote package database',
|
||||
'function' => 'doSearch',
|
||||
'shortcut' => 'sp',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Lists all packages which match the search parameters (first param
|
||||
is package name, second package info)',
|
||||
),
|
||||
'list-all' => array(
|
||||
'summary' => 'List All Packages',
|
||||
'function' => 'doListAll',
|
||||
'shortcut' => 'la',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Lists the packages available on the configured server along with the
|
||||
latest stable release of each package.',
|
||||
),
|
||||
'download' => array(
|
||||
'summary' => 'Download Package',
|
||||
'function' => 'doDownload',
|
||||
'shortcut' => 'd',
|
||||
'options' => array(
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'download an uncompressed (.tar) file',
|
||||
),
|
||||
),
|
||||
'doc' => '{package|package-version}
|
||||
Download a package tarball. The file will be named as suggested by the
|
||||
server, for example if you download the DB package and the latest stable
|
||||
version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
|
||||
),
|
||||
'clear-cache' => array(
|
||||
'summary' => 'Clear XML-RPC Cache',
|
||||
'function' => 'doClearCache',
|
||||
'shortcut' => 'cc',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Clear the XML-RPC cache. See also the cache_ttl configuration
|
||||
parameter.
|
||||
',
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Remote constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Remote(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doRemoteInfo()
|
||||
|
||||
function doRemoteInfo($command, $options, $params)
|
||||
{
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("$command expects one param: the remote package name");
|
||||
}
|
||||
$r = new PEAR_Remote($this->config);
|
||||
$info = $r->call('package.info', $params[0]);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
|
||||
$reg = new PEAR_Registry($this->config->get('php_dir'));
|
||||
$installed = $reg->packageInfo($info['name']);
|
||||
$info['installed'] = $installed['version'] ? $installed['version'] : '- no -';
|
||||
|
||||
$this->ui->outputData($info, $command);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doRemoteList()
|
||||
|
||||
function doRemoteList($command, $options, $params)
|
||||
{
|
||||
$r = new PEAR_Remote($this->config);
|
||||
$list_options = false;
|
||||
if ($this->config->get('preferred_state') == 'stable')
|
||||
$list_options = true;
|
||||
$available = $r->call('package.listAll', $list_options);
|
||||
if (PEAR::isError($available)) {
|
||||
return $this->raiseError($available);
|
||||
}
|
||||
$i = $j = 0;
|
||||
$data = array(
|
||||
'caption' => 'Available packages:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Version'),
|
||||
);
|
||||
foreach ($available as $name => $info) {
|
||||
$data['data'][] = array($name, isset($info['stable']) ? $info['stable'] : '-n/a-');
|
||||
}
|
||||
if (count($available)==0) {
|
||||
$data = '(no packages installed yet)';
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doListAll()
|
||||
|
||||
function doListAll($command, $options, $params)
|
||||
{
|
||||
$r = new PEAR_Remote($this->config);
|
||||
$reg = new PEAR_Registry($this->config->get('php_dir'));
|
||||
$list_options = false;
|
||||
if ($this->config->get('preferred_state') == 'stable')
|
||||
$list_options = true;
|
||||
$available = $r->call('package.listAll', $list_options);
|
||||
if (PEAR::isError($available)) {
|
||||
return $this->raiseError($available);
|
||||
}
|
||||
if (!is_array($available)) {
|
||||
return $this->raiseError('The package list could not be fetched from the remote server. Please try again. (Debug info: "'.$available.'")');
|
||||
}
|
||||
$data = array(
|
||||
'caption' => 'All packages:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Latest', 'Local'),
|
||||
);
|
||||
$local_pkgs = $reg->listPackages();
|
||||
|
||||
foreach ($available as $name => $info) {
|
||||
$installed = $reg->packageInfo($name);
|
||||
$desc = $info['summary'];
|
||||
if (isset($params[$name]))
|
||||
$desc .= "\n\n".$info['description'];
|
||||
|
||||
if (isset($options['mode']))
|
||||
{
|
||||
if ($options['mode'] == 'installed' && !isset($installed['version']))
|
||||
continue;
|
||||
if ($options['mode'] == 'notinstalled' && isset($installed['version']))
|
||||
continue;
|
||||
if ($options['mode'] == 'upgrades'
|
||||
&& (!isset($installed['version']) || $installed['version'] == $info['stable']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$pos = array_search(strtolower($name), $local_pkgs);
|
||||
if ($pos !== false) {
|
||||
unset($local_pkgs[$pos]);
|
||||
}
|
||||
|
||||
$data['data'][$info['category']][] = array(
|
||||
$name,
|
||||
@$info['stable'],
|
||||
@$installed['version'],
|
||||
@$desc,
|
||||
@$info['deps'],
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($local_pkgs as $name) {
|
||||
$info = $reg->packageInfo($name);
|
||||
$data['data']['Local'][] = array(
|
||||
$info['package'],
|
||||
'',
|
||||
$info['version'],
|
||||
$info['summary'],
|
||||
@$info['release_deps']
|
||||
);
|
||||
}
|
||||
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doSearch()
|
||||
|
||||
function doSearch($command, $options, $params)
|
||||
{
|
||||
if ((!isset($params[0]) || empty($params[0]))
|
||||
&& (!isset($params[1]) || empty($params[1])))
|
||||
{
|
||||
return $this->raiseError('no valid search string supplied');
|
||||
};
|
||||
|
||||
$r = new PEAR_Remote($this->config);
|
||||
$reg = new PEAR_Registry($this->config->get('php_dir'));
|
||||
$available = $r->call('package.listAll', true, false);
|
||||
if (PEAR::isError($available)) {
|
||||
return $this->raiseError($available);
|
||||
}
|
||||
$data = array(
|
||||
'caption' => 'Matched packages:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Stable/(Latest)', 'Local'),
|
||||
);
|
||||
|
||||
foreach ($available as $name => $info) {
|
||||
$found = (!empty($params[0]) && stristr($name, $params[0]) !== false);
|
||||
if (!$found && !(isset($params[1]) && !empty($params[1])
|
||||
&& (stristr($info['summary'], $params[1]) !== false
|
||||
|| stristr($info['description'], $params[1]) !== false)))
|
||||
{
|
||||
continue;
|
||||
};
|
||||
|
||||
$installed = $reg->packageInfo($name);
|
||||
$desc = $info['summary'];
|
||||
if (isset($params[$name]))
|
||||
$desc .= "\n\n".$info['description'];
|
||||
|
||||
$unstable = '';
|
||||
if ($info['unstable']) {
|
||||
$unstable = '/(' . $info['unstable'] . $info['state'] . ')';
|
||||
}
|
||||
if (!isset($info['stable']) || !$info['stable']) {
|
||||
$info['stable'] = 'none';
|
||||
}
|
||||
$data['data'][$info['category']][] = array(
|
||||
$name,
|
||||
$info['stable'] . $unstable,
|
||||
$installed['version'],
|
||||
$desc,
|
||||
);
|
||||
}
|
||||
if (!isset($data['data'])) {
|
||||
return $this->raiseError('no packages found');
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doDownload()
|
||||
|
||||
function doDownload($command, $options, $params)
|
||||
{
|
||||
//$params[0] -> The package to download
|
||||
if (count($params) != 1) {
|
||||
return PEAR::raiseError("download expects one argument: the package to download");
|
||||
}
|
||||
$server = $this->config->get('master_server');
|
||||
if (!ereg('^http://', $params[0])) {
|
||||
$getoption = isset($options['nocompress'])&&$options['nocompress']==1?'?uncompress=on':'';
|
||||
$pkgfile = "http://$server/get/$params[0]".$getoption;
|
||||
} else {
|
||||
$pkgfile = $params[0];
|
||||
}
|
||||
$this->bytes_downloaded = 0;
|
||||
$saved = PEAR_Common::downloadHttp($pkgfile, $this->ui, '.',
|
||||
array(&$this, 'downloadCallback'));
|
||||
if (PEAR::isError($saved)) {
|
||||
return $this->raiseError($saved);
|
||||
}
|
||||
$fname = basename($saved);
|
||||
$this->ui->outputData("File $fname downloaded ($this->bytes_downloaded bytes)", $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
function downloadCallback($msg, $params = null)
|
||||
{
|
||||
if ($msg == 'done') {
|
||||
$this->bytes_downloaded = $params;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doListUpgrades()
|
||||
|
||||
function doListUpgrades($command, $options, $params)
|
||||
{
|
||||
include_once "PEAR/Registry.php";
|
||||
$remote = new PEAR_Remote($this->config);
|
||||
if (empty($params[0])) {
|
||||
$state = $this->config->get('preferred_state');
|
||||
} else {
|
||||
$state = $params[0];
|
||||
}
|
||||
$caption = 'Available Upgrades';
|
||||
if (empty($state) || $state == 'any') {
|
||||
$latest = $remote->call("package.listLatestReleases");
|
||||
} else {
|
||||
$latest = $remote->call("package.listLatestReleases", $state);
|
||||
$caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
|
||||
}
|
||||
$caption .= ':';
|
||||
if (PEAR::isError($latest)) {
|
||||
return $latest;
|
||||
}
|
||||
$reg = new PEAR_Registry($this->config->get('php_dir'));
|
||||
$inst = array_flip($reg->listPackages());
|
||||
$data = array(
|
||||
'caption' => $caption,
|
||||
'border' => 1,
|
||||
'headline' => array('Package', 'Local', 'Remote', 'Size'),
|
||||
);
|
||||
foreach ((array)$latest as $pkg => $info) {
|
||||
$package = strtolower($pkg);
|
||||
if (!isset($inst[$package])) {
|
||||
// skip packages we don't have installed
|
||||
continue;
|
||||
}
|
||||
extract($info);
|
||||
$pkginfo = $reg->packageInfo($package);
|
||||
$inst_version = $pkginfo['version'];
|
||||
$inst_state = $pkginfo['release_state'];
|
||||
if (version_compare("$version", "$inst_version", "le")) {
|
||||
// installed version is up-to-date
|
||||
continue;
|
||||
}
|
||||
if ($filesize >= 20480) {
|
||||
$filesize += 1024 - ($filesize % 1024);
|
||||
$fs = sprintf("%dkB", $filesize / 1024);
|
||||
} elseif ($filesize > 0) {
|
||||
$filesize += 103 - ($filesize % 103);
|
||||
$fs = sprintf("%.1fkB", $filesize / 1024.0);
|
||||
} else {
|
||||
$fs = " -"; // XXX center instead
|
||||
}
|
||||
$data['data'][] = array($pkg, "$inst_version ($inst_state)", "$version ($state)", $fs);
|
||||
}
|
||||
if (empty($data['data'])) {
|
||||
$this->ui->outputData('No upgrades available');
|
||||
} else {
|
||||
$this->ui->outputData($data, $command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doClearCache()
|
||||
|
||||
function doClearCache($command, $options, $params)
|
||||
{
|
||||
$cache_dir = $this->config->get('cache_dir');
|
||||
$verbose = $this->config->get('verbose');
|
||||
$output = '';
|
||||
if (!($dp = @opendir($cache_dir))) {
|
||||
return $this->raiseError("opendir($cache_dir) failed: $php_errormsg");
|
||||
}
|
||||
if ($verbose >= 1) {
|
||||
$output .= "reading directory $cache_dir\n";
|
||||
}
|
||||
$num = 0;
|
||||
while ($ent = readdir($dp)) {
|
||||
if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}$/', $ent)) {
|
||||
$path = $cache_dir . DIRECTORY_SEPARATOR . $ent;
|
||||
$ok = @unlink($path);
|
||||
if ($ok) {
|
||||
if ($verbose >= 2) {
|
||||
$output .= "deleted $path\n";
|
||||
}
|
||||
$num++;
|
||||
} elseif ($verbose >= 1) {
|
||||
$output .= "failed to delete $path\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dp);
|
||||
if ($verbose >= 1) {
|
||||
$output .= "$num cache entries cleared\n";
|
||||
}
|
||||
$this->ui->outputData(rtrim($output), $command);
|
||||
return $num;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,509 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2004 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Stig Sæther Bakken <ssb@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
require_once "PEAR.php";
|
||||
|
||||
class PEAR_Frontend_CLI extends PEAR
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* What type of user interface this frontend is for.
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $type = 'CLI';
|
||||
var $lp = ''; // line prefix
|
||||
|
||||
var $params = array();
|
||||
var $term = array(
|
||||
'bold' => '',
|
||||
'normal' => '',
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
function PEAR_Frontend_CLI()
|
||||
{
|
||||
parent::PEAR();
|
||||
$term = getenv('TERM'); //(cox) $_ENV is empty for me in 4.1.1
|
||||
if (function_exists('posix_isatty') && !posix_isatty(1)) {
|
||||
// output is being redirected to a file or through a pipe
|
||||
} elseif ($term) {
|
||||
// XXX can use ncurses extension here, if available
|
||||
if (preg_match('/^(xterm|vt220|linux)/', $term)) {
|
||||
$this->term['bold'] = sprintf("%c%c%c%c", 27, 91, 49, 109);
|
||||
$this->term['normal']=sprintf("%c%c%c", 27, 91, 109);
|
||||
} elseif (preg_match('/^vt100/', $term)) {
|
||||
$this->term['bold'] = sprintf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0);
|
||||
$this->term['normal']=sprintf("%c%c%c%c%c", 27, 91, 109, 0, 0);
|
||||
}
|
||||
} elseif (OS_WINDOWS) {
|
||||
// XXX add ANSI codes here
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ displayLine(text)
|
||||
|
||||
function displayLine($text)
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::displayLine deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _displayLine($text)
|
||||
{
|
||||
print "$this->lp$text\n";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ display(text)
|
||||
|
||||
function display($text)
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::display deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _display($text)
|
||||
{
|
||||
print $text;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayError(eobj)
|
||||
|
||||
/**
|
||||
* @param object PEAR_Error object
|
||||
*/
|
||||
function displayError($eobj)
|
||||
{
|
||||
return $this->_displayLine($eobj->getMessage());
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayFatalError(eobj)
|
||||
|
||||
/**
|
||||
* @param object PEAR_Error object
|
||||
*/
|
||||
function displayFatalError($eobj)
|
||||
{
|
||||
$this->displayError($eobj);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayHeading(title)
|
||||
|
||||
function displayHeading($title)
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::displayHeading deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _displayHeading($title)
|
||||
{
|
||||
print $this->lp.$this->bold($title)."\n";
|
||||
print $this->lp.str_repeat("=", strlen($title))."\n";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ userDialog(prompt, [type], [default])
|
||||
|
||||
function userDialog($command, $prompts, $types = array(), $defaults = array())
|
||||
{
|
||||
$result = array();
|
||||
if (is_array($prompts)) {
|
||||
$fp = fopen("php://stdin", "r");
|
||||
foreach ($prompts as $key => $prompt) {
|
||||
$type = $types[$key];
|
||||
$default = @$defaults[$key];
|
||||
if ($type == 'password') {
|
||||
system('stty -echo');
|
||||
}
|
||||
print "$this->lp$prompt ";
|
||||
if ($default) {
|
||||
print "[$default] ";
|
||||
}
|
||||
print ": ";
|
||||
$line = fgets($fp, 2048);
|
||||
if ($type == 'password') {
|
||||
system('stty echo');
|
||||
print "\n";
|
||||
}
|
||||
if ($default && trim($line) == "") {
|
||||
$result[$key] = $default;
|
||||
} else {
|
||||
$result[$key] = $line;
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ userConfirm(prompt, [default])
|
||||
|
||||
function userConfirm($prompt, $default = 'yes')
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::userConfirm not yet converted", E_USER_ERROR);
|
||||
static $positives = array('y', 'yes', 'on', '1');
|
||||
static $negatives = array('n', 'no', 'off', '0');
|
||||
print "$this->lp$prompt [$default] : ";
|
||||
$fp = fopen("php://stdin", "r");
|
||||
$line = fgets($fp, 2048);
|
||||
fclose($fp);
|
||||
$answer = strtolower(trim($line));
|
||||
if (empty($answer)) {
|
||||
$answer = $default;
|
||||
}
|
||||
if (in_array($answer, $positives)) {
|
||||
return true;
|
||||
}
|
||||
if (in_array($answer, $negatives)) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($default, $positives)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ startTable([params])
|
||||
|
||||
function startTable($params = array())
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::startTable deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _startTable($params = array())
|
||||
{
|
||||
$params['table_data'] = array();
|
||||
$params['widest'] = array(); // indexed by column
|
||||
$params['highest'] = array(); // indexed by row
|
||||
$params['ncols'] = 0;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ tableRow(columns, [rowparams], [colparams])
|
||||
|
||||
function tableRow($columns, $rowparams = array(), $colparams = array())
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::tableRow deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _tableRow($columns, $rowparams = array(), $colparams = array())
|
||||
{
|
||||
$highest = 1;
|
||||
for ($i = 0; $i < sizeof($columns); $i++) {
|
||||
$col = &$columns[$i];
|
||||
if (isset($colparams[$i]) && !empty($colparams[$i]['wrap'])) {
|
||||
$col = wordwrap($col, $colparams[$i]['wrap'], "\n", 0);
|
||||
}
|
||||
if (strpos($col, "\n") !== false) {
|
||||
$multiline = explode("\n", $col);
|
||||
$w = 0;
|
||||
foreach ($multiline as $n => $line) {
|
||||
if (strlen($line) > $w) {
|
||||
$w = strlen($line);
|
||||
}
|
||||
}
|
||||
$lines = sizeof($multiline);
|
||||
} else {
|
||||
$w = strlen($col);
|
||||
}
|
||||
if ($w > @$this->params['widest'][$i]) {
|
||||
$this->params['widest'][$i] = $w;
|
||||
}
|
||||
$tmp = count_chars($columns[$i], 1);
|
||||
// handle unix, mac and windows formats
|
||||
$lines = (isset($tmp[10]) ? $tmp[10] : @$tmp[13]) + 1;
|
||||
if ($lines > $highest) {
|
||||
$highest = $lines;
|
||||
}
|
||||
}
|
||||
if (sizeof($columns) > $this->params['ncols']) {
|
||||
$this->params['ncols'] = sizeof($columns);
|
||||
}
|
||||
$new_row = array(
|
||||
'data' => $columns,
|
||||
'height' => $highest,
|
||||
'rowparams' => $rowparams,
|
||||
'colparams' => $colparams,
|
||||
);
|
||||
$this->params['table_data'][] = $new_row;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ endTable()
|
||||
|
||||
function endTable()
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::endTable deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _endTable()
|
||||
{
|
||||
extract($this->params);
|
||||
if (!empty($caption)) {
|
||||
$this->_displayHeading($caption);
|
||||
}
|
||||
if (count($table_data) == 0) {
|
||||
return;
|
||||
}
|
||||
if (!isset($width)) {
|
||||
$width = $widest;
|
||||
} else {
|
||||
for ($i = 0; $i < $ncols; $i++) {
|
||||
if (!isset($width[$i])) {
|
||||
$width[$i] = $widest[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
$border = false;
|
||||
if (empty($border)) {
|
||||
$cellstart = '';
|
||||
$cellend = ' ';
|
||||
$rowend = '';
|
||||
$padrowend = false;
|
||||
$borderline = '';
|
||||
} else {
|
||||
$cellstart = '| ';
|
||||
$cellend = ' ';
|
||||
$rowend = '|';
|
||||
$padrowend = true;
|
||||
$borderline = '+';
|
||||
foreach ($width as $w) {
|
||||
$borderline .= str_repeat('-', $w + strlen($cellstart) + strlen($cellend) - 1);
|
||||
$borderline .= '+';
|
||||
}
|
||||
}
|
||||
if ($borderline) {
|
||||
$this->_displayLine($borderline);
|
||||
}
|
||||
for ($i = 0; $i < sizeof($table_data); $i++) {
|
||||
extract($table_data[$i]);
|
||||
if (!is_array($rowparams)) {
|
||||
$rowparams = array();
|
||||
}
|
||||
if (!is_array($colparams)) {
|
||||
$colparams = array();
|
||||
}
|
||||
$rowlines = array();
|
||||
if ($height > 1) {
|
||||
for ($c = 0; $c < sizeof($data); $c++) {
|
||||
$rowlines[$c] = preg_split('/(\r?\n|\r)/', $data[$c]);
|
||||
if (sizeof($rowlines[$c]) < $height) {
|
||||
$rowlines[$c] = array_pad($rowlines[$c], $height, '');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($c = 0; $c < sizeof($data); $c++) {
|
||||
$rowlines[$c] = array($data[$c]);
|
||||
}
|
||||
}
|
||||
for ($r = 0; $r < $height; $r++) {
|
||||
$rowtext = '';
|
||||
for ($c = 0; $c < sizeof($data); $c++) {
|
||||
if (isset($colparams[$c])) {
|
||||
$attribs = array_merge($rowparams, $colparams);
|
||||
} else {
|
||||
$attribs = $rowparams;
|
||||
}
|
||||
$w = isset($width[$c]) ? $width[$c] : 0;
|
||||
//$cell = $data[$c];
|
||||
$cell = $rowlines[$c][$r];
|
||||
$l = strlen($cell);
|
||||
if ($l > $w) {
|
||||
$cell = substr($cell, 0, $w);
|
||||
}
|
||||
if (isset($attribs['bold'])) {
|
||||
$cell = $this->bold($cell);
|
||||
}
|
||||
if ($l < $w) {
|
||||
// not using str_pad here because we may
|
||||
// add bold escape characters to $cell
|
||||
$cell .= str_repeat(' ', $w - $l);
|
||||
}
|
||||
|
||||
$rowtext .= $cellstart . $cell . $cellend;
|
||||
}
|
||||
if (!$border) {
|
||||
$rowtext = rtrim($rowtext);
|
||||
}
|
||||
$rowtext .= $rowend;
|
||||
$this->_displayLine($rowtext);
|
||||
}
|
||||
}
|
||||
if ($borderline) {
|
||||
$this->_displayLine($borderline);
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ outputData()
|
||||
|
||||
function outputData($data, $command = '_default')
|
||||
{
|
||||
switch ($command) {
|
||||
case 'install':
|
||||
case 'upgrade':
|
||||
case 'upgrade-all':
|
||||
if (isset($data['release_warnings'])) {
|
||||
$this->_displayLine('');
|
||||
$this->_startTable(array(
|
||||
'border' => false,
|
||||
'caption' => 'Release Warnings'
|
||||
));
|
||||
$this->_tableRow(array($data['release_warnings']), null, array(1 => array('wrap' => 55)));
|
||||
$this->_endTable();
|
||||
$this->_displayLine('');
|
||||
}
|
||||
$this->_displayLine($data['data']);
|
||||
break;
|
||||
case 'search':
|
||||
$this->_startTable($data);
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'], array('bold' => true), array(1 => array('wrap' => 55)));
|
||||
}
|
||||
|
||||
foreach($data['data'] as $category) {
|
||||
foreach($category as $pkg) {
|
||||
$this->_tableRow($pkg, null, array(1 => array('wrap' => 55)));
|
||||
}
|
||||
};
|
||||
$this->_endTable();
|
||||
break;
|
||||
case 'list-all':
|
||||
$this->_startTable($data);
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'], array('bold' => true), array(1 => array('wrap' => 55)));
|
||||
}
|
||||
|
||||
foreach($data['data'] as $category) {
|
||||
foreach($category as $pkg) {
|
||||
unset($pkg[3]);
|
||||
unset($pkg[4]);
|
||||
$this->_tableRow($pkg, null, array(1 => array('wrap' => 55)));
|
||||
}
|
||||
};
|
||||
$this->_endTable();
|
||||
break;
|
||||
case 'config-show':
|
||||
$data['border'] = false;
|
||||
$opts = array(0 => array('wrap' => 30),
|
||||
1 => array('wrap' => 20),
|
||||
2 => array('wrap' => 35));
|
||||
$this->_startTable($data);
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'],
|
||||
array('bold' => true),
|
||||
$opts);
|
||||
}
|
||||
foreach($data['data'] as $group) {
|
||||
foreach($group as $value) {
|
||||
if ($value[2] == '') {
|
||||
$value[2] = "<not set>";
|
||||
}
|
||||
$this->_tableRow($value, null, $opts);
|
||||
}
|
||||
}
|
||||
$this->_endTable();
|
||||
break;
|
||||
case 'remote-info':
|
||||
$data = array(
|
||||
'caption' => 'Package details:',
|
||||
'border' => false,
|
||||
'data' => array(
|
||||
array("Latest", $data['stable']),
|
||||
array("Installed", $data['installed']),
|
||||
array("Package", $data['name']),
|
||||
array("License", $data['license']),
|
||||
array("Category", $data['category']),
|
||||
array("Summary", $data['summary']),
|
||||
array("Description", $data['description']),
|
||||
),
|
||||
);
|
||||
default: {
|
||||
if (is_array($data)) {
|
||||
$this->_startTable($data);
|
||||
$count = count($data['data'][0]);
|
||||
if ($count == 2) {
|
||||
$opts = array(0 => array('wrap' => 25),
|
||||
1 => array('wrap' => 48)
|
||||
);
|
||||
} elseif ($count == 3) {
|
||||
$opts = array(0 => array('wrap' => 30),
|
||||
1 => array('wrap' => 20),
|
||||
2 => array('wrap' => 35)
|
||||
);
|
||||
} else {
|
||||
$opts = null;
|
||||
}
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'],
|
||||
array('bold' => true),
|
||||
$opts);
|
||||
}
|
||||
foreach($data['data'] as $row) {
|
||||
$this->_tableRow($row, null, $opts);
|
||||
}
|
||||
$this->_endTable();
|
||||
} else {
|
||||
$this->_displayLine($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ log(text)
|
||||
|
||||
|
||||
function log($text, $append_crlf = true)
|
||||
{
|
||||
if ($append_crlf) {
|
||||
return $this->_displayLine($text);
|
||||
}
|
||||
return $this->_display($text);
|
||||
}
|
||||
|
||||
|
||||
// }}}
|
||||
// {{{ bold($text)
|
||||
|
||||
function bold($text)
|
||||
{
|
||||
if (empty($this->term['bold'])) {
|
||||
return strtoupper($text);
|
||||
}
|
||||
return $this->term['bold'] . $text . $this->term['normal'];
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
18
pear/README
18
pear/README
@@ -1,18 +0,0 @@
|
||||
PEAR - PHP Extension and Application Repository
|
||||
===============================================
|
||||
Dedicated to Malin Bakken, born 1999-11-21
|
||||
|
||||
WHAT IS PEAR?
|
||||
|
||||
PEAR is a code repository for PHP extensions and PHP library code
|
||||
similar to TeX's CTAN and Perl's CPAN.
|
||||
|
||||
The intention behind PEAR is to provide a means for library code
|
||||
authors to organize their code in a defined way shared by other
|
||||
developers, and to give the PHP community a single source for such
|
||||
code.
|
||||
|
||||
|
||||
DOCUMENTATION
|
||||
|
||||
Documentation for PEAR can be found at http://pear.php.net/manual/.
|
||||
540
pear/System.php
540
pear/System.php
@@ -1,540 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Tomas V.V.Cox <cox@idecnet.com> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'PEAR.php';
|
||||
require_once 'Console/Getopt.php';
|
||||
|
||||
$GLOBALS['_System_temp_files'] = array();
|
||||
|
||||
/**
|
||||
* System offers cross plattform compatible system functions
|
||||
*
|
||||
* Static functions for different operations. Should work under
|
||||
* Unix and Windows. The names and usage has been taken from its respectively
|
||||
* GNU commands. The functions will return (bool) false on error and will
|
||||
* trigger the error with the PHP trigger_error() function (you can silence
|
||||
* the error by prefixing a '@' sign after the function call).
|
||||
*
|
||||
* Documentation on this class you can find in:
|
||||
* http://pear.php.net/manual/
|
||||
*
|
||||
* Example usage:
|
||||
* if (!@System::rm('-r file1 dir1')) {
|
||||
* print "could not delete file1 or dir1";
|
||||
* }
|
||||
*
|
||||
* In case you need to to pass file names with spaces,
|
||||
* pass the params as an array:
|
||||
*
|
||||
* System::rm(array('-r', $file1, $dir1));
|
||||
*
|
||||
* @package System
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
* @version $Revision$
|
||||
* @access public
|
||||
* @see http://pear.php.net/manual/
|
||||
*/
|
||||
class System
|
||||
{
|
||||
/**
|
||||
* returns the commandline arguments of a function
|
||||
*
|
||||
* @param string $argv the commandline
|
||||
* @param string $short_options the allowed option short-tags
|
||||
* @param string $long_options the allowed option long-tags
|
||||
* @return array the given options and there values
|
||||
* @access private
|
||||
*/
|
||||
function _parseArgs($argv, $short_options, $long_options = null)
|
||||
{
|
||||
if (!is_array($argv) && $argv !== null) {
|
||||
$argv = preg_split('/\s+/', $argv);
|
||||
}
|
||||
return Console_Getopt::getopt2($argv, $short_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output errors with PHP trigger_error(). You can silence the errors
|
||||
* with prefixing a "@" sign to the function call: @System::mkdir(..);
|
||||
*
|
||||
* @param mixed $error a PEAR error or a string with the error message
|
||||
* @return bool false
|
||||
* @access private
|
||||
*/
|
||||
function raiseError($error)
|
||||
{
|
||||
if (PEAR::isError($error)) {
|
||||
$error = $error->getMessage();
|
||||
}
|
||||
trigger_error($error, E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a nested array representing the structure of a directory
|
||||
*
|
||||
* System::_dirToStruct('dir1', 0) =>
|
||||
* Array
|
||||
* (
|
||||
* [dirs] => Array
|
||||
* (
|
||||
* [0] => dir1
|
||||
* )
|
||||
*
|
||||
* [files] => Array
|
||||
* (
|
||||
* [0] => dir1/file2
|
||||
* [1] => dir1/file3
|
||||
* )
|
||||
* )
|
||||
* @param string $sPath Name of the directory
|
||||
* @param integer $maxinst max. deep of the lookup
|
||||
* @param integer $aktinst starting deep of the lookup
|
||||
* @return array the structure of the dir
|
||||
* @access private
|
||||
*/
|
||||
|
||||
function _dirToStruct($sPath, $maxinst, $aktinst = 0)
|
||||
{
|
||||
$struct = array('dirs' => array(), 'files' => array());
|
||||
if (($dir = @opendir($sPath)) === false) {
|
||||
System::raiseError("Could not open dir $sPath");
|
||||
return $struct; // XXX could not open error
|
||||
}
|
||||
$struct['dirs'][] = $sPath; // XXX don't add if '.' or '..' ?
|
||||
$list = array();
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$list[] = $file;
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
sort($list);
|
||||
if ($aktinst < $maxinst || $maxinst == 0) {
|
||||
foreach($list as $val) {
|
||||
$path = $sPath . DIRECTORY_SEPARATOR . $val;
|
||||
if (is_dir($path)) {
|
||||
$tmp = System::_dirToStruct($path, $maxinst, $aktinst+1);
|
||||
$struct = array_merge_recursive($tmp, $struct);
|
||||
} else {
|
||||
$struct['files'][] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a nested array representing the structure of a directory and files
|
||||
*
|
||||
* @param array $files Array listing files and dirs
|
||||
* @return array
|
||||
* @see System::_dirToStruct()
|
||||
*/
|
||||
function _multipleToStruct($files)
|
||||
{
|
||||
$struct = array('dirs' => array(), 'files' => array());
|
||||
settype($files, 'array');
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file)) {
|
||||
$tmp = System::_dirToStruct($file, 0);
|
||||
$struct = array_merge_recursive($tmp, $struct);
|
||||
} else {
|
||||
$struct['files'][] = $file;
|
||||
}
|
||||
}
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rm command for removing files.
|
||||
* Supports multiple files and dirs and also recursive deletes
|
||||
*
|
||||
* @param string $args the arguments for rm
|
||||
* @return mixed PEAR_Error or true for success
|
||||
* @access public
|
||||
*/
|
||||
function rm($args)
|
||||
{
|
||||
$opts = System::_parseArgs($args, 'rf'); // "f" do nothing but like it :-)
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
foreach($opts[0] as $opt) {
|
||||
if ($opt[0] == 'r') {
|
||||
$do_recursive = true;
|
||||
}
|
||||
}
|
||||
$ret = true;
|
||||
if (isset($do_recursive)) {
|
||||
$struct = System::_multipleToStruct($opts[1]);
|
||||
foreach($struct['files'] as $file) {
|
||||
if (!@unlink($file)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
foreach($struct['dirs'] as $dir) {
|
||||
if (!@rmdir($dir)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($opts[1] as $file) {
|
||||
$delete = (is_dir($file)) ? 'rmdir' : 'unlink';
|
||||
if (!@$delete($file)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make directories. Note that we use call_user_func('mkdir') to avoid
|
||||
* a problem with ZE2 calling System::mkDir instead of the native PHP func.
|
||||
*
|
||||
* @param string $args the name of the director(y|ies) to create
|
||||
* @return bool True for success
|
||||
* @access public
|
||||
*/
|
||||
function mkDir($args)
|
||||
{
|
||||
$opts = System::_parseArgs($args, 'pm:');
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
$mode = 0777; // default mode
|
||||
foreach($opts[0] as $opt) {
|
||||
if ($opt[0] == 'p') {
|
||||
$create_parents = true;
|
||||
} elseif($opt[0] == 'm') {
|
||||
// if the mode is clearly an octal number (starts with 0)
|
||||
// convert it to decimal
|
||||
if (strlen($opt[1]) && $opt[1]{0} == '0') {
|
||||
$opt[1] = octdec($opt[1]);
|
||||
} else {
|
||||
// convert to int
|
||||
$opt[1] += 0;
|
||||
}
|
||||
$mode = $opt[1];
|
||||
}
|
||||
}
|
||||
$ret = true;
|
||||
if (isset($create_parents)) {
|
||||
foreach($opts[1] as $dir) {
|
||||
$dirstack = array();
|
||||
while (!@is_dir($dir) && $dir != DIRECTORY_SEPARATOR) {
|
||||
array_unshift($dirstack, $dir);
|
||||
$dir = dirname($dir);
|
||||
}
|
||||
while ($newdir = array_shift($dirstack)) {
|
||||
if (!call_user_func('mkdir', $newdir, $mode)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($opts[1] as $dir) {
|
||||
if (!@is_dir($dir) && !call_user_func('mkdir', $dir, $mode)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate files
|
||||
*
|
||||
* Usage:
|
||||
* 1) $var = System::cat('sample.txt test.txt');
|
||||
* 2) System::cat('sample.txt test.txt > final.txt');
|
||||
* 3) System::cat('sample.txt test.txt >> final.txt');
|
||||
*
|
||||
* Note: as the class use fopen, urls should work also (test that)
|
||||
*
|
||||
* @param string $args the arguments
|
||||
* @return boolean true on success
|
||||
* @access public
|
||||
*/
|
||||
function &cat($args)
|
||||
{
|
||||
$ret = null;
|
||||
$files = array();
|
||||
if (!is_array($args)) {
|
||||
$args = preg_split('/\s+/', $args);
|
||||
}
|
||||
for($i=0; $i < count($args); $i++) {
|
||||
if ($args[$i] == '>') {
|
||||
$mode = 'wb';
|
||||
$outputfile = $args[$i+1];
|
||||
break;
|
||||
} elseif ($args[$i] == '>>') {
|
||||
$mode = 'ab+';
|
||||
$outputfile = $args[$i+1];
|
||||
break;
|
||||
} else {
|
||||
$files[] = $args[$i];
|
||||
}
|
||||
}
|
||||
if (isset($mode)) {
|
||||
if (!$outputfd = fopen($outputfile, $mode)) {
|
||||
$err = System::raiseError("Could not open $outputfile");
|
||||
return $err;
|
||||
}
|
||||
$ret = true;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if (!$fd = fopen($file, 'r')) {
|
||||
System::raiseError("Could not open $file");
|
||||
continue;
|
||||
}
|
||||
while ($cont = fread($fd, 2048)) {
|
||||
if (isset($outputfd)) {
|
||||
fwrite($outputfd, $cont);
|
||||
} else {
|
||||
$ret .= $cont;
|
||||
}
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
if (@is_resource($outputfd)) {
|
||||
fclose($outputfd);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates temporary files or directories. This function will remove
|
||||
* the created files when the scripts finish its execution.
|
||||
*
|
||||
* Usage:
|
||||
* 1) $tempfile = System::mktemp("prefix");
|
||||
* 2) $tempdir = System::mktemp("-d prefix");
|
||||
* 3) $tempfile = System::mktemp();
|
||||
* 4) $tempfile = System::mktemp("-t /var/tmp prefix");
|
||||
*
|
||||
* prefix -> The string that will be prepended to the temp name
|
||||
* (defaults to "tmp").
|
||||
* -d -> A temporary dir will be created instead of a file.
|
||||
* -t -> The target dir where the temporary (file|dir) will be created. If
|
||||
* this param is missing by default the env vars TMP on Windows or
|
||||
* TMPDIR in Unix will be used. If these vars are also missing
|
||||
* c:\windows\temp or /tmp will be used.
|
||||
*
|
||||
* @param string $args The arguments
|
||||
* @return mixed the full path of the created (file|dir) or false
|
||||
* @see System::tmpdir()
|
||||
* @access public
|
||||
*/
|
||||
function mktemp($args = null)
|
||||
{
|
||||
static $first_time = true;
|
||||
$opts = System::_parseArgs($args, 't:d');
|
||||
if (PEAR::isError($opts)) {
|
||||
return System::raiseError($opts);
|
||||
}
|
||||
foreach($opts[0] as $opt) {
|
||||
if($opt[0] == 'd') {
|
||||
$tmp_is_dir = true;
|
||||
} elseif($opt[0] == 't') {
|
||||
$tmpdir = $opt[1];
|
||||
}
|
||||
}
|
||||
$prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp';
|
||||
if (!isset($tmpdir)) {
|
||||
$tmpdir = System::tmpdir();
|
||||
}
|
||||
if (!System::mkDir("-p $tmpdir")) {
|
||||
return false;
|
||||
}
|
||||
$tmp = tempnam($tmpdir, $prefix);
|
||||
if (isset($tmp_is_dir)) {
|
||||
unlink($tmp); // be careful possible race condition here
|
||||
if (!call_user_func('mkdir', $tmp, 0700)) {
|
||||
return System::raiseError("Unable to create temporary directory $tmpdir");
|
||||
}
|
||||
}
|
||||
$GLOBALS['_System_temp_files'][] = $tmp;
|
||||
if ($first_time) {
|
||||
PEAR::registerShutdownFunc(array('System', '_removeTmpFiles'));
|
||||
$first_time = false;
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove temporary files created my mkTemp. This function is executed
|
||||
* at script shutdown time
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _removeTmpFiles()
|
||||
{
|
||||
if (count($GLOBALS['_System_temp_files'])) {
|
||||
$delete = $GLOBALS['_System_temp_files'];
|
||||
array_unshift($delete, '-r');
|
||||
System::rm($delete);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the temporal directory set in the system
|
||||
* by looking in its environments variables.
|
||||
* Note: php.ini-recommended removes the "E" from the variables_order setting,
|
||||
* making unavaible the $_ENV array, that s why we do tests with _ENV
|
||||
*
|
||||
* @return string The temporal directory on the system
|
||||
*/
|
||||
function tmpdir()
|
||||
{
|
||||
if (OS_WINDOWS) {
|
||||
if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) {
|
||||
return $var;
|
||||
}
|
||||
if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
|
||||
return $var;
|
||||
}
|
||||
if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) {
|
||||
return $var;
|
||||
}
|
||||
return getenv('SystemRoot') . '\temp';
|
||||
}
|
||||
if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
|
||||
return $var;
|
||||
}
|
||||
return '/tmp';
|
||||
}
|
||||
|
||||
/**
|
||||
* The "which" command (show the full path of a command)
|
||||
*
|
||||
* @param string $program The command to search for
|
||||
* @return mixed A string with the full path or false if not found
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
*/
|
||||
function which($program, $fallback = false)
|
||||
{
|
||||
// is_executable() is not available on windows
|
||||
if (OS_WINDOWS) {
|
||||
$pear_is_executable = 'is_file';
|
||||
} else {
|
||||
$pear_is_executable = 'is_executable';
|
||||
}
|
||||
|
||||
// full path given
|
||||
if (basename($program) != $program) {
|
||||
return (@$pear_is_executable($program)) ? $program : $fallback;
|
||||
}
|
||||
|
||||
// XXX FIXME honor safe mode
|
||||
$path_delim = OS_WINDOWS ? ';' : ':';
|
||||
$exe_suffixes = OS_WINDOWS ? array('.exe','.bat','.cmd','.com') : array('');
|
||||
$path_elements = explode($path_delim, getenv('PATH'));
|
||||
foreach ($exe_suffixes as $suff) {
|
||||
foreach ($path_elements as $dir) {
|
||||
$file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
|
||||
if (@is_file($file) && @$pear_is_executable($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* The "find" command
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* System::find($dir);
|
||||
* System::find("$dir -type d");
|
||||
* System::find("$dir -type f");
|
||||
* System::find("$dir -name *.php");
|
||||
* System::find("$dir -name *.php -name *.htm*");
|
||||
* System::find("$dir -maxdepth 1");
|
||||
*
|
||||
* Params implmented:
|
||||
* $dir -> Start the search at this directory
|
||||
* -type d -> return only directories
|
||||
* -type f -> return only files
|
||||
* -maxdepth <n> -> max depth of recursion
|
||||
* -name <pattern> -> search pattern (bash style). Multiple -name param allowed
|
||||
*
|
||||
* @param mixed Either array or string with the command line
|
||||
* @return array Array of found files
|
||||
*
|
||||
*/
|
||||
function find($args)
|
||||
{
|
||||
if (!is_array($args)) {
|
||||
$args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
$dir = array_shift($args);
|
||||
$patterns = array();
|
||||
$depth = 0;
|
||||
$do_files = $do_dirs = true;
|
||||
for ($i = 0; $i < count($args); $i++) {
|
||||
switch ($args[$i]) {
|
||||
case '-type':
|
||||
if (in_array($args[$i+1], array('d', 'f'))) {
|
||||
if ($args[$i+1] == 'd') {
|
||||
$do_files = false;
|
||||
} else {
|
||||
$do_dirs = false;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
break;
|
||||
case '-name':
|
||||
$patterns[] = "(" . preg_replace(array('/\./', '/\*/'),
|
||||
array('\.', '.*'),
|
||||
$args[$i+1])
|
||||
. ")";
|
||||
$i++;
|
||||
break;
|
||||
case '-maxdepth':
|
||||
$depth = $args[$i+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$path = System::_dirToStruct($dir, $depth);
|
||||
if ($do_files && $do_dirs) {
|
||||
$files = array_merge($path['files'], $path['dirs']);
|
||||
} elseif ($do_dirs) {
|
||||
$files = $path['dirs'];
|
||||
} else {
|
||||
$files = $path['files'];
|
||||
}
|
||||
if (count($patterns)) {
|
||||
$patterns = implode('|', $patterns);
|
||||
$ret = array();
|
||||
for ($i = 0; $i < count($files); $i++) {
|
||||
if (preg_match("#^$patterns\$#", $files[$i])) {
|
||||
$ret[] = $files[$i];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1 +0,0 @@
|
||||
PUBLIC "-//PHP Group//DTD PEAR Package 1.0//EN//XML" "package.dtd"
|
||||
@@ -1,424 +0,0 @@
|
||||
Documentation for class Archive_Tar
|
||||
===================================
|
||||
Last update : 2001-08-15
|
||||
|
||||
|
||||
|
||||
Overview :
|
||||
----------
|
||||
|
||||
The Archive_Tar class helps in creating and managing GNU TAR format
|
||||
files compressed by GNU ZIP or not.
|
||||
The class offers basic functions like creating an archive, adding
|
||||
files in the archive, extracting files from the archive and listing
|
||||
the archive content.
|
||||
It also provide advanced functions that allow the adding and
|
||||
extraction of files with path manipulation.
|
||||
|
||||
|
||||
Sample :
|
||||
--------
|
||||
|
||||
// ----- Creating the object (uncompressed archive)
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
|
||||
|
||||
// ----- Creating the archive
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/";
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->create($v_list);
|
||||
|
||||
// ----- Adding files
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/";
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
|
||||
// ----- Adding more files
|
||||
$tar_object->add("release/newfile.log release/readme.txt");
|
||||
|
||||
// ----- Listing the content
|
||||
if (($v_list = $tar_object->listContent()) != 0)
|
||||
for ($i=0; $i<sizeof($v_list); $i++)
|
||||
{
|
||||
echo "Filename :'".$v_list[$i][filename]."'<br>";
|
||||
echo " .size :'".$v_list[$i][size]."'<br>";
|
||||
echo " .mtime :'".$v_list[$i][mtime]."' (".date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
|
||||
echo " .mode :'".$v_list[$i][mode]."'<br>";
|
||||
echo " .uid :'".$v_list[$i][uid]."'<br>";
|
||||
echo " .gid :'".$v_list[$i][gid]."'<br>";
|
||||
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
|
||||
}
|
||||
|
||||
// ----- Extracting the archive in directory "install"
|
||||
$tar_object->extract("install");
|
||||
|
||||
|
||||
Public arguments :
|
||||
------------------
|
||||
|
||||
None
|
||||
|
||||
|
||||
Public Methods :
|
||||
----------------
|
||||
|
||||
Method : Archive_Tar($p_tarname, $compress = false)
|
||||
Description :
|
||||
Archive_Tar Class constructor. This flavour of the constructor only
|
||||
declare a new Archive_Tar object, identifying it by the name of the
|
||||
tar file.
|
||||
If the compress argument is set the tar will be read or created as a
|
||||
gzip compressed TAR file.
|
||||
Arguments :
|
||||
$p_tarname : A valid filename for the tar archive file.
|
||||
$p_compress : true/false. Indicate if the archive need to be
|
||||
compressed or not.
|
||||
Return value :
|
||||
The Archive_Tar object.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object_compressed = new Archive_Tar("tarname.tgz", true);
|
||||
How it works :
|
||||
Initialize the object.
|
||||
|
||||
Method : create($p_filelist)
|
||||
Description :
|
||||
This method creates the archive file and add the files / directories
|
||||
that are listed in $p_filelist.
|
||||
If the file already exists and is writable, it is replaced by the
|
||||
new tar. It is a create and not an add. If the file exists and is
|
||||
read-only or is a directory it is not replaced. The method return
|
||||
false and a PEAR error text.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
See also createModify() method for more details.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/"; (Optional '/' at the end)
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->create($v_list);
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$tar_object->create("file.txt data/ file.log");
|
||||
How it works :
|
||||
Just calling the createModify() method with the right parameters.
|
||||
|
||||
Method : createModify($p_filelist, $p_add_dir, $p_remove_dir = "")
|
||||
Description :
|
||||
This method creates the archive file and add the files / directories
|
||||
that are listed in $p_filelist.
|
||||
If the file already exists and is writable, it is replaced by the
|
||||
new tar. It is a create and not an add. If the file exists and is
|
||||
read-only or is a directory it is not replaced. The method return
|
||||
false and a PEAR error text.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
The path indicated in $p_remove_dir will be removed from the
|
||||
memorized path of each file / directory listed when this path
|
||||
exists. By default nothing is removed (empty path "")
|
||||
The path indicated in $p_add_dir will be added at the beginning of
|
||||
the memorized path of each file / directory listed. However it can
|
||||
be set to empty "". The adding of a path is done after the removing
|
||||
of path.
|
||||
The path add/remove ability enables the user to prepare an archive
|
||||
for extraction in a different path than the origin files are.
|
||||
See also addModify() method for file adding properties.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_add_dir : A string which contains a path to be added to the
|
||||
memorized path of each element in the list.
|
||||
$p_remove_dir : A string which contains a path to be removed from
|
||||
the memorized path of each element in the list, when
|
||||
relevant.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/"; (Optional '/' at the end)
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->createModify($v_list, "install");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/file.log
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->createModify($v_list, "install", "dev");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/log/file.log
|
||||
How it works :
|
||||
Open the file in write mode (erasing the existing one if one),
|
||||
call the _addList() method for adding the files in an empty archive,
|
||||
add the tar footer (512 bytes block), close the tar file.
|
||||
|
||||
|
||||
Method : addModify($p_filelist, $p_add_dir, $p_remove_dir="")
|
||||
Description :
|
||||
This method add the files / directories listed in $p_filelist at the
|
||||
end of the existing archive. If the archive does not yet exists it
|
||||
is created.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
The path indicated in $p_remove_dir will be removed from the
|
||||
memorized path of each file / directory listed when this path
|
||||
exists. By default nothing is removed (empty path "")
|
||||
The path indicated in $p_add_dir will be added at the beginning of
|
||||
the memorized path of each file / directory listed. However it can
|
||||
be set to empty "". The adding of a path is done after the removing
|
||||
of path.
|
||||
The path add/remove ability enables the user to prepare an archive
|
||||
for extraction in a different path than the origin files are.
|
||||
If a file/dir is already in the archive it will only be added at the
|
||||
end of the archive. There is no update of the existing archived
|
||||
file/dir. However while extracting the archive, the last file will
|
||||
replace the first one. This results in a none optimization of the
|
||||
archive size.
|
||||
If a file/dir does not exist the file/dir is ignored. However an
|
||||
error text is send to PEAR error.
|
||||
If a file/dir is not readable the file/dir is ignored. However an
|
||||
error text is send to PEAR error.
|
||||
If the resulting filename/dirname (after the add/remove option or
|
||||
not) string is greater than 99 char, the file/dir is
|
||||
ignored. However an error text is send to PEAR error.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_add_dir : A string which contains a path to be added to the
|
||||
memorized path of each element in the list.
|
||||
$p_remove_dir : A string which contains a path to be removed from
|
||||
the memorized path of each element in the list, when
|
||||
relevant.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->addModify($v_list, "install");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/file.log
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->addModify($v_list, "install", "dev");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/log/file.log
|
||||
How it works :
|
||||
If the archive does not exists it create it and add the files.
|
||||
If the archive does exists and is not compressed, it open it, jump
|
||||
before the last empty 512 bytes block (tar footer) and add the files
|
||||
at this point.
|
||||
If the archive does exists and is compressed, a temporary copy file
|
||||
is created. This temporary file is then 'gzip' read block by block
|
||||
until the last empty block. The new files are then added in the
|
||||
compressed file.
|
||||
The adding of files is done by going through the file/dir list,
|
||||
adding files per files, in a recursive way through the
|
||||
directory. Each time a path need to be added/removed it is done
|
||||
before writing the file header in the archive.
|
||||
|
||||
Method : add($p_filelist)
|
||||
Description :
|
||||
This method add the files / directories listed in $p_filelist at the
|
||||
end of the existing archive. If the archive does not yet exists it
|
||||
is created.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
See addModify() method for details and limitations.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tgz", true);
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
How it works :
|
||||
Simply call the addModify() method with the right parameters.
|
||||
|
||||
Method : extract($p_path = "")
|
||||
Description :
|
||||
This method extract all the content of the archive in the directory
|
||||
indicated by $p_path.If $p_path is optional, if not set the archive
|
||||
is extracted in the current directory.
|
||||
While extracting a file, if the directory path does not exists it is
|
||||
created.
|
||||
See extractModify() for details and limitations.
|
||||
Arguments :
|
||||
$p_path : Optional path where the files/dir need to by extracted.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extract();
|
||||
How it works :
|
||||
Simply call the extractModify() method with appropriate parameters.
|
||||
|
||||
Method : extractModify($p_path, $p_remove_path)
|
||||
Description :
|
||||
This method extract all the content of the archive in the directory
|
||||
indicated by $p_path. When relevant the memorized path of the
|
||||
files/dir can be modified by removing the $p_remove_path path at the
|
||||
beginning of the file/dir path.
|
||||
While extracting a file, if the directory path does not exists it is
|
||||
created.
|
||||
While extracting a file, if the file already exists it is replaced
|
||||
without looking for last modification date.
|
||||
While extracting a file, if the file already exists and is write
|
||||
protected, the extraction is aborted.
|
||||
While extracting a file, if a directory with the same name already
|
||||
exists, the extraction is aborted.
|
||||
While extracting a directory, if a file with the same name already
|
||||
exists, the extraction is aborted.
|
||||
While extracting a file/directory if the destination directory exist
|
||||
and is write protected, or does not exist but can not be created,
|
||||
the extraction is aborted.
|
||||
If after extraction an extracted file does not show the correct
|
||||
stored file size, the extraction is aborted.
|
||||
When the extraction is aborted, a PEAR error text is set and false
|
||||
is returned. However the result can be a partial extraction that may
|
||||
need to be manually cleaned.
|
||||
Arguments :
|
||||
$p_path : The path of the directory where the files/dir need to by
|
||||
extracted.
|
||||
$p_remove_path : Part of the memorized path that can be removed if
|
||||
present at the beginning of the file/dir path.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
// Imagine tarname.tar with files :
|
||||
// dev/data/file.txt
|
||||
// dev/data/log.txt
|
||||
// readme.txt
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extractModify("install", "dev");
|
||||
// Files will be extracted there :
|
||||
// install/data/file.txt
|
||||
// install/data/log.txt
|
||||
// install/readme.txt
|
||||
How it works :
|
||||
Open the archive and call a more generic function that can extract
|
||||
only a part of the archive or all the archive.
|
||||
See extractList() method for more details.
|
||||
|
||||
Method : listContent()
|
||||
Description :
|
||||
This method returns an array of arrays that describe each
|
||||
file/directory present in the archive.
|
||||
The array is not sorted, so it show the position of the file in the
|
||||
archive.
|
||||
The file informations are :
|
||||
$file[filename] : Name and path of the file/dir.
|
||||
$file[mode] : File permissions (result of fileperms())
|
||||
$file[uid] : user id
|
||||
$file[gid] : group id
|
||||
$file[size] : filesize
|
||||
$file[mtime] : Last modification time (result of filemtime())
|
||||
$file[typeflag] : "" for file, "5" for directory
|
||||
Arguments :
|
||||
Return value :
|
||||
An array of arrays or 0 on error.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
if (($v_list = $tar_object->listContent()) != 0)
|
||||
for ($i=0; $i<sizeof($v_list); $i++)
|
||||
{
|
||||
echo "Filename :'".$v_list[$i][filename]."'<br>";
|
||||
echo " .size :'".$v_list[$i][size]."'<br>";
|
||||
echo " .mtime :'".$v_list[$i][mtime]."' (".
|
||||
date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
|
||||
echo " .mode :'".$v_list[$i][mode]."'<br>";
|
||||
echo " .uid :'".$v_list[$i][uid]."'<br>";
|
||||
echo " .gid :'".$v_list[$i][gid]."'<br>";
|
||||
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
|
||||
}
|
||||
How it works :
|
||||
Call the same function as an extract however with a flag to only go
|
||||
through the archive without extracting the files.
|
||||
|
||||
Method : extractList($p_filelist, $p_path = "", $p_remove_path = "")
|
||||
Description :
|
||||
This method extract from the archive only the files indicated in the
|
||||
$p_filelist. These files are extracted in the current directory or
|
||||
in the directory indicated by the optional $p_path parameter.
|
||||
If indicated the $p_remove_path can be used in the same way as it is
|
||||
used in extractModify() method.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_path : The path of the directory where the files/dir need to by
|
||||
extracted.
|
||||
$p_remove_path : Part of the memorized path that can be removed if
|
||||
present at the beginning of the file/dir path.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
// Imagine tarname.tar with files :
|
||||
// dev/data/file.txt
|
||||
// dev/data/log.txt
|
||||
// readme.txt
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extractList("dev/data/file.txt readme.txt", "install",
|
||||
"dev");
|
||||
// Files will be extracted there :
|
||||
// install/data/file.txt
|
||||
// install/readme.txt
|
||||
How it works :
|
||||
Go through the archive and extract only the files present in the
|
||||
list.
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
Author: Tomas V.V.Cox <cox@idecnet.com>
|
||||
Revision: $Id$
|
||||
Abstract: Open discussion on how to handle PECL binary packages
|
||||
|
||||
|
||||
pecl package name
|
||||
-----------------
|
||||
|
||||
The name of the extension would be:
|
||||
|
||||
peclfoo-bin-<OS>-<ARCH>-3.1.2.tgz
|
||||
|
||||
The os (Operating system) and arch (CPU type), would be the value
|
||||
returned by the OS_Guess class.
|
||||
|
||||
package creation
|
||||
----------------
|
||||
|
||||
pear package [-t <type>] <package>
|
||||
|
||||
-t <type> The type of package you want to generate (pear, rpm,
|
||||
msi, src, etc)
|
||||
|
||||
Without args it will package the extension as it does nowadays (the
|
||||
same as "-t src").
|
||||
|
||||
We have now native pear packages, rpm, msi is planned and others
|
||||
will surely come. Additionally of generating the native package description
|
||||
file, we could perhaps also call the tools for generating the whole package.
|
||||
|
||||
An idea would be to create in addition a BUILDINFO.txt file with some data about
|
||||
the env where the extension was compiled at, like the
|
||||
php version, the php_uname(), the extra libs versions, os vendor
|
||||
version, pear version, etc.
|
||||
|
||||
package.xml
|
||||
-----------
|
||||
|
||||
As a binary release shares the same release data with the source
|
||||
distrib, the same package.xml file could be used for all kind of
|
||||
distribs. Let's say something like:
|
||||
|
||||
<release>
|
||||
<version>...
|
||||
<date>
|
||||
<notes>
|
||||
<filelist>..
|
||||
<file role="ext" platform="">
|
||||
</filelist>
|
||||
</release>
|
||||
|
||||
A package may contain many compiled extensions for different platforms,
|
||||
one single extension or the sources.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
pear install -t bin peclfoo (download and install the binary distrib of
|
||||
peclfoo for your current OS-ARCH)
|
||||
|
||||
pear install peclfoo (download, build and install peclfoo)
|
||||
|
||||
All the files with role="ext" would be installed
|
||||
in "ext_dir" (pear cmd setting). The user can config it with "pear config-set ext_dir=XXX".
|
||||
If this var is not explicitly set, the following will be used for
|
||||
finding a default location:
|
||||
|
||||
if (getenv('PHP_PEAR_EXTENSION_DIR')) {
|
||||
define('PEAR_CONFIG_DEFAULT_EXT_DIR', getenv('PHP_PEAR_EXTENSION_DIR'));
|
||||
} else {
|
||||
if (ini_get('extension_dir')) {
|
||||
define('PEAR_CONFIG_DEFAULT_EXT_DIR', ini_get('extension_dir'));
|
||||
} elseif (defined('PEAR_EXTENSION_DIR') && @is_dir(PEAR_EXTENSION_DIR)) {
|
||||
define('PEAR_CONFIG_DEFAULT_EXT_DIR', PEAR_EXTENSION_DIR);
|
||||
} elseif (defined('PHP_EXTENSION_DIR')) {
|
||||
define('PEAR_CONFIG_DEFAULT_EXT_DIR', PHP_EXTENSION_DIR);
|
||||
} else {
|
||||
define('PEAR_CONFIG_DEFAULT_EXT_DIR', '.');
|
||||
}
|
||||
}
|
||||
|
||||
Listing in the web
|
||||
------------------
|
||||
|
||||
A new column "Type" should be added to the release listing under the
|
||||
package home page at pear.php.net, saying that the package is a binary
|
||||
distrib compiled for OS X and ARCH Y or sources.
|
||||
@@ -1,65 +0,0 @@
|
||||
RFC: subpackages
|
||||
Sept. 17, 2003
|
||||
Greg Beaver
|
||||
|
||||
The Problem:
|
||||
------------
|
||||
Many PEAR packages consist of a core and several ancillary self-contained program elements. Examples are:
|
||||
|
||||
MDB/DB and database drivers
|
||||
Log and log classes
|
||||
Cache and Cache drivers
|
||||
phpDocumentor and Converters
|
||||
HTML_QuickForm and HTML_QuickForm_Controller
|
||||
|
||||
In most cases, not all packages need be installed. The most common example of this is DB: how many people need to use every single database driver? Most of them just eat up disk space, except on multi-user installations.
|
||||
|
||||
In addition, each ancillary program element may have a different stability level (sqlite driver may be beta quality, while the mysql driver is stable). Currently, this results in a contradiction: the core is stable, but one driver is not. What is the stability of the package? stable or beta? People who want to only install and use stable packages may be deceived by a package that is marked stable and contains an alpha-quality driver, for example.
|
||||
|
||||
Plus, many PEAR packages are criticized for their bloat.
|
||||
|
||||
The Solution:
|
||||
-------------
|
||||
Subpackages will allow the solving of all of these problems. Note that subpackaging does not address other problems, such as bundling together related packages (PFC packages, for example, or packages needed for a framework that need not have any dependencies). Subpackages are a dependency relation. In other words, if Package Foo depends on Bar, Foo is not necessarily a subpackage of Bar, but might be. However, if Foo does not depend on Bar, Foo is definitively NOT a subpackage of Bar.
|
||||
|
||||
In other words, subpackages by definition cannot function without the presence of the core package (DB drivers are pretty pointless without DB).
|
||||
|
||||
Note that with the presence of subpackages, a subpackages can be released with a new version number without need to release a new version of the core, allowing rapid development on unstable subpackages, and slower development on stable components.
|
||||
|
||||
How to differentiate a subpackage from a normal dependency:
|
||||
-----------------------------------------------------------
|
||||
An addition should be made to the package.dtd file for package.xml files. A new dependency type, "spkg" should be used to define a subpackage dependency. This dependency type should be used by subpackages to definitively link to a parent package as a subpackage.
|
||||
|
||||
example package Foo_Bar's package.xml dependency:
|
||||
|
||||
<dep type="spkg" rel="has">Foo</dep> <!-- this subpackage works with all Foo -->
|
||||
-or-
|
||||
<dep type="spkg" rel="ge" version="1.5">Foo</dep> <!-- works with v1.5 or newer -->
|
||||
|
||||
All rel values would be available including "not" if a particular version of the parent package must not be installed due to a bug affecting this particular subpackage (rare case).
|
||||
|
||||
package Foo's package.xml dependencies may contain an optional dependency on the subpackage:
|
||||
|
||||
<dep type="pkg" rel="has" optional="yes">Foo_Bar</dep>
|
||||
|
||||
standard subpackages must be listed as optional dependencies in package.xml to allow easy installation with the --alldeps switch, but third party subpackages need not be listed as optional dependencies (if someone releases a custom DB driver or specialized phpDocumentor converter, for example, on their own website)
|
||||
|
||||
Note that a required subpackage must be bundled as part of the core, and is not a subpackage - a subpackage MUST be an optional dependency.
|
||||
|
||||
Naming/Path Conventions:
|
||||
------------------------
|
||||
Subpackages must reside in a subdirectory of the parent package, just as they would under normal circumstances as part of the package. Foo's subpackage Bar must be named Foo_Bar, and reside in Foo/Bar.php as per PEAR conventions.
|
||||
|
||||
pear.php.net changes:
|
||||
---------------------
|
||||
Subpackages would not be listed globally, but instead on the package page as optional components.
|
||||
|
||||
Documentation for subpackages will reside as part of the main package's documentation.
|
||||
|
||||
PEAR Installer changes:
|
||||
-----------------------
|
||||
pear info/remote-info would list available subpackages (remote-info only) and installed subpackages (info only)
|
||||
|
||||
pear list would list top-level packages, with some indication of packages that have subpackages (an asterisk or something). pear list PackageWithSubpackages would list subpackages as well
|
||||
|
||||
pear uninstall PackageWithSubpackages would automatically uninstall any subpackages without requiring --force or other switches, as if they were simply a part of the main application. This is due to the fact that they would be simply a part of the package if PEAR didn't support subpackages.
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
/* This is a list of packages and versions
|
||||
* that will be used to create the PEAR folder
|
||||
* in the windows snapshot.
|
||||
* See win32/build/mkdist.php for more details
|
||||
* $Id$
|
||||
*/
|
||||
$packages = array(
|
||||
// required packages for the installer
|
||||
"PEAR" => "1.3.5",
|
||||
"XML_RPC" => "1.3.1",
|
||||
"Console_Getopt" => "1.2",
|
||||
"Archive_Tar" => "1.3.1",
|
||||
|
||||
// required packages for the web frontend
|
||||
"PEAR_Frontend_Web" => "0.4",
|
||||
"HTML_Template_IT" => "1.1",
|
||||
"Net_UserAgent_Detect" => "2.0.1",
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -1,4 +0,0 @@
|
||||
@ECHO OFF
|
||||
set PHP_BIN=php.exe
|
||||
%PHP_BIN% -d output_buffering=0 PEAR\go-pear.php %1
|
||||
pause
|
||||
@@ -1,137 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
$pear_dir = dirname(__FILE__);
|
||||
ini_set('include_path', $pear_dir);
|
||||
include_once 'PEAR.php';
|
||||
include_once 'PEAR/Installer.php';
|
||||
include_once 'PEAR/Registry.php';
|
||||
include_once 'PEAR/Frontend/CLI.php';
|
||||
|
||||
$force = false;
|
||||
$install_files = array();
|
||||
array_shift($argv);
|
||||
for ($i = 0; $i < sizeof($argv); $i++) {
|
||||
$arg = $argv[$i];
|
||||
$bn = basename($arg);
|
||||
if (ereg('package-(.*)\.xml$', $bn, $matches) ||
|
||||
ereg('([A-Za-z0-9_:]+)-.*\.(tar|tgz)$', $bn, $matches)) {
|
||||
$install_files[$matches[1]] = $arg;
|
||||
} elseif ($arg == '--force') {
|
||||
$force = true;
|
||||
} elseif ($arg == '-d') {
|
||||
$with_dir = $argv[$i+1];
|
||||
$i++;
|
||||
} elseif ($arg == '-b') {
|
||||
$bin_dir = $argv[$i+1];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$config = &PEAR_Config::singleton();
|
||||
|
||||
// make sure we use only default values
|
||||
$config_layers = $config->getLayers();
|
||||
foreach ($config_layers as $layer) {
|
||||
if ($layer == 'default') continue;
|
||||
$config->removeLayer($layer);
|
||||
}
|
||||
$keys = $config->getKeys();
|
||||
$config->set('verbose', 0, 'default');
|
||||
// PEAR executables
|
||||
if (!empty($bin_dir)) {
|
||||
$config->set('bin_dir', $bin_dir, 'default');
|
||||
}
|
||||
// User supplied a dir prefix
|
||||
if (!empty($with_dir)) {
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
$config->set('php_dir', $with_dir, 'default');
|
||||
$config->set('doc_dir', $with_dir . $ds . 'doc', 'default');
|
||||
$config->set('data_dir', $with_dir . $ds . 'data', 'default');
|
||||
$config->set('test_dir', $with_dir . $ds . 'test', 'default');
|
||||
}
|
||||
/* Print PEAR Conf (useful for debuging do NOT REMOVE)
|
||||
sort($keys);
|
||||
foreach ($keys as $key) {
|
||||
echo $config->getPrompt($key) . ": " . $config->get($key) . "\n";
|
||||
}
|
||||
exit;
|
||||
// end print
|
||||
//*/
|
||||
|
||||
$php_dir = $config->get('php_dir');
|
||||
$options = array();
|
||||
$install_root = getenv('INSTALL_ROOT');
|
||||
if (!empty($install_root)) {
|
||||
$options['installroot'] = $install_root;
|
||||
$reg_dir = $install_root . $php_dir;
|
||||
} else {
|
||||
$reg_dir = $php_dir;
|
||||
}
|
||||
|
||||
$reg = &new PEAR_Registry($reg_dir);
|
||||
$ui = &new PEAR_Frontend_CLI();
|
||||
$installer = &new PEAR_Installer($ui);
|
||||
//$installer->registry = &$reg; // This should be changed in Installer/Registry
|
||||
|
||||
foreach ($install_files as $package => $instfile) {
|
||||
if ($reg->packageExists($package)) {
|
||||
$info = $installer->infoFromAny($instfile);
|
||||
if (PEAR::isError($info)) {
|
||||
$ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage()));
|
||||
continue;
|
||||
}
|
||||
$new_ver = $info['version'];
|
||||
$old_ver = $reg->packageInfo($package, 'version');
|
||||
if (version_compare($new_ver, $old_ver, 'gt')) {
|
||||
$options['upgrade'] = true;
|
||||
$err = $installer->install($instfile, $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;
|
||||
$err = $installer->install($instfile, $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;
|
||||
$err = $installer->install($instfile, $options);
|
||||
if (PEAR::isError($err)) {
|
||||
$ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
|
||||
continue;
|
||||
}
|
||||
$new_ver = $reg->packageInfo($package, 'version');
|
||||
$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');
|
||||
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');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,11 +0,0 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| The installation process is incomplete. The following resources were |
|
||||
| not installed: |
|
||||
| |
|
||||
| Self-contained Extension Support |
|
||||
| PEAR: PHP Extension and Application Repository |
|
||||
| |
|
||||
| To install these components, become the superuser and execute: |
|
||||
| |
|
||||
| # make install-su |
|
||||
+----------------------------------------------------------------------+
|
||||
@@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<!DOCTYPE package SYSTEM "package.dtd">
|
||||
<package version="1.0">
|
||||
<name>Archive_Tar</name>
|
||||
<summary>Tar file management class</summary>
|
||||
<description>This class provides handling of tar files in PHP.
|
||||
It supports creating, listing, extracting and adding to tar files.
|
||||
Gzip support is available if PHP has the zlib extension built-in or
|
||||
loaded. Bz2 compression is also supported with the bz2 extension loaded.
|
||||
</description>
|
||||
<license>PHP License</license>
|
||||
<maintainers>
|
||||
<maintainer>
|
||||
<user>vblavet</user>
|
||||
<role>lead</role>
|
||||
<name>Vincent Blavet</name>
|
||||
<email>vincent@blavet.net</email>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>ssb</user>
|
||||
<role>helper</role>
|
||||
<name>Stig Sæther Bakken</name>
|
||||
<email>stig@php.net</email>
|
||||
</maintainer>
|
||||
</maintainers>
|
||||
<release>
|
||||
<version>1.1</version>
|
||||
<date>2003-05-28</date>
|
||||
<notes>* Add support for BZ2 compression
|
||||
* Add support for add and extract without using temporary files : methods addString() and extractInString()
|
||||
|
||||
</notes>
|
||||
<state>stable</state>
|
||||
<filelist>
|
||||
<dir name="Archive">
|
||||
<file role="php" name="Tar.php"/>
|
||||
</dir>
|
||||
<file role="doc" name="docs/Archive_Tar.txt" baseinstalldir="/"/>
|
||||
</filelist>
|
||||
</release>
|
||||
<changelog>
|
||||
<release>
|
||||
<version>1.0</version>
|
||||
<date>2003-01-24</date>
|
||||
<notes>Change status to stable</notes>
|
||||
<state>stable</state>
|
||||
<filelist>
|
||||
<dir name="Archive">
|
||||
<file role="php" name="Tar.php"/>
|
||||
</dir>
|
||||
<file role="doc" name="docs/Archive_Tar.txt" baseinstalldir="/"/>
|
||||
</filelist>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.10-b1</version>
|
||||
<date>2003-01-08</date>
|
||||
<notes>Add support for long filenames (greater than 99 characters)</notes>
|
||||
<state>beta</state>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.9</version>
|
||||
<date>2002-05-27</date>
|
||||
<notes>Auto-detect gzip'ed files</notes>
|
||||
<state>stable</state>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.4</version>
|
||||
<date>2002-05-20</date>
|
||||
<notes>Windows bugfix: use forward slashes inside archives</notes>
|
||||
<state>stable</state>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.2</version>
|
||||
<date>2002-02-18</date>
|
||||
<notes>From initial commit to stable</notes>
|
||||
<state>stable</state>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.3</version>
|
||||
<date>2002-04-13</date>
|
||||
<notes>Windows bugfix: used wrong directory separators</notes>
|
||||
<state>stable</state>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<!DOCTYPE package SYSTEM "package.dtd">
|
||||
<!-- do not use the "Type" attribute here, that one is only for
|
||||
generated package.xml files -->
|
||||
<package version="1.0">
|
||||
<name>Console_Getopt</name>
|
||||
<summary>Command-line option parser</summary>
|
||||
<description>This is a PHP implementation of "getopt" supporting both
|
||||
short and long options.</description>
|
||||
<license>PHP License</license>
|
||||
<maintainers>
|
||||
<maintainer>
|
||||
<user>andrei</user>
|
||||
<role>lead</role>
|
||||
<name>Andrei Zmievski</name>
|
||||
<email>andrei@php.net</email>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>ssb</user>
|
||||
<role>developer</role>
|
||||
<name>Stig Sæther Bakken</name>
|
||||
<email>stig@php.net</email>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>cellog</user>
|
||||
<role>helper</role>
|
||||
<name>Greg Beaver</name>
|
||||
<email>cellog@php.net</email>
|
||||
</maintainer>
|
||||
</maintainers>
|
||||
<release>
|
||||
<version>1.2</version>
|
||||
<date>2003-12-11</date>
|
||||
<notes>Fix to preserve BC with 1.0 and allow correct behaviour for new users</notes>
|
||||
<state>stable</state>
|
||||
<filelist>
|
||||
<dir name="Console">
|
||||
<file role="php" name="Getopt.php"/>
|
||||
</dir>
|
||||
</filelist>
|
||||
</release>
|
||||
<changelog>
|
||||
<release>
|
||||
<version>1.0</version>
|
||||
<date>2002-09-13</date>
|
||||
<notes>Stable release</notes>
|
||||
<state>stable</state>
|
||||
<filelist>
|
||||
<dir name="Console">
|
||||
<file role="php" name="Getopt.php"/>
|
||||
</dir>
|
||||
</filelist>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.11</version>
|
||||
<date>2002-05-26</date>
|
||||
<notes>POSIX getopt compatibility fix: treat first element of args
|
||||
array as command name
|
||||
</notes>
|
||||
<state>beta</state>
|
||||
<filelist>
|
||||
<dir name="Console">
|
||||
<file role="php" name="Getopt.php"/>
|
||||
</dir>
|
||||
</filelist>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.10</version>
|
||||
<date>2002-05-12</date>
|
||||
<notes>Packaging fix</notes>
|
||||
<state>beta</state>
|
||||
</release>
|
||||
<release>
|
||||
<version>0.9</version>
|
||||
<date>2002-05-12</date>
|
||||
<notes>Initial release</notes>
|
||||
<state>beta</state>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
@@ -1,201 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<!DOCTYPE package SYSTEM "package.dtd">
|
||||
<package version="1.0">
|
||||
<name>PEAR</name>
|
||||
<summary>PEAR Base System</summary>
|
||||
<description>The PEAR package contains:
|
||||
* the PEAR installer, for creating, distributing
|
||||
and installing packages
|
||||
* the alpha-quality PEAR_Exception php5-only exception class
|
||||
* the beta-quality PEAR_ErrorStack advanced error handling mechanism
|
||||
* the PEAR_Error error handling mechanism
|
||||
* the OS_Guess class for retrieving info about the OS
|
||||
where PHP is running on
|
||||
* the System class for quick handling common operations
|
||||
with files and directories
|
||||
* the PEAR base class
|
||||
</description>
|
||||
<maintainers>
|
||||
<maintainer>
|
||||
<user>ssb</user>
|
||||
<role>lead</role>
|
||||
<name>Stig Sæther Bakken</name>
|
||||
<email>stig@php.net</email>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>cox</user>
|
||||
<role>lead</role>
|
||||
<name>Tomas V.V.Cox</name>
|
||||
<email>cox@idecnet.com</email>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>cellog</user>
|
||||
<role>lead</role>
|
||||
<name>Greg Beaver</name>
|
||||
<email>cellog@php.net</email>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>pajoye</user>
|
||||
<role>lead</role>
|
||||
<name>Pierre-Alain Joye</name>
|
||||
<email>pajoye@pearfr.org</email>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>mj</user>
|
||||
<role>developer</role>
|
||||
<name>Martin Jansen</name>
|
||||
<email>mj@php.net</email>
|
||||
</maintainer>
|
||||
</maintainers>
|
||||
<release>
|
||||
<version>1.3.5</version>
|
||||
<date>2005-02-18</date>
|
||||
<state>stable</state>
|
||||
<license>PHP License</license>
|
||||
<notes>
|
||||
* fix Bug #3505: pecl can't install PDO
|
||||
* enhance pear run-tests dramatically
|
||||
* fix Bug #3506: pear install should export the pear version into the environment
|
||||
</notes>
|
||||
<provides type="class" name="OS_Guess" />
|
||||
<provides type="class" name="System" />
|
||||
<provides type="function" name="md5_file" />
|
||||
<filelist>
|
||||
<dir name="OS">
|
||||
<file role="php" name="Guess.php"/>
|
||||
</dir>
|
||||
<dir name="PEAR">
|
||||
<dir name="Command">
|
||||
<file role="php" name="Auth.php"/>
|
||||
<file role="php" name="Build.php"/>
|
||||
<file role="php" name="Common.php"/>
|
||||
<file role="php" name="Config.php"/>
|
||||
<file role="php" name="Install.php"/>
|
||||
<file role="php" name="Package.php"/>
|
||||
<file role="php" name="Registry.php"/>
|
||||
<file role="php" name="Remote.php"/>
|
||||
<file role="php" name="Mirror.php"/>
|
||||
</dir>
|
||||
<dir name="Frontend">
|
||||
<file role="php" name="CLI.php"/>
|
||||
</dir>
|
||||
<file role="php" name="Autoloader.php"/>
|
||||
<file role="php" name="Command.php"/>
|
||||
<file role="php" name="Common.php"/>
|
||||
<file role="php" name="Config.php"/>
|
||||
<file role="php" name="Dependency.php"/>
|
||||
<file role="php" name="Downloader.php"/>
|
||||
<file role="php" name="Exception.php"/>
|
||||
<file role="php" name="ErrorStack.php"/>
|
||||
<file role="php" name="Builder.php">
|
||||
<replace from="@PEAR-VER@" to="version" type="package-info"/>
|
||||
</file>
|
||||
<file role="php" name="Installer.php"/>
|
||||
<file role="php" name="Packager.php"/>
|
||||
<file role="php" name="Registry.php"/>
|
||||
<file role="php" name="Remote.php"/>
|
||||
<file role="php" name="RunTest.php"/>
|
||||
</dir>
|
||||
<dir name="scripts" baseinstalldir="/">
|
||||
<file role="script" install-as="pear" name="pear.sh">
|
||||
<replace from="@php_bin@" to="php_bin" type="pear-config"/>
|
||||
<replace from="@php_dir@" to="php_dir" type="pear-config"/>
|
||||
<replace from="@pear_version@" to="version" type="package-info"/>
|
||||
<replace from="@include_path@" to="php_dir" type="pear-config"/>
|
||||
</file>
|
||||
<file role="script" platform="windows" install-as="pear.bat" name="pear.bat">
|
||||
<replace from="@bin_dir@" to="bin_dir" type="pear-config"/>
|
||||
<replace from="@php_bin@" to="php_bin" type="pear-config"/>
|
||||
<replace from="@include_path@" to="php_dir" type="pear-config"/>
|
||||
</file>
|
||||
<file role="php" install-as="pearcmd.php" name="pearcmd.php">
|
||||
<replace from="@php_bin@" to="php_bin" type="pear-config"/>
|
||||
<replace from="@php_dir@" to="php_dir" type="pear-config"/>
|
||||
<replace from="@pear_version@" to="version" type="package-info"/>
|
||||
<replace from="@include_path@" to="php_dir" type="pear-config"/>
|
||||
</file>
|
||||
</dir>
|
||||
<file role="data" name="package.dtd"/>
|
||||
<file role="data" name="template.spec"/>
|
||||
<file role="php" name="PEAR.php"/>
|
||||
<file role="php" name="System.php"/>
|
||||
</filelist>
|
||||
<deps>
|
||||
<dep type="php" rel="ge" version="4.2"/>
|
||||
<dep type="pkg" rel="ge" version="1.1">Archive_Tar</dep>
|
||||
<dep type="pkg" rel="ge" version="1.2">Console_Getopt</dep>
|
||||
<dep type="pkg" rel="ge" version="1.0.4">XML_RPC</dep>
|
||||
<dep type="ext" rel="has">xml</dep>
|
||||
<dep type="ext" rel="has">pcre</dep>
|
||||
</deps>
|
||||
</release>
|
||||
<changelog>
|
||||
<release>
|
||||
<version>1.3.1</version>
|
||||
<date>2004-04-06</date>
|
||||
<state>stable</state>
|
||||
<notes>
|
||||
PEAR Installer:
|
||||
|
||||
* Bug #534 pear search doesn't list unstable releases
|
||||
* Bug #933 CMD Usability Patch
|
||||
* Bug #937 throwError() treats every call as static
|
||||
* Bug #964 PEAR_ERROR_EXCEPTION causes fatal error
|
||||
* Bug #1008 safe mode raises warning
|
||||
|
||||
PEAR_ErrorStack:
|
||||
|
||||
* Added experimental error handling, designed to eventually replace
|
||||
PEAR_Error. It should be considered experimental until explicitly marked
|
||||
stable. require_once 'PEAR/ErrorStack.php' to use.
|
||||
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>1.3.3</version>
|
||||
<date>2004-10-28</date>
|
||||
<state>stable</state>
|
||||
<notes>
|
||||
Installer:
|
||||
* fix Bug #1186 raise a notice error on PEAR::Common $_packageName
|
||||
* fix Bug #1249 display the right state when using --force option
|
||||
* fix Bug #2189 upgrade-all stops if dependancy fails
|
||||
* fix Bug #1637 The use of interface causes warnings when packaging with PEAR
|
||||
* fix Bug #1420 Parser bug for T_DOUBLE_COLON
|
||||
* fix Request #2220 pear5 build fails on dual php4/php5 system
|
||||
* fix Bug #1163 pear makerpm fails with packages that supply role="doc"
|
||||
|
||||
Other:
|
||||
* add PEAR_Exception class for PHP5 users
|
||||
* fix critical problem in package.xml for linux in 1.3.2
|
||||
* fix staticPopCallback() in PEAR_ErrorStack
|
||||
* fix warning in PEAR_Registry for windows 98 users
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>1.3.3.1</version>
|
||||
<date>2004-11-08</date>
|
||||
<state>stable</state>
|
||||
<notes>
|
||||
add RunTest.php to package.xml, make run-tests display failed tests, and use ui
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>1.3.4</version>
|
||||
<date>2005-01-01</date>
|
||||
<state>stable</state>
|
||||
<notes>
|
||||
* fix a serious problem caused by a bug in all versions of PHP that caused multiple registration
|
||||
of the shutdown function of PEAR.php
|
||||
* fix Bug #2861: package.dtd does not define NUMBER
|
||||
* fix Bug #2946: ini_set warning errors
|
||||
* fix Bug #3026: Dependency type "ne" is needed, "not" is not handled
|
||||
properly
|
||||
* fix Bug #3061: potential warnings in PEAR_Exception
|
||||
* implement Request #2848: PEAR_ErrorStack logger extends, PEAR_ERRORSTACK_DIE
|
||||
* implement Request #2914: Dynamic Include Path for run-tests command
|
||||
* make pear help listing more useful (put how-to-use info at the bottom of the listing)
|
||||
</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
110
pear/package.dtd
110
pear/package.dtd
@@ -1,110 +0,0 @@
|
||||
<!--
|
||||
$Id: package.dtd,v 1.36 2005-03-28 16:38:58 cellog Exp $
|
||||
|
||||
This is the PEAR package description, version 1.0.
|
||||
It should be used with the informal public identifier:
|
||||
|
||||
"-//PHP Group//DTD PEAR Package 1.0//EN//XML"
|
||||
|
||||
Copyright (c) 1997-2004 The PHP Group
|
||||
|
||||
This source file is subject to version 3.0 of the PHP license,
|
||||
that is bundled with this package in the file LICENSE, and is
|
||||
available at through the world-wide-web at
|
||||
http://www.php.net/license/3_0.txt.
|
||||
If you did not receive a copy of the PHP license and are unable to
|
||||
obtain it through the world-wide-web, please send a note to
|
||||
license@php.net so we can mail you a copy immediately.
|
||||
|
||||
Authors:
|
||||
Stig S. Bakken <ssb@php.net>
|
||||
|
||||
-->
|
||||
<!ENTITY % NUMBER "CDATA">
|
||||
<!ELEMENT package (name|summary|description|license|maintainers|release|changelog)+>
|
||||
<!ATTLIST package type (source|binary|empty) "empty"
|
||||
version CDATA #REQUIRED>
|
||||
|
||||
<!ELEMENT name (#PCDATA)>
|
||||
|
||||
<!ELEMENT summary (#PCDATA)>
|
||||
|
||||
<!ELEMENT description (#PCDATA)>
|
||||
|
||||
<!ELEMENT license (#PCDATA)>
|
||||
|
||||
<!ELEMENT maintainers (maintainer)+>
|
||||
|
||||
<!ELEMENT maintainer (user|role|name|email)+>
|
||||
|
||||
<!ELEMENT user (#PCDATA)>
|
||||
|
||||
<!ELEMENT role (#PCDATA)>
|
||||
|
||||
<!ELEMENT email (#PCDATA)>
|
||||
|
||||
<!ELEMENT changelog (release)+>
|
||||
|
||||
<!ELEMENT release (version|license|state|date|notes|filelist|deps|provides|script|configureoptions)+>
|
||||
|
||||
<!ELEMENT version (#PCDATA)>
|
||||
|
||||
<!ELEMENT state (#PCDATA)>
|
||||
|
||||
<!ELEMENT date (#PCDATA)>
|
||||
|
||||
<!ELEMENT notes (#PCDATA)>
|
||||
|
||||
<!ELEMENT filelist (dir|file)+>
|
||||
|
||||
<!ELEMENT dir (dir|file)+>
|
||||
<!ATTLIST dir name CDATA #REQUIRED
|
||||
baseinstalldir CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT file (replace*)>
|
||||
<!ATTLIST file role (php|ext|src|test|doc|data|script) 'php'
|
||||
debug (na|on|off) 'na'
|
||||
zts (na|on|off) 'na'
|
||||
phpapi %NUMBER; #IMPLIED
|
||||
zendapi %NUMBER; #IMPLIED
|
||||
format CDATA #IMPLIED
|
||||
baseinstalldir CDATA #IMPLIED
|
||||
platform CDATA #IMPLIED
|
||||
md5sum CDATA #IMPLIED
|
||||
name CDATA #REQUIRED
|
||||
install-as CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT replace EMPTY>
|
||||
<!ATTLIST replace from CDATA #REQUIRED
|
||||
to CDATA #REQUIRED
|
||||
type CDATA #REQUIRED>
|
||||
|
||||
<!ELEMENT deps (dep)+>
|
||||
|
||||
<!ELEMENT dep (#PCDATA)>
|
||||
<!ATTLIST dep
|
||||
optional (yes|no) 'no'
|
||||
type (pkg|ext|php|prog|ldlib|rtlib|os|websrv|sapi|zend) #REQUIRED
|
||||
rel (has|eq|lt|le|gt|ge) 'has'
|
||||
version CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT provides (#PCDATA)>
|
||||
<!ATTLIST provides
|
||||
type (ext|prog|class|function|feature|api) #REQUIRED
|
||||
name CDATA #REQUIRED
|
||||
extends CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT script (#PCDATA)>
|
||||
<!ATTLIST script
|
||||
phase (pre-install |post-install |
|
||||
pre-uninstall|post-uninstall|
|
||||
pre-build |post-build |
|
||||
pre-setup |post-setup ) #REQUIRED>
|
||||
|
||||
<!ELEMENT configureoptions (configureoption*)>
|
||||
|
||||
<!ELEMENT configureoption EMPTY>
|
||||
<!ATTLIST configureoption
|
||||
name CDATA #REQUIRED
|
||||
default CDATA #IMPLIED
|
||||
prompt CDATA #REQUIRED>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,69 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM ----------------------------------------------------------------------
|
||||
REM PHP version 5
|
||||
REM ----------------------------------------------------------------------
|
||||
REM Copyright (c) 1997-2004 The PHP Group
|
||||
REM ----------------------------------------------------------------------
|
||||
REM This source file is subject to version 3.0 of the PHP license,
|
||||
REM that is bundled with this package in the file LICENSE, and is
|
||||
REM available at through the world-wide-web at
|
||||
REM http://www.php.net/license/3_0.txt.
|
||||
REM If you did not receive a copy of the PHP license and are unable to
|
||||
REM obtain it through the world-wide-web, please send a note to
|
||||
REM license@php.net so we can mail you a copy immediately.
|
||||
REM ----------------------------------------------------------------------
|
||||
REM Authors: Alexander Merz (alexmerz@php.net)
|
||||
REM ----------------------------------------------------------------------
|
||||
REM
|
||||
REM Last updated 3/13/2004 ($Id$ is not replaced if the file is binary)
|
||||
|
||||
REM change this lines to match the paths of your system
|
||||
REM -------------------
|
||||
|
||||
@ECHO OFF
|
||||
:: Check PEAR global ENV, set them if they do not exist
|
||||
IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"
|
||||
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"
|
||||
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"
|
||||
|
||||
:: Check Folders and files
|
||||
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR
|
||||
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2
|
||||
IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR
|
||||
IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR
|
||||
:: launch pearcmd
|
||||
GOTO RUN
|
||||
:PEAR_INSTALL_ERROR
|
||||
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
|
||||
ECHO Please fix it using your environment variable or modify
|
||||
ECHO the default value in pear.bat
|
||||
ECHO The current value is:
|
||||
ECHO %PHP_PEAR_INSTALL_DIR%
|
||||
GOTO END
|
||||
:PEAR_INSTALL_ERROR2
|
||||
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
|
||||
ECHO pearcmd.php could not be found there.
|
||||
ECHO Please fix it using your environment variable or modify
|
||||
ECHO the default value in pear.bat
|
||||
ECHO The current value is:
|
||||
ECHO %PHP_PEAR_INSTALL_DIR%
|
||||
GOTO END
|
||||
:PEAR_BIN_ERROR
|
||||
ECHO PHP_PEAR_BIN_DIR is not set correctly.
|
||||
ECHO Please fix it using your environment variable or modify
|
||||
ECHO the default value in pear.bat
|
||||
ECHO The current value is:
|
||||
ECHO %PHP_PEAR_BIN_DIR%
|
||||
GOTO END
|
||||
:PEAR_PHPBIN_ERROR
|
||||
ECHO PHP_PEAR_PHP_BIN is not set correctly.
|
||||
ECHO Please fix it using your environment variable or modify
|
||||
ECHO the default value in pear.bat
|
||||
ECHO The current value is:
|
||||
ECHO %PHP_PEAR_PHP_BIN%
|
||||
GOTO END
|
||||
:RUN
|
||||
"%PHP_PEAR_PHP_BIN%" -C -d output_buffering=1 -d include_path="%PHP_PEAR_INSTALL_DIR%" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
:END
|
||||
@ECHO ON
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# first find which PHP binary to use
|
||||
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
|
||||
PHP="$PHP_PEAR_PHP_BIN"
|
||||
else
|
||||
if test "@php_bin@" = '@'php_bin'@'; then
|
||||
PHP=php
|
||||
else
|
||||
PHP="@php_bin@"
|
||||
fi
|
||||
fi
|
||||
|
||||
# then look for the right pear include dir
|
||||
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
|
||||
INCDIR=$PHP_PEAR_INSTALL_DIR
|
||||
INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
|
||||
else
|
||||
if test "@php_dir@" = '@'php_dir'@'; then
|
||||
INCDIR=`dirname $0`
|
||||
INCARG=""
|
||||
else
|
||||
INCDIR="@php_dir@"
|
||||
INCARG="-d include_path=@php_dir@"
|
||||
fi
|
||||
fi
|
||||
|
||||
exec $PHP -C -q $INCARG -d output_buffering=1 $INCDIR/pearcmd.php "$@"
|
||||
@@ -1,318 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Stig Bakken <ssb@php.net> |
|
||||
// | Tomas V.V.Cox <cox@idecnet.com> |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
ob_end_clean();
|
||||
/**
|
||||
* @nodep Gtk
|
||||
*/
|
||||
if ('@include_path@' != '@'.'include_path'.'@') {
|
||||
ini_set('include_path', '@include_path@');
|
||||
}
|
||||
ini_set('allow_url_fopen', true);
|
||||
if (!ini_get('safe_mode')) {
|
||||
@set_time_limit(0);
|
||||
}
|
||||
ob_implicit_flush(true);
|
||||
ini_set('track_errors', true);
|
||||
ini_set('html_errors', false);
|
||||
ini_set('magic_quotes_runtime', false);
|
||||
set_error_handler('error_handler');
|
||||
|
||||
$pear_package_version = "@pear_version@";
|
||||
|
||||
require_once 'PEAR.php';
|
||||
require_once 'PEAR/Config.php';
|
||||
require_once 'PEAR/Command.php';
|
||||
require_once 'Console/Getopt.php';
|
||||
|
||||
PEAR_Command::setFrontendType('CLI');
|
||||
$all_commands = PEAR_Command::getCommands();
|
||||
|
||||
$argv = Console_Getopt::readPHPArgv();
|
||||
/* $progname = basename($argv[0]); */
|
||||
$progname = 'pear';
|
||||
if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
|
||||
array_shift($argv);
|
||||
$options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV");
|
||||
} else {
|
||||
$options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV");
|
||||
}
|
||||
if (PEAR::isError($options)) {
|
||||
usage($options);
|
||||
}
|
||||
|
||||
$opts = $options[0];
|
||||
|
||||
$fetype = 'CLI';
|
||||
if ($progname == 'gpear' || $progname == 'pear-gtk') {
|
||||
$fetype = 'Gtk';
|
||||
} else {
|
||||
foreach ($opts as $opt) {
|
||||
if ($opt[0] == 'G') {
|
||||
$fetype = 'Gtk';
|
||||
}
|
||||
}
|
||||
}
|
||||
PEAR_Command::setFrontendType($fetype);
|
||||
$ui = &PEAR_Command::getFrontendObject();
|
||||
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
|
||||
if (ini_get('safe_mode')) {
|
||||
$ui->outputData('WARNING: running in safe mode requires that all files created ' .
|
||||
'be the same uid as the current script. PHP reports this script is uid: ' .
|
||||
@getmyuid() . ', and current user is: ' . @get_current_user());
|
||||
}
|
||||
|
||||
$pear_user_config = '';
|
||||
$pear_system_config = '';
|
||||
$store_user_config = false;
|
||||
$store_system_config = false;
|
||||
$verbose = 1;
|
||||
|
||||
foreach ($opts as $opt) {
|
||||
switch ($opt[0]) {
|
||||
case 'c':
|
||||
$pear_user_config = $opt[1];
|
||||
break;
|
||||
case 'C':
|
||||
$pear_system_config = $opt[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$config = &PEAR_Config::singleton($pear_user_config, $pear_system_config);
|
||||
$verbose = $config->get("verbose");
|
||||
$cmdopts = array();
|
||||
|
||||
foreach ($opts as $opt) {
|
||||
$param = !empty($opt[1]) ? $opt[1] : true;
|
||||
switch ($opt[0]) {
|
||||
case 'd':
|
||||
list($key, $value) = explode('=', $param);
|
||||
$config->set($key, $value, 'user');
|
||||
break;
|
||||
case 'D':
|
||||
list($key, $value) = explode('=', $param);
|
||||
$config->set($key, $value, 'system');
|
||||
break;
|
||||
case 's':
|
||||
$store_user_config = true;
|
||||
break;
|
||||
case 'S':
|
||||
$store_system_config = true;
|
||||
break;
|
||||
case 'u':
|
||||
$config->remove($param, 'user');
|
||||
break;
|
||||
case 'v':
|
||||
$config->set('verbose', $config->get('verbose') + 1);
|
||||
break;
|
||||
case 'q':
|
||||
$config->set('verbose', $config->get('verbose') - 1);
|
||||
break;
|
||||
case 'V':
|
||||
usage(null, 'version');
|
||||
default:
|
||||
// all non pear params goes to the command
|
||||
$cmdopts[$opt[0]] = $param;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($store_system_config) {
|
||||
$config->store('system');
|
||||
}
|
||||
|
||||
if ($store_user_config) {
|
||||
$config->store('user');
|
||||
}
|
||||
|
||||
$command = (isset($options[1][0])) ? $options[1][0] : null;
|
||||
|
||||
if (empty($command) && ($store_user_config || $store_system_config)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($fetype == 'Gtk') {
|
||||
Gtk::main();
|
||||
} else do {
|
||||
if ($command == 'help') {
|
||||
usage(null, @$options[1][1]);
|
||||
}
|
||||
|
||||
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$cmd = PEAR_Command::factory($command, $config);
|
||||
PEAR::popErrorHandling();
|
||||
if (PEAR::isError($cmd)) {
|
||||
usage(null, @$options[1][1]);
|
||||
}
|
||||
|
||||
$short_args = $long_args = null;
|
||||
PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
|
||||
if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
|
||||
array_shift($options[1]);
|
||||
$tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
|
||||
} else {
|
||||
$tmp = Console_Getopt::getopt($options[1], $short_args, $long_args);
|
||||
}
|
||||
if (PEAR::isError($tmp)) {
|
||||
break;
|
||||
}
|
||||
list($tmpopt, $params) = $tmp;
|
||||
$opts = array();
|
||||
foreach ($tmpopt as $foo => $tmp2) {
|
||||
list($opt, $value) = $tmp2;
|
||||
if ($value === null) {
|
||||
$value = true; // options without args
|
||||
}
|
||||
if (strlen($opt) == 1) {
|
||||
$cmdoptions = $cmd->getOptions($command);
|
||||
foreach ($cmdoptions as $o => $d) {
|
||||
if (@$d['shortopt'] == $opt) {
|
||||
$opts[$o] = $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (substr($opt, 0, 2) == '--') {
|
||||
$opts[substr($opt, 2)] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ok = $cmd->run($command, $opts, $params);
|
||||
if ($ok === false) {
|
||||
PEAR::raiseError("unknown command `$command'");
|
||||
}
|
||||
} while (false);
|
||||
|
||||
// {{{ usage()
|
||||
|
||||
function usage($error = null, $helpsubject = null)
|
||||
{
|
||||
global $progname, $all_commands;
|
||||
$stderr = fopen('php://stderr', 'w');
|
||||
if (PEAR::isError($error)) {
|
||||
fputs($stderr, $error->getMessage() . "\n");
|
||||
} elseif ($error !== null) {
|
||||
fputs($stderr, "$error\n");
|
||||
}
|
||||
if ($helpsubject != null) {
|
||||
$put = cmdHelp($helpsubject);
|
||||
} else {
|
||||
$put =
|
||||
"Commands:\n";
|
||||
$maxlen = max(array_map("strlen", $all_commands));
|
||||
$formatstr = "%-{$maxlen}s %s\n";
|
||||
ksort($all_commands);
|
||||
foreach ($all_commands as $cmd => $class) {
|
||||
$put .= sprintf($formatstr, $cmd, PEAR_Command::getDescription($cmd));
|
||||
}
|
||||
$put .=
|
||||
"Usage: $progname [options] command [command-options] <parameters>\n".
|
||||
"Type \"$progname help options\" to list all options.\n".
|
||||
"Type \"$progname help shortcuts\" to list all command shortcuts.\n".
|
||||
"Type \"$progname help <command>\" to get the help for the specified command.";
|
||||
}
|
||||
fputs($stderr, "$put\n");
|
||||
fclose($stderr);
|
||||
exit;
|
||||
}
|
||||
|
||||
function cmdHelp($command)
|
||||
{
|
||||
global $progname, $all_commands, $config;
|
||||
if ($command == "options") {
|
||||
return
|
||||
"Options:\n".
|
||||
" -v increase verbosity level (default 1)\n".
|
||||
" -q be quiet, decrease verbosity level\n".
|
||||
" -c file find user configuration in `file'\n".
|
||||
" -C file find system configuration in `file'\n".
|
||||
" -d foo=bar set user config variable `foo' to `bar'\n".
|
||||
" -D foo=bar set system config variable `foo' to `bar'\n".
|
||||
" -G start in graphical (Gtk) mode\n".
|
||||
" -s store user configuration\n".
|
||||
" -S store system configuration\n".
|
||||
" -u foo unset `foo' in the user configuration\n".
|
||||
" -h, -? display help/usage (this message)\n".
|
||||
" -V version information\n";
|
||||
} elseif ($command == "shortcuts") {
|
||||
$sc = PEAR_Command::getShortcuts();
|
||||
$ret = "Shortcuts:\n";
|
||||
foreach ($sc as $s => $c) {
|
||||
$ret .= sprintf(" %-8s %s\n", $s, $c);
|
||||
}
|
||||
return $ret;
|
||||
|
||||
} elseif ($command == "version") {
|
||||
return "PEAR Version: ".$GLOBALS['pear_package_version'].
|
||||
"\nPHP Version: ".phpversion().
|
||||
"\nZend Engine Version: ".zend_version().
|
||||
"\nRunning on: ".php_uname();
|
||||
|
||||
} elseif ($help = PEAR_Command::getHelp($command)) {
|
||||
if (is_string($help)) {
|
||||
return "$progname $command [options] $help\n";
|
||||
}
|
||||
if ($help[1] === null) {
|
||||
return "$progname $command $help[0]";
|
||||
} else {
|
||||
return "$progname $command [options] $help[0]\n$help[1]";
|
||||
}
|
||||
}
|
||||
return "Command '$command' is not valid, try 'pear help'";
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
function error_handler($errno, $errmsg, $file, $line, $vars) {
|
||||
if ((defined('E_STRICT') && $errno & E_STRICT) || !error_reporting()) {
|
||||
return; // @silenced error
|
||||
}
|
||||
$errortype = array (
|
||||
E_ERROR => "Error",
|
||||
E_WARNING => "Warning",
|
||||
E_PARSE => "Parsing Error",
|
||||
E_NOTICE => "Notice",
|
||||
E_CORE_ERROR => "Core Error",
|
||||
E_CORE_WARNING => "Core Warning",
|
||||
E_COMPILE_ERROR => "Compile Error",
|
||||
E_COMPILE_WARNING => "Compile Warning",
|
||||
E_USER_ERROR => "User Error",
|
||||
E_USER_WARNING => "User Warning",
|
||||
E_USER_NOTICE => "User Notice"
|
||||
);
|
||||
$prefix = $errortype[$errno];
|
||||
$file = basename($file);
|
||||
print "\n$prefix: $errmsg in $file on line $line\n";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* mode: php
|
||||
* End:
|
||||
*/
|
||||
// vim600:syn=php
|
||||
|
||||
?>
|
||||
@@ -1,233 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Stig Bakken <ssb@php.net> |
|
||||
// | Tomas V.V.Cox <cox@idecnet.com> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once 'PEAR.php';
|
||||
require_once 'PEAR/Common.php';
|
||||
require_once 'PEAR/Config.php';
|
||||
require_once 'PEAR/Remote.php';
|
||||
require_once 'PEAR/Registry.php';
|
||||
require_once 'Console/Getopt.php';
|
||||
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
|
||||
$progname = basename($argv[0]);
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "$progname: %s\n");
|
||||
|
||||
$argv = Console_Getopt::readPHPArgv();
|
||||
if (PEAR::isError($argv)) {
|
||||
die($argv->getMessage());
|
||||
}
|
||||
$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sSqu:v");
|
||||
if (PEAR::isError($options)) {
|
||||
usage($options);
|
||||
}
|
||||
|
||||
|
||||
$php_sysconfdir = getenv('PHP_SYSCONFDIR');
|
||||
if (!empty($php_sysconfdir)) {
|
||||
$pear_default_config = $php_sysconfdir.DIRECTORY_SEPARATOR.'pearsys.ini';
|
||||
$pear_user_config = $php_sysconfdir.DIRECTORY_SEPARATOR.'pear.ini';
|
||||
} else {
|
||||
$pear_default_config = PHP_SYSCONFDIR.DIRECTORY_SEPARATOR.'pearsys.ini';
|
||||
$pear_user_config = PHP_SYSCONFDIR.DIRECTORY_SEPARATOR.'pear.ini';
|
||||
}
|
||||
|
||||
$opts = $options[0];
|
||||
|
||||
//echo "ini_get : ".ini_get("pear_install_dir")."\n";
|
||||
//echo "get_cfg_var : ".get_cfg_var("pear_install_dir")."\n";
|
||||
|
||||
foreach ($opts as $opt) {
|
||||
switch ($opt[0]) {
|
||||
case 'c':
|
||||
$pear_user_config = $opt[1];
|
||||
break;
|
||||
case 'C':
|
||||
$pear_default_config = $opt[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$config = new PEAR_Config($pear_user_config, $pear_default_config);
|
||||
$store_user_config = false;
|
||||
$store_default_config = false;
|
||||
$verbose = 1;
|
||||
|
||||
foreach ($opts as $opt) {
|
||||
$param = $opt[1];
|
||||
switch ($opt[0]) {
|
||||
case 'd':
|
||||
list($key, $value) = explode('=', $param);
|
||||
$config->set($key, $value);
|
||||
break;
|
||||
case 'D':
|
||||
list($key, $value) = explode('=', $param);
|
||||
$config->set($key, $value, true);
|
||||
break;
|
||||
case 's':
|
||||
$store_user_config = true;
|
||||
break;
|
||||
case 'S':
|
||||
$store_default_config = true;
|
||||
break;
|
||||
case 'u':
|
||||
$config->toDefault($param);
|
||||
break;
|
||||
case 'v':
|
||||
$verbose++;
|
||||
break;
|
||||
case 'q':
|
||||
$verbose--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($store_default_config) {
|
||||
if (@is_writeable($pear_default_config)) {
|
||||
$config->writeConfigFile($pear_default_config, 'default');
|
||||
} else {
|
||||
die("You don't have write access to $pear_default_config, exiting!\n");
|
||||
}
|
||||
}
|
||||
|
||||
if ($store_user_config) {
|
||||
$config->writeConfigFile($pear_user_config, 'userdefined');
|
||||
}
|
||||
|
||||
$fallback_config = array(
|
||||
'master_server' => 'pear.php.net',
|
||||
'php_dir' => getenv('PEAR_INSTALL_DIR'),
|
||||
'ext_dir' => getenv('PEAR_EXTENSION_DIR'),
|
||||
'doc_dir' => getenv('PHP_DATADIR') . DIRECTORY_SEPARATOR . 'pear' .
|
||||
DIRECTORY_SEPARATOR . 'doc',
|
||||
'verbose' => true,
|
||||
);
|
||||
$fallback_done = array();
|
||||
|
||||
foreach ($fallback_config as $key => $value) {
|
||||
if (!$config->isDefined($key)) {
|
||||
$config->set($key, $value);
|
||||
$fallback_done[$key] = true;
|
||||
}
|
||||
}
|
||||
|
||||
//$verbose = $config->get("verbose");
|
||||
$script_dir = $config->get("php_dir");
|
||||
$ext_dir = $config->get("ext_dir");
|
||||
$doc_dir = $config->get("doc_dir");
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
|
||||
|
||||
$command = (isset($options[1][1])) ? $options[1][1] : null;
|
||||
$rest = array_slice($options[1], 2);
|
||||
|
||||
if (isset($command_options[$command])) {
|
||||
$tmp = Console_Getopt::getopt($rest, $command_options[$command]);
|
||||
if (PEAR::isError($tmp)) {
|
||||
usage($tmp);
|
||||
}
|
||||
$cmdopts = $tmp[0];
|
||||
$cmdargs = $tmp[1];
|
||||
} else {
|
||||
$cmdopts = array();
|
||||
$cmdargs = $rest;
|
||||
}
|
||||
|
||||
|
||||
/* Extracted from pearcmd-common.php */
|
||||
function heading($text)
|
||||
{
|
||||
$l = strlen(trim($text));
|
||||
print rtrim($text) . "\n" . str_repeat("=", $l) . "\n";
|
||||
}
|
||||
|
||||
switch ($command) {
|
||||
case 'install':
|
||||
include 'pearcmd-install.php';
|
||||
break;
|
||||
case 'uninstall':
|
||||
include 'pearcmd-uninstall.php';
|
||||
break;
|
||||
case 'list':
|
||||
include 'pearcmd-list.php';
|
||||
break;
|
||||
case 'package':
|
||||
include 'pearcmd-package.php';
|
||||
break;
|
||||
case 'remote-list':
|
||||
include 'pearcmd-remote-list.php';
|
||||
break;
|
||||
case 'show-config':
|
||||
$keys = $config->getKeys();
|
||||
foreach ($keys as $key) {
|
||||
$value = $config->get($key);
|
||||
$xi = "";
|
||||
if ($config->isDefaulted($key)) {
|
||||
$xi .= " (default)";
|
||||
}
|
||||
if (isset($fallback_done[$key])) {
|
||||
$xi .= " (built-in)";
|
||||
}
|
||||
printf("%s = %s%s\n", $key, $value, $xi);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
if (!$store_default_config && !$store_user_config) {
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function usage($obj = null)
|
||||
{
|
||||
$stderr = fopen('php://stderr', 'w');
|
||||
if ($obj !== null) {
|
||||
fputs($stderr, $obj->getMessage());
|
||||
}
|
||||
fputs($stderr,
|
||||
"Usage: pear [options] command [command-options] <parameters>\n".
|
||||
"Options:\n".
|
||||
" -v increase verbosity level (default 1)\n".
|
||||
" -q be quiet, decrease verbosity level\n".
|
||||
" -c file find user configuration in `file'\n".
|
||||
" -C file find system configuration in `file'\n".
|
||||
" -d \"foo=bar\" set user config variable `foo' to `bar'\n".
|
||||
" -D \"foo=bar\" set system config variable `foo' to `bar'\n".
|
||||
" -s store user configuration\n".
|
||||
" -S store system configuration\n".
|
||||
" -u foo unset `foo' in the user configuration\n".
|
||||
" -h, -? display help/usage (this message)\n".
|
||||
"Commands:\n".
|
||||
" help [command]\n".
|
||||
" install [-r] <package file>\n".
|
||||
" uninstall [-r] <package name>\n".
|
||||
" package [package info file]\n".
|
||||
" list\n".
|
||||
" remote-list\n".
|
||||
" show-config\n".
|
||||
"\n");
|
||||
fclose($stderr);
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,68 +0,0 @@
|
||||
Summary: PEAR: @summary@
|
||||
Name: @rpm_package@
|
||||
Version: @version@
|
||||
Release: 1
|
||||
License: @release_license@
|
||||
Group: Development/Libraries
|
||||
Source: http://@master_server@/get/@package@-%{version}.tgz
|
||||
BuildRoot: %{_tmppath}/%{name}-root
|
||||
URL: http://@master_server@/
|
||||
Prefix: %{_prefix}
|
||||
#Docdir: @doc_dir@/@package@
|
||||
BuildArchitectures: @arch@
|
||||
@extra_headers@
|
||||
|
||||
%description
|
||||
@description@
|
||||
|
||||
%prep
|
||||
rm -rf %{buildroot}/*
|
||||
# XXX Source files location is missing here in pear cmd
|
||||
pear -v -c %{buildroot}/pearrc \
|
||||
-d php_dir=%{_libdir}/php/pear \
|
||||
-d doc_dir=/docs \
|
||||
-d bin_dir=%{_bindir} \
|
||||
-d data_dir=%{_libdir}/php/pear/data \
|
||||
-d test_dir=%{_libdir}/php/pear/tests \
|
||||
-d ext_dir=%{_libdir} \
|
||||
-s
|
||||
|
||||
%build
|
||||
echo BuildRoot=%{buildroot}
|
||||
|
||||
%clean
|
||||
[ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot}
|
||||
|
||||
%postun
|
||||
pear uninstall --nodeps -r @package@
|
||||
|
||||
%post
|
||||
pear install --nodeps -r @rpm_xml_dir@/@package@.xml
|
||||
|
||||
%install
|
||||
pear -c "%{buildroot}/pearrc" install --nodeps -R "%{buildroot}" \
|
||||
"$RPM_SOURCE_DIR/@package@-%{version}.tgz"
|
||||
rm %{buildroot}/pearrc
|
||||
rm %{buildroot}/%{_libdir}/php/pear/.filemap
|
||||
rm %{buildroot}/%{_libdir}/php/pear/.lock
|
||||
rm -rf %{buildroot}/%{_libdir}/php/pear/.registry
|
||||
for DOCDIR in docs doc examples; do
|
||||
if [ -d "%{buildroot}/docs/@package@/$DOCDIR" ]; then
|
||||
rm -rf $RPM_BUILD_DIR/$DOCDIR
|
||||
mv %{buildroot}/docs/@package@/$DOCDIR $RPM_BUILD_DIR
|
||||
rm -rf %{buildroot}/docs
|
||||
fi
|
||||
done
|
||||
mkdir -p %{buildroot}@rpm_xml_dir@
|
||||
tar -xzf $RPM_SOURCE_DIR/@package@-%{version}.tgz package.xml
|
||||
cp -p package.xml %{buildroot}@rpm_xml_dir@/@package@.xml
|
||||
|
||||
#rm -rf %{buildroot}/*
|
||||
#pear -q install -R %{buildroot} -n package.xml
|
||||
#mkdir -p %{buildroot}@rpm_xml_dir@
|
||||
#cp -p package.xml %{buildroot}@rpm_xml_dir@/@package@.xml
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc @doc_files@
|
||||
/
|
||||
Reference in New Issue
Block a user