From de48a5ac9c9c814c5870d9a52c2ff55607a8b1fa Mon Sep 17 00:00:00 2001
From: Alexander Neumann <alexander@bumpern.de>
Date: Mon, 29 May 2017 23:27:25 +0200
Subject: [PATCH 1/2] build.go: Strip temporary path, allow reproducible builds

---
 build.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/build.go b/build.go
index adf188f38..b6fd2ad8d 100644
--- a/build.go
+++ b/build.go
@@ -195,8 +195,11 @@ func cleanEnv() (env []string) {
 
 // build runs "go build args..." with GOPATH set to gopath.
 func build(cwd, goos, goarch, gopath string, args ...string) error {
-	args = append([]string{"build"}, args...)
-	cmd := exec.Command("go", args...)
+	a := []string{"build"}
+	a = append(a, "-asmflags", fmt.Sprintf("-trimpath=%s", gopath))
+	a = append(a, "-gcflags", fmt.Sprintf("-trimpath=%s", gopath))
+	a = append(a, args...)
+	cmd := exec.Command("go", a...)
 	cmd.Env = append(cleanEnv(), "GOPATH="+gopath, "GOARCH="+goarch, "GOOS="+goos)
 	if !enableCGO {
 		cmd.Env = append(cmd.Env, "CGO_ENABLED=0")

From ed91cafce2a3264b1b33e742648facca6c0bdf8f Mon Sep 17 00:00:00 2001
From: Alexander Neumann <alexander@bumpern.de>
Date: Mon, 29 May 2017 23:46:48 +0200
Subject: [PATCH 2/2] Add entry to CHANGELOG

---
 CHANGELOG.md | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32aa08892..5586c00cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,10 @@ Small changes:
    reporting the current status by sending a `USR1` signal to the process.
    https://github.com/restic/restic/pull/974
 
+ * The `build.go` now strips the temporary directory used for compilation from
+   the binary. This is the first step in enabling reproducible builds.
+   https://github.com/restic/restic/pull/981
+
 Important Changes in 0.6.0
 ==========================