### Install Translations with Make Source: https://github.com/archlinux/aurweb/blob/master/upgrading/1.9.1.txt Run this command in the 'po/' directory to install translations after merging configuration files. ```bash make install ``` -------------------------------- ### pkgname.json Structure Example Source: https://github.com/archlinux/aurweb/blob/master/doc/repos/metadata-repo.md An example of the JSON structure for pkgname.json, containing metadata for individual packages. ```json { "pkg1": { "CheckDepends": [], # Only included if a check dependency exists "Conflicts": [], # Only included if a conflict exists "Depends": [], # Only included if a dependency exists "Description": "some description", "Groups": [], # Only included if a group exists "ID": 1, "Keywords": [], "License": [], "MakeDepends": [], # Only included if a make dependency exists "Name": "pkg1", "OptDepends": [], # Only included if an opt dependency exists "PackageBase": "pkgbase1", "Provides": [], # Only included if `provides` is defined "Replaces": [], # Only included if `replaces` is defined "URL": "https://some_url.com", "Version": "1.0-1" }, ... } ``` -------------------------------- ### pkgbase.json Structure Example Source: https://github.com/archlinux/aurweb/blob/master/doc/repos/metadata-repo.md An example of the JSON structure for pkgbase.json, containing metadata for package bases. ```json { "pkgbase1": { "FirstSubmitted": 123456, "ID": 1, "LastModified": 123456, "Maintainer": "kevr", "OutOfDate": null, "URLPath": "/cgit/aur.git/snapshot/pkgbase1.tar.gz", "NumVotes": 1, "Popularity": 1.0, "PopularityUpdated": 12345567753.0 }, ... } ``` -------------------------------- ### Start Aurweb Services Source: https://github.com/archlinux/aurweb/blob/master/docker/README.md Bring up the initial Aurweb cluster. Subsequent runs should use 'start' instead of 'up'. ```sh docker compose up ``` -------------------------------- ### Install Aurweb Dependencies Source: https://github.com/archlinux/aurweb/blob/master/test/README.md Install all necessary project dependencies using Poetry. This command should be run from the project root. ```bash $ poetry install ``` -------------------------------- ### Install Pre-commit Git Hook Source: https://github.com/archlinux/aurweb/blob/master/CONTRIBUTING.md Install the pre-commit package and run this command to automatically format code before committing. ```bash pre-commit install ``` -------------------------------- ### Example Pkgbase JSON Structure Source: https://github.com/archlinux/aurweb/blob/master/doc/repos/pkgbases-repo.md Illustrates the expected format of the `pkgbase.json` file, which is a simple JSON array of strings. ```json [ "pkgbase1", "pkgbase2", ... ] ``` -------------------------------- ### AUR RPC JSONP Example Source: https://context7.com/archlinux/aurweb/llms.txt Demonstrates how to use JSONP for cross-domain requests, specifying a callback function. ```bash curl "https://aur.archlinux.org/rpc?v=5&type=info&arg=yay&callback=myFunc" ``` -------------------------------- ### Install Keycloak on Arch Linux Source: https://github.com/archlinux/aurweb/blob/master/doc/sso.txt Use pacman to install Keycloak from the official Arch repositories. Ensure Keycloak is not running before proceeding with configuration changes. ```bash # pacman -S keycloak ``` -------------------------------- ### Build and Install aurblup Utility Source: https://github.com/archlinux/aurweb/blob/master/upgrading/1.8.0.txt Optional steps to build and install the 'aurblup' helper utility. This utility prevents users from uploading source packages with names that conflict with predefined binary repositories. It involves navigating to the script directory, configuring, and installing. ```bash cd scripts/aurblup/ make config.h $EDITOR config.h make install # as root ``` -------------------------------- ### Start Docker Services Source: https://github.com/archlinux/aurweb/blob/master/CONTRIBUTING.md Start all necessary services for the aurweb application in detached mode, exposing the nginx service. ```bash docker-compose up -d nginx ``` -------------------------------- ### Start Docker Service Source: https://github.com/archlinux/aurweb/blob/master/docker/README.md Ensure the Docker service is running before proceeding with other Docker commands. ```sh systemctl start docker.service ``` -------------------------------- ### AUR RPC v5 Multi-info Lookup (GET) Source: https://context7.com/archlinux/aurweb/llms.txt Retrieves detailed information for multiple packages using the v5 API via GET request. ```bash curl "https://aur.archlinux.org/rpc/v5/info?arg[]=yay&arg[]=paru" ``` -------------------------------- ### Multi-Info Request (POST Experimental) Source: https://github.com/archlinux/aurweb/blob/master/doc/rpc.txt An experimental POST method for retrieving multi-package information, with different argument parsing compared to GET. ```APIDOC ## Multi-Info Request (POST Experimental) ### Description An experimental POST request for retrieving information about multiple packages. The argument parsing differs from the GET method. ### Method POST ### Endpoint /rpc ### Parameters #### Request Body - **v** (integer) - Required - API version, currently 5. - **type** (string) - Required - Must be `info`. - **arg** (string) - Optional - A single package name. - **arg[]** (string) - Optional - A package name. Can be specified multiple times. ### Request Example ``` curl -d 'v=5' -d 'type=info' -d 'arg=one' -d 'arg[]=two' -d 'arg[]=three' ... ``` ### Response #### Success Response (200) Returns detailed information for the requested packages. ``` -------------------------------- ### Generate Dummy Data for Aurweb Source: https://github.com/archlinux/aurweb/blob/master/docker/README.md Steps to generate dummy data for Aurweb queries. This involves entering the Fast API container, installing packages, running a script, and importing data into MariaDB. ```sh docker compose exec fastapi /bin/bash ``` ```sh pacman -S words fortune-mod ``` ```sh ./schema/gendummydata.py dummy.sql ``` ```sh mariadb aurweb < dummy.sql ``` -------------------------------- ### Get Single Package Details Source: https://context7.com/archlinux/aurweb/llms.txt Retrieve detailed information for a specific package. Supports options to include all dependencies or requirements. ```python resp = httpx.get( "https://aur.archlinux.org/packages/python-requests", params={\"all_deps\": True, \"all_reqs\": False}, ) ``` -------------------------------- ### Run Pytest Python Test Suites Source: https://github.com/archlinux/aurweb/blob/master/test/README.md Execute the Pytest Python test suites. Use 'poetry run pytest' if Aurweb is installed via poetry, or 'pytest' if installed globally. ```bash # With poetry-installed aurweb $ poetry run pytest # With globally-installed aurweb $ pytest ``` -------------------------------- ### Lighttpd URL Rewrite Rule Source: https://github.com/archlinux/aurweb/blob/master/upgrading/1.9.0.txt This is the equivalent URL rewrite rule for lighttpd setups to provide backward-compatible package URLs. ```lighttpd url.rewrite-once = ( "^/packages/([^/]{1,2})([^/]*/(PKGBUILD|[^/]*\.tar\.gz|))$" => "/packages/$1/$1$2" ) ``` -------------------------------- ### Create Initial Translation File Source: https://github.com/archlinux/aurweb/blob/master/doc/i18n.md Navigate to the 'po/' directory and use msginit to create a new .po file for your locale. This requires the aurweb.pot template. ```bash cd aurweb-git git checkout master git pull cd po msginit -l -o .po -i aurweb.pot ``` -------------------------------- ### Configuration Management with aurweb.config Source: https://context7.com/archlinux/aurweb/llms.txt Demonstrates how to read, set, and reload configuration options using the aurweb.config module. Supports INI-style configuration files and provides typed getters. ```python import aurweb.config # Read a string option aur_location = aurweb.config.get("options", "aur_location") # → "https://aur.archlinux.org" # Read an integer option with a fallback salt_rounds = aurweb.config.getint("options", "salt_rounds", fallback=12) # Read a boolean option disable_http_login = aurweb.config.getboolean("options", "disable_http_login") # Read an entire section as a dict-like object db_section = aurweb.config.get_section("database") print(db_section["backend"]) # → "mysql" print(db_section["host"]) # → "localhost" # Temporarily override an option (useful in tests) aurweb.config.set_option("options", "enable-maintenance", "1") aurweb.config.save() # persists to $AUR_CONFIG # Reload configuration from disk aurweb.config.rehash() # Publicly available version string print(aurweb.config.AURWEB_VERSION) # → "v6.3.4" ``` -------------------------------- ### Create Groups and PackageGroups Tables Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Sets up tables for managing package groups, including a Groups table for group definitions and a PackageGroups table for associating packages with groups. ```sql CREATE TABLE `Groups` ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(64) NOT NULL, PRIMARY KEY (ID), UNIQUE (Name) ) ENGINE = InnoDB; CREATE TABLE PackageGroups ( PackageID INTEGER UNSIGNED NOT NULL, GroupID INTEGER UNSIGNED NOT NULL, PRIMARY KEY (PackageID, GroupID), FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE, FOREIGN KEY (GroupID) REFERENCES `Groups`(ID) ON DELETE CASCADE ) ENGINE = InnoDB; ``` -------------------------------- ### Create Licenses and PackageLicenses Tables Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Establishes tables for managing package licenses, including a Licenses table for license definitions and a PackageLicenses table for associating packages with licenses. ```sql CREATE TABLE Licenses ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(64) NOT NULL, PRIMARY KEY (ID), UNIQUE (Name) ) ENGINE = InnoDB; CREATE TABLE PackageLicenses ( PackageID INTEGER UNSIGNED NOT NULL, LicenseID INTEGER UNSIGNED NOT NULL, PRIMARY KEY (PackageID, LicenseID), FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE, FOREIGN KEY (LicenseID) REFERENCES Licenses(ID) ON DELETE CASCADE ) ENGINE = InnoDB; ``` -------------------------------- ### Create DependencyTypes Table and Insert Initial Data Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Creates a new table to store different types of package dependencies and inserts the initial 'depends' type. ```sql CREATE TABLE DependencyTypes ( ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(32) NOT NULL DEFAULT '', PRIMARY KEY (ID) ) ENGINE = InnoDB; INSERT INTO DependencyTypes VALUES (1, 'depends'); ``` -------------------------------- ### Clone Initial Archive Source: https://github.com/archlinux/aurweb/blob/master/doc/git-archive.md Use this command to perform a shallow clone when fetching archives for the first time. ```bash git clone --depth=1 https://aur.archlinux.org/archive.git aurweb-archive ``` -------------------------------- ### Populate Package Licenses Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Migrates existing license information from the Packages table into the new Licenses and PackageLicenses tables. ```sql INSERT INTO Licenses (Name) SELECT DISTINCT License FROM Packages; INSERT INTO PackageLicenses (PackageID, LicenseID) SELECT Packages.ID, Licenses.ID FROM Packages INNER JOIN Licenses ON Licenses.Name = Packages.License; ``` -------------------------------- ### Query Aurweb RPC Source: https://github.com/archlinux/aurweb/blob/master/docker/README.md Example of querying the Aurweb RPC interface using curl. The -k flag bypasses local certificate issues. ```sh curl -k "https://localhost:8444/rpc/?v=5&type=search&arg=python" ``` -------------------------------- ### AUR OpenAPI Routes (v5) Source: https://context7.com/archlinux/aurweb/llms.txt Modern RESTful API endpoints for interacting with AUR package data, supporting GET and POST requests. ```APIDOC ## Single package info ```bash curl "https://aur.archlinux.org/rpc/v5/info/yay" ``` ### Description Retrieves detailed information for a single package. ### Method GET ### Endpoint `/rpc/v5/info/{packageName}` ### Path Parameters - **packageName** (string) - Required - The name of the package to retrieve information for. ## Multi-info lookup via GET ```bash curl "https://aur.archlinux.org/rpc/v5/info?arg[]=yay&arg[]=paru" ``` ### Description Retrieves detailed information for multiple packages using GET request with query parameters. ### Method GET ### Endpoint `/rpc/v5/info` ### Query Parameters - **arg[]** (string) - Required - Package name. Can be specified multiple times for multiple packages. ## Multi-info lookup via POST ```bash curl -X POST "https://aur.archlinux.org/rpc/v5/info" \ -H "Content-Type: application/json" \ -d '{"arg": ["yay", "paru"]}' ``` ### Description Retrieves detailed information for multiple packages using a POST request with a JSON body. ### Method POST ### Endpoint `/rpc/v5/info` ### Request Body - **arg** (array of strings) - Required - A list of package names. ### Request Example ```json { "arg": ["yay", "paru"] } ``` ## Search with 'by' field via GET ```bash curl "https://aur.archlinux.org/rpc/v5/search/yay?by=n" ``` ### Description Searches for packages, filtering by a specific field. ### Method GET ### Endpoint `/rpc/v5/search/{packageName}` ### Path Parameters - **packageName** (string) - Required - The package name to search for. ### Query Parameters - **by** (string) - Required - The field to search by (e.g., `n` for name). ## Search via POST ```bash curl -X POST "https://aur.archlinux.org/rpc/v5/search" \ -H "Content-Type: application/json" \ -d '{"arg": "python", "by": "nd"}' ``` ### Description Searches for packages using a POST request with a JSON body, allowing specification of search arguments and filters. ### Method POST ### Endpoint `/rpc/v5/search` ### Request Body - **arg** (string) - Required - The search term. - **by** (string) - Required - The search filter (e.g., `nd` for name and description). ### Request Example ```json { "arg": "python", "by": "nd" } ``` ## Suggest (autocomplete) via GET ```bash curl "https://aur.archlinux.org/rpc/v5/suggest/pyt" ``` ### Description Provides package name suggestions based on a partial input string using a GET request. ### Method GET ### Endpoint `/rpc/v5/suggest/{partialName}` ### Path Parameters - **partialName** (string) - Required - The partial package name for suggestions. ``` -------------------------------- ### Package Search Source: https://github.com/archlinux/aurweb/blob/master/doc/rpc.txt Perform package searches by issuing HTTP GET requests. You can search by package name, name and description, maintainer, or dependencies. ```APIDOC ## Package Search ### Description Searches for packages based on specified criteria. ### Method GET ### Endpoint /rpc?v=5&type=search&by=_field_&arg=_keywords_ ### Parameters #### Query Parameters - **v** (integer) - Required - API version, currently 5. - **type** (string) - Required - Must be `search`. - **by** (string) - Optional - The field to search by. Defaults to `name-desc`. Possible values: `name`, `name-desc`, `maintainer`, `depends`, `makedepends`, `optdepends`, `checkdepends`. - **arg** (string) - Required - The search keywords or maintainer name. - **callback** (string) - Optional - For JSONP requests. ### Request Example ``` /rpc?v=5&type=search&arg=foobar /rpc?v=5&type=search&by=maintainer&arg=john /rpc?v=5&type=search&by=makedepends&arg=boost /rpc?v=5&type=search&arg=foobar&callback=jsonp1192244621103 ``` ### Response #### Success Response (200) Returns a list of packages matching the search criteria. ``` -------------------------------- ### Build Aurweb Docker Image Source: https://github.com/archlinux/aurweb/blob/master/docker/README.md Build the main 'aurweb' Docker image. This command should be run after cloning the repository. ```sh docker compose build ``` -------------------------------- ### AUR RPC API (v5) Source: https://context7.com/archlinux/aurweb/llms.txt Interact with the AUR using the RPC API for searching, getting info, and suggestions. Supports JSONP for older clients. ```APIDOC ## Search by depends / makedepends / optdepends / checkdepends ```bash curl "https://aur.archlinux.org/rpc?v=5&type=search&by=depends&arg=python" ``` ### Description Searches for packages based on their dependency information. ### Method GET ### Endpoint `/rpc?v=5&type=search` ### Query Parameters - **by** (string) - Required - The type of dependency to search by (e.g., `depends`, `makedepends`). - **arg** (string) - Required - The dependency name to search for. ## Search by provides / conflicts / replaces / groups / keywords ```bash curl "https://aur.archlinux.org/rpc?v=5&type=search&by=provides&arg=libfoo.so" ``` ### Description Searches for packages based on provided, conflicting, replaced, grouped, or keyword information. ### Method GET ### Endpoint `/rpc?v=5&type=search` ### Query Parameters - **by** (string) - Required - The search category (e.g., `provides`, `conflicts`, `replaces`, `groups`, `keywords`). - **arg** (string) - Required - The item to search for within the specified category. ## Multi-info lookup ```bash curl "https://aur.archlinux.org/rpc?v=5&type=info&arg[]=yay&arg[]=paru" ``` ### Description Retrieves detailed information for multiple packages simultaneously. ### Method GET ### Endpoint `/rpc?v=5&type=info` ### Query Parameters - **arg[]** (string) - Required - Package name. Can be specified multiple times for multiple packages. ## Suggest (autocomplete) ```bash curl "https://aur.archlinux.org/rpc?v=5&type=suggest&arg=pyth" ``` ### Description Provides package name suggestions based on a partial input string. ### Method GET ### Endpoint `/rpc?v=5&type=suggest` ### Query Parameters - **arg** (string) - Required - The partial package name for suggestions. ## JSONP support ```bash curl "https://aur.archlinux.org/rpc?v=5&type=info&arg=yay&callback=myFunc" ``` ### Description Retrieves package information and wraps the JSON response in a JavaScript callback function for JSONP requests. ### Method GET ### Endpoint `/rpc?v=5&type=info` ### Query Parameters - **arg** (string) - Required - The package name. - **callback** (string) - Required - The name of the JavaScript function to call with the response. ``` -------------------------------- ### Pytest Fixture for Database Testing Source: https://github.com/archlinux/aurweb/blob/master/test/README.md Example of using the `db_test` pytest fixture to prepare test databases and clean up tables for each test function. This fixture is essential for most Pytest database tests. ```python import pytest from aurweb import db from aurweb.models.account_type import USER_ID from aurweb.models.user import User from aurweb.testing.requests import Request # We need to use the `db_test` fixture at some point # during our test functions. @pytest.fixture(autouse=True) def setup(db_test: None) -> None: return # Or... specify it in a dependency fixture. @pytest.fixture def user(db_test: None) -> User: with db.begin(): user = db.create(User, Username="test", Email="test@example.org", Passwd="testPassword", AccountTypeID=USER_ID) yield user def test_user_login(user: User): assert isinstance(user, User) is True fake_request = Request() sid = user.login(fake_request, "testPassword") assert sid is not None ``` -------------------------------- ### Build Docker Image Source: https://github.com/archlinux/aurweb/blob/master/CONTRIBUTING.md Build the Docker image for the aurweb application. ```bash docker-compose build ``` -------------------------------- ### pkgname.json File Layout Source: https://github.com/archlinux/aurweb/blob/master/doc/repos/pkgnames-repo.md The pkgname.json file contains a simple JSON array of package names. ```json [ "pkgname1", "pkgname2", ... ] ``` -------------------------------- ### Create Terms and AcceptedTerms tables Source: https://github.com/archlinux/aurweb/blob/master/upgrading/4.6.0.txt These SQL scripts create the 'Terms' and 'AcceptedTerms' tables. The 'Terms' table stores information about terms and conditions, while 'AcceptedTerms' tracks which users have accepted which terms. ```sql CREATE TABLE Terms ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Description VARCHAR(255) NOT NULL, URL VARCHAR(8000) NOT NULL, Revision INTEGER UNSIGNED NOT NULL DEFAULT 1, PRIMARY KEY (ID) ) ENGINE = InnoDB; ``` ```sql CREATE TABLE AcceptedTerms ( UsersID INTEGER UNSIGNED NOT NULL, TermsID INTEGER UNSIGNED NOT NULL, Revision INTEGER UNSIGNED NOT NULL DEFAULT 0, FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE, FOREIGN KEY (TermsID) REFERENCES Terms(ID) ON DELETE CASCADE ) ENGINE = InnoDB; ``` -------------------------------- ### Legacy RPC API - Search by Name/Description Source: https://context7.com/archlinux/aurweb/llms.txt Use the legacy RPC API (v5) to search for packages by name and description. This is rate-limited per IP. ```bash curl "https://aur.archlinux.org/rpc?v=5&type=search&arg=python-requests" ``` -------------------------------- ### Perform Bulk Package Actions Source: https://context7.com/archlinux/aurweb/llms.txt Execute bulk actions on multiple packages, such as notifying, adopting, or deleting. Authentication is required. The response indicates success or errors. ```python resp = httpx.post( "https://aur.archlinux.org/packages", data={ "IDs": [1234, 5678], # Package.ID list "action": "notify", }, cookies={\"AURSID\": aursid}, ) ``` ```python resp = httpx.post( "https://aur.archlinux.org/packages", data={ "IDs": [9999], "action": "adopt", "confirm": "on", }, cookies={\"AURSID\": aursid}, ) ``` -------------------------------- ### AUR RPC Search by Provides Source: https://context7.com/archlinux/aurweb/llms.txt Searches for packages that provide a specific file or capability. ```bash curl "https://aur.archlinux.org/rpc?v=5&type=search&by=provides&arg=libfoo.so" ``` -------------------------------- ### Run Ruff Checks and Formatting Source: https://github.com/archlinux/aurweb/blob/master/CONTRIBUTING.md Before submitting patches, run these commands to check and format your code according to project standards. ```bash ruff check . ruff format . ``` -------------------------------- ### Web UI Package Search with `PackageSearch` Source: https://context7.com/archlinux/aurweb/llms.txt Utilize `PackageSearch` for building SQLAlchemy queries for the web UI. It supports chained `search_by` and `sort_by` calls, and can leverage Redis for caching counts. ```python from aurweb.packages.search import PackageSearch, RPCSearch from aurweb import db from aurweb.models.user import User # --- Web UI search (authenticated user gets Voted/Notify columns) --- user = db.query(User, User.Username == "alice").first() search = PackageSearch(user) # Search by name/description (default), chained AND keywords search.search_by("nd", "python") search.search_by("nd", "library") # Sort by popularity (descending) search.sort_by("p", "d") # Get count (uses Redis cache when available) count = search.count() # Get result rows results = search.results().with_entities(...).limit(50).offset(0).all() ``` -------------------------------- ### Run All Aurweb Tests Source: https://github.com/archlinux/aurweb/blob/master/test/README.md Execute all Sharness and Pytest suites from the project root. Ensure you are in the project directory before running. ```bash $ make -C test sh $ poetry run pytest ``` -------------------------------- ### Configure Aurweb Development Settings Source: https://github.com/archlinux/aurweb/blob/master/test/README.md Copy the development configuration file and modify it to point to your Aurweb repository root. This is essential for running tests. ```bash $ cp -v conf/config.dev conf/config $ sed -i "s;YOUR_AUR_ROOT;/path/to/aurweb;g" conf/config ``` -------------------------------- ### Create PackageBases Table Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Defines the schema for the new PackageBases table, including primary and unique keys, indexes, and foreign key relationships to Users and PackageCategories. ```sql CREATE TABLE PackageBases ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(64) NOT NULL, CategoryID TINYINT UNSIGNED NOT NULL DEFAULT 1, NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0, OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL, SubmittedTS BIGINT UNSIGNED NOT NULL, 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 (PackagerUID) REFERENCES Users(ID) ON DELETE SET NULL ) ENGINE = InnoDB; ``` -------------------------------- ### Upgrade Database with Alembic Source: https://github.com/archlinux/aurweb/blob/master/upgrading/5.x.x.txt Run this command from the aurweb root directory after upgrading the source code to a new release that uses Alembic for database migrations. ```bash alembic upgrade head ``` -------------------------------- ### Add Salt and ResetKey Columns to Users Table Source: https://github.com/archlinux/aurweb/blob/master/upgrading/1.7.0.txt Execute these SQL statements to add the 'Salt' and 'ResetKey' columns to the 'Users' table. Both columns are mandatory and default to an empty string. ```sql ALTER TABLE Users ADD Salt CHAR(32) NOT NULL DEFAULT ''; ``` ```sql ALTER TABLE Users ADD ResetKey CHAR(32) NOT NULL DEFAULT ''; ``` -------------------------------- ### AUR RPC Multi-info Lookup Source: https://context7.com/archlinux/aurweb/llms.txt Retrieves detailed information for multiple packages simultaneously. ```bash curl "https://aur.archlinux.org/rpc?v=5&type=info&arg[]=yay&arg[]=paru" ``` -------------------------------- ### AUR RPC v5 Multi-info Lookup (POST) Source: https://context7.com/archlinux/aurweb/llms.txt Retrieves detailed information for multiple packages using the v5 API via POST request with a JSON body. ```bash curl -X POST "https://aur.archlinux.org/rpc/v5/info" \ -H "Content-Type: application/json" \ -d '{"arg": ["yay", "paru"]}' ``` -------------------------------- ### AUR RPC v5 Suggest (Autocomplete) Source: https://context7.com/archlinux/aurweb/llms.txt Provides package name suggestions using the v5 API for autocomplete functionality. ```bash curl "https://aur.archlinux.org/rpc/v5/suggest/pyt" ``` -------------------------------- ### AUR RPC Suggest (Autocomplete) Source: https://context7.com/archlinux/aurweb/llms.txt Provides package name suggestions for autocomplete functionality. ```bash curl "https://aur.archlinux.org/rpc?v=5&type=suggest&arg=pyth" ``` -------------------------------- ### Credential Checks with `aurweb.auth.creds` Source: https://context7.com/archlinux/aurweb/llms.txt Demonstrates using `has_credential` with specific credential constants from `aurweb.auth.creds`. An `approved` list can grant access regardless of the user's role. ```python from aurweb.auth.creds import has_credential from aurweb.auth import creds from aurweb.models.user import User from aurweb import db user = db.query(User, User.Username == "alice").first() pkgbase = db.query(...).first() # Any authenticated user can flag assert has_credential(user, creds.PKGBASE_FLAG) ``` ```python # Only Package Maintainer / Developer can delete packages assert not has_credential(user, creds.PKGBASE_DELETE) # for a normal User ``` ```python # An "approved" list grants access regardless of role # e.g., a maintainer can always unflag their own package approved_users = [pkgbase.Maintainer, pkgbase.Flagger] can_unflag = has_credential(user, creds.PKGBASE_UNFLAG, approved=approved_users) ``` -------------------------------- ### Allow Nulls for Description and URL Source: https://github.com/archlinux/aurweb/blob/master/upgrading/4.0.0.txt Modifies the 'Packages' table to allow 'Description' and 'URL' fields to store NULL values. This change accommodates packages that may not have these fields populated. ```sql ALTER TABLE Packages MODIFY Description VARCHAR(255) NULL DEFAULT NULL, MODIFY URL VARCHAR(255) NULL DEFAULT NULL; ``` -------------------------------- ### Search Packages Source: https://context7.com/archlinux/aurweb/llms.txt Search for packages using various query parameters like keywords, search fields, sorting, and pagination. ```python resp = httpx.get( "https://aur.archlinux.org/packages", params={ "K": "python library", # keywords "SeB": "nd", # search by: name+description "SB": "p", # sort by: popularity "SO": "d", # sort order: descending "PP": 50, # per page "O": 0, # offset "outdated": "on", # filter flagged-only }, ) ``` -------------------------------- ### Bash Script to Convert Package Build Files Source: https://github.com/archlinux/aurweb/blob/master/upgrading/1.8.0.txt This bash script should be run inside your incoming directory. It iterates through subdirectories, checks for the existence of a PKGBUILD file, and if not found, it searches for and copies the PKGBUILD to the correct location. This is necessary because source tarballs are no longer extracted automatically in 1.8.0. ```bash #!/bin/bash for pkg in *; do if [ -d "${pkg}" -a ! -f "${pkg}/PKGBUILD" ]; then pkgbuild_file=$(find -P "${pkg}" -name PKGBUILD) [ -n "${pkgbuild_file}" ] && \ cp "${pkgbuild_file}" "${pkg}/PKGBUILD" f done ``` -------------------------------- ### Recreate Foreign Keys and Indexes for Package Relationships Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Establishes new foreign key constraints and unique indexes for PackageVotes, PackageComments, and CommentNotify to reference PackageBases and Users correctly. This ensures data integrity after migration. ```sql ALTER TABLE PackageVotes ADD FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE, ADD FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE; ALTER TABLE PackageComments ADD FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE; ALTER TABLE CommentNotify ADD FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE, ADD FOREIGN KEY (UserID) REFERENCES Users(ID) ON DELETE CASCADE; CREATE UNIQUE INDEX VoteUsersIDPackageID ON PackageVotes (UsersID, PackageBaseID); CREATE UNIQUE INDEX NotifyUserIDPkgID ON CommentNotify (UserID, PackageBaseID); ``` -------------------------------- ### Package Base Actions (Python SDK) Source: https://context7.com/archlinux/aurweb/llms.txt Internal Python functions for managing package bases, used by web UI and router components. Requires an authenticated FastAPI Request object. ```APIDOC ## Adopt an orphaned package base ```python from fastapi import Request from aurweb import db from aurweb.models.package_base import PackageBase from aurweb.pkgbase import actions pkgbase = db.query(PackageBase, PackageBase.Name == "my-package").first() actions.pkgbase_adopt_instance(request, pkgbase) ``` ### Description Adopts an orphaned package base, assigning it to the current user and sending a notification. ### Parameters - **request** (Request) - Required - The FastAPI request object containing user authentication. - **pkgbase** (PackageBase) - Required - The package base instance to adopt. ## Disown a package base ```python actions.pkgbase_disown_instance(request, pkgbase) ``` ### Description Disowns a package base. If co-maintainers exist, the first one is promoted; otherwise, the package becomes orphaned. Sends a notification. ### Parameters - **request** (Request) - Required - The FastAPI request object. - **pkgbase** (PackageBase) - Required - The package base instance to disown. ## Enable/disable notifications for a package base ```python actions.pkgbase_notify_instance(request, pkgbase) actions.pkgbase_unnotify_instance(request, pkgbase) ``` ### Description Manages notification settings for the current user regarding a specific package base. ### Parameters - **request** (Request) - Required - The FastAPI request object. - **pkgbase** (PackageBase) - Required - The package base instance. ## Clear out-of-date flag ```python actions.pkgbase_unflag_instance(request, pkgbase) ``` ### Description Clears the out-of-date flag for a package base. Requires the `PKGBASE_UNFLAG` credential. ### Parameters - **request** (Request) - Required - The FastAPI request object. - **pkgbase** (PackageBase) - Required - The package base instance. ## Delete a package base ```python notifs = actions.pkgbase_delete_instance(request, pkgbase, comments="Deleted: merged upstream") for n in notifs: n.send() ``` ### Description Deletes a package base. This action is restricted to Package Managers or Developers. Returns a list of notifications to be sent. ### Parameters - **request** (Request) - Required - The FastAPI request object. - **pkgbase** (PackageBase) - Required - The package base instance to delete. - **comments** (str) - Optional - Reason for deletion. ## Merge package base into target ```python target = db.query(PackageBase, PackageBase.Name == "new-package").first() actions.pkgbase_merge_instance(request, pkgbase, target, comments="Merged into new-package") ``` ### Description Merges one package base into another, migrating votes, comments, and notifications to the target package base. ### Parameters - **request** (Request) - Required - The FastAPI request object. - **pkgbase** (PackageBase) - Required - The source package base to merge. - **target** (PackageBase) - Required - The destination package base. - **comments** (str) - Optional - Reason for the merge. ``` -------------------------------- ### Migrate Data from Packages to PackageBases Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Inserts data from the existing Packages table into the newly created PackageBases table, mapping relevant columns. ```sql INSERT INTO PackageBases SELECT ID, Name, CategoryID, NumVotes, OutOfDateTS, SubmittedTS, ModifiedTS, SubmitterUID, MaintainerUID, NULL FROM Packages; ``` -------------------------------- ### Python Package Base Actions: Enable Notifications Source: https://context7.com/archlinux/aurweb/llms.txt Enables package base notifications for the current user. ```python from fastapi import Request from aurweb import db from aurweb.models.package_base import PackageBase from aurweb.pkgbase import actions pkgbase = db.query(PackageBase, PackageBase.Name == "my-package").first() actions.pkgbase_notify_instance(request, pkgbase) ``` -------------------------------- ### Create RelationTypes Table Source: https://github.com/archlinux/aurweb/blob/master/upgrading/3.0.0.txt Creates a new table to store different types of package relations, such as conflicts, provides, and replaces. Initializes with common relation types. ```sql CREATE TABLE RelationTypes ( ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(32) NOT NULL DEFAULT '', PRIMARY KEY (ID) ) ENGINE = InnoDB; INSERT INTO RelationTypes VALUES (1, 'conflicts'); INSERT INTO RelationTypes VALUES (2, 'provides'); INSERT INTO RelationTypes VALUES (3, 'replaces'); ``` -------------------------------- ### Create New Account Source: https://context7.com/archlinux/aurweb/llms.txt Register a new user account on the AUR. Requires user details, password, and CAPTCHA information. ```python resp = httpx.post( "https://aur.archlinux.org/register", data={ "U": "bob", # Username "E": "bob@example.com", # Email "P": "securepassword", # Password "C": "securepassword", # Confirm "L": "en", # Language "TZ": "UTC", # Timezone "CN": "on", # Comment Notify "captcha": "answer", "captcha_salt": "...", }, ) ``` -------------------------------- ### View Package Base Source: https://context7.com/archlinux/aurweb/llms.txt Retrieve information about a package base. For single-package bases, this redirects to the /packages/{name} endpoint. ```python resp = httpx.get("https://aur.archlinux.org/pkgbase/my-split-package") ``` -------------------------------- ### Package Listing & Bulk Actions Source: https://context7.com/archlinux/aurweb/llms.txt Endpoints for searching packages, viewing package details, and performing bulk actions on packages. ```APIDOC ## GET /packages — search packages ### Description Searches for packages based on various criteria. ### Method GET ### Endpoint /packages ### Parameters #### Query Parameters - **K** (string) - Optional - Keywords to search for (e.g., "python library"). - **SeB** (string) - Optional - Search by field (e.g., "nd" for name and description). - **SB** (string) - Optional - Sort by field (e.g., "p" for popularity). - **SO** (string) - Optional - Sort order (e.g., "d" for descending). - **PP** (integer) - Optional - Number of results per page. - **O** (integer) - Optional - Offset for pagination. - **outdated** (string) - Optional - Filter for outdated packages ('on'). ## GET /packages/{name} — single package detail ### Description Retrieves detailed information for a specific package. ### Method GET ### Endpoint /packages/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the package. #### Query Parameters - **all_deps** (boolean) - Optional - Include all dependencies. - **all_reqs** (boolean) - Optional - Include all requirements. ## POST /packages — bulk actions ### Description Performs bulk actions on a list of packages. Authentication is required. ### Method POST ### Endpoint /packages ### Parameters #### Request Body - **IDs** (array of integers) - Required - List of Package IDs. - **action** (string) - Required - The action to perform (e.g., "unflag", "notify", "unnotify", "adopt", "disown", "delete"). - **confirm** (string) - Optional - Confirmation for actions like 'adopt' ('on'). #### Request Headers - **Cookies** - Required - Authentication cookie `AURSID`. ### Response #### Success Response Returns a JSON object with either `success` or `errors` keys, containing lists of affected package identifiers or error messages. ``` -------------------------------- ### Manage Package Maintainer Proposals with httpx Source: https://context7.com/archlinux/aurweb/llms.txt Use httpx to interact with the package-maintainer API for listing proposals, creating new ones, and casting votes. Requires authentication via AURSID cookie. ```python import httpx # GET /package-maintainer — list current and past proposals (PM/Developer) resp = httpx.get( "https://aur.archlinux.org/package-maintainer", params={"cby": "desc", "pby": "desc", "coff": 0, "poff": 0}, cookies={"AURSID": aursid}, ) ``` ```python # GET /addvote — form to create a proposal (Package Maintainers only) # POST /addvote — submit a proposal resp = httpx.post( "https://aur.archlinux.org/addvote", data={ "user": "newpm", "type": "add_pm", # add_pm | remove_pm | remove_inactive_pm | bylaws "agenda": "Nominating newpm for Package Maintainer role.", }, cookies={"AURSID": pm_aursid}, ) # 303 → /package-maintainer/{new_proposal_id} ``` ```python # POST /package-maintainer/{proposal} — cast vote resp = httpx.post( "https://aur.archlinux.org/package-maintainer/42", data={"decision": "Yes"}, # Yes | No | Abstain cookies={"AURSID": pm_aursid}, ) # Vote durations & quorums: # add_pm / bylaws: 7 days, 66% quorum # remove_pm: 7 days, 75% quorum # remove_inactive_pm: 5 days, 66% quorum ``` -------------------------------- ### Set Aurweb Configuration and Logging Environment Variables Source: https://github.com/archlinux/aurweb/blob/master/test/README.md Export the AUR_CONFIG and LOG_CONFIG environment variables to point to the correct configuration and logging files. These are necessary before running tests. ```bash $ export AUR_CONFIG=conf/config $ export LOG_CONFIG=logging.test.conf ``` -------------------------------- ### Pull Translations from Transifex Source: https://github.com/archlinux/aurweb/blob/master/doc/i18n.md Use the transifex-client to download all current translation files. This is useful for updating existing translations. ```bash tx pull -a ``` -------------------------------- ### Clone Aurweb Source Code Source: https://github.com/archlinux/aurweb/blob/master/doc/i18n.md Use git to clone the Aurweb repository. This is the first step to access the source files for translation. ```bash git clone https://gitlab.archlinux.org/archlinux/aurweb.git aurweb-git ``` -------------------------------- ### Vote for a Package Source: https://context7.com/archlinux/aurweb/llms.txt Submit a vote for a package. Authentication is required. ```python resp = httpx.post( "https://aur.archlinux.org/pkgbase/my-package/vote", cookies={\"AURSID\": aursid}, ) ``` -------------------------------- ### Create Package Co-maintainers Table Source: https://github.com/archlinux/aurweb/blob/master/upgrading/4.0.0.txt Creates a new table to manage co-maintainers for package bases. This table links users to package bases with a priority level. ```sql CREATE TABLE PackageComaintainers ( UsersID INTEGER UNSIGNED NOT NULL, PackageBaseID INTEGER UNSIGNED NOT NULL, Priority INTEGER UNSIGNED NOT NULL, INDEX (UsersID), INDEX (PackageBaseID), FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE, FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE ) ENGINE = InnoDB; ``` -------------------------------- ### Convert LastLoginIPAddress to VARCHAR(40) Source: https://github.com/archlinux/aurweb/blob/master/upgrading/4.2.1.txt Use this SQL command to alter the Users table, changing the LastLoginIPAddress column to VARCHAR(40) and allowing NULL values. ```sql ALTER TABLE Users MODIFY LastLoginIPAddress VARCHAR(40) NULL DEFAULT NULL; ``` -------------------------------- ### Add Package Flagging User and Comment Fields Source: https://github.com/archlinux/aurweb/blob/master/upgrading/4.1.0.txt Adds columns to the PackageBases table to store the user ID and comment of the last person who flagged a package as out-of-date. ```SQL ALTER TABLE PackageBases ADD COLUMN FlaggerUID INTEGER UNSIGNED NULL DEFAULT NULL, ADD COLUMN FlaggerComment VARCHAR(255) NOT NULL, ADD FOREIGN KEY (FlaggerUID) REFERENCES Users(ID) ON DELETE SET NULL; ``` -------------------------------- ### HTTP POST /passreset Request (Step 1) Source: https://context7.com/archlinux/aurweb/llms.txt Initiates a password reset by sending a POST request to the /passreset endpoint. This is the first step, which sends a reset link via email. ```python resp = httpx.post( "https://aur.archlinux.org/passreset", data={"user": "alice"}, # username or email ) ``` -------------------------------- ### Push Updated Translations to Transifex Source: https://github.com/archlinux/aurweb/blob/master/doc/i18n.md Use the transifex-client to push your updated translation file back to Transifex. Specify the resource, template, and locale. ```bash tx push -r aurweb.aurwebpot -t -l ``` -------------------------------- ### AUR RPC v5 Single Info Lookup Source: https://context7.com/archlinux/aurweb/llms.txt Retrieves detailed information for a single package using the v5 API. ```bash curl "https://aur.archlinux.org/rpc/v5/info/yay" ``` -------------------------------- ### Add Repository Column to OfficialProviders Table Source: https://github.com/archlinux/aurweb/blob/master/upgrading/4.3.0.txt Adds a new VARCHAR(64) column named Repo to the OfficialProviders table. This column is mandatory and stores repository information for official providers. ```sql ALTER TABLE OfficialProviders ADD COLUMN Repo VARCHAR(64) NOT NULL; ``` -------------------------------- ### Flag Package as Out-of-Date Source: https://context7.com/archlinux/aurweb/llms.txt Flag a package as out-of-date, providing comments to explain the reason. Authentication is required. ```python resp = httpx.post( "https://aur.archlinux.org/pkgbase/my-package/flag", data={\"comments\": \"Upstream released v2.0, PKGBUILD still on v1.9\"}, cookies={\"AURSID\": aursid}, ) ``` -------------------------------- ### Users JSON File Structure Source: https://github.com/archlinux/aurweb/blob/master/doc/repos/users-repo.md This snippet shows the expected format for the users.json file, which is a simple array of strings representing usernames. ```json [ "user1", "user2", ... ] ``` -------------------------------- ### Migrate Package Dependency Storage Source: https://github.com/archlinux/aurweb/blob/master/upgrading/1.8.2.txt This SQL script modifies the PackageDepends table to store dependency names directly and removes the old DepPkgID column. It also cleans up dummy packages. ```sql ALTER TABLE PackageDepends ADD COLUMN DepName VARCHAR(64) NOT NULL DEFAULT '' AFTER PackageID; ``` ```sql UPDATE PackageDepends SET DepName = (SELECT Name FROM Packages WHERE ID = DepPkgID); ``` ```sql ALTER TABLE PackageDepends MODIFY DepName VARCHAR(64) NOT NULL; ``` ```sql ALTER TABLE PackageDepends DROP FOREIGN KEY `PackageDepends_ibfk_2`; ``` ```sql ALTER TABLE PackageDepends DROP COLUMN DepPkgID; ``` ```sql DELETE FROM Packages WHERE DummyPkg = 1; ``` ```sql ALTER TABLE Packages DROP COLUMN DummyPkg; ``` -------------------------------- ### AUR RPC v5 Search by Field Source: https://context7.com/archlinux/aurweb/llms.txt Searches for packages based on a query and a specific field (e.g., name). ```bash curl "https://aur.archlinux.org/rpc/v5/search/yay?by=n" ``` -------------------------------- ### RPC API - Legacy Search Source: https://context7.com/archlinux/aurweb/llms.txt Legacy RPC methods for searching packages. ```APIDOC ## Legacy RPC API (v5) ### Description Provides legacy JSON RPC endpoints for interacting with the AUR. Supports JSONP. ### Method GET ### Endpoint /rpc ### Parameters #### Query Parameters - **v** (integer) - Required - API version (e.g., 5). - **type** (string) - Required - The type of RPC request (e.g., "search"). - **arg** (string) - Required for search - The search term. - **by** (string) - Optional for search - The field to search by (e.g., "m" for maintainer). ### Request Example ```bash curl "https://aur.archlinux.org/rpc?v=5&type=search&arg=python-requests" curl "https://aur.archlinux.org/rpc?v=5&type=search&by=m&arg=alice" ``` ``` -------------------------------- ### Reset Password Step 2 Source: https://context7.com/archlinux/aurweb/llms.txt Use this endpoint to set a new password after initiating a password reset. ```python resp = httpx.post( "https://aur.archlinux.org/passreset", data={ "user": "alice", "resetkey": "abc123...", "password": "newpass", "confirm": "newpass", }, ) ``` -------------------------------- ### Add OfficialProviders Table Source: https://github.com/archlinux/aurweb/blob/master/upgrading/4.2.0.txt Creates a new table to store provider information from official packages. This table is essential for tracking package dependencies and origins. ```sql CREATE TABLE OfficialProviders ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(64) NOT NULL, Provides VARCHAR(64) NOT NULL, PRIMARY KEY (ID) ) ENGINE = InnoDB; CREATE UNIQUE INDEX ProviderNameProvides ON OfficialProviders (Name, Provides); ``` -------------------------------- ### Run AUR Web Tests with Docker Source: https://github.com/archlinux/aurweb/blob/master/doc/docker.md Executes the test suite for AUR Web within a Docker container. ```bash docker-compose run test ```