Ejemplo n.º 1
0
def do_build(iface, target, feat, rebuild=True, dstfolder=None):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    if target == "src-fullpatch":
        dstfolder = "build/src"
        target = "test-fullpatch"

    build_instructions = oi.get_build_actions(target, feat, dstfolder)
    if build_instructions is None:
        iface.error("Error al generar las instrucciones de compilado.")
        return False
    buildpath = os.path.join(build_instructions.get("path"), "build")
    if not os.path.exists(buildpath):
        os.mkdir(buildpath)
    dstfile = os.path.join(buildpath, "%s.build.xml" % target)
    build_instructions.getroottree().write(dstfile, pretty_print=True)
    depends = build_instructions.get("depends", "").split(" ")
    if depends:
        for dep in depends:
            dep = dep.strip()
            if dep == "": continue
            if not is_target_built(iface, dep, feat):
                # Si tiene una dependencia, y no está cumplida, recompilarla:
                do_build(iface, dep, feat, rebuild=False)

    mtool_iface = MergeToolInterface()
    mtool_iface.verbosity = iface.verbosity + cfg.mergetool.verbosity_delta
    mtool_iface.patch_qs_rewrite = cfg.mergetool.patch_qs_rewrite
    mtool_iface.patch_xml_style_name = cfg.mergetool.patch_xml_style_name
    mtool_iface.diff_xml_search_move = cfg.mergetool.diff_xml_search_move

    projectbuilder.build_xml(mtool_iface, build_instructions, rebuild)
Ejemplo n.º 2
0
def do_build(iface,target, feat, rebuild=True, dstfolder = None):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    if target == "src-fullpatch":
        dstfolder = "build/src"
        target = "test-fullpatch"
        
    build_instructions = oi.get_build_actions(target,feat,dstfolder)
    if build_instructions is None: 
        iface.error("Error al generar las instrucciones de compilado.")
        return False
    buildpath = os.path.join(build_instructions.get("path"), "build")
    if not os.path.exists(buildpath):
        os.mkdir(buildpath)
    dstfile = os.path.join(buildpath, "%s.build.xml" % target)
    build_instructions.getroottree().write(dstfile, pretty_print=True)
    depends = build_instructions.get("depends", "").split(" ")
    if depends:
        for dep in depends: 
            dep = dep.strip()
            if dep == "": continue
            if not is_target_built(iface, dep, feat):
                # Si tiene una dependencia, y no está cumplida, recompilarla:
                do_build(iface, dep, feat, rebuild = False)
                
    mtool_iface = MergeToolInterface()
    mtool_iface.verbosity = iface.verbosity
    projectbuilder.build_xml(mtool_iface,build_instructions,rebuild)
Ejemplo n.º 3
0
def list_objects(iface):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    iface.msg(u"\nMódulos cargados:")
    for obj in sorted(oi.modules(), key=lambda obj:obj.formal_name()):
        iface.msg(u" - %s" % obj.formal_name())

    iface.msg(u"\nFuncionalidades cargadas:")
    for obj in sorted(oi.features(), key=lambda obj:obj.formal_name()):
        iface.msg(u" - %s" % obj.formal_name())
Ejemplo n.º 4
0
def do_howto_build(iface,target, feat):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    build_instructions = oi.get_build_actions(target,feat)
    if build_instructions is None:
        iface.error("Error al buscar %s -> %s" % (feat,target))
        return False
    iface.info("Acciones para compilar funcionalidad %s %s:" % (feat, target))
    iface.msg(etree.tostring(build_instructions, pretty_print=True))
    buildpath = os.path.join(build_instructions.get("path"), "build")
    if not os.path.exists(buildpath):
        os.mkdir(buildpath)
    dstfile = os.path.join(buildpath, "%s.build.xml" % target)
    build_instructions.getroottree().write(dstfile, pretty_print=True)
Ejemplo n.º 5
0
def do_howto_build(iface, target, feat):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    build_instructions = oi.get_build_actions(target, feat)
    if build_instructions is None:
        iface.error("Error al buscar %s -> %s" % (feat, target))
        return False
    iface.info("Acciones para compilar funcionalidad %s %s:" % (feat, target))
    iface.msg(etree.tostring(build_instructions, pretty_print=True))
    buildpath = os.path.join(build_instructions.get("path"), "build")
    if not os.path.exists(buildpath):
        os.mkdir(buildpath)
    dstfile = os.path.join(buildpath, "%s.build.xml" % target)
    build_instructions.getroottree().write(dstfile, pretty_print=True)
Ejemplo n.º 6
0
def do_save_fullpatch(iface, feat):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    patchname = oi.get_patch_name(feat, default = True)
    patch_folder = os.path.join("patches", patchname)
    do_build(iface, target = "fullpatch", feat = feat, rebuild = True, dstfolder = patch_folder)
    oi.set_patch_name(feat, patchname)
Ejemplo n.º 7
0
def do_save_fullpatch(iface, feat):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    patchname = oi.get_patch_name(feat, default=True)
    patch_folder = os.path.join("patches", patchname)
    do_build(iface,
             target="fullpatch",
             feat=feat,
             rebuild=True,
             dstfolder=patch_folder)
    oi.set_patch_name(feat, patchname)
Ejemplo n.º 8
0
def list_objects(iface):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    iface.msg(u"\nMódulos cargados:")
    for obj in sorted(oi.modules(), key=lambda obj: obj.formal_name()):
        iface.msg(u" - %s" % obj.formal_name())

    iface.msg(u"\nFuncionalidades cargadas:")
    for obj in sorted(oi.features(), key=lambda obj: obj.formal_name()):
        iface.msg(u" - %s" % obj.formal_name())
Ejemplo n.º 9
0
def do_new(iface, subfoldername = None, description = None, patchurl = None):
    letters = list("abcdefghijklmnopqrstuvwxyz123456789")
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    fpath = ftype = fcode = fname = fdesc = None
    if description: fdesc = unicode(description, output_encoding)
    if subfoldername:
        match = re.match(u"^([a-z]+)([A-Z0-9][0-9]{3})-([a-z][a-z0-9_]{3,20})$", unicode(subfoldername, output_encoding))
        if not match:
            print "El nombre de subcarpeta '%s' no es válido" % subfoldername
            return False
        ftype, fcode, fname = match.groups()
    # SELECCIONAR CARPETA DONDE SE GUARDARA:
    folders = []
    for path in cfg.module.featurefolders:
        if not os.path.exists(path):
            iface.debug(u"Se ignora directorio inexistente %s" % repr(path))
            continue
        folders.append(path)
    if len(folders) == 0:
        iface.error("No hay carpetas válidas donde guardar extensiones. Imposible continuar.")
        return False

    def change_fpath():
        print
        if len(folders) == 1:
            fpath = folders[0]
            print u"La funcionalidad se guardará en la única carpeta válida: '%s'" % fpath
        else:
            a,fpath = select_option( 
                    title = u"Existen varias carpetas de funcionalidades:", 
                    question = u"Seleccione en qué carpeta desea crear la nueva funcionalidad: ", 
                    options = folders,
                    answers = letters,
                    )
        return fpath
    fpath = folders[-1]
    
    ftype_options = [u"extensión",u"proyecto", u"conjunto de extensiones"]
    ftype_answers = ["ext","prj","set"]
    ftype_idx = dict(zip(ftype_answers,ftype_options))
    def change_ftype():
        print
        ftype,o = select_option( 
                title = u"Qué tipo de funcionalidad va a crear?", 
                question = u"Seleccione una opción: ", 
                options = ftype_options,
                answers = ftype_answers,
                )
        return ftype
        
    if ftype is None: ftype = change_ftype()
    
    def change_fcode():
        print
        t,m = uinput_mask(
                    question = u"Código para la nueva funcionalidad: ",
                    mask = r"^([A-Z0-9]\d{3})$", 
                    errortext = u"ERROR: El valor '%s' debe seguir el formato A999 (A puede ser número).",
                    )
        fcode = m.group(0)
        return fcode
    if fcode is None: fcode = change_fcode()
    
    def change_fname():    
        print
        t,m = uinput_mask(
                    question = u"Nombre corto de funcionalidad: ",
                    mask = r"^([a-z][a-z0-9_]{3,19})$", 
                    errortext = u"ERROR: El valor '%s' debe tener entre 4 y 20 carácteres, ser minúsculas y tener solo letras y números (empezando siempre por letra)",
                    )
        fname = m.group(0)
        return fname
    if fname is None: fname = change_fname()
    
    def change_fdesc():
        print
        fdesc = uinput(u"Descripción de la funcionalidad: ")
        return fdesc
    if fdesc is None: fdesc = change_fdesc()
    
    def change_fload_patch():
        t,m = uinput_mask(
                question = u"Ruta hasta el parche: ",
                mask = r"^([\w./-]*)$", 
                errortext = u"ERROR: El valor '%s' debe ser una ruta válida",
                )
        if os.path.exists(t):
            return t
        else:
            print "ERROR: La ruta '%s' no existe." % t
            return None
        

    
    fdep_modules = []
    fdep_features = []
    fload_patch = patchurl
    def checkpatch_deps(fload_patch):
        file_index = oi.index_by_file()
        from enebootools.mergetool.flpatchdir import FolderApplyPatch
        fpatch = FolderApplyPatch(iface, fload_patch)
        info = fpatch.get_patch_info()
        for filename in info["requires"]:
            if filename not in file_index:
                print "??? Dependencia no encontrada para:", filename
                continue
            modules = file_index[filename]["provided-by-module"]
            features = file_index[filename]["provided-by-feature"]
            for m in modules:
                if m not in fdep_modules:
                    fdep_modules.append(m)
                    print u"Se agregó automáticamente la dependencia con el módulo '%s'" % m
            for f in features:
                if f not in fdep_features:
                    fdep_features.append(f)
                    print u"Se agregó automáticamente la dependencia con la funcionalidad '%s'" % f
    
    if fload_patch:
        try:
            checkpatch_deps(fload_patch)
        except Exception, e:
            print u"Hubo un problema al intentar comprobar el parche. Probablemente la carpeta sea incorrecta."
Ejemplo n.º 10
0
def test_deps(iface, feat):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    patchname = oi.get_patch_name(feat, default = True)
    feature = FeatureObject.find(feat)
    patch_folder = os.path.join(feature.fullpath, "patches", patchname)
    
    file_index = oi.index_by_file()
    from enebootools.mergetool.flpatchdir import FolderApplyPatch
    fpatch = FolderApplyPatch(iface, patch_folder)
    info = fpatch.get_patch_info()
    fdep_features = feature._get_full_required_features()[:]
    fdep_modules = feature._get_full_required_modules()[:]
    fdep_features.append( feature.formal_name() )
    orig_fdep_features = fdep_features[:]
    orig_fdep_modules = fdep_modules[:]
    
    for filename in info["requires"]:
        if filename not in file_index:
            print "??? Dependencia no encontrada para:", filename
            continue
        modules = file_index[filename]["provided-by-module"]
        features = file_index[filename]["provided-by-feature"]
        for m in modules:
            if m not in fdep_modules:
                fdep_modules.append(m)
        for f in features:
            if f not in fdep_features:
                fdep_features.append(f)

    for filename in info["provides"]:
        if filename not in file_index:
            continue
        modules = file_index[filename]["provided-by-module"]
        features = file_index[filename]["provided-by-feature"]
        for m in modules:
            if m not in fdep_modules:
                fdep_modules.append(m)
        for f in features:
            if f not in fdep_features:
                fdep_features.append(f)
    
    new_modules = list(set(fdep_modules) - set(orig_fdep_modules))
    new_modules.sort()
    new_features = list(set(fdep_features) - set(orig_fdep_features))
    new_features.sort()
    
    if new_modules:
        print u"La funcionalidad requiere además de los siguientes módulos:"
        for m in new_modules:
            print " - %s" % m
        print
        
    if new_features:
        print u"La funcionalidad requiere además de las siguientes funcionalidades:"
        try: new_features.remove(feature.formal_name())
        except ValueError: pass
        for m in new_features:
            print " - %s" % m
        print
Ejemplo n.º 11
0
def do_new(iface, subfoldername=None, description=None, patchurl=None):
    letters = list("abcdefghijklmnopqrstuvwxyz123456789")
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    fpath = ftype = fcode = fname = fdesc = None
    if description: fdesc = unicode(description, output_encoding)
    if subfoldername:
        match = re.match(
            u"^([a-z]+)([A-Z0-9][0-9]{3})-([a-z][a-z0-9_]{3,20})$",
            unicode(subfoldername, output_encoding))
        if not match:
            print "El nombre de subcarpeta '%s' no es válido" % subfoldername
            return False
        ftype, fcode, fname = match.groups()
    # SELECCIONAR CARPETA DONDE SE GUARDARA:
    folders = []
    for path in cfg.module.featurefolders:
        if not os.path.exists(path):
            iface.debug(u"Se ignora directorio inexistente %s" % repr(path))
            continue
        folders.append(path)
    if len(folders) == 0:
        iface.error(
            "No hay carpetas válidas donde guardar extensiones. Imposible continuar."
        )
        return False

    def change_fpath():
        print
        if len(folders) == 1:
            fpath = folders[0]
            print u"La funcionalidad se guardará en la única carpeta válida: '%s'" % fpath
        else:
            a, fpath = select_option(
                title=u"Existen varias carpetas de funcionalidades:",
                question=
                u"Seleccione en qué carpeta desea crear la nueva funcionalidad: ",
                options=folders,
                answers=letters,
            )
        return fpath

    fpath = folders[-1]

    ftype_options = [u"extensión", u"proyecto", u"conjunto de extensiones"]
    ftype_answers = ["ext", "prj", "set"]
    ftype_idx = dict(zip(ftype_answers, ftype_options))

    def change_ftype():
        print
        ftype, o = select_option(
            title=u"Qué tipo de funcionalidad va a crear?",
            question=u"Seleccione una opción: ",
            options=ftype_options,
            answers=ftype_answers,
        )
        return ftype

    if ftype is None: ftype = change_ftype()

    def change_fcode():
        print
        t, m = uinput_mask(
            question=u"Código para la nueva funcionalidad: ",
            mask=r"^([A-Z0-9]\d{3})$",
            errortext=
            u"ERROR: El valor '%s' debe seguir el formato A999 (A puede ser número).",
        )
        fcode = m.group(0)
        return fcode

    if fcode is None: fcode = change_fcode()

    def change_fname():
        print
        t, m = uinput_mask(
            question=u"Nombre corto de funcionalidad: ",
            mask=r"^([a-z][a-z0-9_]{3,19})$",
            errortext=
            u"ERROR: El valor '%s' debe tener entre 4 y 20 carácteres, ser minúsculas y tener solo letras y números (empezando siempre por letra)",
        )
        fname = m.group(0)
        return fname

    if fname is None: fname = change_fname()

    def change_fdesc():
        print
        fdesc = uinput(u"Descripción de la funcionalidad: ")
        return fdesc

    if fdesc is None: fdesc = change_fdesc()

    def change_fload_patch():
        t, m = uinput_mask(
            question=u"Ruta hasta el parche: ",
            mask=r"^([\w./-]*)$",
            errortext=u"ERROR: El valor '%s' debe ser una ruta válida",
        )
        if os.path.exists(t):
            return t
        else:
            print "ERROR: La ruta '%s' no existe." % t
            return None

    fdep_modules = []
    fdep_features = []
    fload_patch = patchurl

    def checkpatch_deps(fload_patch):
        file_index = oi.index_by_file()
        from enebootools.mergetool.flpatchdir import FolderApplyPatch
        fpatch = FolderApplyPatch(iface, fload_patch)
        info = fpatch.get_patch_info()
        for filename in info["requires"]:
            if filename not in file_index:
                print "??? Dependencia no encontrada para:", filename
                continue
            modules = file_index[filename]["provided-by-module"]
            features = file_index[filename]["provided-by-feature"]
            for m in modules:
                if m not in fdep_modules:
                    fdep_modules.append(m)
                    print u"Se agregó automáticamente la dependencia con el módulo '%s'" % m
            for f in features:
                if f not in fdep_features:
                    fdep_features.append(f)
                    print u"Se agregó automáticamente la dependencia con la funcionalidad '%s'" % f

    if fload_patch:
        try:
            checkpatch_deps(fload_patch)
        except Exception, e:
            print u"Hubo un problema al intentar comprobar el parche. Probablemente la carpeta sea incorrecta."
Ejemplo n.º 12
0
def test_deps(iface, feat):
    db = init_database()
    oi = ObjectIndex(iface)
    oi.analyze_objects()
    patchname = oi.get_patch_name(feat, default=True)
    feature = FeatureObject.find(feat)
    patch_folder = os.path.join(feature.fullpath, "patches", patchname)

    file_index = oi.index_by_file()
    from enebootools.mergetool.flpatchdir import FolderApplyPatch
    fpatch = FolderApplyPatch(iface, patch_folder)
    info = fpatch.get_patch_info()
    fdep_features = feature._get_full_required_features()[:]
    fdep_modules = feature._get_full_required_modules()[:]
    fdep_features.append(feature.formal_name())
    orig_fdep_features = fdep_features[:]
    orig_fdep_modules = fdep_modules[:]

    for filename in info["requires"]:
        if filename not in file_index:
            print "??? Dependencia no encontrada para:", filename
            continue
        modules = file_index[filename]["provided-by-module"]
        features = file_index[filename]["provided-by-feature"]
        for m in modules:
            if m not in fdep_modules:
                fdep_modules.append(m)
        for f in features:
            if f not in fdep_features:
                fdep_features.append(f)

    for filename in info["provides"]:
        if filename not in file_index:
            continue
        modules = file_index[filename]["provided-by-module"]
        features = file_index[filename]["provided-by-feature"]
        for m in modules:
            if m not in fdep_modules:
                fdep_modules.append(m)
        for f in features:
            if f not in fdep_features:
                fdep_features.append(f)

    new_modules = list(set(fdep_modules) - set(orig_fdep_modules))
    new_modules.sort()
    new_features = list(set(fdep_features) - set(orig_fdep_features))
    new_features.sort()

    if new_modules:
        print u"La funcionalidad requiere además de los siguientes módulos:"
        for m in new_modules:
            print " - %s" % m
        print

    if new_features:
        print u"La funcionalidad requiere además de las siguientes funcionalidades:"
        try:
            new_features.remove(feature.formal_name())
        except ValueError:
            pass
        for m in new_features:
            print " - %s" % m
        print