Merge lp:~xnox/charms/precise/sbuild/add-more-options into lp:charms/sbuild

Proposed by Dimitri John Ledkov
Status: Merged
Merged at revision: 5
Proposed branch: lp:~xnox/charms/precise/sbuild/add-more-options
Merge into: lp:charms/sbuild
Diff against target: 157 lines (+51/-19)
4 files modified
config.yaml (+16/-0)
hooks/config-changed (+17/-3)
hooks/install (+17/-15)
revision (+1/-1)
To merge this branch: bzr merge lp:~xnox/charms/precise/sbuild/add-more-options
Reviewer Review Type Date Requested Status
Juan L. Negron (community) Approve
Review via email: mp+135099@code.launchpad.net

Description of the change

  * make btsparty an option (to have unattended sbuilds)
  * add $HOME option (set to /mnt, as that's where most clouds give space)
  * add .mk-sbuild.rc & .mk-sbuild.sources (for mk-sbuild integration)

To post a comment you must log in.
Revision history for this message
Juan L. Negron (negronjl) wrote :

Hi Dmitrijs:

Thank you for the extra options in the charm.

This looks good to me and, it doesn't seem to be breaking anything.

Approved.

Merged.

Thanks,

Juan

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2012-06-18 16:15:49 +0000
3+++ config.yaml 2012-11-20 10:18:32 +0000
4@@ -3,11 +3,19 @@
5 type: string
6 default: builder
7 description: The name of the account that performs builds.
8+ home:
9+ type: string
10+ default: /home
11+ description: The home directory location for the above account.
12 salt:
13 type: string
14 default: unset
15 description: Salt for generating builder accounts.
16 validator: '.{8,}'
17+ btsparty:
18+ type: boolean
19+ default: yes
20+ description: Setup accounts for public access.
21 chroots:
22 type: string
23 default: ubuntu:quantal
24@@ -16,3 +24,11 @@
25 type: string
26 default: ""
27 description: Comma-separated list of extra packages to install in chroots.
28+ mk-sbuild.rc:
29+ type: string
30+ default: ""
31+ description: Contents of mk-sbuild.rc. See $ man mk-sbuild.
32+ mk-sbuild.sources:
33+ type: string
34+ default: ""
35+ descption: Conternts of ~/.mk-sbuild.sources. See $ man mk-sbuild.
36
37=== modified file 'hooks/config-changed'
38--- hooks/config-changed 2012-06-18 16:15:49 +0000
39+++ hooks/config-changed 2012-11-20 10:18:32 +0000
40@@ -3,16 +3,30 @@
41
42 USERNAME=$(config-get username)
43 SALT=$(config-get salt)
44+BTSPARTY=$(config-get btsparty)
45
46-password=$(echo "$SALT:$JUJU_UNIT_NAME" | md5sum - | cut -c-12)
47-juju-log "On $JUJU_UNIT_NAME $USERNAME password is '$password'"
48-echo "$USERNAME:$password" | chpasswd
49+if [ "$BTSPARTY" = "yes" ]; then
50+ password=$(echo "$SALT:$JUJU_UNIT_NAME" | md5sum - | cut -c-12)
51+ juju-log "On $JUJU_UNIT_NAME $USERNAME password is '$password'"
52+ echo "$USERNAME:$password" | chpasswd
53+fi
54
55 CHROOTS=$(config-get chroots)
56 PACKAGES=$(config-get packages)
57+MK_SBUILD_RC=$(config-get mk-sbuild.rc)
58+MK_SBUILD_SOURCES=$(config-get mk-sbuild.sources)
59+HOMEDIR=$(getent passwd $USERNAME | cut -d: -f 6)
60 if [ -n "$PACKAGES" ]; then
61 PACKAGES="--debootstrap-include=$PACKAGES"
62 fi
63+if [ -n "$MK_SBUILD_RC" ]; then
64+ config-get mk-sbuild.rc -o $HOMEDIR/.mk-sbuild.rc
65+ chown $USERNAME $HOMEDIR/.mk-sbuild.rc
66+fi
67+if [ -n "$MK_SBUILD_SOURCES" ]; then
68+ config-get mk-sbuild.rc -o $HOMEDIR/.mk-sbuild.sources
69+ chown $USERNAME $HOMEDIR/.mk-sbuild.sources
70+fi
71
72 ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
73 arches=$ARCH
74
75=== modified file 'hooks/install'
76--- hooks/install 2012-06-18 23:28:51 +0000
77+++ hooks/install 2012-11-20 10:18:32 +0000
78@@ -2,9 +2,11 @@
79 set -ex
80
81 USERNAME=$(config-get username)
82+HOMEDIR=$(config-get home)
83 DISTRO=$(config-get distro)
84 RELEASES=$(config-get releases)
85 SALT=$(config-get salt)
86+BTSPARTY=$(config-get btsparty)
87
88 echo set debconf/frontend Noninteractive | debconf-communicate
89 echo set debconf/priority critical | debconf-communicate
90@@ -13,24 +15,16 @@
91
92 apt-get dist-upgrade -y
93
94-apt-get install -y build-essential devscripts ubuntu-dev-tools sbuild schroot debootstrap rng-tools </dev/null
95+apt-get install -y build-essential devscripts ubuntu-dev-tools sbuild schroot debootstrap haveged </dev/null
96
97 # Fix up weird issue with debootstrap leaving system in uninstallable state
98 perl -pi -e 's/^# Pull down signature requirements/apt-get -f install -y --force-yes\n# Pull down signature requirements/' /usr/bin/mk-sbuild
99
100-passwd -l ubuntu
101-if grep -q '^PasswordAuthentication no' /etc/ssh/sshd_config; then
102- perl -pi -e 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
103- service ssh restart
104-fi
105 if ! getent passwd $USERNAME >/dev/null; then
106 adduser --quiet --disabled-password --ingroup users \
107 --gecos "Build User" \
108- --home /home/$USERNAME $USERNAME
109+ --home $HOMEDIR/$USERNAME $USERNAME
110 fi
111-password=$(echo "$SALT:$JUJU_UNIT_NAME" | md5sum - | cut -c-12)
112-juju-log "On $JUJU_UNIT_NAME $USERNAME password is '$password'"
113-echo "$USERNAME:$password" | chpasswd
114
115 cat >/etc/sudoers.d/60-sbuild <<EOM
116 $USERNAME ALL=(ALL) NOPASSWD:ALL
117@@ -41,13 +35,20 @@
118 if ! getent group sbuild | grep -q $USERNAME; then
119 # No-op to set up mk-sbuild environment.
120 EDITOR=cat su -c "/usr/bin/mk-sbuild invalid-release" $USERNAME
121- # Terrible hack to gain entropy and generate builder keys for sbuild.
122- rngd -r /dev/urandom
123 su -c "sbuild-update --keygen" $USERNAME
124 fi
125
126-rm -f /etc/update-motd.d/98-cloudguest
127-cat >/etc/update-motd.d/98-sbuild <<EOM
128+if [ "$BTSPARTY" = "yes" ]; then
129+ passwd -l ubuntu
130+ if grep -q '^PasswordAuthentication no' /etc/ssh/sshd_config; then
131+ perl -pi -e 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
132+ service ssh restart
133+ fi
134+ password=$(echo "$SALT:$JUJU_UNIT_NAME" | md5sum - | cut -c-12)
135+ juju-log "On $JUJU_UNIT_NAME $USERNAME password is '$password'"
136+ echo "$USERNAME:$password" | chpasswd
137+ rm -f /etc/update-motd.d/98-cloudguest
138+ cat >/etc/update-motd.d/98-sbuild <<EOM
139 #!/bin/bash
140 echo ""
141 echo "###################################################################"
142@@ -58,6 +59,7 @@
143 echo "# #"
144 echo "###################################################################"
145 EOM
146-chmod a+rx /etc/update-motd.d/98-sbuild
147+ chmod a+rx /etc/update-motd.d/98-sbuild
148+fi
149
150 exit 0
151
152=== modified file 'revision'
153--- revision 2012-06-18 16:15:49 +0000
154+++ revision 2012-11-20 10:18:32 +0000
155@@ -1,1 +1,1 @@
156-22
157+24

Subscribers

People subscribed via source and target branches

to all changes: