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 \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() }