[aur-dev] [PATCH 1/2] Add repository information to official providers
When updating the list of packages provided by the official repositories, also save the repository names. --- schema/aur-schema.sql | 1 + scripts/aurblup.py | 8 ++++++-- upgrading/4.3.0.txt | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 upgrading/4.3.0.txt diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index aa5ed9d..ee58a52 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -310,6 +310,7 @@ CREATE TABLE PackageBlacklist ( CREATE TABLE OfficialProviders ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(64) NOT NULL, + Repo VARCHAR(64) NOT NULL, Provides VARCHAR(64) NOT NULL, PRIMARY KEY (ID) ) ENGINE = InnoDB; diff --git a/scripts/aurblup.py b/scripts/aurblup.py index 325ef3d..9e11e43 100755 --- a/scripts/aurblup.py +++ b/scripts/aurblup.py @@ -20,6 +20,7 @@ servers = config.get('aurblup', 'servers').split(' ') blacklist = set() providers = set() +repomap = dict() h = pyalpm.Handle("/", db_path) for sync_db in sync_dbs: @@ -33,9 +34,11 @@ for sync_db in sync_dbs: blacklist.add(pkg.name) [blacklist.add(x) for x in pkg.replaces] providers.add((pkg.name, pkg.name)) + repomap[(pkg.name, pkg.name)] = repo.name for provision in pkg.provides: provisionname = re.sub(r'(<|=|>).*', '', provision) providers.add((pkg.name, provisionname)) + repomap[(pkg.name, provisionname)] = repo.name db = mysql.connector.connect(host=aur_db_host, user=aur_db_user, passwd=aur_db_pass, db=aur_db_name, @@ -54,8 +57,9 @@ cur.execute("SELECT Name, Provides FROM OfficialProviders") oldproviders = set(cur.fetchall()) for pkg, provides in providers.difference(oldproviders): - cur.execute("INSERT INTO OfficialProviders (Name, Provides) " - "VALUES (%s, %s)", [pkg, provides]) + repo = repomap[(pkg, provides)] + cur.execute("INSERT INTO OfficialProviders (Name, Repo, Provides) " + "VALUES (%s, %s, %s)", [pkg, repo, provides]) for pkg, provides in oldproviders.difference(providers): cur.execute("DELETE FROM OfficialProviders " "WHERE Name = %s AND Provides = %s", [pkg, provides]) diff --git a/upgrading/4.3.0.txt b/upgrading/4.3.0.txt new file mode 100644 index 0000000..b4d299f --- /dev/null +++ b/upgrading/4.3.0.txt @@ -0,0 +1,5 @@ +1. Add a new column to store repository information of official providers: + +---- +ALTER TABLE OfficialProviders ADD COLUMN Repo VARCHAR(64) NOT NULL; +---- -- 2.8.2
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 <lfleischer@archlinux.org> --- git-interface/git-update.py | 6 ++++++ scripts/aurblup.py | 8 -------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/git-interface/git-update.py b/git-interface/git-update.py index e54e0e6..2c24e72 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -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]) diff --git a/scripts/aurblup.py b/scripts/aurblup.py index 9e11e43..6733b45 100755 --- a/scripts/aurblup.py +++ b/scripts/aurblup.py @@ -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()) -- 2.8.2
participants (1)
-
Lukas Fleischer