summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rwxr-xr-xpackages/brpm47
-rw-r--r--packages/suse/cloud-init.spec.in162
3 files changed, 202 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index b659836f..29bfe0bd 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,10 @@ YAML_FILES+=$(shell find doc/examples -name "cloud-config*.txt" -type f )
CHANGELOG_VERSION=$(shell $(CWD)/tools/read-version)
CODE_VERSION=$(shell python -c "from cloudinit import version; print version.version_string()")
+ifeq ($(distro),)
+ distro = redhat
+endif
+
all: test check_version
pep8:
@@ -25,7 +29,7 @@ test:
check_version:
@if [ "$(CHANGELOG_VERSION)" != "$(CODE_VERSION)" ]; then \
echo "Error: ChangeLog version $(CHANGELOG_VERSION)" \
- "not equal to code version $(CODE_VERSION)"; exit 2; \
+ "not equal to code version $(CODE_VERSION)"; exit 2; \
else true; fi
2to3:
@@ -37,9 +41,9 @@ clean:
yaml:
@$(CWD)/tools/validate-yaml.py $(YAML_FILES)
-
+
rpm:
- ./packages/brpm
+ ./packages/brpm --distro $(distro)
deb:
./packages/bddeb
diff --git a/packages/brpm b/packages/brpm
index 53de802c..14faea4f 100755
--- a/packages/brpm
+++ b/packages/brpm
@@ -34,14 +34,26 @@ from cloudinit import util
# this is a translation of the 'requires'
# file pypi package name to a redhat/fedora package name.
PKG_MP = {
- 'argparse': 'python-argparse',
- 'boto': 'python-boto',
- 'cheetah': 'python-cheetah',
- 'configobj': 'python-configobj',
- 'oauth': 'python-oauth',
- 'prettytable': 'python-prettytable',
- 'pyyaml': 'PyYAML',
- 'requests': 'python-requests',
+ 'redhat': {
+ 'argparse': 'python-argparse',
+ 'boto': 'python-boto',
+ 'cheetah': 'python-cheetah',
+ 'configobj': 'python-configobj',
+ 'oauth': 'python-oauth',
+ 'prettytable': 'python-prettytable',
+ 'pyyaml': 'PyYAML',
+ 'requests': 'python-requests',
+ },
+ 'suse': {
+ 'argparse': 'python-argparse',
+ 'boto': 'python-boto',
+ 'cheetah': 'python-cheetah',
+ 'configobj': 'python-configobj',
+ 'oauth': 'python-oauth',
+ 'prettytable': 'python-prettytable',
+ 'pyyaml': 'python-yaml',
+ 'requests': 'python-requests',
+ }
}
# Subdirectories of the ~/rpmbuild dir
@@ -120,7 +132,7 @@ def generate_spec_contents(args, tmpl_fn, top_dir, arc_fn):
# Map to known packages
requires = []
for p in pkgs:
- tgt_pkg = PKG_MP.get(p)
+ tgt_pkg = PKG_MP[args.distro].get(p)
if not tgt_pkg:
raise RuntimeError(("Do not know how to translate pypi dependency"
" %r to a known package") % (p))
@@ -142,10 +154,11 @@ def generate_spec_contents(args, tmpl_fn, top_dir, arc_fn):
missing_versions += 1
if missing_versions == 1:
# Must be using a new 'dev'/'trunk' release
- changelog_lines.append(format_change_line(datetime.now(), '??'))
+ changelog_lines.append(format_change_line(datetime.now(),
+ '??'))
else:
- sys.stderr.write(("Changelog version line %s "
- "does not have a corresponding tag!\n") % (line))
+ sys.stderr.write(("Changelog version line %s does not "
+ "have a corresponding tag!\n") % (line))
else:
changelog_lines.append(header)
else:
@@ -171,6 +184,10 @@ def generate_spec_contents(args, tmpl_fn, top_dir, arc_fn):
def main():
parser = argparse.ArgumentParser()
+ parser.add_argument("-d", "--distro", dest="distro",
+ help="select distro (default: %(default)s)",
+ metavar="DISTRO", default='redhat',
+ choices=('redhat', 'suse'))
parser.add_argument("-b", "--boot", dest="boot",
help="select boot type (default: %(default)s)",
metavar="TYPE", default='sysvinit',
@@ -218,7 +235,7 @@ def main():
# Form the spec file to be used
tmpl_fn = util.abs_join(find_root(), 'packages',
- 'redhat', 'cloud-init.spec.in')
+ args.distro, 'cloud-init.spec.in')
contents = generate_spec_contents(args, tmpl_fn, root_dir,
os.path.basename(archive_fn))
spec_fn = util.abs_join(root_dir, 'cloud-init.spec')
@@ -237,13 +254,15 @@ def main():
globs.extend(glob.glob("%s/*.rpm" %
(util.abs_join(root_dir, 'RPMS', 'noarch'))))
globs.extend(glob.glob("%s/*.rpm" %
+ (util.abs_join(root_dir, 'RPMS', 'x86_64'))))
+ globs.extend(glob.glob("%s/*.rpm" %
(util.abs_join(root_dir, 'RPMS'))))
globs.extend(glob.glob("%s/*.rpm" %
(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("Wrote out redhat package %r" % (tgt_fn))
+ print("Wrote out %s package %r" % (args.distro, tgt_fn))
return 0
diff --git a/packages/suse/cloud-init.spec.in b/packages/suse/cloud-init.spec.in
new file mode 100644
index 00000000..296505c6
--- /dev/null
+++ b/packages/suse/cloud-init.spec.in
@@ -0,0 +1,162 @@
+## This is a cheetah template
+
+# See: http://www.zarb.org/~jasonc/macros.php
+# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
+# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
+
+#for $d in $defines
+%define ${d}
+#end for
+
+Name: cloud-init
+Version: ${version}
+Release: ${release}${subrelease}%{?dist}
+Summary: Cloud instance init scripts
+
+Group: System/Management
+License: GPLv3
+URL: http://launchpad.net/cloud-init
+
+Source0: ${archive_name}
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+
+%if 0%{?suse_version} && 0%{?suse_version} <= 1110
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+%else
+BuildArch: noarch
+%endif
+
+BuildRequires: fdupes
+BuildRequires: filesystem
+BuildRequires: python-devel
+BuildRequires: python-setuptools
+BuildRequires: python-cheetah
+
+%if 0%{?suse_version} && 0%{?suse_version} <= 1210
+ %define initsys sysvinit
+%else
+ %define initsys systemd
+%endif
+
+# System util packages needed
+Requires: iproute2
+Requires: e2fsprogs
+Requires: net-tools
+Requires: procps
+
+# Install pypi 'dynamic' requirements
+#for $r in $requires
+Requires: ${r}
+#end for
+
+# Custom patches
+#set $size = 0
+#for $p in $patches
+Patch${size}: $p
+#set $size += 1
+#end for
+
+%description
+Cloud-init is a set of init scripts for cloud instances. Cloud instances
+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}~${release}
+
+# Custom patches activation
+#set $size = 0
+#for $p in $patches
+%patch${size} -p1
+#set $size += 1
+#end for
+
+%build
+%{__python} setup.py build
+
+%install
+%{__python} setup.py install \
+ --skip-build --root=%{buildroot} --prefix=%{_prefix} \
+ --record-rpm=INSTALLED_FILES --install-lib=%{python_sitelib} \
+ --init-system=%{initsys}
+
+# Remove non-SUSE templates
+rm %{buildroot}/%{_sysconfdir}/cloud/templates/*.debian.*
+rm %{buildroot}/%{_sysconfdir}/cloud/templates/*.redhat.*
+rm %{buildroot}/%{_sysconfdir}/cloud/templates/*.ubuntu.*
+
+# Remove cloud-init tests
+rm -r %{buildroot}/%{python_sitelib}/tests
+
+# Move sysvinit scripts to the correct place and create symbolic links
+%if %{initsys} == sysvinit
+ mkdir -p %{buildroot}/%{_initddir}
+ mv %{buildroot}%{_sysconfdir}/rc.d/init.d/* %{buildroot}%{_initddir}/
+ rmdir %{buildroot}%{_sysconfdir}/rc.d/init.d
+ rmdir %{buildroot}%{_sysconfdir}/rc.d
+
+ mkdir -p %{buildroot}/%{_sbindir}
+ pushd %{buildroot}/%{_initddir}
+ for file in * ; do
+ ln -s %{_initddir}/\${file} %{buildroot}/%{_sbindir}/rc\${file}
+ done
+ popd
+%endif
+
+# Move documentation
+mkdir -p %{buildroot}/%{_defaultdocdir}
+mv %{buildroot}/usr/share/doc/cloud-init %{buildroot}/%{_defaultdocdir}
+for doc in TODO LICENSE ChangeLog Requires ; do
+ cp \${doc} %{buildroot}/%{_defaultdocdir}/cloud-init
+done
+
+# Remove duplicate files
+%if 0%{?suse_version}
+ %fdupes %{buildroot}/%{python_sitelib}
+%endif
+
+mkdir -p %{buildroot}/var/lib/cloud
+
+%postun
+%insserv_cleanup
+
+%files
+
+# Sysvinit scripts
+%if %{initsys} == sysvinit
+ %attr(0755, root, root) %{_initddir}/cloud-config
+ %attr(0755, root, root) %{_initddir}/cloud-final
+ %attr(0755, root, root) %{_initddir}/cloud-init-local
+ %attr(0755, root, root) %{_initddir}/cloud-init
+
+ %{_sbindir}/rccloud-*
+%endif
+
+# Program binaries
+%{_bindir}/cloud-init*
+
+# There doesn't seem to be an agreed upon place for these
+# although it appears the standard says /usr/lib but rpmbuild
+# will try /usr/lib64 ??
+/usr/lib/%{name}/uncloud-init
+/usr/lib/%{name}/write-ssh-key-fingerprints
+
+# Docs
+%doc %{_defaultdocdir}/cloud-init/*
+
+# Configs
+%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg
+%dir %{_sysconfdir}/cloud/cloud.cfg.d
+%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/*.cfg
+%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/README
+%dir %{_sysconfdir}/cloud/templates
+%config(noreplace) %{_sysconfdir}/cloud/templates/*
+
+# Python code is here...
+%{python_sitelib}/*
+
+/var/lib/cloud
+
+%changelog
+
+${changelog}