Dash:
[t2.git] / misc / archive / compare_builddirs.sh
blobae293290b95db3150406b37bbce4452a7bb6076b
1 #!/bin/sh
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 #
5 # T2 SDE: misc/archive/compare_builddirs.sh
6 # Copyright (C) 2005 The T2 SDE Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 config=default
17 if [ "$1" = -cfg ]; then
18 config="$2"
21 compare_builddirs() {
22 local config="$1" dir0="${2%/}" dir1="${3%/}"
23 local cfgid0="${dir0#build/}" cfgid1="${dir1#build/}"
24 local cfg0= cfg1=
25 echo "compare: $cfgid0 vs. $cfgid1"
27 # config dir
28 if grep -q "^export SDECFG_ID='$cfgid0'" config/$config/config; then
29 cfg0="config/$config"
30 elif [ -f "$dir0/etc/ROCK-CONFIG/packages" ]; then
31 cfg0="$dir0/etc/ROCK-CONFIG"
32 elif [ -f "$dir0/etc/SDE-CONFIG/packages" ]; then
33 cfg0="$dir0/etc/SDE-CONFIG"
34 else
35 echo "Unable to detect '$dir0' config."
37 if grep -q "^export SDECFG_ID='$cfgid1'" config/$config/config; then
38 cfg1="config/$config"
39 elif [ -f "$dir1/etc/ROCK-CONFIG/packages" ]; then
40 cfg1="$dir1/etc/ROCK-CONFIG"
41 elif [ -f "$dir1/etc/SDE-CONFIG/packages" ]; then
42 cfg1="$dir1/etc/SDE-CONFIG"
43 else
44 echo "Unable to detect '$dir1' config."
47 [ -n "$cfg0" -a -n "$cfg1" ] || exit 1
49 # package list
50 #diff -U1 "$cfg0/packages" "$cfg1/packages"
52 # dir0 vs dir1
53 for flist in "$dir0/var/adm/flists/"*; do
54 pkg="${flist#$dir0/var/adm/flists/}"
55 if [ -f "$dir1/var/adm/flists/$pkg" ]; then
56 diff -U1 "$flist" "$dir1/var/adm/flists/$pkg"
57 else
58 echo "missing '$pkg' at '$cfgid1'"
60 done
61 for flist in "$dir1/var/adm/flists/"*; do
62 pkg="${flist#$dir1/var/adm/flists/}"
63 if [ ! -f "$dir0/var/adm/flists/$pkg" ]; then
64 echo "missing '$pkg' at '$cfgid0'"
66 done
69 bd0= bd1=
70 find build/$config-*/ -maxdepth 0 -type d 2> /dev/null | while read -r builddir; do
71 if [ -z "$bd0" ]; then
72 # first builddir
73 bd0="$builddir"
74 elif [ -z "$bd1" ]; then
75 # second builddir
76 bd1="$builddir"
77 else
78 # third or another builddir, rotate
79 bd0="$bd1"
80 bd1="$builddir"
83 if [ -n "$bd0" -a -n "$bd1" ]; then
84 compare_builddirs "$config" "$bd0" "$bd1"
86 done