Removes build.sh 99/41099/2
authorTim Rozet <trozet@redhat.com>
Tue, 5 Sep 2017 20:04:23 +0000 (16:04 -0400)
committerTim Rozet <trozet@redhat.com>
Wed, 6 Sep 2017 11:59:45 +0000 (07:59 -0400)
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>
apex/build.py
ci/build.sh [deleted file]
docs/release/release-notes/release-notes.rst

index cda4e06..2d0786a 100644 (file)
@@ -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)
diff --git a/ci/build.sh b/ci/build.sh
deleted file mode 100755 (executable)
index 113f35d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat) and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-set -e
-rpm -q ansible || sudo yum -y install ansible
-ansible-playbook --become -i "localhost," -c local $DIR/../lib/ansible/playbooks/build_dependencies.yml -vvv
-make -C $DIR/../build clean
-python3 $DIR/../apex/build.py $@
index a4d653e..7d8a78f 100644 (file)
@@ -243,7 +243,7 @@ Software Deliverables
 - Apex overcloud .rpm (opnfv-apex) - For nosdn and OpenDaylight Scenarios
 - Apex undercloud .rpm (opnfv-apex-undercloud)
 - Apex common .rpm (opnfv-apex-common)
-- build.sh - Builds the above artifacts
+- build.py - Builds the above artifacts
 - opnfv-deploy - Automatically deploys Target OPNFV System
 - opnfv-clean - Automatically resets a Target OPNFV Deployment
 - opnfv-util - Utility to connect to or debug Overcloud nodes + OpenDaylight