- .chainguard
- .github
- config
- docs
- examples
- hack
-
internal
-
cli
-
testdata
-
base_image
-
blobs
-
sha256
- 2580c204e7b254c8988c5cd1840cd58246afafb2479190b6cb3f448341003a5f
- 2ef91a9967f2e1759ea49a8c01cf6a45dd9f9af71fe09bcf2b86175bc4a71314
- 583625b6164fff3b017f62b9fcd60cb53fff18a7e89ee538212134a13fc29fb1
- 5a99438a9ced8193f1d71209d0b558fdc0b184aee5cf258e5f7aa9a6ab0f0671
- 65eba664f408f8a2b2cf6b190255c8b0e8cb16a85d773089ae184ac35d782464
- bf74ddaf55d32ec9672a0a40efc6cb1bf0a167763c18fc22586c8a301167822f
-
sha256
- metadata
- sboms
- index.json
- oci-layout
-
blobs
-
golden
-
blobs
-
sha256
- 18d41b1f595d19375dc45a14f87f64e736d577e618fc77707bb710a8e59842b1
- 26344c4399ce8d47eed8a16da31044b45634ab26a8e43493574a7c944ca35328
- 41b285b4a6870e47e59ef34f87d3637a202783f535d70d0152c53d80f57c90a2
- 5398671bcb1dc210cfb253a808be94fff70723d939d7ce6d8053a823f4720d57
- c4fba92e353f8a3be76c9feaa4763c3f9177697364fe54943eda3f51ec641d55
- e29f907eae193b71f82232ac873a7f2bbe3d5e3b841c729b6a58706750f01ce0
-
sha256
- sboms
- index.json
- oci-layout
-
blobs
- packages
- private_packages
-
top_image
-
blobs
-
sha256
- 149f310693ee8812c28e4e23ee1bf0b35141ac2c19e1a665ff5baadb3fd8a68e
- 1b8f0b6e368cf22d86aaeb2181defed3ffe4bed0383d7acf05b8850881b60a10
- 583625b6164fff3b017f62b9fcd60cb53fff18a7e89ee538212134a13fc29fb1
- 68daf87e56a0a846927c0535c9beaa4d90b7500739d79766b757b8253e7c84d7
- 97502a24c34c7cd4d1c3f29dbba3b123c4da15d2bd3bbe723bfddb949713342a
- a54af7ae5da36e1d6feaf559438cd1b84a27223cd4518f4c875de82bcdc31017
- bf74ddaf55d32ec9672a0a40efc6cb1bf0a167763c18fc22586c8a301167822f
- d509688b2e26be6f4c6e8eb1f8e3f1f1cc563712dfa095cc461d5c37a29057b0
-
sha256
- index.json
- oci-layout
-
blobs
- apko.lock.json
- apko.pre-0.13.lock.json
- apko.yaml
- base_image.apko.yaml
- image_on_top.apko.lock.json
- image_on_top.apko.yaml
- melange.rsa
- melange.rsa.pub
- pretend-baselayout.melange.yaml
- replayout.melange.yaml
-
base_image
- build-cpio.go
- build-minirootfs.go
- build.go
- build_test.go
- commands.go
- dot.go
- install-keys.go
- lock.go
- lock_test.go
- options.go
- publish.go
- publish_test.go
- show-config.go
- show-packages.go
-
testdata
- gen-jsonschema
- tools.go
-
cli
-
pkg
-
apk
-
apk
- testdata
- apkindex.go
- apkindex_test.go
- arch.go
- cache.go
- common.go
- common_test.go
- common_test_nonunix.go
- common_test_unix.go
- const.go
- errors.go
- executor.go
- implementation.go
- implementation_test.go
- index.go
- install.go
- install_test.go
- installed.go
- installed_test.go
- options.go
- package.go
- package_test.go
- releases.go
- repo.go
- repo_test.go
- repository.go
- repository_test.go
- resolveapk.go
- shameful_global_caches.go
- transport.go
- transport_test.go
- util.go
- version.go
- version_test.go
- world.go
- world_test.go
- auth
- client
- docs
- expandapk
- fs
- internal
- passwd
- signature
- tarball
- README.md
-
apk
- baseimg
- build
- cpio
- lock
- options
- passwd
- paths
- s6
- sbom
- tarfs
- vcs
- vfs
-
apk
- .editorconfig
- .gitignore
- .golangci.yml
- .goreleaser.yaml
- .ko.yaml
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- LICENSE
- Makefile
- NEWS.md
- README.md
- apk.md
- go.mod
- go.sum
- header.tmpl
- main.go
- release.md
Explanation
This code generates a Go file with a map of Busybox applets available for different versions. It uses the Busybox Git repository to extract the applets and their locations.
Here’s a breakdown:
- Initialization:
- Defines constants for the Busybox Git repository URL and regex patterns for identifying applets and versions.
- Defines a template for the generated Go file.
- Main Function:
- Takes arguments for the target package, base version, and output file (or stdout if “-“).
- Calls
getBusyboxApplets
to fetch applets for versions greater than the base version. - Populates the template with the applets, the highest version found, and timestamps.
- Executes the template to generate the Go file.
getBusyboxApplets
:
- Clones the Busybox Git repository to a temporary directory.
- Retrieves all tags (versions) using
getBusyboxVersions
. - Iterates through the tags and retrieves applets for each version using
getBusyboxAppletsForVersion
.
getBusyboxVersions
:
- Iterates over all tags in the repository.
- Extracts version numbers from tags using the
semverDashRegex
. - Filters out tags that don’t match semver or are lower than the base version.
getBusyboxAppletsForVersion
:
- Checks out the specified version in the repository.
- Uses
tree.Grep
to find lines containing applet information in C files. - Extracts applet names and paths from those lines using
appletLineToFullPath
.
semverLess
:
- Compares two semver versions and returns
true
if the first version is less than the second.
appletLineToFullPath
:
- Extracts the applet’s full path from the matched line by converting the BB_DIR_
highestVersion
:
- Iterates through the list of versions and returns the highest version.
Key Points:
- The code uses the
git
package to interact with the Git repository. - It uses regex patterns to parse information from the Git repository files.
- The
versionsTemplate
is used to generate the Go code containing a map of applets for each version. - The
highestVersion
function is used to determine the default version to be used.
This code provides a way to easily get information about the applets available in different Busybox versions and can be used in other tools to generate dependencies or other metadata based on the available applets.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph