update Fri Oct 30 12:37:00 PDT 2009
[pkgsrc.git] / wip / import-package.sh
1 #! /bin/sh
2 #
3 # $Id: import-package.sh,v 1.3 2008/03/28 02:51:46 tnn2 Exp $
4 #
5 # Script designed to make initial imports into wip easier.
6 #
7 # Just cd to the package directory and run ../import-package.sh
8 #
9 # It will automatically create a nice import message based on DESCR
10 # and PKGNAME, set up the CVS tags correctly and autodetect what CVSROOT
11 # to use. It also shows you what files will be imported, reminds you
12 # to run pkglint(1) and asks for confirmation before doing anything.
13
14 [ -n "${MKTEMP}" ] || MKTEMP=mktemp
15 [ -n "${EDITOR}" ] || EDITOR=vi
16
17 if [ -z "${MAKE}" ]; then
18   if [ -n "$(which bmake)" ]; then
19     MAKE=bmake
20   else
21     MAKE=make
22   fi
23 fi
24
25 CATEGORY=$(basename $(dirname $(pwd)))
26 PACKAGE=$(basename $(pwd))
27 PKGPATH=${CATEGORY}/${PACKAGE}
28 CVSROOT=$(cat ../CVS/Root)
29 USER=$(echo ${CVSROOT} | sed -e 's/@.*$//' -e 's/^.*://')
30 USER_UPPER="$(echo ${USER} | tr '[a-z]' '[A-Z]')"
31 MSG="$(${MKTEMP} -t import-package.XXXXXXXX)"
32 echo "Please wait while determining PKGNAME and DESCR_SRC."
33 PKGNAME="$(${MAKE} show-var VARNAME=PKGNAME)"
34 DESCR_SRC="$(${MAKE} show-var VARNAME=DESCR_SRC) /dev/null"
35
36 DASH70=----------------------------------------------------------------------
37
38 if echo ${CVSROOT} | grep -i pkgsrc-wip > /dev/null; then
39   TAGS="${USER_UPPER} ${USER_UPPER}_$(date +%Y%m%d)"
40   ROOTDIR=
41 else
42   TAGS="TNF pkgsrc-base"
43   ROOTDIR=pkgsrc/
44 fi
45
46 echo "Import ${PKGNAME} as ${CATEGORY}/${PACKAGE}." > ${MSG}
47 echo "" >> ${MSG}
48 cat ${DESCR_SRC} >> ${MSG}
49 echo ${DASH70} | sed 's/^/CVS: /' >> ${MSG}
50 echo "CVS: Please edit the above message to give a brief description" >> ${MSG}
51 echo "CVS: of the package for those who read the *-changes@ list." >> ${MSG}
52 echo "CVS: Did you remember to run pkglint(1) before importing?" >> ${MSG}
53 echo "CVS:" >> ${MSG}
54 echo "CVS: Lines starting with CVS: will be automatically removed." >> ${MSG}
55 echo "CVS:" >> ${MSG}
56 find . | sed "s|^.|CVS: will import: ${ROOTDIR}${PKGPATH}|" >> ${MSG}
57
58 ${EDITOR} ${MSG}
59
60 echo "Edited message follows:"
61 echo ${DASH70}
62 grep -v '^CVS:.*$' < ${MSG}
63 echo ${DASH70}
64 echo    "CVSROOT:       ${CVSROOT}"
65 echo    "ROOTDIR:       ${ROOTDIR}"
66 echo    "PKGPATH:       ${PKGPATH}"
67 echo    "TAGS:          ${TAGS}"
68 echo ""
69 printf "y, enter to import, ctrl-c to abort> "
70 read ANS
71
72 if [ "${ANS}" = "y" ]; then
73   CVS_RSH=ssh cvs -d ${CVSROOT} import -m "$(cat ${MSG} | grep -v '^CVS:.*$')" ${ROOTDIR}${PKGPATH} ${TAGS}
74 fi
75
76 echo ${DASH70}
77 echo "If the import went OK, move away the ${PKGPATH} directory"
78 echo "and run \"cvs update -dPA ${PACKAGE}\" in ${CATEGORY} to complete"
79 echo "the import. If you got conflict errors, just cvs add the"
80 echo "conflicting files and cvs commit them."
81 echo ""
82 echo "Don't forget to add the package to ${CATEGORY}/Makefile and remove"
83 echo "it from the TODO list."
84 echo ""