mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add support for architecture-specific fields
This adds support for architecture-specific dependencies and relations. Support for this has recently been added to makepkg, see commit 2b556d8 (PKGBUILD: handle arch specific attributes, 2014-07-25) in the pacman repository for details. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
2b29fa4bb0
commit
4d7da95906
5 changed files with 114 additions and 37 deletions
|
@ -198,6 +198,7 @@ CREATE TABLE PackageDepends (
|
||||||
DepTypeID TINYINT UNSIGNED NOT NULL,
|
DepTypeID TINYINT UNSIGNED NOT NULL,
|
||||||
DepName VARCHAR(255) NOT NULL,
|
DepName VARCHAR(255) NOT NULL,
|
||||||
DepCondition VARCHAR(255),
|
DepCondition VARCHAR(255),
|
||||||
|
DepArch VARCHAR(255) NULL DEFAULT NULL,
|
||||||
INDEX (PackageID),
|
INDEX (PackageID),
|
||||||
INDEX (DepName),
|
INDEX (DepName),
|
||||||
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
|
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
|
||||||
|
@ -224,6 +225,7 @@ CREATE TABLE PackageRelations (
|
||||||
RelTypeID TINYINT UNSIGNED NOT NULL,
|
RelTypeID TINYINT UNSIGNED NOT NULL,
|
||||||
RelName VARCHAR(255) NOT NULL,
|
RelName VARCHAR(255) NOT NULL,
|
||||||
RelCondition VARCHAR(255),
|
RelCondition VARCHAR(255),
|
||||||
|
RelArch VARCHAR(255) NULL DEFAULT NULL,
|
||||||
INDEX (PackageID),
|
INDEX (PackageID),
|
||||||
INDEX (RelName),
|
INDEX (RelName),
|
||||||
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
|
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
|
||||||
|
|
6
upgrading/3.5.0.txt
Normal file
6
upgrading/3.5.0.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
1. Add support for architecture-specific dependencies to the database:
|
||||||
|
|
||||||
|
----
|
||||||
|
ALTER TABLE PackageDepends ADD COLUMN DepArch VARCHAR(255) NULL DEFAULT NULL;
|
||||||
|
ALTER TABLE PackageRelations ADD COLUMN RelArch VARCHAR(255) NULL DEFAULT NULL;
|
||||||
|
----
|
|
@ -137,6 +137,13 @@ if ($uid):
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list($key, $value) = explode(' = ', $line, 2);
|
list($key, $value) = explode(' = ', $line, 2);
|
||||||
|
$tokens = explode('_', $key, 2);
|
||||||
|
$key = $tokens[0];
|
||||||
|
if (count($tokens) > 1) {
|
||||||
|
$arch = $tokens[1];
|
||||||
|
} else {
|
||||||
|
$arch = NULL;
|
||||||
|
}
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'pkgbase':
|
case 'pkgbase':
|
||||||
case 'pkgname':
|
case 'pkgname':
|
||||||
|
@ -170,6 +177,8 @@ if ($uid):
|
||||||
case 'license':
|
case 'license':
|
||||||
case 'groups':
|
case 'groups':
|
||||||
case 'source':
|
case 'source':
|
||||||
|
$section_info[$key][] = $value;
|
||||||
|
break;
|
||||||
case 'depends':
|
case 'depends':
|
||||||
case 'makedepends':
|
case 'makedepends':
|
||||||
case 'checkdepends':
|
case 'checkdepends':
|
||||||
|
@ -177,7 +186,7 @@ if ($uid):
|
||||||
case 'conflicts':
|
case 'conflicts':
|
||||||
case 'provides':
|
case 'provides':
|
||||||
case 'replaces':
|
case 'replaces':
|
||||||
$section_info[$key][] = $value;
|
$section_info[$key][$arch][] = $value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,18 +363,22 @@ if ($uid):
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array('depends', 'makedepends', 'checkdepends', 'optdepends') as $deptype) {
|
foreach (array('depends', 'makedepends', 'checkdepends', 'optdepends') as $deptype) {
|
||||||
foreach ($pi[$deptype] as $dep) {
|
foreach ($pi[$deptype] as $deparch => $depgrp) {
|
||||||
$deppkgname = preg_replace("/(<|=|>).*/", "", $dep);
|
foreach ($depgrp as $dep) {
|
||||||
$depcondition = str_replace($deppkgname, "", $dep);
|
$deppkgname = preg_replace("/(<|=|>).*/", "", $dep);
|
||||||
pkg_add_dep($pkgid, $deptype, $deppkgname, $depcondition);
|
$depcondition = str_replace($deppkgname, "", $dep);
|
||||||
|
pkg_add_dep($pkgid, $deptype, $deppkgname, $depcondition, $deparch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array('conflicts', 'provides', 'replaces') as $reltype) {
|
foreach (array('conflicts', 'provides', 'replaces') as $reltype) {
|
||||||
foreach ($pi[$reltype] as $rel) {
|
foreach ($pi[$reltype] as $relarch => $relgrp) {
|
||||||
$relpkgname = preg_replace("/(<|=|>).*/", "", $rel);
|
foreach ($relgrp as $rel) {
|
||||||
$relcondition = str_replace($relpkgname, "", $rel);
|
$relpkgname = preg_replace("/(<|=|>).*/", "", $rel);
|
||||||
pkg_add_rel($pkgid, $reltype, $relpkgname, $relcondition);
|
$relcondition = str_replace($relpkgname, "", $rel);
|
||||||
|
pkg_add_rel($pkgid, $reltype, $relpkgname, $relcondition, $relarch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ function pkg_dependencies($pkgid) {
|
||||||
$pkgid = intval($pkgid);
|
$pkgid = intval($pkgid);
|
||||||
if ($pkgid > 0) {
|
if ($pkgid > 0) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
$q = "SELECT pd.DepName, dt.Name, pd.DepCondition, p.ID FROM PackageDepends pd ";
|
$q = "SELECT pd.DepName, dt.Name, pd.DepCondition, pd.DepArch, p.ID FROM PackageDepends pd ";
|
||||||
$q.= "LEFT JOIN Packages p ON pd.DepName = p.Name ";
|
$q.= "LEFT JOIN Packages p ON pd.DepName = p.Name ";
|
||||||
$q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) = p.Name ";
|
$q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) = p.Name ";
|
||||||
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
|
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
|
||||||
|
@ -167,7 +167,7 @@ function pkg_relations($pkgid) {
|
||||||
$pkgid = intval($pkgid);
|
$pkgid = intval($pkgid);
|
||||||
if ($pkgid > 0) {
|
if ($pkgid > 0) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
$q = "SELECT pr.RelName, rt.Name, pr.RelCondition, p.ID FROM PackageRelations pr ";
|
$q = "SELECT pr.RelName, rt.Name, pr.RelCondition, pr.RelArch, p.ID FROM PackageRelations pr ";
|
||||||
$q.= "LEFT JOIN Packages p ON pr.RelName = p.Name ";
|
$q.= "LEFT JOIN Packages p ON pr.RelName = p.Name ";
|
||||||
$q.= "LEFT JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
|
$q.= "LEFT JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
|
||||||
$q.= "WHERE pr.PackageID = ". $pkgid . " ";
|
$q.= "WHERE pr.PackageID = ". $pkgid . " ";
|
||||||
|
@ -219,11 +219,12 @@ function pkg_relation_type_id_from_name($name) {
|
||||||
* @param string $name The name of the dependency
|
* @param string $name The name of the dependency
|
||||||
* @param string $type The name of the dependency type
|
* @param string $type The name of the dependency type
|
||||||
* @param string $cond The package dependency condition string
|
* @param string $cond The package dependency condition string
|
||||||
|
* @param string $arch The package dependency architecture
|
||||||
* @param int $pkg_id The package of the package to display the dependency for
|
* @param int $pkg_id The package of the package to display the dependency for
|
||||||
*
|
*
|
||||||
* @return string The HTML code of the label to display
|
* @return string The HTML code of the label to display
|
||||||
*/
|
*/
|
||||||
function pkg_depend_link($name, $type, $cond, $pkg_id) {
|
function pkg_depend_link($name, $type, $cond, $arch, $pkg_id) {
|
||||||
if ($type == 'optdepends' && strpos($name, ':') !== false) {
|
if ($type == 'optdepends' && strpos($name, ':') !== false) {
|
||||||
$tokens = explode(':', $name, 2);
|
$tokens = explode(':', $name, 2);
|
||||||
$name = $tokens[0];
|
$name = $tokens[0];
|
||||||
|
@ -242,17 +243,54 @@ function pkg_depend_link($name, $type, $cond, $pkg_id) {
|
||||||
$link .= htmlspecialchars($name) . '</a>';
|
$link .= htmlspecialchars($name) . '</a>';
|
||||||
$link .= htmlspecialchars($cond);
|
$link .= htmlspecialchars($cond);
|
||||||
|
|
||||||
if ($type == 'makedepends') {
|
if ($type != 'depends' || $arch) {
|
||||||
$link .= ' <em>(make)</em>';
|
$link .= ' <em>(';
|
||||||
} elseif ($type == 'checkdepends') {
|
|
||||||
$link .= ' <em>(check)</em>';
|
if ($type == 'makedepends') {
|
||||||
} elseif ($type == 'optdepends') {
|
$link .= 'make';
|
||||||
$link .= ' <em>(optional) – ' . htmlspecialchars($desc) . ' </em>';
|
} elseif ($type == 'checkdepends') {
|
||||||
|
$link .= 'check';
|
||||||
|
} elseif ($type == 'optdepends') {
|
||||||
|
$link .= 'optional';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type != 'depends' && $arch) {
|
||||||
|
$link .= ', ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($arch) {
|
||||||
|
$link .= htmlspecialchars($arch);
|
||||||
|
}
|
||||||
|
|
||||||
|
$link .= ')';
|
||||||
|
if ($type == 'optdepends') {
|
||||||
|
$link .= ' – ' . htmlspecialchars($desc) . ' </em>';
|
||||||
|
}
|
||||||
|
$link .= '</em>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTML code to display a package relation
|
||||||
|
*
|
||||||
|
* @param string $name The name of the relation
|
||||||
|
* @param string $cond The package relation condition string
|
||||||
|
* @param string $arch The package relation architecture
|
||||||
|
*
|
||||||
|
* @return string The HTML code of the label to display
|
||||||
|
*/
|
||||||
|
function pkg_rel_html($name, $cond, $arch) {
|
||||||
|
$html = htmlspecialchars($name) . htmlspecialchars($cond);
|
||||||
|
|
||||||
|
if ($arch) {
|
||||||
|
$html .= ' <em>(' . htmlspecialchars($arch) . ')</em>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine packages that depend on a package
|
* Determine packages that depend on a package
|
||||||
*
|
*
|
||||||
|
@ -749,16 +787,18 @@ function pkg_create($base_id, $pkgname, $pkgver, $pkgdesc, $pkgurl) {
|
||||||
* @param string $type The type of dependency to add
|
* @param string $type The type of dependency to add
|
||||||
* @param string $depname The name of the dependency to add
|
* @param string $depname The name of the dependency to add
|
||||||
* @param string $depcondition The type of dependency for the package
|
* @param string $depcondition The type of dependency for the package
|
||||||
|
* @param string $deparch The architecture of the dependency to add
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function pkg_add_dep($pkgid, $type, $depname, $depcondition) {
|
function pkg_add_dep($pkgid, $type, $depname, $depcondition, $deparch) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
$q = sprintf("INSERT INTO PackageDepends (PackageID, DepTypeID, DepName, DepCondition) VALUES (%d, %d, %s, %s)",
|
$q = sprintf("INSERT INTO PackageDepends (PackageID, DepTypeID, DepName, DepCondition, DepArch) VALUES (%d, %d, %s, %s, %s)",
|
||||||
$pkgid,
|
$pkgid,
|
||||||
pkg_dependency_type_id_from_name($type),
|
pkg_dependency_type_id_from_name($type),
|
||||||
$dbh->quote($depname),
|
$dbh->quote($depname),
|
||||||
$dbh->quote($depcondition)
|
$dbh->quote($depcondition),
|
||||||
|
$deparch ? $dbh->quote($deparch) : 'NULL'
|
||||||
);
|
);
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
}
|
}
|
||||||
|
@ -770,16 +810,18 @@ function pkg_add_dep($pkgid, $type, $depname, $depcondition) {
|
||||||
* @param string $type The type of relation to add
|
* @param string $type The type of relation to add
|
||||||
* @param string $relname The name of the relation to add
|
* @param string $relname The name of the relation to add
|
||||||
* @param string $relcondition The version requirement of the relation
|
* @param string $relcondition The version requirement of the relation
|
||||||
|
* @param string $relarch The architecture of the relation to add
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function pkg_add_rel($pkgid, $type, $relname, $relcondition) {
|
function pkg_add_rel($pkgid, $type, $relname, $relcondition, $relarch) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
$q = sprintf("INSERT INTO PackageRelations (PackageID, RelTypeID, RelName, RelCondition) VALUES (%d, %d, %s, %s)",
|
$q = sprintf("INSERT INTO PackageRelations (PackageID, RelTypeID, RelName, RelCondition, RelArch) VALUES (%d, %d, %s, %s, %s)",
|
||||||
$pkgid,
|
$pkgid,
|
||||||
pkg_relation_type_id_from_name($type),
|
pkg_relation_type_id_from_name($type),
|
||||||
$dbh->quote($relname),
|
$dbh->quote($relname),
|
||||||
$dbh->quote($relcondition)
|
$dbh->quote($relcondition),
|
||||||
|
$relarch ? $dbh->quote($relarch) : 'NULL'
|
||||||
);
|
);
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,16 +30,30 @@ $deps = pkg_dependencies($row["ID"]);
|
||||||
$requiredby = pkg_required($row["Name"]);
|
$requiredby = pkg_required($row["Name"]);
|
||||||
|
|
||||||
usort($deps, function($x, $y) {
|
usort($deps, function($x, $y) {
|
||||||
if ($x[1] == "depends" && $y[1] != "depends") {
|
if ($x[1] != $y[1]) {
|
||||||
return -1;
|
if ($x[1] == "depends") {
|
||||||
|
return -1;
|
||||||
|
} elseif ($y[1] == "depends") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return strcmp($x[1], $y[1]);
|
||||||
|
} elseif ($x[3] != $y[3]) {
|
||||||
|
return strcmp($x[3], $y[3]);
|
||||||
|
} else {
|
||||||
|
return strcmp($x[0], $y[0]);
|
||||||
}
|
}
|
||||||
if ($y[1] == "depends" && $x[1] != "depends") {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return $x[1] == $y[1] ? strcmp($x[0], $y[0]) : strcmp($x[1], $y[1]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$rels = pkg_relations($row["ID"]);
|
$rels = pkg_relations($row["ID"]);
|
||||||
|
|
||||||
|
usort($rels, function($x, $y) {
|
||||||
|
if ($x[3] != $y[3]) {
|
||||||
|
return strcmp($x[3], $y[3]);
|
||||||
|
} else {
|
||||||
|
return strcmp($x[0], $y[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$rels_c = $rels_p = $rels_r = array();
|
$rels_c = $rels_p = $rels_r = array();
|
||||||
foreach ($rels as $rel) {
|
foreach ($rels as $rel) {
|
||||||
switch ($rel[1]) {
|
switch ($rel[1]) {
|
||||||
|
@ -221,9 +235,9 @@ if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
|
||||||
<?php foreach($rels_c as $rarr): ?>
|
<?php foreach($rels_c as $rarr): ?>
|
||||||
<span class="related">
|
<span class="related">
|
||||||
<?php if ($rarr !== end($rels_c)): ?>
|
<?php if ($rarr !== end($rels_c)): ?>
|
||||||
<?= htmlspecialchars($rarr[0] . $rarr[2]) ?>,
|
<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= htmlspecialchars($rarr[0] . $rarr[2]) ?>
|
<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</span>
|
</span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
@ -237,9 +251,9 @@ if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
|
||||||
<?php foreach($rels_p as $rarr): ?>
|
<?php foreach($rels_p as $rarr): ?>
|
||||||
<span class="related">
|
<span class="related">
|
||||||
<?php if ($rarr !== end($rels_p)): ?>
|
<?php if ($rarr !== end($rels_p)): ?>
|
||||||
<?= htmlspecialchars($rarr[0] . $rarr[2]) ?>,
|
<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= htmlspecialchars($rarr[0] . $rarr[2]) ?>
|
<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</span>
|
</span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
@ -253,9 +267,9 @@ if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
|
||||||
<?php foreach($rels_r as $rarr): ?>
|
<?php foreach($rels_r as $rarr): ?>
|
||||||
<span class="related">
|
<span class="related">
|
||||||
<?php if ($rarr !== end($rels_r)): ?>
|
<?php if ($rarr !== end($rels_r)): ?>
|
||||||
<?= htmlspecialchars($rarr[0] . $rarr[2]) ?>,
|
<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= htmlspecialchars($rarr[0] . $rarr[2]) ?>
|
<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</span>
|
</span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
@ -344,7 +358,7 @@ if ($row["PackagerUID"]):
|
||||||
<?php if (count($deps) > 0): ?>
|
<?php if (count($deps) > 0): ?>
|
||||||
<ul id="pkgdepslist">
|
<ul id="pkgdepslist">
|
||||||
<?php while (list($k, $darr) = each($deps)): ?>
|
<?php while (list($k, $darr) = each($deps)): ?>
|
||||||
<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3]); ?></li>
|
<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4]); ?></li>
|
||||||
<?php endwhile; ?>
|
<?php endwhile; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue