Bug 1282782 - Add sourcestamp file to the source package. r=ted

MozReview-Commit-ID: GPuTKfeg7oy
This commit is contained in:
Alessio Placitelli 2016-12-22 09:14:00 +01:00
Родитель a01d83514b
Коммит 3d3b6b38af
2 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -9,6 +9,7 @@ import subprocess
import sys
from datetime import datetime
SOURCESTAMP_FILENAME = 'sourcestamp.txt'
def buildid_header(output):
buildid = os.environ.get('MOZ_BUILD_DATE')
@ -44,6 +45,26 @@ def get_hg_info(workdir):
def get_hg_changeset(path):
return get_program_output('hg', '-R', path, 'parent', '--template={node}')
def get_info_from_sourcestamp(sourcestamp_path):
"""Read the repository and changelog information from the sourcestamp
file. This assumes that the file exists and returns the results as a list
(either strings or None in case of error).
"""
# Load the content of the file.
lines = None
with open(sourcestamp_path) as f:
lines = f.read().splitlines()
# Parse the repo and the changeset. The sourcestamp file is supposed to
# contain two lines: the first is the build id and the second is the source
# URL.
if len(lines) != 2 or not lines[1].startswith('http'):
# Just return if the file doesn't contain what we expect.
return None, None
# Return the repo and the changeset.
return lines[1].split('/rev/')
def source_repo_header(output):
# We allow the source repo and changeset to be specified via the
@ -54,8 +75,11 @@ def source_repo_header(output):
source = ''
if not repo:
sourcestamp_path = os.path.join(buildconfig.topsrcdir, SOURCESTAMP_FILENAME)
if os.path.exists(os.path.join(buildconfig.topsrcdir, '.hg')):
repo, changeset = get_hg_info(buildconfig.topsrcdir)
elif os.path.exists(sourcestamp_path):
repo, changeset = get_info_from_sourcestamp(sourcestamp_path)
elif not changeset:
changeset = get_hg_changeset(buildconfig.topsrcdir)
if not changeset:

Просмотреть файл

@ -228,7 +228,17 @@ upload: checksum
# source-package creates a source tarball from the files in MOZ_PKG_SRCDIR,
# which is either set to a clean checkout or defaults to $topsrcdir
source-package:
@echo 'Generate the sourcestamp file'
# Make sure to have repository information available and then generate the
# sourcestamp file.
$(MAKE) -C $(DEPTH) 'source-repo.h'
$(MAKE) make-sourcestamp-file
@echo 'Packaging source tarball...'
# We want to include the sourcestamp file in the source tarball, so copy it
# in the root source directory. This is useful to enable telemetry submissions
# from builds made from the source package with the correct revision information.
# Don't bother removing it as this is only used by automation.
@cp $(MOZ_SOURCESTAMP_FILE) '$(MOZ_PKG_SRCDIR)/sourcestamp.txt'
$(MKDIR) -p $(DIST)/$(PKG_SRCPACK_PATH)
(cd $(MOZ_PKG_SRCDIR) && $(CREATE_SOURCE_TAR) - ./ ) | xz -9e > $(SOURCE_TAR)