-
Notifications
You must be signed in to change notification settings - Fork 4
/
package.mk
61 lines (47 loc) · 1.46 KB
/
package.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
# Include this file from the main Makefile, and define PROJECT_NAME
# before the include statement.
SPEC_NAME:=$(PROJECT_NAME).spec
# Obtain version from RPM spec file
VERSION:=$(shell grep '^Version:' $(SPEC_NAME) | cut -d' ' -f2)
TAR_BASE:=$(PROJECT_NAME)-$(VERSION)
TAR_NAME:=$(TAR_BASE).tar.gz
GIT_FILES:=$(shell git ls-files -co --exclude-standard)
git_dir_pack/$(TAR_NAME): $(GIT_FILES)
rm -rf git_dir_pack
mkdir -p git_dir_pack/$(TAR_BASE)
rsync --relative $(GIT_FILES) git_dir_pack/$(TAR_BASE)
(cd git_dir_pack; tar -zcvf ../$@ $(TAR_BASE))
.PHONY: tarball
tarball: git_dir_pack/$(TAR_NAME)
@echo Tarball can be found at $<
.PHONY: pkgclean
pkgclean: srpmclean
rm -rf git_dir_pack
# RPM-SPECIFIC
RPMBUILD_LOC:=$(shell which rpmbuild)
ifneq ($(RPMBUILD_LOC),)
# Draw pkg name from spec file
RPM_PROJECT_NAME:=$(shell \
rpmspec -q --qf "%{name}\n" $(SPEC_NAME) | \
head -n1)
RPM_BASE:=$(shell \
rpmspec --query --qf "%{name}-%{version}-%{release}\n" $(SPEC_NAME) | \
head -n1)
SRPM_NAME:=$(RPM_BASE).src.rpm
srpmclean:
rm -rf RPMBUILD
rm -f $(RPM_PROJECT_NAME)*.src.rpm
srpm: $(SRPM_NAME)
RPMBUILD/SOURCES/$(TAR_NAME): git_dir_pack/$(TAR_NAME)
mkdir -p RPMBUILD/SOURCES
cp $< $@
$(SRPM_NAME): RPMBUILD/SOURCES/$(TAR_NAME) $(SPEC_NAME)
rpmbuild -bs --define "_topdir $(shell pwd)/RPMBUILD" $(SPEC_NAME)
cp RPMBUILD/SRPMS/$(SRPM_NAME) ./
else
srpm:
@echo "Cannot build SRPM, rpmbuild tools not installed!"
exit 1
srpmclean:
endif
.PHONY: srpmclean srpm