-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (41 loc) · 1.43 KB
/
Makefile
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
name=emi-version
tag=master
#package_version=3.5.0-1
git=https://github.com/caifti/emi-version.git
# needed dirs
source_dir=sources
rpmbuild_dir=$(shell pwd)/rpmbuild
# spec file
spec_src=$(name).spec.in
spec=$(name).spec
dist=$(shell rpm --eval '%dist' | sed 's/%dist/.el5/')
.PHONY: clean rpm
all: rpm
print-info:
@echo
@echo
@echo "Packaging $(name) fetched from $(git) for tag $(tag)."
@echo
prepare-sources: sanity-checks clean
mkdir -p $(source_dir)/$(name)
git clone $(git) $(source_dir)/$(name)
cd $(source_dir)/$(name) && git checkout $(tag) && git archive --format=tar --prefix=$(name)-$(package_version)/ $(tag) > $(name)-$(package_version).tar
cd $(source_dir) && gzip $(name)/$(name)-$(package_version).tar
cp $(source_dir)/$(name)/$(name)-$(package_version).tar.gz $(source_dir)/$(name)-$(package_version).tar.gz
prepare-spec: prepare-sources
sed -e 's#@@PACKAGE_VERSION@@#$(package_version)#g' \
$(spec_src) > $(spec)
rpm: prepare-spec
mkdir -p $(rpmbuild_dir)/BUILD \
$(rpmbuild_dir)/RPMS \
$(rpmbuild_dir)/SOURCES \
$(rpmbuild_dir)/SPECS \
$(rpmbuild_dir)/SRPMS
cp $(source_dir)/$(name)-$(package_version).tar.gz $(rpmbuild_dir)/SOURCES
rpmbuild --nodeps -v -ba $(spec) --define "_topdir $(rpmbuild_dir)" --define "dist $(dist)" --define "package_version $(package_version)"
clean:
rm -rf $(source_dir) $(rpmbuild_dir) $(spec)
sanity-checks:
ifndef package_version
$(error package_version is undefined)
endif