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
|
# $OpenBSD: bsd.syspatch.mk,v 1.3 2016/09/05 11:55:06 robert Exp $
#
# Copyright (c) 2016 Robert Nagy <robert@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.include <bsd.own.mk>
ERRATA?=
# binaries used by this makefile
FETCH= /usr/bin/ftp -Vm
# make sure to only use the original OpenBSD mirror
MIRROR= http://ftp.openbsd.org/pub/OpenBSD/patches/${OSREV}/common
# the final name of the syspatch tarball
SYSPATCH= syspatch-${OSrev}-${ERRATA}.tgz
# arguments used by different tools
MTREE_FILES= /etc/mtree/4.4BSD.dist
MTREE_ARGS= -qdep ${FAKE} -U
SIGNIFY_KEY= /etc/signify/openbsd-${OSrev}-base.pub
PATCH_STRIP?= -p0
PATCH_ARGS= -d ${SRCDIR} -z .orig --forward --quiet -E ${PATCH_STRIP}
# build type defaults to src
BUILD?= src
# miscellaneous variables
SYSPATCH_DIR= ${FAKE}/var/syspatch/${OSREV}
FAKE= ${ERRATA}/fake
SRCDIR= ${BSDSRCDIR}
SUBDIR?=
_PATCH_COOKIE= ${ERRATA}/.patch_done
_BUILD_COOKIE= ${ERRATA}/.build_done
_FAKE_COOKIE= ${ERRATA}/.fake_done
_INSTALL_COOKIE=${ERRATA}/.install_done
.if ${BUILD:L:Msrc}
SRCDIR= ${BSDSRCDIR}
.elif ${BUILD:L:Mxenocara}
SRCDIR= ${X11SRC}
MTREE_FILES+= /etc/mtree/BSD.x11.dist
.endif
.MAIN: all
all: ${_BUILD_COOKIE}
.if !target(clean)
clean:
rm -rf .depend ${ERRATA} ${SYSPATCH}
.endif
cleandir: clean
${_FAKE_COOKIE}: ${_BUILD_COOKIE}
.for _m in ${MTREE_FILES}
@${SUDO} /usr/sbin/mtree ${MTREE_ARGS} -f ${_m} >/dev/null
.endfor
@touch $@
${ERRATA}/${ERRATA}.patch:
@${INSTALL} -d -m 755 ${SYSPATCH_DIR} && \
echo ">> Fetch ${MIRROR}/${.TARGET:T}.sig"; \
if ${FETCH} -o ${SYSPATCH_DIR}/${.TARGET:T}.sig \
${MIRROR}/${.TARGET:T}.sig; then \
if /usr/bin/signify -Vep ${SIGNIFY_KEY} -x \
${SYSPATCH_DIR}/${.TARGET:T}.sig -m ${.TARGET}; then \
exit 0; \
fi; \
fi; exit 1
${_PATCH_COOKIE}: ${ERRATA}/${ERRATA}.patch
@/usr/bin/patch ${PATCH_ARGS} < ${ERRATA}/${ERRATA}.patch || \
{ echo "***> ${ERRATA}.patch did not apply cleanly"; \
exit 1; };
@touch $@
${_INSTALL_COOKIE}: ${_FAKE_COOKIE}
.if ${BUILD:L:Msrc} || ${BUILD:L:Mxenocara}
. if defined(SUBDIR) && !empty(SUBDIR)
. for _s in ${SUBDIR}
@if [ -f ${_s}/Makefile.bsd-wrapper ]; then \
_mk_spec_="-f Makefile.bsd-wrapper"; \
fi; \
cd ${_s} && ${SUDO} /usr/bin/make $${_mk_spec_} \
DESTDIR=${.OBJDIR}/${FAKE} install
. endfor
. endif
.elif ${BUILD:L:Mkernel}
. for _kern in GENERIC GENERIC.MP
@if [ ${_kern} = "GENERIC" ]; then \
${SUDO} \
cp -p ${SRCDIR}/sys/arch/${MACHINE_ARCH}/compile/${_kern}/bsd \
${.OBJDIR}/${FAKE}/bsd || \
{ echo "***> failed to install ${_kern}"; \
exit 1; }; \
elif [ ${_kern} = "GENERIC.MP" ]; then \
${SUDO} \
cp -p ${SRCDIR}/sys/arch/${MACHINE_ARCH}/compile/${_kern}/bsd \
${.OBJDIR}/${FAKE}/bsd.mp || \
{ echo "***> failed to install ${_kern}"; \
exit 1; }; \
fi; exit 0
. endfor
.endif
@touch $@
${_BUILD_COOKIE}: ${_PATCH_COOKIE}
.if ${BUILD:L:Msrc} || ${BUILD:L:Mxenocara}
. if defined(SUBDIR) && !empty(SUBDIR)
. for _s in ${SUBDIR}
@if [ -f ${_s}/Makefile.bsd-wrapper ]; then \
_mk_spec_="-f Makefile.bsd-wrapper"; \
fi; \
for _t in obj depend all; do \
cd ${_s} && /usr/bin/make $${_mk_spec_} $${_t}; \
done;
. endfor
. endif
.elif ${BUILD:L:Mkernel}
. for _kern in GENERIC GENERIC.MP
@if cd ${SRCDIR}/sys/arch/${MACHINE_ARCH}/conf; then \
if config ${_kern}; then \
if cd ../compile/${_kern} && make clean && make; then \
exit 0; \
fi; exit 1; \
fi; exit 1; \
fi; exit 1
. endfor
.endif
@touch $@
syspatch: ${SYSPATCH}
${SYSPATCH}: ${ERRATA}/.plist
.for _m in ${MTREE_FILES}
@${SUDO} /usr/sbin/mtree ${MTREE_ARGS} -f ${_m} >/dev/null
@${SUDO} chown -R root:wheel ${SYSPATCH_DIR}
.endfor
@tar -Pczf ${.TARGET} -C ${FAKE} -I ${ERRATA}/.plist || \
{ echo "***> unable to create ${.TARGET}"; \
exit 1; };
@echo ">> Created ${SYSPATCH}"; \
${ERRATA}/.fplist: ${_INSTALL_COOKIE}
@${SUDO} find ${FAKE} \! -type d > ${.OBJDIR}/${ERRATA}/.fplist || \
{ echo "***> unable to create list of files"; \
exit 1; };
${ERRATA}/.plist: ${ERRATA}/.fplist
@for _l in $$(cat ${.OBJDIR}/${ERRATA}/.fplist); do \
_o=$$(echo $${_l} | sed "s,${FAKE},,g"); \
cmp -s $${_l} $${_o} || echo $${_o} | sed 's,^/,,g'; \
done > ${.OBJDIR}/${ERRATA}/.plist
findstatic:
.if defined(LIB) && !empty(LIB)
@cd ${SRCDIR} && for _m in $$(find {bin,sbin} \
\( -name Makefile -o -name Makefile.bsd-wrapper \) \
-exec grep -l '\-l${LIB}' {} \;); do \
echo "SUBDIR+= $$(dirname $${_m})"; \
done
.endif
.include <bsd.obj.mk>
|