コード例 #1
0
    def build_package(self, platform, arch_bit, op_id, branding_options,
                      package_types, destination, routing_key):
        buid_request = build.BuildRequest(platform, arch_bit)
        platform = buid_request.platform()
        arch = platform.arch()

        platform_and_arch_str = '{0}_{1}'.format(platform.name(), arch.name())
        dir_name = 'build_{0}_for_{1}'.format(platform_and_arch_str, op_id)
        bs = build.get_supported_build_system_by_name('ninja')

        self.send_status(routing_key, op_id, 20.0, 'Building package')

        def store(progress_min, progress_max, routing_key, op_id):
            def closure(progress, message):
                diff = progress_max - progress_min
                perc = round(progress_min + diff * (progress / 100.0), 1)
                print('{0}% {1}'.format(perc, message))
                sys.stdout.flush()
                self.send_status(routing_key, op_id, perc, message)

            return closure

        store = store(21.0, 79.0, routing_key, op_id)

        saver = build.ProgressSaver(store)
        file_paths = buid_request.build('..', branding_options, dir_name, bs,
                                        package_types, saver)
        file_path = file_paths[0]
        self.send_status(routing_key, op_id, 80.0, 'Loading package to server')
        try:
            result = config.post_install_step(file_path, destination)
        except Exception as ex:
            raise ex

        return result
コード例 #2
0
    def build_package(self, platform, arch_bit, op_id, branding_options, package_types, destination, routing_key):
        buid_request = build.BuildRequest(platform, arch_bit)
        platform = buid_request.platform()
        arch = platform.arch()

        platform_and_arch_str = '{0}_{1}'.format(platform.name(), arch.name())
        dir_name = 'build_{0}_for_{1}'.format(platform_and_arch_str, op_id)
        bs = build.get_supported_build_system_by_name('ninja')

        self.send_status(routing_key, op_id, 20.0, 'Building package')

        def store(progress_min, progress_max, routing_key, op_id):
            def closure(progress, message):
                diff = progress_max - progress_min
                perc = round(progress_min + diff * (progress / 100.0), 1)
                print('{0}% {1}'.format(perc, message))
                sys.stdout.flush()
                self.send_status(routing_key, op_id, perc, message)

            return closure

        store = store(21.0, 79.0, routing_key, op_id)

        saver = build.ProgressSaver(store)
        file_paths = buid_request.build('..', branding_options, dir_name, bs, package_types, saver)
        file_path = file_paths[0]
        self.send_status(routing_key, op_id, 80.0, 'Loading package to server')
        try:
            result = config.post_install_step(file_path, destination)
        except Exception as ex:
            raise ex

        return result
コード例 #3
0
    def build_package(self, op_id, platform, arch, branding_variables, package_type, destination, status_channel, routing_key):

        platform_or_none = base.get_supported_platform_by_name(platform)

        if platform_or_none == None:
            raise BuildError('invalid platform')

        if not arch in platform_or_none.archs:
            raise BuildError('invalid arch')
        if not package_type in platform_or_none.package_types:
            raise BuildError('invalid package_type')

        pwd = os.getcwd()
        dir_name = 'build_{0}_for_{1}'.format(platform, op_id)
        if os.path.exists(dir_name):
            shutil.rmtree(dir_name)

        os.mkdir(dir_name)
        os.chdir(dir_name)

        arch_args = '-DOS_ARCH={0}'.format(arch)
        generator_args = '-DCPACK_GENERATOR={0}'.format(package_type)
        branding_variables_list = shlex.split(branding_variables)
        cmake_line = ['cmake', '../../', '-GUnix Makefiles', '-DCMAKE_BUILD_TYPE=RELEASE', generator_args, arch_args]
        cmake_line.extend(branding_variables_list)
        try:
            run_command(cmake_line)
        except subprocess.CalledProcessError as ex:
            os.chdir(pwd)
            raise ex
            
        self.send_status(status_channel, routing_key, op_id, 20, 'Building package')
                         
        make_line = ['make', 'package', '-j2']
        try:
            run_command(make_line)
        except subprocess.CalledProcessError as ex:
            os.chdir(pwd)
            raise ex

        self.send_status(status_channel, routing_key, op_id, 70, 'Stable package')
        
        in_file = open('CPackConfig.cmake', 'r')
        for line in in_file.readlines():
            res = re.search(r'SET\(CPACK_SOURCE_PACKAGE_FILE_NAME "(.+)"\)', line)
            if res != None:
                filename = res.group(1) + '.' + base.get_extension_by_package(package_type)
        in_file.close()

        try:
            self.send_status(status_channel, routing_key, op_id, 80, 'Loading package to server')
            result = config.post_install_step(filename, destination)
        except Exception as ex:
            os.chdir(pwd)
            raise ex

        os.chdir(pwd)
        return result
コード例 #4
0
    def build_package(self, op_id, platform, arch, branding_variables,
                      package_type, destination, status_channel, routing_key):

        platform_or_none = base.get_supported_platform_by_name(platform)

        if platform_or_none == None:
            raise BuildError('invalid platform')

        if not arch in platform_or_none.archs:
            raise BuildError('invalid arch')
        if not package_type in platform_or_none.package_types:
            raise BuildError('invalid package_type')

        pwd = os.getcwd()
        dir_name = 'build_{0}_for_{1}'.format(platform, op_id)
        if os.path.exists(dir_name):
            shutil.rmtree(dir_name)

        os.mkdir(dir_name)
        os.chdir(dir_name)

        arch_args = '-DOS_ARCH={0}'.format(arch)
        generator_args = '-DCPACK_GENERATOR={0}'.format(package_type)
        branding_variables_list = shlex.split(branding_variables)
        cmake_line = [
            'cmake', '../../', '-GUnix Makefiles',
            '-DCMAKE_BUILD_TYPE=RELEASE', generator_args, arch_args
        ]
        cmake_line.extend(branding_variables_list)
        try:
            run_command(cmake_line)
        except subprocess.CalledProcessError as ex:
            os.chdir(pwd)
            raise ex

        self.send_status(status_channel, routing_key, op_id, 20,
                         'Building package')

        make_line = ['make', 'package', '-j2']
        try:
            run_command(make_line)
        except subprocess.CalledProcessError as ex:
            os.chdir(pwd)
            raise ex

        self.send_status(status_channel, routing_key, op_id, 70,
                         'Stable package')

        in_file = open('CPackConfig.cmake', 'r')
        for line in in_file.readlines():
            res = re.search(r'SET\(CPACK_SOURCE_PACKAGE_FILE_NAME "(.+)"\)',
                            line)
            if res != None:
                filename = res.group(1) + '.' + base.get_extension_by_package(
                    package_type)
        in_file.close()

        try:
            self.send_status(status_channel, routing_key, op_id, 80,
                             'Loading package to server')
            result = config.post_install_step(filename, destination)
        except Exception as ex:
            os.chdir(pwd)
            raise ex

        os.chdir(pwd)
        return result