diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2011-03-22 14:27:23 (GMT) |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2011-03-22 15:11:17 (GMT) |
commit | 7cce8ce5af4087c662db657887b7971a2931e849 (patch) | |
tree | 8d30aa133b129e52dc85587d55b5662952c88a29 /bin | |
parent | e28d33a6924d14afc5851a9a3587891f8507ee16 (diff) | |
download | Qt-7cce8ce5af4087c662db657887b7971a2931e849.zip Qt-7cce8ce5af4087c662db657887b7971a2931e849.tar.gz Qt-7cce8ce5af4087c662db657887b7971a2931e849.tar.bz2 |
Make createpackage and patch_capabilties scripts use tmp dir
Temporary files created by these two scripts will now be created
under a separate directory, contents of which is also added to cleanup.
Task-number: QTBUG-11394
Reviewed-by: axis
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/createpackage.pl | 41 | ||||
-rwxr-xr-x | bin/patch_capabilities.pl | 50 |
2 files changed, 60 insertions, 31 deletions
diff --git a/bin/createpackage.pl b/bin/createpackage.pl index df91876..b7457e1 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -58,7 +58,7 @@ use File::Spec; use File::Path; # use CWD abs_bath, which is exported only on request use Cwd 'abs_path'; - +use File::Copy; sub Usage() { print <<ENDUSAGESTRING; @@ -84,6 +84,8 @@ Where supported options are as follows: [-g|gcce-is-armv5] = Convert gcce platform to armv5. [-d|dont-patch] = Skip automatic patching of capabilities and pkg file if default certificate is used. Instead non-self-signable capabilities just cause warnings. + [-t|tmp-dir <path>] = Specifies temporary directory to be used for package creation. + Defaults to 'createpackage_tmp' under same directory as templatepkg. Where parameters are as follows: templatepkg = Name of .pkg file template target = Either debug or release @@ -130,6 +132,7 @@ my $signed_sis_name = ""; my $onlyUnsigned = ""; my $convertGcce = ""; my $dontPatchCaps = ""; +my $tempPackageDir = ""; unless (GetOptions('i|install' => \$install, 'p|preprocess' => \$preprocessonly, @@ -139,7 +142,8 @@ unless (GetOptions('i|install' => \$install, 's|stub' => \$stub, 'n|sisname=s' => \$signed_sis_name, 'g|gcce-is-armv5' => \$convertGcce, - 'd|dont-patch' => \$dontPatchCaps,)) { + 'd|dont-patch' => \$dontPatchCaps, + 't|tmp-dir=s' => \$tempPackageDir,)) { Usage(); } @@ -190,18 +194,22 @@ $key = $ARGV[3] or $key = ""; my $passphrase; $passphrase = $ARGV[4] or $passphrase = ""; +if ($tempPackageDir eq "") { + my ($templateVolume, $templatePath, $templateFileName) = File::Spec->splitpath($templatepkg); + $tempPackageDir = File::Spec->catpath($templateVolume, $templatePath."createpackage_tmp", ""); +} + +mkpath($tempPackageDir); + # Generate output pkg basename (i.e. file name without extension) my $pkgoutputbasename = $templatepkg; -my $preservePkgOutput = ""; $pkgoutputbasename =~ s/_template/_$targetplatform/g; $pkgoutputbasename =~ s/_installer\.pkg/_installer___temp\.pkg/g; -if ($pkgoutputbasename eq $templatepkg) { - $preservePkgOutput = "1"; -} $pkgoutputbasename =~ s/\.pkg//g; # Store output file names to variables -my $pkgoutput = $pkgoutputbasename.".pkg"; +my ($dummy1, $dummy2, $pkgoutput) = File::Spec->splitpath($pkgoutputbasename.".pkg"); +$pkgoutput = $tempPackageDir."/".$pkgoutput; my $sisoutputbasename; if ($signed_sis_name eq "") { $sisoutputbasename = $pkgoutputbasename; @@ -300,9 +308,7 @@ unlink $unsigned_sis_name; if (!$onlyUnsigned) { unlink $signed_sis_name; } -if (!$preservePkgOutput) { - unlink $pkgoutput; -} +unlink $pkgoutput; # Preprocess PKG @@ -334,6 +340,11 @@ print OUTPUT $_; close OUTPUT; if ($preprocessonly) { + # Copy preprocessed file from tmp dir to pkg file dir + my ($templateVolume, $templatePath, $templateFileName) = File::Spec->splitpath($templatepkg); + my ($dummy1, $dummy2, $copyFileName) = File::Spec->splitpath($pkgoutput); + my $copyTarget = File::Spec->catpath($templateVolume, $templatePath, $copyFileName); + copy($pkgoutput, $copyTarget) or die "Preprocessed pkg file '$pkgoutput' cannot be copied."; exit; } @@ -354,7 +365,7 @@ if($stub) { system ("$patch_capabilities -c $pkgoutput") and print ("Warning: Package check for self-signing viability failed. Installing the package on a device will most likely fail!\n\n"); } else { print("Auto-patching self-signed package.\n"); - system ("$patch_capabilities $pkgoutput") and die ("ERROR: Automatic patching failed"); + system ("$patch_capabilities -t $tempPackageDir $pkgoutput") and die ("ERROR: Automatic patching failed"); } } @@ -377,9 +388,6 @@ if($stub) { print ("\nUnsigned package creation failed!\n"); } - if (!$preservePkgOutput) { - unlink $pkgoutput; - } print ("\n"); exit; } @@ -405,10 +413,7 @@ if($stub) { print ("\tAdditionally signed the SIS with certificate: $row->[0]!\n"); } - # remove temporary pkg and unsigned sis - if (!$preservePkgOutput) { - unlink $pkgoutput; - } + # remove temporary unsigned sis if (!$preserveUnsigned) { unlink $unsigned_sis_name; } diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index 91ab4b8..40b6a17 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -53,6 +53,7 @@ use File::Copy; use File::Spec; +use File::Path; sub Usage() { print("This script can be used to set capabilities of all binaries\n"); @@ -63,11 +64,13 @@ sub Usage() { print(" symbian-sbsv2 platform, 'target-platform' is REQUIRED. ***\n\n"); print(" *** NOTE2: When patching gcce binaries built with symbian-sbsv2 toolchain,\n"); print(" armv5 must be specified as platform.\n"); - print("\nUsage: patch_capabilities.pl [-c] pkg_filename [target-platform [capability list]]\n"); + print("\nUsage: patch_capabilities.pl [-c|-t tmp_path] pkg_filename [target-platform [capability list]]\n"); print("\nE.g. patch_capabilities.pl myapp_template.pkg release-armv5 \"All -TCB\"\n"); print("\nThe parameter -c can be used to just check if package is compatible with self-signing\n"); print("without actually doing any patching.\n"); print("Explicit capability list cannot be used with -c parameter.\n"); + print("\nThe parameter -t can be used to specify a dir under which the temporary files are created.\n"); + print("Defaults to 'patch_capabilities_tmp' under the path to pkg file.\n"); exit(); } @@ -101,6 +104,7 @@ if (@ARGV) my $pkgFileName = shift(@ARGV); my $justCheck = ""; my $msgPrefix = "Patching:"; + my $tempPatchPath = ""; if ($pkgFileName eq "-c") { $pkgFileName = shift(@ARGV); @@ -108,6 +112,18 @@ if (@ARGV) $msgPrefix = "Warning:"; } + if ($pkgFileName eq "-t") { + $tempPatchPath = shift(@ARGV); + $pkgFileName = shift(@ARGV); + } + + my ($pkgVolume, $pkgPath, $pkgPlainFileName) = File::Spec->splitpath($pkgFileName); + if ($tempPatchPath eq "") { + $tempPatchPath = File::Spec->catpath($pkgVolume, $pkgPath."patch_capabilities_tmp", ""); + } + + mkpath($tempPatchPath); + # These variables will only be set for template .pkg files. my $target; my $platform; @@ -165,8 +181,9 @@ if (@ARGV) # Start with no binaries listed. my @binaries = (); + my $binariesDelimeter = "///"; - my $tempPkgFileName = $pkgFileName."_@@TEMP@@"; + my $tempPkgFileName = $tempPatchPath."/__TEMP__".$pkgPlainFileName; if (!$justCheck) { unlink($tempPkgFileName); @@ -216,19 +233,23 @@ if (@ARGV) $sourcePath =~ s/\$\(TARGET\)/$target/gm; } + my ($dummy1, $dummy2, $binaryBaseName) = File::Spec->splitpath($sourcePath); + if ($justCheck) { - push (@binaries, $sourcePath); + push (@binaries, $binaryBaseName.$binariesDelimeter.$sourcePath); } else { - # Change the source file name (but only if not already patched) + # Copy original files over to patching dir + # Patching dir will be flat to make it cleanable with QMAKE_CLEAN, so path + # will be collapsed into the file name to avoid name collisions in the rare + # case where custom pkg rules are used to install files with same names from + # different directories (probably using platform checks to choose only one of them.) my $patchedSourcePath = $sourcePath; - if ($patchedSourcePath !~ m/_patched_caps/) - { - $newLine =~ s/(^.*)(\.dll|\.exe)(.*)(\.dll|\.exe)/$1_patched_caps$2$3$4/i; - $patchedSourcePath =~ s/(^.*)(\.dll|\.exe)/$1_patched_caps$2/i; + $patchedSourcePath =~ s/[\/\\:]/_/g; + $patchedSourcePath = "$tempPatchPath/$patchedSourcePath"; + $newLine =~ s/^.*(\.dll|\.exe)(.*)(\.dll|\.exe)/\"$patchedSourcePath$2$3/i; - copy($sourcePath, $patchedSourcePath) or die "$sourcePath cannot be copied for patching."; - } - push (@binaries, $patchedSourcePath); + copy($sourcePath, $patchedSourcePath) or die "$sourcePath cannot be copied for patching."; + push (@binaries, $binaryBaseName.$binariesDelimeter.$patchedSourcePath); } } } @@ -250,10 +271,13 @@ if (@ARGV) my $baseCommandToExecute = "${epocToolsDir}elftran -vid 0x0 -capability \"%s\" "; # Actually set the capabilities of the listed binaries. - foreach my $binaryPath(@binaries) + foreach my $binariesItem(@binaries) { + $binariesItem =~ m|^(.*)$binariesDelimeter(.*)$|; + my $binaryBaseName = $1; + my $binaryPath = $2; + # Create the command line for setting the capabilities. - my ($binaryVolume, $binaryDirs, $binaryBaseName) = File::Spec->splitpath($binaryPath); my $commandToExecute = $baseCommandToExecute; my $executeNeeded = ""; if (@capabilitiesSpecified) |