Bug 1365722 - Move application.ini processing out to a separate file; r=cmanchester+432261

Windows repackaging for complete mar files will also need to pull a
different value out of the application.ini file, so this code should be
shareable.

MozReview-Commit-ID: CzCoNRYcBPX

--HG--
extra : rebase_source : a5e4b31ba876d811436a7d8d15462fa85f0762f8
This commit is contained in:
Mike Shal 2017-05-04 16:13:55 -04:00
parent 14106ca069
commit ca4aa9a838
2 changed files with 23 additions and 12 deletions

View File

@ -0,0 +1,21 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import ConfigParser
import mozpack.path as mozpath
def get_application_ini_value(application_directory, section, value):
rc = None
for root, dirs, files in os.walk(application_directory):
if 'application.ini' in files:
parser = ConfigParser.ConfigParser()
parser.read(mozpath.join(root, 'application.ini'))
rc = parser.get(section, value)
break
if rc is None:
raise Exception("Input package does not contain an application.ini file")
return rc

View File

@ -6,9 +6,9 @@ import os
import tempfile
import tarfile
import shutil
import ConfigParser
import mozpack.path as mozpath
from mozpack.dmg import create_dmg
from application_ini import get_application_ini_value
def repackage_dmg(infile, output):
@ -28,17 +28,7 @@ def repackage_dmg(infile, output):
if e.errno != errno.ENOENT:
raise
# Grab the volume name
volume_name = None
for root, dirs, files in os.walk(tmpdir):
if 'application.ini' in files:
parser = ConfigParser.ConfigParser()
parser.read(mozpath.join(root, 'application.ini'))
volume_name = parser.get('App', 'CodeName')
break
if volume_name is None:
raise Exception("Input package does not contain an application.ini file")
volume_name = get_application_ini_value(tmpdir, 'App', 'CodeName')
# The extra_files argument is empty [] because they are already a part
# of the original dmg produced by the build, and they remain in the