Merge lp:~javier.collado/utah/bug1118581 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Max Brustkern
Approved revision: 812
Merged at revision: 812
Proposed branch: lp:~javier.collado/utah/bug1118581
Merge into: lp:utah
Diff against target: 25 lines (+9/-3)
1 file modified
utah/provisioning/provisioning.py (+9/-3)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1118581
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Review via email: mp+147423@code.launchpad.net

Description of the change

This branch fixes the nested quotation problems that happen when using a list
of commands that have their own quotation marks.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

This looks elaborate and useful. I'm going to run a test of it.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

This looks good. I've also confirmed the truncation running on my system without it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/provisioning/provisioning.py'
2--- utah/provisioning/provisioning.py 2013-02-01 11:40:31 +0000
3+++ utah/provisioning/provisioning.py 2013-02-08 17:01:39 +0000
4@@ -868,12 +868,18 @@
5 .format(self.CHECK_LOCK_COMMAND, pkg_name, log_file)
6 for pkg_name in config.installpackages]))
7 postinstall_commands = (
8- 'sed -i -e "/^exit 0$/i{}" /etc/rc.local;'
9+ 'sed -i -e \'/^exit 0$/i{}\' /etc/rc.local;'
10 .format(install_commands)
11 )
12 chroot_command = ' '.join([install_commands, postinstall_commands])
13- question.value.prepend('in-target sh -c \'{}\'; '
14- .format(chroot_command))
15+ # Note that since the chroot command is passed to sh within single
16+ # quotes, the single quotes inside the chroot command have to be
17+ # escaped using '"'"'
18+ # For more information, please refer to:
19+ # http://stackoverflow.com/q/1250079/183066
20+ question.value.prepend(
21+ 'in-target sh -c \'{}\'; '
22+ .format(chroot_command.replace('\'', '\'"\'"\'')))
23 question.prepend("ubiquity ubiquity/summary note")
24 question.prepend("ubiquity ubiquity/reboot boolean true")
25 else:

Subscribers

People subscribed via source and target branches