~ubuntu-branches/ubuntu/oneiric/enigmail/oneiric-updates

« back to all changes in this revision

Viewing changes to config/add-chrome.pl

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2010-04-10 01:42:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100410014224-fbq9ui5x3b0h2t36
Tags: 2:1.0.1-0ubuntu1
* First releaase of enigmail 1.0.1 for tbird/icedove 3
  (LP: #527138)
* redo packaging from scratch 
  + add debian/make-orig target that uses xulrunner provided
    buildsystem + enigmail tarball to produce a proper orig.tar.gz
  + use debhelper 7 with mozilla-devscripts
  + use debian source format 3.0 (quilt)
  + patch enigmail to use frozen API only
    - add debian/patches/frozen_api.diff
  + patch build system to not link against -lxul - which isnt
    available for sdks produced by all-static apps like tbird
    - add debian/patches/build_system_dont_link_libxul.diff
  + add minimal build-depends to control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/perl
 
2
 
 
3
use File::Path;
 
4
use Getopt::Std;
 
5
use IO::File;
 
6
use mozLock;
 
7
 
 
8
getopts("lxo:");
 
9
 
 
10
my $installedChromeFile = $ARGV[0];
 
11
my $disableJarPackaging = $ARGV[1];
 
12
my $chromeType = $ARGV[2];
 
13
my $pkgName = $ARGV[3];
 
14
my $jarFileName = $ARGV[4];
 
15
 
 
16
my $win32 = ($^O =~ /((MS)?win32)|msys|cygwin|os2/i) ? 1 : 0;
 
17
my $macos = ($^O =~ /MacOS|darwin/i) ? 1 : 0;
 
18
my $unix  = !($win32 || $macos) ? 1 : 0;
 
19
 
 
20
sub foreignPlatformFile
 
21
{
 
22
   my ($jarfile) = @_;
 
23
   
 
24
   if (!$win32 && index($jarfile, "-win") != -1) {
 
25
     return 1;
 
26
   }
 
27
   
 
28
   if (!$unix && index($jarfile, "-unix") != -1) {
 
29
     return 1; 
 
30
   }
 
31
 
 
32
   if (!$macos && index($jarfile, "-mac") != -1) {
 
33
     return 1;
 
34
   }
 
35
 
 
36
   return 0;
 
37
}
 
38
 
 
39
sub foreignPlatformPath
 
40
{
 
41
   my ($jarpath) = @_;
 
42
   
 
43
   if (!$win32 && index($jarpath, "-platform/win") != -1) {
 
44
     return 1;
 
45
   }
 
46
   
 
47
   if (!$unix && index($jarpath, "-platform/unix") != -1) {
 
48
     return 1; 
 
49
   }
 
50
 
 
51
   if (!$macos && index($jarpath, "-platform/mac") != -1) {
 
52
     return 1;
 
53
   }
 
54
 
 
55
   return 0;
 
56
}
 
57
 
 
58
#print "add-chrome $installedChromeFile $disableJarPackaging $chromeType $pkgName $jarFileName\n";
 
59
 
 
60
my $nofilelocks = 0;
 
61
if (defined($::opt_l)) {
 
62
    $nofilelocks = 1;
 
63
}
 
64
 
 
65
if (defined($::opt_x)) {
 
66
    $win32 = 0;
 
67
    $macos = 0;
 
68
    $unix = 1;
 
69
}
 
70
 
 
71
my $force_os;
 
72
if (defined($::opt_o)) {
 
73
    $force_os = $::opt_o;
 
74
}
 
75
 
 
76
if (defined($force_os)) {
 
77
    $win32 = 0;
 
78
    $macos = 0;
 
79
    $unix = 0;
 
80
    if ($force_os eq "WINNT") {
 
81
        $win32 = 1;
 
82
    } elsif ($force_os eq "OS2") {
 
83
        $win32 = 1;
 
84
    } elsif ($force_os eq "Darwin") {
 
85
        $macos = 1;
 
86
    } else {
 
87
        $unix = 1;
 
88
    }
 
89
}
 
90
 
 
91
if ($jarFileName =~ /(.*)\.jar/) {
 
92
    $jarFileName = $1;
 
93
}
 
94
 
 
95
if (!foreignPlatformFile($jarFileName) && !foreignPlatformPath($pkgName)) {
 
96
 
 
97
my $line;
 
98
if ($disableJarPackaging) {
 
99
    $line = "$chromeType,install,url,resource:/chrome/$jarFileName/$chromeType/$pkgName/";
 
100
}
 
101
else {
 
102
    $line = "$chromeType,install,url,jar:resource:/chrome/$jarFileName.jar!/$chromeType/$pkgName/";
 
103
}
 
104
 
 
105
my $lockfile = "$installedChromeFile.lck";
 
106
my $err;
 
107
 
 
108
mozLock($lockfile) if (!$nofilelocks);
 
109
$err = 0;
 
110
if (open(FILE, "<$installedChromeFile")) {
 
111
    while (<FILE>) {
 
112
        chomp;
 
113
        if ($_ eq $line) {
 
114
            # line already appears in installed-chrome.txt file
 
115
            # just update the mod date
 
116
            close(FILE) or $err = 1; 
 
117
            if ($err) {
 
118
                mozUnlock($lockfile) if (!$nofilelocks);
 
119
                die "error: can't close $installedChromeFile: $!";
 
120
            }
 
121
            my $now = time;
 
122
            utime($now, $now, $installedChromeFile) or $err = 1;
 
123
            mozUnlock($lockfile) if (!$nofilelocks);
 
124
            if ($err) {
 
125
                die "couldn't touch $installedChromeFile";
 
126
            }
 
127
            print "+++ updating chrome $installedChromeFile\n+++\t$line\n";
 
128
            exit;
 
129
        }
 
130
    }
 
131
    close(FILE) or $err = 1;
 
132
    if ($err) {
 
133
        mozUnlock($lockfile) if (!$nofilelocks);
 
134
        die "error: can't close $installedChromeFile: $!";
 
135
    }
 
136
}
 
137
mozUnlock($lockfile) if (!$nofilelocks);
 
138
 
 
139
my $dir = $installedChromeFile;
 
140
if ("$dir" =~ /([\w\d.\-\\\/]+)[\\\/]([\w\d.\-]+)/) {
 
141
    $dir = $1;
 
142
}
 
143
mkpath($dir, 0, 0755);
 
144
 
 
145
mozLock($lockfile) if (!$nofilelocks);
 
146
$err = 0;
 
147
open(FILE, ">>$installedChromeFile") or $err = 1;
 
148
if ($err) {
 
149
    mozUnlock($lockfile) if (!$nofilelocks);
 
150
    die "can't open $installedChromeFile: $!";
 
151
}
 
152
print FILE "$line\n";
 
153
close(FILE) or $err = 1;
 
154
mozUnlock($lockfile) if (!$nofilelocks);
 
155
if ($err) {
 
156
    die "error: can't close $installedChromeFile: $!";
 
157
}
 
158
print "+++ adding chrome $installedChromeFile\n+++\t$line\n";
 
159
}
 
160