Opened 5 years ago

Closed 5 years ago

#12400 closed enhancement (fixed)

Rewrite fix-info-plist.sh with Python plistlib

Reported by: dcf Owned by: dcf
Priority: Low Milestone:
Component: Applications/Tor bundles/installation Version:
Severity: Keywords:
Cc: mcs, brade Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

fix-info-plist.sh uses a sed script to modify an XML file. I looked into ways to programmatically modify a plist file, and found Python plistlib. It will be more robust in case of changes in the input plist file like missing keys. I used plistlib with success in background-plist.py.

Child Tickets

Attachments (1)

0001-Port-fix-info-plist-from-shell-to-Python.patch (3.5 KB) - added by dcf 5 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by mcs

Cc: mcs brade added

If brade and I would have known about plistlib we would have used it. The sed script used in fix-info-plist.sh is quite complicated (it took a while to get it right) and you are correct that it is somewhat fragile.

comment:2 Changed 5 years ago by dcf

Status: newneeds_review

Here's a patch. plistlib canonicalizes indentation and order, so the before–after diff is not empty, but the meaning is the same. In this diff, directory 1 is built with fix-info-plist.sh, and directory is with fix-info-plist.py.

diff -Nru 1/Contents/Info.plist 2/Contents/Info.plist
--- 1/Contents/Info.plist       2000-01-01 00:00:00.000000000 +0000
+++ 2/Contents/Info.plist       2000-01-01 00:00:00.000000000 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
@@ -51,7 +51,7 @@
                <dict>
                        <key>CFBundleTypeExtensions</key>
                        <array>
-                           <string>text</string>
+                               <string>text</string>
                                <string>txt</string>
                                <string>js</string>
                                <string>log</string>
@@ -158,8 +158,6 @@
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>4.0-alpha1-pre</string>
-       <key>NSHumanReadableCopyright</key>
-       <string>Tor Browser 4.0-alpha1-pre Copyright 2014 The Tor Project</string>
        <key>CFBundleSignature</key>
        <string>MOZB</string>
        <key>CFBundleURLTypes</key>
@@ -203,8 +201,6 @@
        </array>
        <key>CFBundleVersion</key>
        <string>2400.1.1</string>
-       <key>NSAppleScriptEnabled</key>
-       <true/>
        <key>LSApplicationCategoryType</key>
        <string>public.app-category.productivity</string>
        <key>LSMinimumSystemVersion</key>
@@ -216,10 +212,15 @@
                <key>x86_64</key>
                <string>10.6.0</string>
        </dict>
-  <key>NSSupportsAutomaticGraphicsSwitching</key>
-  <true/>
-  <key>NSPrincipalClass</key>
-  <string>GeckoNSApplication</string>
-  <key>NSDisablePersistence</key><true/>
+       <key>NSAppleScriptEnabled</key>
+       <true/>
+       <key>NSDisablePersistence</key>
+       <true/>
+       <key>NSHumanReadableCopyright</key>
+       <string>Tor Browser 4.0-alpha1-pre Copyright 2014 The Tor Project</string>
+       <key>NSPrincipalClass</key>
+       <string>GeckoNSApplication</string>
+       <key>NSSupportsAutomaticGraphicsSwitching</key>
+       <true/>
 </dict>
 </plist>

comment:3 Changed 5 years ago by mcs

Your changes look fine to me.

comment:4 Changed 5 years ago by gk

Resolution: fixed
Status: needs_reviewclosed

I assume writePlist() works deterministically, right? Anyway, we'll see how it goes in the next alpha. Thanks! This is commit eae09200b44e70f45a9bd267912b06bb560f238d in the tor-browser-bundle repo now.

Note: See TracTickets for help on using tickets.