summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2009-08-27 05:04:32 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2009-08-27 05:04:32 (GMT)
commitf189e00fb98f3f5cf5353c69ffe77f206304666b (patch)
tree0293b39422ff6ef9123da47ed8cd4fdb7d30178d /bin
parent8c71456e2fdeba68978895d5c38f7fd251ab7808 (diff)
downloadQt-f189e00fb98f3f5cf5353c69ffe77f206304666b.zip
Qt-f189e00fb98f3f5cf5353c69ffe77f206304666b.tar.gz
Qt-f189e00fb98f3f5cf5353c69ffe77f206304666b.tar.bz2
Support for template PKG file.
This commit changes qmake to generate only one template pkg file, instead of one for each supported platform and build. Due to this change createpackage.bat script now need to be called with two additional parameters - platform and target. Example of needed changes: Instead of old way: >createpackage.bat [-i] pkgfile [certificate key [passphrase]] The new implementation works as: >createpackage.bat [-i] pkgfile platform build [certificate key [passphrase]] In addition createpackage.bat backend is replaced by createpackage.pl, it takes care of preprocesing the pkg file, i.e. expanding the variables with their values and calling the makesis and signsis with right parameters. Perl is used to make implementation more cross-platform. Task: 259037 RevBy: Miikka Heikkinen
Diffstat (limited to 'bin')
-rw-r--r--bin/createpackage.bat105
-rw-r--r--bin/createpackage.pl156
2 files changed, 157 insertions, 104 deletions
diff --git a/bin/createpackage.bat b/bin/createpackage.bat
index 116d52b..b5ede18 100644
--- a/bin/createpackage.bat
+++ b/bin/createpackage.bat
@@ -1,106 +1,3 @@
@echo off
-
-set installsigned_old=%installsigned%
-set pkgfile_old=%pkgfile%
-set basename_old=%basename%
-set signsis1_old=%signsis1%
-set signsis2_old=%signsis2%
-set signsis3_old=%signsis3%
-set unsigned_sis_name_old=%unsigned_sis_name%
-set signed_sis_name_old=%signed_sis_name%
-set scriptpath_old=%scriptpath%
-set certificate_old=%certificate%
-
-rem Help text
-if "%1"=="" (
- echo Convenience script for creating signed packages you can install on your phone.
- echo Usage: createpackage.bat [-i] myexample_armv5_udeb.pkg [certificate key [passphrase]]
- echo.
- echo If no certificate and key files are provided, either a RnD certificate or
- echo a self-signed certificate from Qt installation root directory is used.
- echo.
- echo To install the package right away using PC suite, use -i argument.
- goto done
-)
-
-if "%1"=="-i" (
- set installsigned=true
- set pkgfile=%2
- set basename=%~n2
- set signsis1=%3
- set signsis2=%4
- set signsis3=%5
-) else (
- set installsigned=false
- set pkgfile=%1
- set basename=%~n1
- set signsis1=%2
- set signsis2=%3
- set signsis3=%4
-)
-
-set unsigned_sis_name=%basename%_unsigned.sis
-set signed_sis_name=%basename%.sis
-
-rem Get absolute path to this script
set scriptpath=%~dp0
-
-rem Check the .pkg actually exists.
-if not exist %pkgfile% (
- echo Error: Package description file '%pkgfile%' does not exist.
- goto done
-)
-
-rem Remove any existing .sis packages
-if exist %signed_sis_name% del %signed_sis_name%
-if exist %unsigned_sis_name% del %unsigned_sis_name%
-
-rem Create .sis package
-makesis %pkgfile% %unsigned_sis_name%
-
-rem If no certificate is given, check default options
-if x%signsis1% == x (
- rem If RnD certificate is not found, sign with self signed certificate
- if not exist %scriptpath%..\rd.cer (
- set certificate=Self signed
- signsis %unsigned_sis_name% %signed_sis_name% %scriptpath%..\selfsigned.cer %scriptpath%..\selfsigned.key
- goto install
- )
-
- rem Sign with RnD certificate
- set certificate=RnD
- signsis %unsigned_sis_name% %signed_sis_name% %scriptpath%..\rd.cer %scriptpath%..\rd-key.pem
-) else (
- if x%signsis2% == x (
- echo Custom certificate key file parameter missing.
- goto cleanup
- )
-
- set certificate=%signsis1%
- signsis %unsigned_sis_name% %signed_sis_name% %signsis1% %signsis2% %signsis3%
-)
-
-:install
-if exist %signed_sis_name% (
- echo Successfully created %signed_sis_name% using certificate %certificate%
- if "%installsigned%" == "true" (
- echo Installing %signed_sis_name%...
- call %signed_sis_name%
- )
-)
-
-:cleanup
-if exist %unsigned_sis_name% del %unsigned_sis_name%
-
-:done
-
-set installsigned=%installsigned_old%
-set pkgfile=%pkgfile_old%
-set basename=%basename_old%
-set signsis1=%signsis1_old%
-set signsis2=%signsis2_old%
-set signsis3=%signsis3_old%
-set unsigned_sis_name=%unsigned_sis_name_old%
-set signed_sis_name=%signed_sis_name_old%
-set scriptpath=%scriptpath_old%
-set certificate=%certificate_old%
+perl %scriptpath%createpackage.pl %* \ No newline at end of file
diff --git a/bin/createpackage.pl b/bin/createpackage.pl
new file mode 100644
index 0000000..8501174
--- /dev/null
+++ b/bin/createpackage.pl
@@ -0,0 +1,156 @@
+#!\usr\bin\perl
+############################################################################################
+#
+# Convenience script for creating signed packages you can install on your phone.
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Qt Software Information (qt-info@nokia.com)
+#
+############################################################################################
+
+use strict;
+
+# use a command-line parsing module
+use Getopt::Long;
+# Use file name parsing module
+use File::Basename;
+
+sub Usage() {
+ print "\n";
+ print "==========================================================================================\n";
+ print "Convenience script for creating signed packages you can install on your phone.\n";
+ print "\n";
+ print "Usage: createpackage.pl [-i] templatepkg platform target [certificate key [passphrase]]\n";
+ print "\n";
+ print "Where parameters are as follows:\n";
+ print " [-i|install] = Install the package right away using PC suite\n";
+ print " templatepkg = Name of .pkg file template\n";
+ print " platform = One of the supported platform\n";
+ print " GCCE | ARMV5 | ARMV6 | ARMV7\n";
+ print " target = Either UDEB or UREL\n";
+ print " certificate = The certificate file used for signing\n";
+ print " key = The certificate's private key file\n";
+ print " passphrase = The certificate's private key file's passphrase\n";
+ print "\n";
+ print "If no certificate and key files are provided, either a RnD certificate or\n";
+ print "a self-signed certificate from Qt installation root directory is used.\n";
+ print "\n";
+ print "==========================================================================================\n";
+ exit();
+}
+
+# Read given options
+my $install = "";
+unless (GetOptions('i|install' => \$install)){
+ Usage();
+}
+
+# Read params to variables
+my $templatepkg = $ARGV[0];
+my $platform = uc $ARGV[1];
+my $target = uc $ARGV[2];
+my $visualtarget = $target;
+$visualtarget =~ s/udeb/debug/i;
+$visualtarget =~ s/urel/release/i;
+
+my $certificate = $ARGV[3];
+my $key = $ARGV[4];
+my $passphrase = $ARGV[5];
+
+# Generate output pkg basename (i.e. file name without extension)
+my $pkgoutputbasename = $templatepkg;
+$pkgoutputbasename =~ s/_template\.pkg/_$visualtarget-$platform/g;
+$pkgoutputbasename = lc($pkgoutputbasename);
+
+# Store output file names to variables
+my $pkgoutput = lc($pkgoutputbasename.".pkg");
+my $unsigned_sis_name = $pkgoutputbasename."_unsigned.sis";
+my $signed_sis_name = $pkgoutputbasename.".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 = $certpath."../"; # certificates are one step up in hierarcy
+$certpath =~ s-/-\\-go; # for those working with UNIX shells
+
+# Check some pre-conditions and print error messages if needed
+unless (length($templatepkg) && length($platform) && length($target)) {
+ print "\nError: Template PKG filename, platform or target is not defined!\n";
+ Usage();
+}
+
+# Check template exist
+stat($templatepkg);
+unless( -e _ ) {
+ print "\nError: Package description file '$templatepkg' does not exist!\n";
+ Usage();
+}
+
+# Check certifcate preconditions and set default certificate variables if needed
+if (length($certificate)) {
+ unless(length($key)) {
+ print "\nError: Custom certificate key file parameter missing.!\n";
+ Usage();
+ }
+} else {
+ #If no certificate is given, check default options
+ $certtext = "RnD";
+ $certificate = $certpath."rd.cer";
+ $key = $certpath."rd-key.pem";
+
+ stat($certificate);
+ unless( -e _ ) {
+ $certtext = "Self Signed";
+ $certificate = $certpath."selfsigned.cer";
+ $key = $certpath."selfsigned.key";
+ }
+}
+
+# Remove any existing .sis packages
+unlink $unsigned_sis_name;
+unlink $signed_sis_name;
+unlink $pkgoutput;
+
+# Preprocess PKG
+local $/;
+# read template file
+open( TEMPLATE, $templatepkg) or die "Error '$templatepkg': $!\n";
+$_=<TEMPLATE>;
+close (TEMPLATE);
+
+# replace the PKG variables
+s/\$\(PLATFORM\)/$platform/gm;
+s/\$\(TARGET\)/$target/gm;
+
+#write the output
+open( OUTPUT, ">$pkgoutput" ) or die "Error '$pkgoutput' $!\n";
+print OUTPUT $_;
+close OUTPUT;
+
+# Create and sign SIS
+system ("makesis $pkgoutput $unsigned_sis_name");
+system ("signsis $unsigned_sis_name $signed_sis_name $certificate $key $passphrase");
+
+# Check if creating signed SIS Succeeded
+stat($signed_sis_name);
+if( -e _ ) {
+ print ("\nSuccessfully created $signed_sis_name using certificate $certtext!\n");
+
+ # remove temporary pkg and unsigned sis
+ unlink $pkgoutput;
+ unlink $unsigned_sis_name;
+
+ # Install the sis if requested
+ if ($install) {
+ print ("\nInstalling $signed_sis_name...\n");
+ system ("$signed_sis_name");
+ }
+} else {
+ # Lets leave the generated PKG for problem solving purposes
+ print ("\nSIS creation failed!\n");
+}
+
+
+#end of file