Sun Jul 26 21:36:38 2009 UTC ()
Added an experimental target "import" that makes it easier to import
packages from pkgsrc-wip and other sources.


(rillig)
diff -r1.1957 -r1.1958 pkgsrc/mk/bsd.pkg.mk
diff -r0 -r1.1 pkgsrc/mk/misc/import.mk

cvs diff -r1.1957 -r1.1958 pkgsrc/mk/bsd.pkg.mk (expand / switch to unified diff)

--- pkgsrc/mk/bsd.pkg.mk 2009/05/26 06:03:02 1.1957
+++ pkgsrc/mk/bsd.pkg.mk 2009/07/26 21:36:38 1.1958
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.pkg.mk,v 1.1957 2009/05/26 06:03:02 obache Exp $ 1# $NetBSD: bsd.pkg.mk,v 1.1958 2009/07/26 21:36:38 rillig Exp $
2# 2#
3# This file is in the public domain. 3# This file is in the public domain.
4# 4#
5# Please see the pkgsrc/doc/guide manual for details on the 5# Please see the pkgsrc/doc/guide manual for details on the
6# variables used in this make file template. 6# variables used in this make file template.
7# 7#
8# Default sequence for "all" is: 8# Default sequence for "all" is:
9# 9#
10# bootstrap-depends 10# bootstrap-depends
11# fetch 11# fetch
12# checksum 12# checksum
13# depends 13# depends
14# tools 14# tools
@@ -791,14 +791,17 @@ ${_MAKEVARS_MK.${_phase_}}: ${WRKDIR} @@ -791,14 +791,17 @@ ${_MAKEVARS_MK.${_phase_}}: ${WRKDIR}
791 791
792.if make(pbulk-index) || make(pbulk-index-item) || make(pbulk-save-wrkdir) 792.if make(pbulk-index) || make(pbulk-index-item) || make(pbulk-save-wrkdir)
793.include "pbulk/pbulk-index.mk" 793.include "pbulk/pbulk-index.mk"
794.endif 794.endif
795 795
796.if defined(PKG_DEVELOPER) 796.if defined(PKG_DEVELOPER)
797. include "misc/developer.mk" 797. include "misc/developer.mk"
798.endif 798.endif
799.include "misc/show.mk" 799.include "misc/show.mk"
800.if make(debug) 800.if make(debug)
801. include "bsd.pkg.debug.mk" 801. include "bsd.pkg.debug.mk"
802.endif 802.endif
803.include "misc/warnings.mk" 803.include "misc/warnings.mk"
 804.if make(import)
 805.include "misc/import.mk"
 806.endif
804.include "misc/can-be-built-here.mk" 807.include "misc/can-be-built-here.mk"

File Added: pkgsrc/mk/misc/Attic/import.mk
# $NetBSD: import.mk,v 1.1 2009/07/26 21:36:38 rillig Exp $
#

# import:
#	Imports a package from the outside into pkgsrc.
#
#	Command line parameters:
#
#	FROM (optional when you are in a pkgsrc-wip package)
#		The source where the package comes from. A common value
#		is "pkgsrc-wip" or an empty string.
#
#	CATEGORY
#		The main category of the package. This is where the package
#		gets imported.
#
#	BY (optional)
#		The name or mail address of the original package builder.
#		This is used in the commit message.
#
#	NETBSD_LOGIN_NAME
#		The name of your account on cvs.NetBSD.org. Is used for
#		recording the change in doc/CHANGES.
#
# keywords: wip pkgsrc-wip
#

_IMPORT_ERRORS=		# none

_IMPORT_FROM=		# nothing but a leading space
.if defined(FROM) && !empty(FROM)
_IMPORT_FROM+=		from ${FROM}
.elif !empty(PKGPATH:Mwip/*)
_IMPORT_FROM+=		from pkgsrc-wip
.else
_IMPORT_ERRORS+=	"[import.mk] You must set FROM."
.endif
.if ${CATEGORY:U} == ""
_IMPORT_ERRORS+=	"[import.mk] You must set CATEGORY."
.endif
.if exists(${.CURDIR}/TODO)
_IMPORT_ERRORS+=	"[import.mk] Don't import packages that have something TODO."
.endif
.if exists(${PKGSRCDIR}/${CATEGORY:Unonexistent}/${PKGPATH:T}/Makefile)
_IMPORT_ERRORS+=	"[import.mk] The package ${CATEGORY}/${PKGPATH:T} already exists."
.endif
.if ${_EXPERIMENTAL} != "yes"
_IMPORT_ERRORS+=	"[import.mk] The \"import\" target is experimental."
.endif

_IMPORT_YEAR!=		date -u +%Y
_IMPORT_TODAY!=		date -u +%Y-%m-%d
_IMPORT_CHANGES=	${PKGSRCDIR}/doc/CHANGES-${_IMPORT_YEAR}

.PHONY: import _import-check _import-import _import-add-change _import-remove
import: _import-check _import-import _import-add-change _import-remove

_import-check:
.if !empty(_IMPORT_ERRORS)
	${RUN} ${_IMPORT_ERRORS:@e@ ${ERROR_MSG} ${e:Q}; @} ${FALSE}
.endif
	${RUN} pkglint --import -Wall

_import-import:
	@${STEP_MSG} "Importing ${PKGNAME}."
	${RUN} \
	import_msg=`set -e;						\
	{	${ECHO} "Imported ${PKGBASE}${_IMPORT_FROM}.";		\
		${ECHO} "";						\
		${CAT} DESCR;						\
		case ${BY:Q}"" in					\
		"")	;;						\
		*)	${ECHO} ""; ${ECHO} "Packaged by ${BY}.";;	\
		esac;							\
	}`;								\
	cvs -d cvs.netbsd.org:/cvsroot import				\
		-m "$$import_msg"					\
		pkgsrc/${CATEGORY}/${PKGPATH:T}				\
		TNF pkgsrc-base;					\
	${RM} -f "$$import_msg"

_import-add-change:
	@${STEP_MSG} "Adding CHANGES entry."
	${RUN} cd ${PKGSRCDIR}/doc && cvs update ${_IMPORT_CHANGES:T}
	${RUN} printf "\\tAdded %s version %s [%s %s]\\n"		\
		${CATEGORY}/${PKGPATH:T} ${PKGVERSION}			\
		${NETBSD_LOGIN_NAME} ${_IMPORT_TODAY}			\
		>> ${_IMPORT_CHANGES}
	${RUN} cd ${PKGSRCDIR}/doc && cvs commit			\
		-m "Imported ${CATEGORY}/${PKGPATH:T}${_IMPORT_FROM}."	\
		${_IMPORT_CHANGES:T}
	@${STEP_MSG} "Loading the new package from CVS."
	${RUN} cd ${PKGSRCDIR}/${CATEGORY} && cvs update Makefile ${PKGPATH:T}
	@${STEP_MSG} "Adding the package to the category Makefile."
	${RUN} cd ${PKGSRCDIR}/${CATEGORY} && (pkglint -F >/dev/null || ${TRUE}) && pkglint -q
	@${STEP_MSG} "Committing the modified category Makefile."
	${RUN} cd ${PKGSRCDIR}/${CATEGORY} && cvs commit -m "Added ${PKGPATH:T}." Makefile

_IMPORT_REMOVE_FILES!=	ls -d * patches/* files/* 2>/dev/null || ${TRUE}
_IMPORT_REMOVE_FILES:=	${_IMPORT_REMOVE_FILES:NCVS:N*/CVS}
_import-remove:
	${RUN} \
	case ${PKGPATH} in						\
	wip/*)								\
		${STEP_MSG} "Removing ${PKGNAME} from pkgsrc-wip.";	\
		cvs rm -f ${_IMPORT_REMOVE_FILES};			\
		cvs commit -m "Imported into pkgsrc as ${CATEGORY}/${PKGBASE}.";; \
	esac