+Print duplicates.
[nethome.git] / bin / mockupdate
1 #! /bin/bash
2 set -x
3
4 opts=
5 if [ "$1" = "-v" ];then
6         opts="-v"
7         shift
8 fi
9
10 quick=false
11 if [ "$1" = "-q" ];then
12         quick=true
13         shift
14 fi
15
16 for i in "$@";do
17         if [ "$i" = "${i#/var/lib/mock/}" ];then
18                 echo >&2 "$i not /var/lib/mock/*"
19                 exit 1
20         fi
21         if [ "$i" != "${i#*/root}" ];then
22                 echo >&2 "$i contains /root"
23                 exit 1
24         fi
25         if [ "$i" != "${i%-intel}" ];then
26                 continue
27         fi
28         set +x
29         l=""
30         b=""
31         for p in /proc/*/root;do
32                 l="`readlink $p`"
33                 if [ "${l#$i/}" != "$l" ];then
34                         p="${p#/proc/}"
35                         p="${p%/root}"
36                         b="$b $p"
37                 fi
38         done
39         set -x
40         if [ -n "$b" ];then
41                 echo >&2 "$i has existing processes: $b"
42                 continue
43         fi
44
45         /usr/local/sbin/mocksetup -u `basename $i`
46         rm -f $i/root/var/lib/rpm/__db.*
47         if ! $quick;then
48                 mock $opts -r `basename $i` --update
49                 mock $opts -r `basename $i` --install `cat ~/src/INSTALL`
50         fi
51         # Run: yum groupinstall buildsys-build
52         # Cleaning would undo the changes above.
53         # file /lib/libnssutil3.so conflicts between attempted installs of nss-3.12.3.99.3-10.fc12.i686 and nss-util-3.12.3.99.3-9.fc12.i686
54         # rpmdb: Build signature doesn't match environment
55         # on: fedora-{11,12}-i386
56         #if [ "$i" = "${i#*/fedora-rawhide-}" ];then
57         #       mock $opts -r `basename $i` --no-clean --no-cleanup-after --rebuild /usr/local/share/empty-0.1-1.src.rpm
58         #fi
59         # Just rpmbuild would error with:
60         # error: cannot open Packages index using db3 - Invalid argument (22)
61         rpm -r $i/root --rebuilddb
62         # Leftover usually just removing vital system packages:
63         rm -f $i/root/var/lib/yum/transaction-*
64         # Print duplicates:
65         rpm -r $i/root --qf '%{name}.%{arch}\n' -qa|sort|uniq -d|sed -e '1s/^/ror duplicity:\n/' -e '1s/^/mockupdate er/'
66 done
67
68 echo done mockupdate "$*"