Skip to content

Commit

Permalink
Generate binaries only if they are changes in src code.
Browse files Browse the repository at this point in the history
Changes I am making:

1. The target `.gopathok` was listed in `.PHONY` which
looks wrong as it regenerates `.gopathok` every time we
 re-run it, which was a part of the issue. I removed it
 to avoid that. If `.gopathok` is present', makefile
should not need to rerun it.

2. Ensure the binaries are created only if they don't
exist by adding `bin/podman`
and `bin/podman-remote`.

3. Add a `SOURCES = $(shell find . -name "*.go")` and put
it as a dependency of the podman binaries target. It allows us
to re-generate the binaries only when there is a change in the
source files. The downside is it increases the running time of
the command that generates them (20 seconds on my virtual machine
running Centos 7). If this is a problem, we could introduce a
hidden file that would list all the files to track, that
would need to be updated only when a dev is introducing new files.

4. Fixed the make package-install as it does not work with yum.
I updated the build_rpm.sh to ensure it works on centos 7
and centos 8 with no pre-required installation.

Closes #4367

Signed-off-by: Neville Cain <[email protected]>
  • Loading branch information
NevilleC committed Jan 4, 2020
1 parent 9e03aa1 commit 16b793a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .copr/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ if [ ! -d conmon ]; then
git clone -n --quiet https://github.com/containers/conmon
fi
pushd conmon
git checkout --detach 6f3572558b97bc60dd8f8c7f0807748e6ce2c440
git checkout --detach d532caebc788fafdd2a305b68cd1983b4039bea4
git archive --prefix "conmon/" --format "tar.gz" HEAD -o "../build/conmon.tar.gz"
popd
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ BUILDTAGS ?= \
PYTHON ?= $(shell command -v python python3|head -n1)
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)

SOURCES = $(shell find . -name "*.go")

GO_BUILD=$(GO) build
# Go module support: set `-mod=vendor` to use the vendored sources
Expand Down Expand Up @@ -164,11 +165,15 @@ test/checkseccomp/checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go)
test/goecho/goecho: .gopathok $(wildcard test/goecho/*.go)
$(GO_BUILD) -ldflags '$(LDFLAGS_PODMAN)' -o $@ $(PROJECT)/test/goecho

podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman
$(GO_BUILD) $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o bin/$@ $(PROJECT)/cmd/podman
bin/podman: .gopathok $(SOURCES) go.mod go.sum $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman
$(GO_BUILD) $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/cmd/podman

podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote environment
$(GO_BUILD) $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o bin/$@ $(PROJECT)/cmd/podman
podman: bin/podman

bin/podman-remote: .gopathok $(SOURCES) go.mod go.sum $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote environment
$(GO_BUILD) $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o $@ $(PROJECT)/cmd/podman

podman-remote: bin/podman-remote

.PHONY: podman.msi
podman.msi: podman-remote podman-remote-windows install-podman-remote-windows-docs ## Will always rebuild exe as there is no podman-remote-windows.exe target to verify timestamp
Expand Down Expand Up @@ -544,7 +549,6 @@ vendor-in-container:
podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.13 make vendor

.PHONY: \
.gopathok \
binaries \
changelog \
clean \
Expand Down Expand Up @@ -572,4 +576,6 @@ package: ## Build rpm packages
./contrib/build_rpm.sh

package-install: package ## Install rpm packages
sudo ${PKG_MANAGER} -y install --allowerasing ${HOME}/rpmbuild/RPMS/*/*.rpm
sudo ${PKG_MANAGER} -y remove podman podman-remote
sudo ${PKG_MANAGER} -y clean all
sudo ${PKG_MANAGER} -y install ${HOME}/rpmbuild/RPMS/*/*.rpm
29 changes: 18 additions & 11 deletions contrib/build_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,26 @@ declare -a PKGS=(device-mapper-devel \
)

if [[ $pkg_manager == *dnf ]]; then
# We need to enable PowerTools if we want to get
# install all the pkgs we define in PKGS
sudo dnf config-manager --set-enabled PowerTools

PKGS+=(python3-devel \
python3-varlink \
)
# btrfs-progs-devel is not available in CentOS/RHEL-8
if ! grep -i -q 'Red Hat\|CentOS' /etc/redhat-release; then
PKGS+=(btrfs-progs-devel)
fi
# disable doc until go-md2man rpm becomes available
# disable debug to avoid error: Empty %files file ~/rpmbuild/BUILD/libpod-.../debugsourcefiles.list
export extra_arg="--without doc --without debug"
else
if ! grep -i -q 'Red Hat\|CentOS' /etc/redhat-release; then
PKGS+=(golang-github-cpuguy83-go-md2man)
fi
fi

# btrfs-progs-devel is not available in CentOS/RHEL-8
if ! (grep -i 'Red Hat\|CentOS' /etc/redhat-release | grep " 8" ); then
PKGS+=(golang-github-cpuguy83-go-md2man \
btrfs-progs-devel \
)
fi

# disable doc until go-md2man rpm becomes available
# disable debug to avoid error: Empty %files file ~/rpmbuild/BUILD/libpod-.../debugsourcefiles.list
export extra_arg="--without doc --without debug"

echo ${PKGS[*]}
sudo $pkg_manager install -y ${PKGS[*]}

Expand All @@ -56,3 +60,6 @@ if [ -d ~/rpmbuild/BUILD ]; then
fi

rpmbuild --rebuild ${extra_arg:-} podman-*.src.rpm

# clean up src.rpm as it's been built
sudo rm -f podman-*.src.rpm
3 changes: 1 addition & 2 deletions contrib/spec/podman.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# People want conmon packaged with the copr rpm
%global import_path_conmon github.com/containers/conmon
%global git_conmon https://%{import_path_conmon}
%global commit_conmon 6f3572558b97bc60dd8f8c7f0807748e6ce2c440
%global commit_conmon d532caebc788fafdd2a305b68cd1983b4039bea4
%global shortcommit_conmon %(c=%{commit_conmon}; echo ${c:0:7})

Name: podman
Expand Down Expand Up @@ -79,7 +79,6 @@ Requires: runc
Requires: skopeo-containers
Requires: containernetworking-plugins >= 0.6.0-3
Requires: iptables
Requires: oci-systemd-hook
%if 0%{?rhel} <= 7
Requires: container-selinux
%else
Expand Down

0 comments on commit 16b793a

Please sign in to comment.