$this->prev_element = $this->element_stack[sizeof($this->element_stack)-2];
$this->current_attributes = $attribs;
switch ($name) {
- case 'DIR':
+ case 'dir':
if (isset($this->dir_names)) {
- $this->dir_names[] = $attribs['NAME'];
+ $this->dir_names[] = $attribs['name'];
} else {
// Don't add the root dir
$this->dir_names = array();
}
- if (isset($attribs['BASEINSTALLDIR'])) {
- $this->dir_install = $attribs['BASEINSTALLDIR'];
+ if (isset($attribs['baseinstalldir'])) {
+ $this->dir_install = $attribs['baseinstalldir'];
}
- if (isset($attribs['ROLE'])) {
- $this->dir_role = $attribs['ROLE'];
+ if (isset($attribs['role'])) {
+ $this->dir_role = $attribs['role'];
}
break;
- case 'LIBFILE':
+ case 'libfile':
$this->lib_atts = $attribs;
- $this->lib_atts['ROLE'] = 'extension';
+ $this->lib_atts['role'] = 'extension';
break;
- case 'MAINTAINERS':
+ case 'maintainers':
$this->pkginfo['maintainers'] = array();
$this->m_i = 0; // maintainers array index
break;
- case 'MAINTAINER':
+ case 'maintainer':
// compatibility check
if (!isset($this->pkginfo['maintainers'])) {
$this->pkginfo['maintainers'] = array();
$this->pkginfo['maintainers'][$this->m_i] = array();
$this->current_maintainer =& $this->pkginfo['maintainers'][$this->m_i];
break;
- case 'CHANGELOG':
+ case 'changelog':
$this->pkginfo['changelog'] = array();
$this->c_i = 0; // changelog array index
$this->in_changelog = true;
break;
- case 'RELEASE':
+ case 'release':
if ($this->in_changelog) {
$this->pkginfo['changelog'][$this->c_i] = array();
$this->current_release =& $this->pkginfo['changelog'][$this->c_i];
function _element_end($xp, $name)
{
switch ($name) {
- case 'DIR':
+ case 'dir':
array_pop($this->dir_names);
break;
- case 'FILE':
+ case 'file':
$path = '';
foreach ($this->dir_names as $dir) {
$path .= $dir . DIRECTORY_SEPARATOR;
$path .= $this->current_file;
$this->filelist[$path] = $this->current_attributes;
// Set the baseinstalldir only if the file don't have this attrib
- if (!isset($this->filelist[$path]['BASEINSTALLDIR']) &&
+ if (!isset($this->filelist[$path]['baseinstalldir']) &&
isset($this->dir_install))
{
- $this->filelist[$path]['BASEINSTALLDIR'] = $this->dir_install;
+ $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
}
// Set the Role
- if (!isset($this->filelist[$path]['ROLE']) && isset($this->dir_role)) {
- $this->filelist[$path]['ROLE'] = $this->dir_role;
+ if (!isset($this->filelist[$path]['role']) && isset($this->dir_role)) {
+ $this->filelist[$path]['role'] = $this->dir_role;
}
break;
- case 'LIBFILE':
+ case 'libfile':
$path = '';
foreach ($this->dir_names as $dir) {
$path .= $dir . DIRECTORY_SEPARATOR;
$path .= $this->lib_name;
$this->filelist[$path] = $this->lib_atts;
// Set the baseinstalldir only if the file don't have this attrib
- if (!isset($this->filelist[$path]['BASEINSTALLDIR']) &&
+ if (!isset($this->filelist[$path]['baseinstalldir']) &&
isset($this->dir_install))
{
- $this->filelist[$path]['BASEINSTALLDIR'] = $this->dir_install;
+ $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
}
if (isset($this->lib_sources)) {
$this->filelist[$path]['sources'] = $this->lib_sources;
unset($this->lib_atts);
unset($this->lib_sources);
break;
- case 'MAINTAINER':
+ case 'maintainer':
$this->m_i++;
break;
- case 'RELEASE':
+ case 'release':
if ($this->in_changelog) {
$this->c_i++;
}
break;
- case 'CHANGELOG':
+ case 'changelog':
$this->in_changelog = false;
}
array_pop($this->element_stack);
function _pkginfo_cdata($xp, $data)
{
switch ($this->current_element) {
- case 'NAME':
+ case 'name':
switch ($this->prev_element) {
- case 'PACKAGE':
+ case 'package':
$this->pkginfo['package'] .= $data;
break;
- case 'MAINTAINER':
+ case 'maintainer':
$this->current_maintainer['name'] .= $data;
break;
}
break;
- case 'SUMMARY':
+ case 'summary':
$this->pkginfo['summary'] .= $data;
break;
- case 'USER':
+ case 'user':
$this->current_maintainer['handle'] .= $data;
break;
- case 'EMAIL':
+ case 'email':
$this->current_maintainer['email'] .= $data;
break;
- case 'ROLE':
+ case 'role':
if (!in_array($data, $this->maintainer_roles)) {
trigger_error("The maintainer role: '$data' is not valid", E_USER_WARNING);
} else {
$this->current_maintainer['role'] .= $data;
}
break;
- case 'VERSION':
+ case 'version':
if ($this->in_changelog) {
$this->current_release['version'] .= $data;
} else {
$this->pkginfo['version'] .= $data;
}
break;
- case 'DATE':
+ case 'date':
if ($this->in_changelog) {
$this->current_release['release_date'] .= $data;
} else {
$this->pkginfo['release_date'] .= $data;
}
break;
- case 'NOTES':
+ case 'notes':
if ($this->in_changelog) {
$this->current_release['release_notes'] .= $data;
} else {
$this->pkginfo['release_notes'] .= $data;
}
break;
- case 'STATE':
+ case 'state':
if (!in_array($data, $this->releases_states)) {
trigger_error("The release state: '$data' is not valid", E_USER_WARNING);
} elseif ($this->in_changelog) {
$this->pkginfo['release_state'] .= $data;
}
break;
- case 'DIR':
+ case 'dir':
break;
- case 'FILE':
- $role = strtolower($this->current_attributes['ROLE']);
+ case 'file':
+ $role = strtolower($this->current_attributes['role']);
$this->current_file = trim($data);
break;
- case 'LIBNAME':
+ case 'libname':
$this->lib_name = trim($data);
break;
- case 'SOURCES':
+ case 'sources':
$this->lib_sources[] = trim($data);
break;
}
xml_set_object($xp, $this);
xml_set_element_handler($xp, '_element_start', '_element_end');
xml_set_character_data_handler($xp, '_pkginfo_cdata');
- xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true);
+ xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
$this->element_stack = array();
$this->pkginfo = array();
$tmp_path = dirname($descfile);
foreach ($pkginfo['filelist'] as $fname => $atts) {
$dest_dir = $this->phpdir . DIRECTORY_SEPARATOR;
- if (isset($atts['BASEINSTALLDIR'])) {
- $dest_dir .= $atts['BASEINSTALLDIR'] . DIRECTORY_SEPARATOR;
+ if (isset($atts['baseinstalldir'])) {
+ $dest_dir .= $atts['baseinstalldir'] . DIRECTORY_SEPARATOR;
}
if (dirname($fname) != '.') {
$dest_dir .= dirname($fname) . DIRECTORY_SEPARATOR;
function _installFile($file, $dest_dir, $atts)
{
- $type = strtolower($atts['ROLE']);
+ $type = strtolower($atts['role']);
switch ($type) {
case 'test':
// don't install test files for now
return $dest_package;
}
- /* XXXX REMOVEME: this is the old code
- function _package($pkgfile = "package.xml")
- {
- $pwd = getcwd();
- $fp = @fopen($pkgfile, "r");
- if (!is_resource($fp)) {
- return $this->raiseError($php_errormsg);
- }
-
- $xp = xml_parser_create();
- if (!$xp) {
- return $this->raiseError("Unable to create XML parser.");
- }
- xml_set_object($xp, $this);
- xml_set_element_handler($xp, "startHandler", "endHandler");
- xml_set_character_data_handler($xp, "charHandler");
- xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
- xml_parser_set_option($xp, XML_OPTION_TARGET_ENCODING, "UTF-8");
-
- $this->element_stack = array();
- $this->pkginfo = array();
- $this->current_element = false;
-
- $data = fread($fp, filesize($pkgfile));
- fclose($fp);
- if (!xml_parse($xp, $data, true)) {
- $msg = sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xp)),
- xml_get_current_line_number($xp));
- xml_parser_free($xp);
- return $this->raiseError($msg);
- }
- xml_parser_free($xp);
-
- $pkginfofile = $this->tmpdir . DIRECTORY_SEPARATOR . "package.xml";
- $fp = fopen($pkginfofile, "w");
- if (!is_resource($fp)) {
- return $this->raiseError("Could not create $pkginfofile: $php_errormsg");
- }
-
- $this->filelist = preg_replace('/^[\r\n]+\s+/', ' ', $this->filelist);
- $this->filelist = preg_replace('/\n\s+/', "\n ", $this->filelist);
- $this->filelist = preg_replace('/\n\s+$/', "", $this->filelist);
-
- fputs($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n".
- "<!DOCTYPE Package PUBLIC \"-//PHP Group//DTD PEAR Package 1.0//EN//XML\" \"http://php.net/pear/package.dtd\">\n".
- "<Package Type=\"Source\">\n".
- " <Name>".$this->pkginfo["Package,Name"]."</Name>\n".
- " <Summary>".$this->pkginfo["Package,Summary"]."</Summary>\n".
- " <Maintainer>\n".
- " <Initials>".$this->pkginfo["Maintainer,Initials"]."</Initials>\n".
- " <Name>".$this->pkginfo["Maintainer,Name"]."</Name>\n".
- " <Email>".$this->pkginfo["Maintainer,Email"]."</Email>\n".
- " </Maintainer>\n".
- " <Release>\n".
- " <Version>".$this->pkginfo["Release,Version"]."</Version>\n".
- " <Date>".$this->pkginfo["Release,Date"]."</Date>\n".
- " <Notes>".$this->pkginfo["Release,Notes"]."</Notes>\n".
- " </Release>\n".
- " <FileList>\n".
- "$this->filelist\n".
- " </FileList>\n".
- "</Package>\n");
- fclose($fp);
- chdir(dirname($this->tmpdir));
- // XXX FIXME Windows and non-GNU tar
- $pkgver = $this->pkgver;
- $cmd = "tar -cvzf $pwd/${pkgver}.tgz $pkgver";
- $this->log(1, `$cmd`);
- $this->log(1, "Package $pwd/${pkgver}.tgz done");
- }
-
- // }}}
-
- // {{{ startHandler()
-
- function startHandler($xp, $name, $attribs)
- {
- array_push($this->element_stack, $name);
- $this->current_element = $name;
- $this->current_attributes = $attribs;
- $this->tmpdata = '';
- if ($this->recordfilelist) {
- $this->filelist .= "<$name";
- foreach ($attribs as $k => $v) {
- $this->filelist .= " $k=\"$v\"";
- }
- $this->filelist .= ">";
- }
- switch ($name) {
- case "Package":
- if ($attribs["Type"]) {
- // warning
- }
- break;
- case "FileList":
- // XXX FIXME Windows
- $this->recordfilelist = true;
- $pwd = getcwd();
- $this->pkgver = $this->pkginfo["Package,Name"] . "-" .
- $this->pkginfo["Release,Version"];
- // don't want extrange characters
- $this->pkgver = ereg_replace ("[^a-zA-Z0-9._-]", '_', $this->pkgver);
- $this->tmpdir = $pwd . DIRECTORY_SEPARATOR . $this->pkgver;
- if (file_exists($this->tmpdir)) {
- xml_parser_free($xp);
- $this->raiseError("$this->tmpdir already exists",
- null, PEAR_ERROR_TRIGGER,
- E_USER_ERROR);
- }
- if (!mkdir($this->tmpdir, 0755)) {
- xml_parser_free($xp);
- $this->raiseError("Unable to create temporary directory $this->tmpdir.",
- null, PEAR_ERROR_TRIGGER,
- E_USER_ERROR);
- }
- $this->_tempfiles[] = $this->tmpdir;
- break;
- }
- }
-
- // }}}
- // {{{ endHandler()
-
- function endHandler($xp, $name)
- {
- array_pop($this->element_stack);
- $this->current_element = $this->element_stack[sizeof($this->element_stack)-1];
- switch ($name) {
- case "FileList":
- $this->recordfilelist = false;
- break;
- }
- if ($this->recordfilelist) {
- $this->filelist .= "</$name>";
- }
- }
-
- // }}}
- // {{{ charHandler()
-
- function charHandler($xp, $data)
- {
- if ($this->recordfilelist) {
- $this->filelist .= $data;
- }
- switch ($this->current_element) {
- case "Dir":
- break;
- case "File":
- $file = "$this->tmpdir/$data";
- $dir = dirname($file);
- if (!is_dir($dir)) {
- if (!$this->mkDirHier($dir)) {
- $this->log(0, "could not mkdir $dir");
- break;
- }
- }
- if (!@copy($data, $file)) {
- $this->log(0, "could not copy $data to $file");
- }
- // fall through
- default:
- $data = trim($data);
- if ($data) {
- $id = implode(",", array_slice($this->element_stack, -2));
- $this->pkginfo[$id] = $data;
- }
- break;
- }
- }
- */
// }}}
}