diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-04 13:52:34 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-04 13:52:34 -0700 |
commit | 51a8e6ee88e9ee83450215208e2aaad4ad2a2843 (patch) | |
tree | cfdbe27fbe0e353bd48f2ee203d92a9e923bb691 | |
parent | 3cd17b470b70cf4c15f47bfe4f84844b078cd914 (diff) | |
download | vyos-cloud-init-51a8e6ee88e9ee83450215208e2aaad4ad2a2843.tar.gz vyos-cloud-init-51a8e6ee88e9ee83450215208e2aaad4ad2a2843.zip |
1. Make the debian rules file a template (and pass in the daemon-type)
2. Adjust the bddeb to pass this in (as well as other output statement being added)
3. Adjust make-tarball to only archive the bzr versioned files (using --recursive)
-rwxr-xr-x | packages/bddeb | 37 | ||||
-rwxr-xr-x | packages/debian/rules | 3 | ||||
-rwxr-xr-x | packages/make-tarball | 78 |
3 files changed, 81 insertions, 37 deletions
diff --git a/packages/bddeb b/packages/bddeb index eeb64434..b5a70dd8 100755 --- a/packages/bddeb +++ b/packages/bddeb @@ -29,7 +29,7 @@ PKG_MP = { } -def write_debian_folder(root, version, revno): +def write_debian_folder(root, version, revno, daemon_type): deb_dir = util.abs_join(root, 'debian') os.makedirs(deb_dir) @@ -65,8 +65,12 @@ def write_debian_folder(root, version, revno): util.abs_join(deb_dir, 'control'), params={'requires': requires}) + templater.render_to_file(util.abs_join('debian', 'rules'), + util.abs_join(deb_dir, 'rules'), + params={'daemon_type': daemon_type}) + # Just copy the following directly - for base_fn in ['dirs', 'copyright', 'compat', 'pycompat', 'rules']: + for base_fn in ['dirs', 'copyright', 'compat', 'pycompat']: shutil.copy(util.abs_join('debian', base_fn), util.abs_join(deb_dir, base_fn)) @@ -84,6 +88,10 @@ def main(): " (default: %(default)s)"), default=False, action='store_true') + parser.add_argument("-b", "--boot", dest="boot", + help="select boot type (default: %(default)s)", + metavar="TYPE", default='upstart', + choices=('upstart', 'upstart-local')) args = parser.parse_args() capture = True @@ -101,25 +109,33 @@ def main(): (sysout, _stderr) = util.subp(cmd) revno = sysout.strip() + # This is really only a temporary archive + # 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')] (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] - util.subp(cmd) - + 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) + version, revno, args.boot) + # The naming here seems to follow some debian standard + # so it will whine if it is changed... tar_fn = "cloud-init_%s~%s.orig.tar.gz" % (version, revno) + 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')] @@ -127,7 +143,8 @@ def main(): 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'))) with util.chdir(util.abs_join(tdir, 'cloud-init')): cmd = ['debuild'] if not args.sign: @@ -137,14 +154,16 @@ def main(): globs = [] globs.extend(glob.glob("%s/*.deb" % (os.path.join(tdir)))) + link_fn = os.path.join(os.getcwd(), 'cloud-init_all.deb') for fn in globs: base_fn = os.path.basename(fn) shutil.move(fn, base_fn) print("Wrote out debian package %r" % (base_fn)) if fn.endswith('_all.deb'): # Add in the local link - util.del_file('cloud-init_all.deb') - os.symlink(base_fn, 'cloud-init_all.deb') + util.del_file(link_fn) + os.symlink(base_fn, link_fn) + print("Linked %r to %r" % (base_fn, link_fn)) return 0 diff --git a/packages/debian/rules b/packages/debian/rules index 1739f4cf..6814974f 100755 --- a/packages/debian/rules +++ b/packages/debian/rules @@ -7,8 +7,11 @@ binary-install/cloud-init::cloud-init-fixups include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk +DEB_PYTHON_INSTALL_ARGS_ALL += --daemon-type={{daemon_type}} + DEB_DH_INSTALL_SOURCEDIR := debian/tmp cloud-init-fixups: install -d $(DEB_DESTDIR)/etc/rsyslog.d cp tools/21-cloudinit.conf $(DEB_DESTDIR)/etc/rsyslog.d/21-cloudinit.conf + diff --git a/packages/make-tarball b/packages/make-tarball index 479e11af..43a6fc33 100755 --- a/packages/make-tarball +++ b/packages/make-tarball @@ -7,6 +7,8 @@ import subprocess import sys import tempfile +import optparse + # Use the util functions from cloudinit possible_topdir = os.path.normpath(os.path.join(os.path.abspath( @@ -17,51 +19,71 @@ if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")): from cloudinit import util -def main(args): +def find_versioned_files(): + (stdout, _stderr) = util.subp(['bzr', 'ls', '--versioned', '--recursive']) + fns = [fn for fn in stdout.splitlines() + if fn and not fn.startswith('.')] + fns.sort() + return fns - base_fn = None - if args: - base_fn = args[0] - with util.tempdir() as tdir: +def copy(fn, where_to, verbose): + if verbose: + print("Copying %r --> %r" % (fn, where_to)) + if os.path.isfile(fn): + shutil.copy(fn, where_to) + elif os.path.isdir(fn) and not os.path.isdir(where_to): + os.makedirs(where_to) + else: + raise RuntimeError("Do not know how to copy %s" % (fn)) + + +def main(): - if not base_fn: - (stdout, _stderr) = util.subp(['bzr', 'revno']) - revno = stdout.strip() - - cmd = [sys.executable, - util.abs_join(os.pardir, 'tools', 'read-version')] - (stdout, _stderr) = util.subp(cmd) - version = stdout.strip() - base_fn = 'cloud-init-%s-%s' % (version, revno) + parser = optparse.OptionParser() + parser.add_option("-f", "--file", dest="filename", + help="write archive to FILE", metavar="FILE") + parser.add_option("-v", "--verbose", + action="store_true", dest="verbose", default=False, + help="show verbose messaging") + (options, args) = parser.parse_args() + + base_fn = options.filename + if not base_fn: + (stdout, _stderr) = util.subp(['bzr', 'revno']) + revno = stdout.strip() + cmd = [sys.executable, + util.abs_join(os.pardir, 'tools', 'read-version')] + (stdout, _stderr) = util.subp(cmd) + version = stdout.strip() + base_fn = 'cloud-init-%s-%s' % (version, revno) + + with util.tempdir() as tdir: util.ensure_dir(util.abs_join(tdir, base_fn)) arch_fn = '%s.tar.gz' % (base_fn) with util.chdir(os.pardir): - (stdout, _stderr) = util.subp(['bzr', 'ls', '--versioned']) - fns = [fn for fn in stdout.splitlines() - if fn and not fn.startswith('.')] - # TODO - only copy the right files - # ie do a recursive versioned... + fns = find_versioned_files() for fn in fns: - if os.path.isfile(fn): - shutil.copy(fn, util.abs_join(tdir, base_fn, fn)) - else: - shutil.copytree(fn, util.abs_join(tdir, base_fn, fn)) + copy(fn, util.abs_join(tdir, base_fn, fn), + verbose=options.verbose) - cmd = ['tar', '-czf', - util.abs_join(tdir, arch_fn), - '-C', tdir, base_fn] - util.subp(cmd) + arch_full_fn = util.abs_join(tdir, arch_fn) + cmd = ['tar', '-czvf', arch_full_fn, '-C', tdir, base_fn] + if options.verbose: + print("Creating an archive from directory %r to %r" % + (util.abs_join(tdir, base_fn), arch_full_fn)) + util.subp(cmd, capture=(not options.verbose)) shutil.move(util.abs_join(tdir, arch_fn), util.abs_join(os.getcwd(), arch_fn)) + print(os.path.abspath(arch_fn)) return 0 if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) + sys.exit(main()) |