summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--po/aur.pot7
-rw-r--r--schema/aur-schema.sql3
-rw-r--r--scripts/config.proto5
-rwxr-xr-xscripts/mkpkglists.py38
-rw-r--r--upgrading/3.5.0.txt7
-rw-r--r--web/html/index.php14
-rw-r--r--web/html/pkgsubmit.php39
-rw-r--r--web/lib/pkgfuncs.inc.php112
-rw-r--r--web/template/pkg_details.php62
9 files changed, 222 insertions, 65 deletions
diff --git a/po/aur.pot b/po/aur.pot
index d3514be..0f043f3 100644
--- a/po/aur.pot
+++ b/po/aur.pot
@@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: AUR v3.4.1\n"
+"Project-Id-Version: AUR v3.4.3\n"
"Report-Msgid-Bugs-To: https://bugs.archlinux.org/index.php?project=2\n"
-"POT-Creation-Date: 2014-07-29 18:33+0200\n"
+"POT-Creation-Date: 2014-08-11 22:50+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -699,6 +699,9 @@ msgstr ""
msgid "View packages details for"
msgstr ""
+msgid "You must be logged in to file package requests."
+msgstr ""
+
msgid "The comment field must not be empty."
msgstr ""
diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql
index 0ec4f75..08f87d8 100644
--- a/schema/aur-schema.sql
+++ b/schema/aur-schema.sql
@@ -198,6 +198,7 @@ CREATE TABLE PackageDepends (
DepTypeID TINYINT UNSIGNED NOT NULL,
DepName VARCHAR(255) NOT NULL,
DepCondition VARCHAR(255),
+ DepArch VARCHAR(255) NULL DEFAULT NULL,
INDEX (PackageID),
INDEX (DepName),
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
@@ -224,6 +225,7 @@ CREATE TABLE PackageRelations (
RelTypeID TINYINT UNSIGNED NOT NULL,
RelName VARCHAR(255) NOT NULL,
RelCondition VARCHAR(255),
+ RelArch VARCHAR(255) NULL DEFAULT NULL,
INDEX (PackageID),
INDEX (RelName),
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
@@ -236,6 +238,7 @@ CREATE TABLE PackageRelations (
CREATE TABLE PackageSources (
PackageID INTEGER UNSIGNED NOT NULL,
Source VARCHAR(255) NOT NULL DEFAULT "/dev/null",
+ SourceArch VARCHAR(255) NULL DEFAULT NULL,
INDEX (PackageID),
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE
) ENGINE = InnoDB;
diff --git a/scripts/config.proto b/scripts/config.proto
new file mode 100644
index 0000000..4cac94f
--- /dev/null
+++ b/scripts/config.proto
@@ -0,0 +1,5 @@
+[database]
+host = localhost
+name = AUR
+user = aur
+password = aur
diff --git a/scripts/mkpkglists.py b/scripts/mkpkglists.py
new file mode 100755
index 0000000..c208fd1
--- /dev/null
+++ b/scripts/mkpkglists.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python3
+
+import configparser
+import datetime
+import gzip
+import mysql.connector
+import os
+
+docroot = os.path.dirname(os.path.realpath(__file__)) + "/../web/html/"
+
+config = configparser.RawConfigParser()
+config.read(os.path.dirname(os.path.realpath(__file__)) + "/config")
+
+aur_db_host = config.get('database', 'host')
+aur_db_name = config.get('database', 'name')
+aur_db_user = config.get('database', 'user')
+aur_db_pass = config.get('database', 'password')
+
+db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
+ passwd=aur_db_pass, db=aur_db_name,
+ buffered=True)
+cur = db.cursor()
+
+datestr = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
+pkglist_header = "# AUR package list, generated on " + datestr
+pkgbaselist_header = "# AUR package base list, generated on " + datestr
+
+with gzip.open(docroot + "packages.gz", "w") as f:
+ f.write(bytes(pkglist_header + "\n", "UTF-8"))
+ cur.execute("SELECT Name FROM Packages")
+ f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()])
+
+with gzip.open(docroot + "pkgbase.gz", "w") as f:
+ f.write(bytes(pkgbaselist_header + "\n", "UTF-8"))
+ cur.execute("SELECT Name FROM PackageBases")
+ f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()])
+
+db.close()
diff --git a/upgrading/3.5.0.txt b/upgrading/3.5.0.txt
new file mode 100644
index 0000000..152fc84
--- /dev/null
+++ b/upgrading/3.5.0.txt
@@ -0,0 +1,7 @@
+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;
+ALTER TABLE PackageSources ADD COLUMN SourceArch VARCHAR(255) NULL DEFAULT NULL;
+----
diff --git a/web/html/index.php b/web/html/index.php
index e05b555..95989f5 100644
--- a/web/html/index.php
+++ b/web/html/index.php
@@ -143,12 +143,12 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
case "/css/aur.css":
case "/css/archnavbar/archnavbar.css":
header("Content-Type: text/css");
- include "./$path";
+ readfile("./$path");
break;
case "/css/archnavbar/archlogo.gif":
case "/images/new.png":
header("Content-Type: image/png");
- include "./$path";
+ readfile("./$path");
break;
case "/css/archnavbar/archlogo.png":
case "/images/AUR-logo-80.png":
@@ -158,11 +158,17 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
case "/images/titlelogo.png":
case "/images/x.png":
header("Content-Type: image/png");
- include "./$path";
+ readfile("./$path");
break;
case "/js/bootstrap-typeahead.min.js":
header("Content-Type: application/javascript");
- include "./$path";
+ readfile("./$path");
+ break;
+ case "/packages.gz":
+ case "/pkgbase.gz":
+ header("Content-Type: text/plain");
+ header("Content-Encoding: gzip");
+ readfile("./$path");
break;
default:
header("HTTP/1.0 404 Not Found");
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index a11fb5b..8cecd67 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -137,6 +137,13 @@ if ($uid):
continue;
}
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) {
case 'pkgbase':
case 'pkgname':
@@ -169,7 +176,8 @@ if ($uid):
break;
case 'license':
case 'groups':
- case 'source':
+ $section_info[$key][] = $value;
+ break;
case 'depends':
case 'makedepends':
case 'checkdepends':
@@ -177,7 +185,8 @@ if ($uid):
case 'conflicts':
case 'provides':
case 'replaces':
- $section_info[$key][] = $value;
+ case 'source':
+ $section_info[$key][$arch][] = $value;
break;
}
}
@@ -354,23 +363,29 @@ if ($uid):
}
foreach (array('depends', 'makedepends', 'checkdepends', 'optdepends') as $deptype) {
- foreach ($pi[$deptype] as $dep) {
- $deppkgname = preg_replace("/(<|=|>).*/", "", $dep);
- $depcondition = str_replace($deppkgname, "", $dep);
- pkg_add_dep($pkgid, $deptype, $deppkgname, $depcondition);
+ foreach ($pi[$deptype] as $deparch => $depgrp) {
+ foreach ($depgrp as $dep) {
+ $deppkgname = preg_replace("/(<|=|>).*/", "", $dep);
+ $depcondition = str_replace($deppkgname, "", $dep);
+ pkg_add_dep($pkgid, $deptype, $deppkgname, $depcondition, $deparch);
+ }
}
}
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[$reltype] as $relarch => $relgrp) {
+ foreach ($relgrp as $rel) {
+ $relpkgname = preg_replace("/(<|=|>).*/", "", $rel);
+ $relcondition = str_replace($relpkgname, "", $rel);
+ pkg_add_rel($pkgid, $reltype, $relpkgname, $relcondition, $relarch);
+ }
}
}
- foreach ($pi['source'] as $src) {
- pkg_add_src($pkgid, $src);
+ foreach ($pi['source'] as $srcarch => $srcgrp) {
+ foreach ($srcgrp as $src) {
+ pkg_add_src($pkgid, $src, $srcarch);
+ }
}
}
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index defe7f4..cf8c2f9 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -138,7 +138,7 @@ function pkg_dependencies($pkgid) {
$pkgid = intval($pkgid);
if ($pkgid > 0) {
$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.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) = p.Name ";
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
@@ -167,7 +167,7 @@ function pkg_relations($pkgid) {
$pkgid = intval($pkgid);
if ($pkgid > 0) {
$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 RelationTypes rt ON rt.ID = pr.RelTypeID ";
$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 $type The name of the dependency type
* @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
*
* @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) {
$tokens = explode(':', $name, 2);
$name = $tokens[0];
@@ -242,12 +243,74 @@ function pkg_depend_link($name, $type, $cond, $pkg_id) {
$link .= htmlspecialchars($name) . '</a>';
$link .= htmlspecialchars($cond);
- if ($type == 'makedepends') {
- $link .= ' <em>(make)</em>';
- } elseif ($type == 'checkdepends') {
- $link .= ' <em>(check)</em>';
- } elseif ($type == 'optdepends') {
- $link .= ' <em>(optional) &ndash; ' . htmlspecialchars($desc) . ' </em>';
+ if ($type != 'depends' || $arch) {
+ $link .= ' <em>(';
+
+ if ($type == 'makedepends') {
+ $link .= 'make';
+ } 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 .= ' &ndash; ' . htmlspecialchars($desc) . ' </em>';
+ }
+ $link .= '</em>';
+ }
+
+ 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;
+}
+
+/**
+ * Get the HTML code to display a source link
+ *
+ * @param string $url The URL of the source
+ * @param string $arch The source architecture
+ *
+ * @return string The HTML code of the label to display
+ */
+function pkg_source_link($url, $arch) {
+ $url = explode('::', $url);
+ $parsed_url = parse_url($url[0]);
+
+ if (isset($parsed_url['scheme']) || isset($url[1])) {
+ $link = '<a href="' . htmlspecialchars((isset($url[1]) ? $url[1] : $url[0]), ENT_QUOTES) . '">' . htmlspecialchars($url[0]) . '</a>';
+ } else {
+ $link = htmlspecialchars($url[0]);
+ }
+
+ if ($arch) {
+ $link .= ' <em>(' . htmlspecialchars($arch) . ')</em>';
}
return $link;
@@ -289,7 +352,7 @@ function pkg_sources($pkgid) {
$pkgid = intval($pkgid);
if ($pkgid > 0) {
$dbh = DB::connect();
- $q = "SELECT Source FROM PackageSources ";
+ $q = "SELECT Source, SourceArch FROM PackageSources ";
$q.= "WHERE PackageID = " . $pkgid;
$q.= " ORDER BY Source";
$result = $dbh->query($q);
@@ -297,7 +360,7 @@ function pkg_sources($pkgid) {
return array();
}
while ($row = $result->fetch(PDO::FETCH_NUM)) {
- $sources[] = $row[0];
+ $sources[] = $row;
}
}
return $sources;
@@ -749,16 +812,18 @@ function pkg_create($base_id, $pkgname, $pkgver, $pkgdesc, $pkgurl) {
* @param string $type The type of 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 $deparch The architecture of the dependency to add
*
* @return void
*/
-function pkg_add_dep($pkgid, $type, $depname, $depcondition) {
+function pkg_add_dep($pkgid, $type, $depname, $depcondition, $deparch) {
$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,
pkg_dependency_type_id_from_name($type),
$dbh->quote($depname),
- $dbh->quote($depcondition)
+ $dbh->quote($depcondition),
+ $deparch ? $dbh->quote($deparch) : 'NULL'
);
$dbh->exec($q);
}
@@ -770,16 +835,18 @@ function pkg_add_dep($pkgid, $type, $depname, $depcondition) {
* @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
+ * @param string $relarch The architecture of the relation to add
*
* @return void
*/
-function pkg_add_rel($pkgid, $type, $relname, $relcondition) {
+function pkg_add_rel($pkgid, $type, $relname, $relcondition, $relarch) {
$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,
pkg_relation_type_id_from_name($type),
$dbh->quote($relname),
- $dbh->quote($relcondition)
+ $dbh->quote($relcondition),
+ $relarch ? $dbh->quote($relarch) : 'NULL'
);
$dbh->exec($q);
}
@@ -789,14 +856,17 @@ function pkg_add_rel($pkgid, $type, $relname, $relcondition) {
*
* @param int $pkgid The package ID to add the source for
* @param string $pkgsrc The package source to add to the database
+ * @param string $srcarch The architecture of the source to add
*
* @return void
*/
-function pkg_add_src($pkgid, $pkgsrc) {
+function pkg_add_src($pkgid, $pkgsrc, $srcarch) {
$dbh = DB::connect();
- $q = "INSERT INTO PackageSources (PackageID, Source) VALUES (";
- $q .= $pkgid . ", " . $dbh->quote($pkgsrc) . ")";
-
+ $q = sprintf("INSERT INTO PackageSources (PackageID, Source, SourceArch) VALUES (%d, %s, %s)",
+ $pkgid,
+ $dbh->quote($pkgsrc),
+ $srcarch ? $dbh->quote($srcarch) : 'NULL'
+ );
$dbh->exec($q);
}
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 7f01d2f..d09b3d8 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -29,7 +29,31 @@ $grps = pkg_groups($row["ID"]);
$deps = pkg_dependencies($row["ID"]);
$requiredby = pkg_required($row["Name"]);
+usort($deps, function($x, $y) {
+ if ($x[1] != $y[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]);
+ }
+});
+
$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();
foreach ($rels as $rel) {
switch ($rel[1]) {
@@ -211,9 +235,9 @@ if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
<?php foreach($rels_c as $rarr): ?>
<span class="related">
<?php if ($rarr !== end($rels_c)): ?>
- <?= htmlspecialchars($rarr[0] . $rarr[2]) ?>,
+ <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
<?php else: ?>
- <?= htmlspecialchars($rarr[0] . $rarr[2]) ?>
+ <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
<?php endif; ?>
</span>
<?php endforeach; ?>
@@ -227,9 +251,9 @@ if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
<?php foreach($rels_p as $rarr): ?>
<span class="related">
<?php if ($rarr !== end($rels_p)): ?>
- <?= htmlspecialchars($rarr[0] . $rarr[2]) ?>,
+ <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
<?php else: ?>
- <?= htmlspecialchars($rarr[0] . $rarr[2]) ?>
+ <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
<?php endif; ?>
</span>
<?php endforeach; ?>
@@ -243,9 +267,9 @@ if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
<?php foreach($rels_r as $rarr): ?>
<span class="related">
<?php if ($rarr !== end($rels_r)): ?>
- <?= htmlspecialchars($rarr[0] . $rarr[2]) ?>,
+ <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
<?php else: ?>
- <?= htmlspecialchars($rarr[0] . $rarr[2]) ?>
+ <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
<?php endif; ?>
</span>
<?php endforeach; ?>
@@ -334,7 +358,7 @@ if ($row["PackagerUID"]):
<?php if (count($deps) > 0): ?>
<ul id="pkgdepslist">
<?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; ?>
</ul>
<?php endif; ?>
@@ -355,28 +379,14 @@ if ($row["PackagerUID"]):
<div id="pkgfiles" class="listing">
<h3><?= __('Sources') ?></h3>
</div>
-<?php if (count($sources) > 0): ?>
+ <?php if (count($sources) > 0): ?>
<div>
<ul id="pkgsrcslist">
-<?php
- while (list($k, $src) = each($sources)):
- $src = explode('::', $src);
- $parsed_url = parse_url($src[0]);
-
- # It is an external source
- if (isset($parsed_url['scheme']) || isset($src[1])):
-?>
- <li><a href="<?= htmlspecialchars((isset($src[1]) ? $src[1] : $src[0]), ENT_QUOTES) ?>"><?= htmlspecialchars($src[0]) ?> </a></li>
-<?php
- else:
- # It is presumably an internal source
- $src = $src[0];
-?>
- <li><?= htmlspecialchars($src) ?></li>
- <?php endif; ?>
- <?php endwhile; ?>
+ <?php while (list($k, $src) = each($sources)): ?>
+ <li><?= pkg_source_link($src[0], $src[1]) ?></li>
+ <?php endwhile; ?>
</ul>
</div>
-<?php endif; ?>
+ <?php endif; ?>
</div>
</div>