Bug 479178. Remove some unnecessary refcounting in XUL trees. r+sr=roc
[mozilla-central.git] / config / installcfunc.pl
blob443d723c3b13ac36325eeeb6217df5401817f7db
1 #!perl -w
2 #
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # The Original Code is Mozilla Communicator client code, released
17 # March 31, 1998.
19 # The Initial Developer of the Original Code is
20 # Netscape Communications Corporation.
21 # Portions created by the Initial Developer are Copyright (C) 1998-1999
22 # the Initial Developer. All Rights Reserved.
24 # Contributor(s):
25 # Sean Su <ssu@netscape.com>
27 # Alternatively, the contents of this file may be used under the terms of
28 # either of the GNU General Public License Version 2 or later (the "GPL"),
29 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
41 use Cwd;
42 return(1);
44 sub InstallChrome()
46 # inOsType - type of OS being run under
47 # inType - type of reg file to create (jar or resource)
48 # inTargetPath - path to where the bin\chrome dir
49 ($inOsType, $inType, $inTargetPath) = @_;
50 my($mOutFilenameTmp) = "installed-chrome_tmp.txt";
51 my($mFinalFilename) = "installed-chrome.txt";
53 if($inOsType =~ /win32/i)
55 $gPathDelimiter="\\";
57 elsif($inOsType =~ /mac/i)
59 $gPathDelimiter=":";
61 elsif($inOsType =~ /unix/i)
63 $gPathDelimiter="/";
66 if($inOsType =~ /win32/i)
68 # Convert all '/' to '\\' or else win32 will have problems
69 $inTargetPath =~ s/\//\\/g;
72 # Make sure $inTargetPath exists
73 if(!(-e "$inTargetPath"))
75 return(1);
78 open(fpOutFileTmp, ">$inTargetPath$gPathDelimiter$mOutFilenameTmp") || die "\nCould not open $inTargetPath$gPathDelimiter$mOutFilenameTmp: $!\n";
80 CreateChromeTextFile($inType, $inTargetPath, "locales", "loc");
81 CreateChromeTextFile($inType, $inTargetPath, "packages", "pkg");
82 CreateChromeTextFile($inType, $inTargetPath, "skins", "skn");
84 if(-e "$inTargetPath$gPathDelimiter$mFinalFilename")
86 open(fpInFile, "$inTargetPath$gPathDelimiter$mFinalFilename") || die "\nCould not open $inTargetPath$gPathDelimiter$mFinalFilename: $!\n";
87 while($line = <fpInFile>)
89 print fpOutFileTmp "$line";
92 close(fpInFile);
93 unlink "$inTargetPath$gPathDelimiter$mFinalFilename";
95 close(fpOutFileTmp);
97 if(!rename("$inTargetPath$gPathDelimiter$mOutFilenameTmp", "$inTargetPath$gPathDelimiter$mFinalFilename"))
99 die "\n Error $!: rename (\"$inTargetPath$gPathDelimiter$mOutFilenameTmp\", \"$inTargetPath$gPathDelimiter$mFinalFilename\")\n";
101 return(0);
104 sub CreateChromeTextFile()
106 my($inType, $inTargetPath, $inChromeDir, $inExt) = @_;
108 @dlChromeDir = <$inTargetPath\\$inChromeDir\\*>;
109 foreach $dir (@dlChromeDir)
111 if($inOsType =~ /win32/i)
113 # Convert all '/' to '\\' or else win32 will have problems
114 $dir =~ s/\//\\/g;
117 # Get the leaf dir name from full path
118 if($inOsType =~ /win32/i)
120 @dirItem = split(/\\/, $dir);
122 elsif($inOsType =~ /mac/i)
124 @dirItem = split(/:/, $dir);
126 elsif($inOsType =~ /unix/i)
128 @dirItem = split(/\//, $dir);
130 $dirName = $dirItem[$#dirItem];
132 # Make sure the path is valid
133 if(-d "$dir")
135 if($inType =~ /jar/i)
137 if(CheckDir("content", "$dir"))
139 print fpOutFileTmp "content,install,url,jar:resource:/chrome/$dirName.$inExt!/\n";
141 if(CheckDir("locale", "$dir"))
143 print fpOutFileTmp "locale,install,url,jar:resource:/chrome/$dirName.$inExt!/\n";
145 if(CheckDir("skin", "$dir"))
147 print fpOutFileTmp "skin,install,url,jar:resource:/chrome/$dirName.$inExt!/\n";
150 else
152 if(CheckDir("content", "$dir"))
154 print fpOutFileTmp "content,install,url,resource:/chrome/$inChromeDir/$dirName/\n";
156 if(CheckDir("locale", "$dir"))
158 print fpOutFileTmp "locale,install,url,resource:/chrome/$inChromeDir/$dirName/\n";
160 if(CheckDir("skin", "$dir"))
162 print fpOutFileTmp "skin,install,url,resource:/chrome/$inChromeDir/$dirName/\n";
168 return(0);
171 sub CheckDir()
173 my($dirType, $inPath) = @_;
175 @dlDirType = <$inPath$gPathDelimiter*>;
176 foreach $dir (@dlDirType)
178 if($inOsType =~ /win32/i)
180 # Convert all '/' to '\\' or else win32 will have problems
181 $dir =~ s/\//\\/g;
184 if(-d "$dir$gPathDelimiter$dirType")
186 return(1);
189 return(0);