diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-09 15:36:16 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-07-09 15:36:16 -0400 |
commit | 7cd3e340264365c2e968b72cce78db9ff74b24a7 (patch) | |
tree | 4a7872cde84ca0d29e7e163f768aed564a8fa208 /packages/bddeb | |
parent | 492dc7478e0ab3eb03eb3b0b5d0e47812339b83f (diff) | |
parent | c7aeea86fb8a17e4402cfc42626dfff2fb04c1a0 (diff) | |
download | vyos-cloud-init-7cd3e340264365c2e968b72cce78db9ff74b24a7.tar.gz vyos-cloud-init-7cd3e340264365c2e968b72cce78db9ff74b24a7.zip |
rework packaging tools to find the right cloud-init topdir
This also fixes 'brpm' to address --init-system change that
smoser made to setup.py before the large 'rework' merge.
Diffstat (limited to 'packages/bddeb')
-rwxr-xr-x | packages/bddeb | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/packages/bddeb b/packages/bddeb index 10ad08b3..df2d6707 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -5,11 +5,19 @@ import shutil import sys import glob + +def find_root(): + # expected path is in <top_dir>/packages/ + top_dir = os.environ.get("CLOUD_INIT_TOP_D", None) + if top_dir is None: + top_dir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) + if os.path.isfile(os.path.join(top_dir, 'setup.py')): + return os.path.abspath(top_dir) + raise OSError(("Unable to determine where your cloud-init topdir is." + " set CLOUD_INIT_TOP_D?")) + # Use the util functions from cloudinit -possible_topdir = os.path.normpath(os.path.join(os.path.abspath( - sys.argv[0]), os.pardir, os.pardir)) -if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")): - sys.path.insert(0, possible_topdir) +sys.path.insert(0, find_root()) from cloudinit import templater from cloudinit import util @@ -34,7 +42,8 @@ def write_debian_folder(root, version, revno, init_sys): os.makedirs(deb_dir) # Fill in the change log template - templater.render_to_file(util.abs_join('debian', 'changelog'), + templater.render_to_file(util.abs_join(find_root(), + 'packages', 'debian', 'changelog'), util.abs_join(deb_dir, 'changelog'), params={ 'version': version, @@ -42,8 +51,7 @@ def write_debian_folder(root, version, revno, init_sys): }) # Write out the control file template - cmd = [sys.executable, - util.abs_join(os.pardir, 'tools', 'read-dependencies')] + cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')] (stdout, _stderr) = util.subp(cmd) # Map to known packages @@ -61,17 +69,20 @@ def write_debian_folder(root, version, revno, init_sys): else: requires.append(tgt_pkg) - templater.render_to_file(util.abs_join('debian', 'control'), + templater.render_to_file(util.abs_join(find_root(), + 'packages', 'debian', 'control'), util.abs_join(deb_dir, 'control'), params={'requires': requires}) - templater.render_to_file(util.abs_join('debian', 'rules'), + templater.render_to_file(util.abs_join(find_root(), + 'packages', 'debian', 'rules'), util.abs_join(deb_dir, 'rules'), params={'init_sys': init_sys}) # Just copy the following directly for base_fn in ['dirs', 'copyright', 'compat', 'pycompat']: - shutil.copy(util.abs_join('debian', base_fn), + shutil.copy(util.abs_join(find_root(), + 'packages', 'debian', base_fn), util.abs_join(deb_dir, base_fn)) @@ -100,8 +111,7 @@ def main(): with util.tempdir() as tdir: - cmd = [sys.executable, - util.abs_join(os.pardir, 'tools', 'read-version')] + cmd = [util.abs_join(find_root(), 'tools', 'read-version')] (sysout, _stderr) = util.subp(cmd) version = sysout.strip() @@ -113,24 +123,20 @@ def main(): # since we will extract it then add in the debian # folder, then re-archive it for debian happiness print("Creating a temporary tarball using the 'make-tarball' helper") - cmd = [sys.executable, - util.abs_join(os.getcwd(), 'make-tarball')] + cmd = [util.abs_join(find_root(), 'tools', 'make-tarball')] (sysout, _stderr) = util.subp(cmd) arch_fn = sysout.strip() tmp_arch_fn = util.abs_join(tdir, os.path.basename(arch_fn)) shutil.move(arch_fn, tmp_arch_fn) print("Extracting temporary tarball %r" % (tmp_arch_fn)) - cmd = ['tar', '-xvzf', tmp_arch_fn, '-C', tdir] + xdir = util.abs_join(tdir, 'cloud-init') + os.makedirs(xdir) + cmd = ['tar', '-xvzf', tmp_arch_fn, '-C', xdir] util.subp(cmd, capture=capture) - base_name = os.path.basename(arch_fn)[:-len(".tar.gz")] - shutil.move(util.abs_join(tdir, base_name), - util.abs_join(tdir, 'cloud-init')) - print("Creating a debian/ folder in %r" % - (util.abs_join(tdir, 'cloud-init'))) - write_debian_folder(util.abs_join(tdir, 'cloud-init'), - version, revno, args.boot) + print("Creating a debian/ folder in %r" % (xdir)) + write_debian_folder(xdir, version, revno, args.boot) # The naming here seems to follow some debian standard # so it will whine if it is changed... @@ -138,13 +144,13 @@ def main(): print("Archiving that new folder into %r" % (tar_fn)) cmd = ['tar', '-czvf', util.abs_join(tdir, tar_fn), - '-C', util.abs_join(tdir, 'cloud-init')] - cmd.extend(os.listdir(util.abs_join(tdir, 'cloud-init'))) + '-C', xdir] + cmd.extend(os.listdir(xdir)) util.subp(cmd, capture=capture) shutil.copy(util.abs_join(tdir, tar_fn), tar_fn) print("Wrote out archive %r" % (util.abs_join(tar_fn))) - print("Running 'debuild' in %r" % (util.abs_join(tdir, 'cloud-init'))) + print("Running 'debuild' in %r" % (xdir)) with util.chdir(util.abs_join(tdir, 'cloud-init')): cmd = ['debuild'] if not args.sign: |