auto commit
[opensuse:package-lists.git] / rebuildpacs.sh
1 set -e
2 export LC_ALL=C
3
4 . ./options
5 ret=0
6 project=openSUSE:$proj
7 repo=standard
8 arch=x86_64
9 dir=rebuilds.$tree
10 mdeps=/tmp/missingdeps
11
12 if test "$1" = "ppc"; then
13   project="openSUSE:Factory:PowerPC"
14   arch="ppc"
15   dir=rebuildsppc
16   mdeps=/tmp/missingdeps_ppc
17 fi
18  
19 if test "$1" = "arm"; then
20   project="openSUSE:Factory:ARM"
21   arch="armv7l"
22   dir=rebuildsarm
23   mdeps=/tmp/missingdeps_arm
24 fi
25
26 if test "$1" = "factory"; then
27   project="openSUSE:Factory"
28   arch="x86_64"
29   dir=rebuilds.obs
30   mdeps=/tmp/missingdeps_factory
31 fi
32
33 function maptosource {
34  egrep 'package|subpkg|source' /tmp/builddep  | fgrep -B50 "<subpkg>$1</subpkg>" | fgrep '<source>'| tail -n 1 | sed -e 's, *<[/s]*ource>,,g'
35 }
36
37 function rebuildpacs {
38  api="/build/$project/_result?repository=$repo"
39  for i in $@; do 
40   value="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$i")"
41   api="$api&package=$value"
42  done
43  tpackages=`osc api $api | grep 'code="succeeded"' | sed -e 's,.*package=",,; s,".*,,' | sort -u`
44  api=
45  for i in $tpackages; do 
46   if test -f "$dir/$i"; then
47     echo "skipping to rebuild $i"
48     continue
49   fi
50   echo "rebuilding $i"
51   value="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$i")"
52   api="$api&package=$value"
53   touch "$dir/$i"
54  done
55  if test -n "$api"; then
56    #echo "$api"
57    ret=1
58    osc api -m POST "/build/$project?cmd=rebuild&repository=$repo$api"
59  fi
60 }
61
62 osc api /build/$project/$repo/$arch/_builddepinfo > /tmp/builddep
63
64 : > /tmp/torebuild
65 touch $dir/package-lists-openSUSE
66 for package in installation-images-openSUSE rpmlint rpmlint-mini bundle-lang-common bundle-lang-kde bundle-lang-gnome glib2-branding-openSUSE PackageKit-branding-openSUSE kiwi-config-openSUSE xfce4-branding-openSUSE kdebase4-openSUSE branding-openSUSE kde-branding-openSUSE; do
67   osc buildinfo $project $package $repo $arch | grep 'bdep name' | grep -v rpmlint | grep -v wallpaper-branding > $dir/$package.new || true
68   if diff -u $dir/$package.old $dir/$package.new | grep '^[+-]'; then
69     echo $package >> /tmp/torebuild
70     rm -f $dir/$package
71   fi
72 done
73 find $dir -cmin +1500 -print | fgrep -va .old | xargs --no-run-if-empty rm -v || true
74
75 missingdeps=`sed -e 's,.*needed by ,,' $mdeps | sort -u`
76 for i in $missingdeps; do
77   maptosource $i >> /tmp/torebuild
78 done
79 sort -o /tmp/torebuild -u /tmp/torebuild
80
81 newfiles=`ls -1 $dir/*.new 2> /dev/null`
82 for i in $newfiles; do
83   mv -vf $i ${i/.new/.old}
84 done
85
86 if test -s /tmp/torebuild; then
87   split -l 50 /tmp/torebuild rebuilds_
88   for file in rebuilds_*; do
89     rebuildpacs `cat $file`
90     rm -f $file
91   done
92 fi
93
94 exit $ret