-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial support for installing debian packages
- Loading branch information
Showing
24 changed files
with
1,165 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.tar filter=lfs diff=lfs merge=lfs -text | ||
*.apk filter=lfs diff=lfs merge=lfs -text | ||
*.ar filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## This file is a standard image that | ||
# installs a single Debian package. | ||
apiVersion: ayb.dcas.dev/v1 | ||
kind: Build | ||
metadata: | ||
name: my-base-image | ||
spec: | ||
from: debian:bullseye | ||
repositories: | ||
debian: | ||
- url: https://mirror.aarnet.edu.au/pub/debian bullseye main | ||
packages: | ||
- type: Debian | ||
names: | ||
- git | ||
entrypoint: | ||
- /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package archiveutil | ||
|
||
import ( | ||
"context" | ||
"github.com/blakesmith/ar" | ||
"github.com/chainguard-dev/go-apk/pkg/fs" | ||
"github.com/go-logr/logr" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// Unar expands an ar archive into the given path. | ||
func Unar(ctx context.Context, r io.Reader, rootfs fs.FullFS) error { | ||
log := logr.FromContextOrDiscard(ctx) | ||
tr := ar.NewReader(r) | ||
|
||
for { | ||
header, err := tr.Next() | ||
switch { | ||
case err == io.EOF: | ||
return nil | ||
case err != nil: | ||
log.Error(err, "failed to read file from archive") | ||
return err | ||
case header == nil: | ||
continue | ||
} | ||
|
||
target := filepath.Clean("/" + header.Name) | ||
|
||
log.V(5).Info("creating file", "target", target, "mode", header.Mode) | ||
f, err := rootfs.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode)) | ||
if err != nil { | ||
log.Error(err, "failed to open file", "target", target) | ||
return err | ||
} | ||
|
||
if _, err := io.Copy(f, tr); err != nil { | ||
log.Error(err, "failed to extract file", "target", target) | ||
_ = f.Close() | ||
return err | ||
} | ||
_ = f.Close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package archiveutil | ||
|
||
import ( | ||
"context" | ||
"github.com/chainguard-dev/go-apk/pkg/fs" | ||
"github.com/go-logr/logr" | ||
"github.com/go-logr/logr/testr" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestUnar(t *testing.T) { | ||
ctx := logr.NewContext(context.TODO(), testr.NewWithOptions(t, testr.Options{Verbosity: 10})) | ||
|
||
rootfs := fs.NewMemFS() | ||
|
||
f, err := os.Open("./testdata/test.ar") | ||
require.NoError(t, err) | ||
defer f.Close() | ||
|
||
err = Unar(ctx, f, rootfs) | ||
assert.NoError(t, err) | ||
|
||
_, err = rootfs.Stat("test.txt") | ||
assert.NotErrorIs(t, err, os.ErrNotExist) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.deb filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
test.tar: | ||
tar -cf test.tar test.txt test-symbolic.txt | ||
|
||
test.ar: | ||
ar rsv test.ar test.txt |
Git LFS file not shown
Oops, something went wrong.