tools/update-packaging/unwrap_full_update.pl

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rwxr-xr-x

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 #!/usr/bin/perl -w
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6 #
     7 # This tool unpacks a full update package generated by make_full_update.sh
     8 # Author: Benjamin Smedberg
     9 #
    11 # -----------------------------------------------------------------------------
    12 # By default just assume that these tools exist on our path
    14 use Getopt::Std;
    16 my ($MAR, $BZIP2, $archive, @marentries, @marfiles);
    18 if (defined($ENV{"MAR"})) {
    19     $MAR = $ENV{"MAR"};
    20 }
    21 else {
    22     $MAR = "mar";
    23 }
    25 if (defined($ENV{"BZIP2"})) {
    26     $BZIP2 = $ENV{"BZIP2"};
    27 }
    28 else {
    29     $BZIP2 = "bzip2";
    30 }
    32 sub print_usage
    33 {
    34     print "Usage: unwrap_full_update.pl [OPTIONS] ARCHIVE\n\n";
    35     print "The contents of ARCHIVE will be unpacked into the current directory.\n\n";
    36     print "Options:\n";
    37     print "  -h show this help text\n";
    38 }
    40 my %opts;
    41 getopts("h", \%opts);
    43 if (defined($opts{'h'}) || scalar(@ARGV) != 1) {
    44     print_usage();
    45     exit 1;
    46 }
    48 $archive = $ARGV[0];
    49 @marentries = `"$MAR" -t "$archive"`;
    51 $? && die("Couldn't run \"$MAR\" -t");
    53 shift @marentries;
    55 system("$MAR -x \"$archive\"") == 0 || die "Couldn't run $MAR -x";
    57 foreach (@marentries) {
    58     tr/\n\r//d;
    59     my @splits = split(/\t/,$_);
    60     my $file = $splits[2];
    62     system("mv \"$file\" \"$file.bz2\"") == 0 ||
    63       die "Couldn't mv \"$file\"";
    64     system("\"$BZIP2\" -d \"$file.bz2\"") == 0 ||
    65       die "Couldn't decompress \"$file\"";
    66 }

mercurial