Commit d273ee5e authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

Use the official provider list to detect duplicates



Instead of automatically adding packages from the official binary
repositories to the package blacklist, use the official provider list to
prevent users from uploading duplicates.

This does not only result in reduced disk usage but also has a nice
visible side effect. The error messages printed by the update hook now
look like

    error: package already provided by [community]: powerline-fonts

instead of

    error: package is blacklisted: powerline-fonts

which was confusing to most end users.
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent b2e97cdd
......@@ -331,12 +331,18 @@ pkgbase_id = cur.fetchone()[0] if cur.rowcount == 1 else 0
cur.execute("SELECT Name FROM PackageBlacklist")
blacklist = [row[0] for row in cur.fetchall()]
cur.execute("SELECT Name, Repo FROM OfficialProviders")
providers = dict(cur.fetchall())
for pkgname in srcinfo.utils.get_package_names(metadata):
pkginfo = srcinfo.utils.get_merged_package(pkgname, metadata)
pkgname = pkginfo['pkgname']
if pkgname in blacklist and not privileged:
die('package is blacklisted: {:s}'.format(pkgname))
if pkgname in providers and not privileged:
repo = providers[pkgname]
die('package already provided by [{:s}]: {:s}'.format(repo, pkgname))
cur.execute("SELECT COUNT(*) FROM Packages WHERE Name = %s AND " +
"PackageBaseID <> %s", [pkgname, pkgbase_id])
......
......@@ -45,14 +45,6 @@ db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
unix_socket=aur_db_socket, buffered=True)
cur = db.cursor()
cur.execute("SELECT Name FROM PackageBlacklist")
oldblacklist = set([row[0] for row in cur.fetchall()])
for pkg in blacklist.difference(oldblacklist):
cur.execute("INSERT INTO PackageBlacklist (Name) VALUES (%s)", [pkg])
for pkg in oldblacklist.difference(blacklist):
cur.execute("DELETE FROM PackageBlacklist WHERE Name = %s", [pkg])
cur.execute("SELECT Name, Provides FROM OfficialProviders")
oldproviders = set(cur.fetchall())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment