diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2019-07-28 02:21:22 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2019-07-28 02:40:19 -0400 |
commit | 7c55f85a33343ad56f7a3125ffe04cc07bea3400 (patch) | |
tree | 4f54e82546cd10c63c4b3cab932bba1755edd550 | |
parent | 38012be5bddbcec27030cb099d4c4237af776e6f (diff) |
squashme - binary build
-rw-r--r-- | branding-dev-build/bootstrap.py | 181 | ||||
-rwxr-xr-x | branding-dev-build/branding-dev-build.sh | 139 |
2 files changed, 82 insertions, 238 deletions
diff --git a/branding-dev-build/bootstrap.py b/branding-dev-build/bootstrap.py deleted file mode 100644 index 6c68621..0000000 --- a/branding-dev-build/bootstrap.py +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env python -# 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/. - -# This script provides one-line bootstrap support to configure systems to build -# the tree. -# -# The role of this script is to load the Python modules containing actual -# bootstrap support. It does this through various means, including fetching -# content from the upstream source repository. - -# If we add unicode_literals, optparse breaks on Python 2.6.1 (which is needed -# to support OS X 10.6). - -from __future__ import absolute_import, print_function - -WRONG_PYTHON_VERSION_MESSAGE = ''' -Bootstrap currently only runs on Python 2.7 or Python 2.6. -Please try re-running with python2.7 or python2.6. - -If these aren't available on your system, you may need to install them. -Look for a "python2" or "python27" package in your package manager. -''' - -import sys -if sys.version_info[:2] not in [(2, 6), (2, 7)]: - print(WRONG_PYTHON_VERSION_MESSAGE) - sys.exit(1) - -import os -import shutil -from StringIO import StringIO -import tempfile -try: - from urllib2 import urlopen -except ImportError: - from urllib.request import urlopen -import zipfile - -from optparse import OptionParser - -# The next two variables define where in the repository the Python files -# reside. This is used to remotely download file content when it isn't -# available locally. -REPOSITORY_PATH_PREFIX = 'python/mozboot/' - -TEMPDIR = None - - -def setup_proxy(): - # Some Linux environments define ALL_PROXY, which is a SOCKS proxy - # intended for all protocols. Python doesn't currently automatically - # detect this like it does for http_proxy and https_proxy. - if 'ALL_PROXY' in os.environ and 'https_proxy' not in os.environ: - os.environ['https_proxy'] = os.environ['ALL_PROXY'] - if 'ALL_PROXY' in os.environ and 'http_proxy' not in os.environ: - os.environ['http_proxy'] = os.environ['ALL_PROXY'] - - -def fetch_files(repo_url, repo_rev, repo_type): - setup_proxy() - repo_url = repo_url.rstrip('/') - - files = {} - - if repo_type == 'hgweb': - url = repo_url + '/archive/%s.zip/python/mozboot' % repo_rev - req = urlopen(url=url, timeout=30) - data = StringIO(req.read()) - data.seek(0) - zip = zipfile.ZipFile(data, 'r') - for f in zip.infolist(): - # The paths are prefixed with the repo and revision name before the - # directory name. - offset = f.filename.find(REPOSITORY_PATH_PREFIX) + len(REPOSITORY_PATH_PREFIX) - name = f.filename[offset:] - - # We only care about the Python modules. - if not name.startswith('mozboot/'): - continue - - files[name] = zip.read(f) - else: - raise NotImplementedError('Not sure how to handle repo type.', repo_type) - - return files - - -def ensure_environment(repo_url=None, repo_rev=None, repo_type=None): - """Ensure we can load the Python modules necessary to perform bootstrap.""" - - try: - from mozboot.bootstrap import Bootstrapper - return Bootstrapper - except ImportError: - # The first fallback is to assume we are running from a tree checkout - # and have the files in a sibling directory. - pardir = os.path.join(os.path.dirname(__file__), os.path.pardir) - include = os.path.normpath(pardir) - - sys.path.append(include) - try: - from mozboot.bootstrap import Bootstrapper - return Bootstrapper - except ImportError: - sys.path.pop() - - # The next fallback is to download the files from the source - # repository. - files = fetch_files(repo_url, repo_rev, repo_type) - - # Install them into a temporary location. They will be deleted - # after this script has finished executing. - global TEMPDIR - TEMPDIR = tempfile.mkdtemp() - - for relpath in files.keys(): - destpath = os.path.join(TEMPDIR, relpath) - destdir = os.path.dirname(destpath) - - if not os.path.exists(destdir): - os.makedirs(destdir) - - with open(destpath, 'wb') as fh: - fh.write(files[relpath]) - - # This should always work. - sys.path.append(TEMPDIR) - from mozboot.bootstrap import Bootstrapper - return Bootstrapper - - -def main(args): - parser = OptionParser() - parser.add_option('--vcs', dest='vcs', - default='hg', - help='VCS (hg or git) to use for downloading the source code. ' - 'Uses hg if omitted.') - parser.add_option('-r', '--repo-url', dest='repo_url', - default='https://hg.mozilla.org/mozilla-central/', - help='Base URL of source control repository where bootstrap files can ' - 'be downloaded.') - parser.add_option('--repo-rev', dest='repo_rev', - default='default', - help='Revision of files in repository to fetch') - parser.add_option('--repo-type', dest='repo_type', - default='hgweb', - help='The type of the repository. This defines how we fetch file ' - 'content. Like --repo, you should not need to set this.') - - parser.add_option('--application-choice', dest='application_choice', - help='Pass in an application choice (see mozboot.bootstrap.APPLICATIONS) ' - 'instead of using the default interactive prompt.') - parser.add_option('--no-interactive', dest='no_interactive', action='store_true', - help='Answer yes to any (Y/n) interactive prompts.') - - options, leftover = parser.parse_args(args) - - try: - try: - cls = ensure_environment(options.repo_url, options.repo_rev, - options.repo_type) - except Exception as e: - print('Could not load the bootstrap Python environment.\n') - print('This should never happen. Consider filing a bug.\n') - print('\n') - print(e) - return 1 - dasboot = cls(choice=options.application_choice, no_interactive=options.no_interactive, - vcs=options.vcs) - dasboot.bootstrap() - - return 0 - finally: - if TEMPDIR is not None: - shutil.rmtree(TEMPDIR) - - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/branding-dev-build/branding-dev-build.sh b/branding-dev-build/branding-dev-build.sh index b4c3d00..7c5dc0a 100755 --- a/branding-dev-build/branding-dev-build.sh +++ b/branding-dev-build/branding-dev-build.sh @@ -1,5 +1,4 @@ #!/bin/bash -#!/bin/bash # 'branding-dev-build.sh' pre-compiled binary builds for front-end dev # 'bootstrap.py' from: @@ -13,6 +12,8 @@ # this script will leave *.patch files behind for use in the published PKGBUILDs +## configuration ## + readonly USE_GIT=0 # git support requires 'git-cinnabar', per the Artifact_builds docs readonly CWD=${PWD} readonly BINARY_BUILD_SRCDIR=${CWD}/sources @@ -21,32 +22,63 @@ readonly CID_FILENAME='UPSTREAM_CID' readonly CID_FILE=${CWD}/${CID_FILENAME} readonly MOZCONFIG_FILE=${BINARY_BUILD_SRCDIR}/.mozconfig -readonly BOOTSTRAP_BASE_CMD='python2 ./bootstrap.py --application-choice=browser_artifact_mode' + +## commands ## + readonly COMMIT_MSG='nobody $(date +%F-%H-%M-%S)' readonly PARSE_CID_CMD='$(head --bytes=40 '${CID_FILE}' 2> /dev/null)' -readonly VALIDATE_CMD='[[ "${PARSE_CID_CMD}" =~ ^[0-9a-f]{40}$ ]]' +readonly BOOTSTRAP_CMD='./mach bootstrap' +readonly VALIDATE_CMD='[[ "$(eval echo ${PARSE_CID_CMD})" =~ ^[0-9a-f]{40}$ ]]' readonly TIMESTAMP_REGEX='s|.*"nobody ([0-9-]{19})"|\1|' readonly PATCH_FILE=${CWD}/'${timestamp}.patch' -(( ${USE_GIT} )) && readonly BOOTSTRAP_CMD=${BOOTSTRAP_BASE_CMD}' --vcs=git' || \ - readonly BOOTSTRAP_CMD=${BOOTSTRAP_BASE_CMD}' --vcs=hg' + (( ${USE_GIT} )) && readonly CHECKOUT_CMD='git clone https://github.com/mozilla/gecko-dev.git' || \ readonly CHECKOUT_CMD='hg clone https://hg.mozilla.org/mozilla-unified' (( ${USE_GIT} )) && readonly MARKER_CMD='git merge-base origin/master HEAD' || \ readonly MARKER_CMD='hg log --rev tip --template {node}' (( ${USE_GIT} )) && readonly STAGE_CMD='git add . .gitconfig' || \ readonly STAGE_CMD='hg addremove' -# readonly STAGE_CMD='hg add .'OR${CID_FILE} (( ${USE_GIT} )) && readonly VCS_ENV_CMD='cp {${CWD}/,${BINARY_BUILD_SRCDIR}/.}gitconfig' || \ readonly VCS_ENV_CMD='cp {${CWD}/,${BINARY_BUILD_SRCDIR}/.hg/}hgrc' -(( ${USE_GIT} )) && readonly COMMIT_CMD='git commit --message=\"$(COMMIT_MSG)\"' || \ - readonly COMMIT_CMD='hg commit --message=\"$(COMMIT_MSG)\"' -(( ${USE_GIT} )) && readonly PATCH_CMD='git diff --patch ${PARSE_CID_CMD} HEAD' || \ - readonly PATCH_CMD='hg log --follow --patch' # commited range -# readonly PATCH_CMD='hg export -o ${PATCH_FILE} -r tip' # commited tip -# readonly PATCH_CMD='hg diff -r '${PARSE_CID_CMD}':0000 path > '${PATCH_FILE} # commited range -# readonly PATCH_CMD='hg diff -g > ${PATCH_FILE}' # uncommited -# readonly PATCH_CMD='hg log --patch > ${PATCH_FILE}' # commited +(( ${USE_GIT} )) && readonly COMMIT_CMD='git commit --message=\"'${COMMIT_MSG}'\"' || \ + readonly COMMIT_CMD='hg commit --message=\"'${COMMIT_MSG}'\"' +(( ${USE_GIT} )) && readonly PATCH_COMMENT="Created against upstream git checkout-point: " || \ + readonly PATCH_COMMENT="Created against upstream hg checkout-point: " +(( ${USE_GIT} )) && readonly PATCH_CMD='git diff --patch '${PARSE_CID_CMD}' HEAD' || \ + readonly PATCH_CMD='hg diff -r '${PARSE_CID_CMD}':tip .' + + +## long strings ## + +readonly CID_FILE_MSG=" The contents of the ${CID_FILENAME} file will be injected "\ +"as a comment into the patch files, + to indicate the upstream checkout-point against which the patch was created. + Be sure to run these commands after pulling upstream sources manually: + $ cd ${BINARY_BUILD_SRCDIR} + $ ${MARKER_CMD} > ../${CID_FILENAME} + $ cd ${CWD}" + +read -r -d '' BINARY_BUILD_CFG <<-'BINARY_BUILD_CFG_END' +# download and use pre-compiled C++ components +ac_add_options --enable-artifact-builds +mk_add_options MOZ_OBJDIR=objdir-artifact + +# prefer debug versions of the pre-built binary artifacts +ac_add_options --enable-debug +# specify build target (IIRC 'browser' is the default) +# binary builds are also available for icedove and iceape (optional) +ac_add_options --enable-application=browser +# ac_add_options --enable-application=mail +# ac_add_options --enable-application=suite + +# build multiple of iceweasel|icedove|iceape +# mk_add_options MOZ_OBJDIR=obj-artifact-@CONFIG_GUESS@ +# mk_add_options MOZ_BUILD_PROJECTS="browser mail suite" +BINARY_BUILD_CFG_END + + +## functions ## PrepareMozillaBinaryBuild() { @@ -56,6 +88,7 @@ PrepareMozillaBinaryBuild() echo "NOTE: This initial setup will be run only once, or when the upstream sources are otherwise mising." echo " The build will require approximately 30GB disk space." ${CHECKOUT_CMD} ${BINARY_BUILD_SRCDIR} + echo echo "NOTE: This bootstrap script will prompt for a series of decisions." echo " You should see: \"Using an experimental bootstrapper for Archlinux.\"." @@ -65,25 +98,23 @@ PrepareMozillaBinaryBuild() echo " The bootstrap script will then download the tooling." echo " You should see: \"Your system should be ready to build Firefox for Desktop Artifact Mode!
\"" echo " Ignore the note about the $topsrcdir/mozconfig file; but do open a new shell to continue." + # bootstrap cd ${BINARY_BUILD_SRCDIR}/ ; ${BOOTSTRAP_CMD} ; cd ${CWD} ; + # mark upstream CID + rm ${CID_FILE} 2> /dev/null + cd ${BINARY_BUILD_SRCDIR}/ ; ${MARKER_CMD} > ${CID_FILE} ; cd ${CWD} ; + + echo "NOTE: The file: ${CID_FILE} has been created; but it must be maintained manually." + eval ${CID_FILE_MSG} else echo "Source directory 'sources' already exists." fi - # mark upstream CID and validate - rm ${CID_FILE} 2> /dev/null - cd ${BINARY_BUILD_SRCDIR}/ ; ${MARKER_CMD} > ${CID_FILE} ; cd ${CWD} ; - - if ! eval echo ${VALIDATE_CMD} > /dev/null + # validate upstream CID + if ! eval ${VALIDATE_CMD} then echo - echo "NOTE: The file: ${CID_FILE} is missing. The VCS may be insane." - echo " The contents of that file will be injected as a comment into the patch files," - echo " to indicate the upstream checkout-point against which the patch was created." - echo " Try running these commands before continuing:" - echo " $ cd ${BINARY_BUILD_SRCDIR}" - echo " $ git merge-base origin/master HEAD > ../${CID_FILENAME}" - echo " $ cd ${CWD}" - echo " If that fails, you probably need to delete the" - echo " ${BINARY_BUILD_SRCDIR} directory and start fresh." + echo "NOTE: The file: ${CID_FILE} is missing." + echo "${CID_FILE_MSG}" + echo " If that fails, you probably need to delete the sources directory and start fresh." return 1 else return 0 fi @@ -96,41 +127,35 @@ ConfigMozillaBinaryBuild() # modify the mozconfig file to download and re-build against pre-built binary artifacts echo echo "NOTE: Any existing .mozconfig file is about to be clobbered;" - echo " then the changes defined in ConfigMozillaBinaryBuild() will be re-applied." - echo " Ensure that all modifications to .mozconfig are in ConfigMozillaBinaryBuild()." - cat > ${MOZCONFIG_FILE} <<'BINARY_BUILD_END' - # download and use pre-compiled C++ components - ac_add_options --enable-artifact-builds - mk_add_options MOZ_OBJDIR=objdir-artifact - - # prefer debug versions of the pre-built binary artifacts - ac_add_options --enable-debug - - # specify build target (IIRC 'browser' is the default) - # binary builds are also available for icedove and iceape (optional) - ac_add_options --enable-application=browser - # ac_add_options --enable-application=mail - # ac_add_options --enable-application=suite - - # build multiple of iceweasel|icedove|iceape - # mk_add_options MOZ_OBJDIR=obj-artifact-@CONFIG_GUESS@ - # mk_add_options MOZ_BUILD_PROJECTS="browser mail suite" -BINARY_BUILD_END + echo " then the changes defined in the \$BINARY_BUILD_CFG constant will be re-applied." + echo " Ensure that all modifications to .mozconfig are in \$BINARY_BUILD_CFG." + cat > ${MOZCONFIG_FILE} <<< $BINARY_BUILD_CFG local commit_cmd=$(eval echo ${COMMIT_CMD}) local timestamp=$(sed -E "${TIMESTAMP_REGEX}" <<< ${commit_cmd}) - local patch_comment="Created against upstream VCS checkout-point: $(eval echo ${PARSE_CID_CMD})" -echo "commit_cmd=${commit_cmd}" -echo "timestamp=${timestamp}" -eval echo ${PATCH_FILE} + local patch_comment="${PATCH_COMMENT} $(eval echo ${PARSE_CID_CMD})" + local patch_file=$(eval echo ${PATCH_FILE}) + +# P_CMD='hg log --follow --patch' # commited range +# P_CMD='hg export -o ${PATCH_FILE} -r tip' # commited tip +# PATCH_CMD='hg diff -r '${PARSE_CID_CMD}':tip .' # commited range +# P_CMD='hg diff -g > ${PATCH_FILE}' # uncommited +# P_CMD='hg log --patch > ${PATCH_FILE}' # commited +# echo ${PATCH_CMD} +# eval ${PATCH_CMD} +# exit + echo echo "NOTE: Your local changes are about to be committed to the upstream VCS;" echo " and a patch file against the pristine upstream source will be written." echo " The ID of this commit/patch is: ${timestamp}." - echo ${patch_comment} > $(eval echo ${PATCH_FILE}) - ${STAGE_CMD} && eval ${VCS_ENV_CMD} && eval ${commit_cmd} && \ - eval ${PATCH_CMD} >> ${PATCH_FILE} && return 0 || \ - echo "Failed to commit changes and/or write patch file." && return 1 + if ${STAGE_CMD} && eval ${VCS_ENV_CMD} && eval ${commit_cmd} + then echo ${patch_comment} > ${patch_file} + eval ${PATCH_CMD} >> ${patch_file} + return 0 + else echo -e "\nFailed to commit changes and/or write patch file - aborting build." + return 1 + fi } ReBuildMozillaBinaryBuild() @@ -146,6 +171,6 @@ ReBuildMozillaBinaryBuild() ## main entry ## echo -e "\n\n== PrepareMozillaBinaryBuild ==" && PrepareMozillaBinaryBuild && \ -# echo -e "\n\n== ConfigMozillaBinaryBuild ==" && ConfigMozillaBinaryBuild && \ +echo -e "\n\n== ConfigMozillaBinaryBuild ==" && ConfigMozillaBinaryBuild && \ # echo -e "\n\n== ReBuildMozillaBinaryBuild ==" && ReBuildMozillaBinaryBuild echo -e "\n\n== ReBuildMozillaBinaryBuild ==" && echo out # ReBuildMozillaBinaryBuild |