3 # $Id: import-package.sh,v 1.3 2008/03/28 02:51:46 tnn2 Exp $
5 # Script designed to make initial imports into wip easier.
7 # Just cd to the package directory and run ../import-package.sh
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.
14 [ -n "${MKTEMP}" ] || MKTEMP=mktemp
15 [ -n "${EDITOR}" ] || EDITOR=vi
17 if [ -z "${MAKE}" ]; then
18 if [ -n "$(which bmake)" ]; then
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"
36 DASH70=----------------------------------------------------------------------
38 if echo ${CVSROOT} | grep -i pkgsrc-wip > /dev/null; then
39 TAGS="${USER_UPPER} ${USER_UPPER}_$(date +%Y%m%d)"
42 TAGS="TNF pkgsrc-base"
46 echo "Import ${PKGNAME} as ${CATEGORY}/${PACKAGE}." > ${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}
54 echo "CVS: Lines starting with CVS: will be automatically removed." >> ${MSG}
56 find . | sed "s|^.|CVS: will import: ${ROOTDIR}${PKGPATH}|" >> ${MSG}
60 echo "Edited message follows:"
62 grep -v '^CVS:.*$' < ${MSG}
64 echo "CVSROOT: ${CVSROOT}"
65 echo "ROOTDIR: ${ROOTDIR}"
66 echo "PKGPATH: ${PKGPATH}"
69 printf "y, enter to import, ctrl-c to abort> "
72 if [ "${ANS}" = "y" ]; then
73 CVS_RSH=ssh cvs -d ${CVSROOT} import -m "$(cat ${MSG} | grep -v '^CVS:.*$')" ${ROOTDIR}${PKGPATH} ${TAGS}
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."
82 echo "Don't forget to add the package to ${CATEGORY}/Makefile and remove"
83 echo "it from the TODO list."