progress towards mirroring

This commit is contained in:
dave 2022-11-29 23:13:38 -08:00
parent 40965d9775
commit b57676d972

View File

@ -152,7 +152,7 @@ class Repoline:
if line[0].startswith("["):
# assume amd64 for now
#TODO assume amd64 for now
arch = "amd64"
# now we have the base url
@ -310,10 +310,62 @@ def cmd_mirror(args, parser):
- containing a subset of packages based on some query
- containing a subset of packages matching an existing repo
repo = Repo(args.database)
# filter the packages
package_query = """SELECT * FROM repo_package;"""
package_query_params = ()
from collections import defaultdict
# (dist,component) -> list((name,arch,version))
packages = defaultdict(list)
with closing(repo.db.cursor()) as c:
c.execute(package_query, package_query_params)
for row in c:
packages[(row["dist"], row["component"], )].append(
(row["arch"], row["name"], row["version"], ))
packages = dict(packages)
# build the metadata files
we need to build a structure like:
* source is a field in the package's metadata
TODO add it to the db
Release (hashes of everything in ./<component/)
InRelease (the above, but as a gpg signed message)
Release.gpg (pgp signature for Release file)
(optional? Some kind of index of package contents)
we'll need to skip it for now anyways as we aren't importing it
Release (very small identifier file)
Packages (the metadata of all the packages we'll include)
for each component:
for each package:
link the package file into place, if needed
for each dist:
for each component:
for each arch:
generate Packages file
generate the Release / InRelease metadata file
import pdb
# sign the files
@ -340,11 +392,25 @@ def cmd_import(args, parser):
def cmd_shell(args, parser):
repo = Repo(args.database)
import pdb
def main():
parser = argparse.ArgumentParser(description="apt repo mirroring tool")
parser.add_argument("--database", required=True, help="package database path")
sp_action = parser.add_subparsers(dest="action", help="action to take")
p_shell = sp_action.add_parser("shell", help="interactive shell")
p_mirror = sp_action.add_parser("mirror", help="deploy a repo")
p_ingest = sp_action.add_parser("ingest", help="import packages from existing repos")