Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.28k stars 383 forks source link

Build from tarball fails in extend_version_file #2098

Closed cleeland closed 5 years ago

cleeland commented 5 years ago

Describe the bug Trying to build from a tarball of a tagged release, rather than from a git clone, fails when it tries to use git commands inside scripts/build/extend_version_file.py to populate build/CodeChecker/config/version.json.

CodeChecker version v6.9.1

To Reproduce Steps to reproduce the behavior

  1. Download https://github.com/Ericsson/codechecker/tarball/$(VERSION_TAG)
  2. Untar the tarball
  3. Follow the instructions in the "boostrapping" section of README AFTER git clone

Observe error similar to the following:

[INFO] - Extending version file '/rpmbuilddir/BUILDROOT/codechecker-6.9.1-201917252134.x86_64/config/analyzer_version.json'.
fatal: Not a git repository (or any of the parent directories): .git
[ERROR] - Failed to get last commit hash.
Traceback (most recent call last):
  File "./scripts/build/extend_version_file.py", line 41, in extend_version_file
    git_hash = run_cmd(git_hash_cmd, repository_root)
  File "./scripts/build/extend_version_file.py", line 28, in run_cmd
    cwd=cwd)
  File "/usr/lib64/python2.7/subprocess.py", line 575, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['git', 'rev-parse', 'HEAD']' returned non-zero exit status 128
fatal: Not a git repository (or any of the parent directories): .git
[ERROR] - Failed to get last commit describe.
Traceback (most recent call last):
  File "./scripts/build/extend_version_file.py", line 61, in extend_version_file
    git_describe = run_cmd(git_describe_cmd, repository_root)
  File "./scripts/build/extend_version_file.py", line 28, in run_cmd
    cwd=cwd)
  File "/usr/lib64/python2.7/subprocess.py", line 575, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['git', 'describe', '--always', '--tags', '--abbrev=0']' returned non-zero exit status 128
Traceback (most recent call last):
  File "./scripts/build/extend_version_file.py", line 139, in <module>
    extend_version_file(args['repository'], version_file)
  File "./scripts/build/extend_version_file.py", line 86, in extend_version_file
    version_json_data['git_describe'] = {'tag': git_tag,
UnboundLocalError: local variable 'git_tag' referenced before assignment
make[1]: *** [package] Error 1

Expected behavior At minimum substitute a bogus made-up value for version. Ideally I would be able to hard-code this version as part of the build.

Desktop (please complete the following information)

Additional context This is part of an effort to package codechecker as an installable RPM.

csordasmarton commented 5 years ago

Resolved by #2099