Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.1
/layers-*
/skopeo
result

# ignore JetBrains IDEs (GoLand) config folder
.idea
.idea
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ CONTAINER_RUN := $(CONTAINER_CMD) "$(IMAGE)"

GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true)

EXTRA_LDFLAGS ?=
LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} $(EXTRA_LDFLAGS)'

MANPAGES_MD = $(wildcard docs/*.md)
MANPAGES ?= $(MANPAGES_MD:%.md=%)

Expand All @@ -85,7 +88,7 @@ help:
@echo
@echo " * 'install' - Install binaries and documents to system locations"
@echo " * 'binary' - Build skopeo with a container"
@echo " * 'binary-local' - Build skopeo locally"
@echo " * 'bin/skopeo' - Build skopeo locally"
@echo " * 'test-unit' - Execute unit tests"
@echo " * 'test-integration' - Execute integration tests"
@echo " * 'validate' - Verify whether there is no conflict and all Go source files have been formatted, linted and vetted"
Expand All @@ -98,19 +101,18 @@ help:
binary: cmd/skopeo
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage .
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/src/github.com/containers/skopeo \
skopeobuildimage make binary-local $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'
skopeobuildimage make bin/skopeo $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'

binary-static: cmd/skopeo
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage .
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/src/github.com/containers/skopeo \
skopeobuildimage make binary-local-static $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'
# Update nix/nixpkgs.json its latest master commit
.PHONY: nixpkgs
nixpkgs:
@nix run -f channel:nixpkgs-unstable nix-prefetch-git -c nix-prefetch-git \
--no-deepClone https://github.com/nixos/nixpkgs > nix/nixpkgs.json

# Build w/o using containers
binary-local:
$(GPGME_ENV) $(GO) build $(MOD_VENDOR) ${GO_DYN_FLAGS} -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo

binary-local-static:
$(GPGME_ENV) $(GO) build $(MOD_VENDOR) -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo
.PHONY: bin/skopeo
bin/skopeo:
$(GPGME_ENV) $(GO) build $(MOD_VENDOR) ${GO_DYN_FLAGS} ${LDFLAGS} -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o $@ ./cmd/skopeo

build-container:
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -t "$(IMAGE)" .
Expand All @@ -126,7 +128,7 @@ docs-in-container:
skopeobuildimage make docs $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'

clean:
rm -f skopeo docs/*.1
rm -f bin docs/*.1

install: install-binary install-docs install-completions
install -d -m 755 ${SIGSTOREDIR}
Expand All @@ -135,9 +137,9 @@ install: install-binary install-docs install-completions
install -d -m 755 ${REGISTRIESDDIR}
install -m 644 default.yaml ${REGISTRIESDDIR}/default.yaml

install-binary: ./skopeo
install-binary: bin/skopeo
install -d -m 755 ${INSTALLDIR}
install -m 755 skopeo ${INSTALLDIR}/skopeo
install -m 755 bin/skopeo ${INSTALLDIR}/skopeo

install-docs: docs
install -d -m 755 ${MANINSTALLDIR}/man1
Expand Down
2 changes: 1 addition & 1 deletion contrib/skopeoimage/upstream/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mkdir /root/skopeo; \
git clone https://github.com/containers/skopeo /root/skopeo/src/github.com/containers/skopeo; \
export GOPATH=/root/skopeo; \
cd /root/skopeo/src/github.com/containers/skopeo; \
make binary-local;\
make bin/skopeo;\
make install;\
rm -rf /root/skopeo/*; \
yum -y remove git golang go-md2man make; \
Expand Down
2 changes: 1 addition & 1 deletion hack/make/test-integration
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bundle_test_integration() {

# subshell so that we can export PATH without breaking other things
(
make binary-local ${BUILDTAGS:+BUILDTAGS="$BUILDTAGS"}
make bin/skopeo ${BUILDTAGS:+BUILDTAGS="$BUILDTAGS"}
make install
bundle_test_integration
) 2>&1
2 changes: 1 addition & 1 deletion hack/make/test-system
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sed -i \
/etc/containers/storage.conf

# Build skopeo, install into /usr/bin
make binary-local ${BUILDTAGS:+BUILDTAGS="$BUILDTAGS"}
make bin/skopeo ${BUILDTAGS:+BUILDTAGS="$BUILDTAGS"}
make install

# Run tests
Expand Down
2 changes: 1 addition & 1 deletion hack/travis_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ go version
GO111MODULE=off go get -u github.com/cpuguy83/go-md2man golang.org/x/lint/golint

cd ${_containers}/skopeo
make validate-local test-unit-local binary-local
make validate-local test-unit-local bin/skopeo
sudo make install
skopeo -v
2 changes: 1 addition & 1 deletion install.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Make sure to clone this repository in your `GOPATH` - otherwise compilation fail

```bash
$ git clone https://github.com/containers/skopeo $GOPATH/src/github.com/containers/skopeo
$ cd $GOPATH/src/github.com/containers/skopeo && make binary-local
$ cd $GOPATH/src/github.com/containers/skopeo && make bin/skopeo
```

### Building in a container
Expand Down
2 changes: 1 addition & 1 deletion integration/openshift_shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ to start a container, then within the container:
SKOPEO_CONTAINER_TESTS=1 PS1='nested> ' go test -tags openshift_shell -timeout=24h ./integration -v -check.v -check.vv -check.f='CopySuite.TestRunShell'

An example of what can be done within the container:
cd ..; make binary-local install
cd ..; make bin/skopeo install
./skopeo --tls-verify=false copy --sign-by=personal@example.com docker://busybox:latest atomic:localhost:5000/myns/personal:personal
oc get istag personal:personal -o json
curl -L -v 'http://localhost:5000/v2/'
Expand Down
43 changes: 43 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{ system ? builtins.currentSystem }:
let
pkgs = (import ./nixpkgs.nix {
config = {
packageOverrides = pkg: {
gpgme = (static pkg.gpgme);
libassuan = (static pkg.libassuan);
libgpgerror = (static pkg.libgpgerror);
};
};
});

static = pkg: pkg.overrideAttrs(x: {
configureFlags = (x.configureFlags or []) ++
[ "--without-shared" "--disable-shared" ];
dontDisableStatic = true;
enableSharedExecutables = false;
enableStatic = true;
});

self = with pkgs; buildGoPackage rec {
name = "skopeo";
src = ./..;
goPackagePath = "github.com/containers/skopeo";
doCheck = false;
enableParallelBuilding = true;
nativeBuildInputs = [ git go-md2man installShellFiles makeWrapper pkg-config ];
buildInputs = [ glibc glibc.static gpgme libassuan libgpgerror ];
prePatch = ''
export LDFLAGS='-s -w -static-libgcc -static'
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
export BUILDTAGS='static netgo exclude_graphdriver_btrfs exclude_graphdriver_devicemapper'
'';
buildPhase = ''
pushd go/src/${goPackagePath}
patchShebangs .
make bin/skopeo
'';
installPhase = ''
install -Dm755 bin/skopeo $out/bin/skopeo
'';
};
in self
10 changes: 10 additions & 0 deletions nix/nixpkgs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"url": "https://github.com/nixos/nixpkgs",
"rev": "78e324d2726127828a15f87a75b4d3199a8955ec",
"date": "2020-06-16T18:23:14-07:00",
"path": "/nix/store/bwhp0061k3fk00j8fskpfak261jdcjl6-nixpkgs",
"sha256": "1j58aa9ngdmvbnds4x4a497nynj390dzqyb5yrvmhjc7k9anq6jm",
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}
8 changes: 8 additions & 0 deletions nix/nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let
json = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
nixpkgs = import (builtins.fetchTarball {
name = "nixos-unstable";
url = "${json.url}/archive/${json.rev}.tar.gz";
inherit (json) sha256;
});
in nixpkgs