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
|
#!/bin/bash
# -*- Mode: Sh -*-
# cvs-pkg-upgrade ---
# Author : Marcelo E. Magallon" <mmagallo@efis.ucr.ac.cr>
# Created On : Thu Apr 3 13:34:54 1999
# Created On Node : efis.ucr.ac.cr
# Last Modified By : Manoj Srivastava
# Last Modified On : Mon Nov 12 15:20:33 2001
# Last Machine Used: glaurung.green-gryphon.com
# Update Count : 17
# Status : Unknown, Use with caution!
# HISTORY :
# Description :
#
#
set -eC
files_to_remove=
trap '${verbose} Removing ${files_to_remove} >&2 ; rm -f ${files_to_remove}' \
EXIT SIGHUP SIGINT SIGQUIT SIGTERM
progname="`basename \"$0\"`"
pversion='0.1'
usage () {
cat >&2 <<EOU
Usage:
$progname [options] <package name> <previous version> <current 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.
Sources for both the old and the new versions are expected in the
files
<workdir>/<package name>/<package name>_<version>.orig.tar.gz
and should unpack into a single subdir.
EOU
}
action=
verbose=:
DEBUG=0
while [ $# != 0 ]; do
value="`echo x\"$1\" | sed -e 's/^x-.//'`"
case "$1" in
-h) usage; exit 0 ;;
-M*) opt_cvsmodule="$value" ;;
-R*) opt_rootdir="$value" ;;
-W*) opt_workdir="$value" ;;
-d*) opt_DEBUG="$value" ;;
-n) action=: ; docmd='NO' ;;
-v) verbose=echo; VERBOSE=1 ;;
-x*) opt_prefix="$value" ;;
-*) echo >&2 "Unknown option $1."
usage; exit 1 ;;
*) break ;;
esac
shift
done
if [ $# -ne 3 ]; then
echo >&2 "${progname}: package name, previous version and upstream version required."
usage;
exit 1;
fi
package=$1
pre_version=$2
cur_version=$3
if dpkg --compare-versions $2 lt $3; then
${verbose} Version test passed;
else
echo "Older version $2 greater than newer version $3"
echo "This can break CVS badly. (Of course, you may be using epochs, "
echo "and I am too dumb to grok epochs, in which case ignore my rambling)"
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
# Command line, env variable, config file, or default
if [ ! "x$opt_packageintag" = "x" ]; then
packageintag="$opt_packageintag"
elif [ ! "x$CVSDEB_PACKAGEINTAG" = "x" ]; then
packageintag="$CVSDEB_PACKAGEINTAG"
elif [ ! "x$conf_packageintag" = "x" ]; then
packageintag="$conf_packageintag"
else
packageintag=""
fi
# env variable, or default
if [ ! "x$CVSDEB_IMPORTSUBSTMODE" = "x" ]; then
importsubstmode="$CVSDEB_IMPORTSUBSTMODE"
else
importsubstmode="-ko -d"
fi
# No user defined changes here
pre_src_file="${workdir}/${package}_${pre_version}.orig.tar.gz"
cur_src_file="${workdir}/${package}_${cur_version}.orig.tar.gz"
for file in ${pre_src_file} ${cur_src_file} ; do
if [ ! -f "${file}" ] ; then
echo >&2 "${progname}: ${file} does not exist!"
exit 1
fi
done
build_list() {
# extract the list of files contained in the tarball stripping
# the first directory from the names if the tarball unpacks into
# a single directory and ommitting directories
if [ $(tar tzf $1 | sed -e 's/\/.*$//' | uniq | wc -l) -eq 1 ]; then
sed_command='sed -n -e s:^\./:: -e s:^[^/]*/:: -e /\(^\|\/\)$/!p'
else
sed_command='sed -n -e /\(^\|\/\)$/!p'
fi
tar tzf $1 | $sed_command | sort
}
update_cvs() {
diff -u $1 $2 | # diffs both listings
tail -n 3 | # removes the diff header
grep '^[-+]' | # trims unchanged stuff
sed -e 's:^+:cvs add :' -e 's:^-:cvs delete -fR :' #| sh -s
}
pre_src_list=$(basename ${pre_src_file} .tar.gz).list.$$
files_to_remove="${files_to_remove} ${pre_src_list}"
${verbose} build_list ${pre_src_file} \> ${pre_src_list} >&2
${action} build_list ${pre_src_file} > ${pre_src_list}
cur_src_list=$(basename ${cur_src_file} .tar.gz).list.$$
files_to_remove="${files_to_remove} ${cur_src_list}"
${verbose} build_list ${cur_src_file} \> ${cur_src_list} >&2
${action} build_list ${cur_src_file} > ${cur_src_list}
update_cvs ${pre_src_list} ${cur_src_list}
exit 0
|