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