Makefile.inc1:

- New file.  Adds logic to search for the git binary, as well
  as determining the branch and revision, used in various
  places.

Makefile:
- Remove searching for the svn{,lite} binary.

Makefile.ec2:
- Reduce duplicated code, removing searching for the svn{,lite}
  binary, in addition to EC2_SVN{BRANCH,REV}.
- Rename EC2_SVN* with GIT* for consistency.

Makefile.mirrors:
- Remove the SRCBRANCH declaration, replaced with the exported
  GITBRANCH variable.
- Update _SNAP_SUFFIX from SVNREVISION to GITREV, and remove
  the leading 'r' from it, since it will break git hashes.
- Remove yet another instance of duplicated code to search for
  the svn{,version}lite binary.

Sponsored by:	Rubicon Communications, LLC (netgate.com)
This commit is contained in:
Glen Barber 2020-07-16 20:34:26 +00:00
parent e2c0e292e8
commit 29b282f31d
4 changed files with 33 additions and 58 deletions

View File

@ -90,15 +90,6 @@ EXTRA_PACKAGES+= src.txz
.endif
.if !defined(NODOC)
EXTRA_PACKAGES+= reldoc
. if !defined(SVN) || empty(SVN)
. for S in svn svnlite
. for D in /usr/local/bin /usr/bin
. if(exists(${D}/${S}))
SVN?= ${D}/${S}
. endif
. endfor
. endfor
. endif
.endif
RELEASE_TARGETS= ftp
@ -173,7 +164,6 @@ ports.txz:
reldoc:
cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \
env MAN4DIR=${WORLDDIR}/share/man/man4 \
SVN=${SVN} \
_BRANCH=${BRANCH} \
${MAKE} all install clean "FORMATS=html txt" \
INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \
@ -336,4 +326,5 @@ release-install:
cd ${DESTDIR} && sha512 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA512
cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
.include "${.CURDIR}/Makefile.inc1"
.include "${.CURDIR}/Makefile.vm"

View File

@ -5,30 +5,6 @@
# Makefile for creating an EC2 AMI from a disk image.
#
# Figure out where SVN is
.if !defined(SVN_CMD) || empty(SVN_CMD)
. for _P in /usr/bin /usr/local/bin
. for _S in svn svnlite
. if exists(${_P}/${_S})
SVN_CMD= ${_P}/${_S}
. endif
. endfor
. endfor
.endif
.if exists(${SRCTOP}/.svn)
. if empty(EC2_SVNBRANCH)
EC2_SVNBRANCH!= ${SVN_CMD} info --show-item relative-url ${WORLDDIR} 2>/dev/null | sed -e 's/\^\///'
. export EC2_SVNBRANCH
. endif
. if empty(EC2_SVNREV)
EC2_SVNREV!= ${SVN_CMD} info --show-item last-changed-revision ${WORLDDIR} 2>/dev/null || true
. export EC2_SVNREV
. endif
.else
EC2_SVNBRANCH= unknown
EC2_SVNREV= unknown
.endif
.if ${BRANCH} == "CURRENT" || ${BRANCH} == "STABLE" || ${BRANCH} == "PRERELEASE"
AMINAMESUFFIX!= date +-%Y-%m-%d
.endif
@ -40,7 +16,7 @@ PUBLICSNAP= --publicsnap
.endif
.if defined(EC2SNSTOPIC) && !empty(EC2SNSTOPIC)
EC2SNSREL= ${REVISION}-${BRANCH}
EC2SNSVERS= ${EC2_SVNBRANCH}@${EC2_SVNREV}
EC2SNSVERS= ${GITBRANCH}@${GITREV}
.endif
.if ${TARGET_ARCH} != "amd64"
EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/}
@ -89,7 +65,7 @@ ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
${EC2ARCH} --sriov --ena \
${.OBJDIR}/ec2.raw \
"${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \
"${TYPE}/${TARGET} ${EC2_SVNBRANCH}@${EC2_SVNREV}" \
"${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \
${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE} \
${EC2SNSTOPIC} ${EC2SNSREL} ${EC2SNSVERS}
@touch ${.TARGET}

25
release/Makefile.inc1 Normal file
View File

@ -0,0 +1,25 @@
#
# $FreeBSD$
#
# Figure out where the git binary is.
.if !defined(GIT_CMD) || empty(GIT_CMD)
. for _P in /usr/bin /usr/local/bin
. if exists(${_P}/git)
GIT_CMD= ${_P}/git
. endif
. endfor
. export GIT_CMD
.else
. error "Git binary not found. Set GIT_CMD appropriately."
.endif
# Set the git branch and hash to export where needed.
.if !defined(GITBRANCH) || empty(GITBRANCH)
GITBRANCH!= ${GIT_CMD} rev-parse --abbrev-ref HEAD 2>/dev/null | sed -e 's/\^\///'
.export GITBRANCH
.endif
.if !defined(GITREV) || empty(GITREV)
GITREV!= ${GIT_CMD} rev-parse --verify --short HEAD 2>/dev/null || true
.export GITREV
.endif

View File

@ -19,7 +19,6 @@ FTPDIR?= ${RELEASEDIR}/ftp-stage
.if exists(${RELEASEDIR})
STAGE_TARGETS?= iso-images-stage
.endif
SRCBRANCH!= ${SVN_CMD} info --show-item relative-url ${WORLDDIR}
.if (defined(EMBEDDED_TARGET) && !empty(EMBEDDED_TARGET)) || (defined(EMBEDDEDBUILD) && !empty(EMBEDDEDBUILD))
. if ${TARGET:Marm*} != "" || ${EMBEDDED_TARGET:Marm*} != ""
@ -31,26 +30,10 @@ EMBEDDED= 1
.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" || ${BRANCH:MALPHA*} != ""
SNAPSHOT= 1
TLD?= ${FTPDIR}/snapshots
. if !defined(SVNREVISION) || empty(SVNREVISION)
. 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(${SVNVERSION}) && !empty(SVNVERSION)
SVNREVISION!= ${SVNVERSION} ${WORLDDIR}/Makefile
. endif
. endif # !defined(SVNREVISION)
. if !defined(BUILDDATE) || empty(BUILDDATE)
. 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
.if !defined(BUILDDATE) || empty(BUILDDATE)
BUILDDATE!= date +%Y%m%d
. endif
. endif
_SNAP_SUFFIX:= ${BUILDDATE}-r${SVNREVISION}
.endif
_SNAP_SUFFIX:= ${BUILDDATE}-${GITREV}
.else
# release
SNAPSHOT=
@ -187,8 +170,8 @@ iso-images-stage:
mkdir -p ${FTP_DIR}
cp -p ${RELEASEDIR}/ftp/*.txz ${RELEASEDIR}/ftp/MANIFEST ${FTP_DIR}
echo ${BUILDDATE} > ${FTP_DIR}/BUILDDATE
echo ${SRCBRANCH} > ${FTP_DIR}/SRCBRANCH
echo r${SVNREVISION} > ${FTP_DIR}/REVISION
echo ${GITBRANCH} > ${FTP_DIR}/GITBRANCH
echo ${GITREV} > ${FTP_DIR}/REVISION
cd ${TLD}/${TARGET} && \
ln -s ${TARGET_ARCH}/${REVISION}-${BRANCH} \
${REVISION}-${BRANCH}