Include boostrap packages list into deboostrap call
This commit includes the packages listed in boostrap section to the debootstrap call instead chrooting into the new root tree and call apt. Fixes #1587
This commit is contained in:
parent
23f7e5025b
commit
c5d51ec86e
@ -143,16 +143,22 @@ class PackageManagerApt(PackageManagerBase):
|
||||
cmd.append('--no-check-gpg')
|
||||
if self.deboostrap_minbase:
|
||||
cmd.append('--variant=minbase')
|
||||
if self.package_requests:
|
||||
cmd.append(
|
||||
'--include={}'.format(','.join(self.package_requests))
|
||||
)
|
||||
if self.repository.components:
|
||||
cmd.append(
|
||||
'--components={0}'.format(
|
||||
','.join(self.repository.components)
|
||||
)
|
||||
)
|
||||
self.cleanup_requests()
|
||||
cmd.extend([
|
||||
self.distribution, bootstrap_dir, self.distribution_path
|
||||
])
|
||||
Command.run(cmd, self.command_env)
|
||||
result = Command.call(cmd, self.command_env)
|
||||
output, error = result.process.communicate()
|
||||
data = DataSync(
|
||||
bootstrap_dir + '/', self.root_dir
|
||||
)
|
||||
@ -167,7 +173,7 @@ class PackageManagerApt(PackageManagerBase):
|
||||
finally:
|
||||
Path.wipe(bootstrap_dir)
|
||||
|
||||
return self.process_install_requests()
|
||||
return result
|
||||
|
||||
def process_install_requests(self):
|
||||
"""
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import logging
|
||||
from mock import (
|
||||
patch, call
|
||||
)
|
||||
from mock import patch
|
||||
from pytest import (
|
||||
raises, fixture
|
||||
)
|
||||
@ -70,14 +68,14 @@ class TestPackageManagerApt:
|
||||
with raises(KiwiDebootstrapError):
|
||||
self.manager.process_install_requests_bootstrap()
|
||||
|
||||
@patch('kiwi.command.Command.run')
|
||||
@patch('kiwi.command.Command.call')
|
||||
@patch('os.path.exists')
|
||||
@patch('kiwi.package_manager.apt.Path.wipe')
|
||||
def test_process_install_requests_bootstrap_failed_debootstrap(
|
||||
self, mock_wipe, mock_exists, mock_run
|
||||
self, mock_wipe, mock_exists, mock_call
|
||||
):
|
||||
self.manager.request_package('apt-get')
|
||||
mock_run.side_effect = Exception
|
||||
mock_call.side_effect = Exception
|
||||
mock_exists.return_value = True
|
||||
with raises(KiwiDebootstrapError):
|
||||
self.manager.process_install_requests_bootstrap()
|
||||
@ -91,6 +89,9 @@ class TestPackageManagerApt:
|
||||
):
|
||||
self.manager.request_package('apt-get')
|
||||
self.manager.request_package('vim')
|
||||
call_result = mock.Mock()
|
||||
call_result.process.communicate.return_value = ('stdout', 'stderr')
|
||||
mock_call.return_value = call_result
|
||||
data = mock.Mock()
|
||||
mock_sync.return_value = data
|
||||
mock_exists.return_value = True
|
||||
@ -102,40 +103,30 @@ class TestPackageManagerApt:
|
||||
options=['-a', '-H', '-X', '-A', '--one-file-system', '--inplace'],
|
||||
exclude=['proc', 'sys', 'dev']
|
||||
)
|
||||
assert mock_run.call_args_list == [
|
||||
call(
|
||||
[
|
||||
'debootstrap', '--keyring=trusted.gpg',
|
||||
'--variant=minbase', '--components=main,restricted',
|
||||
'xenial', 'root-dir.debootstrap', 'xenial_path'
|
||||
], ['env']
|
||||
),
|
||||
call(
|
||||
['rm', '-r', '-f', 'root-dir.debootstrap']
|
||||
),
|
||||
call(
|
||||
[
|
||||
'chroot', 'root-dir', 'apt-get',
|
||||
'-c', 'apt.conf', '-y', 'update'
|
||||
], ['env']
|
||||
)
|
||||
]
|
||||
mock_call.assert_called_once_with([
|
||||
'chroot', 'root-dir', 'apt-get',
|
||||
'-c', 'apt.conf', '-y', 'install', 'vim'],
|
||||
['env']
|
||||
mock_call.assert_called_once_with(
|
||||
[
|
||||
'debootstrap', '--keyring=trusted.gpg',
|
||||
'--variant=minbase', '--include=vim',
|
||||
'--components=main,restricted', 'xenial',
|
||||
'root-dir.debootstrap', 'xenial_path'
|
||||
], ['env']
|
||||
)
|
||||
mock_run.assert_called_once_with(
|
||||
['rm', '-r', '-f', 'root-dir.debootstrap']
|
||||
)
|
||||
|
||||
@patch('kiwi.command.Command.call')
|
||||
@patch('kiwi.command.Command.run')
|
||||
@patch('os.path.exists')
|
||||
@patch('kiwi.package_manager.apt.DataSync')
|
||||
def test_process_install_requests_bootstrap_no_gpg_check(
|
||||
self, mock_sync, mock_exists, mock_run, mock_call
|
||||
self, mock_sync, mock_exists, mock_call
|
||||
):
|
||||
self.manager.request_package('apt-get')
|
||||
self.manager.request_package('vim')
|
||||
data = mock.Mock()
|
||||
call_result = mock.Mock()
|
||||
call_result.process.communicate.return_value = ('stdout', 'stderr')
|
||||
mock_call.return_value = call_result
|
||||
mock_sync.return_value = data
|
||||
mock_exists.side_effect = lambda x: True if 'xenial' in x else False
|
||||
self.manager.process_install_requests_bootstrap()
|
||||
@ -146,25 +137,13 @@ class TestPackageManagerApt:
|
||||
options=['-a', '-H', '-X', '-A', '--one-file-system', '--inplace'],
|
||||
exclude=['proc', 'sys', 'dev']
|
||||
)
|
||||
assert mock_run.call_args_list == [
|
||||
call(
|
||||
[
|
||||
'debootstrap', '--no-check-gpg',
|
||||
'--variant=minbase', '--components=main,restricted',
|
||||
'xenial', 'root-dir.debootstrap', 'xenial_path'
|
||||
], ['env']
|
||||
),
|
||||
call(
|
||||
[
|
||||
'chroot', 'root-dir', 'apt-get',
|
||||
'-c', 'apt.conf', '-y', 'update'
|
||||
], ['env']
|
||||
)
|
||||
]
|
||||
mock_call.assert_called_once_with([
|
||||
'chroot', 'root-dir', 'apt-get',
|
||||
'-c', 'apt.conf', '-y', 'install', 'vim'],
|
||||
['env']
|
||||
mock_call.assert_called_once_with(
|
||||
[
|
||||
'debootstrap', '--no-check-gpg',
|
||||
'--variant=minbase', '--include=vim',
|
||||
'--components=main,restricted', 'xenial',
|
||||
'root-dir.debootstrap', 'xenial_path'
|
||||
], ['env']
|
||||
)
|
||||
|
||||
@patch('kiwi.command.Command.call')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user