diff options
Diffstat (limited to '.copr')
-rw-r--r-- | .copr/Makefile | 31 | ||||
-rw-r--r-- | .copr/prepare.sh | 22 |
2 files changed, 27 insertions, 26 deletions
diff --git a/.copr/Makefile b/.copr/Makefile index 0b2e1c8f2..3ba480376 100644 --- a/.copr/Makefile +++ b/.copr/Makefile @@ -1,28 +1,7 @@ #!/usr/bin/make -f +mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -spec := contrib/spec/podman.spec -outdir := $(CURDIR) -tmpdir := build -gitdir := $(PWD)/.git - -rev := $(shell git rev-list HEAD | head -n1 | cut -c -7) -date := $(shell date +%Y%m%d.%H%M) - -version := $(shell sed -n '/Version:/{s/.* //;p}' $(spec)) -release := $(date).git.$(rev) - -srpm: $(outdir)/podman-$(version)-$(release).src.rpm - -$(tmpdir)/podman.spec: $(spec) - @mkdir -p $(tmpdir) - sed '/^Release:/s/\(: *\).*/\1$(release)%{?dist}/' $< >$@ - -$(tmpdir)/$(version).tar.gz: $(gitdir)/.. - @mkdir -p $(tmpdir) - tar c --exclude-vcs --exclude-vcs-ignores -C $< --transform 's|^\.|podman-$(version)|' . | gzip -9 >$@ - -$(outdir)/podman-$(version)-$(release).src.rpm: $(tmpdir)/podman.spec $(tmpdir)/$(version).tar.gz - @mkdir -p $(outdir) - rpmbuild -D'_srcrpmdir $(outdir)' -D'_sourcedir $(tmpdir)' -bs $(tmpdir)/podman.spec - -.PHONY: srpm +srpm: + sh $(current_dir)/prepare.sh + rpmbuild -bs -D "dist %{nil}" -D "_sourcedir build/" -D "_srcrpmdir ./" --nodeps contrib/spec/podman.spec diff --git a/.copr/prepare.sh b/.copr/prepare.sh new file mode 100644 index 000000000..d33d55dc7 --- /dev/null +++ b/.copr/prepare.sh @@ -0,0 +1,22 @@ +#!/bin/sh -euf +set -x + +if [ ! -e /usr/bin/git ]; then + dnf -y install git-core +fi + +git fetch --unshallow || : + +COMMIT=$(git rev-parse HEAD) +COMMIT_SHORT=$(git rev-parse --short HEAD) +COMMIT_NUM=$(git rev-list HEAD --count) +COMMIT_DATE=$(date --date="@$(git show -s --format=%ct HEAD)" +%Y%m%d) + +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 + +mkdir build/ +git archive --prefix "podman-${COMMIT_SHORT}/" --format "tar.gz" HEAD -o "build/podman-${COMMIT_SHORT}.tar.gz" |