Bug 748389: add buildID to the CFBundleVersion field in our Info.plist so that Mac OS X can differentiate different Firefox builds when launching webapprt, r=ted, r=felipe, r=dwalkowski, feedback=smichaud
authorGavin Sharp <gavin@gavinsharp.com>
Thu, 26 Apr 2012 13:46:29 -0400
changeset 93885 c0be912b90b4c917f6043c01ef309bb5efcd70c9
parent 93884 f597b823f6e4be3d465a83ff6994948e6fcd975c
child 93886 1541548bee2110e374a6911058ac566ac32b3056
push id9367
push usergsharp@mozilla.com
push dateMon, 14 May 2012 18:52:54 +0000
treeherdermozilla-inbound@ba1c1a993a33 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, felipe, dwalkowski
bugs748389
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 748389: add buildID to the CFBundleVersion field in our Info.plist so that Mac OS X can differentiate different Firefox builds when launching webapprt, r=ted, r=felipe, r=dwalkowski, feedback=smichaud
browser/app/Makefile.in
browser/app/macbuild/Contents/Info.plist.in
browser/app/macversion.py
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -196,26 +196,28 @@ clean clobber repackage::
 	$(RM) -r $(dist_dest)
 
 ifdef LIBXUL_SDK
 APPFILES = Resources
 else
 APPFILES = MacOS
 endif
 
+MAC_BUNDLE_VERSION = $(shell $(PYTHON) $(srcdir)/macversion.py --version=$(MOZ_APP_VERSION) --buildid=$(DEPTH)/config/buildid)
+
 libs-preqs = \
   $(call mkdir_deps,$(dist_dest)/Contents/MacOS) \
   $(call mkdir_deps,$(dist_dest)/Contents/Resources/$(AB).lproj) \
   $(NULL)
 
 .PHONY: repackage
 libs repackage:: $(PROGRAM) $(libs-preqs)
 	rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents $(dist_dest) --exclude English.lproj
 	rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents/Resources/English.lproj/ $(dist_dest)/Contents/Resources/$(AB).lproj
-	sed -e "s/%APP_VERSION%/$(MOZ_APP_VERSION)/" -e "s/%MAC_APP_NAME%/$(MAC_APP_NAME)/" -e "s/%LOWER_MAC_APP_NAME%/$(LOWER_MAC_APP_NAME)/" $(srcdir)/macbuild/Contents/Info.plist.in > $(dist_dest)/Contents/Info.plist
+	sed -e "s/%APP_VERSION%/$(MOZ_APP_VERSION)/" -e "s/%MAC_APP_NAME%/$(MAC_APP_NAME)/" -e "s/%LOWER_MAC_APP_NAME%/$(LOWER_MAC_APP_NAME)/" -e "s/%MAC_BUNDLE_VERSION%/$(MAC_BUNDLE_VERSION)/" $(srcdir)/macbuild/Contents/Info.plist.in > $(dist_dest)/Contents/Info.plist
 	sed -e "s/%MAC_APP_NAME%/$(MAC_APP_NAME)/" $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | iconv -f UTF-8 -t UTF-16 > $(dist_dest)/Contents/Resources/$(AB).lproj/InfoPlist.strings
 	rsync -a $(DIST)/bin/ $(dist_dest)/Contents/$(APPFILES)
 ifdef LIBXUL_SDK
 	cp $(LIBXUL_DIST)/bin/$(XR_STUB_NAME) $(dist_dest)/Contents/MacOS/firefox
 else
 	$(RM) $(dist_dest)/Contents/MacOS/$(PROGRAM)
 	rsync -aL $(PROGRAM) $(dist_dest)/Contents/MacOS
 endif
--- a/browser/app/macbuild/Contents/Info.plist.in
+++ b/browser/app/macbuild/Contents/Info.plist.in
@@ -195,17 +195,17 @@
 			<string>file URL</string>
 			<key>CFBundleURLSchemes</key>
 			<array>
 				<string>file</string>
 			</array>
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>%APP_VERSION%</string>
+	<string>%MAC_BUNDLE_VERSION%</string>
 	<key>NSAppleScriptEnabled</key>
 	<true/>
 	<key>LSMinimumSystemVersion</key>
 	<string>10.5</string>
 	<key>LSMinimumSystemVersionByArchitecture</key>
 	<dict>
 		<key>i386</key>
 		<string>10.5.0</string>
new file mode 100644
--- /dev/null
+++ b/browser/app/macversion.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+
+from optparse import OptionParser
+import sys
+import re
+
+o = OptionParser()
+o.add_option("--buildid", dest="buildid")
+o.add_option("--version", dest="version")
+
+(options, args) = o.parse_args()
+
+if not options.buildid:
+    print >>sys.stderr, "--buildid is required"
+    sys.exit(1)
+
+if not options.version:
+    print >>sys.stderr, "--version is required"
+    sys.exit(1)
+
+# We want to build a version number that matches the format allowed for
+# CFBundleVersion (nnnnn[.nn[.nn]]). We'll incorporate both the version
+# number as well as the date, so that it changes at least daily (for nightly
+# builds), but also so that newly-built older versions (e.g. beta build) aren't
+# considered "newer" than previously-built newer versions (e.g. a trunk nightly)
+
+buildid = open(options.buildid, 'r').read()
+
+# extract only the major version (i.e. "14" from "14.0b1")
+majorVersion = re.match(r'^(\d+)[^\d].*', options.version).group(1)
+# last two digits of the year
+twodigityear = buildid[2:4]
+month = buildid[4:6]
+if month[0] == '0':
+  month = month[1]
+day = buildid[6:8]
+if day[0] == '0':
+  day = day[1]
+
+print '%s.%s.%s' % (majorVersion + twodigityear, month, day)