-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
90 lines (75 loc) · 5.66 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
77
78
79
80
81
82
83
84
85
86
87
88
89
VERSION = 2.0.0
RELEASE = 1
# system paths
RESULT_PATH = target
RPMBUILD_PATH = ~/rpmbuild
all: help
help:
@printf '\nusuage make ...\n'
@printf ' clean -> remove results\n'
@printf ' package -> package archive for deploy .tar.xz\n'
@printf ' build-spec -> build python3-pkb-client.spec\n'
@printf ' build-srpm -> build python3-pkb-client-'${VERSION}-${RELEASE}'.src.rpm\n'
@printf ' build-rpm -> build python3-pkb-client-'${VERSION}-${RELEASE}'.noarch.rpm\n'
# helper commands
clean:
@printf '[INFO] removing '${RESULT_PATH}/'\n'
@rm -rf python3-pkb-client.spec ${RESULT_PATH}/
package: ${RESULT_PATH}/python3-pkb-client-${VERSION}.tar.xz
build-spec: python3-pkb-client.spec
build-srpm: ${RESULT_PATH}/python3-pkb-client-${VERSION}-${RELEASE}.src.rpm
build-rpm: ${RESULT_PATH}/python3-pkb-client-${VERSION}-${RELEASE}.noarch.rpm
# file generators
python3-pkb-client.spec:
@mkdir -p ${RESULT_PATH}/
@printf '[INFO] generating python3-pkb-client.spec\n' | tee -a ${RESULT_PATH}/build.log
@printf '%%global modname pkb_client\n\n' > python3-pkb-client.spec
@printf 'Name: python3-pkb-client\n' >> python3-pkb-client.spec
@printf 'Version: '${VERSION}'\n' >> python3-pkb-client.spec
@printf 'Release: '${RELEASE}'\n' >> python3-pkb-client.spec
@printf 'Obsoletes: %%{name} <= %%{version}\n' >> python3-pkb-client.spec
@printf 'Summary: Python client for the Porkbun API\n\n' >> python3-pkb-client.spec
@printf 'License: MIT License\n' >> python3-pkb-client.spec
@printf 'URL: https://github.com/infinityofspace/pkb_client/\n' >> python3-pkb-client.spec
@printf 'Source0: %%{name}-%%{version}.tar.xz\n\n' >> python3-pkb-client.spec
@printf 'BuildArch: noarch\n' >> python3-pkb-client.spec
@printf 'BuildRequires: python3-setuptools\n' >> python3-pkb-client.spec
@printf 'BuildRequires: python3-rpm-macros\n' >> python3-pkb-client.spec
@printf 'BuildRequires: python3-py\n\n' >> python3-pkb-client.spec
@printf '%%?python_enable_dependency_generator\n\n' >> python3-pkb-client.spec
@printf '%%description\n' >> python3-pkb-client.spec
@printf 'Python client for the Porkbun API\n\n' >> python3-pkb-client.spec
@printf '%%prep\n' >> python3-pkb-client.spec
@printf '%%autosetup -n %%{modname}_v%%{version}\n\n' >> python3-pkb-client.spec
@printf '%%build\n' >> python3-pkb-client.spec
@printf '%%py3_build\n\n' >> python3-pkb-client.spec
@printf '%%install\n' >> python3-pkb-client.spec
@printf '%%py3_install\n\n' >> python3-pkb-client.spec
@printf '%%files\n' >> python3-pkb-client.spec
@printf '%%doc Readme.md\n' >> python3-pkb-client.spec
@printf '%%license License\n' >> python3-pkb-client.spec
@printf '%%{_bindir}/pkb-client\n' >> python3-pkb-client.spec
@printf '%%{python3_sitelib}/%%{modname}/\n' >> python3-pkb-client.spec
@printf '%%{python3_sitelib}/%%{modname}-%%{version}*\n\n' >> python3-pkb-client.spec
@printf '%%changelog\n' >> python3-pkb-client.spec
@printf '...\n' >> python3-pkb-client.spec
@printf '\n' >> python3-pkb-client.spec
${RESULT_PATH}/python3-pkb-client-${VERSION}.tar.xz:
@mkdir -p ${RESULT_PATH}/
@printf '[INFO] packing python3-pkb-client-'${VERSION}'.tar.xz\n' | tee -a ${RESULT_PATH}/build.log
@mkdir -p ${RESULT_PATH}/pkb_client_v${VERSION}
@cp -r pkb_client requirements.txt setup.py License Readme.md \
${RESULT_PATH}/pkb_client_v${VERSION}/
@cd ${RESULT_PATH}; tar -I "pxz -9" -cf python3-pkb-client-${VERSION}.tar.xz pkb_client_v${VERSION}
${RESULT_PATH}/python3-pkb-client-${VERSION}-${RELEASE}.src.rpm: ${RESULT_PATH}/python3-pkb-client-${VERSION}.tar.xz python3-pkb-client.spec
@printf '[INFO] building python3-pkb-client-'${VERSION}-${RELEASE}'.src.rpm\n' | tee -a ${RESULT_PATH}/build.log
@mkdir -p ${RPMBUILD_PATH}/SOURCES/
@cp ${RESULT_PATH}/python3-pkb-client-${VERSION}.tar.xz ${RPMBUILD_PATH}/SOURCES/
@rpmbuild -bs python3-pkb-client.spec &>> ${RESULT_PATH}/build.log
@mv ${RPMBUILD_PATH}/SRPMS/python3-pkb-client-${VERSION}-${RELEASE}.src.rpm ${RESULT_PATH}/
${RESULT_PATH}/python3-pkb-client-${VERSION}-${RELEASE}.noarch.rpm: ${RESULT_PATH}/python3-pkb-client-${VERSION}-${RELEASE}.src.rpm
@printf '[INFO] building python3-pkb-client-'${VERSION}-${RELEASE}'.noarch.rpm\n' | tee -a ${RESULT_PATH}/build.log
@mkdir -p ${RPMBUILD_PATH}/SRPMS/
@cp ${RESULT_PATH}/python3-pkb-client-${VERSION}-${RELEASE}.src.rpm ${RPMBUILD_PATH}/SRPMS/
@rpmbuild --rebuild ${RESULT_PATH}/python3-pkb-client-${VERSION}-${RELEASE}.src.rpm &>> ${RESULT_PATH}/build.log
@mv ${RPMBUILD_PATH}/RPMS/noarch/python3-pkb-client-${VERSION}-${RELEASE}.noarch.rpm ${RESULT_PATH}/