5 |
# Copyright (C) 2004-2005 Red Hat, Inc. |
# Copyright (C) 2004-2005 Red Hat, Inc. |
6 |
# Copyright (C) 2005 Fedora Foundation |
# Copyright (C) 2005 Fedora Foundation |
7 |
# |
# |
8 |
# $Id: cvs-import.sh,v 1.1 2007/11/08 18:10:19 slords Exp $ |
# $Id: cvs-import.sh,v 1.8 2011/11/03 22:47:20 slords Exp $ |
9 |
|
|
10 |
|
shopt -s nocasematch |
11 |
|
|
12 |
# Initial setup |
# Initial setup |
13 |
CVSTREE=${CVSTREE:=extras} |
CVSTREE=${CVSTREE:=extras} |
23 |
# use the CVSROOT from the checkout |
# use the CVSROOT from the checkout |
24 |
CVSROOT=$(cat ${MYDIR}/CVS/Root) |
CVSROOT=$(cat ${MYDIR}/CVS/Root) |
25 |
|
|
26 |
|
# use the TAG from the checkout |
27 |
|
TAG=$(sed -n 's@^T@@p' $(pwd)/CVS/Tag 2> /dev/null) |
28 |
|
|
29 |
# We need a writable directory for temporary checkouts and CVS work |
# We need a writable directory for temporary checkouts and CVS work |
30 |
WORKDIR="/tmp" |
WORKDIR="/tmp" |
31 |
if test -w $(pwd) ; then |
if test -w $(pwd) ; then |
32 |
WORKDIR="$(pwd)" |
WORKDIR="$(pwd)" |
33 |
fi |
fi |
34 |
|
|
35 |
|
[ -f branch ] && BRANCH=$(cat branch) |
36 |
|
|
37 |
# short usage help |
# short usage help |
38 |
Usage() { |
Usage() { |
39 |
cat <<EOF |
cat <<EOF |
40 |
Usage: |
Usage: |
41 |
|
|
42 |
$0 [-b <branch>] [-m <message>] <package> |
$0 [-b <branch>] [-t <cvs tag/branch>] [-m <message>] <package> |
43 |
|
|
44 |
Imports a package into the cvs repository. Will use the following defaults: |
Imports a package into the cvs repository. Will use the following defaults: |
45 |
CVSROOT = $CVSROOT |
CVSROOT = $CVSROOT |
46 |
BRANCH = ${BRANCH:-devel} |
BRANCH = ${BRANCH:-devel} |
47 |
|
TAG = ${TAG} |
48 |
|
|
49 |
The package can also be imported on a PRE-EXISTING branch using the |
The package can also be imported on a PRE-EXISTING branch using the |
50 |
"-b BRANCH" flag. This script can not create new branches for you. |
"-b BRANCH" flag. This script can not create new branches for you. |
53 |
} |
} |
54 |
|
|
55 |
# Parse arguments |
# Parse arguments |
|
BRANCH= |
|
56 |
MESSAGE= |
MESSAGE= |
57 |
while [ -n "$1" ] ; do |
while [ -n "$1" ] ; do |
58 |
case "$1" in |
case "$1" in |
59 |
# import the package on the given branch. If the branch does |
# import the package on the given branch. If the branch does |
60 |
# not exist, we will branch the HEAD and then we will perform |
# not exist, we will branch the HEAD and then we will perform |
61 |
# the import |
# the import |
62 |
|
-t | --tag ) |
63 |
|
shift |
64 |
|
TAG="$1" |
65 |
|
if [ -z "$TAG" ] ; then |
66 |
|
echo "ERROR: --tag requires an argument" |
67 |
|
Usage |
68 |
|
exit -1 |
69 |
|
fi |
70 |
|
;; |
71 |
|
|
72 |
-b | --branch ) |
-b | --branch ) |
73 |
shift |
shift |
74 |
BRANCH="$1" |
BRANCH="$1" |
159 |
SPECFILE = \$(firstword \$(wildcard *.spec)) |
SPECFILE = \$(firstword \$(wildcard *.spec)) |
160 |
|
|
161 |
define find-makefile-common |
define find-makefile-common |
162 |
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 |
163 |
endef |
endef |
164 |
|
|
165 |
MAKEFILE_COMMON := \$(shell \$(find-makefile-common)) |
MAKEFILE_COMMON := \$(shell \$(find-makefile-common)) |
167 |
ifeq (\$(MAKEFILE_COMMON),) |
ifeq (\$(MAKEFILE_COMMON),) |
168 |
# attept a checkout |
# attept a checkout |
169 |
define checkout-makefile-common |
define checkout-makefile-common |
170 |
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 |
171 |
endef |
endef |
172 |
|
|
173 |
MAKEFILE_COMMON := \$(shell \$(checkout-makefile-common)) |
MAKEFILE_COMMON := \$(shell \$(checkout-makefile-common)) |
180 |
# Check out the existing module |
# Check out the existing module |
181 |
cd $TMPDIR |
cd $TMPDIR |
182 |
echo "Checking out module: '$NAME'" |
echo "Checking out module: '$NAME'" |
183 |
$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; } |
184 |
|
|
185 |
# this is our working directory |
# this is our working directory |
186 |
cd $TOPLEVEL/$NAME |
cd $TOPLEVEL/$NAME |
190 |
# check if we have imported this entry |
# check if we have imported this entry |
191 |
TAG=$(echo "${NAME##[0-9]}-$VERSION-$RELEASE" | sed -e 's/[$,.:;@]/_/g') |
TAG=$(echo "${NAME##[0-9]}-$VERSION-$RELEASE" | sed -e 's/[$,.:;@]/_/g') |
192 |
LOG_ENTRY="$TAG:${BRANCH:-HEAD}:$(basename $PACKAGE)" |
LOG_ENTRY="$TAG:${BRANCH:-HEAD}:$(basename $PACKAGE)" |
193 |
|
if [ -n "$(grep ""^$LOG_ENTRY"" ./${BRANCH}/import.log 2>/dev/null)" ] ; then |
194 |
|
echo "ERROR: $PACKAGE was already imported on branch ${BRANCH:-HEAD}" |
195 |
|
CleanUp |
196 |
|
exit -2 |
197 |
|
fi |
198 |
|
# Check here as well because back in the old days we used to write it here |
199 |
if [ -n "$(grep ""^$LOG_ENTRY"" ./import.log 2>/dev/null)" ] ; then |
if [ -n "$(grep ""^$LOG_ENTRY"" ./import.log 2>/dev/null)" ] ; then |
200 |
echo "ERROR: $PACKAGE was already imported on branch ${BRANCH:-HEAD}" |
echo "ERROR: $PACKAGE was already imported on branch ${BRANCH:-HEAD}" |
201 |
CleanUp |
CleanUp |
223 |
# Remove the files that are no longer present |
# Remove the files that are no longer present |
224 |
OLDFILES=$(find ${BRANCH} -maxdepth 1 -type f \ |
OLDFILES=$(find ${BRANCH} -maxdepth 1 -type f \ |
225 |
-not -name branch \ |
-not -name branch \ |
226 |
|
-not -name import.log \ |
227 |
-not -name sources \ |
-not -name sources \ |
228 |
-not -name Makefile \ |
-not -name Makefile \ |
229 |
-not -name .cvsignore \ |
-not -name .cvsignore \ |
266 |
pushd ${BRANCH} >/dev/null |
pushd ${BRANCH} >/dev/null |
267 |
if [ "$add_file" = "yes" ] ; then |
if [ "$add_file" = "yes" ] ; then |
268 |
case $f in |
case $f in |
269 |
*.tar | *gz | *.bz2 | *.Z | *.zip | *.ZIP | \ |
*.tar | *gz | *.bz2 | *.lzma | *.Z | *.zip | \ |
270 |
*.ttf | *.bin | *.tbz | *.pdf | *.rpm | \ |
*.ttf | *.bin | *.tbz | *.tbz2 | *.pdf | *.rpm | \ |
271 |
*.jar | *.war | *.db | *.cpio | *.jisp | *.egg ) |
*.jar | *.war | *.db | *.cpio | *.jisp | *.egg | *.gem ) |
272 |
UPLOADFILES="$UPLOADFILES $f" |
UPLOADFILES="$UPLOADFILES $f" |
273 |
if [ -n "$(grep $f sources 2>/dev/null)" ] ; then |
if [ -n "$(grep $f sources 2>/dev/null)" ] ; then |
274 |
# this file existed before with a different md5sum |
# this file existed before with a different md5sum |
306 |
rm -rf $TMP2 |
rm -rf $TMP2 |
307 |
|
|
308 |
# setup finished |
# setup finished |
309 |
echo "$LOG_ENTRY:$(date +%s)" >> ./import.log |
[ -f ./${BRANCH}/import.log ] || $(touch ./${BRANCH}/import.log; cvs add ./${BRANCH}/import.log) |
310 |
|
echo "$LOG_ENTRY:$(date +%s)" >> ./${BRANCH}/import.log |
311 |
|
|
312 |
echo "=======================================================================" |
echo "=======================================================================" |
313 |
cvs -Q diff -u |
cvs -Q diff -u |
315 |
echo "Please check the above cvs diff." |
echo "Please check the above cvs diff." |
316 |
echo "If you want to make any changes before committing, please press Ctrl-C." |
echo "If you want to make any changes before committing, please press Ctrl-C." |
317 |
echo "Otherwise press Enter to proceed to commit." |
echo "Otherwise press Enter to proceed to commit." |
318 |
#read |
read |
319 |
|
|
320 |
cvs -Q update && \ |
cvs -Q update && \ |
321 |
echo "cvs commit..." && \ |
echo "cvs commit..." && \ |
322 |
cvs -Q commit ${MESSAGE:+-m "$MESSAGE"} && echo "Commit Complete" |
cvs -Q commit ${MESSAGE:+-m "$MESSAGE"} && echo "Commit Complete" && \ |
323 |
|
cd ${BRANCH} && cvs tag ${TAG} && echo "Tagging '${TAG}' complete." |
324 |
|
|
325 |
# Clean up |
# Clean up |
326 |
CleanUp |
CleanUp |