cvs: php4 /pear/PEAR Installer.php Packager.php /pear/scripts pear.in

From: Date: Tue, 17 Apr 2001 02:33:46 +0000
Subject: cvs: php4 /pear/PEAR Installer.php Packager.php /pear/scripts pear.in
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36@lists.php.net to get a copy of this message
ssb Mon Apr 16 19:33:46 2001 EDT Modified files: /php4/pear/PEAR Installer.php Packager.php /php4/pear/scripts pear.in Log: * PEAR_Installer un-broken again, it still doesn't update the package list though * better error handling in "pear" script Index: php4/pear/PEAR/Installer.php diff -u php4/pear/PEAR/Installer.php:1.7 php4/pear/PEAR/Installer.php:1.8 --- php4/pear/PEAR/Installer.php:1.7 Mon Apr 16 18:17:59 2001 +++ php4/pear/PEAR/Installer.php Mon Apr 16 19:33:45 2001 @@ -91,7 +91,7 @@ $this->extdir = $extdir; $this->docdir = $docdir; $this->statedir = "/var/lib/php"; // XXX FIXME Windows - $this->loadPackageList("$this->statedir/packagelist.xml"); + $this->loadPackageList("$this->statedir/packages.lst"); } // }}} @@ -182,15 +182,26 @@ function loadPackageList($file) { $this->pkglist_file = $file; + $this->pkglist = array(); if (!file_exists($file)) { - touch($file); + if (!@touch($file)) { + return $this->raiseError("touch($file): $php_errormsg"); + } } - $fp = $this->pkglist_fp = fopen($file, "r"); + $fp = $this->pkglist_fp = @fopen($file, "r"); + if (!is_resource($fp)) { + return $this->raiseError("fopen($file): $php_errormsg"); + } $this->lockPackageList(); - while ($line = fgets($fp, 2048)) { - list($type, $name, $file) = explode(" ", trim($line)); - $this->pkglist[$type][$name] = $file; - } + $versionline = trim(fgets($fp, 2048)); + if ($versionline == ";1") { + while ($line = fgets($fp, 2048)) { + list($name, $version, $file) = explode(";", trim($line)); + $this->pkglist[$name]["version"] = $version; + $this->pkglist[$name]["files"][] = $file; + } + } + $this->unlockPackageList(); } // }}} @@ -198,19 +209,19 @@ function savePackageList() { $fp = $this->pkglist_fp; - $wfp = fopen($this->pkglist_file, "w"); - if (!$wfp) { - return false; + $wfp = @fopen($this->pkglist_file, "w"); + if (!is_resource($wfp)) { + return $this->raiseError("could not write $this->pkglist_file"); } if (is_resource($fp)) { fclose($fp); } $this->pkglist_fp = $fp = $wfp; - reset($this->pkglist); - while (list($type, $entry) = each($this->pkglist)) { - reset($entry); - while (list($name, $file) = each($entry)) { - fwrite($fp, "$type $name $file\n"); + fwrite($fp, ";1\n"); + foreach ($this->pkglist as $name => $entry) { + $ver = $entry["version"]; + foreach ($entry["files"] as $file) { + fwrite($fp, "$name;$ver;$file\n"); } } fclose($fp); @@ -338,14 +349,13 @@ $this->current_element = false; $this->destdir = ''; - while ($data = fread($fp, 2048)) { - if (!xml_parse($xp, $data, feof($fp))) { - $err = $this->raiseError(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 $err; - } + $data = fread($fp, filesize($descfile)); + if (!xml_parse($xp, $data, 1)) { + $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); @@ -362,10 +372,12 @@ $this->current_attributes = $attribs; switch ($name) { case "Package": +/* if (strtolower($attribs["Type"]) != "binary") { return $this->raiseError("Invalid package: only binary packages supported yet."); } $this->pkginfo['pkgtype'] = strtolower($attribs["Type"]); +*/ break; } } @@ -382,10 +394,16 @@ // {{{ charHandler() function charHandler($xp, $data) { - // XXX FIXME: $data may be incomplete, all of this code should - // actually be in endHandler. - // + $next = $this->element_stack[sizeof($this->element_stack)-1]; switch ($this->current_element) { + case "Name": + if ($next == "Package") { + $this->pkginfo["name"] = $data; + } + break; + case "Version": + $this->pkginfo["version"] = $data; + break; case "Dir": if (!$this->phpdir) { break; Index: php4/pear/PEAR/Packager.php diff -u php4/pear/PEAR/Packager.php:1.1 php4/pear/PEAR/Packager.php:1.2 --- php4/pear/PEAR/Packager.php:1.1 Mon Apr 16 18:17:59 2001 +++ php4/pear/PEAR/Packager.php Mon Apr 16 19:33:45 2001 @@ -158,7 +158,7 @@ " <Summary>".$this->pkginfo["Package,Summary"]."</Summary>\n". " <Maintainer>\n". " <Initials>".$this->pkginfo["Maintainer,Initials"]."</Initials>\n". - " <Name>".$this->pkginfo["Maintainer,Name"]."</Initials>\n". + " <Name>".$this->pkginfo["Maintainer,Name"]."</Name>\n". " <Email>".$this->pkginfo["Maintainer,Email"]."</Email>\n". " </Maintainer>\n". " <Release>\n". Index: php4/pear/scripts/pear.in diff -u php4/pear/scripts/pear.in:1.2 php4/pear/scripts/pear.in:1.3 --- php4/pear/scripts/pear.in:1.2 Mon Apr 16 18:17:59 2001 +++ php4/pear/scripts/pear.in Mon Apr 16 19:33:45 2001 @@ -24,14 +24,20 @@ case "install": $package = $options[1][2]; $installer =& new PEAR_Installer(); - $installer->Install($package); - print "install ok\n"; + if (PEAR::isError($installer->Install($package))) { + print "\ninstall failed\n"; + } else { + print "install ok\n"; + } break; case "package": $pkginfofile = $options[1][2]; $packager =& new PEAR_Packager(); - $packager->Package($pkginfofile); - print "package ok\n"; + if (PEAR::isError($packager->Package($pkginfofile))) { + print "\npackage failed\n"; + } else { + print "package ok\n"; + } break; default: usage();

« previous php.pear.cvs (#36) next »