Added LGPL standard comment, and copyright notices where necessary.
[wine] / programs / regapi / regSet.sh
1 #!/bin/bash
2
3 # This script is the receipe to generate the key that have to be created like 
4 # if an applicaiton was installed by its installer.  It processes using a 
5 # registry based on the picture of the registry before the application is 
6 # installed and the picture of the registry after the application is installed.
7 #
8 # Copyright 1999 Sylvain St-Germain
9 #
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2.1 of the License, or (at your option) any later version.
14 #
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 # Lesser General Public License for more details.
19 #
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with this library; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 #
24
25 if [ $# -ne 2 ]; then
26   echo "$0 Usage: "
27   echo "  You must provide 2 arguments."
28   echo "  1 - Registry output before the application's installation."
29   echo "  2 - Registry output after the application's installation."
30   echo 
31   exit 1
32 fi
33
34 echo "Assuming that $1 is the \"before\" file..."
35 echo "Assuming that $2 is the \"after\" file..."
36
37 #
38 # do not attempt to regFix.pl /dev/null ...
39 #
40 echo "Fixing exported registry files..."
41 if [ $1 != "/dev/null" ]; then  
42   cat $1 | ./regFixer.pl > $1.fix
43 fi
44
45 cat $2 | ./regFixer.pl > $2.fix
46
47 #
48 # diff accordingly depending on /dev/null
49 #
50 echo "Diffing..."
51 if [ $1 != "/dev/null" ]; then  
52   diff $1.fix $2.fix > $2.diff
53 else
54   diff /dev/null $2.fix > $2.diff
55 fi
56
57 #
58 # Keep only added lines
59
60 echo "Grepping keys to add and generating cleaned fixed registry file."
61 cat $2.diff | grep '^> ' | sed -e 's/^> //' > $2.toAdd.clean
62
63
64 # Restore the file format to the regedit export 'like' format
65 #
66 echo "Restoring key's in the regedit export format..."
67 cat $2.toAdd.clean | ./regRestorer.pl > $2.toAdd
68
69 echo "Cleaning..."
70 rm $1.fix $2.fix    >/dev/null 2>&1
71 rm $2.diff          >/dev/null 2>&1
72 rm $2.toAdd.clean   >/dev/null 2>&1
73
74 echo "Operation completed, result file is $2.toAdd"
75
76 exit 0