Skip to content

Commit

Permalink
Fix binary names (#122)
Browse files Browse the repository at this point in the history
## Description

This PR fixes the binary names to be both correct and also "unsurprising".

## Why is this needed

Avoids needing to COPY all the binaries, only to keep 1. Also avoids glaringly misnamed binaries :D. 

For example these are the binaries built from master:
```
file boots-* | sed 's|, statically.*||'
boots-linux-aarch64: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)
boots-linux-amd64:   ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
boots-linux-arm64:   ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV)
boots-linux-armv7l:  ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)
boots-linux-x86_64:  ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV)
```
notice the 32bit arm v6 binary is named aarch64 and x86_64 is actually 386!

Here is from this PR:
```
[~/go/src/github.com/tinkerbell/boots]─[manny@dellnix]> 
file boots-* | sed 's|, statically.*||'
boots-linux-386:   ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV)
boots-linux-amd64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
boots-linux-arm64: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV)
boots-linux-armv6: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)
boots-linux-armv7: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)
```

## How Has This Been Tested?

Inspecting each file with `file`, docker build works.

## How are existing users impacted? What migration steps/scripts do we need?

Any user using the cross compiled binaries directly will be impacted, but this should most likely be 0 users since they will likely use plain-old `boots` binary instead.
  • Loading branch information
mergify[bot] authored Jan 20, 2021
2 parents 0498419 + 4984a29 commit 62ed4b8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!boots-*-*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.idea*/**
/bin/
boots
boots-*-*
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
FROM alpine:3.11

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

ENTRYPOINT ["/usr/bin/boots"]
EXPOSE 67 69 80

RUN apk add --update --upgrade --no-cache ca-certificates socat
COPY . /usr/myapp
RUN cp /usr/myapp/boots-linux-$(uname -m) /usr/bin/boots
RUN rm -fr /usr/myapp
COPY boots-${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT} /usr/bin/boots
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ binary := boots
.PHONY: all ${binary} crosscompile dc gen run test
all: ${binary}

CGO_ENABLED := 0
export CGO_ENABLED

GitRev := $(shell git rev-parse --short HEAD)
crosscompile: ${binary}
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -v -o ./boots-linux-x86_64 -ldflags="-X main.GitRev=${GitRev}"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./boots-linux-amd64 -ldflags="-X main.GitRev=${GitRev}"
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -v -o ./boots-linux-aarch64 -ldflags="-X main.GitRev=${GitRev}"
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -v -o ./boots-linux-armv7l -ldflags="-X main.GitRev=${GitRev}"
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -v -o ./boots-linux-arm64 -ldflags="-X main.GitRev=${GitRev}"
crosscompile: boots-linux-386 boots-linux-amd64 boots-linux-arm64 boots-linux-armv6 boots-linux-armv7
boots-linux-386: FLAGS=GOARCH=386
boots-linux-amd64: FLAGS=GOARCH=amd64
boots-linux-arm64: FLAGS=GOARCH=arm64
boots-linux-armv6: FLAGS=GOARCH=arm GOARM=6
boots-linux-armv7: FLAGS=GOARCH=arm GOARM=7
boots-linux-386 boots-linux-amd64 boots-linux-arm64 boots-linux-armv6 boots-linux-armv7: ${binary}
${FLAGS} GOOS=linux go build -v -ldflags="-X main.GitRev=${GitRev}" -o $@

# this is quick and its really only for rebuilding when dev'ing, I wish go would
# output deps in make syntax like gcc does... oh well this is good enough
${binary}: $(shell git ls-files | grep -v -e vendor -e '_test.go' | grep '.go$$' ) ipxe/bindata.go
CGO_ENABLED=0 go build -v -ldflags="-X main.GitRev=${GitRev}"
go build -v -ldflags="-X main.GitRev=${GitRev}"

ifeq ($(origin GOBIN), undefined)
GOBIN := ${PWD}/bin
Expand Down

0 comments on commit 62ed4b8

Please sign in to comment.