2023-02-24 22:19:13 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2023-02-24 21:22:21 +00:00
|
|
|
package unixpkgs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"tailscale.com/release/dist"
|
|
|
|
|
2023-08-03 20:00:45 +00:00
|
|
|
_ "github.com/goreleaser/nfpm/v2/deb"
|
|
|
|
_ "github.com/goreleaser/nfpm/v2/rpm"
|
2023-02-24 21:22:21 +00:00
|
|
|
)
|
|
|
|
|
2023-08-03 22:27:06 +00:00
|
|
|
type Signers struct {
|
2023-08-24 21:36:47 +00:00
|
|
|
Tarball dist.Signer
|
|
|
|
RPM dist.Signer
|
2023-08-03 22:27:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Targets(signers Signers) []dist.Target {
|
2023-02-24 21:22:21 +00:00
|
|
|
var ret []dist.Target
|
|
|
|
for goosgoarch := range tarballs {
|
|
|
|
goos, goarch := splitGoosGoarch(goosgoarch)
|
|
|
|
ret = append(ret, &tgzTarget{
|
2023-08-03 22:27:06 +00:00
|
|
|
goEnv: map[string]string{
|
2023-02-24 21:22:21 +00:00
|
|
|
"GOOS": goos,
|
|
|
|
"GOARCH": goarch,
|
|
|
|
},
|
2023-08-03 22:27:06 +00:00
|
|
|
signer: signers.Tarball,
|
2023-02-24 21:22:21 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
for goosgoarch := range debs {
|
|
|
|
goos, goarch := splitGoosGoarch(goosgoarch)
|
|
|
|
ret = append(ret, &debTarget{
|
2023-08-03 22:27:06 +00:00
|
|
|
goEnv: map[string]string{
|
2023-02-24 21:22:21 +00:00
|
|
|
"GOOS": goos,
|
|
|
|
"GOARCH": goarch,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
for goosgoarch := range rpms {
|
|
|
|
goos, goarch := splitGoosGoarch(goosgoarch)
|
|
|
|
ret = append(ret, &rpmTarget{
|
2023-08-03 22:27:06 +00:00
|
|
|
goEnv: map[string]string{
|
2023-02-24 21:22:21 +00:00
|
|
|
"GOOS": goos,
|
|
|
|
"GOARCH": goarch,
|
|
|
|
},
|
2023-08-24 21:36:47 +00:00
|
|
|
signer: signers.RPM,
|
2023-02-24 21:22:21 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special case: AMD Geode is 386 with softfloat. Tarballs only since it's
|
|
|
|
// an ancient architecture.
|
|
|
|
ret = append(ret, &tgzTarget{
|
|
|
|
filenameArch: "geode",
|
2023-08-03 22:27:06 +00:00
|
|
|
goEnv: map[string]string{
|
2023-02-24 21:22:21 +00:00
|
|
|
"GOOS": "linux",
|
|
|
|
"GOARCH": "386",
|
|
|
|
"GO386": "softfloat",
|
|
|
|
},
|
2023-08-03 22:27:06 +00:00
|
|
|
signer: signers.Tarball,
|
2023-02-24 21:22:21 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
sort.Slice(ret, func(i, j int) bool {
|
|
|
|
return ret[i].String() < ret[j].String()
|
|
|
|
})
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
tarballs = map[string]bool{
|
|
|
|
"linux/386": true,
|
|
|
|
"linux/amd64": true,
|
|
|
|
"linux/arm": true,
|
|
|
|
"linux/arm64": true,
|
|
|
|
"linux/mips64": true,
|
|
|
|
"linux/mips64le": true,
|
|
|
|
"linux/mips": true,
|
|
|
|
"linux/mipsle": true,
|
|
|
|
"linux/riscv64": true,
|
|
|
|
// TODO: more tarballs we could distribute, but don't currently. Leaving
|
|
|
|
// out for initial parity with redo.
|
|
|
|
// "darwin/amd64": true,
|
|
|
|
// "darwin/arm64": true,
|
|
|
|
// "freebsd/amd64": true,
|
|
|
|
// "openbsd/amd64": true,
|
|
|
|
}
|
|
|
|
|
|
|
|
debs = map[string]bool{
|
2023-05-09 09:09:55 +00:00
|
|
|
"linux/386": true,
|
|
|
|
"linux/amd64": true,
|
|
|
|
"linux/arm": true,
|
|
|
|
"linux/arm64": true,
|
|
|
|
"linux/riscv64": true,
|
|
|
|
"linux/mipsle": true,
|
|
|
|
"linux/mips64le": true,
|
|
|
|
"linux/mips": true,
|
|
|
|
// Debian does not support big endian mips64. Leave that out until we know
|
|
|
|
// we need it.
|
2023-02-24 21:22:21 +00:00
|
|
|
// "linux/mips64": true,
|
|
|
|
}
|
|
|
|
|
|
|
|
rpms = map[string]bool{
|
2023-05-09 09:09:55 +00:00
|
|
|
"linux/386": true,
|
|
|
|
"linux/amd64": true,
|
|
|
|
"linux/arm": true,
|
|
|
|
"linux/arm64": true,
|
|
|
|
"linux/riscv64": true,
|
|
|
|
"linux/mipsle": true,
|
|
|
|
"linux/mips64le": true,
|
|
|
|
// Fedora only supports little endian mipses. Maybe some other distribution
|
|
|
|
// supports big-endian? Leave them out for now.
|
2023-02-24 21:22:21 +00:00
|
|
|
// "linux/mips": true,
|
|
|
|
// "linux/mips64": true,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func splitGoosGoarch(s string) (string, string) {
|
|
|
|
goos, goarch, ok := strings.Cut(s, "/")
|
|
|
|
if !ok {
|
|
|
|
panic(fmt.Sprintf("invalid target %q", s))
|
|
|
|
}
|
|
|
|
return goos, goarch
|
|
|
|
}
|