chiark / gitweb /
Remove yet more obsolete programs.
[bin.git] / dinstall-riva
1 #! /bin/sh
2 # The name is a deliberate echo of the "real" Debian dinstall; it moves
3 # packages into http://riva.ucam.org/~cjw44/debian/, removes any old versions
4 # of those packages there, and re-runs dpkg-myscan {packages,sources}.
5
6 if [ $# -lt 2 ]; then
7         echo "Usage: $0 package-name version-number" >&2
8         exit 1
9 fi
10
11 PACKAGE=$1
12 VERSION=$2
13 UPSTREAM=`echo $VERSION | sed -e 's/-[^-]*$//'`
14 NATIVE=
15 if [ "$VERSION" = "$UPSTREAM" ]; then
16     NATIVE=y
17 fi
18
19 echo -n "Dinstalling package $PACKAGE, "
20 echo -n "version $VERSION, "
21 echo    "upstream version $UPSTREAM"
22 [ "$NATIVE" ] && echo "Native Debian package"
23
24 ARCH=i386
25 BINARCH=i386
26 DEB=$PWD/${PACKAGE}_${VERSION}_${BINARCH}.deb
27 if [ ! -f $DEB ]; then
28     BINARCH=all
29     ALLDEB=$PWD/${PACKAGE}_${VERSION}_${BINARCH}.deb
30 else
31     ALLDEB=$DEB
32 fi
33 if [ "$NATIVE" ]; then
34     ORIG=$PWD/${PACKAGE}_${VERSION}.tar.gz
35     DIFF=
36 else
37     ORIG=$PWD/${PACKAGE}_${UPSTREAM}.orig.tar.gz
38     DIFF=$PWD/${PACKAGE}_${VERSION}.diff.gz
39 fi
40 DSC=$PWD/${PACKAGE}_${VERSION}.dsc
41 CHANGES=$PWD/${PACKAGE}_${VERSION}_${ARCH}.changes
42
43 # Sanity checks
44
45 ERROR=
46 if [ ! -f $DEB -a ! -f $ALLDEB ]; then
47     echo $DEB 'not found' >&2
48     [ $BINARCH = all ] && echo $ALLDEB 'not found' >&2
49     ERROR=1
50 fi
51 DEB=$ALLDEB
52 if [ ! -f $ORIG    ]; then echo $ORIG    'not found' >&2; ERROR=1; fi
53 if [ "$DIFF" -a ! -f "$DIFF" ]; then
54     echo $DIFF 'not found' >&2
55     ERROR=1
56 fi
57 if [ ! -f $DSC     ]; then echo $DSC     'not found' >&2; ERROR=1; fi
58 if [ ! -f $CHANGES ]; then echo $CHANGES 'not found' >&2; ERROR=1; fi
59 [ "$ERROR" ] && exit 1
60
61 SECTION=`dpkg -f $DEB Section`
62 if [ "$SECTION" ]; then
63     echo "Section: $SECTION"
64 else
65     echo "Section not found." >&2
66     exit 1
67 fi
68
69 if echo $SECTION | egrep -q '^(contrib|non-free)/'; then
70     BINARYDIR=`echo $SECTION | sed -e "s|/|/binary-$BINARCH/|"`
71     SOURCEDIR=`echo $SECTION | sed -e "s|/|/source/|"`
72 elif echo $SECTION | egrep -q '^non-US/'; then
73     BINARYDIR=$SECTION/binary-$BINARCH
74     SOURCEDIR=$SECTION/source
75 else
76     BINARYDIR=main/binary-$BINARCH/$SECTION
77     SOURCEDIR=main/source/$SECTION
78 fi
79
80 echo "Binaries in $BINARYDIR, sources in $SOURCEDIR"
81
82 cd /home/httpd/users/$USER/debian
83
84 ERROR=
85 if [ ! -d $BINARYDIR ]; then echo 'Binary dir not found.' >&2; ERROR=1; fi
86 if [ ! -d $SOURCEDIR ]; then echo 'Source dir not found.' >&2; ERROR=1; fi
87 [ "$ERROR" ] && exit 1
88
89 shopt -s nullglob
90
91 BINARIES=`echo $BINARYDIR/${PACKAGE}_*`
92 if [ "$BINARIES" ]; then
93     echo 'Binaries found in binary dir:'
94     echo $BINARIES | xargs -n1
95     read -n1 -esp 'Remove: (y/N) ' REMOVE
96     if [ "$REMOVE" = y ]; then
97         echo -n 'Removing ... '
98         echo $BINARIES | xargs rm
99         echo 'done.'
100     else
101         echo 'Aborting.'
102         exit
103     fi
104 fi
105
106 SOURCES=`echo $SOURCEDIR/${PACKAGE}_*`
107 if [ "$SOURCES" ]; then
108     echo 'Sources found in source dir:'
109     echo $SOURCES | xargs -n1
110     read -n1 -esp 'Remove: (y/N) ' REMOVE
111     if [ "$REMOVE" = y ]; then
112         echo -n 'Removing ... '
113         echo $SOURCES | xargs rm
114         echo 'done.'
115     else
116         echo 'Aborting.'
117         exit
118     fi
119 fi
120
121 echo "Moving $DEB to $BINARYDIR ..."
122 mv -f $DEB $BINARYDIR
123 echo "Copying $ORIG to $SOURCEDIR ..."
124 cp -f $ORIG $SOURCEDIR
125 if [ "$DIFF" ]; then
126     echo "Copying $DIFF to $SOURCEDIR ..."
127     cp -f $DIFF $SOURCEDIR
128 fi
129 echo "Moving $DSC to $SOURCEDIR ..."
130 mv -f $DSC $SOURCEDIR
131 echo "Moving $CHANGES to $SOURCEDIR ..."
132 mv -f $CHANGES $SOURCEDIR
133
134 echo
135
136 dpkg-myscan packages
137
138 echo
139
140 dpkg-myscan sources
141
142 echo
143
144 echo -n 'Updating index.html ...'
145 if [ "$NATIVE" ]; then
146     perl -pi -l \
147         -e 's/('$PACKAGE'_).*?(_|\.dsc)/${1}'$VERSION'$2/;' \
148         -e 's/('$PACKAGE'_).*?(\.tar\.gz)/${1}'$VERSION'$2/;' index.html
149 else
150     perl -pi -l \
151         -e 's/('$PACKAGE'_).*?(_|\.diff\.gz|\.dsc)/${1}'$VERSION'$2/;' \
152         -e 's/('$PACKAGE'_).*?(\.orig\.tar\.gz)/${1}'$UPSTREAM'$2/;' index.html
153 fi
154 echo ' done.'
155
156 echo "Dinstallation of $PACKAGE-$VERSION complete."
157