--- common/cvs-import.sh 2007/11/08 18:10:19 1.1 +++ common/cvs-import.sh 2013/02/26 18:51:26 1.10 @@ -5,7 +5,9 @@ # Copyright (C) 2004-2005 Red Hat, Inc. # Copyright (C) 2005 Fedora Foundation # -# $Id: cvs-import.sh,v 1.1.1.1 2007/06/12 14:33:00 slords Exp $ +# $Id: cvs-import.sh,v 1.9 2012/03/14 15:25:11 slords Exp $ + +shopt -s nocasematch # Initial setup CVSTREE=${CVSTREE:=extras} @@ -21,22 +23,28 @@ fi # use the CVSROOT from the checkout CVSROOT=$(cat ${MYDIR}/CVS/Root) +# use the TAG from the checkout +TAG=$(sed -n 's@^T@@p' $(pwd)/CVS/Tag 2> /dev/null) + # We need a writable directory for temporary checkouts and CVS work WORKDIR="/tmp" if test -w $(pwd) ; then WORKDIR="$(pwd)" fi +[ -f branch ] && BRANCH=$(cat branch) + # short usage help Usage() { cat <] [-m ] + $0 [-b ] [-t ] [-m ] Imports a package into the cvs repository. Will use the following defaults: CVSROOT = $CVSROOT BRANCH = ${BRANCH:-devel} +TAG = ${TAG} The package can also be imported on a PRE-EXISTING branch using the "-b BRANCH" flag. This script can not create new branches for you. @@ -45,13 +53,22 @@ EOF } # Parse arguments -BRANCH= MESSAGE= while [ -n "$1" ] ; do case "$1" in # import the package on the given branch. If the branch does # not exist, we will branch the HEAD and then we will perform # the import + -t | --tag ) + shift + TAG="$1" + if [ -z "$TAG" ] ; then + echo "ERROR: --tag requires an argument" + Usage + exit -1 + fi + ;; + -b | --branch ) shift BRANCH="$1" @@ -142,7 +159,7 @@ NAME := $NAME SPECFILE = \$(firstword \$(wildcard *.spec)) define find-makefile-common -for d in ../common ../../common ; do if [ -f \$\$d/Makefile.common ] ; then if [ -f \$\$d/CVS/Root -a -w \$\$/Makefile.common ] ; then cd \$\$d ; cvs -Q update ; fi ; echo "\$\$d/Makefile.common" ; break ; fi ; done +for d in common ../common ../../common ; do if [ -f \$\$d/Makefile.common ] ; then if [ -f \$\$d/CVS/Root -a -w \$\$/Makefile.common ] ; then cd \$\$d ; cvs -Q update ; fi ; echo "\$\$d/Makefile.common" ; break ; fi ; done endef MAKEFILE_COMMON := \$(shell \$(find-makefile-common)) @@ -150,7 +167,7 @@ MAKEFILE_COMMON := \$(shell \$(find-make ifeq (\$(MAKEFILE_COMMON),) # attept a checkout define checkout-makefile-common -test -f CVS/Root && { cd .. ; cvs -Q -d \$\$(cat CVS/Root) checkout common && echo "../common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +test -f CVS/Root && { cvs -Q -d \$\$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 endef MAKEFILE_COMMON := \$(shell \$(checkout-makefile-common)) @@ -163,7 +180,7 @@ EOF # Check out the existing module cd $TMPDIR echo "Checking out module: '$NAME'" -$CVS -Q checkout $TOPLEVEL/$NAME || { echo "ERROR: \"$NAME\" module does not exist in cvs."; exit 1; } +$CVS -Q checkout ${TAG:+-r $TAG} $TOPLEVEL/$NAME || { echo "ERROR: \"$NAME\" module does not exist in cvs."; exit 1; } # this is our working directory cd $TOPLEVEL/$NAME @@ -173,6 +190,12 @@ cd $TOPLEVEL/$NAME # check if we have imported this entry TAG=$(echo "${NAME##[0-9]}-$VERSION-$RELEASE" | sed -e 's/[$,.:;@]/_/g') LOG_ENTRY="$TAG:${BRANCH:-HEAD}:$(basename $PACKAGE)" +if [ -n "$(grep ""^$LOG_ENTRY"" ./${BRANCH}/import.log 2>/dev/null)" ] ; then + echo "ERROR: $PACKAGE was already imported on branch ${BRANCH:-HEAD}" + CleanUp + exit -2 +fi +# Check here as well because back in the old days we used to write it here if [ -n "$(grep ""^$LOG_ENTRY"" ./import.log 2>/dev/null)" ] ; then echo "ERROR: $PACKAGE was already imported on branch ${BRANCH:-HEAD}" CleanUp @@ -200,6 +223,7 @@ FILES=$(rpm -qpl $PACKAGE 2>/dev/null) # Remove the files that are no longer present OLDFILES=$(find ${BRANCH} -maxdepth 1 -type f \ -not -name branch \ + -not -name import.log \ -not -name sources \ -not -name Makefile \ -not -name .cvsignore \ @@ -242,9 +266,9 @@ for _f in $FILES ; do pushd ${BRANCH} >/dev/null if [ "$add_file" = "yes" ] ; then case $f in - *.tar | *gz | *.bz2 | *.Z | *.zip | *.ZIP | \ - *.ttf | *.bin | *.tbz | *.pdf | *.rpm | \ - *.jar | *.war | *.db | *.cpio | *.jisp | *.egg ) + *.tar | *gz | *.bz2 | *.lzma | *.Z | *.zip | *.xz | \ + *.ttf | *.bin | *.tbz | *.tbz2 | *.pdf | *.rpm | \ + *.jar | *.war | *.db | *.cpio | *.jisp | *.egg | *.gem ) UPLOADFILES="$UPLOADFILES $f" if [ -n "$(grep $f sources 2>/dev/null)" ] ; then # this file existed before with a different md5sum @@ -282,7 +306,8 @@ popd >/dev/null rm -rf $TMP2 # setup finished -echo "$LOG_ENTRY:$(date +%s)" >> ./import.log +[ -f ./${BRANCH}/import.log ] || $(touch ./${BRANCH}/import.log; cvs add ./${BRANCH}/import.log) +echo "$LOG_ENTRY:$(date +%s)" >> ./${BRANCH}/import.log echo "=======================================================================" cvs -Q diff -u @@ -294,7 +319,8 @@ read cvs -Q update && \ echo "cvs commit..." && \ - cvs -Q commit ${MESSAGE:+-m "$MESSAGE"} && echo "Commit Complete" + cvs -Q commit ${MESSAGE:+-m "$MESSAGE"} && echo "Commit Complete" && \ + cd ${BRANCH} && cvs tag ${TAG} && echo "Tagging '${TAG}' complete." # Clean up CleanUp