xref: /freebsd/release/Makefile.mirrors (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
1#
2# This Makefile helps create the directory structure on ftp-master,
3# making staging builds a bit more sane.
4#
5# You probably do not want to use this.  Really.
6# You have been warned.
7#
8# Seriously.
9#
10# Don't use this unless you know why you're using it.
11#
12#
13
14.include "${.CURDIR}/Makefile"
15
16RELEASEDIR?=		/R
17FTPDIR?=		${RELEASEDIR}/ftp-stage
18.if exists(${RELEASEDIR})
19STAGE_TARGETS?=		iso-images-stage
20.endif
21
22.if (defined(EMBEDDED_TARGET) && !empty(EMBEDDED_TARGET)) || (defined(EMBEDDEDBUILD) && !empty(EMBEDDEDBUILD))
23. if ${TARGET:Marm*} != "" || ${EMBEDDED_TARGET:Marm*} != "" || ${TARGET:Mriscv*} != ""
24EMBEDDED=		1
25. endif
26.endif
27
28# snapshot
29.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" || ${BRANCH:MALPHA*} != ""
30SNAPSHOT=		1
31TLD?=			${FTPDIR}/snapshots
32.if !defined(BUILDDATE) || empty(BUILDDATE)
33BUILDDATE!=		date +%Y%m%d
34.endif
35_SNAP_SUFFIX:=		${BUILDDATE}-${GITREV}-${GITCOUNT}
36.else
37# release
38SNAPSHOT=
39TLD?=			${FTPDIR}/releases
40.endif
41
42.if defined(EMBEDDED) && !empty(EMBEDDED)
43. if ${TARGET:Marm*} != "" && (${TARGET_ARCH:Marm*} != "" || ${TARGET_ARCH} == "aarch64") || ${TARGET:Mriscv*} != ""
44.  if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" || ${BRANCH:MALPHA*} != ""
45SNAPSHOT=		1
46.  endif
47IMAGES:=		img
48. endif # arm/armv6
49.endif # embedded
50
51.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
52STAGE_TARGETS+=		vm-images-stage
53VM_DIR=			${TLD}/VM-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
54.endif
55
56.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)
57STAGE_TARGETS+=		ci-images-stage
58CI_DIR=			${TLD}/CI-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
59.endif
60
61CLEANFILES+=		${STAGE_TARGETS}
62CHECKSUM_FILES?=	SHA512 SHA256
63SNAP_SUFFIX!=		echo ${_SNAP_SUFFIX:S,^-,,1} | tr -d ' '
64ISO_DIR=		${TLD}/${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}
65FTP_DIR=		${TLD}/${TARGET}/${TARGET_ARCH}/${REVISION}-${BRANCH}
66
67remove-old-bits:
68	rm -rf ${FTPDIR}
69
70iso-images-stage:
71	mkdir -p ${ISO_DIR}
72	mkdir -p ${TLD}/ISO-IMAGES/${REVISION}
73.if defined(SNAPSHOT) && !empty(SNAPSHOT)
74	cd ${RELEASEDIR} && rm -f CHECKSUM.*
75. for IMAGE in ${IMAGES}
76.  if defined(EMBEDDED) && !empty(EMBEDDED)
77	cd ${RELEASEDIR} && \
78		mv ${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
79		${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
80	cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz \
81		${ISO_DIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
82	cd ${TLD}/ISO-IMAGES/${REVISION} && \
83		ln -s \
84		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
85.  endif # not embedded
86.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
87	cd ${RELEASEDIR} && \
88		mv ${OSRELEASE}-${IMAGE} \
89		${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
90	cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE} \
91		${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
92	cd ${TLD}/ISO-IMAGES/${REVISION} && \
93		ln -s \
94		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
95.   endif
96.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
97	cd ${RELEASEDIR} && \
98		mv ${OSRELEASE}-${IMAGE}.xz \
99		${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
100	cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz \
101		${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
102	cd ${TLD}/ISO-IMAGES/${REVISION} && \
103		ln -s \
104		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
105.   endif
106. endfor # images loop
107	cd ${RELEASEDIR} && rm -f CHECKSUM.*
108. for CHECKSUM in ${CHECKSUM_FILES}
109.  if defined(EMBEDDED) && !empty(EMBEDDED)
110	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
111		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
112	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX} \
113		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
114	cd ${TLD}/ISO-IMAGES/${REVISION} && \
115		ln -s \
116		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
117.  else # not embedded
118	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
119		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
120	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX} \
121		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
122	cd ${TLD}/ISO-IMAGES/${REVISION} && \
123		ln -s \
124		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
125.  endif #
126. endfor # checksum files
127.else # not snapshot
128. for IMAGE in ${IMAGES}
129.  if defined(EMBEDDED) && !empty(EMBEDDED)
130	cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
131		${ISO_DIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
132	cd ${TLD}/ISO-IMAGES/${REVISION} && \
133		ln -s \
134		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
135.  endif # not embedded
136.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
137	cd ${RELEASEDIR} && \
138	cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE} \
139		${ISO_DIR}/${OSRELEASE}-${IMAGE}
140	cd ${TLD}/ISO-IMAGES/${REVISION} && \
141		ln -s \
142		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}
143.   endif
144.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
145	cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz \
146		${ISO_DIR}/${OSRELEASE}-${IMAGE}.xz
147	cd ${TLD}/ISO-IMAGES/${REVISION} && \
148		ln -s \
149		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}.xz
150.   endif
151. endfor # images loop
152	cd ${RELEASEDIR} && rm -f CHECKSUM.*
153. for CHECKSUM in ${CHECKSUM_FILES}
154.  if defined(EMBEDDED) && !empty(EMBEDDED)
155	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
156		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
157	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME} \
158		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
159	cd ${TLD}/ISO-IMAGES/${REVISION} && \
160		ln -s \
161		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
162.  else # not embedded
163	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
164		CHECKSUM.${CHECKSUM}-${OSRELEASE}
165	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE} \
166		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
167	cd ${TLD}/ISO-IMAGES/${REVISION} && \
168		ln -s \
169		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
170.  endif
171. endfor # checksum files
172.endif # release
173.if exists(${RELEASEDIR}/ftp)
174	mkdir -p ${FTP_DIR}
175	cp -p ${RELEASEDIR}/ftp/*.txz ${RELEASEDIR}/ftp/MANIFEST ${FTP_DIR}
176	echo ${BUILDDATE} > ${FTP_DIR}/BUILDDATE
177	echo ${GITBRANCH} > ${FTP_DIR}/GITBRANCH
178	echo ${GITREV} > ${FTP_DIR}/REVISION
179	cd ${TLD}/${TARGET} && \
180		ln -s ${TARGET_ARCH}/${REVISION}-${BRANCH} \
181			${REVISION}-${BRANCH}
182.endif
183
184vm-images-stage:
185	mkdir -p ${VM_DIR}
186.if defined(SNAPSHOT) && !empty(SNAPSHOT)
187. if exists(${VM_DIR}/Latest)
188	rm -rf ${VM_DIR}/Latest
189. endif
190	mkdir -p ${VM_DIR}/Latest
191	mkdir -p ${VM_DIR}/${BUILDDATE}
192. for VMFORMAT in ${VMFORMATS}
193.  for FS in ${VMFSLIST}
194	cd ${RELEASEDIR}/vmimages && \
195		mv ${OSRELEASE}-${FS}.${VMFORMAT}.xz \
196		${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz
197	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
198		${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz
199	cd ${VM_DIR}/Latest && \
200		ln -s ../${BUILDDATE}/${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
201		${OSRELEASE}-${FS}.${VMFORMAT}.xz
202.  endfor
203. endfor
204. if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)
205.  for CW in ${CLOUDWARE}
206.   if ${CW} == BASIC-CLOUDINIT
207.    for VMFORMAT in ${${CW}_FORMAT}
208.     for FS in ${${CW}_FSLIST}
209	cd ${RELEASEDIR}/vmimages && \
210		mv ${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz \
211		${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
212	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
213		${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
214	cd ${VM_DIR}/Latest && \
215		ln -s ../${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
216		${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
217.     endfor
218.    endfor
219.   endif
220.  endfor
221. endif
222	cd ${RELEASEDIR}/vmimages && rm -f CHECKSUM.*
223. for CHECKSUM in ${CHECKSUM_FILES}
224	cd ${RELEASEDIR}/vmimages && \
225		${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
226	cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
227		${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
228	cd ${VM_DIR}/Latest && \
229		ln -s ../${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
230		CHECKSUM.${CHECKSUM}
231. endfor
232.else # not snapshot
233. if exists(${VM_DIR}/Latest)
234	rm -rf ${VM_DIR}/Latest
235. endif
236	mkdir -p ${VM_DIR}/Latest
237. for VMFORMAT in ${VMFORMATS}
238.  for FS in ${VMFSLIST}
239	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${FS}.${VMFORMAT}.xz \
240		${VM_DIR}/Latest/${OSRELEASE}-${FS}.${VMFORMAT}.xz
241.  endfor
242. endfor
243. if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)
244.  for CW in ${CLOUDWARE}
245.   if ${CW} == BASIC-CLOUDINIT
246.    for VMFORMAT in ${${CW}_FORMAT}
247.     for FS in ${${CW}_FSLIST}
248	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz \
249		${VM_DIR}/Latest/${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
250.     endfor
251.    endfor
252.   endif
253.  endfor
254. endif
255. for CHECKSUM in ${CHECKSUM_FILES}
256	cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM} \
257		${VM_DIR}/Latest/CHECKSUM.${CHECKSUM}
258. endfor
259.endif
260
261ci-images-stage:
262	mkdir -p ${CI_DIR}
263.if defined(SNAPSHOT) && !empty(SNAPSHOT)
264. if exists(${CI_DIR}/Latest)
265	rm -rf ${CI_DIR}/Latest
266. endif
267	mkdir -p ${CI_DIR}/Latest
268	mkdir -p ${CI_DIR}/${BUILDDATE}
269. for CW in ${CLOUDWARE}
270.  if ${CW} == BASIC-CI
271.   for VMFORMAT in ${${CW}_FORMAT}
272.    for FS in ${${CW}_FSLIST}
273	cd ${RELEASEDIR}/ciimages && \
274		mv ${OSRELEASE}-${CW}-${FS}.${VMFORMAT}.xz \
275		${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
276	cp -p ${RELEASEDIR}/ciimages/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
277		${CI_DIR}/${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
278	cd ${CI_DIR}/Latest && \
279		ln -s ../${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
280		${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
281.    endfor
282.   endfor
283.  endif
284. endfor
285	cd ${RELEASEDIR}/ciimages && rm -f CHECKSUM.*
286. for CHECKSUM in ${CHECKSUM_FILES}
287	cd ${RELEASEDIR}/ciimages && \
288		${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
289	cp -p ${RELEASEDIR}/ciimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
290		${CI_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
291	cd ${CI_DIR}/Latest && \
292		ln -s ../${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
293		CHECKSUM.${CHECKSUM}
294. endfor
295.else # not snapshot
296. if exists(${CI_DIR}/Latest)
297	rm -rf ${CI_DIR}/Latest
298. endif
299	mkdir -p ${CI_DIR}/Latest
300. for CW in ${CLOUDWARE}
301.  if ${CW} == BASIC-CI
302.   for VMFORMAT in ${${CW}_FORMAT}
303.    for FS in ${${CW}_FSLIST}
304	cp -p ${RELEASEDIR}/ciimages/${OSRELEASE}-${CW}-${FS}.${VMFORMAT}.xz \
305		${CI_DIR}/Latest/${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
306.    endfor
307.   endfor
308.  endif
309. endfor
310. for CHECKSUM in ${CHECKSUM_FILES}
311	cp -p ${RELEASEDIR}/ciimages/CHECKSUM.${CHECKSUM} \
312		${CI_DIR}/Latest/CHECKSUM.${CHECKSUM}
313. endfor
314.endif
315
316ftp-stage:	remove-old-bits ${STAGE_TARGETS}
317
318