Esempio n. 1
0
def get_pkgs(pkgs):
	error = ''
	for name in pkgs:
		if '.pkg.tar.' in name:
			full_path = abspath(name)
			transaction.to_load.add(full_path)
		elif transaction.get_syncpkg(name):
			transaction.to_add.add(name)
		else:
			aur_pkg = None
			if config.enable_aur:
				aur_pkg = aur.info(name)
				if aur_pkg:
					transaction.to_build.append(aur_pkg)
			if not aur_pkg:
				if error:
					error += '\n'
				error += _('{pkgname} is not a valid path or package name').format(pkgname = name)
	if error:
		handle_error(error)
		return False
	else:
		return True
Esempio n. 2
0
def get_pkgs(pkgs):
    error = ''
    for name in pkgs:
        if '.pkg.tar.' in name:
            full_path = abspath(name)
            transaction.to_load.add(full_path)
        elif transaction.get_syncpkg(name):
            transaction.to_add.add(name)
        else:
            aur_pkg = None
            if config.enable_aur:
                aur_pkg = aur.info(name)
                if aur_pkg:
                    transaction.to_build.append(aur_pkg)
            if not aur_pkg:
                if error:
                    error += '\n'
                error += _('{pkgname} is not a valid path or package name'
                           ).format(pkgname=name)
    if error:
        handle_error(error)
        return False
    else:
        return True
Esempio n. 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
Esempio n. 4
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