source: npl/rebuildcheck @ 72a275e

gcc484ntopperl-5.22
Last change on this file since 72a275e was 72a275e, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

fix

  • Property mode set to 100755
File size: 5.6 KB
RevLine 
[c5c522c]1#!/bin/bash
2#(C)DatuX 2005 - all rights reserved
3BUILDFILE=$1
4DEPTH=$2
[72a275e]5IGNORE_REGEX='/CVS/|md5$|/\.git|/\.svn|/\.cvs|/docs|~$|\.depver$|\.arch$|\.version$|\.major$|\.check$|\.build$|\.check\.ok$';
[c5c522c]6if [ ! "`id -u`" = "0" ]; then
7echo "root priviliges required. Quiting...";
8exit 1;
9fi
10
11shift
12shift
13for PAR in $*; do eval "$PAR=1" &>/dev/null; done
14
15if ! [ "$BUILDFILE" ]; then
16        echo "Usage:"
17        echo " $0 </path/to/package.SlackBuild>"
18        echo " $0 <packagename>"
19        echo "To ignore changes to the package:"
20        echo " $0 <packagename> '' ignoremd5"
21        echo "To regenerate md5 sum of a package, without rebuilding:"
22        echo " $0 <packagename> '' regenmd5"
23        echo "To force rebuilding of a package that doesnt need it:"
24        echo " $0 <packagename> '' force"
25        exit 1
26fi
27
28
29msg()
30{
31        echo "$DEPTH$*"
32}
33
34#buildfile meegeven?
35if ! [ -f "$BUILDFILE" ]; then
36        #pkgname in plaats van rechstreekse buildfile meegegeven?
37        BUILDFILE=`./findbuild $BUILDFILE`.SlackBuild
38        if ! [ -f "$BUILDFILE" ]; then
39                msg "ERROR: $BUILDFILE not found. (specify the syn-3 pkgname or path to .SlackBuild file)"
40                exit 1
41        fi
42fi
43
44#kijk of een directory veranderd is.
45#(dit is puur om rebuild check sneller te maken en md5 checks te skippen)
46dir_changed()
47{
48        DIR=$1
49        MD5=`ls -lR "$DIR"|md5sum`
50        ! grep -x "$MD5" "$DIR/.signature" &>/dev/null
51}
52
53#bewaar signature
54store_dir()
55{
56        DIR=$1
57        ls -lR "$DIR"|md5sum > "$DIR/.signature"
58}
59
60
61# bepaald absoluut path
62DIRNAME=`dirname $BUILDFILE`
63BASENAME=`basename $BUILDFILE`
64pushd $DIRNAME >/dev/null || exit 1
65BUILDFILE="`pwd`/$BASENAME"
66popd >/dev/null
67
68if [ "$fast" ] && grep -x $BUILDFILE .tmp/builded &>/dev/null; then
69        exit 0
70fi
71
72
73DEPS=`cat "$BUILDFILE" |grep '^#DEP:'|cut -f2 -d':'`
74
75
76#### controleer of MD5 van al onze files nog kloppen
77#-negeer cvs dirs, md5sums en hidden files, backup files
78#-negeer ook andere arch en version files!
79DIR=`dirname $BUILDFILE`
80MD5FILE=`echo $BUILDFILE|sed 's/.SlackBuild$//g'`.md5
81if ! [ "$ignoremd5" ]; then
82        pushd "$DIR" >/dev/null || exit 1
83        find . -type f |
84                #negeer bepaalde files
85                egrep -v $IGNORE_REGEX |
86                while read FILE; do
87                        MD5=`md5sum "$FILE"`
88                        #md5 sum gewijzigd of ontbreekt?
89                        if ! grep "$MD5" "$MD5FILE" &>/dev/null; then
90                                msg "Rebuild required: $FILE has changed!"
91                                exit 2 #exit 2, rebuild dus
92                        fi
93                done
94        RET=$?
95        popd >/dev/null
96       
97        if [ "$RET" == "2" ]; then
98                REBUILD=1
99        elif [ "$RET" != "0" ]; then
100                msg "ERROR!"
101                exit 1
102        fi
103fi
104
105#### controleer of er DEPS zijn die een ANDER major nummer hebben, waardoor we opnieuw moeten compilen
106DEPVERFILE=`echo $BUILDFILE|sed 's/.SlackBuild$//g'`.depver
107DEPERROR=0
108for DEP in $DEPS; do
109        if DEPBUILDNAME=`./findbuild "$DEP"`; then
110                DEPMAJOR=`cat "$DEPBUILDNAME.major" 2>/dev/null`
111                if ! [ "$DEPMAJOR" ]; then
112                        DEPMAJOR=0
113                fi
114
115                MAJOR=`cat $DEPVERFILE 2>/dev/null |grep "^$DEP[[:space:]]"| cut -f2|head -1`
116                if ! [ "$MAJOR" ]; then
117                        MAJOR=0
118                        #FIXME: should be -1, but the requires a rebuild of a lot of old packages
119                fi
120#               echo "$DEP is '$DEPMAJOR' en '$MAJOR'"
121                if [ "$DEPMAJOR" -ne "$MAJOR" ]; then
122                        msg "Rebuild required: $DEP major is now $DEPMAJOR, but this package was build was against $MAJOR."
123                        DEPERROR=1
124                fi
125        fi
126done
127
128
129#if we need to rebuild because of a DEPERROR, check our direct dependencys first so that we rebuild the
130#"deepest" stuff first.
131if ! [ "$ignoredep" ] && [ "$DEPERROR" == "1" ]; then
132        for DEP in $DEPS; do
133                #zoek de buildbase op, als deze er al is
134                if BUILDBASE=`./findbuild "$DEP"` 2>/dev/null; then
135                        msg "Dependency check $DEP"
136                        #note: niet de parameters meegeven, anders gaat hij alles rebuilden bij een force
137                        ./rebuildcheck "$BUILDBASE.SlackBuild" "|-$DEPTH"  || exit 1
138                fi
139        done
140fi
141
142if [ "$DEPERROR" == "1" ]; then
143        REBUILD=1
144fi
145
146
147
148if [ "$REBUILD" == "1" ] && [ "$nobuild" == "1" ]; then
149        msg "Need to rebuild $BUILDFILE"
150        msg "(no building because you specified nobuild)"
151        REBUILD=
152fi
153
154
155
156if [ "$force" == "1" ]; then
157        REBUILD=1
158fi
159
160fatal(){
161        echo -e "Error while rebuilding $BUILDFILE!\a";
162        exit 1;
163}
164
165#### rebuild nodig?
166if [ "$REBUILD" == "1" ]; then
167        if [ ! "$regenmd5" ] ; then
168                msg "REBUILDING $BUILDFILE:"
169                if grep '#NOBUILDROOT' "$BUILDFILE" >/dev/null; then
170                        msg "Building package without buildroot!"
171                        (
172                                cd `dirname $BUILDFILE` || exit 1
173                                $BUILDFILE $* || exit 1
174                        ) || fatal
175                else
176                        (
177                                cd ../builder
178                                ./runrooted "$BUILDFILE" $*
179                        ) || fatal
180                fi
181
182                #show all packages contents:
183                for PKG in `dirname $BUILDFILE`/*.pkg; do
184                        echo
185                        echo "################## Contents of $PKG:"
186                        tar -tvzf $PKG || fatal
187                        echo "################## end of $PKG "
188                done
189
190                #show all diffs:
191                for PKG in `dirname $BUILDFILE`/*.pkg; do
192                        if svn info "$PKG" &>/dev/null; then
193                                echo
194                                echo "################## DIFF of $PKG:"
195                                ./diffpkg $PKG
196                                echo "################## end of DIFF $PKG "
197                        fi
198                done
199        else
200                msg "Not building, only updating md5 sums.."
201        fi
202       
203        msg "Updating md5 for $BUILDFILE..."
204        #bepaal en bewaar major versies waartegen we gebuild hebben
205        rm $MD5FILE &>/dev/null
206        pushd $DIR >/dev/null
207        find . -type f| sort |
208                #negeer bepaalde files
209                egrep -v $IGNORE_REGEX |
210                while read FILE; do
211                        md5sum "$FILE" >> $MD5FILE
212                done
213        popd > /dev/null
214               
215        msg "Updating dependency information for $BUILDFILE..."
216        DEPVERFILE=`echo $BUILDFILE | sed 's/.SlackBuild$//g'`.depver
217        rm "$DEPVERFILE" &>/dev/null
218        for DEP in $DEPS; do
219                if DEPBUILDNAME=`./findbuild "$DEP"`; then
220                        DEPMAJOR=`cat "$DEPBUILDNAME.major" 2>/dev/null`;
221                        if ! [ "$DEPMAJOR" ]; then
222                                DEPMAJOR=0
223                        fi
224                        echo -e "$DEP\t$DEPMAJOR" >> $DEPVERFILE || exit 1
225                fi
226        done
227fi
228
229echo "$BUILDFILE" >> .tmp/builded
230
231if ! [ "$DEPTH" ]; then
232        echo -e "All rebuilds completed.\a"
233fi
234
235#store_dir "$DIR"
236exit 0
237
238
Note: See TracBrowser for help on using the repository browser.