2000-10-18 21:15:17 +04:00
|
|
|
#
|
2004-04-18 18:21:17 +04:00
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2000-10-18 21:15:17 +04:00
|
|
|
#
|
2004-04-18 18:21:17 +04:00
|
|
|
# The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
# http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
# for the specific language governing rights and limitations under the
|
|
|
|
# License.
|
2000-10-18 21:15:17 +04:00
|
|
|
#
|
|
|
|
# The Original Code is mozilla.org code.
|
|
|
|
#
|
2004-04-18 18:21:17 +04:00
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# Netscape Communications Corporation.
|
|
|
|
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
|
|
|
# the Initial Developer. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
2000-10-18 21:15:17 +04:00
|
|
|
#
|
2004-04-18 18:21:17 +04:00
|
|
|
# Alternatively, the contents of this file may be used under the terms of
|
|
|
|
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
# of those above. If you wish to allow use of your version of this file only
|
|
|
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
# use your version of this file under the terms of the MPL, indicate your
|
|
|
|
# decision by deleting the provisions above and replace them with the notice
|
|
|
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
# the provisions above, a recipient may use your version of this file under
|
|
|
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
2000-10-18 21:15:17 +04:00
|
|
|
#
|
2004-04-18 18:21:17 +04:00
|
|
|
# ***** END LICENSE BLOCK *****
|
2000-10-18 21:15:17 +04:00
|
|
|
|
|
|
|
package mozBDate;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use IO::File;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use Exporter ();
|
2003-03-11 03:31:29 +03:00
|
|
|
use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $milestone);
|
2000-10-18 21:15:17 +04:00
|
|
|
|
|
|
|
$VERSION = 1.00;
|
|
|
|
@ISA = qw(Exporter);
|
2003-03-11 03:31:29 +03:00
|
|
|
@EXPORT = qw(&UpdateBuildNumber &SubstituteBuildNumber &SetMilestone);
|
2000-10-18 21:15:17 +04:00
|
|
|
%EXPORT_TAGS = ( );
|
|
|
|
@EXPORT_OK = qw();
|
|
|
|
}
|
|
|
|
|
2003-03-11 03:31:29 +03:00
|
|
|
local $mozBDate::milestone = "0.0";
|
|
|
|
|
2000-10-18 21:15:17 +04:00
|
|
|
sub write_number($) {
|
|
|
|
my ($file, $num) = @_;
|
|
|
|
unlink($file);
|
|
|
|
open(OUT, ">$file") || die "$file: $!\n";
|
|
|
|
print OUT "$num\n";
|
|
|
|
close(OUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub UpdateBuildNumber($$) {
|
|
|
|
|
|
|
|
my ($outfile, $official) = @_;
|
2002-02-20 09:21:10 +03:00
|
|
|
my $given_date = $ENV{"MOZ_BUILD_DATE"};
|
|
|
|
my $build_number;
|
2000-10-18 21:15:17 +04:00
|
|
|
|
2002-02-20 09:21:10 +03:00
|
|
|
if ($given_date eq "") {
|
|
|
|
# XP way of doing the build date.
|
|
|
|
# 1998091509 = 1998, September, 15th, 9am local time zone
|
|
|
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
|
|
|
localtime(time);
|
2000-10-18 21:15:17 +04:00
|
|
|
|
2002-02-20 09:21:10 +03:00
|
|
|
# localtime returns year minus 1900
|
|
|
|
$year = $year + 1900;
|
|
|
|
$build_number = sprintf("%04d%02d%02d%02d", $year, 1+$mon,
|
|
|
|
$mday, $hour);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$build_number = $given_date;
|
|
|
|
}
|
2000-10-18 21:15:17 +04:00
|
|
|
|
|
|
|
if ("$outfile" eq "") {
|
2000-10-21 03:14:12 +04:00
|
|
|
print "$build_number\n";
|
|
|
|
return;
|
2000-10-18 21:15:17 +04:00
|
|
|
}
|
|
|
|
|
2006-04-04 12:14:36 +04:00
|
|
|
if (!$official) {
|
|
|
|
$build_number = "0000000000";
|
|
|
|
}
|
2000-10-18 21:15:17 +04:00
|
|
|
|
2006-04-04 12:14:36 +04:00
|
|
|
my $old_num = "";
|
2000-10-21 03:14:12 +04:00
|
|
|
|
2006-04-09 16:03:38 +04:00
|
|
|
# Don't overwrite $outfile if its contents won't change
|
2006-04-04 12:14:36 +04:00
|
|
|
if ( -e $outfile ) {
|
|
|
|
open(OLD, "<$outfile") || die "$outfile: $!\n";
|
|
|
|
$old_num = <OLD>;
|
|
|
|
chomp($old_num);
|
|
|
|
close(OLD);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($old_num ne $build_number) {
|
|
|
|
&write_number($outfile, $build_number);
|
2000-10-18 21:15:17 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub SubstituteBuildNumber($$$) {
|
|
|
|
|
|
|
|
my ($outfile, $build_num, $infile) = @_;
|
|
|
|
my $INFILE = new IO::File;
|
|
|
|
my $OUTFILE = new IO::File;
|
2003-03-11 03:31:29 +03:00
|
|
|
|
2000-10-18 21:15:17 +04:00
|
|
|
open $INFILE, "<$build_num";
|
|
|
|
my $build = <$INFILE>;
|
|
|
|
close $INFILE;
|
|
|
|
chomp $build;
|
2004-12-15 01:39:26 +03:00
|
|
|
chop $build if (substr($build, -1, 1) eq "\r");
|
2000-10-18 21:15:17 +04:00
|
|
|
|
2000-10-21 03:14:12 +04:00
|
|
|
if ($infile ne "") {
|
|
|
|
open($INFILE, "< $infile") || die "$infile: $!\n";
|
2000-10-18 21:15:17 +04:00
|
|
|
} else {
|
2000-10-21 03:14:12 +04:00
|
|
|
open($INFILE, "< $outfile") || die "$outfile: $!\n";
|
2000-10-18 21:15:17 +04:00
|
|
|
}
|
|
|
|
open $OUTFILE, ">${outfile}.old" || die;
|
|
|
|
|
|
|
|
while (<$INFILE>) {
|
2004-12-15 01:39:26 +03:00
|
|
|
my $id = $_;
|
|
|
|
my $temp;
|
|
|
|
if ($id =~ "Build ID:") {
|
|
|
|
$temp = "Build ID: " . $build;
|
|
|
|
$id =~ s/Build ID:\s\d+/$temp/;
|
|
|
|
print $OUTFILE $id;
|
|
|
|
}
|
|
|
|
elsif ($id =~ "NS_BUILD_ID") {
|
|
|
|
$temp = "NS_BUILD_ID " . $build;
|
|
|
|
$id =~ s/NS_BUILD_ID\s\d+/$temp/;
|
|
|
|
print $OUTFILE $id;
|
|
|
|
}
|
|
|
|
elsif ($id =~ "GRE_BUILD_ID") {
|
2006-02-02 23:56:10 +03:00
|
|
|
if (defined($ENV{'MOZ_MILESTONE_RELEASE'}) &&
|
|
|
|
$ENV{'MOZ_MILESTONE_RELEASE'} ne "") {
|
2004-12-15 01:39:26 +03:00
|
|
|
$temp = "GRE_BUILD_ID \"$milestone\"";
|
|
|
|
} else {
|
|
|
|
$temp = "GRE_BUILD_ID \"${milestone}_${build}\"";
|
|
|
|
}
|
|
|
|
$id =~ s/GRE_BUILD_ID\s\"\d+\"/$temp/;
|
|
|
|
print $OUTFILE $id;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print $OUTFILE $_;
|
|
|
|
}
|
2000-10-18 21:15:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
close $INFILE;
|
|
|
|
close $OUTFILE;
|
|
|
|
|
|
|
|
unlink $outfile;
|
|
|
|
rename "${outfile}.old", "$outfile";
|
|
|
|
}
|
|
|
|
|
2003-03-11 03:31:29 +03:00
|
|
|
sub SetMilestone($) {
|
|
|
|
my ($mstone) = (@_);
|
|
|
|
$milestone = $mstone if ($mstone ne "");
|
|
|
|
}
|
|
|
|
|
2000-10-18 21:15:17 +04:00
|
|
|
END {};
|
|
|
|
|
|
|
|
1;
|
|
|
|
|