blob: 9cf62fb222991a57a146950d3305690a7cac31fb (
plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
#!/usr/bin/env build
cat >"${BUILDER_MAKEFILE}" <<EOF
##
# Some generic catchall rules
all: all_all_archive
all_fetch: all_all_fetch
all_prep: all_all_prep
all_compile: all_all_compile
all_archive: all_all_archive
all_install: all_all_install
all_test: all_all_test
all_export: all_all_export
all_source: all_all_source
all_makedeps:
all_source:
sysroot_clean:
@if test -d "${SYSROOT}"; then \
echo "cleaning: sysroot" ; \
(cd "${SYSROOT}" && find . -delete) ; \
fi
artifacts_clean:
@if test -d "${BUILDER_ATFDIR}"; then \
echo "cleaning: artifacts" ; \
(cd "${BUILDER_ATFDIR}" && find . -delete) ; \
fi
tmpdir_clean:
@if test -d "${BUILDER_TMPDIR}"; then \
echo "cleaning: tmpdir" ; \
find "${BUILDER_TMPDIR}" -delete ; \
fi
exports_clean:
@if test -d "${BUILDER_TOPDIR}/exports"; then \
echo "cleaning: exports" ; \
find "${BUILDER_TOPDIR}/exports" -delete ; \
fi
EOF
PACKAGES_CLEAN=
for package in $(echo "${BUILDER_PKGDIR}"/*/*); do
test -d "${package}" || die "no packages defined"
package="${package#${BUILDER_PKGDIR}/}"
if ! test -f "${BUILDER_PKGDIR}/${package}/Buildrules"; then
error "no rulesfile for package '${package}'"
continue
fi
load_rules "${package}"
package_make="$(echo "${package}"|tr '/-' '__')"
package_source="${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source"
package_prep="${BUILDER_TMPDIR}/${CATEGORY}/${NAME}/.prepped"
package_compile="${BUILDER_TMPDIR}/${CATEGORY}/${NAME}/.compiled"
package_archive="${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}"
package_install="${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}"
package_test="${BUILDER_TMPDIR}/${CATEGORY}/${NAME}/.tested"
package_export="${BUILDER_TOPDIR}/exports/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${CHOST%%-*}.rpm"
package_logdir="${L}"
package_sources=
for index in ".git/modules/scripts" "scripts/.git"; do
if test -f "${BUILDER_TOPDIR}/${index}/index"; then
package_sources="${BUILDER_TOPDIR}/${index}/index"
break
fi
done
for config in ${BUILDER_INCLUDED}; do
if test -f "${BUILDER_CFGDIR}/${config}"; then
die "include does not exist '${file}'"
fi
package_sources="${package_sources} ${BUILDER_CFGDIR}/${config}"
done
unset config
for file in ${EXTRA_SOURCES}; do
if test -f "${F}/${file}"; then
die "file does not exist '${file}'"
fi
package_sources="${package_sources} ${F}/${file}"
done
unset file
package_sources="${package_sources} ${RULESFILE}"
if test -f "${BUILDER_PKGDIR}/${CATEGORY}/.buildrules"; then
package_sources="${package_sources} ${BUILDER_PKGDIR}/${CATEGORY}/.buildrules"
fi
for patch in ${PATCHES}; do
patch="${F}/${NAME}-${VERSION}-${patch}.patch"
if ! test -f "${patch}"; then
die "patch does not exist '${patch}'"
fi
package_sources="${package_sources} ${patch}"
done
unset patch
# FIXME there can be strange characters in a URI .. this might not be
# the best approach in the long term.
for url in ${SOURCE_URI}; do
case "${url}" in
# Do not translate local paths into archives in BUILDER_SRCDIR
(file://*|/*) package_sources="${package_sources} ${url##file://}";;
# Assume anything else with :// in the name is remote
(*://*) pkg_src="$(build-url --archive "${url}")"
if test "$?" -ne "0"; then
exit 1
fi
package_sources="${package_sources} ${BUILDER_SRCDIR}/${pkg_src}";;
# Junk?
(*) die "do not know how to handle url '${url}'";;
esac
done
# This loop can end up being fairly costly if we have to fire up
# build-query, particularly when dealing with a large number of
# packages. So we do some FS level checks first in hopes of avoiding
# it and improving performance.
package_bdeps=
package_tdeps=
for pkg_dep in ${BDEPENDS}; do
if ! test -d "${BUILDER_PKGDIR}/${pkg_dep}"; then
die "bad BDEPENDS in package '${package}'"
elif ! test -f "${BUILDER_PKGDIR}/${pkg_dep}/Buildrules"; then
die "no Buildrules for '${pkg_dep}'"
fi
package_bdeps="${package_bdeps} ${SYSROOT}/var/db/binpkgs/${pkg_dep}"
package_tdeps="${package_tdeps} ${BUILDER_TMPDIR}/${pkg_dep}/work/.tested"
done
package_rdeps=
for pkg_dep in ${RDEPENDS}; do
if ! test -d "${BUILDER_PKGDIR}/${pkg_dep}"; then
die "bad RDEPENDS in package '${package}'"
elif ! test -f "${BUILDER_PKGDIR}/${pkg_dep}/Buildrules"; then
die "no Buildrules for '${pkg_dep}'"
fi
package_rdeps="${package_rdeps} ${SYSROOT}/var/db/binpkgs/${pkg_dep}"
done
unset pkg_dep
cat <<EOF
##
# ${CATEGORY}/${NAME} - ${DESCRIPTION}
${package_make}: ${package_archive}
${package_make}_makedeps:
${package_make}_fetch: ${package_sources}
${package_make}_clean:
@build-make-clean "${CATEGORY}/${NAME}"
${package_make}_distclean:
@build-make-distclean "${CATEGORY}/${NAME}"
${package_make}_prep: ${package_prep}
${package_prep}: ${package_sources} ${package_bdeps}
@build-make-prep "${CATEGORY}/${NAME}"
@date >> "${package_prep}"
${package_make}_compile: ${package_compile}
${package_compile}: ${package_prep}
@build-make-compile "${CATEGORY}/${NAME}"
@date >> "${package_compile}"
${package_make}_package: ${package_archive}
${package_archive}: ${package_compile}
@build-make-package "${CATEGORY}/${NAME}"
${package_make}_install: ${package_install}
${package_install}: ${package_archive} ${package_rdeps}
@build-make-install "${CATEGORY}/${NAME}"
${package_make}_source: ${package_source}
${package_source}: ${package_sources}
@build-make-source "${CATEGORY}/${NAME}"
${package_make}_test: ${package_test}
${package_test}: ${package_tdeps} ${package_install}
@build-make-test "${CATEGORY}/${NAME}"
${package_make}_export: ${package_export}
${package_export}: ${package_install}
@build-make-export "${CATEGORY}/${NAME}"
EOF
##
# This is a bit of a fun late-injection of the source archive for a
# package. The core problem is that multiple packages may depend on
# the same sources, so we set up a separate rule for the source
# archive when processing the package, but only if an existing entry
# for that source does not exist. We use the source name (as opposed
# to the package name) to track if the package already has a rule. The
# whole thing really translates into something like
# foo_1_1_3_tar_bz2="http://some/path/to/foo-1.1.3.tar.bz2"
# All forms of URL translation and variable translation are done for us
# by fetch so that makedeps doesn't have any specific expectations on
# what the variable name should be.
for url in ${SOURCE_URI}; do
case "${url}" in
# Do not translate local paths into archives in BUILDER_SRCDIR
(file://*|/*) echo "${url##file://}:";;
# Assume anything else with :// in the name is remote
(*://*)
var="fetch_$(build-url --archive "${url}"|sed 's/[+.-]/_/g')"
if test -z "$(eval echo -n "\$${var}")"; then
eval "${var}='${url}'"
echo "${BUILDER_SRCDIR}/$(build-url --archive "${url}"):"
echo " @build-make-fetch \"${url}\""
fi
;;
esac
done
category="$(echo "${CATEGORY}"|tr '/-' '__')"
CATEGORIES="${CATEGORIES} ${category}"
eval "${category}_SOURCES=\"\${${category}_SOURCES} ${package_sources}\""
eval "${category}_PACKAGES=\"\${${category}_PACKAGES} ${package_archive}\""
eval "${category}_INSTALL=\"\${${category}_INSTALL} ${package_install}\""
eval "${category}_TEST=\"\${${category}_TEST} ${package_test}\""
eval "${category}_EXPORT=\"\${${category}_EXPORT} ${package_export}\""
eval "${category}_SOURCE=\"\${${category}_SOURCE} ${package_source}\""
eval "${category}_CLEAN=\"\${${category}_CLEAN} ${package_make}_clean\""
eval "${category}_DISTCLEAN=\"\${${category}_DISTCLEAN} ${package_make}_distclean\""
PACKAGES_CLEAN="${PACKAGES_CLEAN} ${package_make}_clean"
done >> "${BUILDER_MAKEFILE}"
# FIXME It would have been nice to have not inserted the category if it was
# already in the list.
CATEGORIES="$(for CATEGORY in ${CATEGORIES};do echo "${CATEGORY}";done|sort|uniq)"
for CATEGORY in ${CATEGORIES}; do
cat<<EOF >> "${BUILDER_MAKEFILE}"
${CATEGORY}_all: ${CATEGORY}_archive
${CATEGORY}_all_fetch: $(eval echo "\${${CATEGORY}_SOURCES}")
${CATEGORY}_all_archive: $(eval echo "\${${CATEGORY}_PACKAGES}")
${CATEGORY}_all_install: $(eval echo "\${${CATEGORY}_INSTALL}")
${CATEGORY}_all_test: $(eval echo "\${${CATEGORY}_TEST}")
${CATEGORY}_all_export: $(eval echo "\${${CATEGORY}_EXPORT}")
${CATEGORY}_all_source: $(eval echo "\${${CATEGORY}_SOURCE}")
${CATEGORY}_all_clean: $(eval echo "\${${CATEGORY}_CLEAN}")
${CATEGORY}_all_distclean: $(eval echo "\${${CATEGORY}_DISTCLEAN}")
all_all: ${CATEGORY}_all
all_all_fetch: ${CATEGORY}_all_fetch
all_all_archive: ${CATEGORY}_all_archive
all_all_install: ${CATEGORY}_all_install
all_all_test: ${CATEGORY}_all_test
all_all_export: ${CATEGORY}_all_export
all_all_source: ${CATEGORY}_all_source
EOF
done
cat<<EOF >> "${BUILDER_MAKEFILE}"
all_clean: ${PACKAGES_CLEAN} exports_clean
all_distclean: sysroot_clean artifacts_clean tmpdir_clean exports_clean
all_all_distclean: all_distclean
all_all_clean: all_clean
EOF
# vim: filetype=sh
|