This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmfRPMRules.mk
125 lines (106 loc) · 5.48 KB
/
mfRPMRules.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Created with insights from
## amc13/config/mfRPMRules.mk
## xdaq/config/mfRPM.rules
## xdaq/config/mfBuildRPM.rules
## xdaq/config/mfSetupRPM.rules
## xdaq/config/mfExternRPM.rules
ProjectPath?=$(BUILD_HOME)/$(Project)
PackagePath?=$(ProjectPath)
RPM_DIR:=$(PackagePath)/rpm
RPMBUILD_DIR:=$(RPM_DIR)/RPMBUILD
ifndef BUILD_COMPILER
BASE_COMPILER =$(word 1, $(shell $(CC) --version))
BASE_COMPILER :=$(subst -,_,$(BASE_COMPILER))
BUILD_COMPILER:=$(BASE_COMPILER)$(shell $(CC) -dumpfullversion -dumpversion | sed -e 's/\./_/g')
endif
ifndef PACKAGE_FULL_RELEASE
# would like to use the correct %?{dist}
PACKAGE_FULL_RELEASE=$(BUILD_VERSION).$(GITREV)git.$(GEM_OS).$(BUILD_COMPILER)
endif
ifndef REQUIRED_PACKAGE_LIST
REQUIRED_PACKAGE_LIST=$(shell awk 'BEGIN{IGNORECASE=1} /define $(PackageName)_REQUIRED_PACKAGE_LIST/ {print $$3;}' $(PackagePath)/include/packageinfo.h)
endif
ifndef BUILD_REQUIRED_PACKAGE_LIST
BUILD_REQUIRED_PACKAGE_LIST=$(shell awk 'BEGIN{IGNORECASE=1} /define $(PackageName)_BUILD_REQUIRED_PACKAGE_LIST/ {print $$3;}' $(PackagePath)/include/packageinfo.h)
endif
REQUIRES_LIST=0
ifndef REQUIRED_PACKAGE_LIST
REQUIRES_LIST=1
endif
BUILD_REQUIRES_LIST=0
ifndef BUILD_REQUIRED_PACKAGE_LIST
BUILD_REQUIRES_LIST=1
endif
RPM_OPTIONS=
ifeq ($(Arch),arm)
RPM_OPTIONS=--define "_binary_payload 1"
endif
.PHONY: rpm rpmprep
## @rpm performs all steps necessary to generate RPM packages
rpm: _spec_update _rpmbuild _rpmharvest
## @rpm Perform any specific setup before packaging, is an implicit dependency of `rpm`
rpmprep:
.PHONY: _rpmbuild _rpmharvest
_rpmbuild: all _spec_update rpmprep
$(MakeDir) $(RPMBUILD_DIR)/{RPMS/{arm,noarch,i586,i686,x86_64},SPECS,BUILD,SOURCES,SRPMS}
rpmbuild --quiet -ba -bl \
--buildroot=$(RPMBUILD_DIR)/BUILDROOT \
--define "_requires $(REQUIRES_LIST)" \
--define "_build_requires $(BUILD_REQUIRES_LIST)" \
--define "_topdir $(RPMBUILD_DIR)" \
$(RPM_DIR)/$(PackageName).spec \
$(RPM_OPTIONS) --target "$(Arch)"
_rpmharvest: _rpmbuild
find $(RPMBUILD_DIR) -name "*.rpm" -exec mv {} $(RPM_DIR)/ \;
.PHONY: _spec_update
_spec_update:
$(MakeDir) $(RPMBUILD_DIR)
if [ -e $(PackagePath)/spec.template ]; then \
echo "$(PackagePath) found spec.template"; \
echo "cp $(PackagePath)/spec.template $(RPM_DIR)/$(PackageName).spec"; \
cp $(PackagePath)/spec.template $(RPM_DIR)/$(PackageName).spec; \
elif [ -e $(ProjectPath)/config/specTemplate.spec ]; then \
echo "$(ProjectPath)/config/specTemplate.spec found"; \
echo "cp $(ProjectPath)/config/specTemplate.spec $(RPM_DIR)/$(PackageName).spec"; \
cp $(ProjectPath)/config/specTemplate.spec $(RPM_DIR)/$(PackageName).spec; \
else \
echo "No valid spec template found"; \
exit 2; \
fi
sed -i 's#__gitrev__#$(GITREV)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__builddate__#$(BUILD_DATE)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__package__#$(Package)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__longpackage__#$(LongPackage)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__packagename__#$(PackageName)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__version__#$(PACKAGE_FULL_VERSION)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__release__#$(PACKAGE_FULL_RELEASE)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__prefix__#$(INSTALL_PATH)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__sources_dir__#$(RPMBUILD_DIR)/SOURCES#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__packagedir__#$(PackagePath)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__os__#$(GEM_OS)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__platform__#$(GEM_PLATFORM)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__project__#$(Project)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__author__#$(Packager)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__summary__#None#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__description__#None#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__url__#None#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__buildarch__#$(Arch)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__requires_list__#$(REQUIRED_PACKAGE_LIST)#' $(RPM_DIR)/$(PackageName).spec
sed -i 's#__build_requires_list__#$(BUILD_REQUIRED_PACKAGE_LIST)#' $(RPM_DIR)/$(PackageName).spec
# @if [ "${BuildDebuginfoRPM}" == "1" ]; then \
# echo "sed -i '1 i\%define _build_debuginfo_package %{nil}' $(RPM_DIR)/$(PackageName).spec"; \
# sed -i '1 i\%define _build_debuginfo_package %{nil}' $(RPM_DIR)/$(PackageName).spec; \
# fi
@if [ -e $(PackagePath)/scripts/postinstall.sh ]; then \
echo "sed -i '\#\bpost\b#r $(PackagePath)/scripts/postinstall.sh' $(RPM_DIR)/$(PackageName).spec"; \
sed -i '\#\bpost\b#r $(PackagePath)/scripts/postinstall.sh' $(RPM_DIR)/$(PackageName).spec; \
echo "sed -i 's#__prefix__#$(INSTALL_PATH)#' $(RPM_DIR)/$(PackageName).spec"; \
sed -i 's#__prefix__#$(INSTALL_PATH)#' $(RPM_DIR)/$(PackageName).spec; \
fi
.PHONY: cleanrpm cleanallrpm
## @rpm Clean up the rpm build directory
cleanrpm:
$(RM) $(RPMBUILD_DIR)
## @rpm Entirely remove the rpm directory
cleanallrpm: cleanrpm
$(RM) $(RPM_DIR)