Skip to content

Commit

Permalink
pkg/uroot: busybox build mode and reproducible archives.
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Koch <chrisko@google.com>
  • Loading branch information
hugelgupf committed Nov 11, 2017
1 parent 47a7e24 commit 5d26e78
Show file tree
Hide file tree
Showing 10 changed files with 517 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*.so
*~

bbsh
u-root

# Folders
_obj
_test
Expand Down
5 changes: 4 additions & 1 deletion pkg/cpio/newc/newc.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ func (r *reader) ReadRecord() (cpio.Record, error) {

content := io.NewSectionReader(r.r, r.pos, int64(hdr.FileSize))
r.pos = round4(r.pos + int64(hdr.FileSize))
return cpio.Record{cpio.NewReadCloser(content), info}, nil
return cpio.Record{
Info: info,
ReadCloser: cpio.NewReadCloser(content),
}, nil
}

func init() {
Expand Down
13 changes: 13 additions & 0 deletions pkg/cpio/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"io/ioutil"
"os"
"syscall"
"time"
)

Expand Down Expand Up @@ -43,6 +44,18 @@ func StaticRecord(contents []byte, info Info) Record {
}
}

// Symlink returns a symlink record at path pointing to target.
func Symlink(path string, target string) Record {
return Record{
ReadCloser: ioutil.NopCloser(bytes.NewReader([]byte(target))),
Info: Info{
FileSize: uint64(len(target)),
Mode: syscall.S_IFLNK | 0777,
Name: path,
},
}
}

func NewBytesReadCloser(contents []byte) io.ReadCloser {
return ioutil.NopCloser(bytes.NewReader(contents))
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/golang/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"go/build"
"os"
"os/exec"
"path/filepath"
"strings"
)

Expand All @@ -22,7 +23,11 @@ func Default() Environ {
// This currently assumes that packages are named after the directory they are
// in.
func (c Environ) FindPackageByPath(path string) (string, error) {
p, err := c.Context.ImportDir(path, 0)
abs, err := filepath.Abs(path)
if err != nil {
return "", err
}
p, err := c.Context.ImportDir(abs, 0)
if err != nil {
return "", fmt.Errorf("failed to find package in %q: %v", path, err)
}
Expand Down
Loading

0 comments on commit 5d26e78

Please sign in to comment.