Add Alpine/apk local repository support
The alpine provider hosted only remote (proxy) repos; there was no way to publish first-party .apk packages the way rpm-local and deb-local already allow. This extends the existing alpine provider into a real apk repository: uploaded .apk files are parsed in pure Go and a per-arch APKINDEX.tar.gz is generated on demand, at parity with rpm repodata and deb Packages generation. - Implement LocalUploader/LocalIndexer/PostUploadHook/PostDeleteHook on the alpine provider, keeping the remote proxy methods intact. - Parse .apk (concatenated gzipped tar streams) in pure Go: read .PKGINFO from the control stream and compute the apk pull checksum C: = Q1+base64(sha1) over the raw control gzip stream (not the whole file). - Generate an unsigned per-arch APKINDEX.tar.gz (clients use --allow-untrusted), applying the same dot-segment normalization as deb for ./<arch>/... requests. - Add AlpineMetadata plus separate Alpine store/reader/deleter interfaces so the rpm/deb metadata interfaces are not widened. - Add the alpine_metadata table and its Insert/Delete/List DB methods. - Add testsupport.MinimalApk plus unit tests (parse, Q1 checksum, per-arch filtering, dot-segment handling, validate) and a dockere2e index test.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package testsupport
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MinimalApk builds a valid-enough Alpine package in pure Go (no committed
|
||||
// binary fixture, no abuild): two concatenated, independently gzipped tar
|
||||
// streams -- a control stream carrying .PKGINFO and a data stream carrying a
|
||||
// single payload file. It mirrors MinimalDeb/MinimalRPM and is parseable by the
|
||||
// alpine provider (which derives arch/name/version and the Q1 pull checksum from
|
||||
// the control stream).
|
||||
func MinimalApk(name, version, arch string) []byte {
|
||||
pkginfo := fmt.Sprintf(
|
||||
"# generated by testsupport\n"+
|
||||
"pkgname = %s\n"+
|
||||
"pkgver = %s\n"+
|
||||
"arch = %s\n"+
|
||||
"pkgdesc = minimal test package\n"+
|
||||
"url = https://example.com/%s\n"+
|
||||
"license = MIT\n"+
|
||||
"origin = %s\n"+
|
||||
"maintainer = e2e <e2e@example.com>\n"+
|
||||
"builddate = 1700000000\n"+
|
||||
"size = 4\n"+
|
||||
"depend = so:libc.musl-x86_64.so.1\n"+
|
||||
"provides = cmd:%s=%s\n",
|
||||
name, version, arch, name, name, name, version)
|
||||
|
||||
control := gzipBytes(tarSingle(".PKGINFO", []byte(pkginfo)))
|
||||
data := gzipBytes(tarSingle("usr/bin/"+name, []byte("body")))
|
||||
|
||||
var buf bytes.Buffer
|
||||
buf.Write(control)
|
||||
buf.Write(data)
|
||||
return buf.Bytes()
|
||||
}
|
||||
Reference in New Issue
Block a user