diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/createpackage | 3 | ||||
-rwxr-xr-x | bin/createpackage.pl | 72 | ||||
-rwxr-xr-x | bin/patch_capabilities | 3 | ||||
-rwxr-xr-x | bin/patch_capabilities.pl | 70 | ||||
-rwxr-xr-x | bin/syncqt | 48 |
5 files changed, 129 insertions, 67 deletions
diff --git a/bin/createpackage b/bin/createpackage new file mode 100755 index 0000000..fdd4eeb --- /dev/null +++ b/bin/createpackage @@ -0,0 +1,3 @@ +#!/bin/sh +scriptpath=`dirname $0` +perl $scriptpath/createpackage.pl "$@" diff --git a/bin/createpackage.pl b/bin/createpackage.pl index 7f803fd..554d619 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -85,7 +85,7 @@ Where parameters are as follows: winscw | gcce | armv5 | armv6 | armv7 certificate = The certificate file used for signing key = The certificate's private key file - passphrase = The certificate's private key file's passphrase + passphrase = The passphrase of the certificate's private key file Example: createpackage.pl fluidlauncher_template.pkg release-armv5 @@ -130,16 +130,21 @@ my $templatepkg = $ARGV[0]; my $targetplatform = lc $ARGV[1]; my @tmpvalues = split('-', $targetplatform); -my $target = $tmpvalues[0]; -my $platform = $tmpvalues[1];; +my $target; +$target = $tmpvalues[0] or $target = ""; +my $platform; +$platform = $tmpvalues[1] or $platform = ""; # Convert visual target to real target (debug->udeb and release->urel) $target =~ s/debug/udeb/i; $target =~ s/release/urel/i; -my $certificate = $ARGV[2]; -my $key = $ARGV[3]; -my $passphrase = $ARGV[4]; +my $certificate; +$certificate = $ARGV[2] or $certificate = ""; +my $key; +$key = $ARGV[3] or $key = ""; +my $passphrase; +$passphrase = $ARGV[4] or $passphrase = ""; # Generate output pkg basename (i.e. file name without extension) my $pkgoutputbasename = $templatepkg; @@ -149,11 +154,11 @@ if ($pkgoutputbasename eq $templatepkg) { $preservePkgOutput = "1"; } $pkgoutputbasename =~ s/\.pkg//g; -$pkgoutputbasename = lc($pkgoutputbasename); +$pkgoutputbasename = $pkgoutputbasename; # Store output file names to variables -my $pkgoutput = lc($pkgoutputbasename.".pkg"); -my $sisoutputbasename = lc($pkgoutputbasename); +my $pkgoutput = $pkgoutputbasename.".pkg"; +my $sisoutputbasename = $pkgoutputbasename; $sisoutputbasename =~ s/_$targetplatform//g; my $unsigned_sis_name = $sisoutputbasename."_unsigned.sis"; my $signed_sis_name = $sisoutputbasename.".sis"; @@ -162,10 +167,8 @@ my $stub_sis_name = $sisoutputbasename."_stub.sis"; # Store some utility variables my $scriptpath = dirname(__FILE__); my $certtext = $certificate; -my $certpath = $scriptpath; -$certpath =~ s-^(.*[^\\])$-$1\\-o; # ensure path ends with a backslash -$certpath =~ s-/-\\-go; # for those working with UNIX shells -$certpath =~ s-bin\\$-src\\s60installs\\-; # certificates are one step up in hierarcy +# certificates are one step up in hierarchy +my $certpath = File::Spec->catdir($scriptpath, File::Spec->updir(), "src/s60installs/"); # Check some pre-conditions and print error messages if needed. unless (length($templatepkg)) { @@ -173,14 +176,6 @@ unless (length($templatepkg)) { Usage(); } -# If the pkg file is not actually a template, there is no need for plaform or target. -if ($templatepkg =~ m/_template\.pkg/i) { - unless (length($platform) && length($target)) { - print "\nError: Platform or target is not defined!\n"; - Usage(); - } -} - # Check template exist stat($templatepkg); unless( -e _ ) { @@ -197,14 +192,14 @@ if (length($certificate)) { } else { #If no certificate is given, check default options $certtext = "RnD"; - $certificate = $certpath."rd.cer"; - $key = $certpath."rd-key.pem"; + $certificate = File::Spec->catfile($certpath, "rd.cer"); + $key = File::Spec->catfile($certpath, "rd-key.pem"); stat($certificate); unless( -e _ ) { $certtext = "Self Signed"; - $certificate = $certpath."selfsigned.cer"; - $key = $certpath."selfsigned.key"; + $certificate = File::Spec->catfile($certpath, "selfsigned.cer"); + $key = File::Spec->catfile($certpath, "selfsigned.key"); } } @@ -242,12 +237,25 @@ if (!$preservePkgOutput) { } # Preprocess PKG +if ($certtext eq "Self Signed" && !@certificates) { + print("Patching capabilities for self signed package $certificate\n"); + system ("patch_capabilities $templatepkg $targetplatform"); +} + local $/; # read template file open( TEMPLATE, $templatepkg) or die "Error '$templatepkg': $!\n"; $_=<TEMPLATE>; close (TEMPLATE); +# If the pkg file does not contain macros, there is no need for platform or target. +if (m/\$\(PLATFORM\)/) { + unless (length($platform) && length($target)) { + print "\nError: Platform or target is not defined!\n"; + Usage(); + } +} + # replace the PKG variables s/\$\(PLATFORM\)/$platform/gm; s/\$\(TARGET\)/$target/gm; @@ -270,11 +278,15 @@ if($stub) { system ("makesis -s $pkgoutput $stub_sis_name"); } else { # Create SIS. - system ("makesis $pkgoutput $unsigned_sis_name"); + # The 'and' is because system uses 0 to indicate success. + system ("makesis $pkgoutput $unsigned_sis_name") and die ("makesis failed"); print("\n"); # Sign SIS with certificate info given as an argument. - system ("signsis $unsigned_sis_name $signed_sis_name $certificate $key $passphrase"); + my $relcert = File::Spec->abs2rel($certificate); + my $relkey = File::Spec->abs2rel($key); + # The 'and' is because system uses 0 to indicate success. + system ("signsis $unsigned_sis_name $signed_sis_name $relcert $relkey $passphrase") and die ("signsis failed"); # Check if creating signed SIS Succeeded stat($signed_sis_name); @@ -288,10 +300,10 @@ if($stub) { # Sign with additional certificates & keys for my $row ( @certificates ) { # Get certificate absolute file names, relative paths are relative to certfilepath - my $abscert = File::Spec->rel2abs( $row->[0], $certfilepath); - my $abskey = File::Spec->rel2abs( $row->[1], $certfilepath); + my $relcert = File::Spec->abs2rel(File::Spec->rel2abs( $row->[0], $certfilepath)); + my $relkey = File::Spec->abs2rel(File::Spec->rel2abs( $row->[1], $certfilepath)); - system ("signsis $signed_sis_name $signed_sis_name $abscert $abskey $row->[2]"); + system ("signsis $signed_sis_name $signed_sis_name $relcert $relkey $row->[2]"); print ("\tAdditionally signed the SIS with certificate: $row->[0]!\n"); } diff --git a/bin/patch_capabilities b/bin/patch_capabilities new file mode 100755 index 0000000..0d89622 --- /dev/null +++ b/bin/patch_capabilities @@ -0,0 +1,3 @@ +#!/bin/sh +scriptpath=`dirname $0` +perl $scriptpath/patch_capabilities.pl "$@" diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index f82c48f..4390957 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -50,14 +50,26 @@ sub Usage() { print("This script can be used to set capabilities of all binaries\n"); print("specified for deployment in a .pkg file.\n"); print("If no capabilities are given, the binaries will be given the\n"); - print("capabilities supported by self-signed certificates.\n"); - print("\n *** NOTE: If *_template.pkg file is given, 'target-platform' is REQUIRED. ***\n"); - print("\nUsage: patch_capabilities.pl pkg_filename <target-platform> [capability list]\n"); + print("capabilities supported by self-signed certificates.\n\n"); + print(" *** NOTE: If *_template.pkg file is given and one is using symbian-abld or\n"); + print(" symbian-sbsv2 platform, 'target-platform' is REQUIRED. ***\n"); + print("\nUsage: patch_capabilities.pl pkg_filename [target-platform [capability list]]\n"); print("\nE.g. patch_capabilities.pl myapp_template.pkg release-armv5 \"All -TCB\"\n"); exit(); } -my @capabilitiesToSet = ("LocalServices", "NetworkServices", "ReadUserData", "UserEnvironment", "WriteUserData"); +sub trim($) { + my $string = shift; + $string =~ s/^\s+//; + $string =~ s/\s+$//; + return $string; +} + +my $nullDevice = "/dev/null"; +$nullDevice = "NUL" if ($^O =~ /MSWin/); + +my @capabilitiesToAllow = ("LocalServices", "NetworkServices", "ReadUserData", "UserEnvironment", "WriteUserData"); +my @capabilitiesSpecified = (); # If arguments were given to the script, if (@ARGV) @@ -73,11 +85,16 @@ if (@ARGV) if (($pkgFileName =~ m|_template\.pkg$|i) && -r($pkgFileName)) { my $targetplatform; - unless ($targetplatform = shift(@ARGV)) + my $templateFile; + my $templateContents; + open($templateFile, "< $pkgFileName") or die ("Could not open $pkgFileName"); + $templateContents = <$templateFile>; + close($templateFile); + unless (($targetplatform = shift(@ARGV)) || $templateContents !~ /\$\(PLATFORM\)/) { Usage(); } - + $targetplatform = "-" if (!$targetplatform); my @tmpvalues = split('-', $targetplatform); $target = $tmpvalues[0]; $platform = $tmpvalues[1]; @@ -93,10 +110,10 @@ if (@ARGV) # If there are more arguments given, parse them as capabilities. if (@ARGV) { - @capabilitiesToSet = (); + @capabilitiesSpecified = (); while (@ARGV) { - push (@capabilitiesToSet, pop(@ARGV)); + push (@capabilitiesSpecified, pop(@ARGV)); } } @@ -174,7 +191,7 @@ if (@ARGV) my $destinationPath = $2; # If the given file is a binary, check the target and binary type (+ the actual filename) from its path. - if ($sourcePath =~ m:/epoc32/release/([^/]+)/(udeb|urel|\$\(TARGET\))/(\w+(\.dll|\.exe)):i) + if ($sourcePath =~ m:\w+(\.dll|\.exe)$:i) { # Do preprocessing for template pkg, # In case of template pkg target and platform variables are set @@ -197,23 +214,42 @@ if (@ARGV) print ("\n"); - my $baseCommandToExecute = "elftran -vid 0x0 -capability \""; - if (@capabilitiesToSet) - { - $baseCommandToExecute .= join(" ", @capabilitiesToSet); - } - $baseCommandToExecute .= "\" "; + my $baseCommandToExecute = "elftran -vid 0x0 -capability \"%s\" "; # Actually set the capabilities of the listed binaries. foreach my $binaryPath(@binaries) { # Create the command line for setting the capabilities. my $commandToExecute = $baseCommandToExecute; + if (@capabilitiesSpecified) + { + $commandToExecute = sprintf($baseCommandToExecute, join(" ", @capabilitiesSpecified)); + } else { + # Test which capabilities are present and then restrict them to the allowed set. + # This avoid raising the capabilities of apps that already have none. + my $dllCaps; + open($dllCaps, "elftran -dump s $binaryPath |") or die ("Could not execute elftran"); + my $capsFound = 0; + my @capabilitiesToSet; + my $capabilitiesToAllow = join(" ", @capabilitiesToAllow); + while (<$dllCaps>) { + if (!$capsFound) { + $capsFound = 1 if (/Capabilities:/); + } else { + $_ = trim($_); + if ($capabilitiesToAllow =~ /$_/) { + push(@capabilitiesToSet, $_); + } + } + } + close($dllCaps); + $commandToExecute = sprintf($baseCommandToExecute, join(" ", @capabilitiesToSet)); + } $commandToExecute .= $binaryPath; # Actually execute the elftran command to set the capabilities. - system ($commandToExecute." > NUL"); - print ("Executed ".$commandToExecute."\n"); + print ("Executing ".$commandToExecute."\n"); + system ($commandToExecute." > $nullDevice"); ## Create another command line to check that the set capabilities are correct. #$commandToExecute = "elftran -dump s ".$binaryPath; @@ -44,7 +44,6 @@ my %modules = ( # path to module name map "Qt3Support" => "$basedir/src/qt3support", "ActiveQt" => "$basedir/src/activeqt/container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared", "QtTest" => "$basedir/src/testlib", - "QtAssistant" => "$basedir/tools/assistant/compat/lib", "QtHelp" => "$basedir/tools/assistant/lib", "QtDesigner" => "$basedir/tools/designer/src/lib", "QtUiTools" => "$basedir/tools/designer/src/uitools", @@ -63,6 +62,7 @@ my %moduleheaders = ( # restrict the module headers to those found in relative p # global variables (modified by options) my $module = 0; my $showonly = 0; +my $quiet = 0; my $remove_stale = 1; my $force_win = 0; my $force_relative = 0; @@ -93,6 +93,7 @@ sub showUsage print " -windows Force platform to Windows (default: " . ($force_win ? "yes" : "no") . ")\n"; print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n"; print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n"; + print " -quiet Only report problems, not activity (default: " . ($quiet ? "yes" : "no") . ")\n"; print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR> Create headers for <NAME> with original headers in <HEADERDIR> relative to <PROFILEDIR> \n"; print " -help This help\n"; exit 0; @@ -325,7 +326,7 @@ sub syncHeader { unless(-e "$header") { my $header_dir = dirname($header); - mkpath $header_dir, 0777; + mkpath $header_dir, !$quiet; #write it my $iheader_out = fixPaths($iheader, $header_dir); @@ -355,12 +356,13 @@ sub fixPaths { #setup my $ret = $file; + $ret =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; my $file_dir = dirname($file); if($file_dir eq ".") { $file_dir = getcwd(); $file_dir =~ s=\\=/=g; } - $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:,g; + $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; if($dir eq ".") { $dir = getcwd(); $dir =~ s=\\=/=g; @@ -465,7 +467,7 @@ sub copyFile if ( $knowdiff || ($filecontents ne $ifilecontents) ) { if ( $copy > 0 ) { my $file_dir = dirname($file); - mkpath $file_dir, 0777 unless(-e "$file_dir"); + mkpath $file_dir, !$quiet unless(-e "$file_dir"); open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; local $/; binmode O; @@ -474,7 +476,7 @@ sub copyFile return 1; } elsif ( $copy < 0 ) { my $ifile_dir = dirname($ifile); - mkpath $ifile_dir, 0777 unless(-e "$ifile_dir"); + mkpath $ifile_dir, !$quiet unless(-e "$ifile_dir"); open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; local $/; binmode O; @@ -500,7 +502,7 @@ sub symlinkFile my ($file,$ifile) = @_; if ($isunix) { - print "symlink created for $file "; + print "symlink created for $file " unless $quiet; if ( $force_relative && ($ifile =~ /^$basedir/)) { my $t = getcwd(); my $c = -1; @@ -508,9 +510,9 @@ sub symlinkFile $t =~ s-^$basedir/--; $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 ); $file =~ s-^$basedir/-$p-; - print " ($file)\n"; + print " ($file)\n" unless $quiet; } - print "\n"; + print "\n" unless $quiet; return symlink($file, $ifile); } return copyFile($file, $ifile); @@ -594,13 +596,13 @@ while ( @ARGV ) { } elsif("$arg" eq "-show") { $var = "showonly"; $val = "yes"; + } elsif("$arg" eq "-quiet") { + $var = "quiet"; + $val = "yes"; } elsif("$arg" eq "-base-dir") { # skip, it's been dealt with at the top of the file shift @ARGV; next; - } elsif("$arg" eq '*') { - # workaround for windows 9x where "%*" expands to "*" - $var = 1; } #do something @@ -619,6 +621,12 @@ while ( @ARGV ) { } elsif($showonly) { $showonly--; } + } elsif ("$var" eq "quiet") { + if("$val" eq "yes") { + $quiet++; + } elsif($quiet) { + $quiet--; + } } elsif ("$var" eq "check-includes") { if("$val" eq "yes") { $check_includes++; @@ -644,7 +652,7 @@ while ( @ARGV ) { $force_relative--; } } elsif ("$var" eq "module") { - print "module :$val:\n"; + print "module :$val:\n" unless $quiet; die "No such module: $val" unless(defined $modules{$val}); push @modules_to_sync, $val; } elsif ("$var" eq "separate-module") { @@ -672,7 +680,7 @@ while ( @ARGV ) { $isunix = checkUnix; #cache checkUnix # create path -mkpath "$out_basedir/include", 0777; +mkpath "$out_basedir/include", !$quiet; my @ignore_headers = (); my $class_lib_map_contents = ""; @@ -680,7 +688,7 @@ my @ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" ); my @ignore_for_include_check = ( "qatomic.h" ); my @ignore_for_qt_begin_header_check = ( "qiconset.h", "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qt_windows.h" ); my @ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h" ); -my @ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtSql}/drivers", "$modules{QtTest}", "$modules{QtAssistant}", "$modules{QtDesigner}", "$modules{QtUiTools}", "$modules{QtDBus}", "$modules{phonon}" ); +my @ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtSql}/drivers", "$modules{QtTest}", "$modules{QtDesigner}", "$modules{QtUiTools}", "$modules{QtDBus}", "$modules{phonon}" ); foreach (@modules_to_sync) { #iteration info @@ -875,7 +883,7 @@ foreach (@modules_to_sync) { $pri_install_pfiles.= "$pri_install_iheader ";; } } - print "header created for $iheader ($header_copies)\n" if($header_copies > 0); + print "header created for $iheader ($header_copies)\n" if($header_copies > 0 && !$quiet); } } } @@ -902,8 +910,8 @@ foreach (@modules_to_sync) { } if($master_include && $master_contents) { my $master_dir = dirname($master_include); - mkpath $master_dir, 0777; - print "header (master) created for $lib\n"; + mkpath $master_dir, !$quiet; + print "header (master) created for $lib\n" unless $quiet; open MASTERINCLUDE, ">$master_include"; print MASTERINCLUDE "$master_contents"; close MASTERINCLUDE; @@ -927,8 +935,8 @@ foreach (@modules_to_sync) { } if($headers_pri_file && $master_contents) { my $headers_pri_dir = dirname($headers_pri_file); - mkpath $headers_pri_dir, 0777; - print "headers.pri file created for $lib\n"; + mkpath $headers_pri_dir, !$quiet; + print "headers.pri file created for $lib\n" unless $quiet; open HEADERS_PRI_FILE, ">$headers_pri_file"; print HEADERS_PRI_FILE "$headers_pri_contents"; close HEADERS_PRI_FILE; @@ -948,7 +956,7 @@ unless($showonly || !$create_uic_class_map) { } if($class_lib_map) { my $class_lib_map_dir = dirname($class_lib_map); - mkpath $class_lib_map_dir, 0777; + mkpath $class_lib_map_dir, !$quiet; open CLASS_LIB_MAP, ">$class_lib_map"; print CLASS_LIB_MAP "$class_lib_map_contents"; close CLASS_LIB_MAP; |