summaryrefslogtreecommitdiff
path: root/packages/brpm
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-07-06 17:29:09 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-07-06 17:29:09 -0700
commitc7aeea86fb8a17e4402cfc42626dfff2fb04c1a0 (patch)
tree032389ae7e0e7ffb1541086a9c60731492825e06 /packages/brpm
parentb2a21ed1dc682a262d55a4202c6b9606496d211f (diff)
downloadvyos-cloud-init-c7aeea86fb8a17e4402cfc42626dfff2fb04c1a0.tar.gz
vyos-cloud-init-c7aeea86fb8a17e4402cfc42626dfff2fb04c1a0.zip
Reworking these to look attempt to find the right parent directory, as well
as adjustments due to sysvinit rename.
Diffstat (limited to 'packages/brpm')
-rwxr-xr-xpackages/brpm43
1 files changed, 25 insertions, 18 deletions
diff --git a/packages/brpm b/packages/brpm
index 1d05bd2a..7d0dc78f 100755
--- a/packages/brpm
+++ b/packages/brpm
@@ -11,11 +11,21 @@ import re
import argparse
+def find_root():
+ look_where = [
+ os.path.join(os.getcwd(), 'setup.py'),
+ os.path.join(os.pardir, 'setup.py'),
+ ]
+ for fn in look_where:
+ if os.path.isfile(fn):
+ return os.path.dirname(os.path.abspath(fn))
+ raise ImportError(("Unable to determine where your cloud-init 'setup.py'"
+ " file is located at!"))
+
+
# 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
@@ -82,8 +92,7 @@ def format_change_line(ds, who, comment=None):
def generate_spec_contents(args, tmpl_fn):
# Figure out the version and revno
- cmd = [sys.executable,
- util.abs_join(os.pardir, 'tools', 'read-version')]
+ cmd = [util.abs_join(find_root(), 'tools', 'read-version')]
(stdout, _stderr) = util.subp(cmd)
version = stdout.strip()
@@ -99,8 +108,7 @@ def generate_spec_contents(args, tmpl_fn):
subs['archive_name'] = '%{name}-%{version}-' + revno + '.tar.gz'
subs['bd_requires'] = ['python-devel', 'python-setuptools']
- 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
@@ -122,7 +130,7 @@ def generate_spec_contents(args, tmpl_fn):
subs['requires'] = requires
# Format a nice changelog (as best as we can)
- changelog = util.load_file(util.abs_join(os.pardir, 'ChangeLog'))
+ changelog = util.load_file(util.abs_join(find_root(), 'ChangeLog'))
changelog_lines = []
for line in changelog.splitlines():
if not line.strip():
@@ -159,8 +167,8 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("-b", "--boot", dest="boot",
help="select boot type (default: %(default)s)",
- metavar="TYPE", default='initd',
- choices=('initd', 'systemd', 'initd-local'))
+ metavar="TYPE", default='sysvinit',
+ choices=('sysvinit', 'systemd'))
parser.add_argument("-v", "--verbose", dest="verbose",
help=("run verbosely"
" (default: %(default)s)"),
@@ -179,17 +187,16 @@ def main():
util.ensure_dirs([root_dir, arc_dir])
# Archive the code
- cmd = [sys.executable,
- util.abs_join(os.getcwd(), 'make-tarball')]
+ cmd = [util.abs_join(find_root(), 'tools', 'make-tarball')]
(stdout, _stderr) = util.subp(cmd)
archive_fn = stdout.strip()
real_archive_fn = os.path.join(arc_dir, os.path.basename(archive_fn))
shutil.move(archive_fn, real_archive_fn)
# Form the spec file to be used
- tmpl_fn = util.abs_join(os.getcwd(), 'redhat', 'cloud-init.spec')
+ tmpl_fn = util.abs_join(find_root(), 'packages', 'redhat', 'cloud-init.spec')
contents = generate_spec_contents(args, tmpl_fn)
- spec_fn = os.path.join(root_dir, 'cloud-init.spec')
+ spec_fn = util.abs_join(root_dir, 'cloud-init.spec')
util.write_file(spec_fn, contents)
# Now build it!
@@ -199,11 +206,11 @@ def main():
# Copy the items built to our local dir
globs = []
globs.extend(glob.glob("%s/*.rpm" %
- (os.path.join(root_dir, 'RPMS', 'noarch'))))
+ (util.abs_join(root_dir, 'RPMS', 'noarch'))))
globs.extend(glob.glob("%s/*.rpm" %
- (os.path.join(root_dir, 'RPMS'))))
+ (util.abs_join(root_dir, 'RPMS'))))
globs.extend(glob.glob("%s/*.rpm" %
- (os.path.join(root_dir, 'SRPMS'))))
+ (util.abs_join(root_dir, 'SRPMS'))))
for rpm_fn in globs:
tgt_fn = util.abs_join(os.getcwd(), os.path.basename(rpm_fn))
shutil.move(rpm_fn, tgt_fn)