[aur-dev] [PATCH] Notify package maintainers about deleted dependencies (FS#10372).
Lukas Fleischer
archlinux at cryptocrack.de
Fri Mar 11 10:55:11 EST 2011
Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
While upgrading our database to InnoDB, I noticed that there are missing
dependencies in the package details view for some packages. This happens
when some dependency of a package gets deleted as we recently added an
"ON DELETE CASCADE" foreign key on package IDs to the "PackageDepends"
table (the problem already existed before, tho). While thinking about a
proper fix, it reminded me of FS#10372 which is related and would seem
to me to be kinda useful.
Reviews and comments welcome!
web/lib/pkgfuncs.inc | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index d5e0771..bfa3e1f 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -709,6 +709,35 @@ function pkg_delete ($atype, $ids) {
}
$dbh = db_connect();
+
+ # Notify of deleted dependencies.
+ $f_name = username_from_sid($_COOKIE['AURSID']);
+ $f_uid = uid_from_sid($_COOKIE['AURSID']);
+ $q = "SELECT Users.Email, DepPkgs.ID, DepPkgs.Name, ";
+ $q .= "GROUP_CONCAT(Packages.Name SEPARATOR ', ') AS DepList ";
+ $q .= "FROM Packages ";
+ $q .= "LEFT JOIN PackageDepends ON PackageDepends.DepPkgId = Packages.ID ";
+ $q .= "LEFT JOIN Packages DepPkgs ON DepPkgs.ID = PackageDepends.PackageID ";
+ $q .= "LEFT JOIN Users ON Users.ID = DepPkgs.MaintainerUID ";
+ $q .= "WHERE Packages.ID IN (" . implode(",", $ids) . ") ";
+ $q .= "GROUP BY DepPkgs.ID;";
+ $result = db_query($q, $dbh);
+ if (mysql_num_rows($result)) {
+ while ($row = mysql_fetch_assoc($result)) {
+ # construct email
+ $body = "The following dependencies of your package " . $row['Name'] . " [1] ";
+ $body .= "have been removed by " . $f_name . " [1]: " . $row['DepList'] . ".\n\n";
+ $body .= "Please check if the \"depends\" array of your PKGBUILD needs to be updated ";
+ $body .= "(shouldn't be necessary if a package was moved to the official repos) ";
+ $body .= "and re-upload your package.\n\n";
+ $body .= "[1] http://aur.archlinux.org/packages.php?ID=" . $row['ID'] . "\n";
+ $body .= "[2] http://aur.archlinux.org/account.php?Action=AccountInfo&ID=" . $f_uid;
+ $body = wordwrap($body, 70);
+ $headers = "Reply-to: nobody at archlinux.org\nFrom:aur-notify at archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
+ @mail($row['Email'], "AUR Dependency Removal Notification for " . $row['Name'], $body, $headers);
+ }
+ }
+
$q = "DELETE FROM Packages WHERE ID IN (" . implode(",", $ids) . ")";
$result = db_query($q, $dbh);
--
1.7.4.1
More information about the aur-dev
mailing list