Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / misc / import.mk
blob170d02a8d8886066a571c1d78f634e34b1870a70
1 # $NetBSD: import.mk,v 1.4 2011/11/13 23:04:41 joerg Exp $
4 # import:
5 # Imports a package from the outside into pkgsrc.
7 # Command line parameters:
9 # FROM (optional when you are in a pkgsrc-wip package)
10 # The source where the package comes from. A common value
11 # is "pkgsrc-wip" or an empty string.
13 # CATEGORY
14 # The main category of the package. This is where the package
15 # gets imported.
17 # BY (optional)
18 # The name or mail address of the original package builder.
19 # This is used in the commit message.
21 # NETBSD_LOGIN_NAME
22 # The name of your account on cvs.NetBSD.org. Is used for
23 # recording the change in doc/CHANGES.
25 # keywords: wip pkgsrc-wip
28 _IMPORT_ERRORS= # none
30 _IMPORT_FROM= # nothing but a leading space
31 .if defined(FROM)
32 . if !empty(FROM)
33 _IMPORT_FROM+= from ${FROM}
34 . endif
35 .elif !empty(PKGPATH:Mwip/*)
36 _IMPORT_FROM+= from pkgsrc-wip
37 .else
38 _IMPORT_ERRORS+= "[import.mk] You must set FROM."
39 .endif
40 CATEGORY?= ${CATEGORIES:[1]}
41 .if ${CATEGORY:U} == ""
42 _IMPORT_ERRORS+= "[import.mk] You must set CATEGORY."
43 .endif
44 .if exists(${.CURDIR}/TODO)
45 _IMPORT_ERRORS+= "[import.mk] Don't import packages that have something TODO."
46 .endif
47 .if exists(${PKGSRCDIR}/${CATEGORY:Unonexistent}/${PKGPATH:T}/Makefile)
48 _IMPORT_REMOVE_BEFORE_UPDATE=yes
49 .else
50 _IMPORT_REMOVE_BEFORE_UPDATE=no
51 .endif
52 .if ${_EXPERIMENTAL:U""} != "yes"
53 _IMPORT_ERRORS+= "[import.mk] The \"import\" target is experimental."
54 .endif
56 _IMPORT_YEAR!= date -u +%Y
57 _IMPORT_TODAY!= date -u +%Y-%m-%d
58 _IMPORT_CHANGES= ${PKGSRCDIR}/doc/CHANGES-${_IMPORT_YEAR}
60 .PHONY: import _import-check _import-import _import-add-change _import-remove
61 import: _import-check _import-import _import-add-change _import-remove
63 _import-check:
64 .if !empty(_IMPORT_ERRORS)
65 ${RUN} ${_IMPORT_ERRORS:@e@ ${ERROR_MSG} ${e:Q}; @} ${FALSE}
66 .endif
67 ${RUN} pkglint --import -Wall
69 _import-import:
70 @${STEP_MSG} "Importing ${PKGNAME}."
71 ${RUN} \
72 import_msg=`set -e; \
73 { ${ECHO} "Imported ${PKGBASE}${_IMPORT_FROM}."; \
74 ${ECHO} ""; \
75 ${CAT} DESCR; \
76 case ${BY:Q}"" in \
77 "") ;; \
78 *) ${ECHO} ""; ${ECHO} "Packaged by ${BY}.";; \
79 esac; \
80 }`; \
81 cvs -d cvs.netbsd.org:/cvsroot import \
82 -m "$$import_msg" \
83 pkgsrc/${CATEGORY}/${PKGPATH:T} \
84 TNF pkgsrc-base
86 _import-add-change:
87 @${STEP_MSG} "Adding CHANGES entry."
88 ${RUN} cd ${PKGSRCDIR}/doc && cvs update ${_IMPORT_CHANGES:T}
89 ${RUN} printf "\\tAdded %s version %s [%s %s]\\n" \
90 ${CATEGORY}/${PKGPATH:T} ${PKGVERSION} \
91 ${NETBSD_LOGIN_NAME} ${_IMPORT_TODAY} \
92 >> ${_IMPORT_CHANGES}
93 ${RUN} cd ${PKGSRCDIR}/doc && cvs commit \
94 -m "Imported ${CATEGORY}/${PKGPATH:T}${_IMPORT_FROM}." \
95 ${_IMPORT_CHANGES:T}
96 .if ${_IMPORT_REMOVE_BEFORE_UPDATE} == "yes"
97 @${STEP_MSG} "Removing local copy."
98 ${RUN} cd ${PKGSRCDIR}/${CATEGORY}/${PKGPATH:T} && rm -f *
99 .endif
100 @${STEP_MSG} "Loading the new package from CVS."
101 ${RUN} cd ${PKGSRCDIR}/${CATEGORY}/${PKGPATH:T} && rm -f *
102 ${RUN} cd ${PKGSRCDIR}/${CATEGORY} && cvs update Makefile ${PKGPATH:T}
103 @${STEP_MSG} "Adding the package to the category Makefile."
104 ${RUN} cd ${PKGSRCDIR}/${CATEGORY} && (pkglint -F >/dev/null || ${TRUE}) && pkglint -q
105 @${STEP_MSG} "Committing the modified category Makefile."
106 ${RUN} cd ${PKGSRCDIR}/${CATEGORY} && cvs commit -m "Added ${PKGPATH:T}." Makefile
108 _IMPORT_REMOVE_FILES!= ls -d * patches/* files/* 2>/dev/null || ${TRUE}
109 _IMPORT_REMOVE_FILES:= ${_IMPORT_REMOVE_FILES:NCVS:N*/CVS}
110 _import-remove:
111 ${RUN} \
112 case ${PKGPATH} in \
113 wip/*) \
114 ${STEP_MSG} "Removing ${PKGNAME} from pkgsrc-wip."; \
115 cvs rm -f ${_IMPORT_REMOVE_FILES}; \
116 cvs commit -m "Imported into pkgsrc as ${CATEGORY}/${PKGBASE}.";; \
117 esac