def build_next(): global build_proc pkg = to_build[0] path = os.path.join(aur.srcpkgdir, pkg.name) new_pkgs = aur.get_pkgs(path + '/PKGBUILD') # sources are identicals for splitted packages # (not complete) download(new_pkgs[0].source, path) action = _('Building {pkgname}').format(pkgname=pkg.name) + '...' action_handler(action) action_long_handler(action + '\n') icon_handler('pamac-setup') target_handler('') percent_handler(0) ProgressCancelButton.set_visible(True) ProgressCloseButton.set_visible(False) progress_expander.set_visible(True) progress_expander.set_expanded(True) ProgressWindow.show() build_proc = subprocess.Popen(["makepkg", "-cf"], cwd=path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while Gtk.events_pending(): Gtk.main_iteration() GObject.timeout_add(100, check_finished_build, (path, pkg))
def build_next(): global build_proc pkg = to_build[0] path = os.path.join(aur.srcpkgdir, pkg.name) new_pkgs = aur.get_pkgs(path + "/PKGBUILD") # sources are identicals for splitted packages # (not complete) download(new_pkgs[0].source, path) action = _("Building {pkgname}").format(pkgname=pkg.name) + "..." action_handler(action) action_long_handler(action + "\n") icon_handler("pamac-setup") target_handler("") percent_handler(0) ProgressCancelButton.set_visible(True) ProgressCloseButton.set_visible(False) progress_expander.set_visible(True) progress_expander.set_expanded(True) ProgressWindow.show() build_proc = subprocess.Popen(["makepkg", "-cf"], cwd=path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while Gtk.events_pending(): Gtk.main_iteration() GObject.timeout_add(100, check_finished_build, (path, pkg))
def check_finished_build(data): def handle_timeout(*args): raise Exception("timeout") def no_handle_timeout(*args): try: pass except: pass global to_build global build_proc path = data[0] pkg = data[1] if build_proc.poll() is None: # Build no finished : read stdout to push it to text_buffer # add a timeout to stop reading stdout if too long # so the gui won't freeze signal.signal(signal.SIGALRM, handle_timeout) signal.setitimer(signal.ITIMER_REAL, 0.05) # 50 ms timeout try: line = build_proc.stdout.readline().decode(encoding="UTF-8") line = re.sub(colors_regexp, "", line) # print(line.rstrip('\n')) progress_buffer.insert_at_cursor(line) except Exception: pass else: signal.signal(signal.SIGALRM, no_handle_timeout) finally: progress_bar.pulse() while Gtk.events_pending(): Gtk.main_iteration() return True elif build_proc.poll() == 0: # Build successfully finished built = [] # parse again PKGBUILD to have new pkg objects in case of a pkgver() function # was used so pkgver was changed during build process new_pkgs = aur.get_pkgs(path + "/PKGBUILD") # find built packages for new_pkg in new_pkgs: for item in os.listdir(path): if os.path.isfile(os.path.join(path, item)): # add a * before pkgver if there an epoch variable if fnmatch.fnmatch(item, "{}-*{}-*.pkg.tar.?z".format(new_pkg.name, new_pkg.version)): built.append(os.path.join(path, item)) break if built: print("successfully built:", built) build_proc = None if pkg in to_build: to_build.remove(pkg) # install built packages error = "" error += init_transaction() if not error: for pkg_path in built: error += Load(pkg_path) if not error: error += prepare() if not error: if To_Remove(): set_transaction_sum() ConfDialog.show_all() while Gtk.events_pending(): Gtk.main_iteration() else: finalize() if error: Release() ProgressCancelButton.set_visible(False) ProgressCloseButton.set_visible(True) ErrorDialog.format_secondary_text(error) response = ErrorDialog.run() if response: ErrorDialog.hide() else: ProgressCancelButton.set_visible(False) ProgressCloseButton.set_visible(True) action_long_handler(_("Build process failed.")) return False elif build_proc.poll() == 1: # Build finish with an error ProgressCancelButton.set_visible(False) ProgressCloseButton.set_visible(True) action_long_handler(_("Build process failed.")) return False
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
def check_finished_build(data): def handle_timeout(*args): raise Exception('timeout') def no_handle_timeout(*args): try: pass except: pass global to_build global build_proc path = data[0] pkg = data[1] if build_proc.poll() is None: # Build no finished : read stdout to push it to text_buffer # add a timeout to stop reading stdout if too long # so the gui won't freeze signal.signal(signal.SIGALRM, handle_timeout) signal.setitimer(signal.ITIMER_REAL, 0.05) # 50 ms timeout try: line = build_proc.stdout.readline().decode(encoding='UTF-8') line = re.sub(colors_regexp, '', line) #print(line.rstrip('\n')) progress_buffer.insert_at_cursor(line) except Exception: pass else: signal.signal(signal.SIGALRM, no_handle_timeout) finally: progress_bar.pulse() while Gtk.events_pending(): Gtk.main_iteration() return True elif build_proc.poll() == 0: # Build successfully finished built = [] # parse again PKGBUILD to have new pkg objects in case of a pkgver() function # was used so pkgver was changed during build process new_pkgs = aur.get_pkgs(path + '/PKGBUILD') # find built packages for new_pkg in new_pkgs: for item in os.listdir(path): if os.path.isfile(os.path.join(path, item)): # add a * before pkgver if there an epoch variable if fnmatch.fnmatch( item, '{}-*{}-*.pkg.tar.?z'.format( new_pkg.name, new_pkg.version)): built.append(os.path.join(path, item)) break if built: print('successfully built:', built) build_proc = None if pkg in to_build: to_build.remove(pkg) # install built packages error = '' error += init_transaction() if not error: for pkg_path in built: error += Load(pkg_path) if not error: error += prepare() if not error: if To_Remove(): set_transaction_sum() ConfDialog.show_all() while Gtk.events_pending(): Gtk.main_iteration() else: finalize() if error: Release() ProgressCancelButton.set_visible(False) ProgressCloseButton.set_visible(True) ErrorDialog.format_secondary_text(error) response = ErrorDialog.run() if response: ErrorDialog.hide() else: ProgressCancelButton.set_visible(False) ProgressCloseButton.set_visible(True) action_long_handler(_('Build process failed.')) return False elif build_proc.poll() == 1: # Build finish with an error ProgressCancelButton.set_visible(False) ProgressCloseButton.set_visible(True) action_long_handler(_('Build process failed.')) return False
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