xref: /freebsd/release/Makefile.mirrors (revision 809a8352dd5bb83dca991ff6c82e509208afad26)
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# $FreeBSD$
13#
14
15.include "${.CURDIR}/Makefile"
16
17RELEASEDIR?=		/R
18FTPDIR?=		${RELEASEDIR}/ftp-stage
19.if exists(${RELEASEDIR})
20STAGE_TARGETS?=		iso-images-stage
21.endif
22
23.if (defined(EMBEDDED_TARGET) && !empty(EMBEDDED_TARGET)) || (defined(EMBEDDEDBUILD) && !empty(EMBEDDEDBUILD))
24. if ${TARGET:Marm*} != "" || ${EMBEDDED_TARGET:Marm*} != ""
25EMBEDDED=		1
26. endif
27.endif
28
29# snapshot
30.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" || ${BRANCH:MALPHA*} != ""
31SNAPSHOT=		1
32TLD?=			${FTPDIR}/snapshots
33. if !defined(SVNREVISION) || empty(SVNREVISION)
34.  for _D in /usr/bin /usr/local/bin
35.   for _S in svnversion svnliteversion
36.    if exists(${_D}/${_S})
37SVNVERSION?=		${_D}/${_S}
38.    endif
39.   endfor
40.  endfor
41.  if exists(${SVNVERSION}) && !empty(SVNVERSION)
42SVNREVISION!=		${SVNVERSION} ${WORLDDIR}/Makefile
43.  endif
44. endif # !defined(SVNREVISION)
45. if !defined(BUILDDATE) || empty(BUILDDATE)
46.  if exists(${.CURDIR}/${.OBJDIR}/dist/base/bin/sh)
47BUILDDATE!=		cd ${.CURDIR} && date -j -f '%s' $$(stat -f "%c" ${.OBJDIR}/dist/base/bin/sh) +%Y%m%d
48.  else
49BUILDDATE!=		date +%Y%m%d
50.  endif
51. endif
52_SNAP_SUFFIX:=		${BUILDDATE}-r${SVNREVISION}
53.else
54# release
55SNAPSHOT=
56TLD?=			${FTPDIR}/releases
57.endif
58
59.if defined(EMBEDDED) && !empty(EMBEDDED)
60. if ${TARGET:Marm*} != "" && (${TARGET_ARCH:Marm*} != "" || ${TARGET_ARCH} == "aarch64")
61.  if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" || ${BRANCH:MALPHA*} != ""
62SNAPSHOT=		1
63.  endif
64IMAGES:=		img
65. endif # arm/armv6
66.endif # embedded
67
68.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
69STAGE_TARGETS+=		vm-images-stage
70VM_DIR=			${TLD}/VM-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
71.endif
72
73CLEANFILES+=		${STAGE_TARGETS}
74CHECKSUM_FILES?=	SHA512 SHA256
75SNAP_SUFFIX!=		echo ${_SNAP_SUFFIX:S,^-,,1} | tr -d ' '
76ISO_DIR=		${TLD}/${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}
77FTP_DIR=		${TLD}/${TARGET}/${TARGET_ARCH}/${REVISION}-${BRANCH}
78
79remove-old-bits:
80	rm -rf ${FTPDIR}
81
82iso-images-stage:
83	mkdir -p ${ISO_DIR}
84	mkdir -p ${TLD}/ISO-IMAGES/${REVISION}
85.if defined(SNAPSHOT) && !empty(SNAPSHOT)
86	cd ${RELEASEDIR} && rm -f CHECKSUM.*
87. for IMAGE in ${IMAGES}
88.  if defined(EMBEDDED) && !empty(EMBEDDED)
89	cd ${RELEASEDIR} && \
90		mv ${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
91		${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
92	cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz \
93		${ISO_DIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
94	cd ${TLD}/ISO-IMAGES/${REVISION} && \
95		ln -s \
96		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
97.  endif # not embedded
98.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
99	cd ${RELEASEDIR} && \
100		mv ${OSRELEASE}-${IMAGE} \
101		${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
102	cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE} \
103		${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
104	cd ${TLD}/ISO-IMAGES/${REVISION} && \
105		ln -s \
106		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
107.   endif
108.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
109	cd ${RELEASEDIR} && \
110		mv ${OSRELEASE}-${IMAGE}.xz \
111		${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
112	cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz \
113		${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
114	cd ${TLD}/ISO-IMAGES/${REVISION} && \
115		ln -s \
116		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
117.   endif
118. endfor # images loop
119	cd ${RELEASEDIR} && rm -f CHECKSUM.*
120. for CHECKSUM in ${CHECKSUM_FILES}
121.  if defined(EMBEDDED) && !empty(EMBEDDED)
122	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
123		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
124	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX} \
125		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
126	cd ${TLD}/ISO-IMAGES/${REVISION} && \
127		ln -s \
128		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
129.  else # not embedded
130	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
131		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
132	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX} \
133		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
134	cd ${TLD}/ISO-IMAGES/${REVISION} && \
135		ln -s \
136		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
137.  endif #
138. endfor # checksum files
139.else # not snapshot
140. for IMAGE in ${IMAGES}
141.  if defined(EMBEDDED) && !empty(EMBEDDED)
142	cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
143		${ISO_DIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
144	cd ${TLD}/ISO-IMAGES/${REVISION} && \
145		ln -s \
146		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
147.  endif # not embedded
148.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
149	cd ${RELEASEDIR} && \
150	cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE} \
151		${ISO_DIR}/${OSRELEASE}-${IMAGE}
152	cd ${TLD}/ISO-IMAGES/${REVISION} && \
153		ln -s \
154		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}
155.   endif
156.   if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
157	cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz \
158		${ISO_DIR}/${OSRELEASE}-${IMAGE}.xz
159	cd ${TLD}/ISO-IMAGES/${REVISION} && \
160		ln -s \
161		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}.xz
162.   endif
163. endfor # images loop
164	cd ${RELEASEDIR} && rm -f CHECKSUM.*
165. for CHECKSUM in ${CHECKSUM_FILES}
166.  if defined(EMBEDDED) && !empty(EMBEDDED)
167	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
168		CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
169	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME} \
170		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
171	cd ${TLD}/ISO-IMAGES/${REVISION} && \
172		ln -s \
173		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
174.  else # not embedded
175	cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
176		CHECKSUM.${CHECKSUM}-${OSRELEASE}
177	cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE} \
178		${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
179	cd ${TLD}/ISO-IMAGES/${REVISION} && \
180		ln -s \
181		../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
182.  endif
183. endfor # checksum files
184.endif # release
185.if exists(${RELEASEDIR}/ftp)
186	mkdir -p ${FTP_DIR}
187	cp -p ${RELEASEDIR}/ftp/*.txz ${RELEASEDIR}/ftp/MANIFEST ${FTP_DIR}
188	cd ${TLD}/${TARGET} && \
189		ln -s ${TARGET_ARCH}/${REVISION}-${BRANCH} \
190			${REVISION}-${BRANCH}
191.endif
192
193vm-images-stage:
194	mkdir -p ${VM_DIR}
195.if defined(SNAPSHOT) && !empty(SNAPSHOT)
196. if exists(${VM_DIR}/Latest)
197	rm -rf ${VM_DIR}/Latest
198. endif
199	mkdir -p ${VM_DIR}/Latest
200	mkdir -p ${VM_DIR}/${BUILDDATE}
201. for VMFORMAT in ${VMFORMATS}
202	cd ${RELEASEDIR}/vmimages && \
203		mv ${OSRELEASE}.${VMFORMAT}.xz \
204		${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz
205	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
206		${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz
207	cd ${VM_DIR}/Latest && \
208		ln -s ../${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
209		${OSRELEASE}.${VMFORMAT}.xz
210. endfor
211	cd ${RELEASEDIR}/vmimages && rm -f CHECKSUM.*
212. for CHECKSUM in ${CHECKSUM_FILES}
213	cd ${RELEASEDIR}/vmimages && \
214		${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
215	cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
216		${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
217	cd ${VM_DIR}/Latest && \
218		ln -s ../${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
219		CHECKSUM.${CHECKSUM}
220. endfor
221.else # not snapshot
222. if exists(${VM_DIR}/Latest)
223	rm -rf ${VM_DIR}/Latest
224. endif
225	mkdir -p ${VM_DIR}/Latest
226. for VMFORMAT in ${VMFORMATS}
227	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}.${VMFORMAT}.xz \
228		${VM_DIR}/Latest/${OSRELEASE}.${VMFORMAT}.xz
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