Bug 1275437 - Added methods for interacting with pacman. r?gps draft
authorNathan Hakkakzadeh <nhakkakzadeh@mozilla.com>
Wed, 25 May 2016 11:19:22 -0700
changeset 371052 45ca4e9778732365822cd0e9f49626602f4ed6c9
parent 371051 a43e615dfbd6092d4a31a564d3400f66997510b6
child 371053 ca39b7213ad42ea3591d6149a46fc33d5b8d9027
child 371064 d1c7c59028b07fca8d9dbe64825c7eca74477fc8
push id19222
push userbmo:nhakkakzadeh@mozilla.com
push dateWed, 25 May 2016 21:49:35 +0000
reviewersgps
bugs1275437
milestone49.0a1
Bug 1275437 - Added methods for interacting with pacman. r?gps These new convenience methods let the bootstrapper update the local package list, upgrade all installed packages, and install new packages. MozReview-Commit-ID: KZPyBl0OU6Z
python/mozboot/mozboot/windows.py
--- a/python/mozboot/mozboot/windows.py
+++ b/python/mozboot/mozboot/windows.py
@@ -1,12 +1,34 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+import sys
+import subprocess
+
 from mozboot.base import BaseBootstrapper
 
 class WindowsBootstrapper(BaseBootstrapper):
     '''Bootstrapper for msys2 based environments for building in Windows.'''
     def __init__(self, **kwargs):
         BaseBootstrapper.__init__(self, **kwargs)
         raise NotImplementedError('Bootstrap support is not yet available for Windows. '
                                   'For now, use MozillaBuild to set up a build environment on Windows.')
+
+    def run(self, command):
+        subprocess.check_call(command, stdin=sys.stdin)
+
+    def pacman_update(self):
+        command = ['pacman', '-S', '--refresh']
+        self.run(command)
+
+    def pacman_upgrade(self):
+        command = ['pacman', '-Syu']
+        self.run(command)
+
+    def pacman_install(self, *packages):
+        command = ['pacman', '-S', '--needed']
+        if self.no_interactive:
+            command.append('--noconfirm')
+
+        command.extend(packages)
+        self.run(command)