Skip to content

Commit

Permalink
Merge branch 'arch-cloud-init-0-7-6-user-id' (pull request #52)
Browse files Browse the repository at this point in the history
  • Loading branch information
hartwork committed Jul 23, 2017
2 parents e2ed364 + e56c3c4 commit 71d31af
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
37 changes: 27 additions & 10 deletions image_bootstrap/distros/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,31 @@ def install_sudo(self):
self._install_packages(['sudo'])

def _install_cloud_init_0_7_6(self):
pkgbuild_patch_filename = resource_filename('image_bootstrap',
'patches/cloud-init-0-7-6-pkgbuild.patch')
inner_script_filename = '/root/install-cloud-init-0-7-6.sh'
inner_patch_filename = '/root/cloud-init-pkgbuild.patch'

self._executor.check_call([
COMMAND_CP, pkgbuild_patch_filename,
os.path.join(self._abs_mountpoint, inner_patch_filename.lstrip('/')),
])
# NOTE: The PKGBUILD patch pulls in all other patches
pkgbuild_patch_basename = 'cloud-init-0-7-6-pkgbuild.patch'
patch_basenames = (
pkgbuild_patch_basename,
'cloud-init-0-7-6-uid.patch'
)

def _inner_abs_filename(patch_basename):
return '/root/%s' % patch_basename

def _outer_abs_filename(patch_basename):
return resource_filename(
'image_bootstrap', 'patches/%s' % patch_basename)

# Copy patches over
for patch_basename in patch_basenames:
self._executor.check_call([
COMMAND_CP,
_outer_abs_filename(patch_basename),
os.path.join(self._abs_mountpoint,
_inner_abs_filename(patch_basename).lstrip('/')),
])

inner_script_filename = _inner_abs_filename(
'install-cloud-init-0-7-6.sh')

with open(os.path.join(self._abs_mountpoint, inner_script_filename.lstrip('/')), 'w') as f:
f.write(dedent("""\
Expand All @@ -247,6 +263,7 @@ def _install_cloud_init_0_7_6(self):
chmod a+rw community-${COMMIT}/trunk/
cd community-${COMMIT}/trunk/
cp %s .
patch PKGBUILD %s
pacman --noconfirm --sync \
python2 python2-boto python2-cheetah \
Expand All @@ -256,7 +273,7 @@ def _install_cloud_init_0_7_6(self):
python2-setuptools python2-yaml net-tools
sudo -u nobody makepkg
pacman --noconfirm --upgrade cloud-init-9999-1-any.pkg.tar.xz
""" % inner_patch_filename))
""" % (_inner_abs_filename('cloud-init-*.patch'), pkgbuild_patch_basename)))
os.fchmod(f.fileno(), 0755)

self._executor.check_call([
Expand Down
14 changes: 11 additions & 3 deletions image_bootstrap/patches/cloud-init-0-7-6-pkgbuild.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- PKGBUILD 2016-11-17 21:46:52.836622919 +0000
+++ PKGBUILD 2016-11-17 23:17:02.088376215 +0000
@@ -2,29 +2,32 @@
@@ -2,29 +2,39 @@
# Maintainer: Daniel Wallace <danielwallace at gtmanfred dot com>

pkgname=cloud-init
Expand All @@ -20,8 +20,13 @@
options=(!emptydirs)
# Archlinux specific cloud.cfg
-source=(https://launchpad.net/$pkgname/trunk/$pkgver/+download/$pkgname-$pkgver.tar.gz)
+source=(https://launchpad.net/$pkgname/trunk/$PKGVER/+download/$pkgname-$PKGVER.tar.gz)
sha1sums=('9af02f68d68abce91463bec22b17964d1618e1da')
-sha1sums=('9af02f68d68abce91463bec22b17964d1618e1da')
+source=(https://launchpad.net/$pkgname/trunk/$PKGVER/+download/$pkgname-$PKGVER.tar.gz
+ cloud-init-${PKGVER//./-}-uid.patch
+)
+sha1sums=('9af02f68d68abce91463bec22b17964d1618e1da'
+ SKIP
+)
backup=(etc/cloud/cloud.cfg etc/cloud/cloud.cfg.d/05_logging.cfg)

prepare(){
Expand All @@ -33,6 +38,9 @@
+ sed -i '1s/python$/&2/' $pkgname-$PKGVER/tools/read*
+ sed -i 's:/etc/systemd:/usr/lib/systemd:g' $pkgname-$PKGVER/setup.py
+ sed -i 's,name: ubuntu,name: archlinux,;s,gecos: Ubuntu,gecos: Archlinux,' $srcdir/$pkgname-$PKGVER/config/cloud.cfg
+
+ cd ${pkgname}-${PKGVER}
+ patch -Np1 -i "${srcdir}"/cloud-init-${PKGVER//./-}-uid.patch
}

package() {
Expand Down
21 changes: 21 additions & 0 deletions image_bootstrap/patches/cloud-init-0-7-6-uid.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
From b05d0d54d29553e1fe1961ccc64da7d0b45016dd Mon Sep 17 00:00:00 2001
From: Gerhard Muntingh <[email protected]>
Date: Tue, 14 Apr 2015 15:20:39 +0200
Subject: Add functionality to fixate the uid of a newly added user.


diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index ab874b4..b297c78 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -318,6 +318,7 @@ class Distro(object):
"gecos": '--comment',
"homedir": '--home',
"primary_group": '--gid',
+ "uid": '--uid',
"groups": '--groups',
"passwd": '--password',
"shell": '--shell',
--
cgit v0.10.2

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
],
'image_bootstrap': [
'patches/cloud-init-0-7-6-pkgbuild.patch',
'patches/cloud-init-0-7-6-uid.patch',
],
},
entry_points={
Expand Down

0 comments on commit 71d31af

Please sign in to comment.