summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-25 23:57:01 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-25 23:57:01 -0700
commit2e05cec5cc9b5b334f7e46b629d424b09b9925b2 (patch)
tree18a2f34716b012a8e3f686d6924e3bd2a6359e9b /packages
parent86d7dfa8dae0b53866462ce8e737309a40436402 (diff)
downloadvyos-cloud-init-2e05cec5cc9b5b334f7e46b629d424b09b9925b2.tar.gz
vyos-cloud-init-2e05cec5cc9b5b334f7e46b629d424b09b9925b2.zip
Get these working again after the subdirectory and output
format changes.
Diffstat (limited to 'packages')
-rwxr-xr-xpackages/bddeb99
-rwxr-xr-xpackages/brpm32
2 files changed, 89 insertions, 42 deletions
diff --git a/packages/bddeb b/packages/bddeb
index 1a9f13f3..c39965da 100755
--- a/packages/bddeb
+++ b/packages/bddeb
@@ -8,6 +8,17 @@ import subprocess
import sys
import tempfile
+import tempita
+
+PKG_MP = {
+ 'tempita': 'python-tempita',
+ 'boto': 'python-boto',
+ 'configobj': 'python-configobj',
+ 'oauth': 'python-oauth',
+ 'yaml': 'python-yaml',
+ 'prettytable': 'python-prettytable',
+ 'argparse': 'python-argparse',
+}
@contextlib.contextmanager
def tmpdir():
@@ -24,11 +35,16 @@ def join(*paths):
return os.path.abspath(p)
-def tiny_p(cmd):
+def tiny_p(cmd, capture=True):
# Darn python 2.6 doesn't have check_output (argggg)
info("Running %s" % (cmd))
- sp = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, stdin=None)
+ stdout = subprocess.PIPE
+ stderr = subprocess.PIPE
+ if not capture:
+ stdout = None
+ stderr = None
+ sp = subprocess.Popen(cmd, stdout=stdout,
+ stderr=stderr, stdin=None)
(out, err) = sp.communicate()
if sp.returncode not in [0]:
raise RuntimeError("Failed running %s [rc=%s] (%s, %s)"
@@ -36,6 +52,53 @@ def tiny_p(cmd):
return (out, err)
+def tmpl_file(name, params):
+ with open(join('debian', name), 'r') as fh:
+ contents = fh.read()
+ tpl = tempita.Template(contents)
+ return tpl.substitute(**params)
+
+
+def write_debian(version, revno, root):
+ db_dir = join(root, 'debian')
+ os.makedirs(db_dir)
+
+ # Fill in the change log template
+ with open(join(db_dir, 'changelog'), 'w') as fh:
+ params = {
+ 'version': version,
+ 'revision': revno,
+ }
+ contents = tmpl_file('changelog', params)
+ fh.write(contents)
+
+ # Write out the control file template
+ cmd = [sys.executable, join(os.pardir, 'tools', 'read-dependencies')]
+ (stdout, _stderr) = tiny_p(cmd)
+ pkgs = stdout.splitlines()
+ requires = []
+
+ # Map to known packages
+ for e in pkgs:
+ e = e.lower().strip()
+ tgt_pkg = None
+ for n in PKG_MP.keys():
+ if e.find(n) != -1:
+ tgt_pkg = PKG_MP.get(n)
+ if not tgt_pkg:
+ raise RuntimeError(("Do not know how to translate %s to "
+ " a known package") % (e))
+ else:
+ requires.append(tgt_pkg)
+ contents = tmpl_file('control', {'requires': requires})
+ with open(join(db_dir, 'control'), 'w') as fh:
+ fh.write(contents)
+
+ # Just copy the following directly
+ for fn in ['dirs', 'copyright', 'compat', 'pycompat', 'rules']:
+ shutil.copy(join('debian', fn),
+ join(db_dir, fn))
+
def info(msg):
print("INFO: %s" % (msg))
@@ -46,49 +109,33 @@ def warn(msg):
def archive_code():
(stdout, _stderr) = tiny_p([sys.executable,
- join(os.getcwd(), 'tar-me')])
- lines = stdout.splitlines()
- revno = lines[0]
- version = lines[1]
- bname = lines[2]
- arc_fn = lines[3]
- return (revno, version, bname, arc_fn)
+ join(os.getcwd(), 'make-tarball')])
+ return stdout.split(None)
def main():
- # cmd = ['apt-get', 'install', 'python-nose',
- #'pyflakes', 'python-mocker', 'cdbs', 'debhelper']
- # tiny_p(cmd)
-
with tmpdir() as td:
(revno, version, bname, archive_fn) = archive_code()
real_archive_fn = os.path.join(td, os.path.basename(archive_fn))
shutil.move(archive_fn, real_archive_fn)
- info("Archived code to %s" % (real_archive_fn))
-
cmd = ['tar', '-xvzf', real_archive_fn, '-C', td]
stdout, stderr = tiny_p(cmd)
edir = join(td, bname)
shutil.move(edir, join(td, 'cloud-init'))
- shutil.copytree('debian.trunk', join(td, 'cloud-init', 'debian'))
-
- cmd = ['sed', '-i', '-e',"s,VERSION,%s," %(version),
- '-e', "s,REVNO,bzr%s," % (revno),
- join(td, 'cloud-init', 'debian', 'changelog')]
- tiny_p(cmd)
-
+ write_debian(version, revno, join(td, 'cloud-init'))
+
# Seems to want an original tar ball
- o_tar = "cloud-init_%s~bzr%s.orig.tar.gz" % (version, revno)
- cmd = ['tar', '-czf', join(td, o_tar), '-C', join(td, 'cloud-init')]
+ o_tar = "cloud-init_%s~%s.orig.tar.gz" % (version, revno)
+ cmd = ['tar', '-czvf', join(td, o_tar), '-C', join(td, 'cloud-init')]
cmd.extend(os.listdir(join(td, 'cloud-init')))
tiny_p(cmd)
ocwd = os.getcwd()
os.chdir(join(td, 'cloud-init'))
cmd = ['debuild']
- tiny_p(cmd)
+ tiny_p(cmd, capture=False)
debname = "cloud-init_%s~bzr%s-1_all.deb" % (version, revno)
shutil.move(debname, join(owcwd, debname))
diff --git a/packages/brpm b/packages/brpm
index c3be5997..bbe637e8 100755
--- a/packages/brpm
+++ b/packages/brpm
@@ -37,11 +37,16 @@ def join(*paths):
return os.path.abspath(p)
-def tiny_p(cmd):
+def tiny_p(cmd, capture=True):
# Darn python 2.6 doesn't have check_output (argggg)
info("Running %s" % (cmd))
- sp = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, stdin=None)
+ stdout = subprocess.PIPE
+ stderr = subprocess.PIPE
+ if not capture:
+ stdout = None
+ stderr = None
+ sp = subprocess.Popen(cmd, stdout=stdout,
+ stderr=stderr, stdin=None)
(out, err) = sp.communicate()
if sp.returncode not in [0]:
raise RuntimeError("Failed running %s [rc=%s] (%s, %s)"
@@ -123,12 +128,8 @@ def generate_spec_contents(tmpl_fn, revno, version):
def archive_code():
(stdout, _stderr) = tiny_p([sys.executable,
- join(os.getcwd(), 'tar-me')])
- lines = stdout.splitlines()
- revno = lines[0]
- version = lines[1]
- bname = lines[2]
- arc_fn = lines[3]
+ join(os.getcwd(), 'make-tarball')])
+ (revno, version, bname, arc_fn) = stdout.split(None)
return (revno, version, arc_fn)
@@ -136,7 +137,7 @@ def main():
# Clean out the root dir and make sure the dirs we want are in place
root_dir = os.path.expanduser("~/rpmbuild")
- info("Cleaning %s" % (root_dir))
+ info("Cleaning %r" % (root_dir))
if os.path.isdir(root_dir):
shutil.rmtree(root_dir)
arc_dir = os.path.join(root_dir, 'SOURCES')
@@ -147,22 +148,21 @@ def main():
(revno, version, archive_fn) = archive_code()
real_archive_fn = os.path.join(arc_dir, os.path.basename(archive_fn))
shutil.move(archive_fn, real_archive_fn)
- info("Archived code to %s" % (real_archive_fn))
+ info("Archived code to %r" % (real_archive_fn))
# Form the spec file to be used
- tmpl_fn = os.path.join(os.getcwd(), 'brpm.tmpl')
- info("Generated spec file from template %s" % (tmpl_fn))
+ tmpl_fn = os.path.join(os.getcwd(), 'redhat', 'cloud-init.spec')
+ info("Generated spec file from template %r" % (tmpl_fn))
(base_name, arc_name, contents) = generate_spec_contents(tmpl_fn,
revno, version)
spec_fn = os.path.join(root_dir, 'cloud-init.spec')
with open(spec_fn, 'w') as fh:
fh.write(contents)
- info("Wrote spec file to %s" % (spec_fn))
+ info("Wrote spec file to %r" % (spec_fn))
# Now build it!
cmd = ['rpmbuild', '-ba', spec_fn]
- info("Running rpmbuild %s" % (cmd))
- tiny_p(cmd)
+ tiny_p(cmd, capture=False)
info("Rpmbuild completed!")
# Copy the items built to our local dir