Page MenuHomeFreeBSD
Paste P416

Command-Line Input
ActivePublic

Authored by swills on Aug 12 2020, 1:21 PM.
Tags
None
Referenced Files
F7822307: Command-Line Input
Aug 12 2020, 1:21 PM
Subscribers
None
# $FreeBSD$
PORTNAME= ports-tree-version
CATEGORIES= ports-mgmt
DISTFILES= # none
MAINTAINER= swills@FreeBSD.org
COMMENT= Package indicating current ports tree version
NO_BUILD= yes
WRKSRC= ${WRKDIR}
# This port is breaking all the rules/best practices, don't copy and paste from
# here
#
.include <bsd.port.pre.mk>
.if exists(${PORTSDIR}/.git)
BUILD_DEPENDS= git:devel/git
HASH!= (cd ${PORTSDIR} ; git log -3 --pretty=format:"%h" | tail -n 1)
BRANCH!= (cd ${PORTSDIR} ; git branch --show-current)
REVCOUNT!= (cd ${PORTSDIR} ; git rev-list --count ${HASH})
PORTVERSION= r${REVCOUNT}.${BRANCH}.${HASH}
PLIST_FILES= ${DOCSDIR}/git-hash ${DOCSDIR}/git-branch ${DOCSDIR}/git-rev-count
.elif exists(${PORTSDIR}/.svn)
.if exists(/usr/bin/svnlite)
SVN= /usr/bin/svnlite
.else
BUILD_DEPENDS= ${LOCALBASE}/bin/svn:devel/subversion
SVN= ${LOCALBASE}/svn
.endif
REV!= ${SVN}version ${PORTSDIR} | ${SED} -e s/M//g
BRANCH!= ${SVN} info ${PORTSDIR} | ${GREP} '^URL:' | ${SED} -e s,.*ports/,, -e 's,.*branches/,,'
PORTVERSION= r${REV}.${BRANCH}
PLIST_FILES= ${DOCSDIR}/svn-revision ${DOCSDIR}/svn-branch
.else
IGNORE= not a git or subversion checkout
PORTVERSION= 0
.endif
do-configure:
.if exists(${PORTSDIR}/.git)
@${MKDIR} ${STAGEDIR}${DOCSDIR}
@${ECHO} ${REVCOUNT} > ${STAGEDIR}${DOCSDIR}/git-rev-count
@${ECHO} ${HASH} > ${STAGEDIR}${DOCSDIR}/git-hash
@${ECHO} ${BRANCH} > ${STAGEDIR}${DOCSDIR}/git-branch
.endif
.if exists(${PORTSDIR}/.svn)
@${MKDIR} ${STAGEDIR}${DOCSDIR}
@${ECHO} ${REV} > ${STAGEDIR}${DOCSDIR}/svn-revision
@${ECHO} ${BRANCH} > ${STAGEDIR}${DOCSDIR}/svn-branch
.endif
do-install:
@${DO_NADA}
.include <bsd.port.post.mk>