[tor-commits] [tor-browser-bundle/master] Bug 20210: in dmg2mar, extract old mar file to copy permissions to the new one

gk at torproject.org gk at torproject.org
Fri Oct 21 14:13:58 UTC 2016


commit 97acdebccac65377317068cdbfae6def9bb67309
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Mon Oct 17 19:23:17 2016 +0200

    Bug 20210: in dmg2mar, extract old mar file to copy permissions to the new one
    
    7z does not currently extract file permissions from the dmg files
    so we also extract the old mar file to copy the permissions.
---
 tools/dmg2mar | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tools/dmg2mar b/tools/dmg2mar
index 010761e..8eaebe8 100755
--- a/tools/dmg2mar
+++ b/tools/dmg2mar
@@ -31,6 +31,7 @@
 use strict;
 use IO::CaptureOutput qw(capture_exec);
 use File::Slurp;
+use File::Find;
 use Parallel::ForkManager;
 use Cwd;
 
@@ -110,6 +111,27 @@ sub convert_files {
         my (undef, $err, $success) = capture_exec('7z', 'x', "-o$tmpdir",
                                                         $file->{filename});
         exit_error "Error extracting $file->{filename}: $err" unless $success;
+
+        # 7z does not currently extract file permissions from the dmg files
+        # so we also extract the old mar file to copy the permissions
+        # https://trac.torproject.org/projects/tor/ticket/20210
+        my $tmpdir_oldmar = File::Temp->newdir();
+        my $oldmar = getcwd . '/' . $output;
+        exit_error "Error extracting $output"
+                unless system('mar', '-C', $tmpdir_oldmar, '-x', $oldmar) == 0;
+        my $wanted = sub {
+            my $file = $File::Find::name;
+            $file =~ s{^$tmpdir/TorBrowser\.app/}{};
+            if (-f "$tmpdir_oldmar/$file") {
+                my (undef, undef, $mode) = stat("$tmpdir_oldmar/$file");
+                chmod $mode, $File::Find::name;
+                return;
+            }
+            chmod 0644, $File::Find::name if -f $File::Find::name;
+            chmod 0755, $File::Find::name if -d $File::Find::name;
+        };
+        find($wanted, "$tmpdir/TorBrowser.app");
+
         unlink $output;
         (undef, $err, $success) =  capture_exec('make_full_update.sh', '-q',
                                         $output, "$tmpdir/TorBrowser.app");



More information about the tor-commits mailing list