summaryrefslogtreecommitdiffstats
path: root/bin/patch_capabilities.pl
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-04-24 11:34:15 (GMT)
committeraxis <qt-info@nokia.com>2009-04-24 11:34:15 (GMT)
commit8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (patch)
treea17e1a767a89542ab59907462206d7dcf2e504b2 /bin/patch_capabilities.pl
downloadQt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.zip
Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.gz
Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.bz2
Long live Qt for S60!
Diffstat (limited to 'bin/patch_capabilities.pl')
-rw-r--r--bin/patch_capabilities.pl95
1 files changed, 95 insertions, 0 deletions
diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl
new file mode 100644
index 0000000..586e7b0
--- /dev/null
+++ b/bin/patch_capabilities.pl
@@ -0,0 +1,95 @@
+#######################################################################
+#
+# A script for setting binary capabilities based on .pkg file contents.
+#
+# Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+# Contact: Qt Software Information (qt-info@nokia.com)
+#
+#######################################################################
+
+my @capabilitiesToSet = ("LocalServices", "NetworkServices", "ReadUserData", "UserEnvironment", "WriteUserData");
+
+# If arguments were given to the script,
+if (@ARGV)
+{
+ # Parse the first given script argument as a ".pkg" file name.
+ my $pkgFileName = shift(@ARGV);
+
+ # If the specified ".pkg" file exists (and can be read),
+ if (($pkgFileName =~ m|\.pkg$|i) && -r($pkgFileName))
+ {
+ # If there are more arguments given, parse them as capabilities.
+ if (@ARGV)
+ {
+ @capabilitiesToSet = ();
+ while (@ARGV)
+ {
+ push (@capabilitiesToSet, pop(@ARGV));
+ }
+ }
+
+ # Start with no binaries listed.
+ my @binaries = ();
+
+ # Open the ".pkg" file.
+ open (PKG, "<".$pkgFileName);
+
+ # Parse each line.
+ while (<PKG>)
+ {
+ my $line = $_;
+ chomp ($line);
+
+ # If the line specifies a file, parse the source and destination locations.
+ if ($line =~ m|\"([^\"]+)\"\s*\-\s*\"([^\"]+)\"|)
+ {
+ my $sourcePath = $1;
+ 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)\\(\w+(\.dll|\.exe)):i)
+ {
+ push (@binaries, $sourcePath);
+ }
+ }
+ }
+
+ # Close the ".pkg" file.
+ close (PKG);
+
+ print ("\n");
+
+ my $baseCommandToExecute = "elftran -capability \"";
+ if (@capabilitiesToSet)
+ {
+ $baseCommandToExecute .= join(" ", @capabilitiesToSet);
+ }
+ $baseCommandToExecute .= "\" ";
+
+ # Actually set the capabilities of the listed binaries.
+ foreach my $binaryPath(@binaries)
+ {
+ # Create the command line for setting the capabilities.
+ my $commandToExecute = $baseCommandToExecute;
+ $commandToExecute .= $binaryPath;
+
+ # Actually execute the elftran command to set the capabilities.
+ system ($commandToExecute." > NUL");
+ print ("Executed ".$commandToExecute."\n");
+
+ ## Create another command line to check that the set capabilities are correct.
+ #$commandToExecute = "elftran -dump s ".$binaryPath;
+ }
+
+ print ("\n");
+ }
+}
+else
+{
+ 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("\nUsage: patch_capabilities.pl pkg_filename [capability list]\n");
+ print("\nE.g. patch_capabilities.pl myapp_armv5_urel.pkg \"All -TCB\"\n");
+} \ No newline at end of file