Skip to content

Instantly share code, notes, and snippets.

@lsblakk
Last active December 17, 2015 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsblakk/5568843 to your computer and use it in GitHub Desktop.
Save lsblakk/5568843 to your computer and use it in GitHub Desktop.
Merge day helper script for Release Management to use for version bumping, branding changes, etc. Does *not* do tagging or pushes to hg.
#!/usr/bin/python
"""A merge day helper script to go along with https://wiki.mozilla.org/Release_Management/Merge_Documentation"""
import urllib2
import os
import re
import sys
def getTemplateValue(url):
version_regex = re.compile(".*<p>(.*)</p>.*")
template_page = urllib2.urlopen(url).read().replace('\n', '')
parsed_template = version_regex.match(template_page)
return parsed_template.groups()[0]
def file_replace(fname, pat, s_after):
try:
with open(fname) as f:
if not any(re.search(pat, line) for line in f):
print pat, "not found in", fname
return # pattern does not occur in file so we are done.
with open(fname) as f:
out_fname = fname + ".tmp"
out = open(out_fname, "w")
for line in f:
out.write(re.sub(pat, s_after, line))
out.close()
os.rename(out_fname, fname)
except IOError:
print fname, "does not exist"
return
#=========================================================================================================#
mozilla_central = "./mozilla-central/"
mozilla_aurora = "./mozilla-aurora/"
mozilla_beta = "./mozilla-beta/"
beta_version = getTemplateValue("https://wiki.mozilla.org/Template:BETA_VERSION")
aurora_version = getTemplateValue("https://wiki.mozilla.org/Template:AURORA_VERSION")
central_version = getTemplateValue("https://wiki.mozilla.org/Template:CENTRAL_VERSION")
next_version = getTemplateValue("https://wiki.mozilla.org/Template:NEXT_VERSION")
weave_version = str(int(central_version)+2)
next_weave_version = str(int(weave_version)+1)
# mozilla-central
raw_input("Please go tag & push tag of mozilla-central first before proceeding.")
raw_input("> version-bump mozilla-central (hit 'return' to proceed) <")
## version bump
central_version_files = ["browser/config/version.txt", "config/milestone.txt", "mobile/android/confvars.sh", "b2g/confvars.sh", "js/src/config/milestone.txt"]
for avf in central_version_files:
file_replace(mozilla_central+avf, central_version+".0a1$", next_version+".0a1")
file_replace(mozilla_central+"xpcom/components/Module.h", central_version+";$", next_version+";")
file_replace(mozilla_central+"services/sync/Makefile.in", "\."+weave_version+"\.", "."+next_weave_version+".")
raw_input("Verify & commit version bumps then hit 'return' to continue...")
# mozilla-beta
raw_input("Go to wiki, tag mozilla-aurora, close & tag mozilla-beta.")
raw_input("> version-bump mozilla-beta (hit 'return' to proceed) <")
## version bump
beta_version_files = central_version_files
for avf in beta_version_files:
file_replace(mozilla_beta+avf, aurora_version+".0a2$", aurora_version+".0")
raw_input("Verify & commit mozilla-beta version bumps then hit 'return' to continue with branding updates...")
## branding changes
file_replace(mozilla_beta+"browser/confvars.sh", "MOZ_BRANDING_DIRECTORY=browser/branding/aurora", "MOZ_BRANDING_DIRECTORY=browser/branding/nightly")
file_replace(mozilla_beta+"browser/confvars.sh", "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-aurora", "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-beta,firefox-mozilla-release")
file_replace(mozilla_beta+"browser/confvars.sh", "MAR_CHANNEL_ID=firefox-mozilla-aurora", "MAR_CHANNEL_ID=firefox-mozilla-beta")
beta_branding_dirs = ["mobile/android/config/mozconfigs/android/", "mobile/android/config/mozconfigs/android-armv6/", "mobile/android/config/mozconfigs/android-x86/", "mobile/android/config/mozconfigs/android-noion/"]
beta_branding_files = ["debug","l10n-nightly","nightly"]
for bbd in beta_branding_dirs:
for bbf in beta_branding_files:
file_replace(mozilla_beta+bbd+bbf, "ac_add_options --with-branding=mobile/android/branding/aurora", "ac_add_options --with-branding=mobile/android/branding/beta")
file_replace(mozilla_beta+"mobile/xul/config/mozconfigs/android/debug", "ac_add_options --with-branding=mobile/xul/branding/aurora", "ac_add_options --with-branding=mobile/xul/branding/beta")
file_replace(mozilla_beta+"mobile/xul/config/mozconfigs/android/nightly", "ac_add_options --enable-js-diagnostics", "")
file_replace(mozilla_beta+"mobile/xul/config/mozconfigs/android/nightly", "ac_add_options --enable-application=mobile", "ac_add_options --enable-application=mobile/xul")
file_replace(mozilla_beta+"mobile/xul/config/mozconfigs/android/nightly", "ac_add_options --with-branding=mobile/xul/branding/aurora", "ac_add_options --with-branding=mobile/xul/branding/beta")
raw_input("Verify & commit mozilla-beta branding changes then hit 'return' to continue to mozilla-aurora...")
# mozilla-aurora
raw_input("Tag & close old Aurora and pull from m-c into Aurora before proceeding.")
raw_input("> version-bump mozilla-aurora (hit 'return' to proceed) <")
## version bumps
aurora_version_files = central_version_files
for avf in aurora_version_files:
file_replace(mozilla_aurora+avf, central_version+".0a1$", central_version+".0a2")
raw_input("Verify & commit mozilla-aurora version bumps then hit 'return' to continue to branding updates...")
## branding changes
file_replace(mozilla_aurora+"browser/confvars.sh", "MOZ_BRANDING_DIRECTORY=browser/branding/nightly", "MOZ_BRANDING_DIRECTORY=browser/branding/aurora")
file_replace(mozilla_aurora+"browser/confvars.sh", "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-central", "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-aurora")
file_replace(mozilla_aurora+"browser/confvars.sh", "MAR_CHANNEL_ID=firefox-mozilla-central", "MAR_CHANNEL_ID=firefox-mozilla-aurora")
aurora_branding_dirs = beta_branding_dirs
aurora_branding_files = beta_branding_files
for abd in aurora_branding_dirs:
for abf in aurora_branding_files:
file_replace(mozilla_aurora+abd+abf, "ac_add_options --with-branding=mobile/android/branding/nightly", "ac_add_options --with-branding=mobile/android/branding/aurora")
if abf == "l10n-nightly":
file_replace(mozilla_aurora+abd+abf, "ac_add_options --with-l10n-base=../../l10n-central", "ac_add_options --with-l10n-base=..")
raw_input("Verify & commit branding changes then hit 'return' to continue to profiling changes...")
## disable profiling and elf-hack
aurora_profiling_files = ["mobile/android/config/mozconfigs/android/nightly", "browser/config/mozconfigs/linux32/nightly", "browser/config/mozconfigs/linux64/nightly", "browser/config/mozconfigs/macosx-universal/nightly", "browser/config/mozconfigs/win32/nightly", "browser/config/mozconfigs/win64/nightly"]
for apf in aurora_profiling_files:
file_replace(mozilla_aurora+apf, "ac_add_options --enable-profiling\n", "")
file_replace(mozilla_aurora+apf, "ac_add_options --disable-elf-hack # --enable-elf-hack conflicts with --enable-profiling\n", "")
raw_input("Verify & commit profile changes and you're done.")
## clear dtrace & instruments on mozconfigs higher than nightly see bug 748669
aurora_dtrace_files = ["browser/config/mozconfigs/macosx-universal/nightly"]
for apf in aurora_dtrace_files:
file_replace(mozilla_aurora+apf, "ac_add_options --enable-instruments\nac_add_options --enable-dtrace\n", "")
raw_input("Verify & commit dtrace & instruments changes and you're done.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment