chiark / gitweb /
pass any other options to rosetta-merge, as well as --apply
[bin.git] / dinstall-private
1 #! /bin/sh
2 # The name is a deliberate echo of the "real" Debian dinstall; it moves
3 # packages into /usr/src/debian, removes any old versions of those packages
4 # 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
15 echo -n "Dinstalling package $PACKAGE, "
16 echo -n "version $VERSION, "
17 echo    "upstream version $UPSTREAM"
18
19 ARCH=i386
20 DEB=$PWD/${PACKAGE}_${VERSION}_${ARCH}.deb
21 ORIG=$PWD/${PACKAGE}_$UPSTREAM.orig.tar.gz
22 DIFF=$PWD/${PACKAGE}_${VERSION}.diff.gz
23 DSC=$PWD/${PACKAGE}_${VERSION}.dsc
24 CHANGES=$PWD/${PACKAGE}_${VERSION}_${ARCH}.changes
25
26 # Sanity checks
27
28 ERROR=
29 if [ ! -f $DEB     ]; then echo $DEB     'not found' >&2; ERROR=1; fi
30 if [ ! -f $ORIG    ]; then echo $ORIG    'not found' >&2; ERROR=1; fi
31 if [ ! -f $DIFF    ]; then echo $DIFF    'not found' >&2; ERROR=1; fi
32 if [ ! -f $DSC     ]; then echo $DSC     'not found' >&2; ERROR=1; fi
33 if [ ! -f $CHANGES ]; then echo $CHANGES 'not found' >&2; ERROR=1; fi
34 [ "$ERROR" ] && exit 1
35
36 SECTION=`dpkg -f $DEB Section`
37 if [ "$SECTION" ]; then
38         echo "Section: $SECTION"
39 else
40         echo "Section not found." >&2
41         exit 1
42 fi
43
44 if echo $SECTION | egrep -q '^(contrib|non-free)/'; then
45         BINARYDIR=`echo $SECTION | sed -e "s|/|/binary-$ARCH/|"`
46         SOURCEDIR=`echo $SECTION | sed -e "s|/|/source/|"`
47 elif echo $SECTION | egrep -q '^non-US/'; then
48         BINARYDIR=$SECTION/binary-$ARCH
49         SOURCEDIR=$SECTION/source
50 else
51         BINARYDIR=main/binary-$ARCH/$SECTION
52         SOURCEDIR=main/source/$SECTION
53 fi
54
55 echo "Binaries in $BINARYDIR, sources in $SOURCEDIR"
56
57 cd /usr/src/debian/dists/unstable
58
59 ERROR=
60 if [ ! -d $BINARYDIR ]; then echo 'Binary dir not found.' >&2; ERROR=1; fi
61 if [ ! -d $SOURCEDIR ]; then echo 'Source dir not found.' >&2; ERROR=1; fi
62 [ "$ERROR" ] && exit 1
63
64 shopt -s nullglob
65
66 BINARIES=`echo $BINARYDIR/${PACKAGE}_*`
67 if [ "$BINARIES" ]; then
68         echo 'Binaries found in binary dir:'
69         echo $BINARIES | xargs -n1
70         read -n1 -esp 'Remove: (y/N) ' REMOVE
71         if [ "$REMOVE" == y ]; then
72                 echo -n 'Removing ... '
73                 echo $BINARIES | xargs rm
74                 echo 'done.'
75         else
76                 echo 'Aborting.'
77                 exit
78         fi
79 fi
80
81 SOURCES=`echo $SOURCEDIR/${PACKAGE}_*`
82 if [ "$SOURCES" ]; then
83         echo 'Sources found in source dir:'
84         echo $SOURCES | xargs -n1
85         read -n1 -esp 'Remove: (y/N) ' REMOVE
86         if [ "$REMOVE" == y ]; then
87                 echo -n 'Removing ... '
88                 echo $SOURCES | xargs rm
89                 echo 'done.'
90         else
91                 echo 'Aborting.'
92                 exit
93         fi
94 fi
95
96 echo "Moving $DEB to $BINARYDIR ..."
97 mv -f $DEB $BINARYDIR
98 echo "Copying $ORIG to $SOURCEDIR ..."
99 cp -f $ORIG $SOURCEDIR
100 echo "Copying $DIFF to $SOURCEDIR ..."
101 cp -f $DIFF $SOURCEDIR
102 echo "Moving $DSC to $SOURCEDIR ..."
103 mv -f $DSC $SOURCEDIR
104 echo "Moving $CHANGES to $SOURCEDIR ..."
105 mv -f $CHANGES $SOURCEDIR
106
107 echo
108
109 cd ../..
110
111 dpkg-myscan packages
112
113 echo
114
115 dpkg-myscan sources
116
117 echo
118
119 echo "Dinstallation of $PACKAGE-$VERSION complete."
120