Updates docs for SR1 with final revision
[genesis.git] / fuel / build / patch-packages / tools / correct_deps
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12
13 patch_package () {
14     deb=$1
15     pkgdep=$2
16     newrev=$3
17
18
19     tmpdir=`mktemp -d /tmp/patchXXXXX`
20
21     cp $deb $tmpdir
22     pushd $tmpdir > /dev/null
23
24     mkdir -p repack
25     dpkg -x $deb repack
26
27     mkdir -p repack/DEBIAN
28     dpkg -e $deb repack/DEBIAN
29
30
31     pushd repack/DEBIAN > /dev/null
32
33     echo "Before: `cat control | grep '^Depends:'`"
34     sed -i "s/$pkgdep (\([^ ]*\) [^)]*)/$pkgdep (\1 $newrev)/"  control
35     echo "After: `cat control | grep '^Depends:'`"
36     popd > /dev/null
37
38     fakeroot dpkg-deb --build repack
39
40     popd > /dev/null
41
42     cp $tmpdir/repack.deb $deb
43     rm -Rf $tmpdir
44 }
45
46 # Name of package for which to check dependencies to
47 PKGDEP=$1
48 # The old revision of the package in question
49 OLDREV=$2
50 # The new revision of the package in question
51 NEWREV=$3
52
53 if [ -z "$PKGDEP" ]; then
54     echo "No package dependency name"
55     exit 1
56 fi
57
58 if [ -z "$OLDREV" ]; then
59     echo "No old rev"
60     exit 1
61 fi
62
63 if [ -z "$NEWREV" ]; then
64     echo "No new rev"
65     exit 1
66 fi
67
68
69 for deb in *.deb
70 do
71     ar p $deb control.tar.gz | tar xzO ./control | grep -q "^Depends:.* ${PKGDEP} ([^ ]* ${OLDREV})"
72     if [ $? -eq 0 ]; then
73         name=`ar p $deb control.tar.gz | tar xzO ./control | grep "^Package:.* " | sed 's/.* //'`
74         echo "**** Changing dependencies line in $deb ($name) ****"
75         patch_package $deb $PKGDEP $NEWREV
76     fi
77 done
78