forked from zssfred/cderpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (64 loc) · 2.23 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Makefile to drive local builds of the cde RPM.
# Author: David Cantrell <[email protected]>
CWD := $(shell pwd)
RPMBUILD = rpmbuild --define='_topdir $(CWD)' \
--define='_sourcedir $(CWD)' \
--define='_specdir $(CWD)'
URL = https://www.burdell.org/cde/
NAME = $(shell grep Name: cde.spec | awk '{ print $$2; }')
VERSION = $(shell grep Version: cde.spec | awk '{ print $$2; }')
RELEASE = $(shell grep Release: cde.spec | awk '{ print $$2; }' | cut -d '%' -f 1)
ARCH = $(shell uname -m)
all: fetch
$(RPMBUILD) -ba cde.spec
# This could be improved from any of my other projects.
fetch:
@while read checksum filename ; do \
if [ -f ${CWD}/$${filename} ]; then \
computed="$$(sha256sum $(CWD)/$${filename} | cut -d ' ' -f 1)" ; \
if [ "$${computed}" = "$${checksum}" ]; then \
echo "Already have $${filename} and it checks out." ; \
else \
curl -O $(URL)/$${filename} ; \
computed="$$(sha256sum $(CWD)/$${filename} | cut -d ' ' -f 1)" ; \
if [ ! "$${computed}" = "$${checksum}" ]; then \
echo "*** INVALID CHECKSUM $${filename}" ; \
exit 1 ; \
fi ; \
fi ; \
else \
curl -O $(URL)/$${filename} ; \
computed="$$(sha256sum $(CWD)/$${filename} | cut -d ' ' -f 1)" ; \
if [ ! "$${computed}" = "$${checksum}" ]; then \
echo "*** INVALID CHECKSUM $${filename}" ; \
exit 1 ; \
fi ; \
fi ; \
done < $(CWD)/sources
# Local RPM building right here in this directory
prep:
$(RPMBUILD) -bp cde.spec
compile:
$(RPMBUILD) -bb cde.spec
install:
$(RPMBUILD) -bi cde.spec
srpm: fetch
$(RPMBUILD) -bs -v cde.spec 2>&1 | tee rpmbuild.out
srpm="$$(echo $$(basename $$(cut -d ' ' -f 2 < rpmbuild.out)))" ; \
mv $(CWD)/SRPMS/$$srpm $(CWD)
rm -f rpmbuild.out
# Release helpers
tag:
git tag -s -m "Tag $(NAME)-$(VERSION)-$(RELEASE)" $(NAME)-$(VERSION)-$(RELEASE)
clog:
@len=$$(($$(wc -l < cde.spec) - $$(sed -n '/%changelog/=' cde.spec))) ; \
top=$$(tail -n $$len cde.spec | sed -n '/^$$/=' | head -n 1) ; \
tail -n $$len cde.spec | head -n $$(($$top - 1)) > clog
@cat clog
# Housekeeping
clean:
-rm -rf BUILD BUILDROOT RPMS SRPMS clog
realclean: clean
while read checksum filename ; do \
[ -f "$$filename" ] && rm -f "$$filename" ; \
done < $(CWD)/sources