blob: a4e26ae98b31278afdd7bffe294aaad5c7d394cb [file] [log] [blame]
Sylvain St.Germain1bb0e661999-03-14 14:00:22 +00001#!/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
11if [ $# -ne 2 ]; then
12 echo "$0 Usage: "
13 echo " You must provide 2 arguments."
14 echo " 1 - Registry output before the application's installation."
15 echo " 2 - Registry output after the application's installation."
16 echo
17 exit 1
18fi
19
20echo "Assuming that $1 is the \"before\" file..."
21echo "Assuming that $2 is the \"after\" file..."
22
23#
24# do not attempt to regFix.pl /dev/null ...
25#
26echo "Fixing exported registry files..."
27if [ $1 != "/dev/null" ]; then
28 cat $1 | ./regFixer.pl > $1.fix
29fi
30
31cat $2 | ./regFixer.pl > $2.fix
32
33#
34# diff accordingly depending on /dev/null
35#
36echo "Diffing..."
37if [ $1 != "/dev/null" ]; then
38 diff $1.fix $2.fix > $2.diff
39else
40 diff /dev/null $2.fix > $2.diff
41fi
42#
43# Keep only added lines
44#
45echo "Grepping keys to add and generating cleaned fixed registry file."
46cat $2.diff | grep '^> ' | sed -e 's/^> //' > $2.toAdd
47
48#
49# Restore the file format to the regedit export 'like' format
50#
51echo "Restoring key's in the regedit export format..."
52cat $2.toAdd | ./regRestorer.pl > $2.toAdd.final
53
54echo "Cleaning..."
55rm $1.fix $2.fix >/dev/null 2>&1
56rm $2.diff >/dev/null 2>&1
57rm $2.toAdd >/dev/null 2>&1
58mv $2.toAdd.final $2.toAdd
59
60echo "Operation completed, result file is $2.toAdd"
61
62exit 0