From 6a72c4de3e92cae65016578270e6f68e66c4f1e8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 21 Sep 2017 11:30:12 -0400 Subject: Updates to scons build system to use git instead of hg to determine revision information --- .gitignore | 3 +++ SConstruct | 44 +++++++++++++++++++------------------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 50e717a..a5ff571 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ venv.bak/ # mypy .mypy_cache/ + +# SCons files +.sconsign.* diff --git a/SConstruct b/SConstruct index 4ec3545..7e225d7 100644 --- a/SConstruct +++ b/SConstruct @@ -90,7 +90,7 @@ dh_builddeb = whereis('dh_builddeb') fakeroot = whereis('fakeroot') gzip = whereis('gzip') rpmbuild = whereis('rpmbuild') -hg = os.path.exists('.hg') and whereis('hg') +git = os.path.exists('.git') and whereis('git') unzip = whereis('unzip') zip = whereis('zip') @@ -122,29 +122,24 @@ version = ARGUMENTS.get('VERSION', '') if not version: version = default_version -hg_status_lines = [] +git_status_lines = [] -if hg: - cmd = "%s status --all 2> /dev/null" % hg - hg_status_lines = os.popen(cmd, "r").readlines() +if git: + cmd = "%s status 2> /dev/null" % git + git_status_lines = os.popen(cmd, "r").readlines() revision = ARGUMENTS.get('REVISION', '') def generate_build_id(revision): return revision -if not revision and hg: - hg_heads = os.popen("%s heads 2> /dev/null" % hg, "r").read() - cs = re.search('changeset:\s+(\S+)', hg_heads) - if cs: - revision = cs.group(1) - b = re.search('branch:\s+(\S+)', hg_heads) - if b: - revision = b.group(1) + ':' + revision - def generate_build_id(revision): - result = revision - if [l for l in hg_status_lines if l[0] in 'AMR!']: - result = result + '[MODIFIED]' - return result +if not revision and git: + git_hash = os.popen("%s rev-parse HEAD 2> /dev/null" % git, "r").read().strip() + def generate_build_id(revision): + result = git_hash + if [l for l in git_status_lines if 'modified' in l]: + result = result + '[MODIFIED]' + return result + revision = git_hash checkpoint = ARGUMENTS.get('CHECKPOINT', '') if checkpoint: @@ -234,8 +229,8 @@ command_line_variables = [ "variable from the list $USERNAME, $LOGNAME, $USER."), ("REVISION=", "The revision number of the source being built. " + - "The default is the Subversion revision returned " + - "'hg heads', with an appended string of " + + "The default is the git hash returned " + + "'git rev-parse HEAD', with an appended string of " + "'[MODIFIED]' if there are any changes in the " + "working copy."), @@ -1227,18 +1222,17 @@ SConscript('doc/SConscript') # source archive from the project files and files in the change. # + sfiles = None -if hg_status_lines: - slines = [l for l in hg_status_lines if l[0] in 'ACM'] +if git_status_lines: + slines = [l for l in git_status_lines if 'modified:' in l] sfiles = [l.split()[-1] for l in slines] else: print("Not building in a Mercurial tree; skipping building src package.") if sfiles: remove_patterns = [ - '.hgt/*', - '.svnt/*', - '*.aeignore', + '*.gitignore', '*.hgignore', 'www/*', ] -- cgit v0.12