Add support for installing yum packages
This commit is contained in:
parent
83d60c4dec
commit
7dfb05653c
79
cloud-init-0.6.3-yum.patch
Normal file
79
cloud-init-0.6.3-yum.patch
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
From b36b33335c4872bc1bef5bcece33c3ea43de4ea5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Karasek <tomas.karasek@cern.ch>
|
||||||
|
Date: Wed, 27 Jun 2012 16:48:15 +0100
|
||||||
|
Subject: [PATCH] support package installation using 'yum'
|
||||||
|
|
||||||
|
---
|
||||||
|
cloudinit/CloudConfig/__init__.py | 42 +++++++++++++++++++++++++++++++++---
|
||||||
|
1 files changed, 38 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/cloudinit/CloudConfig/__init__.py b/cloudinit/CloudConfig/__init__.py
|
||||||
|
index a16bdde..6a7005a 100644
|
||||||
|
--- a/cloudinit/CloudConfig/__init__.py
|
||||||
|
+++ b/cloudinit/CloudConfig/__init__.py
|
||||||
|
@@ -27,6 +27,7 @@ import traceback
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
+import platform
|
||||||
|
|
||||||
|
per_instance = cloudinit.per_instance
|
||||||
|
per_always = cloudinit.per_always
|
||||||
|
@@ -253,6 +254,27 @@ def run_per_instance(name, func, args, clear_on_fail=False):
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
+def get_package_manager():
|
||||||
|
+ if 'linux_distribution' in platform.__dict__:
|
||||||
|
+ distname, _, _ = platform.linux_distribution(
|
||||||
|
+ full_distribution_name=0)
|
||||||
|
+ else:
|
||||||
|
+ distname, _, _ = platform.dist()
|
||||||
|
+ yum_dists = ['redhat', 'fedora', 'centos']
|
||||||
|
+ apt_dists = ['debian', 'ubuntu']
|
||||||
|
+ if distname.lower() in yum_dists:
|
||||||
|
+ return 'yum'
|
||||||
|
+ elif distname.lower() in apt_dists:
|
||||||
|
+ return 'apt'
|
||||||
|
+ elif os.system('yum --help >/dev/null 2>&1'):
|
||||||
|
+ return 'yum'
|
||||||
|
+ elif os.system('apt-get --help >/dev/null 2>&1'):
|
||||||
|
+ return 'apt'
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+_PACKAGE_MANAGER = get_package_manager()
|
||||||
|
+
|
||||||
|
+
|
||||||
|
# apt_get top level command (install, update...), and args to pass it
|
||||||
|
def apt_get(tlc, args=None):
|
||||||
|
if args is None:
|
||||||
|
@@ -265,10 +287,22 @@ def apt_get(tlc, args=None):
|
||||||
|
subprocess.check_call(cmd, env=e)
|
||||||
|
|
||||||
|
|
||||||
|
-def update_package_sources():
|
||||||
|
- run_per_instance("update-sources", apt_get, ("update",))
|
||||||
|
+def yum(tlc, args=None):
|
||||||
|
+ if args is None:
|
||||||
|
+ args = []
|
||||||
|
+ cmd = ['yum', '-y', tlc]
|
||||||
|
+ cmd.extend(args)
|
||||||
|
+ subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
def install_packages(pkglist):
|
||||||
|
- update_package_sources()
|
||||||
|
- apt_get("install", pkglist)
|
||||||
|
+ if _PACKAGE_MANAGER == "yum":
|
||||||
|
+ run_per_instance("update-sources", yum, ("makecache",))
|
||||||
|
+ yum("install", pkglist)
|
||||||
|
+ elif _PACKAGE_MANAGER == "apt":
|
||||||
|
+ run_per_instance("update-sources", apt_get, ("update",))
|
||||||
|
+ apt_get("install", pkglist)
|
||||||
|
+ else:
|
||||||
|
+ raise Exception("Unknown distribution, unable to install packages %s" %
|
||||||
|
+ pkglist)
|
||||||
|
+
|
||||||
|
--
|
||||||
|
1.7.6.4
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Name: cloud-init
|
Name: cloud-init
|
||||||
Version: 0.6.3
|
Version: 0.6.3
|
||||||
Release: 0.2.bzr532%{?dist}
|
Release: 0.3.bzr532%{?dist}
|
||||||
Summary: Cloud instance init scripts
|
Summary: Cloud instance init scripts
|
||||||
|
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
@ -18,6 +18,7 @@ Patch0: cloud-init-0.6.3-fedora.patch
|
|||||||
Patch1: cloud-init-0.6.3-no-runparts.patch
|
Patch1: cloud-init-0.6.3-no-runparts.patch
|
||||||
# https://bugs.launchpad.net/cloud-init/+bug/970071
|
# https://bugs.launchpad.net/cloud-init/+bug/970071
|
||||||
Patch2: cloud-init-0.6.3-lp970071.patch
|
Patch2: cloud-init-0.6.3-lp970071.patch
|
||||||
|
Patch3: cloud-init-0.6.3-yum.patch
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
@ -53,6 +54,7 @@ ssh keys and to let the user run various scripts.
|
|||||||
%patch0 -p0
|
%patch0 -p0
|
||||||
%patch1 -p0
|
%patch1 -p0
|
||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
|
|
||||||
cp -p %{SOURCE2} README.fedora
|
cp -p %{SOURCE2} README.fedora
|
||||||
|
|
||||||
@ -134,6 +136,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jun 27 2012 Pádraig Brady <P@draigBrady.com> - 0.6.3-0.3.bzr532
|
||||||
|
- Add support for installing yum packages
|
||||||
|
|
||||||
* Sat Mar 31 2012 Andy Grimm <agrimm@gmail.com> - 0.6.3-0.2.bzr532
|
* Sat Mar 31 2012 Andy Grimm <agrimm@gmail.com> - 0.6.3-0.2.bzr532
|
||||||
- Fixed incorrect interpretation of relative path for
|
- Fixed incorrect interpretation of relative path for
|
||||||
AuthorizedKeysFile (BZ #735521)
|
AuthorizedKeysFile (BZ #735521)
|
||||||
|
Loading…
Reference in New Issue
Block a user