summaryrefslogtreecommitdiffstats
path: root/apex/build.py
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2017-09-05 16:04:23 -0400
committerTim Rozet <trozet@redhat.com>2017-09-06 07:59:45 -0400
commit27018324387d4ef0efa908b315403a636f92de55 (patch)
tree5fbae8e4e76ed6b56ed8d34883e5c9609d4ac14c /apex/build.py
parent13377044e0cafd1e27ff66da2b264d8fa19e09af (diff)
Removes build.sh
We now have build.py which handles all the building and build.sh was just a wrapper to include ansible playbook. Now that we have built in apex libs to run ansible there is no reason to keep build.sh anymore. Also simplifies the logic to determine apex root by using the git properties. Change-Id: I00d2e5c7c198e549d21936bb1e9b562ba93d3010 Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'apex/build.py')
-rw-r--r--apex/build.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/apex/build.py b/apex/build.py
index cda4e06..2d0786a 100644
--- a/apex/build.py
+++ b/apex/build.py
@@ -15,6 +15,8 @@ import sys
import uuid
import yaml
+from apex.common import utils
+
CACHE_JOURNAL = 'cache_journal.yaml'
TMP_CACHE = '.cache'
BUILD_ROOT = 'build'
@@ -116,6 +118,12 @@ def build(build_root, version, iso=False, rpms=False):
make_args = ['RELEASE={}'.format(version)]
else:
make_args = []
+ logging.info('Running make clean...')
+ try:
+ subprocess.check_call(['make', '-C', build_root, 'clean'])
+ except subprocess.CalledProcessError:
+ logging.error('Failure to make clean')
+ raise
logging.info('Building targets: {}'.format(make_targets))
try:
output = subprocess.check_output(["make"] + make_args + ["-C",
@@ -216,13 +224,13 @@ if __name__ == '__main__':
console.setLevel(log_level)
console.setFormatter(logging.Formatter(formatter))
logging.getLogger('').addHandler(console)
- apex_root = os.path.split(os.getcwd())[0]
- if 'apex/apex' in apex_root:
- apex_root = os.path.split(apex_root)[0]
- for root, dirs, files in os.walk(apex_root):
- if BUILD_ROOT in dirs and 'apex/apex' not in root:
- apex_root = root
- break
+ # Since we only support building inside of git repo this should be fine
+ try:
+ apex_root = subprocess.check_output(
+ ['git', 'rev-parse', '--show-toplevel']).decode('utf-8').strip()
+ except subprocess.CalledProcessError:
+ logging.error("Must be in an Apex git repo to execute build")
+ raise
apex_build_root = os.path.join(apex_root, BUILD_ROOT)
if os.path.isdir(apex_build_root):
cache_tmp_dir = os.path.join(apex_root, TMP_CACHE)
@@ -232,6 +240,9 @@ if __name__ == '__main__':
raise ApexBuildException("Invalid path for apex root: {}. Must be "
"invoked from within Apex code directory.".
format(apex_root))
+ dep_playbook = os.path.join(apex_root,
+ 'lib/ansible/playbooks/build_dependencies.yml')
+ utils.run_ansible(None, dep_playbook)
unpack_cache(cache_tmp_dir, args.cache_dir)
build(apex_build_root, args.build_version, args.iso, args.rpms)
build_cache(cache_tmp_dir, args.cache_dir)