File: cvs-upgrade

package info (click to toggle)
cvs-buildpackage 1.14
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 128 kB
  • ctags: 34
  • sloc: sh: 857; perl: 77; makefile: 61
file content (314 lines) | stat: -rwxr-xr-x 9,316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#! /bin/bash
#                               -*- Mode: Sh -*- 
# cvs-upgrade --- 
# Author           : Manoj Srivastava ( srivasta@tiamat.datasync.com ) 
# Created On       : Fri Feb 20 15:17:09 1998
# Created On Node  : tiamat.datasync.com
# Last Modified By : Manoj Srivastava
# Last Modified On : Wed Apr  1 15:30:24 1998
# Last Machine Used: tiamat.datasync.com
# Update Count     : 78
# Status           : Unknown, Use with caution!
# HISTORY          : 
# Description      : 
# 
# 

# Make sure we abort on error
set -e

progname="`basename \"$0\"`"
pversion='$Revision: 1.6 $'

setq() {
    # Variable Value Doc string
    if [ "x$2" = "x" ]; then
        echo >&2 "$progname: Unable to determine $3"
        exit 1;
    else
        if [ ! "x$Verbose" = "x" ]; then
            echo "$progname: $3 is $2";
        fi
        eval "$1=\"\$2\"";
    fi
}

withecho () {
        echo " $@" >&2
        "$@"
}

usageversion () {
        cat >&2 <<END
Usage: $progname  [options] <package name> <upstream version> <debian version>
Options: 
  -h           print this message
  -M<module>   CVS module name
  -R<root dir> Root directory.
  -W<work dir> Working directory.    
  -d<digit>    Set Debug Level
  -n           "Dry-run" mode - No action taken, only print commands.
  -v           make the command verbose
  -x<prefix>   CVS default module prefix.
 
 Files are unpacked in here while being upgraded. The new upstream
 sources are expected in the file
 <workdir>/<package name>/<package name>_<upstream version>.orig.tar.gz)
 and should unpack into a subdir.

Note that the current behaviour of cvs-upgrade is to ignore files that
match the default list of file name patterns to be ignored (this is
built into cvs); and that any .cvsignore files in the upstream sources
shall be honoured.

END
}

# The defaults
docmd='YES'
action='withecho'
tmpdir="temp-$progname"


DEBUG=0
VERBOSE=0
# parse Command line
while [ $# != 0 ]; do
    value="`echo x\"$1\" | sed -e 's/^x-.//'`"
    case "$1" in
        -h)  usageversion; exit 0          ;;
        -M*) opt_cvsmodule="$value"        ;;
        -R*) opt_rootdir="$value"          ;;
        -W*) opt_workdir="$value"          ;;
	-n)  action='echo';docmd='NO'      ;;
	-v)  VERBOSE=1                     ;;
	-d*) opt_DEBUG="$value"            ;;
	-x*) opt_prefix="$value"           ;;
	-*) echo >&2 "Unknown option $1."
	    usageversion; exit 1           ;;
	*)  break                          ;;
    esac
    shift
done

# We need at lease two arguments
if [ $# -lt 2 ]; then
    echo >&2 " Require package name and upstream version"
    usageversion; 
    exit 1;
fi

package=$1
shift
upstream_version=$1
cvs_upstream_tag=`echo "upstream_version_$upstream_version" | tr . _ `
shift


if [ $# != 0 ]; then
    debian_version=$1
    cvstag=`echo "debian_version_${upstream_version}-$debian_version" | tr . _ `
else
    debian_version=""
    cvstag="debian_version_${upstream_tag}"
fi

CVS_QUIET="-Q"
TAR_QUIET=""

if [ $VERBOSE -gt 0 ]; then
    echo " *** Initializing ... ***"
fi

if [ "X$CVSROOT" = "X" ]; then
    echo "You should have set the CVSROOT env variable."  1>&2
    usageversion; 
    exit 1
fi

# get the package name
rootdir='/usr/local/src/Packages'

# Load site defaults and over rides.
if [ -f /etc/cvsdeb.conf ]; then
    . /etc/cvsdeb.conf
fi

# Load user defaults and over rides.
if [ -f ~/.cvsdeb.conf ]; then
    . ~/.cvsdeb.conf
fi

# If asked to debug on command line, that's what we get
if [ ! "x$opt_DEBUG" = "x" ]; then
    DEBUG="$opt_DEBUG"
fi

if [ "$DEBUG" -gt 0 ]; then
    CVS_QUIET=""
    TAR_QUIET="vv"
fi

# Command line, env variable, config file, or default
if [ ! "x$opt_rootdir" = "x" ]; then
    rootdir="$opt_rootdir"
elif [ ! "x$CVSDEB_ROOTDIR" = "x" ]; then
    rootdir="$CVSDEB_ROOTDIR"
elif [ ! "x$conf_rootdir" = "x" ]; then
    rootdir="$conf_rootdir"
fi

# Command line, env variable, config file, or default
if [ ! "x$opt_workdir" = "x" ]; then
    workdir="$opt_workdir"
elif [ ! "x$CVSDEB_WORKDIR" = "x" ]; then
    workdir="$CVSDEB_WORKDIR"
elif [ ! "x$conf_workdir" = "x" ]; then
    workdir="$conf_workdir"
else
    workdir="$rootdir/$package"
fi

# Command line, env variable, config file, or default
if [ ! "x$opt_prefix" = "x" ]; then
    prefix="$opt_prefix"
elif [ ! "x$CVSDEB_PREFIX" = "x" ]; then
    prefix="$CVSDEB_PREFIX"
elif [ ! "x$conf_prefix" = "x" ]; then
    prefix="$conf_prefix"
else
    prefix=""
fi

# put a slash at the end of the prefix
if [ "X$prefix" != "X" ]; then
    prefix="$prefix/";
    prefix=`echo $prefix | sed 's://:/:g'`;
fi

# Command line, env variable, or default
if [ ! "x$opt_cvsmodule" = "x" ]; then
    cvsmodule="$opt_cvsmodule"
elif [ ! "x$CVSDEB_MODULE" = "x" ]; then
    cvsmodule="$CVSDEB_MODULE"
else
    cvsmodule="${prefix}$package"
fi

# No user defined changes here
pkgdir="$workdir/$package-$upstream_version"
orig_tarfile="$workdir/${package}_${upstream_version}.orig.tar.gz"

if [ ! -r $orig_tarfile ]; then
    echo >&2 "I could not find the expected file $orig_tarfile"
    echo >&2 "I parsed the package name=($package), version=${upstream_version}"
    if [ $debian_version ]; then
	echo >&2 "The debian revision seems to be  $debian_version"
    else
	echo >&2 "This seems to be a debian only package"
    fi
    echo >&2 "The working directory is $workdir"
    echo >&2 ""
    echo >&2 "Since something has gone wrong, I am aborting"
    exit 1
fi

if [ $VERBOSE -gt 0 ]; then
    echo ""
    echo " *** Preparing the working directory *** "
fi
if [ ! -d "$workdir" ]; then
    eval "$action mkdir -p $workdir"
fi
eval "$action cd $workdir"
eval "$action mkdir $tmpdir"
if [ "X$docmd" = "XYES" ]; then
    if [ ! -d "$tmpdir" ]; then
	echo >&2 "The working directory ($workdir) is not writable"
	exit 1
    fi
fi

if [ $VERBOSE -gt 0 ]; then
    echo ""
    echo " *** Unpacking the new sources *** "
fi
eval "$action cd $tmpdir"
eval "$action tar ${TAR_QUIET}zfx ../${package}_${upstream_version}.orig.tar.gz"
if [ "X$docmd" = "XYES" ]; then
    numdirs=`ls -1 | wc -l`
    if [ $numdirs -gt 1 ]; then
	echo >&2 "Source unpacked into ore than one dir"
	eval "cd .."
	eval "rm -rf $tmpdir"
	exit 1;
    fi
    eval "$action cd `ls -1`"
else
    echo "numdirs=\`ls -1 | wc -l\`"
    echo "if [ $numdirs gt 1 ]; then "
    echo "   echo >&2 Source unpacked into ore than one dir"
    echo "   cd ..; rm -rf $tmpdir"
    echo "   exit 1"
    echo "fi"
    echo "cd \`ls -1\`"
fi

# check for symbolic links in the upstream sources
if [ "X$docmd" = "XYES" ]; then
    symbolic_links=$(find . -type l -print)
    if [ "X$symbolic_links" != "X" ]; then
	echo >&2 "The upstream sources contain symbolic links."
	echo >&2 "CVS ignores symblic links, you have to handle link "
	echo >&2 "creation in the modules file (-e and -o args)"
	echo >&2 "Please hit return to continue."
	read ans
    fi
fi

# check for CVS dirs in the upstream sources
if [ "X$docmd" = "XYES" ]; then
    CVS_dirs=$(find . -type d -name CVS -print)
    if [ "X$CVS_dirs" != "X" ]; then
	echo >&2 "The upstream sources contain CVS directories."
	echo >&2 "This I can't handle. Please delete the following"
	echo >&2 "directories and try again."
	echo >&2 "$CVS_dirs"
	cd ..; rm -rf $tmpdir ;
	exit 1;
    fi
fi

if [ $VERBOSE -gt 0 ]; then
    echo ""
    echo " *** Importing the new sources *** "
fi
eval "$action cvs $CVS_QUIET import -ko -m\\\'Initial Import\\\' ${cvsmodule} source-dist ${cvs_upstream_tag}"
eval "$action cd ../.."
eval "$action rm -rf $tmpdir"

echo "                                                                      "
echo "##############  Done automated tasks   ##############                 "
echo "                                                                      "
echo "# If there was no conflict, We can just check out the main            "
echo "# branch. You can simply do the following manually:                   "
echo "                                                                      "
echo "       cvs co ${cvsmodule}                                            "
echo "                                                                      "
echo "# If there were conflicts, however, you would have been given         "
echo "# directives by the import command to do the following checkout       "
echo "# and resolve the conflicts before continuing                         " 
echo "                                                                      "
echo "       cvs co -jsource-dist:yesterday -jsource-dist:today ${cvsmodule}"
echo "                                                                      "
echo "# After that don't forget to commit and tag you newly created         "
echo "# revision as                                                         "
echo "                                                                      "
echo "       cd ${cvsmodule}                                                "
echo "       edit debian/changelog                                          "
echo "       cvs ci -m'New upstream source'                                 "
echo "       cvs $CVS_QUIET tag -F ${cvstag}                                "
echo "       cd ${workdir}                                                  "
echo "       rm -rf ${cvsmodule}                                            "

exit 0