xref: /freebsd/release/Makefile.mirrors (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
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
56CLEANFILES+=		${STAGE_TARGETS}
57CHECKSUM_FILES?=	SHA512 SHA256
58SNAP_SUFFIX!=		echo ${_SNAP_SUFFIX:S,^-,,1} | tr -d ' '
59ISO_DIR=		${TLD}/${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}
60FTP_DIR=		${TLD}/${TARGET}/${TARGET_ARCH}/${REVISION}-${BRANCH}
61
62remove-old-bits:
63	rm -rf ${FTPDIR}
64
65iso-images-stage:
66	mkdir -p ${ISO_DIR}
67	mkdir -p ${TLD}/ISO-IMAGES/${REVISION}
68.if defined(SNAPSHOT) && !empty(SNAPSHOT)
69	cd ${RELEASEDIR} && rm -f CHECKSUM.*
70. for IMAGE in ${IMAGES}
71.  if defined(EMBEDDED) && !empty(EMBEDDED)
72	cd ${RELEASEDIR} && \
73		mv ${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
74		${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
75	cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz \
76		${ISO_DIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
77	cd ${TLD}/ISO-IMAGES/${REVISION} && \
78		ln -s \
79		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
80.  endif # not embedded
81.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
82	cd ${RELEASEDIR} && \
83		mv ${OSRELEASE}-${IMAGE} \
84		${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
85	cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE} \
86		${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
87	cd ${TLD}/ISO-IMAGES/${REVISION} && \
88		ln -s \
89		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
90.   endif
91.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
92	cd ${RELEASEDIR} && \
93		mv ${OSRELEASE}-${IMAGE}.xz \
94		${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
95	cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz \
96		${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
97	cd ${TLD}/ISO-IMAGES/${REVISION} && \
98		ln -s \
99		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
100.   endif
101. endfor # images loop
102	cd ${RELEASEDIR} && rm -f CHECKSUM.*
103. for CHECKSUM in ${CHECKSUM_FILES}
104.  if defined(EMBEDDED) && !empty(EMBEDDED)
105	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
106		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
107	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX} \
108		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
109	cd ${TLD}/ISO-IMAGES/${REVISION} && \
110		ln -s \
111		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
112.  else # not embedded
113	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
114		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
115	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX} \
116		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
117	cd ${TLD}/ISO-IMAGES/${REVISION} && \
118		ln -s \
119		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
120.  endif #
121. endfor # checksum files
122.else # not snapshot
123. for IMAGE in ${IMAGES}
124.  if defined(EMBEDDED) && !empty(EMBEDDED)
125	cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
126		${ISO_DIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
127	cd ${TLD}/ISO-IMAGES/${REVISION} && \
128		ln -s \
129		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
130.  endif # not embedded
131.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
132	cd ${RELEASEDIR} && \
133	cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE} \
134		${ISO_DIR}/${OSRELEASE}-${IMAGE}
135	cd ${TLD}/ISO-IMAGES/${REVISION} && \
136		ln -s \
137		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}
138.   endif
139.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
140	cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz \
141		${ISO_DIR}/${OSRELEASE}-${IMAGE}.xz
142	cd ${TLD}/ISO-IMAGES/${REVISION} && \
143		ln -s \
144		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}.xz
145.   endif
146. endfor # images loop
147	cd ${RELEASEDIR} && rm -f CHECKSUM.*
148. for CHECKSUM in ${CHECKSUM_FILES}
149.  if defined(EMBEDDED) && !empty(EMBEDDED)
150	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
151		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
152	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME} \
153		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
154	cd ${TLD}/ISO-IMAGES/${REVISION} && \
155		ln -s \
156		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
157.  else # not embedded
158	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
159		CHECKSUM.${CHECKSUM}-${OSRELEASE}
160	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE} \
161		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
162	cd ${TLD}/ISO-IMAGES/${REVISION} && \
163		ln -s \
164		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
165.  endif
166. endfor # checksum files
167.endif # release
168.if exists(${RELEASEDIR}/ftp)
169	mkdir -p ${FTP_DIR}
170	cp -p ${RELEASEDIR}/ftp/*.txz ${RELEASEDIR}/ftp/MANIFEST ${FTP_DIR}
171	echo ${BUILDDATE} > ${FTP_DIR}/BUILDDATE
172	echo ${GITBRANCH} > ${FTP_DIR}/GITBRANCH
173	echo ${GITREV} > ${FTP_DIR}/REVISION
174	cd ${TLD}/${TARGET} && \
175		ln -s ${TARGET_ARCH}/${REVISION}-${BRANCH} \
176			${REVISION}-${BRANCH}
177.endif
178
179vm-images-stage:
180	mkdir -p ${VM_DIR}
181.if defined(SNAPSHOT) && !empty(SNAPSHOT)
182. if exists(${VM_DIR}/Latest)
183	rm -rf ${VM_DIR}/Latest
184. endif
185	mkdir -p ${VM_DIR}/Latest
186	mkdir -p ${VM_DIR}/${BUILDDATE}
187. for VMFORMAT in ${VMFORMATS}
188	cd ${RELEASEDIR}/vmimages && \
189		mv ${OSRELEASE}.${VMFORMAT}.xz \
190		${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz
191	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
192		${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz
193	cd ${VM_DIR}/Latest && \
194		ln -s ../${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
195		${OSRELEASE}.${VMFORMAT}.xz
196.  for FS in ${VMFSLIST}
197	cd ${RELEASEDIR}/vmimages && \
198		mv ${OSRELEASE}-${FS}.${VMFORMAT}.xz \
199		${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz
200	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
201		${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz
202	cd ${VM_DIR}/Latest && \
203		ln -s ../${BUILDDATE}/${OSRELEASE}-${FS}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
204		${OSRELEASE}-${FS}.${VMFORMAT}.xz
205.  endfor
206. endfor
207	cd ${RELEASEDIR}/vmimages && rm -f CHECKSUM.*
208. for CHECKSUM in ${CHECKSUM_FILES}
209	cd ${RELEASEDIR}/vmimages && \
210		${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
211	cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
212		${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
213	cd ${VM_DIR}/Latest && \
214		ln -s ../${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
215		CHECKSUM.${CHECKSUM}
216. endfor
217.else # not snapshot
218. if exists(${VM_DIR}/Latest)
219	rm -rf ${VM_DIR}/Latest
220. endif
221	mkdir -p ${VM_DIR}/Latest
222. for VMFORMAT in ${VMFORMATS}
223	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}.${VMFORMAT}.xz \
224		${VM_DIR}/Latest/${OSRELEASE}.${VMFORMAT}.xz
225.  for FS in ${VMFSLIST}
226	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${FS}.${VMFORMAT}.xz \
227		${VM_DIR}/Latest/${OSRELEASE}-${FS}.${VMFORMAT}.xz
228.  endfor
229. endfor
230. for CHECKSUM in ${CHECKSUM_FILES}
231	cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM} \
232		${VM_DIR}/Latest/CHECKSUM.${CHECKSUM}
233. endfor
234.endif
235
236ftp-stage:	remove-old-bits ${STAGE_TARGETS}
237
238