Commit Graph

44 Commits

Author SHA1 Message Date
CrazyMax 6f799c1a1c
dockerfile: llvm needed on debian for cross comp
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-07-28 22:49:07 +02:00
CrazyMax 87b085c8cd
missing DWARF symbol table
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-07-25 11:27:09 +02:00
Sebastiaan van Stijn 8fd92f1866
scripts/build: make sure build-time is in UTC
Before this:

    SOURCE_DATE_EPOCH=1606660000 DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ...
    + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T15:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-590-g090dd58dc"' -buildmode=pie github.com/docker/cli/cmd/docker
    ...

    make -f docker.Makefile shell
    SOURCE_DATE_EPOCH=1606660000 make binary
    ...
    + go build -o build/docker-linux-amd64 -tags  -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.0-dev"' github.com/docker/cli/cmd/docker
    ...

Notice that `version.BuildTime` is `2020-11-29T15:26:40Z` outside the container,
and `2020-11-29T14:26:40Z` inside.

After this:

    SOURCE_DATE_EPOCH=1606660000 DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ...
    + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-590-g090dd58dc.m"' -buildmode=pie github.com/docker/cli/cmd/docker
    ...

    make -f docker.Makefile shell
    SOURCE_DATE_EPOCH=1606660000 make binary
    ...
    + go build -o build/docker-linux-amd64 -tags  -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.0-dev"' github.com/docker/cli/cmd/docker
    ...

Notice that `version.BuildTime` is `2020-11-29T14:26:40Z` both outside and inside
the container.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-06 11:30:55 +02:00
Sebastiaan van Stijn 72ed7bd3e9
scripts/build: fix date formatting on macOS
This was introduced in 9d40c7464e, which added
support for `SOURCE_DATE_EPOCH` to override the build-time.

macOS uses the BSD flavor of `date`, which does not support the `--date` option
to set a custom time.

Before this:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ./scripts/build/binary
    date: illegal option -- -
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

After this:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ./scripts/build/binary
    Building static docker-darwin-amd64
    + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=a4b6fe16a" -X "github.com/docker/cli/cli/version.BuildTime=2022-04-06T10:57:25Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-589-ga4b6fe16a.m"' -buildmode=pie github.com/docker/cli/cmd/docker
    ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-06 11:30:19 +02:00
CrazyMax 22edabb584
fix version quad logic that trims 0 digit so returns an empty one
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-03-31 21:14:29 +02:00
CrazyMax 525845572a
trim leading 0 for minor in the version quad
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-03-31 15:54:39 +02:00
Sebastiaan van Stijn 391e6ad944
use GO_LDFLAGS instead of LDFLAGS to prevent inheriting unrelated options
When building on Fedora 36, the build failed. I suspect this is because the
rpm tools also set LDFLAGS, but with options that cannot be used;

    GO_LINKMODE=dynamic
    + ./scripts/build/binary
      /go/src/github.com/docker/cli ~/rpmbuild/BUILD/src
      Building dynamic docker-linux-arm64
      + go build -o build/docker-linux-arm64 -tags ' pkcs11' -ldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/root/rpmbuild/BUILD/src/.package_note-docker-ce-cli-0.0.0.20220330082637.68cad50-0.fc36.aarch64.ld -w -X "github.com/docker/cli/cli/version.GitCommit=68cad50" -X "github.com/docker/cli/cli/version.BuildTime=2022-03-30T20:05:36Z" -X "github.com/docker/cli/cli/version.Version=0.0.0-20220330082637-68cad50" -X "github.com/docker/cli/cli/version.PlatformName=Docker Engine - Community"' -buildmode=pie github.com/docker/cli/cmd/docker
    # github.com/docker/cli/cmd/docker
    flag provided but not defined: -Wl,-z,relro
    usage: link [options] main.o

This patch changes the variable we use to `GO_LDFLAGS`, taking a similar approach
as containerd, and various other projects using this name: https://grep.app/search?q=GO_LDFLAGS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-31 10:30:56 +02:00
Sebastiaan van Stijn 4cd2d9ddd2
Change "COMPANY_NAME" to "PACKAGER_NAME"
The COMPANY_NAME currently sets the "CompanyName" field in the metadata
of Windows binaries. Our intent of this field is this field to contain
information about the company/party that produced the binary.

Also from [FileVersionInfo.CompanyName][FileVersionInfo.CompanyName]:

> Gets the name of the company that produced the file

Based on the above, "PACKAGER_NAME" is a bit more generic, and clearer
on intent, and we may at some point re-use this same information to
propagate equivalent fields on other platforms (rpms, debs)

[FileVersionInfo.CompanyName]: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.fileversioninfo.companyname

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-27 10:09:50 +02:00
Sebastiaan van Stijn e20572d047
scripts/build: make sure osusergo is set for static with CGO enabled
Our previous CI probably did not cross-compile for s390x and ppc64le,
and therefore did not get these errors; the scripts/build/.variables
file sets CGO_ENABLED=1 for amd64|arm64|arm|s390x architectures if
it's not set;
87b8e57868/scripts/build/.variables (L34-L46)

When compiling statically with CGO enabled, we must have osusergo
enabled as well, so set it accordingly, to prevent;

    #53 [linux/amd64 build 2/2] RUN --mount=type=bind,target=.,ro     --mount=type=cache,target=/root/.cache     --mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk     --mount=type=tmpfs,target=cli/winresources     xx-go --wrap &&     TARGET=/out ./scripts/build/binary &&     xx-verify $([ "static" = "static" ] && echo "--static") /out/docker
    #53 953.6 # github.com/docker/cli/cmd/docker
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000022.o: in function `New':
    #53 953.6 /go/src/github.com/docker/cli/vendor/github.com/miekg/pkcs11/pkcs11.go:75: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000018.o: in function `mygetgrouplist':
    #53 953.6 /usr/local/go/src/os/user/getgrouplist_unix.go:18: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetgrgid_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:40: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetgrnam_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:45: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetpwnam_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:35: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetpwuid_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:30: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000004.o: in function `_cgo_3c1cec0c9a4e_C2func_getaddrinfo':
    #53 953.6 /tmp/go-build/cgo-gcc-prolog:58: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-26 15:49:05 +01:00
CrazyMax 5fab1b2b10
ensure version quad for goversioninfo
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-12-10 10:50:23 +01:00
CrazyMax 62ea2bf1aa
GitHub Actions e2e tests
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-11-17 17:18:25 +01:00
CrazyMax dbac826815
Fix checkout behavior and FileVersion
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-12 10:48:31 +02:00
CrazyMax 75284bd1d1
Use goversioninfo to create Windows Version Info
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-11 16:54:22 +02:00
Sebastiaan van Stijn a477a727fc
Update to go1.16.6
Keeping the dockerfiles/Dockerfile.cross image at 1.13, as we don't
have more current versions of that image. However, I don't think it's
still used, so we should remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-07-29 11:52:02 +02:00
Brian Goff 43dc024002
Merge pull request #2855 from Foxboron/morten/reprobuilds 2021-07-23 09:41:51 -07:00
Brian Goff 83e9eeb8a0 scripts: Allow skipping windres when WINDRES= (empty string)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
2021-04-13 21:29:54 +00:00
Tibor Vass 2c40960ba1 scripts: use WINDRES env var if set
This allows setting WINDRES to mingw's windres.

For the record, mingw's windres needs --use-temp-file for a weird reason:
in that case, it keeps preprocessor arguments intact (including quotes),
without it, mingw's windres calls popen, which happens to pass the entire
command to sh -c, stripping quotes after evaluation and causing a syntax
error in mingw's windres.

To use mingw's windres, set WINDRES to:
- `x86_64-w64-mingw32-windres` on 64 bit
- `i686-w64-mingw32-windres` on 32 bit

Signed-off-by: Tibor Vass <tibor@docker.com>
2021-04-13 16:55:00 +00:00
Tibor Vass 6e45f4bfe2 scripts: fix VERSION_QUAD corner case in windows resource
When the git checkout is dirty on top of a git tag (i.e., v20.10.6.m),
the VERSION_QUAD was keeping a trailing comma.
Now the trailing comma is stripped.

Signed-off-by: Tibor Vass <tibor@docker.com>
2021-04-13 16:52:53 +00:00
Tonis Tiigi 26b633d37b set default version from git
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-04-06 00:21:10 -07:00
Tonis Tiigi 8b822c9219 update windows resources generation
New solution is not hardcoded to amd64 but integrates
with the cross toolchain and support creating arm binaries.

Go has been updated so that ASLR works

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-04-06 00:20:59 -07:00
Tonis Tiigi 6423da8dcd dockerfile based binary building
Using cross compilation toolchains that work from any platform
Adds darwin/arm64 support and bake targets. Static and dynamic
binary targets are available, both with glibc and musl.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-04-06 00:20:21 -07:00
Morten Linderud 9d40c7464e
scripts/build/.variables: Support SOURCE_DATE_EPOCH
Repeated builds of docker is currently unreproducible as the embedded
time does not support SOURCE_DATE_EPOCH. This patch ensures we check for
the defined variable before utilizing current date.

This has been fixed previously with manpages as well

2d7091aaeb

Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-11-29 16:07:46 +01:00
Xiaodong Liu eeafa40154 -buildmode=pie is not supported for the mips arch
reference: 4c99c81326

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
2020-05-12 09:14:36 +08:00
Silvin Lubecki 40aa020534 Add an exe extension to windows binary during cross build.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2020-02-27 15:34:23 +01:00
Sebastiaan van Stijn ef37a8a57c
Fix "make build" (non-containerized) on macOS
macOS doesn't ship with the GNU version of `date`, which
causes the command to fail if the `--rfc-3339 ns` format option
is used.

Given that we don't need the build-time with nanosecond precision,
this patch changes the format used, so that the CLI binary can be
built on the host (outside of a container);

Before this change, `make binary` would fail:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    WARNING: binary creates a Linux executable. Use cross for macOS or Windows.
    ./scripts/build/binary
    make: *** [binary] Error 1

With this change, the binary can be built on the host:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    WARNING: binary creates a Linux executable. Use cross for macOS or Windows.
    ./scripts/build/binary
    Building statically linked build/docker-darwin-amd64

While the previous version formatted (and parsed) the date with nanoseconds precision,
that level of precision is not actually used;

```go
func reformatDate(buildTime string) string {
	t, errTime := time.Parse(time.RFC3339Nano, buildTime)
	if errTime == nil {
		return t.Format(time.ANSIC)
	}
	return buildTime
}
```

Both the old, and new input will yield the same output:

```go
fmt.Println(reformatDate("2019-12-31T13:41:44.846741804+00:00"))
// Tue Dec 31 13:41:44 2019

fmt.Println(reformatDate("2019-12-31T13:41:44Z"))
// Tue Dec 31 13:41:44 2019
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-12-31 15:06:11 +01:00
Brian Goff 15130e3043 Support GOARM and windows .exe in binary target
This just makes it easier to build a targeted binary for the
goos/goach/goarm version.

This of course will not work for all cases but is nice to get things
going.
Specifically cross-compiling pkcs for yubikey support requires some
extra work whichis not tackled here.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-05-06 10:43:18 -07:00
Sebastiaan van Stijn 5aeb7a0f55
Remove some bashisms
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-02-26 15:31:12 +01:00
Ian Campbell 5db336798c Add some simple e2e tests for executing CLI plugins
To help with this add a bad plugin which produces invalid metadata and arrange
for it to be built in the e2e container.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-01-30 13:44:05 +00:00
Ian Campbell e96240427f Add basic framework for writing a CLI plugin
That is, the helper to be used from the plugin's `main`.

Also add a `helloworld` plugin example and build integration.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-01-29 11:26:40 +00:00
Ian Campbell 20c19830a9 Move versioning variables to a separate package.
This helps to avoid circular includes, by separating the pure data out from the
actual functionality in the cli subpackage, allowing other code which is
imported to access the data.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-01-29 11:26:40 +00:00
Kir Kolyshkin ee461303f9 scripts/build/osx: set CXX, too
In case go build will see a need to call C++ (rather than C)
compiler, CXX env var need to be properly set (to osxcross wrapper).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-10-11 01:15:33 -07:00
Aleksa Sarai 164e812b7a
build: add -buildmode=pie
Make all dynbinary builds be position-independent (this adds both
security benefits and can help with flaky builds on POWER
architectures).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2018-07-30 19:34:01 +10:00
Tibor Vass 5f4c5f8bb6 Add platform and its components to docker version output
The Server section of version output is now composed of an Engine
component and potentially more, based on what the /version endpoint
returns.

Signed-off-by: Tibor Vass <tibor@docker.com>
2017-12-07 02:04:10 +01:00
Jean-Pierre Huynh 24c06c1723 Add scripts folder to shellcheck
Signed-off-by: Jean-Pierre Huynh <jean-pierre.huynh@ounet.fr>
2017-07-19 16:33:58 +01:00
Daniel Nephin 1eb66d60bd Add parallelism to cross build
Reusable docker engine

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-05 15:23:32 -04:00
Daniel Nephin b7b7d784d8 Remove gox, add support for s390x
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-30 16:01:21 -04:00
Andrew Hsu 3dfe334a7a allow version number to be set in builds
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
2017-05-22 13:22:42 -07:00
Daniel Nephin 46049dd0b6 Enabled linux/ppc64le cross build.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-18 13:07:26 -04:00
Daniel Nephin 8a6ad48d2b Add windows resources to binary.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-15 18:03:03 -04:00
Daniel Nephin 60b2dd3e23 Update the README
Remove referenced to developing on the host, we shouldn't support it.

Move script/validate to scripts/validate to be consistent.
Set the default target to be binary instead of clean.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-15 14:07:30 -04:00
Daniel Nephin a408fb0a61 osx cross
Fix CI build

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-13 13:47:00 -04:00
Daniel Nephin 84a77889c3 Add windows and linux cross.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-12 13:34:13 -04:00
Daniel Nephin a787cbc93b Support building a dynbinary
Cleanup dynbinary and binary builds

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-12 13:34:06 -04:00
Kenfe-Mickael Laventure cf51bde7d9 Display proper version information
- The cli version defaults to "unknown-version" unless set via the VERSION env var
- The commit version can be overridden via GITCOMMIT env var
- The build time can be overridden via BUILDTIME env var

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-05-09 14:22:51 -07:00