summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-07-09 17:41:22 -0400
committergit-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com>2012-07-09 21:50:36 +0000
commit5fac4d9db423402b0bebf263624c052f696c39e7 (patch)
tree544d72767338c81fc8c0c7829c8dcdecfe969039
parentfa665442a90e9d33de06415dccef1ffa574721df (diff)
downloadcloud-init-git-5fac4d9db423402b0bebf263624c052f696c39e7.tar.gz
0.7.0~bzr583-0ubuntu1 (patches unapplied)
Imported using git-ubuntu import.
-rw-r--r--ChangeLog10
-rw-r--r--Makefile4
-rw-r--r--Requires6
-rwxr-xr-xbin/cloud-init20
-rw-r--r--cloudinit/config/cc_final_message.py17
-rw-r--r--cloudinit/config/cc_rightscale_userdata.py2
-rw-r--r--cloudinit/config/cc_update_etc_hosts.py6
-rw-r--r--cloudinit/sources/DataSourceEc2.py20
-rw-r--r--cloudinit/stages.py20
-rw-r--r--cloudinit/templater.py11
-rw-r--r--cloudinit/url_helper.py2
-rw-r--r--cloudinit/util.py14
-rw-r--r--config/cloud.cfg2
-rw-r--r--debian/changelog9
-rw-r--r--debian/control10
-rwxr-xr-xpackages/bddeb104
-rwxr-xr-xpackages/brpm108
-rw-r--r--packages/debian/changelog5
-rw-r--r--packages/debian/changelog.in6
-rw-r--r--packages/debian/control.in (renamed from packages/debian/control)18
-rwxr-xr-xpackages/debian/rules3
-rwxr-xr-xpackages/make-tarball89
-rw-r--r--packages/redhat/cloud-init.spec.in (renamed from packages/redhat/cloud-init.spec)103
-rwxr-xr-xsysvinit/cloud-config2
-rwxr-xr-xsysvinit/cloud-final2
-rwxr-xr-xsysvinit/cloud-init-local2
-rw-r--r--templates/chef_client.rb.tmpl18
-rw-r--r--templates/hosts.redhat.tmpl13
-rw-r--r--templates/hosts.ubuntu.tmpl15
-rw-r--r--templates/sources.list.tmpl101
-rwxr-xr-xtools/make-dist-tarball (renamed from packages/make-dist-tarball)0
-rwxr-xr-xtools/make-tarball35
-rwxr-xr-xtools/read-dependencies80
-rwxr-xr-xtools/read-version101
-rwxr-xr-xtools/run-pylint10
35 files changed, 448 insertions, 520 deletions
diff --git a/ChangeLog b/ChangeLog
index c3f71b9c..56746574 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
0.7.0:
+ - Add setuptools + cheetah to debian package build dependencies (LP: #1022101)
+ - Adjust the sysvinit local script to provide 'cloud-init-local' and have
+ the cloud-config script depend on that as well.
+ - Add the 'bzr' name to all packages built
+ - Reduce logging levels for certain non-critical cases to DEBUG instead of the
+ previous level of WARNING
- unified binary that activates the various stages
- Now using argparse + subcommands to specify the various CLI options
- a stage module that clearly separates the stages of the different
@@ -69,10 +75,6 @@
level actions to go through standard set of util functions, this greatly
helps in debugging and determining exactly which system actions cloud-init is
performing
- - switching out the templating engine cheetah for tempita since tempita has
- no external dependencies (minus python) while cheetah has many dependencies
- which makes it more difficult to adopt cloud-init in distros that may not
- have those dependencies
- adjust url fetching and url trying to go through a single function that
reads urls in the new 'url helper' file, this helps in tracing, debugging
and knowing which urls are being called and/or posted to from with-in
diff --git a/Makefile b/Makefile
index a96d6b5b..e20d0bee 100644
--- a/Makefile
+++ b/Makefile
@@ -24,10 +24,10 @@ clean:
/var/lib/cloud/
rpm:
- cd packages && ./brpm
+ ./packages/brpm
deb:
- cd packages && ./bddeb
+ ./packages/bddeb
.PHONY: test pylint pyflakes 2to3 clean pep8 rpm deb
diff --git a/Requires b/Requires
index 10be0155..4f9311d5 100644
--- a/Requires
+++ b/Requires
@@ -1,9 +1,7 @@
# Pypi requirements for cloud-init to work
-# Used for templating any files or strings that are considered
-# to be templates, not cheetah since it pulls in alot of extra libs.
-# This one is pretty dinky and does want we want (var substituion)
-Tempita
+# Used for untemplating any files or strings with parameters.
+cheetah
# This is used for any pretty printing of tabular data.
PrettyTable
diff --git a/bin/cloud-init b/bin/cloud-init
index c7863db1..51360270 100755
--- a/bin/cloud-init
+++ b/bin/cloud-init
@@ -45,9 +45,9 @@ from cloudinit.settings import (PER_INSTANCE, PER_ALWAYS, PER_ONCE,
CLOUD_CONFIG)
-# Pretty little welcome message template
-WELCOME_MSG_TPL = ("Cloud-init v. {{version}} running '{{action}}' at "
- "{{timestamp}}. Up {{uptime}} seconds.")
+# Pretty little cheetah formatted welcome message template
+WELCOME_MSG_TPL = ("Cloud-init v. ${version} running '${action}' at "
+ "${timestamp}. Up ${uptime} seconds.")
# Module section template
MOD_SECTION_TPL = "cloud_%s_modules"
@@ -219,13 +219,15 @@ def main_init(name, args):
try:
init.fetch()
except sources.DataSourceNotFoundException:
- util.logexc(LOG, ("No instance datasource found!"
- " Likely bad things to come!"))
- # In the case of cloud-init (net mode) it is a bit
- # more likely that the user would consider it
- # failure if nothing was found. When using
- # upstart it will also mentions job failure
+ # In the case of 'cloud-init init' without '--local' it is a bit
+ # more likely that the user would consider it failure if nothing was
+ # found. When using upstart it will also mentions job failure
# in console log if exit code is != 0.
+ if args.local:
+ LOG.debug("No local datasource found")
+ else:
+ util.logexc(LOG, ("No instance datasource found!"
+ " Likely bad things to come!"))
if not args.force:
if args.local:
return 0
diff --git a/cloudinit/config/cc_final_message.py b/cloudinit/config/cc_final_message.py
index b1caca47..aff03c4e 100644
--- a/cloudinit/config/cc_final_message.py
+++ b/cloudinit/config/cc_final_message.py
@@ -26,23 +26,20 @@ from cloudinit.settings import PER_ALWAYS
frequency = PER_ALWAYS
-FINAL_MESSAGE_DEF = ("Cloud-init v. {{version}} finished at {{timestamp}}."
- " Up {{uptime}} seconds.")
+# Cheetah formated default message
+FINAL_MESSAGE_DEF = ("Cloud-init v. ${version} finished at ${timestamp}."
+ " Up ${uptime} seconds.")
def handle(_name, cfg, cloud, log, args):
- msg_in = None
+ msg_in = ''
if len(args) != 0:
- msg_in = args[0]
+ msg_in = str(args[0])
else:
- msg_in = util.get_cfg_option_str(cfg, "final_message")
-
- if not msg_in:
- template_fn = cloud.get_template_filename('final_message')
- if template_fn:
- msg_in = util.load_file(template_fn)
+ msg_in = util.get_cfg_option_str(cfg, "final_message", "")
+ msg_in = msg_in.strip()
if not msg_in:
msg_in = FINAL_MESSAGE_DEF
diff --git a/cloudinit/config/cc_rightscale_userdata.py b/cloudinit/config/cc_rightscale_userdata.py
index 7a134569..45d41b3f 100644
--- a/cloudinit/config/cc_rightscale_userdata.py
+++ b/cloudinit/config/cc_rightscale_userdata.py
@@ -53,7 +53,7 @@ def handle(name, _cfg, cloud, log, _args):
try:
ud = cloud.get_userdata_raw()
except:
- log.warn("Failed to get raw userdata in module %s", name)
+ log.debug("Failed to get raw userdata in module %s", name)
return
try:
diff --git a/cloudinit/config/cc_update_etc_hosts.py b/cloudinit/config/cc_update_etc_hosts.py
index c148b12e..38108da7 100644
--- a/cloudinit/config/cc_update_etc_hosts.py
+++ b/cloudinit/config/cc_update_etc_hosts.py
@@ -36,11 +36,11 @@ def handle(name, cfg, cloud, log, _args):
return
# Render from a template file
- distro_n = cloud.distro.name
- tpl_fn_name = cloud.get_template_filename("hosts.%s" % (distro_n))
+ tpl_fn_name = cloud.get_template_filename("hosts.%s" %
+ (cloud.distro.name))
if not tpl_fn_name:
raise RuntimeError(("No hosts template could be"
- " found for distro %s") % (distro_n))
+ " found for distro %s") % (cloud.distro.name))
out_fn = cloud.paths.join(False, '/etc/hosts')
templater.render_to_file(tpl_fn_name, out_fn,
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index cb460de1..cde73de3 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -87,6 +87,7 @@ class DataSourceEc2(sources.DataSource):
return self.get_mirror_from_availability_zone()
def get_mirror_from_availability_zone(self, availability_zone=None):
+ # Return type None indicates there is no cloud specific mirror
# Availability is like 'us-west-1b' or 'eu-west-1a'
if availability_zone is None:
availability_zone = self.get_availability_zone()
@@ -94,26 +95,27 @@ class DataSourceEc2(sources.DataSource):
if self.is_vpc():
return None
- # Use the distro to get the mirror
if not availability_zone:
return None
- mirror_tpl = self.distro.get_option('availability_zone_template')
- if not mirror_tpl:
+ mirror_tpl = self.distro.get_option('package_mirror_ec2_template',
+ None)
+
+ if mirror_tpl is None:
return None
+ # in EC2, the 'region' is 'us-east-1' if 'zone' is 'us-east-1a'
tpl_params = {
'zone': availability_zone.strip(),
+ 'region': availability_zone[:-1]
}
mirror_url = mirror_tpl % (tpl_params)
- (max_wait, timeout) = self._get_url_settings()
- worked = uhelp.wait_for_url([mirror_url], max_wait=max_wait,
- timeout=timeout, status_cb=LOG.warn)
- if not worked:
- return None
+ found = util.search_for_mirror([mirror_url])
+ if found is not None:
+ return mirror_url
- return mirror_url
+ return None
def _get_url_settings(self):
mcfg = self.ds_cfg
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index 8fd6aa5d..3beeb36e 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -133,12 +133,24 @@ class Init(object):
if log_file:
util.ensure_file(log_file)
if perms:
- (u, g) = perms.split(':', 1)
- if u == "-1" or u == "None":
+ perms_parted = perms.split(':', 1)
+ u = perms_parted[0]
+ if len(perms_parted) == 2:
+ g = perms_parted[1]
+ else:
+ g = ''
+ u = u.strip()
+ g = g.strip()
+ if u == "-1" or u.lower() == "none":
u = None
- if g == "-1" or g == "None":
+ if g == "-1" or g.lower() == "none":
g = None
- util.chownbyname(log_file, u, g)
+ try:
+ util.chownbyname(log_file, u, g)
+ except OSError:
+ util.logexc(LOG, ("Unable to change the ownership"
+ " of %s to user %s, group %s"),
+ log_file, u, g)
def read_cfg(self, extra_fns=None):
# None check so that we don't keep on re-loading if empty
diff --git a/cloudinit/templater.py b/cloudinit/templater.py
index c4259fa0..77af1270 100644
--- a/cloudinit/templater.py
+++ b/cloudinit/templater.py
@@ -20,13 +20,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from tempita import Template
+from Cheetah.Template import Template
from cloudinit import util
def render_from_file(fn, params):
- return render_string(util.load_file(fn), params, name=fn)
+ return render_string(util.load_file(fn), params)
def render_to_file(fn, outfn, params, mode=0644):
@@ -34,8 +34,7 @@ def render_to_file(fn, outfn, params, mode=0644):
util.write_file(outfn, contents, mode=mode)
-def render_string(content, params, name=None):
- tpl = Template(content, name=name)
+def render_string(content, params):
if not params:
- params = dict()
- return tpl.substitute(params)
+ params = {}
+ return Template(content, searchList=[params]).respond()
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py
index dbf72392..732d6aec 100644
--- a/cloudinit/url_helper.py
+++ b/cloudinit/url_helper.py
@@ -127,7 +127,7 @@ def readurl(url, data=None, timeout=None,
time.sleep(sec_between)
# Didn't work out
- LOG.warn("Failed reading from %s after %s attempts", url, attempts)
+ LOG.debug("Failed reading from %s after %s attempts", url, attempts)
# It must of errored at least once for code
# to get here so re-raise the last error
diff --git a/cloudinit/util.py b/cloudinit/util.py
index d7dd20b5..e591e306 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -19,6 +19,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# pylint: disable=C0302
from StringIO import StringIO
@@ -805,7 +807,10 @@ def is_resolvable_url(url):
def search_for_mirror(candidates):
- """ Search through a list of mirror urls for one that works """
+ """
+ Search through a list of mirror urls for one that works
+ This needs to return quickly.
+ """
for cand in candidates:
try:
if is_resolvable_url(cand):
@@ -932,12 +937,9 @@ def chownbyname(fname, user=None, group=None):
uid = pwd.getpwnam(user).pw_uid
if group:
gid = grp.getgrnam(group).gr_gid
- except KeyError:
- logexc(LOG, ("Failed changing the ownership of %s using username %s and"
- " groupname %s (do they exist?)"), fname, user, group)
- return False
+ except KeyError as e:
+ raise OSError("Unknown user or group: %s" % (e))
chownbyid(fname, uid, gid)
- return True
# Always returns well formated values
diff --git a/config/cloud.cfg b/config/cloud.cfg
index 5dae4047..cb51d061 100644
--- a/config/cloud.cfg
+++ b/config/cloud.cfg
@@ -70,5 +70,5 @@ system_info:
templates_dir: /etc/cloud/templates/
upstart_dir: /etc/init/
package_mirror: http://archive.ubuntu.com/ubuntu
- availability_zone_template: http://%(zone)s.ec2.archive.ubuntu.com/ubuntu/
+ package_mirror_ec2_template: http://%(region)s.ec2.archive.ubuntu.com/ubuntu/
ssh_svcname: ssh
diff --git a/debian/changelog b/debian/changelog
index 95c01928..cdcf051f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+cloud-init (0.7.0~bzr583-0ubuntu1) quantal; urgency=low
+
+ * New upstream snapshot.
+ * debian/control: wrap-and-sort
+ * debian/control: actually depend on software-properties-common
+ * debian/control: depend on python-cheetah again instead of python-tempita
+
+ -- Scott Moser <smoser@ubuntu.com> Mon, 09 Jul 2012 17:41:22 -0400
+
cloud-init (0.7.0~bzr564-0ubuntu2) quantal; urgency=low
* debian/control: Build-Depends on python-setuptools (LP: #1022101)
diff --git a/debian/control b/debian/control
index 73bcee15..f0bba70c 100644
--- a/debian/control
+++ b/debian/control
@@ -5,29 +5,29 @@ Maintainer: Scott Moser <smoser@ubuntu.com>
Build-Depends: cdbs,
debhelper (>= 5.0.38),
po-debconf,
- python-setuptools,
pyflakes,
pylint,
python (>= 2.6.6-3~),
python-mocker,
- python-nose
+ python-nose,
+ python-setuptools
XS-Python-Version: all
Standards-Version: 3.9.3
Package: cloud-init
Architecture: all
-Depends: add-apt-repository,
- cloud-utils,
+Depends: cloud-utils,
ifupdown (>= 0.6.10ubuntu5),
procps,
python,
python-argparse,
python-boto,
+ python-cheetah,
python-configobj,
python-oauth,
python-prettytable,
- python-tempita,
python-yaml,
+ software-properties-common,
${misc:Depends},
${python:Depends}
Provides: ec2-init
diff --git a/packages/bddeb b/packages/bddeb
index 10ad08b3..ddc0776f 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
@@ -17,24 +25,26 @@ from cloudinit import util
import argparse
# Package names that will showup in requires to what we can actually
-# use in our debian 'control' file
+# use in our debian 'control' file, this is a translation of the 'requires'
+# file pypi package name to a debian/ubuntu package name.
PKG_MP = {
- 'tempita': 'python-tempita',
'boto': 'python-boto',
'configobj': 'python-configobj',
'oauth': 'python-oauth',
- 'yaml': 'python-yaml',
+ 'pyyaml': 'python-yaml',
'prettytable': 'python-prettytable',
'argparse': 'python-argparse',
+ 'cheetah': 'python-cheetah',
}
-def write_debian_folder(root, version, revno, init_sys):
+def write_debian_folder(root, version, revno):
deb_dir = util.abs_join(root, 'debian')
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.in'),
util.abs_join(deb_dir, 'changelog'),
params={
'version': version,
@@ -42,36 +52,29 @@ 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
pkgs = [p.lower().strip() for p in stdout.splitlines()]
+
+ # Map to known packages
requires = []
for p in pkgs:
- tgt_pkg = None
- for name in PKG_MP.keys():
- if p.find(name) != -1:
- tgt_pkg = PKG_MP.get(name)
- break
+ tgt_pkg = PKG_MP.get(p)
if not tgt_pkg:
- raise RuntimeError(("Do not know how to translate %s to "
- " a known package") % (p))
+ raise RuntimeError(("Do not know how to translate pypi dependency"
+ " %r to a known package") % (p))
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.in'),
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={'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),
+ for base_fn in ['dirs', 'copyright', 'compat', 'pycompat', 'rules']:
+ shutil.copy(util.abs_join(find_root(),
+ 'packages', 'debian', base_fn),
util.abs_join(deb_dir, base_fn))
@@ -88,10 +91,6 @@ 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
@@ -100,8 +99,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,8 +111,7 @@ 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))
@@ -123,30 +120,35 @@ def main():
print("Extracting temporary tarball %r" % (tmp_arch_fn))
cmd = ['tar', '-xvzf', tmp_arch_fn, '-C', tdir]
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'))
+ extracted_name = tmp_arch_fn[:-len('.tar.gz')]
+ os.remove(tmp_arch_fn)
- 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)
+ xdir = util.abs_join(tdir, 'cloud-init')
+ shutil.move(extracted_name, xdir)
+
+ print("Creating a debian/ folder in %r" % (xdir))
+ write_debian_folder(xdir, version, revno)
# 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))
+ print("Archiving the adjusted source into %r" %
+ (util.abs_join(tdir, 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')))
- with util.chdir(util.abs_join(tdir, 'cloud-init')):
- cmd = ['debuild']
+ # Copy it locally for reference
+ shutil.copy(util.abs_join(tdir, tar_fn),
+ util.abs_join(os.getcwd(), tar_fn))
+ print("Copied that archive to %r for local usage (if desired)." %
+ (util.abs_join(os.getcwd(), tar_fn)))
+
+ print("Running 'debuild' in %r" % (xdir))
+ with util.chdir(xdir):
+ cmd = ['debuild', '--preserve-envvar', 'INIT_SYSTEM']
if not args.sign:
cmd.extend(['-us', '-uc'])
util.subp(cmd, capture=capture)
diff --git a/packages/brpm b/packages/brpm
index 1d05bd2a..77de0cf2 100755
--- a/packages/brpm
+++ b/packages/brpm
@@ -1,5 +1,6 @@
#!/usr/bin/python
+import argparse
import contextlib
import glob
import os
@@ -9,31 +10,42 @@ import sys
import tempfile
import re
-import argparse
+from datetime import datetime
+
+
+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
-from datetime import datetime
-
-
# Mapping of expected packages to there full name...
+# this is a translation of the 'requires'
+# file pypi package name to a redhat/fedora package name.
PKG_MP = {
'boto': 'python-boto',
- 'tempita': 'python-tempita',
+ 'cheetah': 'python-cheetah',
'prettytable': 'python-prettytable',
'oauth': 'python-oauth',
'configobj': 'python-configobj',
- 'yaml': 'PyYAML',
- 'argparse': 'python-argparse'
+ 'pyyaml': 'PyYAML',
+ 'argparse': 'python-argparse',
}
+# Subdirectories of the ~/rpmbuild dir
+RPM_BUILD_SUBDIRS = ['BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS']
+
def get_log_header(version):
# Try to find the version in the tags output
@@ -79,11 +91,10 @@ def format_change_line(ds, who, comment=None):
return "* %s" % (d)
-def generate_spec_contents(args, tmpl_fn):
+def generate_spec_contents(args, tmpl_fn, arc_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()
@@ -95,34 +106,26 @@ def generate_spec_contents(args, tmpl_fn):
subs = {}
subs['version'] = version
subs['revno'] = revno
- subs['release'] = revno
- subs['archive_name'] = '%{name}-%{version}-' + revno + '.tar.gz'
- subs['bd_requires'] = ['python-devel', 'python-setuptools']
+ subs['release'] = "bzr%s" % (revno)
+ subs['archive_name'] = arc_fn
- 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
pkgs = [p.lower().strip() for p in stdout.splitlines()]
# Map to known packages
requires = []
for p in pkgs:
- tgt_pkg = None
- for name in PKG_MP.keys():
- if p.find(name) != -1:
- tgt_pkg = PKG_MP.get(name)
- break
+ tgt_pkg = PKG_MP.get(p)
if not tgt_pkg:
- raise RuntimeError(("Do not know how to translate %s to "
- " a known package") % (p))
+ raise RuntimeError(("Do not know how to translate pypi dependency"
+ " %r to a known package") % (p))
else:
requires.append(tgt_pkg)
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():
@@ -135,15 +138,10 @@ def generate_spec_contents(args, tmpl_fn):
changelog_lines.append(line)
subs['changelog'] = "\n".join(changelog_lines)
- if args.boot == 'initd':
- subs['init_d'] = True
- subs['init_d_local'] = False
- elif args.boot == 'initd-local':
- subs['init_d'] = True
- subs['init_d_local'] = True
+ if args.boot == 'sysvinit':
+ subs['sysvinit'] = True
else:
- subs['init_d'] = False
- subs['init_d_local'] = False
+ subs['sysvinit'] = False
if args.boot == 'systemd':
subs['systemd'] = True
@@ -159,8 +157,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)"),
@@ -175,39 +173,49 @@ def main():
root_dir = os.path.expanduser("~/rpmbuild")
if os.path.isdir(root_dir):
shutil.rmtree(root_dir)
+
arc_dir = util.abs_join(root_dir, 'SOURCES')
- util.ensure_dirs([root_dir, arc_dir])
+ build_dirs = [root_dir, arc_dir]
+ for dname in RPM_BUILD_SUBDIRS:
+ build_dirs.append(util.abs_join(root_dir, dname))
+ build_dirs.sort()
+ util.ensure_dirs(build_dirs)
# 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)
+ print("Archived the code in %r" % (real_archive_fn))
# Form the spec file to be used
- tmpl_fn = util.abs_join(os.getcwd(), 'redhat', 'cloud-init.spec')
- contents = generate_spec_contents(args, tmpl_fn)
- spec_fn = os.path.join(root_dir, 'cloud-init.spec')
+ tmpl_fn = util.abs_join(find_root(), 'packages',
+ 'redhat', 'cloud-init.spec.in')
+ contents = generate_spec_contents(args, tmpl_fn,
+ os.path.basename(archive_fn))
+ spec_fn = util.abs_join(root_dir, 'cloud-init.spec')
util.write_file(spec_fn, contents)
+ print("Created spec file at %r" % (spec_fn))
# Now build it!
- cmd = ['rpmbuild', '-ba', spec_fn]
+ print("Running 'rpmbuild' in %r" % (root_dir))
+ cmd = ['rpmbuild', '--clean',
+ '-ba', spec_fn]
util.subp(cmd, capture=capture)
# 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)
- print(tgt_fn)
+ print("Wrote out redhat package %r" % (tgt_fn))
return 0
diff --git a/packages/debian/changelog b/packages/debian/changelog
deleted file mode 100644
index ac5bcf98..00000000
--- a/packages/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-cloud-init ({{version}}~{{revision}}-1) UNRELEASED; urgency=low
-
- * build
-
- -- Scott Moser <smoser@ubuntu.com> Fri, 16 Dec 2011 11:50:25 -0500
diff --git a/packages/debian/changelog.in b/packages/debian/changelog.in
new file mode 100644
index 00000000..eda08c57
--- /dev/null
+++ b/packages/debian/changelog.in
@@ -0,0 +1,6 @@
+## This is a cheetah template
+cloud-init (${version}~${revision}-1) UNRELEASED; urgency=low
+
+ * build
+
+ -- Scott Moser <smoser@ubuntu.com> Fri, 16 Dec 2011 11:50:25 -0500
diff --git a/packages/debian/control b/packages/debian/control.in
index e00901af..4e151e3e 100644
--- a/packages/debian/control
+++ b/packages/debian/control.in
@@ -1,14 +1,18 @@
+## This is a cheetah template
Source: cloud-init
Section: admin
Priority: extra
Maintainer: Scott Moser <smoser@ubuntu.com>
Build-Depends: cdbs,
- debhelper (>= 5.0.38),
+ debhelper (>= 5.0.38),
python (>= 2.6.6-3~),
python-nose,
pyflakes,
pylint,
+ python-setuptools,
+ python-cheetah,
python-mocker,
+ python-setuptools
XS-Python-Version: all
Standards-Version: 3.9.3
@@ -17,13 +21,13 @@ Architecture: all
Depends: cloud-utils,
procps,
python,
-{{for r in requires}}
- {{r}},
-{{endfor}}
+#for $r in $requires
+ ${r},
+#end for
python-software-properties,
- ${misc:Depends},
- ${python:Depends}
-XB-Python-Version: ${python:Versions}
+ \${misc:Depends},
+ \${python:Depends}
+XB-Python-Version: \${python:Versions}
Description: Init scripts for cloud instances
Cloud instances need special scripts to run during initialisation
to retrieve and install ssh keys and to let the user run various scripts.
diff --git a/packages/debian/rules b/packages/debian/rules
index 87cd6538..7623ac9d 100755
--- a/packages/debian/rules
+++ b/packages/debian/rules
@@ -1,13 +1,14 @@
#!/usr/bin/make -f
DEB_PYTHON2_MODULE_PACKAGES = cloud-init
+INIT_SYSTEM ?= upstart
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 += --init-system={{init_sys}}
+DEB_PYTHON_INSTALL_ARGS_ALL += --init-system=$(INIT_SYSTEM)
DEB_DH_INSTALL_SOURCEDIR := debian/tmp
diff --git a/packages/make-tarball b/packages/make-tarball
deleted file mode 100755
index 43a6fc33..00000000
--- a/packages/make-tarball
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/python
-
-import contextlib
-import os
-import shutil
-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(
- 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)
-
-from cloudinit import util
-
-
-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
-
-
-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():
-
- 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):
- fns = find_versioned_files()
- for fn in fns:
- copy(fn, util.abs_join(tdir, base_fn, fn),
- verbose=options.verbose)
-
- 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())
-
diff --git a/packages/redhat/cloud-init.spec b/packages/redhat/cloud-init.spec.in
index d0f83a4b..35b27beb 100644
--- a/packages/redhat/cloud-init.spec
+++ b/packages/redhat/cloud-init.spec.in
@@ -1,3 +1,4 @@
+## This is a cheetah template
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
# See: http://www.zarb.org/~jasonc/macros.php
@@ -5,20 +6,21 @@
# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
Name: cloud-init
-Version: {{version}}
-Release: {{release}}%{?dist}
+Version: ${version}
+Release: ${release}%{?dist}
Summary: Cloud instance init scripts
Group: System Environment/Base
License: GPLv3
URL: http://launchpad.net/cloud-init
-Source0: {{archive_name}}
+Source0: ${archive_name}
BuildArch: noarch
BuildRoot: %{_tmppath}
BuildRequires: python-devel
BuildRequires: python-setuptools
+BuildRequires: python-cheetah
# System util packages needed
Requires: shadow-utils
@@ -30,23 +32,23 @@ Requires: procps
Requires: shadow-utils
# Install pypi 'dynamic' requirements
-{{for r in requires}}
-Requires: {{r}}
-{{endfor}}
+#for $r in $requires
+Requires: ${r}
+#end for
-{{if init_d}}
+#if $sysvinit
Requires(post): chkconfig
Requires(postun): initscripts
Requires(preun): chkconfig
Requires(preun): initscripts
-{{endif}}
+#end if
-{{if systemd}}
+#if $systemd
BuildRequires: systemd-units
Requires(post): systemd-units
Requires(postun): systemd-units
Requires(preun): systemd-units
-{{endif}}
+#end if
%description
Cloud-init is a set of init scripts for cloud instances. Cloud instances
@@ -54,104 +56,89 @@ need special scripts to run during initialization to retrieve and install
ssh keys and to let the user run various scripts.
%prep
-%setup -q -n %{name}-%{version}-{{revno}}
+%setup -q -n %{name}-%{version}~${release}
%build
%{__python} setup.py build
%install
-rm -rf $RPM_BUILD_ROOT
+rm -rf \$RPM_BUILD_ROOT
%{__python} setup.py install -O1 \
- --skip-build --root $RPM_BUILD_ROOT \
- --init-system={{init_sys}}
+ --skip-build --root \$RPM_BUILD_ROOT \
+ --init-system=${init_sys}
# Note that /etc/rsyslog.d didn't exist by default until F15.
# el6 request: https://bugzilla.redhat.com/show_bug.cgi?id=740420
-mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d
+mkdir -p \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d
cp -p tools/21-cloudinit.conf \
- $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
+ \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
%clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf \$RPM_BUILD_ROOT
%post
-{{if systemd}}
-if [ $1 -eq 1 ]
+#if $systemd
+if [ \$1 -eq 1 ]
then
/bin/systemctl enable cloud-config.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-final.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-init.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || :
fi
-{{endif}}
+#end if
-{{if init_d_local}}
+#if $sysvinit
/sbin/chkconfig --add %{_initrddir}/cloud-init-local
-{{elif init_d}}
/sbin/chkconfig --add %{_initrddir}/cloud-init
-{{endif}}
-{{if init_d}}
/sbin/chkconfig --add %{_initrddir}/cloud-config
/sbin/chkconfig --add %{_initrddir}/cloud-final
-{{endif}}
+#end if
%preun
-{{if init_d_local}}
-if [ $1 -eq 0 ]
+#if $sysvinit
+if [ \$1 -eq 0 ]
then
- /sbin/service cloud-init-local stop >/dev/null 2>&1
- /sbin/chkconfig --del cloud-init-local
+ /sbin/service cloud-init stop >/dev/null 2>&1 || :
+ /sbin/chkconfig --del cloud-init || :
+ /sbin/service cloud-init-local stop >/dev/null 2>&1 || :
+ /sbin/chkconfig --del cloud-init-local || :
+ /sbin/service cloud-config stop >/dev/null 2>&1 || :
+ /sbin/chkconfig --del cloud-config || :
+ /sbin/service cloud-final stop >/dev/null 2>&1 || :
+ /sbin/chkconfig --del cloud-final || :
fi
-{{elif init_d}}
-if [ $1 -eq 0 ]
-then
- /sbin/service cloud-init stop >/dev/null 2>&1
- /sbin/chkconfig --del cloud-init
-fi
-{{endif}}
-{{if init_d}}
-if [ $1 -eq 0 ]
-then
- /sbin/service cloud-config stop >/dev/null 2>&1
- /sbin/chkconfig --del cloud-config
- /sbin/service cloud-final stop >/dev/null 2>&1
- /sbin/chkconfig --del cloud-final
-fi
-{{endif}}
+#end if
-{{if systemd}}
-if [ $1 -eq 0 ]
+#if $systemd
+if [ \$1 -eq 0 ]
then
/bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
fi
-{{endif}}
+#end if
%postun
-{{if systemd}}
+#if $systemd
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-{{endif}}
+#end if
%files
-{{if init_d}}
+#if $sysvinit
%attr(0755, root, root) %{_initddir}/cloud-config
%attr(0755, root, root) %{_initddir}/cloud-final
-{{endif}}
-{{if init_d_local}}
%attr(0755, root, root) %{_initddir}/cloud-init-local
-{{elif init_d}}
%attr(0755, root, root) %{_initddir}/cloud-init
-{{endif}}
+#end if
-{{if systemd}}
+#if $systemd
%{_unitdir}/cloud-*
-{{endif}}
+#end if
# Program binaries
%{_bindir}/cloud-init*
@@ -180,4 +167,4 @@ fi
%changelog
-{{changelog}}
+${changelog}
diff --git a/sysvinit/cloud-config b/sysvinit/cloud-config
index dd0bca8b..e587446d 100755
--- a/sysvinit/cloud-config
+++ b/sysvinit/cloud-config
@@ -25,7 +25,7 @@
### BEGIN INIT INFO
# Provides: cloud-config
-# Required-Start: cloud-init
+# Required-Start: cloud-init cloud-init-local
# Should-Start: $time
# Required-Stop:
# Should-Stop:
diff --git a/sysvinit/cloud-final b/sysvinit/cloud-final
index 2e462c17..5deb8457 100755
--- a/sysvinit/cloud-final
+++ b/sysvinit/cloud-final
@@ -25,7 +25,7 @@
### BEGIN INIT INFO
# Provides: cloud-final
-# Required-Start: $all cloud-init cloud-config
+# Required-Start: $all cloud-config
# Should-Start: $time
# Required-Stop:
# Should-Stop:
diff --git a/sysvinit/cloud-init-local b/sysvinit/cloud-init-local
index bf5d409a..0c63b9b0 100755
--- a/sysvinit/cloud-init-local
+++ b/sysvinit/cloud-init-local
@@ -24,7 +24,7 @@
# Also based on dhcpd in RHEL (for comparison)
### BEGIN INIT INFO
-# Provides: cloud-init
+# Provides: cloud-init-local
# Required-Start: $local_fs $remote_fs
# Should-Start: $time
# Required-Stop:
diff --git a/templates/chef_client.rb.tmpl b/templates/chef_client.rb.tmpl
index 35123ced..7981cba7 100644
--- a/templates/chef_client.rb.tmpl
+++ b/templates/chef_client.rb.tmpl
@@ -1,12 +1,22 @@
+#*
+ This file is only utilized if the module 'cc_chef' is enabled in
+ cloud-config. Specifically, in order to enable it
+ you need to add the following to config:
+ chef:
+ validation_key: XYZ
+ validation_cert: XYZ
+ validation_name: XYZ
+ server_url: XYZ
+*#
log_level :info
log_location "/var/log/chef/client.log"
ssl_verify_mode :verify_none
-validation_client_name "{{validation_name}}"
+validation_client_name "$validation_name"
validation_key "/etc/chef/validation.pem"
client_key "/etc/chef/client.pem"
-chef_server_url "{{server_url}}"
-environment "{{environment}}"
-node_name "{{node_name}}"
+chef_server_url "$server_url"
+environment "$environment"
+node_name "$node_name"
json_attribs "/etc/chef/firstboot.json"
file_cache_path "/var/cache/chef"
file_backup_path "/var/backups/chef"
diff --git a/templates/hosts.redhat.tmpl b/templates/hosts.redhat.tmpl
index cfc40668..80459d95 100644
--- a/templates/hosts.redhat.tmpl
+++ b/templates/hosts.redhat.tmpl
@@ -1,22 +1,23 @@
-{{# This file /etc/cloud/templates/hosts.tmpl is only utilized
+#*
+ This file /etc/cloud/templates/hosts.redhat.tmpl is only utilized
if enabled in cloud-config. Specifically, in order to enable it
you need to add the following to config:
- manage_etc_hosts: True}}
-#
+ manage_etc_hosts: True
+*#
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
-# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
+# a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
-127.0.0.1 {{fqdn}} {{hostname}}
+127.0.0.1 ${fqdn} ${hostname}
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
# The following lines are desirable for IPv6 capable hosts
-::1 {{fqdn}} {{hostname}}
+::1 ${fqdn} ${hostname}
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
diff --git a/templates/hosts.ubuntu.tmpl b/templates/hosts.ubuntu.tmpl
index 9eebe971..ae120b02 100644
--- a/templates/hosts.ubuntu.tmpl
+++ b/templates/hosts.ubuntu.tmpl
@@ -1,7 +1,9 @@
-{{# This file /etc/cloud/templates/hosts.tmpl is only utilized
- if enabled in cloud-config. Specifically, in order to enable it
- you need to add the following to config:
- manage_etc_hosts: True}}
+## This file (/etc/cloud/templates/hosts.tmpl) is only utilized
+## if enabled in cloud-config. Specifically, in order to enable it
+## you need to add the following to config:
+## manage_etc_hosts: True
+##
+## Note, double-hash commented lines will not appear in /etc/hosts
#
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
@@ -10,8 +12,8 @@
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
-# The following lines are desirable for IPv4 capable hosts
-127.0.1.1 {{fqdn}} {{hostname}}
+## The value '$hostname' will be replaced with the local-hostname
+127.0.1.1 $fqdn $hostname
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
@@ -21,4 +23,3 @@ ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
-
diff --git a/templates/sources.list.tmpl b/templates/sources.list.tmpl
index 8acbd7d5..f702025f 100644
--- a/templates/sources.list.tmpl
+++ b/templates/sources.list.tmpl
@@ -1,59 +1,60 @@
-# Note, this file is written by cloud-init on first boot of an instance
-# modifications made here will not survive a re-bundle.
-# if you wish to make changes you can:
-# a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
-# or do the same in user-data
-# b.) add sources in /etc/apt/sources.list.d
-# c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
+\## Note, this file is written by cloud-init on first boot of an instance
+\## modifications made here will not survive a re-bundle.
+\## if you wish to make changes you can:
+\## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
+\## or do the same in user-data
+\## b.) add sources in /etc/apt/sources.list.d
+\## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
+\###
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
-deb {{mirror}} {{codename}} main
-deb-src {{mirror}} {{codename}} main
+deb $mirror $codename main
+deb-src $mirror $codename main
-# Major bug fix updates produced after the final release of the
-# distribution.
-deb {{mirror}} {{codename}}-updates main
-deb-src {{mirror}} {{codename}}-updates main
+\## Major bug fix updates produced after the final release of the
+\## distribution.
+deb $mirror $codename-updates main
+deb-src $mirror $codename-updates main
-# N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
-# team. Also, please note that software in universe WILL NOT receive any
-# review or updates from the Ubuntu security team.
-deb {{mirror}} {{codename}} universe
-deb-src {{mirror}} {{codename}} universe
-deb {{mirror}} {{codename}}-updates universe
-deb-src {{mirror}} {{codename}}-updates universe
+\## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
+\## team. Also, please note that software in universe WILL NOT receive any
+\## review or updates from the Ubuntu security team.
+deb $mirror $codename universe
+deb-src $mirror $codename universe
+deb $mirror $codename-updates universe
+deb-src $mirror $codename-updates universe
-# N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
-# team, and may not be under a free licence. Please satisfy yourself as to
-# your rights to use the software. Also, please note that software in
-# multiverse WILL NOT receive any review or updates from the Ubuntu
-# security team.
-# deb {{mirror}} {{codename}} multiverse
-# deb-src {{mirror}} {{codename}} multiverse
-# deb {{mirror}} {{codename}}-updates multiverse
-# deb-src {{mirror}} {{codename}}-updates multiverse
+\## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
+\## team, and may not be under a free licence. Please satisfy yourself as to
+\## your rights to use the software. Also, please note that software in
+\## multiverse WILL NOT receive any review or updates from the Ubuntu
+\## security team.
+# deb $mirror $codename multiverse
+# deb-src $mirror $codename multiverse
+# deb $mirror $codename-updates multiverse
+# deb-src $mirror $codename-updates multiverse
-# Uncomment the following two lines to add software from the 'backports'
-# repository.
-# N.B. software from this repository may not have been tested as
-# extensively as that contained in the main release, although it includes
-# newer versions of some applications which may provide useful features.
-# Also, please note that software in backports WILL NOT receive any review
-# or updates from the Ubuntu security team.
-# deb {{mirror}} {{codename}}-backports main restricted universe multiverse
-# deb-src {{mirror}} {{codename}}-backports main restricted universe multiverse
+\## Uncomment the following two lines to add software from the 'backports'
+\## repository.
+\## N.B. software from this repository may not have been tested as
+\## extensively as that contained in the main release, although it includes
+\## newer versions of some applications which may provide useful features.
+\## Also, please note that software in backports WILL NOT receive any review
+\## or updates from the Ubuntu security team.
+# deb $mirror $codename-backports main restricted universe multiverse
+# deb-src $mirror $codename-backports main restricted universe multiverse
-# Uncomment the following two lines to add software from Canonical's
-# 'partner' repository.
-# This software is not part of Ubuntu, but is offered by Canonical and the
-# respective vendors as a service to Ubuntu users.
-# deb http://archive.canonical.com/ubuntu {{codename}} partner
-# deb-src http://archive.canonical.com/ubuntu {{codename}} partner
+\## Uncomment the following two lines to add software from Canonical's
+\## 'partner' repository.
+\## This software is not part of Ubuntu, but is offered by Canonical and the
+\## respective vendors as a service to Ubuntu users.
+# deb http://archive.canonical.com/ubuntu $codename partner
+# deb-src http://archive.canonical.com/ubuntu $codename partner
-deb http://security.ubuntu.com/ubuntu {{codename}}-security main
-deb-src http://security.ubuntu.com/ubuntu {{codename}}-security main
-deb http://security.ubuntu.com/ubuntu {{codename}}-security universe
-deb-src http://security.ubuntu.com/ubuntu {{codename}}-security universe
-# deb http://security.ubuntu.com/ubuntu {{codename}}-security multiverse
-# deb-src http://security.ubuntu.com/ubuntu {{codename}}-security multiverse
+deb http://security.ubuntu.com/ubuntu $codename-security main
+deb-src http://security.ubuntu.com/ubuntu $codename-security main
+deb http://security.ubuntu.com/ubuntu $codename-security universe
+deb-src http://security.ubuntu.com/ubuntu $codename-security universe
+# deb http://security.ubuntu.com/ubuntu $codename-security multiverse
+# deb-src http://security.ubuntu.com/ubuntu $codename-security multiverse
diff --git a/packages/make-dist-tarball b/tools/make-dist-tarball
index 622283bd..622283bd 100755
--- a/packages/make-dist-tarball
+++ b/tools/make-dist-tarball
diff --git a/tools/make-tarball b/tools/make-tarball
new file mode 100755
index 00000000..47979f5b
--- /dev/null
+++ b/tools/make-tarball
@@ -0,0 +1,35 @@
+#!/bin/sh
+set -e
+
+find_root() {
+ local topd
+ if [ -z "${CLOUD_INIT_TOP_D}" ]; then
+ topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
+ else
+ topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
+ fi
+ [ $? -eq 0 -a -f "${topd}/setup.py" ] || return
+ ROOT_DIR="$topd"
+}
+
+if ! find_root; then
+ echo "Unable to locate 'setup.py' file that should" \
+ "exist in the cloud-init root directory." 1>&2
+ exit 1;
+fi
+
+if [ ! -z "$1" ]; then
+ ARCHIVE_FN="$1"
+else
+ REVNO=$(bzr revno $ROOT_DIR)
+ VERSION=$($ROOT_DIR/tools/read-version)
+ ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
+fi
+
+FILES=$(cd $ROOT_DIR && bzr ls --versioned --recursive)
+echo "$FILES" | tar czf $ARCHIVE_FN \
+ -C "$ROOT_DIR" \
+ --transform "s,^,cloud-init-$VERSION~bzr$REVNO/," \
+ --no-recursion --files-from -
+
+echo "$ARCHIVE_FN"
diff --git a/tools/read-dependencies b/tools/read-dependencies
index 72e1e095..4c88aa87 100755
--- a/tools/read-dependencies
+++ b/tools/read-dependencies
@@ -1,45 +1,35 @@
-#!/usr/bin/python
-# vi: ts=4 expandtab
-
-import os
-import sys
-import re
-
-
-def parse_requires(fn):
- requires = []
- with open(fn, 'r') as fh:
- lines = fh.read().splitlines()
- for line in lines:
- line = line.strip()
- if not line or line[0] == '#':
- continue
- else:
- requires.append(line)
- return requires
-
-
-def find_requires(args):
- p_files = []
- if args:
- p_files.append(args[0])
- p_files.append(os.path.join(os.pardir, "Requires"))
- p_files.append(os.path.join(os.getcwd(), 'Requires'))
- found = None
- for fn in p_files:
- if os.path.isfile(fn):
- found = fn
- break
- return found
-
-
-if __name__ == '__main__':
- run_args = sys.argv[1:]
- fn = find_requires(run_args)
- if not fn:
- sys.stderr.write("'Requires' file not found!\n")
- sys.exit(1)
- else:
- deps = parse_requires(fn)
- for entry in deps:
- print entry
+#!/bin/sh
+
+set -e
+
+find_root() {
+ local topd
+ if [ -z "${CLOUD_INIT_TOP_D}" ]; then
+ topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
+ else
+ topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
+ fi
+ [ $? -eq 0 -a -f "${topd}/setup.py" ] || return
+ ROOT_DIR="$topd"
+}
+
+if ! find_root; then
+ echo "Unable to locate 'setup.py' file that should" \
+ "exist in the cloud-init root directory." 1>&2
+ exit 1;
+fi
+
+REQUIRES="$ROOT_DIR/Requires"
+
+if [ ! -e "$REQUIRES" ]
+then
+ echo "Unable to find 'Requires' file located at $REQUIRES"
+ exit 1
+fi
+
+# Filter out comments and empty liens
+DEPS=$(cat $REQUIRES | grep -Pv "^\s*#" | grep -Pv '^\s*$')
+echo "$DEPS" | sort -d -f
+
+
+
diff --git a/tools/read-version b/tools/read-version
index e6167a2c..323357fe 100755
--- a/tools/read-version
+++ b/tools/read-version
@@ -1,70 +1,31 @@
-#!/usr/bin/python
-# vi: ts=4 expandtab
-
-import os
-import sys
-import re
-
-from distutils import version as ver
-
-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)
-
-from cloudinit import version as cver
-
-def parse_versions(fn):
- with open(fn, 'r') as fh:
- lines = fh.read().splitlines()
- versions = []
- for line in lines:
- line = line.strip()
- if line.startswith("-") or not line:
- continue
- if not re.match(r"[\d]", line):
- continue
- line = line.strip(":")
- if (re.match(r"^[\d+]\.[\d+]\.[\d+]$", line) or
- re.match(r"^[\d+]\.[\d+]$", line)):
- versions.append(line)
- return versions
-
-def find_changelog(args):
- p_files = []
- if args:
- p_files.append(args[0])
- p_files.append(os.path.join(os.pardir, "ChangeLog"))
- p_files.append(os.path.join(os.getcwd(), 'ChangeLog'))
- found = None
- for fn in p_files:
- if os.path.isfile(fn):
- found = fn
- break
- return found
-
-
-if __name__ == '__main__':
- run_args = sys.argv[1:]
- fn = find_changelog(run_args)
- if not fn:
- sys.stderr.write("'ChangeLog' file not found!\n")
- sys.exit(1)
- else:
- versions = parse_versions(fn)
- if not versions:
- sys.stderr.write("No versions found in %s!\n" % (fn))
- sys.exit(1)
- else:
- # Check that the code version is the same
- # as the version we found!
- ch_ver = versions[0].strip()
- code_ver = cver.version()
- ch_ver_obj = ver.StrictVersion(ch_ver)
- if ch_ver_obj != code_ver:
- sys.stderr.write(("Code version %s does not match"
- " changelog version %s\n") %
- (code_ver, ch_ver_obj))
- sys.exit(1)
- sys.stdout.write(ch_ver)
- sys.exit(0)
+#!/bin/sh
+
+set -e
+
+find_root() {
+ local topd
+ if [ -z "${CLOUD_INIT_TOP_D}" ]; then
+ topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
+ else
+ topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
+ fi
+ [ $? -eq 0 -a -f "${topd}/setup.py" ] || return
+ ROOT_DIR="$topd"
+}
+
+if ! find_root; then
+ echo "Unable to locate 'setup.py' file that should" \
+ "exist in the cloud-init root directory." 1>&2
+ exit 1;
+fi
+
+CHNG_LOG="$ROOT_DIR/ChangeLog"
+
+if [ ! -e "$CHNG_LOG" ]
+then
+ echo "Unable to find 'ChangeLog' file located at $CHNG_LOG"
+ exit 1
+fi
+
+VERSION=$(grep -P "\d+.\d+.\d+:" $CHNG_LOG | cut -f1 -d ":" | head -n 1)
+echo $VERSION
diff --git a/tools/run-pylint b/tools/run-pylint
index dd6369aa..7ef44ac5 100755
--- a/tools/run-pylint
+++ b/tools/run-pylint
@@ -1,15 +1,7 @@
#!/bin/bash
-ci_files='cloud*.py cloudinit/*.py cloudinit/config/*.py'
-test_files=$(find tests -name "*.py")
-def_files="$ci_files $test_files"
-
if [ $# -eq 0 ]; then
- files=( )
- for f in $def_files; do
- [ -f "$f" ] || { echo "failed, $f not a file" 1>&2; exit 1; }
- files[${#files[@]}]=${f}
- done
+ files=( $(find * -name "*.py" -type f) )
else
files=( "$@" );
fi