freebsd-nq/release/Makefile.mirrors
Glen Barber b72901325f Fix a number of logic and/or naming problems in Makefile.mirrors.
Reduce a number of duplicated logic.

As of this commit, this file does exactly what it is needed to do.

MFC after:	3 days
X-MFC-Note:	needs all previous changes
Sponsored by:	The FreeBSD Foundation
2015-05-22 21:04:42 +00:00

243 lines
8.2 KiB
Makefile

#
# This Makefile helps create the directory structure on ftp-master,
# making staging builds a bit more sane.
#
# You probably do not want to use this. Really.
# You have been warned.
#
# Seriously.
#
# Don't use this unless you know why you're using it.
#
# $FreeBSD$
#
.include "${.CURDIR}/Makefile"
RELEASEDIR?= /R
FTPDIR?= ${RELEASEDIR}/ftp-stage
STAGE_TARGETS?= iso-images-stage
.if (defined(EMBEDDED_TARGET) && !empty(EMBEDDED_TARGET)) || (defined(EMBEDDEDBUILD) && !empty(EMBEDDEDBUILD))
. if ${TARGET} == "arm" || ${EMBEDDED_TARGET} == "arm"
EMBEDDED= 1
. endif
.endif
# snapshot
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT"
SNAPSHOT= 1
TLD?= ${FTPDIR}/snapshots
. for _D in /usr/bin /usr/local/bin
. for _S in svnversion svnliteversion
. if exists(${_D}/${_S})
SVNVERSION?= ${_D}/${_S}
. endif
. endfor
. endfor
. if exists(${.CURDIR}/${.OBJDIR}/dist/base/bin/sh)
BUILDDATE!= cd ${.CURDIR} && date -j -f '%s' $$(stat -f "%c" ${.OBJDIR}/dist/base/bin/sh) +%Y%m%d
. else
BUILDDATE!= date +%Y%m%d
. endif
. if exists(${SVNVERSION}) && !empty(SVNVERSION)
SVNREVISION!= ${SVNVERSION} ${WORLDDIR}/Makefile
_SNAP_SUFFIX:= -r${SVNREVISION}-${BUILDDATE}
. else
_SNAP_SUFFIX:= -${BUILDDATE}
. endif
.else
# release
SNAPSHOT=
TLD?= ${FTPDIR}/releases
.endif
.if defined(EMBEDDED) && !empty(EMBEDDED)
. if ${TARGET} == "arm" && ${TARGET_ARCH} == "armv6"
. if !defined(BOARDNAME) && empty(BOARDNAME)
BOARDNAME:= ${KERNCONF}
. else
OLDNAME:= ${KERNCONF}
. endif
. if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT"
SNAPSHOT= 1
. endif
IMAGES:= img
. endif # arm/armv6
.endif # embedded
.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
STAGE_TARGETS+= vm-images-stage
VM_DIR= ${TLD}/VM-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
.endif
CLEANFILES+= ${STAGE_TARGETS}
CHECKSUM_FILES?= SHA256 MD5
SNAP_SUFFIX!= echo ${_SNAP_SUFFIX:S,^-,,1} | tr -d ' '
ISO_DIR= ${TLD}/${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}
FTP_DIR= ${TLD}/${TARGET}/${TARGET_ARCH}/${REVISION}-${BRANCH}
remove-old-bits:
rm -rf ${FTPDIR}
iso-images-stage:
mkdir -p ${ISO_DIR}
mkdir -p ${TLD}/ISO-IMAGES/${REVISION}
.if exists(${RELEASEDIR})
@# Assume we have images to copy.
. if defined(SNAPSHOT) && !empty(SNAPSHOT)
cd ${RELEASEDIR} && rm -f CHECKSUM.*
. for IMAGE in ${IMAGES}
. if defined(EMBEDDED) && !empty(EMBEDDED)
. if defined(OLDNAME) && !empty(OLDNAME)
@# arm/armv6 IMX6 -> WANDBOARD, for example.
cd ${RELEASEDIR} && \
mv ${OSRELEASE}-${OLDNAME}.${IMAGE}.xz \
${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
. endif
cd ${RELEASEDIR} && \
mv ${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz \
${ISO_DIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
. endif # not embedded
. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
cd ${RELEASEDIR} && \
mv ${OSRELEASE}-${IMAGE} \
${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE} || true
cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE} \
${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
. endif
. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
cd ${RELEASEDIR} && \
mv ${OSRELEASE}-${IMAGE}.xz \
${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz || true
cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz \
${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
. endif
. endfor # images loop
cd ${RELEASEDIR} && rm -f CHECKSUM.*
. for CHECKSUM in ${CHECKSUM_FILES}
. if defined(EMBEDDED) && !empty(EMBEDDED)
cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX} \
${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
. else # not embedded
cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX} \
${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
. endif #
. endfor # checksum files
. else # not snapshot
. for IMAGE in ${IMAGES}
. if defined(EMBEDDED) && !empty(EMBEDDED)
. if defined(OLDNAME) && !empty(OLDNAME)
@# arm/armv6 IMX6 -> WANDBOARD, for example.
cd ${RELEASEDIR} && \
mv ${OSRELEASE}-${OLDNAME}.${IMAGE}.xz \
${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
. endif
cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
${ISO_DIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
. endif # not embedded
. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
cd ${RELEASEDIR} && \
cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE} \
${ISO_DIR}/${OSRELEASE}-${IMAGE}
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}
. endif
. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz \
${ISO_DIR}/${OSRELEASE}-${IMAGE}.xz
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}.xz
. endif
. endfor # images loop
cd ${RELEASEDIR} && rm -f CHECKSUM.*
. for CHECKSUM in ${CHECKSUM_FILES}
. if defined(EMBEDDED) && !empty(EMBEDDED)
cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME} \
${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
. else # not embedded
cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
CHECKSUM.${CHECKSUM}-${OSRELEASE}
cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE} \
${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
cd ${TLD}/ISO-IMAGES/${REVISION} && \
ln -s \
../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
. endif
. endfor # checksum files
. endif # release
. if exists(${RELEASEDIR}/ftp)
mkdir -p ${FTP_DIR}
cp -p ${RELEASEDIR}/ftp/*.txz ${RELEASEDIR}/ftp/MANIFEST ${FTP_DIR}
cd ${TLD}/${TARGET} && \
ln -s ${TARGET_ARCH}/${REVISION}-${BRANCH} \
${REVISION}-${BRANCH}
. endif
.endif # no RELEASEDIR
vm-images-stage:
@true
# mkdir -p ${VM_DIR}
#.if defined(SNAPSHOT) && !empty(SNAPSHOT)
# mkdir -p ${VM_DIR}/${BUILDDATE}
#. if exists(${VM_DIR}/Latest)
# unlink ${VM_DIR}/Latest
# cd ${VM_DIR} && ln -s ${BUILDDATE} Latest
#. endif
#. for VMIMAGE in ${VMIMAGES}
# cd /R/vmimages && cp -p ${VMIMAGE}.xz \
# ${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}-${VMIMAGE}.xz
# cd ${VM_DIR}/Latest && ln -s \
# ../${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}-${VMIMAGE}.xz \
# ${OSRELEASE}-${VMIMAGE}.xz
#. endfor
#. for CHECKSUM in ${CHECKSUM_FILES}
#. if exists(${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM})
# rm -f ${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}
#. endif
# cd ${VM_DIR}/${BUILDDATE} && ${CHECKSUM:tl} ${OSRELEASE}* > \
# CHECKSUM.${CHECKSUM}-${REVISION}-${BRANCH}-${SNAP_SUFFIX}
# cd ${VM_DIR}/Latest && ln -s \
# ${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
# CHECKSUM.${CHECKSUM}
#. endfor
#.else # !snapshot
#. for CHECKSUM in ${CHECKSUM_FILES}
# cd /R/vmimages && cp -p CHECKSUM.${CHECKSUM}* \
# ${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
#.endif
ftp-stage: remove-old-bits ${STAGE_TARGETS}