Fix runparts() compabitility with Fedora

This commit is contained in:
Garrett Holmstrom 2012-03-05 13:34:38 -08:00
parent 2f7ad55032
commit 1829b52a19
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,32 @@
=== modified file 'cloudinit/util.py'
--- cloudinit/util.py 2012-02-29 00:12:33 +0000
+++ cloudinit/util.py 2012-03-05 17:55:03 +0000
@@ -209,16 +209,17 @@
if skip_no_exist and not os.path.isdir(dirp):
return
- # per bug 857926, Fedora's run-parts will exit failure on empty dir
- if os.path.isdir(dirp) and os.listdir(dirp) == []:
- return
-
- cmd = ['run-parts', '--regex', '.*', dirp]
- sp = subprocess.Popen(cmd)
- sp.communicate()
- if sp.returncode is not 0:
- raise subprocess.CalledProcessError(sp.returncode, cmd)
- return
+ failed = 0
+ for exe_name in sorted(os.listdir(dirp)):
+ exe_path = os.path.join(dirp, exe_name)
+ if os.path.isfile(exe_path) and os.access(exe_path, os.X_OK):
+ popen = subprocess.Popen([exe_path])
+ popen.communicate()
+ if popen.returncode is not 0:
+ failed += 1
+ print >> sys.stderr, exe_path, 'failed; code', popen.returncode
+ if failed:
+ raise RuntimeError('runparts: %i failures' % failed)
def subp(args, input_=None):

View File

@ -13,6 +13,9 @@ Source0: %{name}-%{version}-bzr532.tar.gz
Source1: cloud-init-fedora.cfg Source1: cloud-init-fedora.cfg
Source2: cloud-init-README.fedora Source2: cloud-init-README.fedora
Patch0: cloud-init-0.6.3-fedora.patch Patch0: cloud-init-0.6.3-fedora.patch
# Make runparts() work on Fedora
# https://bugs.launchpad.net/cloud-init/+bug/934404
Patch1: cloud-init-0.6.3-no-runparts.patch
BuildArch: noarch BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -46,6 +49,7 @@ ssh keys and to let the user run various scripts.
%prep %prep
%setup -q -n %{name}-%{version}-bzr532 %setup -q -n %{name}-%{version}-bzr532
%patch0 -p0 %patch0 -p0
%patch1 -p0
cp -p %{SOURCE2} README.fedora cp -p %{SOURCE2} README.fedora
@ -129,6 +133,7 @@ fi
%changelog %changelog
* Mon Mar 5 2012 Garrett Holmstrom <gholms@fedoraproject.org> - 0.6.3-0.1.bzr532 * Mon Mar 5 2012 Garrett Holmstrom <gholms@fedoraproject.org> - 0.6.3-0.1.bzr532
- Rebased against upstream rev 532 - Rebased against upstream rev 532
- Fixed runparts() incompatibility with Fedora
* Thu Jan 12 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.2-0.8.bzr457 * Thu Jan 12 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.2-0.8.bzr457
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild