Merge lp:~bac/lpsetup/fix-inithost-install-lxc-deux into lp:lpsetup

Proposed by Brad Crittenden
Status: Merged
Approved by: Gary Poster
Approved revision: 62
Merged at revision: 54
Proposed branch: lp:~bac/lpsetup/fix-inithost-install-lxc-deux
Merge into: lp:lpsetup
Diff against target: 133 lines (+18/-24)
4 files modified
lpsetup/handlers.py (+1/-9)
lpsetup/subcommands/finish_inithost.py (+1/-1)
lpsetup/subcommands/update.py (+13/-11)
lpsetup/tests/subcommands/test_update.py (+3/-3)
To merge this branch: bzr merge lp:~bac/lpsetup/fix-inithost-install-lxc-deux
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+114896@code.launchpad.net

Commit message

Changes to the handling of external path and working dir in the update steps.

Description of the change

Changes to the handling of external path and working dir in the update steps.

Minor changes that are carry over from the review of the previous branch.

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lpsetup/handlers.py'
2--- lpsetup/handlers.py 2012-07-11 15:47:34 +0000
3+++ lpsetup/handlers.py 2012-07-13 16:03:18 +0000
4@@ -236,6 +236,7 @@
5 raise ValidationError(err)
6
7 directory = directory.replace('~', namespace.home_dir)
8+ directory = os.path.abspath(directory)
9 if not directory.startswith(namespace.home_dir + os.path.sep):
10 raise ValidationError(
11 'argument {0} does not reside under the home '
12@@ -275,15 +276,6 @@
13 return os.path.abspath(os.path.expanduser(path))
14
15
16-def handle_external_path(namespace):
17- """Handle path to externals.
18-
19- The external directory is the one that contains the sourcecode and
20- download-cache.
21- """
22- namespace.external_path = normalize_path(namespace.external_path)
23-
24-
25 def handle_working_dir(namespace):
26 """Handle path to the working directory."""
27 namespace.working_dir = normalize_path(namespace.working_dir)
28
29=== modified file 'lpsetup/subcommands/finish_inithost.py'
30--- lpsetup/subcommands/finish_inithost.py 2012-07-12 18:23:37 +0000
31+++ lpsetup/subcommands/finish_inithost.py 2012-07-13 16:03:18 +0000
32@@ -91,6 +91,6 @@
33 self.add_common_arguments(parser)
34 parser.add_argument(
35 '-u', '--user',
36- help='The name of the system user to be created or updated. '
37+ help='The name of the system user. '
38 'The current user is used if this script is not run as '
39 'root and this argument is omitted.')
40
41=== modified file 'lpsetup/subcommands/update.py'
42--- lpsetup/subcommands/update.py 2012-07-12 22:12:09 +0000
43+++ lpsetup/subcommands/update.py 2012-07-13 16:03:18 +0000
44@@ -24,20 +24,22 @@
45 )
46
47
48-def initialize_directories(external_path):
49+def initialize_directories(working_dir, external_path):
50 """Initialize the eggs, yui, and sourcecode directories.
51
52 Create them if necessary.
53 """
54 for dir_ in ['eggs', 'yui', 'sourcecode']:
55- mkdirs(os.path.join(external_path, dir_))
56-
57-
58-def update_dependencies(external_path, working_dir, use_http):
59+ mkdirs(os.path.join(working_dir, external_path, dir_))
60+
61+
62+def update_dependencies(working_dir, external_path, use_http):
63 """Update the external dependencies."""
64 use_http_param = '--use-http' if use_http else None
65 cmd = os.path.join(working_dir, 'utilities', 'update-sourcecode')
66- source_path = os.path.join(external_path, 'sourcecode')
67+ abs_external_path = os.path.abspath(
68+ os.path.join(working_dir, external_path))
69+ source_path = os.path.join(abs_external_path, 'sourcecode')
70 run(cmd, use_http_param, source_path)
71
72 # Update the download cache.
73@@ -48,7 +50,7 @@
74 run('bzr', 'co', '-v', '--lightweight', LP_SOURCE_DEPS, download_cache)
75
76 # Link to the external sourcecode.
77- if external_path != working_dir:
78+ if abs_external_path != working_dir:
79 cmd = os.path.join(
80 working_dir, 'utilities', 'link-external-sourcecode')
81 run(cmd,
82@@ -69,14 +71,13 @@
83 """
84
85 steps = (
86- (initialize_directories, 'external_path'),
87- (update_dependencies, 'external_path', 'working_dir', 'use_http'),
88+ (initialize_directories, 'working_dir', 'external_path'),
89+ (update_dependencies, 'working_dir', 'external_path', 'use_http'),
90 (update_tree, 'working_dir'),
91 )
92 help = __doc__
93 handlers = (
94 # Normalize paths and default to cwd if none exists.
95- handlers.handle_external_path,
96 handlers.handle_working_dir,
97 )
98
99@@ -85,7 +86,8 @@
100 parser.add_argument(
101 '-e', '--external-path', default='.',
102 help='Path to directory that contains sourcecode '
103- 'and download-cache directories.')
104+ 'and download-cache directories, relative to the '
105+ 'working-dir. ')
106
107 def add_arguments(self, parser):
108 super(SubCommand, self).add_arguments(parser)
109
110=== modified file 'lpsetup/tests/subcommands/test_update.py'
111--- lpsetup/tests/subcommands/test_update.py 2012-07-12 22:12:09 +0000
112+++ lpsetup/tests/subcommands/test_update.py 2012-07-13 16:03:18 +0000
113@@ -22,9 +22,10 @@
114 '-W', '~/' + get_random_string(),
115 )
116
117-init_dir_step = (update.initialize_directories, ['external_path'])
118+init_dir_step = (
119+ update.initialize_directories, ['working_dir', 'external_path'])
120 update_dep_step = (
121- update.update_dependencies, ['external_path', 'working_dir', 'use_http'])
122+ update.update_dependencies, ['working_dir', 'external_path', 'use_http'])
123 update_tree_step = (update.update_tree, ['working_dir'])
124
125
126@@ -34,7 +35,6 @@
127 sub_command_class = update.SubCommand
128 expected_arguments = get_arguments()
129 expected_handlers = (
130- handlers.handle_external_path,
131 handlers.handle_working_dir,
132 )
133 expected_steps = (

Subscribers

People subscribed via source and target branches