Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #98 from bpicode/Issue_93-reproducible_builds
Browse files Browse the repository at this point in the history
Issue #93: reproducible builds
  • Loading branch information
bpicode authored Oct 30, 2017
2 parents 03f95ac + a3c16fb commit 1ea0bf8
Show file tree
Hide file tree
Showing 1,322 changed files with 716,971 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .bettercodehub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
component_depth: 1
languages:
- go
exclude:
- /vendor/.*
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ _testmain.go
*.prof

# build folder
build

# vendor folder
vendor
/build

# IDE settings
.idea
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ build:
artifacts:
name: fritzctl_v1.4.16_all
paths:
- ./build/distributions/*.deb
- ./build/distributions/*.rpm
- ./build/distributions/*.zip
- ./build/distributions/fritzctl*
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ go:
go_import_path: github.com/bpicode/fritzctl

script:
- export FRITZCTL_VERSION=0.0.1-unofficial-ci-travis
- make clean all
- make clean all dist_all

after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
57 changes: 30 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH)))
PKGS := $(shell go list ./...)
GOFILES_NOVENDOR := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
FRITZCTL_VERSION ?= unknown
FRITZCTL_OUTPUT ?= fritzctl
BASH_COMPLETION_OUTPUT ?= "os/completion/fritzctl"
MAN_PAGE_OUTPUT ?= "os/man/fritzctl.1"
FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH)))
PKGS := $(shell go list ./...)
GOFILES_NOVENDOR := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
FRITZCTL_VERSION ?= unknown
FRITZCTL_OUTPUT ?= fritzctl
BASH_COMPLETION_OUTPUT ?= "os/completion/fritzctl"
MAN_PAGE_OUTPUT ?= "os/man/fritzctl.1"
DEPENDENCIES_GRAPH_OUTPUT ?= "dependencies.png"
LDFLAGS := --ldflags "-X github.com/bpicode/fritzctl/config.Version=$(FRITZCTL_VERSION)"
TESTFLAGS ?=
BUILDFLAGS := -ldflags="-s -w -X github.com/bpicode/fritzctl/config.Version=$(FRITZCTL_VERSION)" -gcflags="-trimpath=$(GOPATH)" -asmflags="-trimpath=$(GOPATH)"
TESTFLAGS ?=

all: sysinfo deps build install test codequality completion_bash man

Expand All @@ -23,12 +23,16 @@ sysinfo:
@echo ">> SYSTEM INFORMATION"
@echo -n " PLATFORM: $(shell uname -a)"
@$(call ok)
@echo -n " PWD: : $(shell pwd)"
@$(call ok)
@echo -n " GO : $(shell go version)"
@$(call ok)
@echo -n " BUILDFLAGS: $(BUILDFLAGS)"
@$(call ok)

clean:
@echo -n ">> CLEAN"
@go clean
@go clean -i
@rm -f ./os/completion/fritzctl
@rm -f ./os/man/*.gz
@rm -f ./coverage-all.html
Expand All @@ -54,20 +58,20 @@ depgraph: deps

build:
@echo -n ">> BUILD, version = $(FRITZCTL_VERSION), output = $(FRITZCTL_OUTPUT)"
@go build -o $(FRITZCTL_OUTPUT) $(LDFLAGS)
@go build -o $(FRITZCTL_OUTPUT) $(BUILDFLAGS)
@$(call ok)

install:
@echo -n ">> INSTALL, version = $(FRITZCTL_VERSION)"
@go install $(LDFLAGS)
@go install $(BUILDFLAGS)
@$(call ok)

test: build
@echo ">> TEST, \"full-mode\": race detector on"
@echo "mode: count" > coverage-all.out
@$(foreach pkg, $(PKGS),\
echo -n " ";\
go test $(LDFLAGS) $(TESTFLAGS) -race -coverprofile=coverage.out -covermode=atomic $(pkg) || exit 1;\
go test $(BUILDFLAGS) $(TESTFLAGS) -race -coverprofile=coverage.out -covermode=atomic $(pkg) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
@go tool cover -html=coverage-all.out -o coverage-all.html

Expand All @@ -76,7 +80,7 @@ fasttest: build
@echo "mode: count" > coverage-all.out
@$(foreach pkg, $(PKGS),\
echo -n " ";\
go test $(LDFLAGS) $(TESTFLAGS) -coverprofile=coverage.out $(pkg) || exit 1;\
go test $(BUILDFLAGS) $(TESTFLAGS) -coverprofile=coverage.out $(pkg) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
@go tool cover -html=coverage-all.out

Expand Down Expand Up @@ -138,24 +142,23 @@ codequality:

dist_all: dist_linux dist_darwin dist_win

dist_darwin:
@echo -n ">> BUILD, darwin/amd64"
@(GOOS=darwin GOARCH=amd64 go build -o build/distributions/darwin_amd64/fritzctl $(LDFLAGS))
define dist
@echo -n ">> BUILD, $(1)/$(2) "
@(GOOS=$(1) GOARCH=$(2) go build -o $(3) $(BUILDFLAGS))
@cp $(3) build/distributions/fritzctl-$(1)-$(2)$(4)
@cd build/distributions && shasum -a 256 "fritzctl-$(1)-$(2)$(4)" | tee "fritzctl-$(1)-$(2)$(4).sha256" | cut -b 1-64 | tr -d "\n"
@$(call ok)
endef

dist_darwin:
@$(call dist,darwin,amd64,build/distributions/darwin_amd64/fritzctl,"")

dist_win:
@echo -n ">> BUILD, windows/amd64"
@(GOOS=windows GOARCH=amd64 go build -o build/distributions/windows_amd64/fritzctl.exe $(LDFLAGS))
@$(call ok)
@$(call dist,windows,amd64,build/distributions/windows_amd64/fritzctl.exe,".exe")

dist_linux:
@echo -n ">> BUILD, linux/amd64"
@(GOOS=linux GOARCH=amd64 go build -o build/distributions/linux_amd64/usr/bin/fritzctl $(LDFLAGS))
@$(call ok)

@echo -n ">> BUILD, linux/arm"
@(GOOS=linux GOARCH=arm GOARM=6 go build -o build/distributions/linux_arm/usr/bin/fritzctl $(LDFLAGS))
@$(call ok)
@$(call dist,linux,amd64,build/distributions/linux_amd64/usr/bin/fritzctl,"")
@$(call dist,linux,arm,build/distributions/linux_arm/usr/bin/fritzctl,"")

pkg_all: pkg_linux pkg_darwin pkg_win

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ func main() {
}
```

## Reproducing binaries

Versions >= 1.4.16 can be checked for reproducibility. There is a ready-to-go [Dockerfile](docker/build/Dockerfile)
which prepares an appropriate environment given several docker build-args
```bash
docker build -t fritzctl/build docker/build \
--build-arg go_version=1.9.2 \
--build-arg fritzctl_version=1.4.16 \
--build-arg fritzctl_revision=v1.4.16
```
Building the binaries is done in the container phase:
```bash
docker run --rm -v fritzctl_build_folder:/root/go/src/github.com/bpicode/fritzctl/build fritzctl/build
```
The above command will create a docker volume `fritzctl_build_folder` containing the binaries. Those can be checked for
equality with the distributed ones.

## License

This project is licensed under the terms of the MIT license, see [LICENSE](https://github.com/bpicode/fritzctl/blob/master/LICENSE).
Expand Down
7 changes: 6 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ machine:
environment:
GODIST: "go1.9.2.linux-amd64.tar.gz"
IMPORT_PATH: "github.com/$CIRCLE_PROJECT_REPONAME"
FRITZCTL_VERSION: "0.0.1-unofficial-ci-circle"
GOROOT: /usr/local/go

post:
- mkdir -p download
- test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
- sudo rm -rf /usr/local/go
- sudo tar -C /usr/local -xzf download/$GODIST

dependencies:
post:
- GOPATH=/home/ubuntu/.go_project go env
- GOPATH=/home/ubuntu/.go_project make clean sysinfo dist_all
24 changes: 24 additions & 0 deletions docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ubuntu:xenial

ARG go_version=1.9.2
ARG fritzctl_revision=master
ARG fritzctl_version=unknown

RUN apt-get update && apt-get install -y make wget git
RUN wget --quiet https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz
RUN tar -xf go${go_version}.linux-amd64.tar.gz
RUN mv go /usr/local
RUN mkdir -p /root/go/src/github.com/bpicode

WORKDIR /root/go/src/github.com/bpicode
RUN git clone https://github.com/bpicode/fritzctl.git
WORKDIR /root/go/src/github.com/bpicode/fritzctl
RUN git checkout ${fritzctl_revision}
RUN mkdir build

ENV GOPATH=/root/go
ENV GOROOT=/usr/local/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
ENV FRITZCTL_VERSION=$fritzctl_version

ENTRYPOINT [ "make", "sysinfo", "deps", "dist_all"]
1 change: 1 addition & 0 deletions vendor/github.com/cpuguy83/go-md2man/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/Gopkg.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/go-md2man.1.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/md2man.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1ea0bf8

Please sign in to comment.