release/dist/qnap: add qnap target builder

Creates new QNAP builder target, which builds go binaries then uses
docker to build into QNAP packages. Much of the docker/script code
here is pulled over from https://github.com/tailscale/tailscale-qpkg,
with adaptation into our builder structures.

The qnap/Tailscale folder contains static resources needed to build
Tailscale qpkg packages, and is an exact copy of the existing folder
in the tailscale-qpkg repo.

Builds can be run with:
```
sudo ./tool/go run ./cmd/dist build qnap
```

Updates tailscale/tailscale-qpkg#135

Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
This commit is contained in:
Sonia Appasamy
2024-04-22 16:42:01 -04:00
committed by Sonia Appasamy
parent b743b85dad
commit 0a84215036
17 changed files with 658 additions and 3 deletions

16
release/dist/dist.go vendored
View File

@@ -88,6 +88,8 @@ type Build struct {
// number of CPU cores, which empirically keeps the builder responsive
// without impacting overall build time.
goBuildLimit chan struct{}
onCloseFuncs []func() error // funcs to be called when Builder is closed
}
// NewBuild creates a new Build rooted at repo, and writing artifacts to out.
@@ -126,9 +128,19 @@ func NewBuild(repo, out string) (*Build, error) {
return b, nil
}
// Close ends the build and cleans up temporary files.
func (b *Build) AddOnCloseFunc(f func() error) {
b.onCloseFuncs = append(b.onCloseFuncs, f)
}
// Close ends the build, cleans up temporary files,
// and runs any onCloseFuncs.
func (b *Build) Close() error {
return os.RemoveAll(b.Tmp)
var errs []error
errs = append(errs, os.RemoveAll(b.Tmp))
for _, f := range b.onCloseFuncs {
errs = append(errs, f())
}
return errors.Join(errs...)
}
// Build builds all targets concurrently.