Verified Commit 0168ce1d authored by Levente Polyak's avatar Levente Polyak 🚀
Browse files

feature(keyringctl): add simple command to list all certificates

parent 1a8ea839
......@@ -66,6 +66,18 @@ Only export specific certificate directories in [keyring](keyring)
./keyringctl export <directory...>
### List
List all certificates in the keyring
./keyringctl list
Only show a specific main key
./keyringctl list --main <usernames...>
## Installation
To install archlinux-keyring system-wide use the included `Makefile`:
......@@ -1128,6 +1128,39 @@ def build(
def list_keyring(keyring_root: Path, sources: Optional[List[Path]] = None, main_keys: bool = False) -> None:
"""List certificates in the keyring
If sources contains directories, all certificate below them are considered.
keyring_root: Path
The keyring root directory to look up username shorthand sources
sources: Optional[List[Path]]
A list of username or files/directories from which to read PGP packet information (defaults to `keyring_root`)
main_keys: bool
List main keys instead of packager keys (defaults to False)
keyring_dir = keyring_root / ("main" if main_keys else "packager")
if not sources:
sources = list(keyring_dir.iterdir())
# resolve shorthand username exports for packager keys
for index, source in enumerate(sources):
packager_source = keyring_dir /
if not source.exists() and packager_source.exists():
sources[index] = packager_source
username_length = max([len( for source in sources])
for userdir in sources:
certificates = [ for cert in userdir.iterdir()]
print(f"{<{username_length}} {' '.join(certificates)}")
def absolute_path(path: str) -> Path:
"""Return the absolute path of a given str
......@@ -1203,6 +1236,18 @@ if __name__ == "__main__":
help="build keyring PGP artifacts alongside ownertrust and revoked status files",
list_parser = subcommands.add_parser(
help="list the certificates in the keyring",
list_parser.add_argument("--main", action="store_true", help="List main signing keys instead of packager keys")
help="username or files/directories containing certificates (can be provided multiple times)",
args = parser.parse_args()
if args.verbose:
......@@ -1247,6 +1292,12 @@ if __name__ == "__main__":
target_dir=keyring_root.parent / "build",
elif "list" == args.subcommand:
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