Removed some more trailing whitespace.
[wine/multimedia.git] / programs / regapi / regSet.sh
blob89f7d1a2cbe4d034ea53fc43b2f59016e6135f4b
1 #!/bin/bash
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.
8 # Copyright 1999 Sylvain St-Germain
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.
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.
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
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
34 echo "Assuming that $1 is the \"before\" file..."
35 echo "Assuming that $2 is the \"after\" file..."
38 # do not attempt to regFix.pl /dev/null ...
40 echo "Fixing exported registry files..."
42 FIX1_FILE=`mktemp -q /tmp/file1_fix.XXXXXXXXX`
43 FIX2_FILE=`mktemp -q /tmp/file2_fix.XXXXXXXXX`
44 DIFF_FILE=`mktemp -q /tmp/file2_diff.XXXXXXXXX`
45 FILE_TOADD_CLEAN=`mktemp -q /tmp/file_toAdd_clean.XXXXXXXXX`
46 FILE_TOADD=`mktemp -q /tmp/file_toAdd.XXXXXXXXX`
48 if [ $1 != "/dev/null" ]; then
49 cat $1 | ./regFixer.pl > $FIX1_FILE
52 cat $2 | ./regFixer.pl > $FIX2_FILE
56 # diff accordingly depending on /dev/null
58 echo "Diffing..."
59 if [ $1 != "/dev/null" ]; then
60 diff $FIX1_FILE $FIX2_FILE > $DIFF_FILE
61 else
62 diff /dev/null $FIX2_FILE > $DIFF_FILE
66 # Keep only added lines
68 echo "Grepping keys to add and generating cleaned fixed registry file."
69 cat $DIFF_FILE | grep '^> ' | sed -e 's/^> //' > $FILE_TOADD_CLEAN
72 # Restore the file format to the regedit export 'like' format
74 echo "Restoring key's in the regedit export format..."
75 cat $FILE_TOADD_CLEAN | ./regRestorer.pl > $FILE_TOADD
77 echo "Cleaning..."
78 rm $FIX1_FILE $FIX2_FILE >/dev/null 2>&1
79 rm $DIFF_FILE >/dev/null 2>&1
80 rm $FILE_TOADD_CLEAN >/dev/null 2>&1
82 if mv $FILE_TOADD $2.toAdd
83 then
84 FILE_TOADD=$2.toAdd
87 echo "Operation completed, result file is '$FILE_TOADD'"
89 exit 0