diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/html/pkgsubmit.php | 18 | ||||
-rw-r--r-- | web/lib/pkgfuncs.inc.php | 36 |
2 files changed, 52 insertions, 2 deletions
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 11206e1..3df38d8 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -155,7 +155,10 @@ if ($uid): 'makedepends' => array(), 'checkdepends' => array(), 'optdepends' => array(), - 'source' => array() + 'source' => array(), + 'conflicts' => array(), + 'provides' => array(), + 'replaces' => array() ); /* Fall-through case. */ case 'epoch': @@ -171,6 +174,9 @@ if ($uid): case 'makedepends': case 'checkdepends': case 'optdepends': + case 'conflicts': + case 'provides': + case 'replaces': $section_info[$key][] = $value; break; } @@ -190,7 +196,7 @@ if ($uid): if (!isset($pkgbase_info['pkgbase'])) { $pkgbase_info['pkgbase'] = $pkgbase_info['pkgname']; } - foreach (array('source', 'depends', 'makedepends', 'checkdepends', 'optdepends') as $array_opt) { + foreach (array('source', 'depends', 'makedepends', 'checkdepends', 'optdepends', 'conflicts', 'provides', 'replaces') as $array_opt) { if (empty($pkgbase_info[$array_opt])) { $pkgbase_info[$array_opt] = array(); } else { @@ -359,6 +365,14 @@ if ($uid): } } + foreach (array('conflicts', 'provides', 'replaces') as $reltype) { + foreach ($pi[$reltype] as $rel) { + $relpkgname = preg_replace("/(<|=|>).*/", "", $rel); + $relcondition = str_replace($relpkgname, "", $rel); + pkg_add_rel($pkgid, $reltype, $relpkgname, $relcondition); + } + } + foreach ($pi['source'] as $src) { pkg_add_src($pkgid, $src); } diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 5c30a95..2eb0be4 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -148,6 +148,21 @@ function pkg_dependency_type_id_from_name($name) { } /** + * Get the ID of a relation type given its name + * + * @param string $name The name of the relation type + * + * @return int The ID of the relation type + */ +function pkg_relation_type_id_from_name($name) { + $dbh = DB::connect(); + $q = "SELECT ID FROM RelationTypes WHERE Name = "; + $q.= $dbh->quote($name); + $result = $dbh->query($q); + return $result->fetch(PDO::FETCH_COLUMN, 0); +} + +/** * Get the HTML code to display a package dependency link * * @param string $name The name of the dependency @@ -727,6 +742,27 @@ function pkg_add_dep($pkgid, $type, $depname, $depcondition) { } /** + * Add a relation for a specific package to the database + * + * @param int $pkgid The package ID to add the relation for + * @param string $type The type of relation to add + * @param string $relname The name of the relation to add + * @param string $relcondition The version requirement of the relation + * + * @return void + */ +function pkg_add_rel($pkgid, $type, $relname, $relcondition) { + $dbh = DB::connect(); + $q = sprintf("INSERT INTO PackageRelations (PackageID, RelTypeID, RelName, RelCondition) VALUES (%d, %d, %s, %s)", + $pkgid, + pkg_relation_type_id_from_name($type), + $dbh->quote($relname), + $dbh->quote($relcondition) + ); + $dbh->exec($q); +} + +/** * Add a source for a specific package to the database * * @param int $pkgid The package ID to add the source for |