示例#1
0
 def prepare_image(self):
     # Run `snap prepare-image` on the model.assertion.  sudo is currently
     # required in all cases, but eventually, it won't be necessary at
     # least for UEFI support.
     snap(self.args.model_assertion, self.unpackdir, self.args.channel,
          self.args.extra_snaps)
     self._next.append(self.load_gadget_yaml)
示例#2
0
 def prepare_image(self):
     try:
         snap(self.args.model_assertion, self.unpackdir, self.args.channel,
              self.args.extra_snaps)
     except CalledProcessError:
         if self.args.debug:
             _logger.exception('Full debug traceback follows')
         self.exitcode = 1
         # Stop the state machine right here by not appending a next step.
     else:
         self._next.append(self.load_gadget_yaml)
示例#3
0
 def run(self, model_assertion, root_dir, channel=None):
     run_tmp = os.path.join(self._tmpdir,
                            self._checksum(model_assertion, channel))
     tmp_root = os.path.join(run_tmp, 'root')
     if not os.path.isdir(run_tmp):
         os.makedirs(tmp_root)
         snap(model_assertion, tmp_root, channel)
     # copytree() requires that the destination directories do not exist.
     # Since this code only ever executes during the test suite, and even
     # though only when mocking `snap` for speed, this is always safe.
     shutil.rmtree(root_dir, ignore_errors=True)
     shutil.copytree(tmp_root, root_dir)
示例#4
0
 def test_snap(self):
     model = resource_filename('ubuntu_image.tests.data', 'model.assertion')
     with ExitStack() as resources:
         resources.enter_context(LogCapture())
         mock = resources.enter_context(
             patch('ubuntu_image.helpers.subprocess_run',
                   return_value=FakeProc()))
         tmpdir = resources.enter_context(TemporaryDirectory())
         snap(model, tmpdir)
         self.assertEqual(len(mock.call_args_list), 1)
         args, kws = mock.call_args_list[0]
     self.assertEqual(args[0], ['snap', 'prepare-image', model, tmpdir])
示例#5
0
 def test_snap(self):
     model = resource_filename('ubuntu_image.tests.data', 'model.assertion')
     with ExitStack() as resources:
         resources.enter_context(LogCapture())
         mock = resources.enter_context(
             patch('ubuntu_image.helpers.subprocess_run',
                   return_value=FakeProc()))
         tmpdir = resources.enter_context(TemporaryDirectory())
         snap(model, tmpdir)
         self.assertEqual(len(mock.call_args_list), 1)
         args, kws = mock.call_args_list[0]
     self.assertEqual(args[0], ['snap', 'prepare-image', model, tmpdir])
 def prepare_image(self):
     try:
         snap(self.args.model_assertion, self.unpackdir,
              self.args.channel, self.args.extra_snaps)
     except CalledProcessError:
         if self.args.debug:
             _logger.exception('Full debug traceback follows')
         self.exitcode = 1
         # Stop the state machine right here by not appending a next step.
     else:
         self.yaml_file_path = os.path.join(
             self.unpackdir, 'gadget', 'meta', 'gadget.yaml')
         super().prepare_image()
示例#7
0
 def prepare_image(self):
     # Since some people might still use the deprecated extra-snaps syntax,
     # combine the two argument lists before sending it out to
     # prepare-image.
     extra_snaps = (self.args.snap or []) + (self.args.extra_snaps or [])
     try:
         snap(self.args.model_assertion, self.unpackdir, self.args.channel,
              extra_snaps)
     except CalledProcessError:
         if self.args.debug:
             _logger.exception('Full debug traceback follows')
         self.exitcode = 1
         # Stop the state machine right here by not appending a next step.
     else:
         self.yaml_file_path = os.path.join(self.unpackdir, 'gadget',
                                            'meta', 'gadget.yaml')
         super().prepare_image()
示例#8
0
 def prepare_image(self):
     snap(self.args.model_assertion, self.unpackdir, self.args.channel,
          self.args.extra_snaps)
     self._next.append(self.load_gadget_yaml)