feat: github_deb metadata-only package type

Add the Debian/apt analog of github_rpm: a metadata-only remote that scans
a GitHub repo's releases for .deb assets, derives per-asset control metadata
via a ranged prefix fetch (never downloading whole packages), synthesizes a
flat apt repository, and redirects .deb downloads to a backend releases_remote.

- Add PackageGitHubDeb to the package-type enum + validity map.
- Add the github_deb provider (internal/provider/deb/github.go): ServeRemote
  serves Packages/Packages.gz/Release, 404s the signed index variants
  (consumed via [trusted=yes]), and 302-redirects *.deb to the releases_remote;
  deriveAsset ranged-GETs the ar prefix, locates control.tar.*, and parses the
  control paragraph, doubling the range on truncation; sha256 comes from the
  asset digest when present, else a one-time full stream.
- Add the github_deb background Syncer (internal/provider/deb/syncer.go): its
  own worker pool, shared rate limiter, deduped queue, and DB-lease-gated scans.
- Add github_deb_sync_state table plus ListGitHubDebRemotes/Claim/Release DB
  helpers (separate from the rpm ones).
- Prime github_deb remotes on create and run the deb syncer alongside the rpm
  one; route prime-on-create by package type.
- Reuse the deb apt-index generators and control parser; skip empty hash lines
  in the Packages index so a SHA256-only metadata entry is valid.
This commit is contained in:
2026-08-11 22:21:05 +10:00
parent 60f008debc
commit b2a6be8eb5
11 changed files with 1889 additions and 14 deletions
+14 -3
View File
@@ -194,7 +194,14 @@ func extractControl(deb []byte) (string, error) {
return "", err
}
tr := tar.NewReader(bytes.NewReader(tarBytes))
return readControlParagraph(tarBytes)
}
// readControlParagraph scans a decompressed control.tar and returns the raw
// ./control paragraph. Shared by the local upload path (extractControl) and the
// github_deb ranged-prefix parser.
func readControlParagraph(controlTar []byte) (string, error) {
tr := tar.NewReader(bytes.NewReader(controlTar))
for {
hdr, err := tr.Next()
if err == io.EOF {
@@ -370,8 +377,12 @@ func generatePackages(metas []provider.DebMetadata) []byte {
b.WriteString("\n")
fmt.Fprintf(&b, "Filename: %s\n", m.FilePath)
fmt.Fprintf(&b, "Size: %d\n", m.Size)
fmt.Fprintf(&b, "MD5sum: %s\n", m.MD5)
fmt.Fprintf(&b, "SHA256: %s\n", m.SHA256)
if m.MD5 != "" {
fmt.Fprintf(&b, "MD5sum: %s\n", m.MD5)
}
if m.SHA256 != "" {
fmt.Fprintf(&b, "SHA256: %s\n", m.SHA256)
}
b.WriteString("\n")
}
return b.Bytes()