Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: melange package: create a package from a directory #1307

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented Jun 18, 2024

$ go run ./ package examples --name=test --version=1.2.3 --description="this is a test" --arch=x86_64,aarch64,ppc64le
2024/06/18 10:49:07 INFO Data hash: 7a7944a06f0a7269c41b5e51d4cb1f511966152de360031971610c343c657f09
2024/06/18 10:49:07 INFO Creating package packages/x86_64/test-1.2.3-r0.apk arch=x86_64
2024/06/18 10:49:07 INFO Creating package packages/aarch64/test-1.2.3-r0.apk arch=aarch64
2024/06/18 10:49:07 INFO Creating package packages/ppc64le/test-1.2.3-r0.apk arch=ppc64le
$ tar -Oxf packages/aarch64/test-1.2.3-r0.apk .PKGINFO                                                               
# Generated by melange
pkgname = test
pkgver = 1.2.3-r0
arch = aarch64
size = 61952
origin = test
pkgdesc = this is a test
url = 
commit = 
license = PROPRIETARY
builddate = 1718722147
datahash = 7a7944a06f0a7269c41b5e51d4cb1f511966152de360031971610c343c657f09
$ tar -tvf packages/aarch64/test-1.2.3-r0.apk 
-rw-rw-rw-  0 0      0         261 Dec 31  1969 .PKGINFO
-rw-r--r--  0 0      0        1164 Jun 18 10:50 R-build.yaml
-rw-r--r--  0 0      0         766 Jun 18 10:50 aws-sdk-core.yaml
-rw-r--r--  0 0      0         842 Jun 18 10:50 build-ruby-webrick.yaml
-rw-r--r--  0 0      0        1269 Jun 18 10:50 cargo-build.yaml
-rw-r--r--  0 0      0        1320 Jun 18 10:50 conditional.yaml
-rw-r--r--  0 0      0        1292 Jun 18 10:50 git-checkout.yaml
-rw-r--r--  0 0      0         950 Jun 18 10:50 gnu-hello.yaml
-rw-r--r--  0 0      0        1051 Jun 18 10:50 go-build.yaml
-rw-r--r--  0 0      0         812 Jun 18 10:50 go-install.yaml
-rw-r--r--  0 0      0         644 Jun 18 10:50 mbedtls.yaml
-rw-r--r--  0 0      0         382 Jun 18 10:50 minimal.yaml
-rw-r--r--  0 0      0         876 Jun 18 10:50 npm-install.yaml
-rw-r--r--  0 0      0         832 Jun 18 10:50 one-arch.yaml
-rw-r--r--  0 0      0        2455 Jun 18 10:50 options.yaml
-rw-r--r--  0 0      0          91 Jun 18 10:50 pipelineless.yaml
-rw-r--r--  0 0      0         321 Jun 18 10:50 replacement-provides.yaml
drwx------  0 0      0           0 Jun 18 10:50 simple-hello
-rw-r--r--  0 0      0          83 Jun 18 10:50 simple-hello/Makefile
-rw-r--r--  0 0      0         205 Jun 18 10:50 simple-hello/hello.c
-rw-r--r--  0 0      0         551 Jun 18 10:50 simple-hello/melange.yaml
-rw-r--r--  0 0      0         823 Jun 18 10:50 sshfs.yaml
-rw-r--r--  0 0      0         601 Jun 18 10:50 var-transforms.yaml
-rw-r--r--  0 0      0         729 Jun 18 10:50 vars.yaml
-rw-r--r--  0 0      0         742 Jun 18 10:50 working-directory.yaml

Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Short: "Emit a package for the given directory, tarball or file.",
Example: `melange package <dir>`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we hoist the actual package logic somewhere public that can be called by consumers?

I don't have the full context for this change, but it seems like it'd be useful for folks (us) using melange as a library

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, definitely. Ideally this could call something like emitPackage(controlSection, dir) which is shared with the usual melange flow. That's basically where I pulled this code from, it's just not as straightforward in that code as it is here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to make all of this a little more idiomatically go...

Signed-off-by: Jason Hall <jason@chainguard.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants