{"id":20148249,"url":"https://github.com/chainguard-dev/go-apk","last_synced_at":"2025-04-09T19:52:08.590Z","repository":{"id":158061288,"uuid":"633737960","full_name":"chainguard-dev/go-apk","owner":"chainguard-dev","description":"native go library for installation and management of apk packages","archived":false,"fork":false,"pushed_at":"2024-05-28T15:47:20.000Z","size":2009,"stargazers_count":28,"open_issues_count":21,"forks_count":27,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-29T01:20:23.811Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chainguard-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-28T07:04:21.000Z","updated_at":"2024-05-30T04:47:10.899Z","dependencies_parsed_at":"2023-11-07T07:22:46.211Z","dependency_job_id":"f999cf89-7dc6-4542-a5a8-e313d5349f34","html_url":"https://github.com/chainguard-dev/go-apk","commit_stats":null,"previous_names":["chainguard-dev/apkgo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainguard-dev%2Fgo-apk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainguard-dev%2Fgo-apk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainguard-dev%2Fgo-apk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainguard-dev%2Fgo-apk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainguard-dev","download_url":"https://codeload.github.com/chainguard-dev/go-apk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103903,"owners_count":21048244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T22:36:07.783Z","updated_at":"2025-04-09T19:52:08.571Z","avatar_url":"https://github.com/chainguard-dev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-apk\n\n\u003e [!WARNING]\n\u003e This library is no longer maintained as a separate standalone package. Instead, it's been re-absorbed into [apko](https://github.com/chainguard-dev/apko).\n\n\n\nA native go implementation of the functionality of the [Alpine Package Keeper](https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper)\nclient utility `apk`.\n\nAlso includes supporting utilities for working with filesystems, including:\n\n* an interface for a fully functional [fs.FS](https://pkg.go.dev/io/fs#FS) with\nread-write, chmod/chown, devices, and symlinks capabilities\n* an implementation of that FS in memory, i.e. a memfs\n* an implementation of that FS on top of a directory, which uses the memfs for features the underlying disk does not support\n* tarball features\n\nDocumentation is available at [https://pkg.go.dev/github.com/chainguard-dev/go-apk](https://pkg.go.dev/github.com/chainguard-dev/go-apk).\n\n## Usage\n\n```go\nimport (\n    \"github.com/chainguard-dev/go-apk/pkg/apk\"\n    \"github.com/chainguard-dev/go-apk/pkg/fs\"\n)\n\nfsys := fs.NewMemFS()\na, err := apk.New(\n\t\tapk.WithFS(fsys),\n\t\tapk.WithArch(\"aarch64\"),\n\t)\na.InitDB(\"3.16\", \"3.17\") // ensure basic structures and set up the database, fetches keys for those OS versions\na.InitKeyring([]string{\"/etc/apk/keyfiles/key1\"}, nil)\na.SetRepositories([]string{\"https://dl-cdn.alpinelinux.org/alpine/v3.14/main\"})\na.SetWorld([]string{\"curl\", \"vim\"})    // set the packages in /etc/apk/world\na.FixateWorld()              // install packages based on the contents of /etc/apk/world\n```\n\nWherever possible the methods on `apk` that manipulate data are available standalone,\nso you can work with them outside of a given `FullFS`.\n\n## Components\n\n### Filesystems\n\nThe native go [fs.FS](https://pkg.go.dev/io/fs#FS) interface is a read-only filesystem\nwith no support for full capabilities like read-write, let alone symlinks, hardlinks,\nchown/chmod, devices, etc.\n\nThat makes it useful for reading, but not very useful for cases where you need to lay\ndown data, like installing packages from a package manager.\n\n`github.com/chainguard-dev/go-apk/pkg/fs` provides a `FullFS` interface that extends the\n`fs.FS` interface with full read-write, chmod/chown, devices, and symlinks capabilities.\nYou can do pretty much anything that you can do with a normal filesystem.\n\nIt is fully compliant with [fs.FS](https://pkg.go.dev/io/fs#FS), so you can use it\nanywhere an `fs.FS` is required.\n\nIt also provides two implementations of that interface:\n\n* `memfs` is an in-memory implementation of `FullFS`. It is fully functional, but remember that it uses memory, so loading very large files into it will hit limits.\n* `rwosfs` is an on-disk implementation of `FullFS`. It is fully functional, including capabilities that may not exist on the underlying filesystem, like symlinks, devices, chown/chmod and case-sensitivity. The metadata for every file on disk also is in-memory, enabling those additional capabilities. Contents are not stored in memory.\n\n### Tarball\n\n`github.com/chainguard-dev/go-apk/pkg/tarball` provides a utility to write an [fs.FS](https://pkg.go.dev/io/fs#FS) to a tarball. It is implemented on a `tarball.Context`, which lets\nyou provide overrides for timestamps, UID/GID, and other features.\n\n### apk\n\n`github.com/chainguard-dev/go-apk/pkg/apk` is the heart of this library. It provides a native go\nimplementation of the functionality of the\n[Alpine Package Keeper](https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper)\nwith regards to reading repositories, installing packages, and managing a local install.\n\n## Caching\n\nThis package provides an option to cache apk packages locally. This can provide dramatic speedups\nwhen installing packages, especially when the package is large or the network is slow and you already have a copy.\n\nIt is enabled only when the [WithCache()](./pkg/apk/options.go) option is provided to the `New()` function.\n\nWhen the cache is enabled, any requested apk files are checked in the cache first, and only downloaded\nin the case of a cache miss. The now-cached apk can be used in subsequent calls. To ignore the cache,\nsimple do not pass `WithCache()` to `New()`.\n\nSee [CACHE.md](./docs/CACHE.md) for more details on the cache structure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainguard-dev%2Fgo-apk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainguard-dev%2Fgo-apk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainguard-dev%2Fgo-apk/lists"}