summaryrefslogtreecommitdiff
path: root/feeds/feed.php
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-02-11 09:28:26 +0100
committerErich Eckner <git@eckner.net>2019-02-11 09:28:26 +0100
commit8906da52848b6c6d0e42e3d8689f17be64dbe57b (patch)
tree570cce83e14d2f56ec4b95fe3f09972870f758d6 /feeds/feed.php
parent46119ca22fcd4bc1693e2dc1bd83628bfe95981c (diff)
downloadarchweb32-8906da52848b6c6d0e42e3d8689f17be64dbe57b.tar.xz
feeds/feed.php: some working state
Diffstat (limited to 'feeds/feed.php')
-rw-r--r--feeds/feed.php93
1 files changed, 75 insertions, 18 deletions
diff --git a/feeds/feed.php b/feeds/feed.php
index 1176eb4..cb6fd47 100644
--- a/feeds/feed.php
+++ b/feeds/feed.php
@@ -50,45 +50,87 @@ if ($uri_parts[0] == 'packages') {
if (count($uri_parts) > 0 && array_key_exists($uri_parts[0], $actions)) {
$action = $uri_parts[0];
- array_splice(
- $uri_parts,
- 0, 1
- );
+ $action_filter = 'unimplemented';
+ array_splice(
+ $uri_parts,
+ 0, 1
+ );
}
- else
+ else {
$action = '';
+ $action_filter = '`repositories`.`is_on_master_mirror`';
+ }
if (count($uri_parts) > 0) {
if (!array_key_exists($uri_parts[0], $archs))
throw_http_error(501, "Not Implemented", implode('/',$uri_parts));
$arch = $uri_parts[0];
+ $arch_filter = ' AND `r_a`.`name`="' . $arch . '"';
array_splice(
$uri_parts,
0, 1
);
}
- else
+ else {
$arch = '';
+ $arch_filter = '';
+ }
if (count($uri_parts) > 0) {
if (!array_key_exists($uri_parts[0], $repos))
throw_http_error(501, "Not Implemented", implode('/',$uri_parts));
$repo = $uri_parts[0];
+ $repo_filter = ' AND `repositories`.`name`="' . $repo . '"';
array_splice(
$uri_parts,
0, 1
);
}
- else
+ else {
$repo = '';
+ $repo_filter = '';
+ }
if (count($uri_parts) != 0)
throw_http_error(501, "Not Implemented", implode('/',$uri_parts));
-# $result = mysql_run_query(
-# TODO
-# );
+ $result = mysql_run_query(
+ "SELECT MAX(`build_assignments`.`return_date`) AS `max_build_date`" .
+ " FROM `build_assignments`" .
+ mysql_join_build_assignments_binary_packages() .
+ mysql_join_binary_packages_binary_packages_in_repositories() .
+ mysql_join_binary_packages_in_repositories_repositories() .
+ mysql_join_repositories_architectures("", "r_a") .
+ " WHERE " . $action_filter . $repo_filter . $arch_filter
+ );
+ $max_build_date = $result -> fetch_assoc();
+ $max_build_date = $max_build_date['max_build_date'];
+
+ $result = mysql_run_query(
+ "SELECT `binary_packages`.`pkgname`," .
+ "`binary_packages`.`epoch`," .
+ "`binary_packages`.`pkgver`," .
+ "`binary_packages`.`pkgrel`," .
+ "`binary_packages`.`sub_pkgrel`," .
+ "`binary_packages`.`sub_pkgrel_omitted`," .
+ "`architectures`.`name` AS `architecture`," .
+ "`repositories`.`name` AS `repo`," .
+ "`r_a`.`name` AS `r_a`," .
+ "`binary_packages_in_repositories`.`last_moved`" .
+ " FROM `binary_packages`" .
+ mysql_join_binary_packages_binary_packages_in_repositories() .
+ mysql_join_binary_packages_in_repositories_repositories() .
+ mysql_join_repositories_architectures("", "r_a") .
+ mysql_join_binary_packages_architectures() .
+ " WHERE " . $action_filter . $repo_filter . $arch_filter .
+ " ORDER BY `binary_packages_in_repositories`.`last_moved` DESC" .
+ " LIMIT 50"
+ );
+ $packages = array();
+ while ($row = $result -> fetch_assoc())
+ $packages[] = $row;
+ print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
print "<rss version=\"2.0\">";
print "<channel>";
print "<title>";
@@ -112,7 +154,7 @@ if ($uri_parts[0] == 'packages') {
print ")";
print "</title>";
print "<link>";
- print "https://archlinux32.org/packages/";
+ print "https://www.archlinux32.org/packages/";
print "</link>";
print "<description>";
switch ($action) {
@@ -127,32 +169,47 @@ if ($uri_parts[0] == 'packages') {
break;
}
if ($arch != 'all')
- print " for the " . $arch . " architecture (including 'any' packages)";
+ print " for the '" . $arch . "' architecture (including 'any' packages)";
else
print " for all architectures";
if ($repo != '')
- print " for the " . $repo . " repository";
+ print " in the [" . $repo . "] repository";
+ print ".";
print "</description>";
- print "<atom:link href=\"https://archlinux32.org" . $_SERVER['REQUEST_URI'] . "\" rel=\"self\">";
- print "</link>";
+ print "<atom:link href=\"https://www.archlinux32.org" . $_SERVER['REQUEST_URI'] . "\" rel=\"self\">";
+ print "</atom:link>";
print "<language>";
print "en-us";
print "</language>";
print "<lastBuildDate>";
-# TODO
+ print $max_build_date;
print "</lastBuildDate>";
foreach ($packages as $package) {
print "<item>";
print "<title>";
print $package['pkgname'];
- if (array_key_exists('epoch',$package))
+ if ($package['epoch'] != 0)
print $package['epoch'] . ":";
print $package['pkgver'] . "-" . $package['pkgrel'];
if (!$package['sub_pkgrel_omitted'])
print '.' . $package['sub_pkgrel'];
print ' ' . $package['architecture'];
print "</title>";
-# TODO
+ print "<link>";
+ print "https://www.archlinux32.org/packages/" . $package['repo'] . "/" . $package['r_a'] . "/" . $package['pkgname'] . "/";
+ print "</link>";
+// TODO: description
+ print "<pubDate>";
+ print $package['last_moved'];
+ print "</pubDate>";
+// TODO: guid
+ print "<category>";
+ print $package['repo'];
+ print "</category>";
+ print "<category>";
+ print $package['r_a'];
+ print "</category>";
+// TODO: all the rest
print "</item>";
}
print "</channel>";