-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
148 lines (124 loc) · 4.32 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
# The username used for fedpkg authentication (when working on beefy PSI
# machines, the username sometimes doesn't match right FAS user.)
fas_user ?= kkleine
# Current working directory
pwd = $(shell pwd)
today = $(shell date +%Y%m%d)
# YearMonthDay to build for (defaults to today)
yyyymmdd ?= $(today)
# A directory in which we checkout the sources for the package and store the
# build artifacts (e.g. SRPM, RPM)
buildroot ?= $(pwd)/buildroot/$(yyyymmdd)
# The default chroot to build for.
chroot ?= $(shell copr list-chroots | grep -P '^fedora-[0-9]+-x86_64' | sort | head -1)
# The mock config that will be used as a template for the final mock config.
# In it we will place the chroot defined above.
mockconfig_template = $(pwd)/mock-config.cfg
# The final mock config location used for the actual build. Will be generated
# upon each invokation.
mockconfig = $(buildroot)/mock-config.cfg
# In case we build on copr, this will be the project to use.
copr_project ?= kkleine/llvm-snapshots-incubator-$(yyyymmdd)
# Include the file that provides the "help" and "help-html" targets.
include ./help.mk
# Builds the mock config if it doesn't exist
$(mockconfig): $(mockconfig_template)
echo "Creating mock config"
$(shell mkdir -pv $(buildroot))
$(shell chroot=$(chroot) envsubst $${chroot} < $(mockconfig_template) > $(mockconfig))
## Clones the upstream-snapshot branch of the given package package (%) into the
## buildroot.
clone-%:
$(eval package:=$(subst clone-,,$@))
@if [ ! -d "$(buildroot)/$(package)" ]; then \
fedpkg --user $(fas_user) clone --branch upstream-snapshot $(package) $(buildroot)/$(package); \
else \
echo ""; \
echo "NOT CLONING BECAUSE DIRECTORY ALREADY EXISTS: $(buildroot)/$(package)"; \
echo ""; \
fi
## Clones and builds the package (%) and then installs it in the chroot.
build-%:
$(eval package:=$(subst build-,,$@))
$(MAKE) clone-$(package)
$(MAKE) build-and-install-$(package)
.PHONY: init-mock
## Initializes the mock chroot.
init-mock: $(mockconfig)
mock -r $(mockconfig) \
--init \
--with snapshot_build \
## For the package (%) an SRPM and an RPM is built and then it is installed in
## the chroot.
build-and-install-%: $(mockconfig)
$(eval package:=$(subst build-and-install-,,$@))
cd $(buildroot)/$(package) \
&& mock -r $(mockconfig) \
--define "_disable_source_fetch 0" \
--define "yyyymmdd $(yyyymmdd)" \
--rebuild \
--no-clean \
--no-cleanup-after \
--spec $(package).spec \
--sources $(buildroot)/$(package) \
--resultdir $(buildroot)/$(package) \
--postinstall
.PHONY: shell
## Opens up a shell to inspect the mock chroot.
shell: $(mockconfig)
mock -r $(mockconfig) --shell --no-clean
.PHONY: install-vim
## Allows you to use vim inside of mock.
install-vim: $(mockconfig)
mock -r $(mockconfig) --install vim
.PHONY: clean-mock
## Cleans the mock chroot
clean-mock: $(mockconfig)
mock -r $(mockconfig) clean
.PHONY: clean-buildroot
## Removes the buildroot directory
clean-buildroot:
rm -rf $(buildroot)
.PHONY: clean
## Cleans the mock chroot and removes the buildroot.
clean: clean-mock clean-buildroot
## Removes the buildroot dir for the given package (%).
clean-%:
$(eval package:=$(subst clean-,,$@))
rm -rf $(buildroot)/$(package)
## Builds the package (%) in copr by using the tooling used for the automated
## snapshot generation.
copr-build-%:
$(eval package:=$(subst copr-build-,,$@))
@if [ "$(today)" != "$(yyyymmdd)" ]; then \
echo "Sorry, but due to the project setup in copr we can only build for today ($(today))!"; \
exit 1; \
fi
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m llvm_snapshot_builder.cli --verbose \
create-project \
--proj "$(copr_project)" \
--description-file "$(pwd)/project-description.md" \
--instructions-file "$(pwd)/project-instructions.md" \
--delete-after-days 7 \
--chroots $(chroot) \
--update
python -m llvm_snapshot_builder.cli --verbose \
create-packages \
--proj "$(copr_project)" \
--packagenames $(package) \
--update
python -m llvm_snapshot_builder.cli --verbose \
build-packages \
--proj "$(copr_project)" \
--chroots $(chroot) \
--packagenames $(package) \
--timeout "108000"
.PHONY:
test-snapshot-manager:
# pytest --doctest-modules
coverage run -m pytest
coverage report -m