[aur-dev] [PATCH 1/4] Add a packager field to packages
Store the last packager in addition to storing the submitter and the maintainer of a package. This allows for checking who last updated a package, even if the package has been disowned. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- UPGRADING | 5 ++++- schema/aur-schema.sql | 5 ++++- web/lib/pkgbasefuncs.inc.php | 15 +++++++++------ web/lib/pkgfuncs.inc.php | 2 +- web/template/pkg_details.php | 19 +++++++++++++++++++ web/template/pkgbase_details.php | 19 +++++++++++++++++++ 6 files changed, 56 insertions(+), 9 deletions(-) diff --git a/UPGRADING b/UPGRADING index 357cd6c..d9860bb 100644 --- a/UPGRADING +++ b/UPGRADING @@ -31,16 +31,19 @@ CREATE TABLE PackageBases ( ModifiedTS BIGINT UNSIGNED NOT NULL, SubmitterUID INTEGER UNSIGNED NULL DEFAULT NULL, MaintainerUID INTEGER UNSIGNED NULL DEFAULT NULL, + PackagerUID INTEGER UNSIGNED NULL DEFAULT NULL, PRIMARY KEY (ID), UNIQUE (Name), INDEX (CategoryID), INDEX (NumVotes), INDEX (SubmitterUID), INDEX (MaintainerUID), + INDEX (PackagerUID), FOREIGN KEY (CategoryID) REFERENCES PackageCategories(ID) ON DELETE NO ACTION, -- deleting a user will cause packages to be orphaned, not deleted FOREIGN KEY (SubmitterUID) REFERENCES Users(ID) ON DELETE SET NULL, - FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE SET NULL + FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE SET NULL, + FOREIGN KEY (PackagerUID) REFERENCES Users(ID) ON DELETE SET NULL ) ENGINE = InnoDB; ---- diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 8533548..adacdf0 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -104,16 +104,19 @@ CREATE TABLE PackageBases ( ModifiedTS BIGINT UNSIGNED NOT NULL, SubmitterUID INTEGER UNSIGNED NULL DEFAULT NULL, -- who submitted it? MaintainerUID INTEGER UNSIGNED NULL DEFAULT NULL, -- User + PackagerUID INTEGER UNSIGNED NULL DEFAULT NULL, -- Last packager PRIMARY KEY (ID), UNIQUE (Name), INDEX (CategoryID), INDEX (NumVotes), INDEX (SubmitterUID), INDEX (MaintainerUID), + INDEX (PackagerUID), FOREIGN KEY (CategoryID) REFERENCES PackageCategories(ID) ON DELETE NO ACTION, -- deleting a user will cause packages to be orphaned, not deleted FOREIGN KEY (SubmitterUID) REFERENCES Users(ID) ON DELETE SET NULL, - FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE SET NULL + FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE SET NULL, + FOREIGN KEY (PackagerUID) REFERENCES Users(ID) ON DELETE SET NULL ) ENGINE = InnoDB; diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 4eaa640..4d05b94 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -182,7 +182,8 @@ function pkgbase_get_details($base_id) { $q.= "PackageBases.CategoryID, PackageBases.NumVotes, "; $q.= "PackageBases.OutOfDateTS, PackageBases.SubmittedTS, "; $q.= "PackageBases.ModifiedTS, PackageBases.SubmitterUID, "; - $q.= "PackageBases.MaintainerUID, PackageCategories.Category "; + $q.= "PackageBases.MaintainerUID, PackageBases.PackagerUID, "; + $q.= "PackageCategories.Category "; $q.= "FROM PackageBases, PackageCategories "; $q.= "WHERE PackageBases.CategoryID = PackageCategories.ID "; $q.= "AND PackageBases.ID = " . intval($base_id); @@ -917,9 +918,10 @@ function pkgbase_change_category($base_id, $atype) { function pkgbase_create($name, $category_id, $uid) { $dbh = DB::connect(); $q = sprintf("INSERT INTO PackageBases (Name, CategoryID, " . - "SubmittedTS, ModifiedTS, SubmitterUID, MaintainerUID) " . - "VALUES (%s, %d, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), %d, %d)", - $dbh->quote($name), $category_id, $uid, $uid); + "SubmittedTS, ModifiedTS, SubmitterUID, MaintainerUID, " . + "PackagerUID) VALUES (%s, %d, UNIX_TIMESTAMP(), " . + "UNIX_TIMESTAMP(), %d, %d, %d)", + $dbh->quote($name), $category_id, $uid, $uid, $uid); $dbh->exec($q); return $dbh->lastInsertId(); } @@ -937,8 +939,9 @@ function pkgbase_update($base_id, $name, $uid) { $dbh = DB::connect(); $q = sprintf("UPDATE PackageBases SET " . "Name = %s, ModifiedTS = UNIX_TIMESTAMP(), " . - "MaintainerUID = %d, OutOfDateTS = NULL WHERE ID = %d", - $dbh->quote($name), $uid, $base_id); + "MaintainerUID = %d, PackagerUID = %d, OutOfDateTS = NULL " . + "WHERE ID = %d", + $dbh->quote($name), $uid, $uid, $base_id); $dbh->exec($q); } diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index a6fa32e..c35147f 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -400,7 +400,7 @@ function pkg_get_details($id=0) { $q.= "PackageBases.NumVotes, PackageBases.OutOfDateTS, "; $q.= "PackageBases.SubmittedTS, PackageBases.ModifiedTS, "; $q.= "PackageBases.SubmitterUID, PackageBases.MaintainerUID, "; - $q.= "PackageCategories.Category "; + $q.= "PackageBases.PackagerUID, PackageCategories.Category "; $q.= "FROM Packages, PackageBases, PackageCategories "; $q.= "WHERE PackageBases.ID = Packages.PackageBaseID "; $q.= "AND PackageBases.CategoryID = PackageCategories.ID "; diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 791c9ee..12aa692 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -9,6 +9,7 @@ $catarr = pkgbase_categories(); $submitter = username_from_id($row["SubmitterUID"]); $maintainer = username_from_id($row["MaintainerUID"]); +$packager = username_from_id($row["PackagerUID"]); $votes = $row['NumVotes']; @@ -289,6 +290,24 @@ if ($row["MaintainerUID"]): <?php endif; ?> </tr> <tr> + <th><?= __('Last Packager') .': ' ?></th> +<?php +if ($row["PackagerUID"]): + if ($SID): + if (!$USE_VIRTUAL_URLS): +?> + <td><a href="<?= get_uri('/account/'); ?>?Action=AccountInfo&ID=<?= htmlspecialchars($row['PackagerUID'], ENT_QUOTES) ?>" title="<?= __('View account information for')?> <?= htmlspecialchars($packager) ?>"><?= htmlspecialchars($packager) ?></a></td> + <?php else: ?> + <td><a href="<?= get_uri('/account/') . htmlspecialchars($packager, ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($packager)) ?>"><?= htmlspecialchars($packager) ?></a></td> + <?php endif; ?> + <?php else: ?> + <td><?= htmlspecialchars($packager) ?></td> + <?php endif; ?> +<?php else: ?> + <td><?= __('None') ?></td> +<?php endif; ?> + </tr> + <tr> <th><?= __('Votes') . ': ' ?></th> <?php if ($atype == "Developer" || $atype == "Trusted User"): ?> <?php if ($USE_VIRTUAL_URLS): ?> diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php index fd7bdad..eab3a53 100644 --- a/web/template/pkgbase_details.php +++ b/web/template/pkgbase_details.php @@ -8,6 +8,7 @@ $catarr = pkgbase_categories(); $submitter = username_from_id($row["SubmitterUID"]); $maintainer = username_from_id($row["MaintainerUID"]); +$packager = username_from_id($row["PackagerUID"]); $votes = $row['NumVotes']; @@ -172,6 +173,24 @@ if ($row["MaintainerUID"]): <?php endif; ?> </tr> <tr> + <th><?= __('Last Packager') .': ' ?></th> +<?php +if ($row["PackagerUID"]): + if ($SID): + if (!$USE_VIRTUAL_URLS): +?> + <td><a href="<?= get_uri('/account/'); ?>?Action=AccountInfo&ID=<?= htmlspecialchars($row['PackagerUID'], ENT_QUOTES) ?>" title="<?= __('View account information for')?> <?= htmlspecialchars($packager) ?>"><?= htmlspecialchars($packager) ?></a></td> + <?php else: ?> + <td><a href="<?= get_uri('/account/') . htmlspecialchars($packager, ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($packager)) ?>"><?= htmlspecialchars($packager) ?></a></td> + <?php endif; ?> + <?php else: ?> + <td><?= htmlspecialchars($packager) ?></td> + <?php endif; ?> +<?php else: ?> + <td><?= __('None') ?></td> +<?php endif; ?> + </tr> + <tr> <th><?= __('Votes') . ': ' ?></th> <?php if ($atype == "Developer" || $atype == "Trusted User"): ?> <?php if ($USE_VIRTUAL_URLS): ?> -- 1.9.2
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgbuild-parser.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/lib/pkgbuild-parser.inc.php b/web/lib/pkgbuild-parser.inc.php index 0bd4cfe..e112a55 100644 --- a/web/lib/pkgbuild-parser.inc.php +++ b/web/lib/pkgbuild-parser.inc.php @@ -1,4 +1,4 @@ -# <?php +<?php if (!$error) { # process PKGBUILD - remove line concatenation # -- 1.9.2
Move some elseif statements to the same line as the closing brace. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/pkgsubmit.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 7b7023b..51d0203 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -90,20 +90,16 @@ if ($uid): if (strchr($tar_file['filename'], '/') === false) { $error = __("Error - source tarball may not contain files outside a directory."); break; - } - elseif (substr($tar_file['filename'], -9) == '/PKGBUILD') { + } elseif (substr($tar_file['filename'], -9) == '/PKGBUILD') { $pkgbuild_raw = $tar->extractInString($tar_file['filename']); - } - elseif (substr($tar_file['filename'], -9) == '/.AURINFO') { + } elseif (substr($tar_file['filename'], -9) == '/.AURINFO') { $srcinfo_raw = $tar->extractInString($tar_file['filename']); } - } - elseif ($tar_file['typeflag'] == 5) { + } elseif ($tar_file['typeflag'] == 5) { if (substr_count($tar_file['filename'], "/") > 1) { $error = __("Error - source tarball may not contain nested subdirectories."); break; - } - elseif (++$dircount > 1) { + } elseif (++$dircount > 1) { $error = __("Error - source tarball may not contain more than one directory."); break; } -- 1.9.2
All files contained in the source tarball must have permissions of 644 or 755. All directories must have permissions of 755. Implements FS#27754. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/pkgsubmit.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 51d0203..f07580b 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -90,6 +90,9 @@ if ($uid): if (strchr($tar_file['filename'], '/') === false) { $error = __("Error - source tarball may not contain files outside a directory."); break; + } elseif ($tar_file['mode'] != 0644 && $tar_file['mode'] != 0755) { + $error = __("Error - all files must have permissions of 644 or 755."); + break; } elseif (substr($tar_file['filename'], -9) == '/PKGBUILD') { $pkgbuild_raw = $tar->extractInString($tar_file['filename']); } elseif (substr($tar_file['filename'], -9) == '/.AURINFO') { @@ -102,6 +105,9 @@ if ($uid): } elseif (++$dircount > 1) { $error = __("Error - source tarball may not contain more than one directory."); break; + } elseif ($tar_file['mode'] != 0755) { + $error = __("Error - all directories must have permissions of 755."); + break; } } } -- 1.9.2
participants (1)
-
Lukas Fleischer