Try CreateProcess even if SHGetFileInfo fails so that we can launch
[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
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`
47
48 if [ $1 != "/dev/null" ]; then
49   cat $1 | ./regFixer.pl > $FIX1_FILE
50 fi
51
52 cat $2 | ./regFixer.pl > $FIX2_FILE
53
54
55 #
56 # diff accordingly depending on /dev/null
57 #
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
63 fi
64
65 #
66 # Keep only added lines
67 #
68 echo "Grepping keys to add and generating cleaned fixed registry file."
69 cat $DIFF_FILE | grep '^> ' | sed -e 's/^> //' > $FILE_TOADD_CLEAN
70
71 #
72 # Restore the file format to the regedit export 'like' format
73 #
74 echo "Restoring key's in the regedit export format..."
75 cat $FILE_TOADD_CLEAN | ./regRestorer.pl > $FILE_TOADD
76
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
81
82 if mv $FILE_TOADD $2.toAdd
83 then
84   FILE_TOADD=$2.toAdd
85 fi
86
87 echo "Operation completed, result file is '$FILE_TOADD'"
88
89 exit 0