Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 813fde02cb
Fetching contributors…

Cannot retrieve contributors at this time

145 lines (122 sloc) 7.411 kb
# Initial Version Copyright (C) 2010 eZuce, Inc., All Rights Reserved.
# Licensed to the User under the LGPL license.
#
MOCK_CONFIG_DIR = mak/mock
MOCK_TARGET_PLATFORM = $(DISTRO)
# avoids https://bugzilla.redhat.com/show_bug.cgi?id=490613 hit by *some* fedora 14 machines
SRPM_DEFS = --define "_source_filedigest_algorithm md5"
# variable not used here, but can be used in */.sipxecs files
RPM_DIST = @RPM_DIST@
# trick lets you create centos compatible repos from any other distro
CREATEREPO_OPTS_centos = @BACKWARD_COMPATIBLE_CREATEREPO_OPTS_FOR_CENTOS@
CREATEREPO_COMPS = $(SRC)/mak/comps.xml
CREATEREPO_OPTS = -g $(abspath $(CREATEREPO_COMPS)) $(CREATEREPO_OPTS_$(DISTRO_OS))
MOCK_RESULTS_DIR = @RPM_DIST_DIR@/$(DISTRO_RESULTS_DIR)/$(DISTRO_ARCH)
MOCK_SRPM_DIR = @RPM_DIST_DIR@/$(DISTRO_RESULTS_DIR)/source
MOCK_OPTS = \
--configdir=$(MOCK_CONFIG_DIR) \
-r $(MOCK_TARGET_PLATFORM) \
--resultdir=$(MOCK_RESULTS_DIR)
# Define sipx SRPMS and tarball files. Cannot define RPM files however as one specfile may generate many rpms
$(foreach P,$(sipx) $(app),$(eval $(P)_SRPM = $$(call lowercase,$(P))-$(PACKAGE_VERSION)-$$(PROJ_REVISION).src.rpm))
$(foreach P,$(sipx) $(app),$(eval $(P)_TAR = $(P)/$$(call lowercase,$(P))-$(PACKAGE_VERSION).tar.gz))
# pull in dependency make fragments
include $(SRC)/*/.sipxecs.mk
# Allows to target other distros other than the default
help-values.{3} = Any of the available distros identifiers. Complete list: all @ALL_DISTROS@
help-values.{4} = Any rpm related target. Partial list : autoreconf dist rpm srpm rpm-check
help-values.{5} = Any repo related target. Partial list : repo repo-clean repo-chroot-init repo-check repo-create and more...
help.distro.{3}.{1|2}.{4} = Build or operate on a package or set of packages for another distro other than $(DISTRO).
help.distro.{3}.{5} = Build or operate on repository for another distro other than $(DISTRO).
distro.% : SUB_DISTRO=$(word 2,$(subst ., ,$@))
distro.% : SUBMAKE_VARS=DISTRO=$(SUB_DISTRO)
distro.all.% :
# split into separate bash commands so each command gets separate make environment.
# Use command && command && true to ensure a failure in one aborts the build
$(foreach D,@ALL_DISTROS@,$(MAKE) distro.$(D).$* &&) true
# NOTE: 'eval' because 'make a b' when makefile is
# a.% b.% :; x
# only makes x once. usually not what you want and not what we want here
$(foreach D,@ALL_DISTROS@, $(eval distro.$(D).% :; $$(MAKE) $$* $$(SUBMAKE_VARS)))
help.{1|2}.rpm = Build RPMs, you must have mock installed. See Experimental call to build rpms. See \
http://wiki.sipfoundry.org/display/sipXecs/Building+RPMS+on+CentOS+or+Fedora
$(foreach T,$(all),$(T).rpm) : %.rpm : %.autoreconf %.configure %.dist %.srpm %.rpm-by-mock;
CopySourceFile = \
if [ -f $1 ]; then \
cp $1 $2; \
else \
if [ ! -f @DOWNLOAD_LIB_CACHE@/$(notdir $1) ]; then \
curl -f -o @DOWNLOAD_LIB_CACHE@/$(notdir $1) @DOWNLOAD_LIB_URL@/$(notdir $1); \
fi ;\
cp @DOWNLOAD_LIB_CACHE@/$(notdir $1) $2; \
fi; \
help.{1|2}.srpm = Called automatically as part of rpm process after srpm target. Uses rpmbuild command after dist target
%.srpm :
test -d @DOWNLOAD_LIB_CACHE@ || mkdir -p @DOWNLOAD_LIB_CACHE@
test -d $(MOCK_SRPM_DIR) || mkdir -p $(MOCK_SRPM_DIR)
if [ -n "$($(PROJ)_SPEC)" ]; then \
$(foreach S,$($(PROJ)_SOURCES),$(call CopySourceFile,$(S),@RPMBUILD_TOPDIR@/SOURCES)) \
rpmbuild -bs $(SRPM_DEFS) $($(PROJ)_SRPM_DEFS) --nodeps $($(PROJ)_SPEC); \
elif [ -n "$($(PROJ)_TAR)" ]; then \
rpmbuild -ts $(SRPM_DEFS) $($(PROJ)_SRPM_DEFS) --nodeps $($(PROJ)_TAR); \
else \
$(call CopySourceFile,$($(PROJ)_SRPM),@RPMBUILD_TOPDIR@/SRPMS/$($(PROJ)_SRPM)) \
fi
cp @RPMBUILD_TOPDIR@/SRPMS/$($(PROJ)_SRPM) $(MOCK_SRPM_DIR)
help.{1|2}.rpm-by-mock = Called automatically as part of rpm process after srpm target. Uses mock program to build rpm
%.rpm-by-mock : repo-webserver
mock $(MOCK_OPTS) \
--no-clean \
--no-cleanup-after \
--rebuild \
$($(PROJ)_RPM_DEFS) \
$(MOCK_SRPM_DIR)/$($(PROJ)_SRPM)
find $(MOCK_RESULTS_DIR) -name '*.src.rpm' -exec rm {} \;
# generate repo AFTER build because then it's usable as a repo to feed to next build or other systems.
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS) .
repo-comps : $(SRC)/mak/comps.xml
help.repo-chroot-init = Clear mock chroot for $(DISTRO). Requied before first build and useful when you suspect caching is the result of a build error.
repo-chroot-init : repo-create repo-webserver repo-comps repo-comps
mock $(MOCK_OPTS) --scrub=all
test -d $(MOCK_RESULTS_DIR) || mkdir -p $(MOCK_RESULTS_DIR)
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS) .
mock $(MOCK_OPTS) --init
# these files get large, good time to reset them.
find $(MOCK_RESULTS_DIR) -name '*.log' -exec rm {} \;
help.{1|2}.check-rpm = Install the project rpm in the mock environment to test install. This does not install all rpms generated by a project, just the main one. You can install then pretty easily though with command 'mock -r $(MOCK_TARGET_PLATFORM) --install package-name'
%.check-rpm : repo-webserver
mock $(MOCK_OPTS) --install $(proj)
help.repo-clean = Delete all RPMs in $(MOCK_RESULTS_DIR) to ensure fresh build. Build knows how to delete previous build results but only if new RPM results exists.
repo-clean :
test ! -d $(MOCK_RESULTS_DIR) || \
find $(MOCK_RESULTS_DIR) -maxdepth 1 -name '*.rpm' -exec rm {} \;
# points a webserver at $(MOCK_RESULTS_DIR) with no caching headers to feed the results of build back into the
# chroot'ed system. future: explore mounting $(MOCK_RESULTS_DIR) from the chroot system. Possibly there is
# a yum plugin .
# Touching everyfile because squid download proxy will deliver cached files from localhost even when cache live time is zero
# if it has a file time that is newer then the file system. When building rpms from 2 different locations on the sames system
# this is problematic
repo-webserver :
-killall thttpd
find $(MOCK_RESULTS_DIR) -type f -exec touch {} \;
/usr/sbin/thttpd -d @RPM_DIST_DIR@ -p 40100 -M 0
help.repo-src = Assemble source rpms into @RPM_DIST_DIR@/$(DISTRO_RESULTS_DIR)/source
repo-src : repo-comps
for f in $(shell $(SRC)/mak/list-obsolete-rpms $(MOCK_SRPM_DIR)); do rm $$f; done
cd $(MOCK_SRPM_DIR); createrepo $(CREATEREPO_OPTS) .
help.repo-check = Installs sipXecs in chroot. Tip, run repo-chroot-init first for more thourugh test of all dependencies.
repo-check : repo-webserver
mock $(MOCK_OPTS) --install sipxecs
help.repo-remove-dups=If you have built RPMs multiple times between git updates, and therefore have older versions of a package, this will remove all older copies.
repo-remove-dups:
for f in $(shell $(SRC)/mak/list-obsolete-rpms $(MOCK_RESULTS_DIR)); do rm $$f; done
help.repo-create = run createrepo in $(MOCK_RESULTS_DIR)
repo-create: repo-comps
test -d $(MOCK_RESULTS_DIR) || mkdir -p $(MOCK_RESULTS_DIR)
cd $(MOCK_RESULTS_DIR); createrepo $(CREATEREPO_OPTS) .
help.repo-update = If you rebuild local rpms, repo will not automatically replace previously installed versions. This call will force up update to all packages at once.
repo-update :
mock $(MOCK_OPTS) --scrub=yum-cache
mock $(MOCK_OPTS) --update
help.repo = Prepares repository for $(DISTRO) for publishing or re-distributing in ISO by removing extra rpms and moving source rpms to separate directory.
repo: repo-src repo-remove-dups repo-create;
Jump to Line
Something went wrong with that request. Please try again.