echo " Processing All Releases..."; $pear_rest->saveAllReleasesREST($package); echo "done\n"; foreach ($releases as $version => $blah) { $sql = 'SELECT fullpath FROM files WHERE `release` = ?'; $fileinfo = $dbh->getOne($sql, array($blah['id'])); $tar =& new Archive_Tar($fileinfo); if ($pxml = $tar->extractInString('package2.xml')) { } elseif ($pxml = $tar->extractInString('package.xml')) { } PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $pf = $pkg->fromAnyFile($fileinfo, PEAR_VALIDATE_NORMAL); PEAR::popErrorHandling(); if (!PEAR::isError($pf)) { echo " Version {$version}..."; $pear_rest->saveReleaseREST($fileinfo, $pxml, $pf, $blah['doneby'], $blah['id']); echo "done\n"; } else { echo " Skipping INVALID Version {$version}\n"; } } echo "\n"; } else { echo " done\n"; } } echo "Generating Category Package REST...\n"; foreach (category::listAll() as $category) { echo " {$category['name']}..."; $pear_rest->savePackagesCategoryREST($category['name']); echo "done\n";
/** * Confirm release upload * * @param string Package name * @param string Package version * @param string Package state * @param string Release notes * @param string md5 * @param int Package id from database * @param string package contents * @static * @return string the file name of the upload or PEAR_Error object if problems */ static function confirmUpload($package, $version, $state, $relnotes, $md5sum, $package_id, $file, $pkg_info = false, $packagexml = false, $compatible = false) { require_once 'PEAR/Common.php'; global $dbh, $auth_user, $_PEAR_Common_dependency_types, $_PEAR_Common_dependency_relations; if (!$pkg_info) { require_once 'Archive/Tar.php'; $tar = new Archive_Tar($file); $oldpackagexml = $tar->extractInString('package.xml'); if (null === ($packagexml = $tar->extractInString('package2.xml'))) { if ($oldpackagexml === null) { return PEAR::raiseError('Archive uploaded does not appear to contain a package.xml!'); } $packagexml = $oldpackagexml; } $compatible = $oldpackagexml != $packagexml ? true : false; } // Update releases table $query = "INSERT INTO releases (id,package,version,state,doneby," . "releasedate,releasenotes) VALUES(?,?,?,?,?,NOW(),?)"; $sth = $dbh->prepare($query); $release_id = $dbh->nextId('releases'); $dbh->execute($sth, array($release_id, $package_id, $version, $state, $auth_user->handle, $relnotes)); // Update files table $query = "INSERT INTO files " . "(id,package,`release`,md5sum,basename,fullpath,packagexml) " . "VALUES(?,?,?,?,?,?,?)"; $sth = $dbh->prepare($query); $file_id = $dbh->nextId("files"); $ok = $dbh->execute($sth, array($file_id, $package_id, $release_id, $md5sum, basename($file), $file, $packagexml)); /* * Code duplication with deps error * Should be droped soon or later using transaction * (and add mysql4 as a pe(ar|cl)web requirement) */ if (PEAR::isError($ok)) { $dbh->query("DELETE FROM releases WHERE id = {$release_id}"); @unlink($file); return $ok; } // Update dependency table $query = "INSERT INTO deps " . "(package, `release`, type, relation, version, name, optional) " . "VALUES (?,?,?,?,?,?,?)"; $sth = $dbh->prepare($query); if (!$pkg_info) { require_once 'PEAR/PackageFile.php'; require_once 'PEAR/Config.php'; $config = PEAR_Config::singleton(); $pf = new PEAR_PackageFile($config); $pkg_info = $pf->fromXmlString($packagexml, PEAR_VALIDATE_DOWNLOADING, $compatible ? 'package2.xml' : 'package.xml'); } $deps = $pkg_info->getDeps(true); // get the package2.xml actual content $storedeps = $pkg_info->getDeps(); // get the BC-compatible content $pearused = false; if (isset($deps['required']['package'])) { if (!isset($deps['required']['package'][0])) { $deps['required']['package'] = array($deps['required']['package']); } foreach ($deps['required']['package'] as $pkgdep) { if ($pkgdep['channel'] == 'pear.php.net' && strtolower($pkgdep['name']) == 'pear') { $pearused = true; } } } if (is_array($storedeps)) { foreach ($storedeps as $dep) { $prob = array(); if (empty($dep['type']) || !in_array($dep['type'], $_PEAR_Common_dependency_types)) { $prob[] = 'type'; } if (empty($dep['name'])) { /* * NOTE from pajoye in ver 1.166: * This works for now. * This would require a 'cleaner' InfoFromXXX * which may return a defined set of data using * default values if required. */ if (strtolower($dep['type']) == 'php') { $dep['name'] = 'PHP'; } else { $prob[] = 'name'; } } elseif (strtolower($dep['name']) == 'pear') { if (!$pearused && $compatible) { // there is no need for a PEAR dependency here continue; } if (!$pearused && !$compatible) { $dep['name'] = 'PEAR Installer'; } } if (empty($dep['rel']) || !in_array($dep['rel'], $_PEAR_Common_dependency_relations)) { $prob[] = 'rel'; } if (empty($dep['optional'])) { $optional = 0; } else { if ($dep['optional'] != strtolower($dep['optional'])) { $prob[] = 'optional'; } $optional = $dep['optional'] == 'yes' ? 1 : 0; } if (count($prob)) { $res = PEAR::raiseError('The following attribute(s) ' . 'were missing or need proper values: ' . implode(', ', $prob)); } else { $res = $dbh->execute($sth, array($package_id, $release_id, $dep['type'], $dep['rel'], @$dep['version'], $dep['name'], $optional)); } if (PEAR::isError($res)) { $dbh->query('DELETE FROM deps WHERE `release` = ' . $release_id); $dbh->query('DELETE FROM releases WHERE id = ' . $release_id); @unlink($file); return $res; } } } include_once 'pear-database-package.php'; $n = package::info($package, 'name'); if (!in_array($n, array('pearweb', 'pearweb_phars'), true)) { // Add release archive file to API documentation queue $query = "INSERT INTO apidoc_queue (filename, queued) " . "VALUES ('" . $file . "', NOW())"; // Don't abort the release if something goes wrong. $dbh->pushErrorHandling(PEAR_ERROR_RETURN); $sth = $dbh->query($query); $dbh->popErrorHandling(); } // Update Cache include_once 'pear-rest.php'; $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh); $pear_rest->saveAllReleasesREST($package); $pear_rest->saveReleaseREST($file, $packagexml, $pkg_info, $auth_user->handle, $release_id); $pear_rest->savePackagesCategoryREST(package::info($package, 'category')); return $file; }