Beispiel #1
0
    def __build_version(build_home, source, cmode, tag):
        information_str = Glo.CPU + '-' + Glo.SYSTEM + '-' + cmode[:2] + 'bit';
        cur_time_str    = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
        project_reversion_list = list()

        if tag != None:
            url = tag
            project_name   = url[url.rindex("/")+1:]
            revision_code = Pack.__get_svn_info_revision_code(url)
            project_reversion_list.append("project name: %s, revision: %s" % (project_name, revision_code))
        else:
            for index in range(len(source)):
                url = source[index]["trunk"]
                project_name   = url[url.rindex("/")+1:]
                revision_code = SvnLocalOper.get_svn_info_revision_code(url, None)
                project_reversion_list.append("project name: %s, revision: %s" % (project_name, revision_code))

        info_str  = ""
        info_str += "buildc version: " + options.VERSION + os.linesep
        info_str += "information: " + information_str + os.linesep
        info_str += "build time: "  + cur_time_str + os.linesep
        for index in range(len(project_reversion_list)):
            info_str += project_reversion_list[index] + os.linesep

        version_file = open(build_home + os.sep + 'src' + os.sep + 'VERSION', 'w')
        version_file.write(info_str)
        version_file.close()

        print('Build VERSION OK!')
Beispiel #2
0
    def __build_version(build_home, source, cmode, tag):
        information_str = Glo.CPU + '-' + Glo.SYSTEM + '-' + cmode[:2] + 'bit'
        cur_time_str = time.strftime("%Y-%m-%d %H:%M:%S",
                                     time.localtime(time.time()))
        project_reversion_list = list()

        if tag != None:
            url = tag
            project_name = url[url.rindex("/") + 1:]
            revision_code = Pack.__get_svn_info_revision_code(url)
            project_reversion_list.append("project name: %s, revision: %s" %
                                          (project_name, revision_code))
        else:
            for index in range(len(source)):
                url = source[index]["trunk"]
                project_name = url[url.rindex("/") + 1:]
                revision_code = SvnLocalOper.get_svn_info_revision_code(
                    url, None)
                project_reversion_list.append(
                    "project name: %s, revision: %s" %
                    (project_name, revision_code))

        info_str = ""
        info_str += "buildc version: " + options.VERSION + os.linesep
        info_str += "information: " + information_str + os.linesep
        info_str += "build time: " + cur_time_str + os.linesep
        for index in range(len(project_reversion_list)):
            info_str += project_reversion_list[index] + os.linesep

        version_file = open(build_home + os.sep + 'src' + os.sep + 'VERSION',
                            'w')
        version_file.write(info_str)
        version_file.close()

        print('Build VERSION OK!')
Beispiel #3
0
    def __build_component_src(build_home, url, cmode, force_update):
        if not os.path.exists(build_home + os.sep + '.build'):
            Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        Util.execute_and_output('rm -rf ' + url[url.rindex("/")+1:])
        SvnLocalOper.export(url, None, None, Glo.source_svn_user(), Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

        source_home = build_home + '/.build/' + url[url.rindex("/")+1:]
        os.chdir(source_home)
        print "Cd " + source_home

        is_valid = Makerules.config_make(cmode, force_update, "$(shell cd ../.; pwd)/deps", "$(shell cd .; pwd)")
        if is_valid == False:
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        print "Config Make.rules OK!"
        Util.execute_and_output('rm -f buildc.cfg')
        print "Remove buildc.cfg OK!"

        cmd_str =\
"""#! /bin/sh

topdir=`pwd`
parentdir=`cd ../.; pwd`
sed -e "1,$ s%=.*@topdir@%= $topdir#@topdir@%g" Make.rules |\
sed -e "1,$ s%\$(shell cd ../.; pwd)/deps%$parentdir/deps%g"\
> .Make.rules
mv .Make.rules Make.rules

echo "config Make.rules OK!"
"""
        f = open("configure", "w")
        f.write(cmd_str)
        f.close()
        Util.execute_and_output('chmod +x configure')
        print "Create configure OK!"

        os.chdir(build_home)
        print "Cd " + build_home

        print 'Build src [' + url + '] OK!'
        return True
Beispiel #4
0
    def __build_component_deps(build_home, url, cmode, force_update):
        if not os.path.exists(build_home + os.sep + '.build'):
            Util.execute_and_output('mkdir -p ' + build_home + os.sep +
                                    '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        Util.execute_and_output('rm -rf ' + url[url.rindex("/") + 1:])
        SvnLocalOper.export(url, None, None, Glo.source_svn_user(),
                            Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

        source_home = build_home + '/.build/' + url[url.rindex("/") + 1:]
        os.chdir(source_home)
        print "Cd " + source_home

        dotrc = Glo.dot_buildc_rc_path()
        if not os.path.exists(dotrc):
            print('Can not found ' + dotrc)
            print('Please run buildc init and then config .buildc.rc!')
            sys.exit(Errors.conf_file_not_found)
        buildc_rc = Load.load_dot_buildc_rc(dotrc)

        buildc_cfg = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())

        is_valid = Cache.cache_build_by_external_libs(buildc_cfg.external_libs,
                                                      cmode, force_update)
        if is_valid == False:
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        dotrepository = Glo.dot_buildc_repository_path()
        svn_tree = SvnTree()
        svn_tree.import_format_tree_from_file(dotrepository)
        for dependence in buildc_cfg.external_libs:
            Pack.__copy_dependent_all(dependence, svn_tree, buildc_rc,
                                      build_home, cmode)

        os.chdir(build_home)
        print "Cd " + build_home

        print 'Build deps [' + url + '] OK!'
        return True
Beispiel #5
0
    def __build_component_deps(build_home, url, cmode, force_update):
        if not os.path.exists(build_home + os.sep + '.build'):
            Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        Util.execute_and_output('rm -rf ' + url[url.rindex("/")+1:])
        SvnLocalOper.export(url, None, None, Glo.source_svn_user(), Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

        source_home = build_home + '/.build/' + url[url.rindex("/")+1:]
        os.chdir(source_home)
        print "Cd " + source_home

        dotrc = Glo.dot_buildc_rc_path()
        if not os.path.exists(dotrc):
            print('Can not found ' + dotrc)
            print('Please run buildc init and then config .buildc.rc!')
            sys.exit(Errors.conf_file_not_found)
        buildc_rc = Load.load_dot_buildc_rc(dotrc)

        buildc_cfg = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())

        is_valid = Cache.cache_build_by_external_libs(buildc_cfg.external_libs, cmode, force_update)
        if is_valid == False:
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        dotrepository  = Glo.dot_buildc_repository_path()
        svn_tree = SvnTree()
        svn_tree.import_format_tree_from_file(dotrepository)
        for dependence in buildc_cfg.external_libs:
            Pack.__copy_dependent_all(dependence, svn_tree, buildc_rc, build_home, cmode)

        os.chdir(build_home)
        print "Cd " + build_home

        print 'Build deps [' + url + '] OK!'
        return True
Beispiel #6
0
    def __build_source(build_home, url, cmode, force_update, binary_prefix,
                       pack_path):
        Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        SvnLocalOper.export(url, None, None, Glo.source_svn_user(),
                            Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

        source_home = build_home + os.sep + '.build' + os.sep + url[
            url.rindex("/") + 1:]
        os.chdir(source_home)
        print "Cd " + source_home

        result = Makerules.config_make(cmode, force_update)
        if result == False:
            print "Config Make.rules Error!"
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        print "Config Make.rules OK!"

        Pack.__make(cmode)
        print "Make OK!"

        if pack_path != "":
            des_path = build_home + os.sep + 'src' + os.sep + pack_path
            if not os.path.exists(des_path):
                os.mkdir(des_path)
            Util.execute_and_output('cp ' + binary_prefix + '* ' + des_path)
            print "Copy binary file to [" + build_home + os.sep + 'src' + os.sep + pack_path + ']' + " OK!"

        os.chdir(build_home)
        print "Cd " + build_home

        print 'Build source [' + url + '] OK!'
        return True
Beispiel #7
0
    def __build_source(build_home, url, cmode, force_update, binary_prefix, pack_path):
        Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        SvnLocalOper.export(url, None, None, Glo.source_svn_user(), Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

        source_home = build_home + os.sep + '.build' + os.sep + url[url.rindex("/")+1:]
        os.chdir(source_home)
        print "Cd " + source_home

        result = Makerules.config_make(cmode, force_update)
        if result == False:
            print "Config Make.rules Error!"
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        print "Config Make.rules OK!"

        Pack.__make(cmode)
        print "Make OK!"

        if pack_path != "":
            des_path = build_home + os.sep + 'src' + os.sep + pack_path
            if not os.path.exists(des_path):
                os.mkdir(des_path)
            Util.execute_and_output('cp ' + binary_prefix + '* ' + des_path)
            print "Copy binary file to [" + build_home + os.sep + 'src' + os.sep + pack_path + ']' + " OK!"

        os.chdir(build_home)
        print "Cd " + build_home

        print 'Build source [' + url + '] OK!'
        return True
Beispiel #8
0
    def update_tree(self, item, cmode, ignore_error):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while(h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if str(item_text).find("_" + cmode[0:2] + "_") != -1:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]
                    real_svn_path = str(full_svn_path).replace('|', '/')

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|')]
                    cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[str(full_svn_path).find('|')+1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(real_cache_path).rfind('/')]
                    real_cache_name_path    = real_cache_version_path[:str(real_cache_version_path).rfind('/')]
                    dep_libname    = real_cache_name_path[str(real_cache_name_path).rfind('/')+1:]
                    dep_libversion = real_cache_version_path[str(real_cache_version_path).rfind('/')+1:]
                    (trunk_user, trunk_passwd) = self.__get_user_and_passwd_by_url(svn_root_path)
                    svn_revision_code = SvnLocalOper.get_svn_info_revision_code(real_svn_path, True, trunk_user, trunk_passwd)
                    if h_child_item.data == 'none':
                        if os.path.exists(real_cache_path):
                            Util.execute_and_return("rm -rf " + real_cache_path)

                    else:
                        if not os.path.exists(real_cache_path):
                            print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                            print 'Checkout [' + real_svn_path + ']...'
                            SvnLocalOper.checkout(real_svn_path, real_cache_path, ignore_error, trunk_user, trunk_passwd)
                            print 'Checkout [' + real_svn_path + '] OK!'
                        else:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(real_cache_path, None)
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                SvnLocalOper.update(real_cache_path, ignore_error, trunk_user, trunk_passwd)
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'

                        h_child_item.data = svn_revision_code

            self.update_tree(h_child_item, cmode, ignore_error)
            h_child_item = self.get_next_sibling_item(h_child_item)
Beispiel #9
0
    def build_tree(self, search_path, cur_level, level_max = -1, trunk_user = None, trunk_pass = None):
        if cur_level > level_max:
            return

        svn_path = search_path.replace("|", "/")
        item_nodes = SvnLocalOper.get_svn_ls(svn_path, None, trunk_user, trunk_pass)
        if len(item_nodes) == 0:
            return

        is_dir = True
        for item_node in item_nodes:
            if item_node[-1] == "/":
                item_node = item_node[:-1]
                is_dir = True
            else:
                is_dir = False

            node_path = search_path + '|' + item_node
            self.add_item(node_path, '|', True, False, False)

            if is_dir == True:
                cur_level = cur_level + 1
                SvnTree.build_tree(self, node_path, cur_level, level_max, trunk_user, trunk_pass)
                cur_level = cur_level - 1
Beispiel #10
0
    def build_dependent(self, dep_libname, dep_libversion, cmode, force_update = True):
        lib_flag = False

        h_child_item = self.get_root_item()
        while(h_child_item != None):
            svn_root_path = self.get_item_text(h_child_item)
            full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM
            real_svn_path = str(full_svn_path).replace('|', '/')
            leaf_node = self.find_item(full_svn_path, '|', False, 1)
            if leaf_node != None:
                lib_flag = True

                cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories)
                if cache_root_path == None:
                    print svn_root_path + ' does not exist in .buildc.rc'
                    sys.exit(Errors.conf_item_not_found)

                full_cache_path = cache_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM
                real_cache_path = str(full_cache_path).replace('|', '/')
                (trunk_user, trunk_passwd) = self.__get_user_and_passwd_by_url(svn_root_path)
                svn_revision_code = SvnLocalOper.get_svn_info_revision_code(real_svn_path, True, trunk_user, trunk_passwd)
                if svn_revision_code == "":
                    return False
                if leaf_node.data == 'none':
                    if os.path.exists(real_cache_path):
                        Util.execute_and_return("rm -rf " + real_cache_path)

                    print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                    print 'Checkout [' + real_svn_path + ']...'
                    result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd)
                    if result == False:
                        return False
                    print 'Checkout [' + real_svn_path + '] OK!'
                    leaf_node.data = svn_revision_code
                else:
                    if not os.path.exists(real_cache_path):
                        print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                        print 'Checkout [' + real_svn_path + ']...'
                        result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd)
                        if result == False:
                            return False
                        print 'Checkout [' + real_svn_path + '] OK!'
                        leaf_node.data = svn_revision_code
                    else:
                        if force_update:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(real_cache_path, True)
                            if cache_revision_code == "":
                                return False
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                result = SvnLocalOper.update(real_cache_path, True, trunk_user, trunk_passwd)
                                if result == False:
                                    return False
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'
                            leaf_node.data = svn_revision_code
                        else:
                            print "Do not use force_update, skip the update check!"
                            pass

                break

            h_child_item = self.get_next_sibling_item(h_child_item)

        if lib_flag == True:
            return True
        else:
            return False
Beispiel #11
0
    def build_dependent(self,
                        dep_libname,
                        dep_libversion,
                        cmode,
                        force_update=True):
        lib_flag = False

        h_child_item = self.get_root_item()
        while (h_child_item != None):
            svn_root_path = self.get_item_text(h_child_item)
            full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[
                0:2] + '_' + Glo.SYSTEM
            real_svn_path = str(full_svn_path).replace('|', '/')
            leaf_node = self.find_item(full_svn_path, '|', False, 1)
            if leaf_node != None:
                lib_flag = True

                cache_root_path = Glo.get_local_cache_path(
                    svn_root_path, self.__repositories)
                if cache_root_path == None:
                    print svn_root_path + ' does not exist in .buildc.rc'
                    sys.exit(Errors.conf_item_not_found)

                full_cache_path = cache_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[
                    0:2] + '_' + Glo.SYSTEM
                real_cache_path = str(full_cache_path).replace('|', '/')
                (trunk_user, trunk_passwd
                 ) = self.__get_user_and_passwd_by_url(svn_root_path)
                svn_revision_code = SvnLocalOper.get_svn_info_revision_code(
                    real_svn_path, True, trunk_user, trunk_passwd)
                if svn_revision_code == "":
                    return False
                if leaf_node.data == 'none':
                    if os.path.exists(real_cache_path):
                        Util.execute_and_return("rm -rf " + real_cache_path)

                    print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                    print 'Checkout [' + real_svn_path + ']...'
                    result = SvnLocalOper.checkout(real_svn_path,
                                                   real_cache_path, True,
                                                   trunk_user, trunk_passwd)
                    if result == False:
                        return False
                    print 'Checkout [' + real_svn_path + '] OK!'
                    leaf_node.data = svn_revision_code
                else:
                    if not os.path.exists(real_cache_path):
                        print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                        print 'Checkout [' + real_svn_path + ']...'
                        result = SvnLocalOper.checkout(real_svn_path,
                                                       real_cache_path, True,
                                                       trunk_user,
                                                       trunk_passwd)
                        if result == False:
                            return False
                        print 'Checkout [' + real_svn_path + '] OK!'
                        leaf_node.data = svn_revision_code
                    else:
                        if force_update:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(
                                real_cache_path, True)
                            if cache_revision_code == "":
                                return False
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                result = SvnLocalOper.update(
                                    real_cache_path, True, trunk_user,
                                    trunk_passwd)
                                if result == False:
                                    return False
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'
                            leaf_node.data = svn_revision_code
                        else:
                            print "Do not use force_update, skip the update check!"
                            pass

                break

            h_child_item = self.get_next_sibling_item(h_child_item)

        if lib_flag == True:
            return True
        else:
            return False
Beispiel #12
0
    def update_tree(self, item, cmode, ignore_error):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while (h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if str(item_text).find("_" + cmode[0:2] + "_") != -1:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]
                    real_svn_path = str(full_svn_path).replace('|', '/')

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|'
                                                                           )]
                    cache_root_path = Glo.get_local_cache_path(
                        svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[
                        str(full_svn_path).find('|') + 1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(
                        real_cache_path).rfind('/')]
                    real_cache_name_path = real_cache_version_path[:str(
                        real_cache_version_path).rfind('/')]
                    dep_libname = real_cache_name_path[str(real_cache_name_path
                                                           ).rfind('/') + 1:]
                    dep_libversion = real_cache_version_path[
                        str(real_cache_version_path).rfind('/') + 1:]
                    (trunk_user, trunk_passwd
                     ) = self.__get_user_and_passwd_by_url(svn_root_path)
                    svn_revision_code = SvnLocalOper.get_svn_info_revision_code(
                        real_svn_path, True, trunk_user, trunk_passwd)
                    if h_child_item.data == 'none':
                        if os.path.exists(real_cache_path):
                            Util.execute_and_return("rm -rf " +
                                                    real_cache_path)

                    else:
                        if not os.path.exists(real_cache_path):
                            print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                            print 'Checkout [' + real_svn_path + ']...'
                            SvnLocalOper.checkout(real_svn_path,
                                                  real_cache_path,
                                                  ignore_error, trunk_user,
                                                  trunk_passwd)
                            print 'Checkout [' + real_svn_path + '] OK!'
                        else:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(
                                real_cache_path, None)
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                SvnLocalOper.update(real_cache_path,
                                                    ignore_error, trunk_user,
                                                    trunk_passwd)
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'

                        h_child_item.data = svn_revision_code

            self.update_tree(h_child_item, cmode, ignore_error)
            h_child_item = self.get_next_sibling_item(h_child_item)