2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is the Mozilla Mac OS X Universal Binary Packaging System
17 # The Initial Developer of the Original Code is Google Inc.
18 # Portions created by the Initial Developer are Copyright (C) 2006
19 # the Initial Developer. All Rights Reserved.
22 # Mark Mentovai <mark@moxienet.com> (Original Author)
24 # Alternatively, the contents of this file may be used under the terms of
25 # either the GNU General Public License Version 2 or later (the "GPL"), or
26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 # in which case the provisions of the GPL or the LGPL are applicable instead
28 # of those above. If you wish to allow use of your version of this file only
29 # under the terms of either the GPL or the LGPL, and not to allow others to
30 # use your version of this file under the terms of the MPL, indicate your
31 # decision by deleting the provisions above and replace them with the notice
32 # and other provisions required by the GPL or the LGPL. If you do not delete
33 # the provisions above, a recipient may use your version of this file under
34 # the terms of any one of the MPL, the GPL or the LGPL.
36 # ***** END LICENSE BLOCK *****
41 use Archive
::Zip
(':ERROR_CODES');
45 sub fixBuildconfig
($$);
47 $BUILDCONFIG = 'content/global/buildconfig.html';
49 if (scalar(@ARGV) != 2) {
50 print STDERR
("usage: fix-buildconfig <zipfile1> <zipfile2>\n");
54 if (!fixBuildconfig
($ARGV[0], $ARGV[1])) {
60 sub fixBuildconfig
($$) {
61 my ($zipPath1, $zipPath2);
62 ($zipPath1, $zipPath2) = @_;
64 my ($ze, $zip1, $zip2);
66 $zip1 = Archive
::Zip
->new();
67 if (($ze = $zip1->read($zipPath1)) != AZ_OK
) {
68 print STDERR
($0.': could not read "'.$zipPath1.'": error '.$ze."\n");
71 $zip2 = Archive
::Zip
->new();
72 if (($ze = $zip2->read($zipPath2)) != AZ_OK
) {
73 print STDERR
($0.': could not read "'.$zipPath2.'": error '.$ze."\n");
77 my ($contents1, $contents2);
78 if (!defined($contents1 = $zip1->contents($BUILDCONFIG))) {
79 print STDERR
($0.': could not get "'.$BUILDCONFIG.'" from "'.$zipPath1.'"'.
83 if (!defined($contents2 = $zip2->contents($BUILDCONFIG))) {
84 print STDERR
($0.': could not get "'.$BUILDCONFIG.'" from "'.$zipPath2.'"'.
89 my (@lines1, @lines2);
90 @lines1 = split(/\n/, $contents1);
91 @lines2 = split(/\n/, $contents2);
93 my ($line, @linesNew);
96 # Copy everything from the first file up to the end of its <body>.
97 while ($line = shift(@lines1)) {
98 if ($line eq '</body>') {
101 push(@linesNew, $line);
104 # Insert a <hr> between the two files.
105 push (@linesNew, '<hr> </hr>');
107 # Copy the second file's content beginning after its leading <h1> and <p>.
108 while ($line = shift(@lines2)) {
109 if ($line eq '<p> </p>') {
113 while ($line = shift(@lines2)) {
114 push(@linesNew, $line);
118 $contentsNew = join("\n", @linesNew);
120 if (!defined($zip1->contents($BUILDCONFIG, $contentsNew))) {
121 print STDERR
($0.': could not set "'.$BUILDCONFIG.'" to "'.$zipPath1.'"'.
125 if (!defined($zip2->contents($BUILDCONFIG, $contentsNew))) {
126 print STDERR
($0.': could not set "'.$BUILDCONFIG.'" to "'.$zipPath2.'"'.
132 if (($ze = $zip1->overwrite()) != AZ_OK
) {
133 print STDERR
($0.': could not write "'.$zipPath1.'": error '.$ze."\n");
136 if (($ze = $zip2->overwrite()) != AZ_OK
) {
137 print STDERR
($0.': could not write "'.$zipPath2.'": error '.$ze."\n");