podman/.copr/prepare.sh
Neville Cain 16b793a45a Generate binaries only if they are changes in src code.
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 <neville.cain@qonto.eu>
2020-01-04 23:54:57 +01:00

40 lines
1.1 KiB
Bash

#!/bin/sh -euf
set -euxo pipefail
OS_TEST=${OS_TEST:=0}
if [ ! -e /usr/bin/git ]; then
dnf -y install git-core
fi
if [ -f $(git rev-parse --git-dir)/shallow ]; then
git fetch --unshallow
fi
COMMIT=$(git rev-parse HEAD)
COMMIT_SHORT=$(git rev-parse --short=8 HEAD)
COMMIT_NUM=$(git rev-list HEAD --count)
COMMIT_DATE=$(date +%s)
BR="#BuildRequires: golang-bin"
NEWBR="BuildRequires: golang-bin"
sed "s,#COMMIT#,${COMMIT},;
s,#SHORTCOMMIT#,${COMMIT_SHORT},;
s,#COMMITNUM#,${COMMIT_NUM},;
s,#COMMITDATE#,${COMMIT_DATE}," \
contrib/spec/podman.spec.in > contrib/spec/podman.spec
if [ ${OS_TEST} -eq 0 ]; then
sed -i "s/${BR}/${NEWBR}/g" contrib/spec/podman.spec
fi
mkdir -p build/
git archive --prefix "libpod-${COMMIT_SHORT}/" --format "tar.gz" HEAD -o "build/libpod-${COMMIT_SHORT}.tar.gz"
if [ ! -d conmon ]; then
git clone -n --quiet https://github.com/containers/conmon
fi
pushd conmon
git checkout --detach d532caebc788fafdd2a305b68cd1983b4039bea4
git archive --prefix "conmon/" --format "tar.gz" HEAD -o "../build/conmon.tar.gz"
popd