aboutsummaryrefslogtreecommitdiffstats
path: root/internal/build/util.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-10-01 04:03:08 +0800
committerFelix Lange <fjl@twurst.com>2016-10-02 19:08:56 +0800
commit4f7627972e4997965be6f3c406904ef613e14c20 (patch)
tree0d4e7f9ce56a2d161aa8408523d15cf95f0086d2 /internal/build/util.go
parentd8715fba1a366944a069397775fc52a30358eff3 (diff)
downloadgo-tangerine-4f7627972e4997965be6f3c406904ef613e14c20.tar
go-tangerine-4f7627972e4997965be6f3c406904ef613e14c20.tar.gz
go-tangerine-4f7627972e4997965be6f3c406904ef613e14c20.tar.bz2
go-tangerine-4f7627972e4997965be6f3c406904ef613e14c20.tar.lz
go-tangerine-4f7627972e4997965be6f3c406904ef613e14c20.tar.xz
go-tangerine-4f7627972e4997965be6f3c406904ef613e14c20.tar.zst
go-tangerine-4f7627972e4997965be6f3c406904ef613e14c20.zip
build: improve debian packaging
This commit tweaks the debian packaging tool: * All build environment metadata can now be overriden on the command line. This allows testing the CI build behaviour locally. * -unstable packages now actually contain the binaries (oops) * packages use Go 1.7 to build * archiving is skipped for PR builds
Diffstat (limited to 'internal/build/util.go')
-rw-r--r--internal/build/util.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/internal/build/util.go b/internal/build/util.go
index eead824b2..be41efed7 100644
--- a/internal/build/util.go
+++ b/internal/build/util.go
@@ -29,9 +29,7 @@ import (
"text/template"
)
-var (
- DryRunFlag = flag.Bool("n", false, "dry run, don't execute commands")
-)
+var DryRunFlag = flag.Bool("n", false, "dry run, don't execute commands")
// MustRun executes the given command and exits the host process for
// any error.
@@ -69,6 +67,7 @@ func GOPATH() string {
return strings.Join(newpath, string(filepath.ListSeparator))
}
+// VERSION returns the content of the VERSION file.
func VERSION() string {
version, err := ioutil.ReadFile("VERSION")
if err != nil {
@@ -77,10 +76,8 @@ func VERSION() string {
return string(bytes.TrimSpace(version))
}
-func GitCommit() string {
- return RunGit("rev-parse", "HEAD")
-}
-
+// RunGit runs a git subcommand and returns its output.
+// The command must complete successfully.
func RunGit(args ...string) string {
cmd := exec.Command("git", args...)
var stdout, stderr bytes.Buffer
@@ -94,12 +91,13 @@ func RunGit(args ...string) string {
return strings.TrimSpace(stdout.String())
}
-// Render renders the given template file.
+// Render renders the given template file into outputFile.
func Render(templateFile, outputFile string, outputPerm os.FileMode, x interface{}) {
tpl := template.Must(template.ParseFiles(templateFile))
render(tpl, outputFile, outputPerm, x)
}
+// RenderString renders the given template string into outputFile.
func RenderString(templateContent, outputFile string, outputPerm os.FileMode, x interface{}) {
tpl := template.Must(template.New("").Parse(templateContent))
render(tpl, outputFile, outputPerm, x)