forked from TrueCloudLab/restic
helpers: Use version string in built binaries
This commit is contained in:
parent
c5ec4efe91
commit
a5b40e9372
2 changed files with 12 additions and 3 deletions
|
@ -17,12 +17,14 @@ var opts = struct {
|
||||||
Verbose bool
|
Verbose bool
|
||||||
SourceDir string
|
SourceDir string
|
||||||
OutputDir string
|
OutputDir string
|
||||||
|
Version string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pflag.BoolVarP(&opts.Verbose, "verbose", "v", false, "be verbose")
|
pflag.BoolVarP(&opts.Verbose, "verbose", "v", false, "be verbose")
|
||||||
pflag.StringVarP(&opts.SourceDir, "source", "s", "/restic", "path to the source code `directory`")
|
pflag.StringVarP(&opts.SourceDir, "source", "s", "/restic", "path to the source code `directory`")
|
||||||
pflag.StringVarP(&opts.OutputDir, "output", "o", "/output", "path to the output `directory`")
|
pflag.StringVarP(&opts.OutputDir, "output", "o", "/output", "path to the output `directory`")
|
||||||
|
pflag.StringVar(&opts.Version, "version", "", "use `x.y.z` as the version for output files")
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +110,11 @@ func abs(dir string) string {
|
||||||
|
|
||||||
func build(sourceDir, outputDir, goos, goarch string) (filename string) {
|
func build(sourceDir, outputDir, goos, goarch string) (filename string) {
|
||||||
filename = fmt.Sprintf("%v_%v_%v", "restic", goos, goarch)
|
filename = fmt.Sprintf("%v_%v_%v", "restic", goos, goarch)
|
||||||
|
|
||||||
|
if opts.Version != "" {
|
||||||
|
filename = fmt.Sprintf("%v_%v_%v_%v", "restic", opts.Version, goos, goarch)
|
||||||
|
}
|
||||||
|
|
||||||
if goos == "windows" {
|
if goos == "windows" {
|
||||||
filename += ".exe"
|
filename += ".exe"
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,12 +339,14 @@ func extractTar(filename, outputDir string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBuild(sourceDir, outputDir string) {
|
func runBuild(sourceDir, outputDir, version string) {
|
||||||
msg("building binaries...")
|
msg("building binaries...")
|
||||||
run("docker", "run", "--rm",
|
run("docker", "run", "--rm",
|
||||||
"--volume", sourceDir+":/restic",
|
"--volume", sourceDir+":/restic",
|
||||||
"--volume", outputDir+":/output",
|
"--volume", outputDir+":/output",
|
||||||
"restic/builder")
|
"restic/builder",
|
||||||
|
"go", "run", "-mod=vendor", "helpers/build-release-binaries/main.go",
|
||||||
|
"--version", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readdir(dir string) []string {
|
func readdir(dir string) []string {
|
||||||
|
@ -443,7 +445,7 @@ func main() {
|
||||||
exportTar(opts.Version, tarFilename)
|
exportTar(opts.Version, tarFilename)
|
||||||
|
|
||||||
extractTar(tarFilename, sourceDir)
|
extractTar(tarFilename, sourceDir)
|
||||||
runBuild(sourceDir, opts.OutputDir)
|
runBuild(sourceDir, opts.OutputDir, opts.Version)
|
||||||
rmdir(sourceDir)
|
rmdir(sourceDir)
|
||||||
|
|
||||||
sha256sums(opts.OutputDir, filepath.Join(opts.OutputDir, "SHA256SUMS"))
|
sha256sums(opts.OutputDir, filepath.Join(opts.OutputDir, "SHA256SUMS"))
|
||||||
|
|
Loading…
Reference in a new issue