summaryrefslogtreecommitdiffstats
path: root/keystone-moon/debian/create_deb.py
diff options
context:
space:
mode:
Diffstat (limited to 'keystone-moon/debian/create_deb.py')
-rw-r--r--keystone-moon/debian/create_deb.py70
1 files changed, 41 insertions, 29 deletions
diff --git a/keystone-moon/debian/create_deb.py b/keystone-moon/debian/create_deb.py
index b4c17e87..d01ad166 100644
--- a/keystone-moon/debian/create_deb.py
+++ b/keystone-moon/debian/create_deb.py
@@ -4,11 +4,18 @@ import os
import sys
import subprocess
import glob
+import argparse
+
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--src', help='Do not clone Moon repository, use SRC as source directory', dest="src")
+args = parser.parse_args()
os.putenv("LANG", "C")
TMP_DIR = "/tmp/debian-moon"
+MOON_DIR = os.path.join(TMP_DIR, "moon")
INIT_dir = os.path.split(os.path.abspath(sys.argv[0]))[0]
print("init dir: {}".format(INIT_dir))
@@ -23,38 +30,43 @@ _run = subprocess.run(["sudo", "-E", "apt-get", "install", "-y", "git"])
if _run.returncode != 0:
exit("\033[31mCannot install Git\033[m")
-print("\033[32mCloning Debian version\033[m")
-_run = subprocess.run(["git", "clone", "https://anonscm.debian.org/git/openstack/keystone.git"])
-if _run.returncode != 0:
- os.chdir(os.path.join(TMP_DIR, "keystone"))
- _run = subprocess.run(["git", "pull"])
- if _run.returncode != 0:
- print("\033[31mCannot clone ou pull debian version\033[m")
-
-os.chdir(TMP_DIR)
-
-print("\033[32mCloning Moon project\033[m")
-_run = subprocess.run(["git", "clone", "https://git.opnfv.org/moon"])
-if _run.returncode != 0:
- os.chdir(os.path.join(TMP_DIR, "moon"))
- _run = subprocess.run(["git", "pull"])
+# print("\033[32mCloning Debian version\033[m")
+# _run = subprocess.run(["git", "clone", "https://anonscm.debian.org/git/openstack/keystone.git"])
+# if _run.returncode != 0:
+# os.chdir(os.path.join(TMP_DIR, "keystone"))
+# _run = subprocess.run(["git", "pull"])
+# if _run.returncode != 0:
+# print("\033[31mCannot clone ou pull debian version\033[m")
+#
+# os.chdir(TMP_DIR)
+
+
+if args.src:
+ print("\033[32mUsing {} as source directory\033[m".format(args.src))
+ MOON_DIR = args.src
+else:
+ print("\033[32mCloning Moon project\033[m")
+ _run = subprocess.run(["git", "clone", "https://git.opnfv.org/moon"])
if _run.returncode != 0:
- print("\033[31mCannot clone Moon project\033[m")
+ os.chdir(os.path.join(TMP_DIR, "moon"))
+ _run = subprocess.run(["git", "pull"])
+ if _run.returncode != 0:
+ print("\033[31mCannot clone Moon project\033[m")
os.chdir(TMP_DIR)
-_run = subprocess.run(["cp",
- "-r",
- os.path.join(TMP_DIR, "keystone", "debian"),
- os.path.join(TMP_DIR, "moon", "keystone-moon")])
+# _run = subprocess.run(["cp",
+# "-r",
+# os.path.join(TMP_DIR, "keystone", "debian"),
+# os.path.join(TMP_DIR, "moon", "keystone-moon")])
print("\033[32mBuilding Moon project\033[m")
-os.chdir(os.path.join(TMP_DIR, "moon", "keystone-moon"))
+os.chdir(os.path.join(MOON_DIR, "keystone-moon"))
-mandatory_deb_pkg = """dh-apparmor
-dh-systemd
-openstack-pkg-tools
-python-all python-pbr
+mandatory_deb_pkg = """dh-apparmor
+dh-systemd
+openstack-pkg-tools
+python-all python-pbr
python-sphinx
python-bashate
python-keystonemiddleware
@@ -117,12 +129,12 @@ _run = subprocess.run(_command)
os.putenv("DEB_BUILD_OPTIONS", "nocheck")
-changelog = open(os.path.join(TMP_DIR, "moon", "keystone-moon", "debian", "changelog"), "rt")
+changelog = open(os.path.join(MOON_DIR, "keystone-moon", "debian", "changelog"), "rt")
changelog_str = changelog.read()
# print(changelog_str.splitlines()[0])
current_version = changelog_str.splitlines()[0].split("(")[1].split(")")[0]
changelog.close()
-changelog = open(os.path.join(TMP_DIR, "moon", "keystone-moon", "debian", "changelog"), "wt")
+changelog = open(os.path.join(MOON_DIR, "keystone-moon", "debian", "changelog"), "wt")
changelog.write("""keystone ({version}) UNRELEASED; urgency=medium
* integration of the Moon platform.
@@ -135,7 +147,7 @@ changelog.write("""keystone ({version}) UNRELEASED; urgency=medium
changelog.write(changelog_str)
changelog.close()
-keystone_install_file = open(os.path.join(TMP_DIR, "moon", "keystone-moon", "debian", "keystone.install"), "a")
+keystone_install_file = open(os.path.join(MOON_DIR, "keystone-moon", "debian", "keystone.install"), "a")
keystone_install_file.write("etc/policies /etc/keystone\n")
@@ -146,6 +158,6 @@ print("\033[32mResults:\033[m")
subprocess.run(["pwd", ])
subprocess.run(["mkdir", "-p", "/tmp/deb"])
-files = glob.glob(os.path.join(TMP_DIR, "moon", "*.deb"))
+files = glob.glob(os.path.join(MOON_DIR, "*.deb"))
for _file in files:
subprocess.run(["mv", "-v", _file, "/tmp/deb/"])