pkgsrc/mk/misc/developer.mk

90 lines
2.5 KiB
Makefile
Raw Normal View History

# $NetBSD: developer.mk,v 1.7 2007/07/21 22:31:02 gdt Exp $
2007-02-06 21:06:38 +01:00
#
2007-03-09 00:38:43 +01:00
# Public targets for developers:
#
2007-03-09 00:38:43 +01:00
# changes-entry:
# Appends a correctly-formatted entry to the pkgsrc CHANGES file.
#
2007-03-09 00:38:43 +01:00
# Command-line variables:
#
2007-03-09 00:38:43 +01:00
# CTYPE
# The type of entry to add. Must be one of "Added",
# "Updated", "Renamed", "Moved", or "Removed".
2007-03-09 00:38:43 +01:00
# The default is "Updated".
#
# TO
# When a package is renamed, this is the new name of the
# package.
#
2007-03-09 00:38:43 +01:00
# NETBSD_LOGIN_NAME
# The login name assigned by the NetBSD Project.
# The default is the local login name.
#
2007-03-09 00:38:43 +01:00
# PKGSRC_CHANGES
# The path to the CHANGES file to which the entry
# is appended.
# The default is ${PKGSRCDIR}/doc/CHANGES-YYYY.
#
2007-03-09 00:38:43 +01:00
# Example usage:
# % cd /usr/pkgsrc/category/package
# % make changes-entry CTYPE=Added
#
# commit-changes-entry:
# cce:
# Like the above, plus the CHANGES file is committed.
#
2007-02-06 21:06:38 +01:00
CTYPE?= Updated
NETBSD_LOGIN_NAME?= ${_NETBSD_LOGIN_NAME_cmd:sh}
PKGSRC_CHANGES?= ${PKGSRCDIR}/doc/CHANGES-${_CYEAR_cmd:sh}
_CYEAR_cmd= ${DATE} -u +%Y
_CDATE_cmd= ${DATE} -u +%Y-%m-%d
_NETBSD_LOGIN_NAME_cmd= ${ID} -nu
.if ${CTYPE} == "Updated"
_CE_MSG1= Updated ${PKGPATH} to ${PKGVERSION}
.elif ${CTYPE} == "Removed"
_CE_MSG1= Removed ${PKGPATH}
.elif ${CTYPE} == "Added"
_CE_MSG1= Added ${PKGPATH} version ${PKGVERSION}
.elif ${CTYPE} == "Renamed" || ${CTYPE} == "Moved"
. if defined(TO)
. if exists(${PKGSRCDIR}/${TO})
_CE_MSG1= ${CTYPE} ${PKGPATH} to ${TO}
. else
_CE_ERRORS+= "[developer.mk] The package ${TO} does not exist."
. endif
. else
_CE_ERRORS+= "[developer.mk] The TO variable must be set."
. endif
.else
_CE_ERRORS+= "[developer.mk] Invalid value "${CTYPE:Q}" for CTYPE."
.endif
_CE_MSG2= [${NETBSD_LOGIN_NAME} ${_CDATE_cmd:sh}]
_CE_MSG= ${_CE_MSG1} ${_CE_MSG2}
_CCE_CHANGES_DIR= ${PKGSRCDIR}/doc/
_CCE_CHANGES_BASE= CHANGES-${_CYEAR_cmd:sh}
_CCE_CHANGES= ${_CCE_CHANGES_DIR}/${_CCE_CHANGES_BASE}
.PHONY: changes-entry
changes-entry: ce-error-check
${RUN} ${ECHO} " "${_CE_MSG:Q} >> ${PKGSRC_CHANGES:Q}
commit-changes-entry cce: .PHONY ce-error-check
@${STEP_MSG} "Updating ${PKGSRC_CHANGES:T}"
${RUN} cd ${_CCE_CHANGES_DIR} && cvs update ${_CCE_CHANGES:T}
${RUN} cd ${_CCE_CHANGES_DIR} && test -w ${_CCE_CHANGES:T} || cvs edit ${_CCE_CHANGES:T}
@${STEP_MSG} "Adding the change"
${RUN} ${ECHO} " "${_CE_MSG:Q} >> ${_CCE_CHANGES}
@${STEP_MSG} "Committing the change"
${RUN} cd ${_CCE_CHANGES_DIR} && cvs commit -m ${_CE_MSG1:Q} ${_CCE_CHANGES:T}
ce-error-check:
.if defined(_CE_ERRORS) && !empty(_CE_ERRORS:M*)
${RUN} for msg in ${_CE_ERRORS}; do ${ERROR_MSG} "$$msg"; done; exit 1
.else
@${DO_NADA}
.endif