Skip to content

Commit

Permalink
Merge pull request #5832 from kolyshkin/makefile-cleanups
Browse files Browse the repository at this point in the history
(not just) Makefile cleanups
  • Loading branch information
openshift-merge-bot[bot] authored Nov 12, 2024
2 parents 7870181 + 135431f commit a65fd39
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[codespell]
skip = ./vendor,./.git,./go.sum,./docs/*.1,./docker/AUTHORS,./CHANGELOG.md,./changelog.txt,./tests/tools/vendor,./tests/tools/go.mod,./tests/tools/go.sum
ignore-words-list = fo,passt,secon,erro
36 changes: 2 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export GOPROXY=https://proxy.golang.org

APPARMORTAG := $(shell hack/apparmor_tag.sh)
STORAGETAGS := exclude_graphdriver_devicemapper $(shell ./btrfs_tag.sh) $(shell ./btrfs_installed_tag.sh) $(shell ./hack/libsubid_tag.sh)
STORAGETAGS := $(shell ./btrfs_tag.sh) $(shell ./btrfs_installed_tag.sh) $(shell ./hack/libsubid_tag.sh)
SECURITYTAGS ?= seccomp $(APPARMORTAG)
TAGS ?= $(SECURITYTAGS) $(STORAGETAGS) $(shell ./hack/systemd_tag.sh)
ifeq ($(shell uname -s),FreeBSD)
Expand Down Expand Up @@ -29,15 +29,12 @@ RACEFLAGS := $(shell $(GO_TEST) -race ./pkg/dummy > /dev/null 2>&1 && echo -race
COMMIT_NO ?= $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
SOURCE_DATE_EPOCH ?= $(if $(shell date +%s),$(shell date +%s),$(error "date failed"))
STATIC_STORAGETAGS = "containers_image_openpgp $(STORAGE_TAGS)"

# we get GNU make 3.x in MacOS build envs, which wants # to be escaped in
# strings, while the 4.x we have on Linux doesn't. this is the documented
# workaround
COMMENT := \#
CNI_COMMIT := $(shell sed -n 's;^$(COMMENT) github.com/containernetworking/cni \([^ \n]*\).*$$;\1;p' vendor/modules.txt)
RUNC_COMMIT := $(shell sed -n 's;^$(COMMENT) github.com/opencontainers/runc \([^ \n]*\).*$$;\1;p' vendor/modules.txt)
LIBSECCOMP_COMMIT := release-2.3

EXTRA_LDFLAGS ?=
BUILDAH_LDFLAGS := $(GO_LDFLAGS) '-X main.GitCommit=$(GIT_COMMIT) -X main.buildInfo=$(SOURCE_DATE_EPOCH) -X main.cniVersion=$(CNI_COMMIT) $(EXTRA_LDFLAGS)'
Expand Down Expand Up @@ -122,14 +119,8 @@ clean:
docs: install.tools ## build the docs on the host
$(MAKE) -C docs

# For vendoring to work right, the checkout directory must be such that our top
# level is at $GOPATH/src/github.com/containers/buildah.
.PHONY: gopath
gopath:
test $(shell pwd) = $(shell cd ../../../../src/github.com/containers/buildah ; pwd)

codespell:
codespell -S Makefile,buildah.spec.rpkg,AUTHORS,bin,vendor,.git,go.mod,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L secon,passt,bu,uint,iff,od,erro -w
codespell -w

.PHONY: validate
validate: install.tools
Expand All @@ -142,25 +133,6 @@ validate: install.tools
install.tools:
$(MAKE) -C tests/tools

.PHONY: runc
runc: gopath
rm -rf ../../opencontainers/runc
git clone https://github.com/opencontainers/runc ../../opencontainers/runc
cd ../../opencontainers/runc && git checkout $(RUNC_COMMIT) && $(GO) build -tags "$(STORAGETAGS) $(SECURITYTAGS)"
ln -sf ../../opencontainers/runc/runc

.PHONY: install.libseccomp.sudo
install.libseccomp.sudo: gopath
rm -rf ../../seccomp/libseccomp
git clone https://github.com/seccomp/libseccomp ../../seccomp/libseccomp
cd ../../seccomp/libseccomp && git checkout $(LIBSECCOMP_COMMIT) && ./autogen.sh && ./configure --prefix=/usr && make all && sudo make install

.PHONY: install.cni.sudo
install.cni.sudo: gopath
rm -rf ../../containernetworking/plugins
git clone https://github.com/containernetworking/plugins ../../containernetworking/plugins
cd ../../containernetworking/plugins && ./build_linux.sh && sudo install -D -v -m755 -t /opt/cni/bin/ bin/*

.PHONY: install
install:
install -d -m 755 $(DESTDIR)/$(BINDIR)
Expand All @@ -178,10 +150,6 @@ install.completions:
install -m 755 -d $(DESTDIR)/$(BASHINSTALLDIR)
install -m 644 contrib/completions/bash/buildah $(DESTDIR)/$(BASHINSTALLDIR)/buildah

.PHONY: install.runc
install.runc:
install -m 755 ../../opencontainers/runc/runc $(DESTDIR)/$(BINDIR)/

.PHONY: test-conformance
test-conformance:
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -timeout 60m ./tests/conformance
Expand Down
8 changes: 4 additions & 4 deletions copier/syscall_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func sameDevice(a, b os.FileInfo) bool {
if aSys == nil || bSys == nil {
return true
}
au, aok := aSys.(*syscall.Stat_t)
bu, bok := bSys.(*syscall.Stat_t)
if !aok || !bok {
uA, okA := aSys.(*syscall.Stat_t)
uB, okB := bSys.(*syscall.Stat_t)
if !okA || !okB {
return true
}
return au.Dev == bu.Dev
return uA.Dev == uB.Dev
}

const (
Expand Down
2 changes: 1 addition & 1 deletion docs/buildah-build.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ Pass secret information to be used in the Containerfile for building images
in a safe way that will not end up stored in the final image, or be seen in other stages.
The value of the secret will be read from an environment variable or file named
by the "id" option, or named by the "src" option if it is specified, or from an
environment variable specifed by the "env" option.
environment variable specified by the "env" option.
The secret will be mounted in the container at `/run/secrets/*id*` by default.

To later use the secret, use the --mount flag in a `RUN` instruction within a `Containerfile`:
Expand Down
19 changes: 4 additions & 15 deletions install.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,8 @@ In Fedora, you can use this command:
Then to install Buildah on Fedora follow the steps in this example:

```
mkdir ~/buildah
cd ~/buildah
export GOPATH=`pwd`
git clone https://github.com/containers/buildah ./src/github.com/containers/buildah
cd ./src/github.com/containers/buildah
git clone https://github.com/containers/buildah
cd buildah
make
sudo make install
buildah --help
Expand Down Expand Up @@ -252,18 +249,10 @@ In Ubuntu 22.10 (Karmic) or Debian 12 (Bookworm) you can use these commands:

```
sudo apt-get -y -qq update
sudo apt-get -y install bats btrfs-progs git go-md2man golang libapparmor-dev libglib2.0-dev libgpgme11-dev libseccomp-dev libselinux1-dev make skopeo libbtrfs-dev
sudo apt-get -y install bats btrfs-progs git go-md2man golang libapparmor-dev libglib2.0-dev libgpgme11-dev libseccomp-dev libselinux1-dev make runc skopeo libbtrfs-dev
```

Then to install Buildah follow the steps in this example:

```
git clone https://github.com/containers/buildah
cd buildah
make runc all SECURITYTAGS="apparmor seccomp"
sudo make install install.runc
buildah --help
```
The build steps for Buildah on Debian or Ubuntu are the same as for Fedora, above.

## Vendoring - Dependency Management

Expand Down
2 changes: 1 addition & 1 deletion nix/default-arm64.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ let
export CFLAGS='-static -pthread'
export LDFLAGS='-s -w -static-libgcc -static'
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
export BUILDTAGS='static netgo osusergo exclude_graphdriver_btrfs exclude_graphdriver_devicemapper seccomp apparmor selinux'
export BUILDTAGS='static netgo osusergo exclude_graphdriver_btrfs seccomp apparmor selinux'
export CGO_ENABLED=1
'';
buildPhase = ''
Expand Down
2 changes: 1 addition & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let
export CFLAGS='-static -pthread'
export LDFLAGS='-s -w -static-libgcc -static'
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
export BUILDTAGS='static netgo osusergo exclude_graphdriver_btrfs exclude_graphdriver_devicemapper seccomp apparmor selinux'
export BUILDTAGS='static netgo osusergo exclude_graphdriver_btrfs seccomp apparmor selinux'
export CGO_ENABLED=1
'';
buildPhase = ''
Expand Down
2 changes: 1 addition & 1 deletion pkg/parse/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestParsePullPolicy(t *testing.T) {
"newer": true,
"false": true,
"never": true,
"trye": false,
"try": false,
"truth": false,
}
for value, result := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion rpm/buildah.spec
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export CGO_CFLAGS+=" -m64 -mtune=generic -fcf-protection=full"
export CNI_VERSION=`grep '^# github.com/containernetworking/cni ' src/modules.txt | sed 's,.* ,,'`
export LDFLAGS="-X main.buildInfo=`date +%s` -X main.cniVersion=${CNI_VERSION}"

export BUILDTAGS="seccomp exclude_graphdriver_devicemapper $(hack/systemd_tag.sh) $(hack/libsubid_tag.sh)"
export BUILDTAGS="seccomp $(hack/systemd_tag.sh) $(hack/libsubid_tag.sh)"
%if !%{defined build_with_btrfs}
export BUILDTAGS+=" btrfs_noversion exclude_graphdriver_btrfs"
%endif
Expand Down
1 change: 0 additions & 1 deletion tests/source.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ load helpers
# Inspect the config
run jq -r .created $srcdir/blobs/sha256/$configDigest
assert "$status" -eq 0 "status of jq .created on configDigest"
creatd=$output
run date --date="$output"
assert "$status" -eq 0 "status of date (this should never ever fail)"
run jq -r .author $srcdir/blobs/sha256/$configDigest
Expand Down

0 comments on commit a65fd39

Please sign in to comment.