Commit | Line | Data |
27da23d5 |
1 | #!/usr/bin/perl -w |
2 | |
3 | # Copyright (c) 2004-2005 Nokia. All rights reserved. |
4 | |
5 | use strict; |
6 | use lib "symbian"; |
7 | |
8 | do "sanity.pl"; |
9 | |
10 | my %VERSION = %{ do "version.pl" }; |
11 | my $VERSION = "$VERSION{REVISION}$VERSION{VERSION}$VERSION{SUBVERSION}"; |
12 | my $R_V_SV = "$VERSION{REVISION}.$VERSION{VERSION}.$VERSION{SUBVERSION}"; |
13 | |
14 | my $SDK = do "sdk.pl"; |
15 | my $UID = do "uid.pl"; |
16 | my %PORT = %{ do "port.pl" }; |
17 | |
18 | my $ARM = 'thumb'; # TODO |
19 | my $S60SK = $ENV{S60SDK}; # from sdk.pl |
20 | |
21 | my $UREL = $ENV{UREL}; # from sdk.pl |
22 | $UREL =~ s/-ARM-/$ARM/; |
23 | |
24 | my $app = '!:\System\Apps\Perl'; |
25 | my $lib = '!:\System\Libs'; |
26 | |
27 | my @target = @ARGV |
28 | ? @ARGV |
29 | : ( |
30 | "miniperl", "perl", |
31 | "perl${VERSION}dll", "perl${VERSION}lib", |
32 | "perl${VERSION}ext" |
33 | ); |
34 | |
35 | my %suffix; |
36 | @suffix{ "miniperl", "perl", "perl$VERSION" } = ( "exe", "exe", "dll", ); |
37 | |
38 | for my $target (@target) { |
39 | $target = "perl${VERSION}" if $target eq "perl${VERSION}dll"; |
40 | |
41 | my %copy; |
42 | my $pkg = "$target.pkg"; |
43 | print "\nCreating $pkg...\n"; |
44 | |
45 | my $suffix = $suffix{$target} || ""; |
46 | my $dst = $suffix eq "dll" ? $lib : $app; |
47 | |
48 | my $srctarget = "$UREL\\$target.$suffix"; |
49 | |
50 | if ( $target =~ /^(miniperl|perl|perl${VERSION}(?:dll)?)$/ ) { |
51 | $copy{$srctarget} = "$dst\\$target.$suffix"; |
52 | print "\t$target.$suffix\n"; |
53 | } |
54 | if ( $target eq "perl${VERSION}lib" ) { |
55 | print "Libraries...\n"; |
56 | |
57 | print "\tConfig.pm\n"; |
58 | $copy{"lib\\Config.pm"} = |
59 | "$lib\\Perl\\$R_V_SV\\thumb-symbian\\Config.pm"; |
60 | |
61 | print "\tConfig_heavy.pl\n"; |
62 | $copy{"xlib\\symbian\\Config_heavy.pl"} = |
63 | "$lib\\Perl\\$R_V_SV\\thumb-symbian\\Config_heavy.pl"; |
64 | |
65 | print "\tDynaLoader.pm\n"; |
66 | $copy{"ext\\DynaLoader\\DynaLoader.pm"} = |
67 | "$lib\\Perl\\$R_V_SV\\DynaLoader.pm"; |
68 | |
69 | print "\tErrno.pm\n"; |
70 | $copy{"ext\\Errno\\Errno.pm"} = "$lib\\Perl\\$R_V_SV\\Errno.pm"; |
71 | |
72 | open( my $cfg, "symbian/install.cfg" ) |
73 | or die "$!: symbian/install.cfg: $!\n"; |
74 | while (<$cfg>) { |
75 | next unless /^lib\s+(.+)/; |
76 | chomp; |
77 | my $f = $1; |
76e603de |
78 | unless (-f "lib/$f") { |
79 | warn qq[$0: No "lib/$f", skipping...\n]; |
80 | next; |
81 | } |
27da23d5 |
82 | $f =~ s:/:\\:g; |
83 | $copy{"lib\\$f"} = "$lib\\Perl\\$R_V_SV\\$f"; |
84 | print "\t$f\n"; |
85 | } |
86 | close($cfg); |
87 | } |
88 | |
89 | if ( $target eq "perl${VERSION}ext" ) { |
90 | my @lst = glob("symbian/*.lst"); |
91 | print "Extensions...\n"; |
92 | print "\t(none found)\n" unless @lst; |
93 | for my $lst (@lst) { |
94 | $lst =~ m:^symbian/(.+)\.:; |
95 | my $ext = $1; |
96 | $ext =~ s!-!::!g; |
97 | print "\t$ext\n"; |
98 | if ( open( my $pkg, $lst ) ) { |
99 | while (<$pkg>) { |
100 | if (m!^"(.+)"-"(.+)"$!) { |
101 | my ( $src, $dst ) = ( $1, $2 ); |
102 | $copy{$src} = $dst; |
103 | } |
104 | else { |
105 | warn "$0: $lst: $.: unknown syntax\n"; |
106 | } |
107 | } |
108 | close($pkg); |
109 | } |
110 | else { |
111 | warn "$0: $lst: $!\n"; |
112 | } |
113 | } |
114 | } |
115 | |
116 | for my $file ( keys %copy ) { |
117 | warn "$0: $file does not exist\n" unless -f $file; |
118 | } |
119 | |
120 | my @copy = map { qq["$_"-"$copy{$_}"] } sort keys %copy; |
121 | my $copy = join( "\n", @copy ); |
122 | |
123 | my %UID = ( |
124 | "miniperl" => 0, |
125 | "perl" => 0, |
126 | "perl${VERSION}" => $UID + 0, |
127 | "perl${VERSION}dll" => $UID + 0, |
128 | "perl${VERSION}ext" => $UID + 1, |
129 | "perl${VERSION}lib" => $UID + 2, |
130 | |
131 | # app = + 3 |
132 | # rec = + 4 |
133 | ); |
134 | |
135 | die "$0: target has no UID\n" unless defined $UID{$target}; |
136 | |
137 | my $uid = sprintf( "0x%08X", $UID{$target} ); |
138 | |
139 | my ( $MAJOR, $MINOR, $PATCH ) = ( 0, 0, 0 ); |
140 | |
141 | if ( $target =~ m:^perl$VERSION(dll|ext|lib)?$: ) { |
142 | my $pkg = defined $1 ? $1 : "dll"; |
143 | $MAJOR = $PORT{$pkg}->{MAJOR}; |
144 | $MINOR = $PORT{$pkg}->{MINOR}; |
145 | $PATCH = $PORT{$pkg}->{PATCH}; |
146 | } |
147 | |
148 | die "$0: Bad version for $target\n" |
149 | unless defined $MAJOR |
150 | && ( $MAJOR eq 0 || $MAJOR > 0 ) |
151 | && defined $MINOR |
152 | && ( $MINOR eq 0 || $MINOR > 0 ) |
153 | && defined $PATCH |
154 | && ( $PATCH eq 0 || $PATCH > 0 ); |
155 | |
156 | open PKG, ">$pkg" or die "$0: failed to create $pkg: $!\n"; |
157 | print PKG <<__EOF__; |
158 | ; \u$target installation script |
159 | ; |
160 | ; The supported languages |
161 | &EN; |
162 | ; |
163 | ; The installation name and header data |
164 | ; |
165 | #{"\u$target"},($uid),$MAJOR,$MINOR,$PATCH |
166 | ; |
167 | ; Private key and certificate (unused) |
168 | ; |
169 | ;* "\u$target.key", "\u$target.cer" |
170 | ; |
171 | ; Supports Series60 v0.9 |
172 | (0x101F6F88), 0, 0, 0, {"Series60ProductID"} |
173 | ; The files to install |
174 | ; |
175 | $copy |
176 | __EOF__ |
177 | close PKG; |
178 | |
179 | print "Created $pkg\n"; |
180 | |
181 | print "Running makesis...\n"; |
182 | |
183 | unlink("$target.sis"); |
184 | |
185 | system("makesis $pkg") == 0 |
186 | || die "$0: makesis $pkg failed: $!\n"; |
187 | } |
188 | |
189 | exit(0); |