source: trunk/bin/patch_capabilities.pl@ 769

Last change on this file since 769 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.8 KB
RevLine 
[556]1#!/usr/bin/perl
2#############################################################################
3##
[651]4## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
[556]5## All rights reserved.
6## Contact: Nokia Corporation ([email protected])
7##
8## This file is part of the S60 port of the Qt Toolkit.
9##
10## $QT_BEGIN_LICENSE:LGPL$
11## Commercial Usage
12## Licensees holding valid Qt Commercial licenses may use this file in
13## accordance with the Qt Commercial License Agreement provided with the
14## Software or, alternatively, in accordance with the terms contained in
15## a written agreement between you and Nokia.
16##
17## GNU Lesser General Public License Usage
18## Alternatively, this file may be used under the terms of the GNU Lesser
19## General Public License version 2.1 as published by the Free Software
20## Foundation and appearing in the file LICENSE.LGPL included in the
21## packaging of this file. Please review the following information to
22## ensure the GNU Lesser General Public License version 2.1 requirements
23## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24##
25## In addition, as a special exception, Nokia gives you certain additional
26## rights. These rights are described in the Nokia Qt LGPL Exception
27## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28##
29## GNU General Public License Usage
30## Alternatively, this file may be used under the terms of the GNU
31## General Public License version 3.0 as published by the Free Software
32## Foundation and appearing in the file LICENSE.GPL included in the
33## packaging of this file. Please review the following information to
34## ensure the GNU General Public License version 3.0 requirements will be
35## met: http://www.gnu.org/copyleft/gpl.html.
36##
37## If you have questions regarding the use of this file, please contact
38## Nokia at [email protected].
39## $QT_END_LICENSE$
40##
41#############################################################################
42
43#######################################################################
44#
45# A script for setting binary capabilities based on .pkg file contents.
46#
47#######################################################################
48
49sub Usage() {
50 print("This script can be used to set capabilities of all binaries\n");
51 print("specified for deployment in a .pkg file.\n");
52 print("If no capabilities are given, the binaries will be given the\n");
53 print("capabilities supported by self-signed certificates.\n");
54 print("\n *** NOTE: If *_template.pkg file is given, 'target-platform' is REQUIRED. ***\n");
55 print("\nUsage: patch_capabilities.pl pkg_filename <target-platform> [capability list]\n");
56 print("\nE.g. patch_capabilities.pl myapp_template.pkg release-armv5 \"All -TCB\"\n");
57 exit();
58}
59
60my @capabilitiesToSet = ("LocalServices", "NetworkServices", "ReadUserData", "UserEnvironment", "WriteUserData");
61
62# If arguments were given to the script,
63if (@ARGV)
64{
65 # Parse the first given script argument as a ".pkg" file name.
66 my $pkgFileName = shift(@ARGV);
67
68 # These variables will only be set for template .pkg files.
69 my $target;
70 my $platform;
71
72 # Check if using template .pkg and set target/platform variables
73 if (($pkgFileName =~ m|_template\.pkg$|i) && -r($pkgFileName))
74 {
75 my $targetplatform;
76 unless ($targetplatform = shift(@ARGV))
77 {
78 Usage();
79 }
80
81 my @tmpvalues = split('-', $targetplatform);
82 $target = $tmpvalues[0];
83 $platform = $tmpvalues[1];
84
85 # Convert visual target to real target (debug->udeb and release->urel)
86 $target =~ s/debug/udeb/i;
87 $target =~ s/release/urel/i;
88 }
89
90 # If the specified ".pkg" file exists (and can be read),
91 if (($pkgFileName =~ m|\.pkg$|i) && -r($pkgFileName))
92 {
93 # If there are more arguments given, parse them as capabilities.
94 if (@ARGV)
95 {
96 @capabilitiesToSet = ();
97 while (@ARGV)
98 {
99 push (@capabilitiesToSet, pop(@ARGV));
100 }
101 }
102
103 # Start with no binaries listed.
104 my @binaries = ();
105
106 my $tempPkgFileName = $pkgFileName."_@@TEMP@@";
107 unlink($tempPkgFileName);
108 open (NEW_PKG, ">>".$tempPkgFileName);
109 open (PKG, "<".$pkgFileName);
110
[651]