Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMach bootstrap: Improve and support more platforms #15230
Conversation
highfive
commented
Jan 26, 2017
|
Heads up! This PR modifies the following files:
|
|
Core concept is good, but many of the additions have dubious usefulness IMO. |
| @@ -219,7 +247,8 @@ def bootstrap(context, force=False): | |||
| bootstrapper = windows_msvc | |||
| elif "linux-gnu" in host_triple(): | |||
| distro, version, _ = platform.linux_distribution() | |||
| if distro == 'Ubuntu' and version == '14.04': | |||
| if distro in ('CentOS', 'CentOS Linux', 'Fedora', 'Ubuntu'): | |||
This comment has been minimized.
This comment has been minimized.
aneeshusa
Jan 26, 2017
Member
After bootstrapping, is it possible to build Servo even without the MS fonts?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| return 1 | ||
| print("done") | ||
| virtualenv_script_dir = os.path.join(context.topdir, 'python', '_virtualenv', _get_virtualenv_script_dir()) | ||
| if not os.path.exists(os.path.join(virtualenv_script_dir, 'salt-call')): |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Jan 26, 2017
Member
This is not quite right, since from time to time we will need to update Salt to stay in locksetep with saltfs. I'd prefer to continue running pip install every time, which is a (fast) no-op if the dependencies are up to date.
This comment has been minimized.
This comment has been minimized.
| print('Output: {}\nError: {}'.format(out, err)) | ||
| return 1 | ||
| print("done") | ||
| virtualenv_script_dir = os.path.join(context.topdir, 'python', '_virtualenv', _get_virtualenv_script_dir()) |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Jan 26, 2017
Member
It would be nice to add an absolute=True (optional, kwarg?) arg to _get_virtualenv_script_dir so thatthe path prefixes don't need to be appended here and in mach_bootstrap.py.
| if process.returncode: | ||
| out, err = process.communicate() | ||
| if "pycrypto/setup.py" in err and not retry: | ||
| return install_salt_dependencies(context, force) |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Jan 26, 2017
Member
I think it makes more sense to do this before running pip install, to avoid having to call pip install twice.
This comment has been minimized.
This comment has been minimized.
UK992
Jan 26, 2017
Author
Contributor
since install_salt_dependencies only run, when failed to install pycrypto dependency of Salt, probably one time run, i think it's better run pip install twice, then install_salt_dependencies on every run.
| subprocess.check_call(['sudo', '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| command.insert(0, 'sudo') | ||
| except: | ||
| command = ['su', 'root', '-c', ' '.join(command)] |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Jan 26, 2017
Member
Where is su needed? I much prefer using sudo in all circumstances, since su 1) uses root's environment instead of the user's environment and 2) requires the root password instead of the user's password.
This comment has been minimized.
This comment has been minimized.
UK992
Jan 26, 2017
Author
Contributor
On Fedora with user account without password, sudoing is not possible.
This comment has been minimized.
This comment has been minimized.
aneeshusa
Feb 7, 2017
Member
IMO that's an insecure/broken setup (e.g. another sudo benefit is its auditing support), and I'd rather not support it. Additionally, the su codepath does not handle quoting/escaping of the command that it passes to bash, which is also easy to write incorrectly. Users with such setups can always install dependencies manually.
Also, in case a user uses sudo with timestamp_timeout set to 0, the additional sudo -v call means they will have twice as many sudo prompts.
| return subprocess.call(command) | ||
|
|
||
|
|
||
| # This install needed dependencies for Salt |
This comment has been minimized.
This comment has been minimized.
|
Review ping @aneeshusa |
|
Looking better, thanks for this PR! I have some more review comments. |
| @@ -96,11 +96,12 @@ def _get_exec_path(names, is_valid_path=lambda _path: True): | |||
| return None | |||
|
|
|||
|
|
|||
| def _get_virtualenv_script_dir(): | |||
| def _get_virtualenv_script_dir(absolute=True): | |||
This comment has been minimized.
This comment has been minimized.
aneeshusa
Feb 7, 2017
Member
We're no longer using this for the Salt bootstrap, so let's back out the change to this function and its call site in _activate_virtualenv.
| subprocess.check_call(['sudo', '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| command.insert(0, 'sudo') | ||
| except: | ||
| command = ['su', 'root', '-c', ' '.join(command)] |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Feb 7, 2017
Member
IMO that's an insecure/broken setup (e.g. another sudo benefit is its auditing support), and I'd rather not support it. Additionally, the su codepath does not handle quoting/escaping of the command that it passes to bash, which is also easy to write incorrectly. Users with such setups can always install dependencies manually.
Also, in case a user uses sudo with timestamp_timeout set to 0, the additional sudo -v call means they will have twice as many sudo prompts.
| print("Installing missing Salt dependencies...") | ||
| if context.distro == 'Ubuntu': | ||
| run_as_root(['apt-get', 'install', '-y', 'build-essential', 'libssl-dev', 'libffi-dev', 'python-dev']) | ||
| elif context.distro in ('CentOS', 'CentOS Linux', 'Fedora'): |
This comment has been minimized.
This comment has been minimized.
| @@ -219,7 +247,8 @@ def bootstrap(context, force=False): | |||
| bootstrapper = windows_msvc | |||
| elif "linux-gnu" in host_triple(): | |||
| distro, version, _ = platform.linux_distribution() | |||
| if distro == 'Ubuntu' and version == '14.04': | |||
| if distro in ('CentOS', 'CentOS Linux', 'Fedora', 'Ubuntu'): | |||
This comment has been minimized.
This comment has been minimized.
| return subprocess.call(command) | ||
|
|
||
|
|
||
| def install_salt_dependencies(context, force): |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Feb 7, 2017
Member
This method should use the force parameter as it is used elsewhere: if force is False, then it should prompt the user before installing packages.
| @@ -29,6 +51,9 @@ def salt(context, force=False): | |||
| process.wait() | |||
| if process.returncode: | |||
| out, err = process.communicate() | |||
| if "pycrypto/setup.py" in err and not retry: | |||
| return install_salt_dependencies(context, force) | |||
This comment has been minimized.
This comment has been minimized.
aneeshusa
Feb 7, 2017
Member
Hmm, I don't know where my previous comment about this went.
Checking for a substring of the error message in this way seems fragile to me; Salt has changed crypto libraries in the past.
The mutual recursion here is error-prone as well; if in the future there is a new system-level dependency for Salt, then this code won't install it, causing the error on each Salt invocation and endlessly recursing through salt and install_salt_dependencies in a loop, causing the process to hang.
I still think it's better to check for the the Salt dependencies on each run before installing Salt. We can make this faster by using dpkg -s <package> <names> <here> first, and only running apt-get install if it returns nonzero; I'm not sure about the CentOS/Fedora equivalent.
439f9e1
to
226f16a
|
All comments addressed! |
|
@aneeshusa Review ping! |
|
This has been around for way too long. I'd better land this. @bors-servo r=aneeshusa |
|
|
Mach bootstrap: Improve and support more platforms <!-- Please describe your changes on the following line: --> r? @aneeshusa or @wafflespeanut --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15230) <!-- Reviewable:end -->
|
|
UK992 commentedJan 26, 2017
•
edited by larsbergstrom
r? @aneeshusa or @wafflespeanut
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is