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