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
68 changes: 5 additions & 63 deletions agent/rpm/Makefile
Original file line number Diff line number Diff line change
@@ -1,65 +1,7 @@
# Making a pbench-agent RPM requires a few steps:
# 1. Get version number.
# 2. Update the RPM spec file with that version number etc.
# 3. Update the stockpile submodule.
# 4. Do a "make install" of the agent to a temp directory.
# 5. Generate a tar ball from the directory.
# 6. Generate a local SRPM that will be uploaded to COPR for building.
# 7. Optionally generate a local RPM.
# 8. Clean up the temp directory
# Makefile for generating a source RPM and optional local RPM
# for the Pbench agent.

CWD = $(shell pwd)
component = agent
subcomps = agent

# adjust as necessary
AGENT = $(dir ${CWD})

VERSION = $(file < ${AGENT}/VERSION)

# temp directory for packing up the tarball
TMPDIR = /tmp/opt

RPMSRC = ${HOME}/rpmbuild/SOURCES
RPMSRPM = ${HOME}/rpmbuild/SRPMS
RPMSPEC = ${HOME}/rpmbuild/SPECS

prog = pbench-agent
arch = noarch

USE_GIT_SHA1 = yes
sha1 := $(shell git rev-parse --short HEAD)
seqno := $(shell if [ -e ./seqno ] ;then cat ./seqno ;else echo "1" ;fi)

# By default we only build a source RPM
all: srpm

rpm: srpm
rpmbuild -bb ${RPMSPEC}/${prog}.spec

srpm: spec patches tarball
rm -f ${RPMSRPM}/$(prog)-*.src.rpm
rpmbuild -bs ${RPMSPEC}/${prog}.spec

.PHONY: spec
spec: ${prog}.spec.j2
mkdir -p ${RPMSPEC}
if [ -e ./seqno ] ;then expr ${seqno} + 1 > ./seqno ;fi
jinja2 ${prog}.spec.j2 -D version=${VERSION} -D gdist=g${sha1} -D seqno=${seqno} > ${RPMSPEC}/${prog}.spec
rpmlint ${RPMSPEC}/${prog}.spec

.PHONY: patches
patches:
if [ -d ${CWD}/patches ] ;then cp ${CWD}/patches/* ${RPMSRC} ;fi

.PHONY: tarball
tarball:
mkdir -p ${RPMSRC}
(cd ${AGENT}/../; git submodule init; git submodule update)
make -C .. DESTDIR=${TMPDIR}/${prog}-${VERSION}/agent
echo "${sha1}" > ${TMPDIR}/${prog}-${VERSION}/agent/SHA1
echo "${seqno}" > ${TMPDIR}/${prog}-${VERSION}/agent/SEQNO
tar zcf ${RPMSRC}/pbench-agent-${VERSION}.tar.gz -C ${TMPDIR} ${prog}-${VERSION}
rm -rf ${TMPDIR}

include rpm.mk

clean:: rpm-clean
include ../../utils/rpm.mk
46 changes: 0 additions & 46 deletions agent/rpm/rpm.mk

This file was deleted.

74 changes: 5 additions & 69 deletions server/rpm/Makefile
Original file line number Diff line number Diff line change
@@ -1,71 +1,7 @@
# Making a pbench-server RPM requires a few steps
# 1. Generate a version number
# 2. Update the RPM spec file with that version number
# 3. Generate a tar ball of the sources to be used by the RPM building process
# 4. Generate an SRPM that will be uploaded to COPR for building.
# Makefile for generating a source RPM and optional local RPM
# for the Pbench server.

CWD = $(shell pwd -L)

SERVER = $(dir ${CWD})
PBENCHTOP = $(shell dirname ${SERVER})
TMPDIR = /tmp/opt

VERSION = $(shell cat ${SERVER}/VERSION)

DISTRO = $(shell uname -r | python -c 'import sys; print(sys.stdin.read().split(".")[-2])')

PYTHON = python3

RPMSRC = ${HOME}/rpmbuild/SOURCES
RPMSRPM = ${HOME}/rpmbuild/SRPMS
RPMSPEC = ${HOME}/rpmbuild/SPECS

prog = pbench-server
arch = noarch

TBDIR = ${TMPDIR}/${prog}-${VERSION}

USE_GIT_SHA1 = yes
sha1 = $(shell git rev-parse --short HEAD)
seqno := $(shell if [ -e ./seqno ] ;then cat ./seqno ;else echo "1" ;fi)

rpm: srpm
rpmbuild -bb ${HOME}/rpmbuild/SPECS/${prog}.spec

srpm: patches tarball
rm -f ${HOME}/rpmbuild/SRPMS/$(prog)-*.src.rpm
rpmbuild -bs ${HOME}/rpmbuild/SPECS/$(prog).spec

.PHONY: spec
spec: ${prog}.spec.j2
mkdir -p ${RPMSPEC}
if [ -e ./seqno ] ;then expr ${seqno} + 1 > ./seqno ;fi
jinja2 ${prog}.spec.j2 -D version=${VERSION} -D gdist=g${sha1} -D seqno=${seqno} > ${RPMSPEC}/${prog}.spec
rpmlint ${RPMSPEC}/${prog}.spec

.PHONY: patches
patches:
if [ -d ${CWD}/patches ] ;then cp ${CWD}/patches/* ${RPMSRC} ;fi

.PHONY: tarball
tarball: spec
mkdir -p ${RPMSRC}
make -C ${PBENCHTOP}/server DESTDIR=${TBDIR}/server install
make -C ${PBENCHTOP}/web-server DESTDIR=${TBDIR}/web-server install
sed -i '1s;.*python$$;#!/usr/bin/env python3;' ${TBDIR}/server/bin/pbench-config ${TBDIR}/server/bin/pbench-server
echo "${sha1}" > ${TBDIR}/server/SHA1
echo "${seqno}" > ${TBDIR}/server/SEQNO
tar zcf ${RPMSRC}/pbench-server-${VERSION}.tar.gz -C ${TMPDIR} ${prog}-${VERSION}
rm -rf ${TMPDIR}

###########################################################################
# build RPMs in COPR
seqno := $(shell if [ -f seqno ] ;then cat seqno ;else echo 1; fi)

include rpm.mk

clean-sha1:
rm -f ${upstmtree}/${prog}.SHA1

clean:: localclean
component = server
subcomps = server web-server

include ../../utils/rpm.mk
55 changes: 0 additions & 55 deletions server/rpm/rpm.mk

This file was deleted.

92 changes: 92 additions & 0 deletions utils/rpm.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Common definitions for making an RPM, used by both the Agent and the Server.
#
# Making a pbench component RPM requires a few steps:
# 1. Get version number.
# 2. Update the RPM spec file with that version number etc.
# 3. Update any GIT submodules.
# 4. Do a "make install" to a temp directory.
# 5. Generate a tar ball from the directory.
# 6. Generate a local SRPM that will be uploaded to COPR for building.
# 7. Optionally generate a local RPM.
# 8. Clean up the temp directory

PBENCHTOP := $(shell git rev-parse --show-toplevel)
TMPDIR = /tmp/opt

prog = pbench-${component}
VERSION := $(file < ${PBENCHTOP}/${component}/VERSION)
TBDIR = ${TMPDIR}/${prog}-${VERSION}

RPMDIRS = BUILD BUILDROOT SPECS SOURCES SRPMS RPMS

RPMSRC = ${HOME}/rpmbuild/SOURCES
RPMSRPM = ${HOME}/rpmbuild/SRPMS
RPMSPEC = ${HOME}/rpmbuild/SPECS

sha1 := $(shell git rev-parse --short HEAD)
seqno := $(shell if [ -e ./seqno ] ;then cat ./seqno ;else echo "1" ;fi)

# By default we only build a source RPM
all: srpm

.PHONY: rpm
rpm: spec srpm
rpmbuild -bb ${RPMSPEC}/${prog}.spec

.PHONY: srpm
srpm: spec patches tarball
rm -f ${RPMSRPM}/$(prog)-*.src.rpm
rpmbuild -bs ${RPMSPEC}/${prog}.spec

.PHONY: spec
spec: rpm-dirs ${prog}.spec.j2
if [ -e ./seqno ] ;then expr ${seqno} + 1 > ./seqno ;fi
jinja2 ${prog}.spec.j2 -D version=${VERSION} -D gdist=g${sha1} -D seqno=${seqno} > ${RPMSPEC}/${prog}.spec
rpmlint ${RPMSPEC}/${prog}.spec

.PHONY: patches
patches: rpm-dirs
if [ -d ./patches ] ;then cp ./patches/* ${RPMSRC}/ ;fi

.PHONY: tarball
tarball: rpm-dirs submodules ${subcomps}
echo "${sha1}" > ${TBDIR}/${component}/SHA1
echo "${seqno}" > ${TBDIR}/${component}/SEQNO
tar zcf ${RPMSRC}/${prog}-${VERSION}.tar.gz -C ${TMPDIR} ${prog}-${VERSION}
rm -rf ${TMPDIR}

.PHONY: rpm-dirs
rpm-dirs:
mkdir -p $(addprefix ${HOME}/rpmbuild/,${RPMDIRS})

.PHONY: submodules
submodules:
git submodule update --init --recursive

.PHONY: ${subcomps}
${subcomps}:
make -C ${PBENCHTOP}/$@ DESTDIR=${TBDIR}/$@ install

$(RPMSRPM)/$(prog)-$(version)-$(seqno)$(sha1).src.rpm: srpm

ifdef COPR_USER
_copr_user = ${COPR_USER}
else
_copr_user = ${USER}
endif

COPR_TARGETS = copr copr-test
.PHONY: ${COPR_TARGETS}
${COPR_TARGETS}: $(RPMSRPM)/$(prog)-$(version)-$(seqno)$(sha1).src.rpm
copr-cli build $(_copr_user)/$(subst copr,pbench,$@) $(RPMSRPM)/$(prog)-$(VERSION)-$(seqno)g$(sha1).src.rpm

.PHONY: distclean
distclean:
rm -rf $(addprefix ${HOME}/rpmbuild/,${RPMDIRS})

.PHONY: clean
clean:: rpm-clean

.PHONY: rpm-clean
rpm-clean:
rm -rf $(foreach dir,${RPMDIRS},${HOME}/rpmbuild/${dir}/*)