source: npl/rebuildcheck @ a2d969e

perl-5.22
Last change on this file since a2d969e was 0c25615, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

buildnumbers should be updated in rebuildcheck instead of buildrooted. initrd build number was not increased because of this

  • Property mode set to 100755
File size: 5.9 KB
Line 
1#!/bin/bash
2#(C)DatuX 2005 - all rights reserved
3BUILDFILE=$1
4DEPTH=$2
5IGNORE_REGEX='/CVS/|md5$|/\.git|/\.svn|/\.cvs|/docs|~$|\.depver$|\.arch$|\.version$|\.major$|\.check$|\.build$|\.check\.ok$';
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 [ "`git status --porcelain $PKG|grep -v '^?'`" != "" ]; then
193                                echo
194                                echo "################## DIFF of $PKG:"
195                                ./diffpkg $PKG
196                                echo "################## end of DIFF $PKG "
197                        fi
198                done
199
200                msg "Updating build numbers for $BUILDFILE..."
201                pushd $DIR > /dev/null
202                for PKG in *.pkg; do
203                        BUILD_FILE=`echo "$PKG"| sed 's/.pkg$//'`.build
204                        BUILD=`cat $BUILD_FILE 2>/dev/null`
205                        if [ "$BUILD" == "" ]; then
206                                BUILD=1
207                        else
208                                (( BUILD=BUILD+1 ))
209                        fi
210                        echo $BUILD > $BUILD_FILE || exit 1
211                done
212                popd >/dev/null
213
214        else
215                msg "Not building, only updating md5 sums.."
216        fi
217
218
219
220
221        msg "Updating md5 for $BUILDFILE..."
222        #bepaal en bewaar major versies waartegen we gebuild hebben
223        rm $MD5FILE &>/dev/null
224        pushd $DIR >/dev/null
225        find . -type f| sort |
226                #negeer bepaalde files
227                egrep -v $IGNORE_REGEX |
228                while read FILE; do
229                        md5sum "$FILE" >> $MD5FILE
230                done
231        popd > /dev/null
232
233        msg "Updating dependency information for $BUILDFILE..."
234        DEPVERFILE=`echo $BUILDFILE | sed 's/.SlackBuild$//g'`.depver
235        rm "$DEPVERFILE" &>/dev/null
236        for DEP in $DEPS; do
237                if DEPBUILDNAME=`./findbuild "$DEP"`; then
238                        DEPMAJOR=`cat "$DEPBUILDNAME.major" 2>/dev/null`;
239                        if ! [ "$DEPMAJOR" ]; then
240                                DEPMAJOR=0
241                        fi
242                        echo -e "$DEP\t$DEPMAJOR" >> $DEPVERFILE || exit 1
243                fi
244        done
245fi
246
247echo "$BUILDFILE" >> .tmp/builded
248
249if ! [ "$DEPTH" ]; then
250        echo -e "All rebuilds completed.\a"
251fi
252
253#store_dir "$DIR"
254exit 0
Note: See TracBrowser for help on using the repository browser.