pkgsrc-WIP-discuss archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
RFC: patch to let import-package.sh handle pkgs that have existed before
Hi,
I wanted to import packages of which at least some of them have existed
in wip before. The current import-package script does not handle that.
I changed it to:
- check the CVS/Repository files under the pkg directory, and allow the
CVS directory to be present if it matches the current location
- exit with error if the Repository file does not match (as replacement
for the check added last month by othyro/wiz)
- exit with error if CVS/Entries files contain anything else than
directories.
- not cvs add directories that contain a CVS directory
and unrelated:
- cleanup temp files on exit
- use "type" instead of "which" to check for bmake presence
- changed the final prompt (it confused me and I pressed enter without "y")
Please find the diff, as well as the complete script attached, and comment.
thanks
dieter
Index: import-package.sh
===================================================================
RCS file: /cvsroot/pkgsrc-wip/wip/import-package.sh,v
retrieving revision 1.9
diff -u -r1.9 import-package.sh
--- import-package.sh 30 Nov 2012 12:24:29 -0000 1.9
+++ import-package.sh 30 Dec 2012 18:10:05 -0000
@@ -14,27 +14,48 @@
[ -n "${MKTEMP}" ] || MKTEMP=mktemp
[ -n "${EDITOR}" ] || EDITOR=vi
+cleanup() {
+ if [ -n "${CLEANUP}" ]; then
+ rm -f ${CLEANUP}
+ fi
+}
+trap cleanup 0
+
if [ -z "${MAKE}" ]; then
- if [ -n "$(which bmake)" ]; then
- MAKE=bmake
- else
- MAKE=make
- fi
+ if type bmake >/dev/null 2>&1; then
+ MAKE=bmake
+ else
+ MAKE=make
+ fi
fi
-if find . | grep -q CVS
-then
- echo "Please remove any existing CVS directories; or change to the
correct directory path" >&2
- exit 1
-fi
+PACKAGE=$(basename $(pwd))
+
+for cvsdir in $(find . -type d -name CVS); do
+ cvsdir=$(echo ${cvsdir} | cut -c 3-)
+ if [ -r "${cvsdir}/Repository" ]; then
+ read repo < "${cvsdir}/Repository"
+ if [ "${repo}" != "$(dirname wip/${PACKAGE}/${cvsdir})" ]; then
+ echo "Mismatched CVS directory found: ${cvsdir}" >&2
+ echo 'Please remove CVS directories from other' \
+ 'packages, or change to the correct' \
+ 'directory path.' >&2
+ exit 1
+ fi
+ fi
+ if grep '[^D]' "${cvsdir}/Entries"; then
+ echo "It seems $(dirname ${cvsdir}) is already checked in." >&2
+ exit 1
+ fi
+done
CATEGORY=$(basename $(dirname $(pwd)))
-PACKAGE=$(basename $(pwd))
PKGPATH=${CATEGORY}/${PACKAGE}
CVSROOT=$(cat ../CVS/Root)
USER=$(echo ${CVSROOT} | sed -e 's/@.*$//' -e 's/^.*://')
USER_UPPER="$(echo ${USER} | tr '[a-z]' '[A-Z]')"
MSG="$(${MKTEMP} -t import-package.XXXXXXXX)"
+CLEANUP="${MSG}"
echo "Please wait while determining PKGNAME and DESCR_SRC."
PKGNAME="$(${MAKE} show-var VARNAME=PKGNAME)"
DESCR_SRC="$(${MAKE} show-var VARNAME=DESCR_SRC) /dev/null"
@@ -51,7 +72,20 @@
echo "CVS:" >> ${MSG}
echo "CVS: Lines starting with CVS: will be automatically removed." >> ${MSG}
echo "CVS:" >> ${MSG}
-find . | grep -v -e CVS -e orig$ -e ^./.# | sed "s|^.|CVS: will add:
${PKGPATH}|" >> ${MSG}
+
+ADDLIST="$(${MKTEMP} -t import-package-files.XXXXXXXX)"
+CLEANUP="${CLEANUP} ${ADDLIST}"
+(
+ cd ..
+ find ${PACKAGE} \( -name CVS -prune \) -o -type d -print |
+ while read dir; do
+ [ -e "${dir}/CVS" ] && continue
+ echo ${dir}
+ done
+ find ${PACKAGE} \( -name CVS -prune \) -o -type f ! -name '*orig' \
+ ! -name '.#*' -print
+) | sort > ${ADDLIST}
+sed 's|^|CVS: will add: wip/|' ${ADDLIST} >> ${MSG}
${EDITOR} ${MSG}
@@ -62,18 +96,21 @@
echo "CVSROOT: ${CVSROOT}"
echo "PKGPATH: ${PKGPATH}"
echo ""
-printf "y, enter to import, ctrl-c to abort> "
+printf "y + enter to import, any other text + enter to abort> "
read ANS
if [ "${ANS}" = "y" ]; then
- (CVS_RSH=ssh cd .. && cvs add ${PACKAGE}) || exit 1
- CVS_RSH=ssh find . -type d | grep -v -e CVS -e '^\.$' | xargs -L 100 cvs
add "$d"
- CVS_RSH=ssh find . -type f | grep -v -e CVS -e orig$ -e ^./.# | xargs -L
100 cvs add "$d"
- CVS_RSH=ssh cvs commit -m "$(grep -v '^CVS:.*$' ${MSG})"
+ (
+ export CVS_RSH=ssh
+ cd ..
+ [ -e "${PACKAGE}/CVS" ] || cvs add ${PACKAGE} || exit 1
+ fgrep -vx ${PACKAGE} ${ADDLIST} | xargs -L 100 cvs add
+ cvs commit -m "$(grep -v '^CVS:.*$' ${MSG})" ${PACKAGE}
+ )
+
+ echo ${DASH70}
+ echo "Don't forget to add the package to ${CATEGORY}/Makefile."
+ echo "When imported to pkgsrc itself, please update the CHANGES-*"
+ echo "file and possibly remove the package from the TODO list."
+ echo ""
fi
-
-echo ${DASH70}
-echo "Don't forget to add the package to ${CATEGORY}/Makefile."
-echo "When imported to pkgsrc itself, please update the CHANGES-*"
-echo "file and possibly remove the package from the TODO list."
-echo ""
#! /bin/sh
#
# $Id: import-package.sh,v 1.9 2012/11/30 12:24:29 thomasklausner Exp $
#
# Script designed to make add packages into wip easier.
#
# Just cd to the package directory and run ../import-package.sh
#
# It will automatically create a nice import message based on DESCR
# and PKGNAME, set up the CVS tags correctly and autodetect what CVSROOT
# to use. It also shows you what files will be imported, reminds you
# to run pkglint(1) and asks for confirmation before doing anything.
[ -n "${MKTEMP}" ] || MKTEMP=mktemp
[ -n "${EDITOR}" ] || EDITOR=vi
cleanup() {
if [ -n "${CLEANUP}" ]; then
rm -f ${CLEANUP}
fi
}
trap cleanup 0
if [ -z "${MAKE}" ]; then
if type bmake >/dev/null 2>&1; then
MAKE=bmake
else
MAKE=make
fi
fi
PACKAGE=$(basename $(pwd))
for cvsdir in $(find . -type d -name CVS); do
cvsdir=$(echo ${cvsdir} | cut -c 3-)
if [ -r "${cvsdir}/Repository" ]; then
read repo < "${cvsdir}/Repository"
if [ "${repo}" != "$(dirname wip/${PACKAGE}/${cvsdir})" ]; then
echo "Mismatched CVS directory found: ${cvsdir}" >&2
echo 'Please remove CVS directories from other' \
'packages, or change to the correct' \
'directory path.' >&2
exit 1
fi
fi
if grep '[^D]' "${cvsdir}/Entries"; then
echo "It seems $(dirname ${cvsdir}) is already checked in." >&2
exit 1
fi
done
CATEGORY=$(basename $(dirname $(pwd)))
PKGPATH=${CATEGORY}/${PACKAGE}
CVSROOT=$(cat ../CVS/Root)
USER=$(echo ${CVSROOT} | sed -e 's/@.*$//' -e 's/^.*://')
USER_UPPER="$(echo ${USER} | tr '[a-z]' '[A-Z]')"
MSG="$(${MKTEMP} -t import-package.XXXXXXXX)"
CLEANUP="${MSG}"
echo "Please wait while determining PKGNAME and DESCR_SRC."
PKGNAME="$(${MAKE} show-var VARNAME=PKGNAME)"
DESCR_SRC="$(${MAKE} show-var VARNAME=DESCR_SRC) /dev/null"
DASH70=----------------------------------------------------------------------
echo "Import ${PKGNAME} as ${CATEGORY}/${PACKAGE}." > ${MSG}
echo "" >> ${MSG}
cat ${DESCR_SRC} >> ${MSG}
echo ${DASH70} | sed 's/^/CVS: /' >> ${MSG}
echo "CVS: Please edit the above message to give a brief description" >> ${MSG}
echo "CVS: of the package for those who read the *-changes@ list." >> ${MSG}
echo "CVS: Did you remember to run pkglint(1) before importing?" >> ${MSG}
echo "CVS:" >> ${MSG}
echo "CVS: Lines starting with CVS: will be automatically removed." >> ${MSG}
echo "CVS:" >> ${MSG}
ADDLIST="$(${MKTEMP} -t import-package-files.XXXXXXXX)"
CLEANUP="${CLEANUP} ${ADDLIST}"
(
cd ..
find ${PACKAGE} \( -name CVS -prune \) -o -type d -print |
while read dir; do
[ -e "${dir}/CVS" ] && continue
echo ${dir}
done
find ${PACKAGE} \( -name CVS -prune \) -o -type f ! -name '*orig' \
! -name '.#*' -print
) | sort > ${ADDLIST}
sed 's|^|CVS: will add: wip/|' ${ADDLIST} >> ${MSG}
${EDITOR} ${MSG}
echo "Edited message follows:"
echo ${DASH70}
grep -v '^CVS:.*$' < ${MSG}
echo ${DASH70}
echo "CVSROOT: ${CVSROOT}"
echo "PKGPATH: ${PKGPATH}"
echo ""
printf "y + enter to import, any other text + enter to abort> "
read ANS
if [ "${ANS}" = "y" ]; then
(
export CVS_RSH=ssh
cd ..
[ -e "${PACKAGE}/CVS" ] || cvs add ${PACKAGE} || exit 1
fgrep -vx ${PACKAGE} ${ADDLIST} | xargs -L 100 cvs add
cvs commit -m "$(grep -v '^CVS:.*$' ${MSG})" ${PACKAGE}
)
echo ${DASH70}
echo "Don't forget to add the package to ${CATEGORY}/Makefile."
echo "When imported to pkgsrc itself, please update the CHANGES-*"
echo "file and possibly remove the package from the TODO list."
echo ""
fi
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
pkgsrc-wip-discuss mailing list
pkgsrc-wip-discuss%lists.sourceforge.net@localhost
https://lists.sourceforge.net/lists/listinfo/pkgsrc-wip-discuss
Home |
Main Index |
Thread Index |
Old Index