def test_create_toolchains_from_file_definition(self): with prepare_template( get_test_data('toolchain_definition_template.yaml'), URL1=get_toolchain_test_data('tgz_archive.tgz'), NAME1='zenterio-tgz-archive.', DEPENDS1='dpkg', URL2=get_toolchain_test_data('toolchain_dir'), NAME2='zenterio-toolchain-dir') as definition_file: command = 'zdeb-packer --verbose toolchain-list --file {file}'.format( file=definition_file) invoke_for_output(command, cwd=self.test_root) self.assert_file_exists( os.path.join(self.test_root, 'zenterio-tgz-archive*.deb')) self.assert_file_exists( os.path.join(self.test_root, 'zenterio-toolchain-dir*.deb')) debs = glob.glob(os.path.join(self.test_root, '*.deb')) debs.sort() self.assertEqual(2, len(debs)) tgz_toolchain_files = map( lambda path: os.path.join(path, 'file'), ['/tmp/install/tool1', '/tmp/install/tools/tool1']) self.assert_correct_toolchain(debs[0], 'zenterio-tgz-archive', tgz_toolchain_files, 'This is the tgz archive.\n') self.assert_correct_toolchain( debs[1], 'zenterio-toolchain-dir', ['/tmp/install/tool2/file', '/tmp/install/tool2_link/file'], 'This is the file in toolchain_dir.')
def test_create_toolchain_deb_package_from_local_archive(self): out_dir = os.path.join(self.test_root, 'out_dir') uri = get_toolchain_test_data('tgz_archive.tgz') install_path_1 = '/tmp/installation/path/tgz_archive' install_path_2 = '/tmp/installation/other/tgz_archive' link = '/tmp/installation/link' package_name = 'zenterio-tgz-archive' command = 'zdeb-packer -v toolchain --uri {uri} --output-dir {out} --workspace {workspace} ' \ '--installation-path {install_path_1} --installation-path {install_path_2} ' \ '--link {link} {install_path_1}/file --force' \ .format(uri=uri, out=out_dir, workspace=self.test_root, install_path_1=install_path_1, install_path_2=install_path_2, link=link) logger.debug(invoke_for_output(command)) deb_path = glob.glob( os.path.join(out_dir, '{package}_*.deb'.format(package=package_name)))[0] self.assert_file_exists(deb_path) debian_dir = os.path.join(self.test_root, 'output', 'debian') self.assert_file_regex( os.path.join(debian_dir, 'changelog'), r'{package} \(1.0.0\) unstable; urgency=low'.format( package=package_name)) self.assert_file_regex( os.path.join(debian_dir, 'control'), r'Source: {package}'.format(package=package_name)) toolchain_files = list( map(lambda path: os.path.join(path, 'file'), [install_path_1, install_path_2])) toolchain_files.append(link) self.assert_correct_toolchain(deb_path, package_name, toolchain_files, 'This is the tgz archive.\n')
def test_install_toolchain_with_broken_dependency_fails(self): with prepare_template( get_test_data('toolchain_definition_template.yaml'), URL1=get_toolchain_test_data('tgz_archive.tgz'), NAME1='zenterio-tgz-archive.', DEPENDS1='does-not-exist', URL2=get_toolchain_test_data('toolchain_dir'), NAME2='zenterio-toolchain-dir') as definition_file: command = 'zdeb-packer --verbose toolchain-list --file {file}'.format( file=definition_file) invoke_for_output(command, cwd=self.test_root) expected_deb = glob.glob( os.path.join(self.test_root, 'zenterio-tgz-archive*.deb'))[0] self.assert_file_exists(expected_deb) stdout = invoke_for_output( 'sudo gdebi --non-interactive {deb}'.format(deb=expected_deb), expected_exit_code=1) self.assertIn('Dependency is not satisfiable: does-not-exist', stdout)
def setUp(self): self.uri = get_toolchain_test_data('toolchain_dir') self.install_path = [ '/tmp/install/some/path/to/new_dir_name/', '/tmp/install/some/other/path/to/other_dir_name/', '/tmp/install/some/third/path/to/dir_name/' ] self.test_dir_handle = TemporaryDirectory() self.test_dir = self.test_dir_handle.name self.out_dir = os.path.join(self.test_dir, 'dist') self.package_root = os.path.join(self.test_dir, 'output')
def test_create_dummy_toolchains_form_file_definition(self): with prepare_template( get_test_data('toolchain_definition_dummy_template.yaml'), URL1=get_toolchain_test_data('tgz_archive.tgz'), NAME1='zenterio-dummy-1.', DEPENDS1='dpkg', URL2=get_toolchain_test_data('tgz_archive.tgz'), NAME2='zenterio-dummy-2') as definition_file: command = 'zdeb-packer --verbose toolchain-list --file {file} --dummy'.format( file=definition_file) invoke_for_output(command, cwd=self.test_root) for deb in glob.glob( os.path.join(self.test_root, 'zenterio-dummy-*.deb')): invoke_for_output( 'sudo gdebi --non-interactive {deb}'.format(deb=deb), expected_exit_code=0) for path in ('/tmp/dummy/tool1/info.txt', '/tmp/dummy/tool2/info.txt'): with open(path, 'r') as info_file: assert info_file.readline() == 'This is a dummy toolchain.'
def test_create_toolchain_deb_with_minimal_arguments(self): uri = get_toolchain_test_data('toolchain_dir') install_path = '/tmp/path/toolchain_dir/' package_name = 'zenterio-toolchain-dir' command = 'zdeb-packer toolchain --uri {uri} --installation-path {install_path}' \ .format(uri=uri, install_path=install_path) with TemporaryDirectory() as cwd: logger.debug(invoke_for_output(command, cwd=cwd)) deb_path = glob.glob( os.path.join( cwd, '{package}_*.deb'.format(package=package_name)))[0] self.assert_file_exists(deb_path) self.assert_correct_toolchain( deb_path, package_name, [os.path.join(install_path, 'file')], 'This is the file in toolchain_dir.')
def setUp(self): self.tar_gz_archive = get_toolchain_test_data('tar.gz_archive.tar.gz') self.tgz_archive = get_toolchain_test_data('tgz_archive.tgz') self.directory = get_toolchain_test_data('toolchain_dir')
def setUp(self): self.dir_path = get_toolchain_test_data('toolchain_dir') self.path = get_toolchain_test_data('tar.gz_archive.tar.gz') self.uri = 'file://{path}'.format(path=self.path)