Bug 1275437 - Added methods for interacting with pacman. r?gps draft
authorNathan Hakkakzadeh <nhakkakzadeh@mozilla.com>
Thu, 26 May 2016 09:50:02 -0700
changeset 371482 c1511267eeb5da93d7fbafff4cf153b2ff0cb645
parent 371481 f54f521b0709843074f06129242d777bd8b377dd
child 371483 e47a4ce639b1b975f9bff68660c6c009b1f2234c
child 373633 27bc5856f924abd926ca1761464f5e269b24f7e6
child 374003 2f6ea6ddd74640b679c3b594c532fb6971455111
child 374686 06c11a1371f5da8fded0384e9213455cfe332f58
push id19337
push userbmo:nhakkakzadeh@mozilla.com
push dateThu, 26 May 2016 18:26:24 +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,18 +1,39 @@
 # 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 os
+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):
         if 'MOZ_WINDOWS_BOOTSTRAP' not in os.environ or os.environ['MOZ_WINDOWS_BOOTSTRAP'] != '1':
             raise NotImplementedError('Bootstrap support for Windows is under development. For now, use MozillaBuild '
                                       'to set up a build environment on Windows. If you are testing Windows Bootstrap support, '
                                       'try `export MOZ_WINDOWS_BOOTSTRAP=1`')
         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', '--sync', '--refresh']
+        self.run(command)
+
+    def pacman_upgrade(self):
+        command = ['pacman', '--sync', '--refresh', '--sysupgrade']
+        self.run(command)
+
+    def pacman_install(self, *packages):
+        command = ['pacman', '--sync', '--needed']
+        if self.no_interactive:
+            command.append('--noconfirm')
+
+        command.extend(packages)
+        self.run(command)