Example #1
0
def choose_provides(name):
    provides = OrderedDict()
    already_add = []
    for pkg in transaction.syncpkgs.values():
        for provide in pkg.provides:
            if common.format_pkg_name(name) == common.format_pkg_name(provide):
                if not pkg.name in provides.keys():
                    provides[pkg.name] = pkg
    if provides:
        choose_label.set_markup(
            "<b>{} is provided by {} packages.\nPlease choose the one(s) you want to install:</b>".format(
                name, str(len(provides.keys()))
            )
        )
        choose_list.clear()
        for name in provides.keys():
            if transaction.handle.get_localdb().get_pkg(name):
                choose_list.append([True, name])
            else:
                choose_list.append([False, name])
        ChooseDialog.run()
        return [provides[pkgname] for pkgname in transaction.to_provide]
Example #2
0
def check_to_build():
    global to_build
    global to_add
    global to_mark_as_dep
    global make_depends
    global build_depends
    make_depends = set()
    builds_depends = set()
    # check if base_devel packages are installed
    for name in base_devel:
        if not pyalpm.find_satisfier(localdb.pkgcache, name):
            make_depends.add(name)
    already_checked = set()
    build_order = []
    i = 0
    error = ""
    while i < len(to_build):
        while Gtk.events_pending():
            Gtk.main_iteration()
        pkg = to_build[i]
        # if current pkg is not in build_order add it at the end of the list
        if not pkg.name in build_order:
            build_order.append(pkg.name)
            # download end extract tarball from AUR
        srcdir = aur.get_extract_tarball(pkg)
        if srcdir:
            # get PKGBUILD and parse it to create a new pkg object with makedeps and deps
            new_pkgs = aur.get_pkgs(srcdir + "/PKGBUILD")
            for new_pkg in new_pkgs:
                while Gtk.events_pending():
                    Gtk.main_iteration()
                print("checking", new_pkg.name)
                # check if some makedeps must be installed
                for makedepend in new_pkg.makedepends:
                    while Gtk.events_pending():
                        Gtk.main_iteration()
                    if not makedepend in already_checked:
                        if not pyalpm.find_satisfier(localdb.pkgcache, makedepend):
                            print("found make dep:", makedepend)
                            for db in syncdbs:
                                provider = pyalpm.find_satisfier(db.pkgcache, makedepend)
                                if provider:
                                    break
                            if provider:
                                make_depends.add(provider.name)
                                already_checked.add(makedepend)
                            else:
                                # current makedep need to be built
                                raw_makedepend = common.format_pkg_name(makedepend)
                                if raw_makedepend in build_order:
                                    # add it in build_order before pkg
                                    build_order.remove(raw_makedepend)
                                    index = build_order.index(pkg.name)
                                    build_order.insert(index, raw_makedepend)
                                else:
                                    # get infos about it
                                    makedep_pkg = aur.info(raw_makedepend)
                                    if makedep_pkg:
                                        # add it in to_build so it will be checked
                                        to_build.append(makedep_pkg)
                                        # add it in build_order before pkg
                                        index = build_order.index(pkg.name)
                                        build_order.insert(index, raw_makedepend)
                                        # add it in already_checked and to_add_as_as_dep
                                        already_checked.add(raw_makedepend)
                                        to_mark_as_dep.add(raw_makedepend)
                                    else:
                                        if error:
                                            error += "\n"
                                        error += _(
                                            "{pkgname} depends on {dependname} but it is not installable"
                                        ).format(pkgname=pkg.name, dependname=makedepend)
                                        # check if some deps must be installed or built
                for depend in new_pkg.depends:
                    while Gtk.events_pending():
                        Gtk.main_iteration()
                    if not depend in already_checked:
                        if not pyalpm.find_satisfier(localdb.pkgcache, depend):
                            print("found dep:", depend)
                            for db in syncdbs:
                                provider = pyalpm.find_satisfier(db.pkgcache, depend)
                                if provider:
                                    break
                            if provider:
                                # current dep need to be installed
                                build_depends.add(provider.name)
                                already_checked.add(depend)
                            else:
                                # current dep need to be built
                                raw_depend = common.format_pkg_name(depend)
                                if raw_depend in build_order:
                                    # add it in build_order before pkg
                                    build_order.remove(raw_depend)
                                    index = build_order.index(pkg.name)
                                    build_order.insert(index, raw_depend)
                                else:
                                    # get infos about it
                                    dep_pkg = aur.info(raw_depend)
                                    if dep_pkg:
                                        # add it in to_build so it will be checked
                                        to_build.append(dep_pkg)
                                        # add it in build_order before pkg
                                        index = build_order.index(pkg.name)
                                        build_order.insert(index, raw_depend)
                                        # add it in already_checked and to_add_as_as_dep
                                        already_checked.add(raw_depend)
                                        to_mark_as_dep.add(raw_depend)
                                    else:
                                        if error:
                                            error += "\n"
                                        error += _(
                                            "{pkgname} depends on {dependname} but it is not installable"
                                        ).format(pkgname=pkg.name, dependname=depend)
        else:
            if error:
                error += "\n"
            error += _("Failed to get {pkgname} archive from AUR").format(pkgname=pkg.name)
        i += 1
    if error:
        return error
        # add pkgname in make_depends and build_depends in to_add and to_mark_as_dep
    for name in make_depends:
        to_add.add(name)
        to_mark_as_dep.add(name)
    for name in build_depends:
        to_add.add(name)
        to_mark_as_dep.add(name)
        # reorder to_build following build_order
    to_build.sort(key=lambda pkg: build_order.index(pkg.name))
    # print('order:', build_order)
    print("to build:", to_build)
    print("makedeps:", make_depends)
    print("builddeps:", build_depends)
    return error
Example #3
0
def check_to_build():
    global to_build
    global to_add
    global to_mark_as_dep
    global make_depends
    global build_depends
    make_depends = set()
    builds_depends = set()
    # check if base_devel packages are installed
    for name in base_devel:
        if not pyalpm.find_satisfier(localdb.pkgcache, name):
            make_depends.add(name)
    already_checked = set()
    build_order = []
    i = 0
    error = ''
    while i < len(to_build):
        while Gtk.events_pending():
            Gtk.main_iteration()
        pkg = to_build[i]
        # if current pkg is not in build_order add it at the end of the list
        if not pkg.name in build_order:
            build_order.append(pkg.name)
        # download end extract tarball from AUR
        srcdir = aur.get_extract_tarball(pkg)
        if srcdir:
            # get PKGBUILD and parse it to create a new pkg object with makedeps and deps
            new_pkgs = aur.get_pkgs(srcdir + '/PKGBUILD')
            for new_pkg in new_pkgs:
                while Gtk.events_pending():
                    Gtk.main_iteration()
                print('checking', new_pkg.name)
                # check if some makedeps must be installed
                for makedepend in new_pkg.makedepends:
                    while Gtk.events_pending():
                        Gtk.main_iteration()
                    if not makedepend in already_checked:
                        if not pyalpm.find_satisfier(localdb.pkgcache,
                                                     makedepend):
                            print('found make dep:', makedepend)
                            for db in syncdbs:
                                provider = pyalpm.find_satisfier(
                                    db.pkgcache, makedepend)
                                if provider:
                                    break
                            if provider:
                                make_depends.add(provider.name)
                                already_checked.add(makedepend)
                            else:
                                # current makedep need to be built
                                raw_makedepend = common.format_pkg_name(
                                    makedepend)
                                if raw_makedepend in build_order:
                                    # add it in build_order before pkg
                                    build_order.remove(raw_makedepend)
                                    index = build_order.index(pkg.name)
                                    build_order.insert(index, raw_makedepend)
                                else:
                                    # get infos about it
                                    makedep_pkg = aur.info(raw_makedepend)
                                    if makedep_pkg:
                                        # add it in to_build so it will be checked
                                        to_build.append(makedep_pkg)
                                        # add it in build_order before pkg
                                        index = build_order.index(pkg.name)
                                        build_order.insert(
                                            index, raw_makedepend)
                                        # add it in already_checked and to_add_as_as_dep
                                        already_checked.add(raw_makedepend)
                                        to_mark_as_dep.add(raw_makedepend)
                                    else:
                                        if error:
                                            error += '\n'
                                        error += _(
                                            '{pkgname} depends on {dependname} but it is not installable'
                                        ).format(pkgname=pkg.name,
                                                 dependname=makedepend)
                # check if some deps must be installed or built
                for depend in new_pkg.depends:
                    while Gtk.events_pending():
                        Gtk.main_iteration()
                    if not depend in already_checked:
                        if not pyalpm.find_satisfier(localdb.pkgcache, depend):
                            print('found dep:', depend)
                            for db in syncdbs:
                                provider = pyalpm.find_satisfier(
                                    db.pkgcache, depend)
                                if provider:
                                    break
                            if provider:
                                # current dep need to be installed
                                build_depends.add(provider.name)
                                already_checked.add(depend)
                            else:
                                # current dep need to be built
                                raw_depend = common.format_pkg_name(depend)
                                if raw_depend in build_order:
                                    # add it in build_order before pkg
                                    build_order.remove(raw_depend)
                                    index = build_order.index(pkg.name)
                                    build_order.insert(index, raw_depend)
                                else:
                                    # get infos about it
                                    dep_pkg = aur.info(raw_depend)
                                    if dep_pkg:
                                        # add it in to_build so it will be checked
                                        to_build.append(dep_pkg)
                                        # add it in build_order before pkg
                                        index = build_order.index(pkg.name)
                                        build_order.insert(index, raw_depend)
                                        # add it in already_checked and to_add_as_as_dep
                                        already_checked.add(raw_depend)
                                        to_mark_as_dep.add(raw_depend)
                                    else:
                                        if error:
                                            error += '\n'
                                        error += _(
                                            '{pkgname} depends on {dependname} but it is not installable'
                                        ).format(pkgname=pkg.name,
                                                 dependname=depend)
        else:
            if error:
                error += '\n'
            error += _('Failed to get {pkgname} archive from AUR').format(
                pkgname=pkg.name)
        i += 1
    if error:
        return error
    # add pkgname in make_depends and build_depends in to_add and to_mark_as_dep
    for name in make_depends:
        to_add.add(name)
        to_mark_as_dep.add(name)
    for name in build_depends:
        to_add.add(name)
        to_mark_as_dep.add(name)
    # reorder to_build following build_order
    to_build.sort(key=lambda pkg: build_order.index(pkg.name))
    #print('order:', build_order)
    print('to build:', to_build)
    print('makedeps:', make_depends)
    print('builddeps:', build_depends)
    return error
Example #4
0
def check_conflicts(pkg_list):
    depends = [pkg_list]
    warning = ""
    # transaction.get_handle()
    pkgs = transaction.handle.get_localdb().search("linux3")
    installed_linux = []
    for i in pkgs:
        if len(i.name) == 7:
            installed_linux.append(i.name)
    for to_install in transaction.to_add:
        if "linux3" in to_install:
            if len(to_install) == 7:
                installed_linux.append(to_install)
    i = 0
    while depends[i]:
        depends.append([])
        for pkg in depends[i]:
            for depend in pkg.depends:
                provide = pyalpm.find_satisfier(transaction.localpkgs.values(), depend)
                if provide:
                    print(i, "local", provide)
                    if provide.name != common.format_pkg_name(depend):
                        if ("linux" in depend) or ("-module" in depend):
                            for pkg in transaction.syncpkgs.values():
                                if not pkg.name in transaction.localpkgs.keys():
                                    for name in pkg.provides:
                                        for linux in installed_linux:
                                            if linux in pkg.name:
                                                if common.format_pkg_name(depend) == common.format_pkg_name(name):
                                                    depends[i + 1].append(pkg)
                                                    transaction.to_add.append(pkg.name)
                else:
                    provide = pyalpm.find_satisfier(transaction.syncpkgs.values(), depend)
                    if provide:
                        print(i, "sync", provide)
                        if provide.name != common.format_pkg_name(depend):
                            if ("linux" in depend) or ("-module" in depend):
                                for pkg in transaction.syncpkgs.values():
                                    if not pkg.name in transaction.localpkgs.keys():
                                        for name in pkg.provides:
                                            for linux in installed_linux:
                                                if linux in pkg.name:
                                                    if common.format_pkg_name(depend) == common.format_pkg_name(name):
                                                        depends[i + 1].append(pkg)
                                                        transaction.to_add.append(pkg.name)
                            else:
                                to_add_to_depends = choose_provides(depend)
                                print(to_add_to_depends)
                                for pkg in to_add_to_depends:
                                    depends[i + 1].append(pkg)
                                    transaction.to_add.append(pkg.name)
                        else:
                            depends[i + 1].append(provide)
            for replace in pkg.replaces:
                provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
                if provide:
                    if provide.name != pkg.name:
                        if not provide.name in transaction.to_remove:
                            transaction.to_remove.append(provide.name)
                            if warning:
                                warning = warning + "\n"
                            warning = warning + provide.name + " will be replaced by " + pkg.name
            for conflict in pkg.conflicts:
                provide = pyalpm.find_satisfier(transaction.localpkgs.values(), conflict)
                if provide:
                    if provide.name != pkg.name:
                        if not provide.name in transaction.to_remove:
                            transaction.to_remove.append(provide.name)
                            if warning:
                                warning = warning + "\n"
                            warning = warning + pkg.name + " conflicts with " + provide.name
                provide = pyalpm.find_satisfier(depends[0], conflict)
                if provide:
                    if not common.format_pkg_name(conflict) in transaction.to_remove:
                        if pkg.name in transaction.to_add and common.format_pkg_name(conflict) in transaction.to_add:
                            transaction.to_add.remove(common.format_pkg_name(conflict))
                            transaction.to_add.remove(pkg.name)
                            if warning:
                                warning = warning + "\n"
                            warning = (
                                warning
                                + pkg.name
                                + " conflicts with "
                                + common.format_pkg_name(conflict)
                                + "\nNone of them will be installed"
                            )
        i += 1
    for pkg in transaction.localpkgs.values():
        for conflict in pkg.conflicts:
            provide = pyalpm.find_satisfier(depends[0], conflict)
            if provide:
                if provide.name != pkg.name:
                    if not provide.name in transaction.to_remove:
                        transaction.to_remove.append(pkg.name)
                        if warning:
                            warning = warning + "\n"
                        warning = warning + provide.name + " conflicts with " + pkg.name
    for pkg in transaction.syncpkgs.values():
        for replace in pkg.replaces:
            provide = pyalpm.find_satisfier(transaction.localpkgs.values(), replace)
            if provide:
                if provide.name != pkg.name:
                    if not pkg.name in transaction.localpkgs.keys():
                        if common.format_pkg_name(replace) in transaction.localpkgs.keys():
                            if not provide.name in transaction.to_remove:
                                transaction.to_remove.append(provide.name)
                                if warning:
                                    warning = warning + "\n"
                                warning = warning + provide.name + " will be replaced by " + pkg.name
                            if not pkg.name in transaction.to_add:
                                transaction.to_add.append(pkg.name)
    print(transaction.to_add, transaction.to_remove)
    if warning:
        transaction.WarningDialog.format_secondary_text(warning)
        response = transaction.WarningDialog.run()
        if response:
            transaction.WarningDialog.hide()