Add Alpine/apk local repository support #114
Reference in New Issue
Block a user
Delete Branch "benvin/apk-local"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The alpine provider only supported remote (proxy) repositories, so there was no way to publish first-party
.apkpackages the wayrpm-localanddeb-localalready allow. This extends the existing alpine provider into a real apk repository: uploaded.apkfiles are parsed in pure Go and a per-archAPKINDEX.tar.gzis generated on demand, at parity with rpm repodata and deb Packages generation. (The metadata-onlygithub_alpinetype is a separate follow-up and is not part of this PR.)How
LocalUploader/LocalIndexer/PostUploadHook/PostDeleteHookon the existingalpineprovider, leaving the remote proxy methods (UpstreamURL/ContentType/AuthHeaders/RewriteResponse/Classify) intact..apk(up to three concatenated, independently gzipped tar streams) in pure Go: locates the control stream by its.PKGINFOmember, reads thekey = valuefields, and computes the apk pull checksumC:=Q1+ base64(sha1(control gzip stream bytes)) — the sha1 of the second gzip member, not of the whole file..PKGINFOand records download size (S:blob size) and installed size (I:from.PKGINFO size).APKINDEX.tar.gz= gzip(tar(APKINDEX)) filtered by requested arch (clients use--allow-untrusted, matching rpmgpgcheck=0/ deb[trusted=yes]), applying the same dot-segment normalization as deb so./<arch>/APKINDEX.tar.gzresolves. Non-index /.apkpaths returnfalseso the generic file streamer serves the stored blob.AlpineMetadataplus separateAlpineMetadataStore/AlpineMetadataReader/AlpineMetadataDeleterinterfaces (type-asserted from the generic hooks) so the shared rpm/deb metadata interfaces and their test doubles are untouched.alpine_metadatatable (keyed byrepo_name+file_path, per-arch index) and itsInsert/Delete/ListDB methods.testsupport.MinimalApk, unit tests (.PKGINFOparse, Q1 checksum over the control stream, per-arch filtering, empty-field omission,./dot-segment handling, ValidateUpload accept/reject), and adockere2eTestLocalAlpineIndex.Consumption
/etc/apk/repositoriesline =<url>/api/v1/local/<name>(apk appends/<arch>/APKINDEX.tar.gz);apk update --allow-untrusted && apk add --allow-untrusted <pkg>. Packages live at/api/v1/local/<name>/<arch>/<file>.apk.Verification
go build ./...,go vet ./...(incl.-tags dockere2e),go mod tidy(no change),make test(-race), andpre-commit run --all-filesall pass.