tinyrange / pkg2

Package Metadata Database
https://pkg2.thrush-map.ts.net/
Apache License 2.0
2 stars 0 forks source link

Add OCI compatible registry. #3

Open Vbitz opened 1 month ago

Vbitz commented 1 month ago

Part of the long-term idea for pkg2 is to support directly installing collections of packages without using the original package managers.

This is already partially supported inside TinyRange with the -trplan option used to test this. That existing code has TinyRange extract the package. This is already partially supported with Alpine and Arch Linux in TinyRange.

Besides just supporting this inside TinyRange the idea came to have pkg2 implement a OCI compatible registry. The basic idea is each package is an independent archive that can be expressed as a layer in a OCI image. A minimal bit of code added to pkg2 could generate a manifest using these layers which could used a container base image.

There are a few tasks to implement this.

The initial version will probably only support Alpine (APK) packages.

One unsolved issue is changing the "directory" the archive is extracted to. This is possible by using image-specific blobs but that will be computationally expensive to compute hashes for.

Special thanks to @emilytrau for the original idea.

Vbitz commented 1 month ago

This commit adds the ability to add archives to the cache. https://github.com/tinyrange/pkg2/commit/40b22275a150651f9cffecd2b4ac63f3219976ef

It also adds a optimised builder system with customisable tagging.

It still needs support for permissions and pulling from existing archives to be called "modified archives" though.

Vbitz commented 1 month ago

In the latest version there's now a demo of constructing valid docker images.

https://github.com/tinyrange/pkg2/blob/e70083652571a33c7970779b9ec2f1e7b7fc7523/scripts/make_docker_image.star

It can be tested with...

go run . -script scripts/make_docker_image.star -allowLocal
cp local/cache/managedCache/90616f53b228cf7ac7d6a261069a1ffb159b5f5cf77b7387c91b17c1d85fc186_1.bin gcc.tar
docker load -i gcc.tar

Then the image can be used with roughly this Dockerfile.

FROM pkg2/gcc:latest

RUN /.pkg/install.sh