Giter Club home page Giter Club logo

packagekit's People

Contributors

afb avatar arrowd avatar belka-ew avatar caglar10ur avatar dantti avatar dimstar77 avatar fbourigault avatar glatzor avatar hughsie avatar igorpsoares avatar joebonrichie avatar jonathan-conder avatar jonathankang avatar joulupukki avatar kalev avatar kenvandine avatar lmacken avatar megabajt avatar mounirlamouri avatar onestep avatar palfrey avatar piotrdrag avatar pwithnall avatar robert-ancell avatar soig avatar stephanedelcroix avatar timlau avatar xiaoqiang0 avatar ximion avatar zhangsen avatar

Watchers

 avatar  avatar

packagekit's Issues

Segfault when using PkClient GTask, self.percentage() and pisi.api APIs that use the @locked decorator with a pisi.ui.UI override.

Since b068646

We're getting a segfault when we run self.percentage() from our pisi.ui.UI override for pisi APIs that use the @locked decorator.

The pisi locked decorator is here: https://github.com/getsolus/eopkg/blob/python3/pisi/api.py#L39

A simplified version of our code is below

class SimplePisiHandler(pisi.ui.UI):
    def __init__(self, base):
        pisi.ui.UI.__init__(self, False, False)
        # PackageKitPisiBackend
        self.base = base
        def notify(self, event, **keywords):
            if event == installing:
                emit_installing blah blah blah
                self.base.percentage(somenumber)

class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
    def __init__(self, args):
        PackageKitBaseBackend.__init__(self, args)
        self.get_db()
        self.saved_ui = pisi.context.ui

    def get_db(self):
        self.componentdb = pisi.db.componentdb.ComponentDB()
        # self.filesdb = pisi.db.filesdb.FilesDB()
        self.installdb = pisi.db.installdb.InstallDB()
        self.packagedb = pisi.db.packagedb.PackageDB()
        self.historydb = pisi.db.historydb.HistoryDB()
        self.repodb = pisi.db.repodb.RepoDB()

    def privileged(func):
        """
        Decorator for synchronizing privileged functions
        """
        def wrapper(self, *__args,**__kw):
            ui = SimplePisiHandler(self)
            pisi.api.set_userinterface(ui)
            try:
                func(self, *__args,**__kw)
            except Exception as e:
                raise(e)
            # FIXME: the first call gets garbled 16:2percentage'entagegeK100: invalid command 'parse:
            self.percentage(100)
            self.percentage(100)
            self.get_db()
            self.finished()
            pisi.api.set_userinterface(self.saved_ui)
        return wrapper

    @privileged
    def install_packages(self, transaction_flags, package_ids):
        pisi.api.install(packages)

When we don't try to emit percentage updates we no longer get a segfault. If we revert b068646 as a workaround we'll get a (pkcon:7463): GLib-GObject-CRITICAL **: 16:07:48.354: g_object_unref: assertion 'G_IS_OBJECT (object)' failed warning.

Additionally, we have to emit self.percentage(100) twice after finishing as the first call gets garbled up with a ' endix getting added to the self.percentage() call.

Interestingly emitting self.item_progress() updates doesn't result in a segfault only self.percentage()

Note that this segfault only occurs when using pisi APIs that use the @locked decorator. Using something like pisi.api.fetch we can set percentage updates and experience no segfault.

It seems a combination of the @locked decorator that calls pisi.db.invalidate_caches() which invalidates our self.get_db() initialized values and emitting self.percentage() updates is causing the issue.

Backtrace with b068646

(gdb) bt
#0  g_type_check_instance_is_fundamentally_a (type_instance=type_instance@entry=0x5646812bfe70, fundamental_type=fundamental_type@entry=0x50 [GObject])
    at ../gobject/gtype.c:4153
#1  0x00007f74dfd63d2e in g_object_unref (_object=0x5646812bfe70) at ../gobject/gobject.c:4287
#2  0x00007f74dff3b0a6 in glib_autoptr_clear_GTask (_ptr=0x5646812bfe70) at /usr/include/glib-2.0/gio/gio-autocleanups.h:138
#3  0x00007f74dff3b0c3 in glib_autoptr_cleanup_GTask (_ptr=0x7ffe60ccb280) at /usr/include/glib-2.0/gio/gio-autocleanups.h:138
#4  0x00007f74dff3df0c in pk_task_ready_cb (source_object=0x5646812b4370 [PkTaskText], res=0x5646812c15d0, user_data=0x5646812bfe70)
    at ../lib/packagekit-glib2/pk-task.c:846
#5  0x00007f74dfc1c33c in g_task_return_now (task=task@entry=0x5646812c15d0 [GTask]) at ../gio/gtask.c:1361
#6  0x00007f74dfc1d145 in g_task_return (type=<optimized out>, task=0x5646812c15d0 [GTask]) at ../gio/gtask.c:1430
#7  g_task_return (task=0x5646812c15d0 [GTask], type=<optimized out>) at ../gio/gtask.c:1387
#8  0x00007f74dff0a5a1 in pk_client_state_finish (state=0x5646812c1720 [PkClientState], error=0x0) at ../lib/packagekit-glib2/pk-client.c:245
#9  0x00007f74dff0ce96 in pk_client_signal_finished (state=0x5646812c1720 [PkClientState], exit_enum=PK_EXIT_ENUM_SUCCESS, runtime=7264)
    at ../lib/packagekit-glib2/pk-client.c:1202
#10 0x00007f74dff0d279 in pk_client_signal_cb
    (proxy=0x5646812c1390 [GDBusProxy], sender_name=0x7f74c0009610 ":1.360", signal_name=0x7f74c0008e40 "Finished", parameters=0x7f74c0003b60, user_data=0x5646812b9560) at ../lib/packagekit-glib2/pk-client.c:1284
#15 0x00007f74dfd7a2a0 in <emit signal 'g-signal' on instance 0x5646812c1390 [GDBusProxy]>
    (instance=instance@entry=0x5646812c1390, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3583
    #11 0x00007f74dfd5e5fa in g_closure_invoke
    (closure=0x5646812aa800, return_value=0x0, n_param_values=4, param_values=0x7ffe60ccb6c0, invocation_hint=0x7ffe60ccb610)
    at ../gobject/gclosure.c:834
    #12 0x00007f74dfd72b16 in signal_emit_unlocked_R
    (node=node@entry=0x7ffe60ccb7c0, detail=detail@entry=0, instance=instance@entry=0x5646812c1390, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffe60ccb6c0) at ../gobject/gsignal.c:3888
    #13 0x00007f74dfd744c2 in signal_emit_valist_unlocked
    (instance=instance@entry=0x5646812c1390, signal_id=signal_id@entry=12, detail=detail@entry=0, var_args=var_args@entry=0x7ffe60ccb930)
    at ../gobject/gsignal.c:3520
    #14 0x00007f74dfd7a1de in g_signal_emit_valist (instance=0x5646812c1390, signal_id=12, detail=0, var_args=0x7ffe60ccb930)
    at ../gobject/gsignal.c:3263
#16 0x00007f74dfc8b205 in on_signal_received
    (connection=<optimized out>, sender_name=0x7f74c0006fb0 ":1.360", object_path=<optimized out>, interface_name=<optimized out>, signal_name=0x7f74c00094f0 "Finished", parameters=0x7f74c0003b60, user_data=0x5646812b0180) at ../gio/gdbusproxy.c:874
#17 0x00007f74dfc77395 in emit_signal_instance_in_idle_cb (data=0x7f74c0009240) at ../gio/gdbusconnection.c:3798
#18 0x00007f74dfe02377 in g_main_dispatch (context=context@entry=0x5646812a1dd0) at ../glib/gmain.c:3344
#19 0x00007f74dfe05677 in g_main_context_dispatch_unlocked (context=0x5646812a1dd0) at ../glib/gmain.c:4152
#20 g_main_context_iterate_unlocked (context=0x5646812a1dd0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../glib/gmain.c:4217
#21 0x00007f74dfe05fd7 in g_main_loop_run (loop=0x5646812a1ff0) at ../glib/gmain.c:4419
#22 0x0000564680126113 in main (argc=3, argv=0x7ffe60ccc008) at ../client/pk-console.c:2400
(gdb) 
#0  g_type_check_instance_is_fundamentally_a (type_instance=type_instance@entry=0x5646812bfe70, fundamental_type=fundamental_type@entry=0x50 [GObject])
    at ../gobject/gtype.c:4153
#1  0x00007f74dfd63d2e in g_object_unref (_object=0x5646812bfe70) at ../gobject/gobject.c:4287
#2  0x00007f74dff3b0a6 in glib_autoptr_clear_GTask (_ptr=0x5646812bfe70) at /usr/include/glib-2.0/gio/gio-autocleanups.h:138
#3  0x00007f74dff3b0c3 in glib_autoptr_cleanup_GTask (_ptr=0x7ffe60ccb280) at /usr/include/glib-2.0/gio/gio-autocleanups.h:138
#4  0x00007f74dff3df0c in pk_task_ready_cb (source_object=0x5646812b4370 [PkTaskText], res=0x5646812c15d0, user_data=0x5646812bfe70)
    at ../lib/packagekit-glib2/pk-task.c:846
#5  0x00007f74dfc1c33c in g_task_return_now (task=task@entry=0x5646812c15d0 [GTask]) at ../gio/gtask.c:1361
#6  0x00007f74dfc1d145 in g_task_return (type=<optimized out>, task=0x5646812c15d0 [GTask]) at ../gio/gtask.c:1430
#7  g_task_return (task=0x5646812c15d0 [GTask], type=<optimized out>) at ../gio/gtask.c:1387
#8  0x00007f74dff0a5a1 in pk_client_state_finish (state=0x5646812c1720 [PkClientState], error=0x0) at ../lib/packagekit-glib2/pk-client.c:245
#9  0x00007f74dff0ce96 in pk_client_signal_finished (state=0x5646812c1720 [PkClientState], exit_enum=PK_EXIT_ENUM_SUCCESS, runtime=7264)
    at ../lib/packagekit-glib2/pk-client.c:1202
#10 0x00007f74dff0d279 in pk_client_signal_cb
    (proxy=0x5646812c1390 [GDBusProxy], sender_name=0x7f74c0009610 ":1.360", signal_name=0x7f74c0008e40 "Finished", parameters=0x7f74c0003b60, user_data=0x5646812b9560) at ../lib/packagekit-glib2/pk-client.c:1284
#15 0x00007f74dfd7a2a0 in <emit signal 'g-signal' on instance 0x5646812c1390 [GDBusProxy]>
    (instance=instance@entry=0x5646812c1390, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3583
    #11 0x00007f74dfd5e5fa in g_closure_invoke
    (closure=0x5646812aa800, return_value=0x0, n_param_values=4, param_values=0x7ffe60ccb6c0, invocation_hint=0x7ffe60ccb610)
    at ../gobject/gclosure.c:834
    #12 0x00007f74dfd72b16 in signal_emit_unlocked_R
    (node=node@entry=0x7ffe60ccb7c0, detail=detail@entry=0, instance=instance@entry=0x5646812c1390, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffe60ccb6c0) at ../gobject/gsignal.c:3888
    #13 0x00007f74dfd744c2 in signal_emit_valist_unlocked
    (instance=instance@entry=0x5646812c1390, signal_id=signal_id@entry=12, detail=detail@entry=0, var_args=var_args@entry=0x7ffe60ccb930)
    at ../gobject/gsignal.c:3520
    #14 0x00007f74dfd7a1de in g_signal_emit_valist (instance=0x5646812c1390, signal_id=12, detail=0, var_args=0x7ffe60ccb930)
    at ../gobject/gsignal.c:3263
#16 0x00007f74dfc8b205 in on_signal_received
    (connection=<optimized out>, sender_name=0x7f74c0006fb0 ":1.360", object_path=<optimized out>, interface_name=<optimized out>, signal_name=0x7f74c00094f0 "Finished", parameters=0x7f74c0003b60, user_data=0x5646812b0180) at ../gio/gdbusproxy.c:874
#17 0x00007f74dfc77395 in emit_signal_instance_in_idle_cb (data=0x7f74c0009240) at ../gio/gdbusconnection.c:3798
#18 0x00007f74dfe02377 in g_main_dispatch (context=context@entry=0x5646812a1dd0) at ../glib/gmain.c:3344
#19 0x00007f74dfe05677 in g_main_context_dispatch_unlocked (context=0x5646812a1dd0) at ../glib/gmain.c:4152
#20 g_main_context_iterate_unlocked (context=0x5646812a1dd0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../glib/gmain.c:4217
#21 0x00007f74dfe05fd7 in g_main_loop_run (loop=0x5646812a1ff0) at ../glib/gmain.c:4419
#22 0x0000564680126113 in main (argc=3, argv=0x7ffe60ccc008) at ../client/pk-console.c:2400

eopkg: Implement progress bars for installation and use correct behaviour for downloading

Currently, when downloading packages, the eopkg backend, the progress bar percentage is per-package instead of global. This means if downloading two packages the first package will download to 100% then the progress bar will reset when the next package. We currently do not use progress bars for installation.

This is undesirable as the progress bar is meant to be global for all packages. To achieve this we would need to slice how many packages are to downloaded then only update the progress for each package "slice" for a fine-grained global download progress bar.

To get the number of packages to be downloaded we can get from the pisi.ui.packagestogo callback or rework the code in the TRANSACTION_FLAG_SIMULATE section.

We can do something similar with the installation progress bar, get the total number of packages to be installed, then update the progress whenever we get a pisi.ui.installing callback. It isn't possible to get such fine-grained progress like with downloading but it is possible to also listen for the pisi.ui.extracting callback to get more fine-grained control.

solus-sc can be used as inspiration https://github.com/getsolus/solus-sc/blob/master/solus_sc/basket.py#L197. Although bear in mind it doesn't interact with pisi directly but manager.py using comar and the interface will be slightly different.

eopkg: Cleanup eopkgBackend.py

After all the fixes in filling out missing functionality from eopkgBackend.py there are some opportunities to clean up the file a bit.

Possible strategies:

  • De-duplicate all instances of status_cb() and progress_cb() if possible and put inside the PackageKitPisiBackend class. Look at https://github.com/getsolus/packages/blob/main/packages/p/pisi/comar/manager.py for inspiration.
  • Make use of the privileged decorator to set and restore the pisi UI.
  • Create a PackageKitBackendMixin class and move status_cb() and progress_cb() into the SimplePisiHandler class (maybe not possible)
  • Move most of the private eopkg logic into a PackageKitBackendMixin class. See the entropy backend for inspiration.
  • Make use of the privileged decorator to reinit/invalidate the db automatically instead of calling get_db().

pkcon segfaults when installing a package requiring additional dependencies

Steps to reproduce:

This is exactly what I've been testing. I will try other packages tomorrow.

  1. Install something with required dependencies that you probably don't have: pkcon install 0ad
  2. See that pkcon segfaults after installing (operation seems to succeed)
  3. Remove only the leaf package: pkcon remove 0ad
  4. Install it again: pkcon install 0ad
  5. See that the installation completes successfully
  6. Remove only the leaf package: pkcon remove 0ad
  7. Remove a dependency of the leaf package which has no other revdeps: pkcon remove gloox
  8. Install the leaf package again, which will pull in the very small dependency (this bug doesn't seem to be based on download size): pkcon install 0ad
  9. See that pkcon segfaults after installation again
  10. Remove both the leaf package and the small dependency at the same time: pkcon remove gloox
  11. See that you get an assertion failure like GLib-GObject-CRITICAL **: 00:37:09.727: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
  12. Install the leaf package one more time, just to make sure: pkcon install 0ad
  13. See that you get yet another segfault
  14. Stare longingly at another, more enjoyable task like building Kodi on an Asus Transformer T100ta

eopkg: get-details-local doesn't work

Testcase:

eopkg fetch xiphos
pkcon get-details-local xiphos-4.2.1-25-1-x86_64.eopkg

Error in packagekitd

13:16:38	PackageKit          failed to parse: details	xiphos;4.2.1-25;x86_64;local	Xiphos is a Bible study application	GPL-2.0-only	office	Xiphos is a Bible study application: invalid command'details', size 6
13:16:38	PackageKit          failed to parse: 	https://xiphos.org/	16458547: invalid command ''

`pkcon install-local` does nothing

I tried to install ./packagekit-devel-1.2.8-22-1-x86_64.eopkg to test pkcon, using pkcon install-local. It doesn't install any of the files contained in the eopkg. I tested the eopkg package content using lseopkg.

Error shown in Discover

Not sure if a me issue or PK.

Error Type: <type 'exceptions.AttributeError'>
Error Value: pdb
  File : /usr/share/PackageKit/helpers/eopkg/eopkgBackend.py, line 946, in <module>
    main()
  File : /usr/share/PackageKit/helpers/eopkg/eopkgBackend.py, line 943, in main
    backend.dispatcher(sys.argv[1:])
  File : /usr/lib/python2.7/site-packages/packagekit/backend.py, line 740, in dispatcher
    self.dispatch_command(args[0], args[1:])
  File : /usr/lib/python2.7/site-packages/packagekit/backend.py, line 629, in dispatch_command
    self.get_updates(filters)
  File : /usr/share/PackageKit/helpers/eopkg/eopkgBackend.py, line 440, in get_updates
    if self.packagedb.has_package(package):
  File : /usr/lib/python2.7/site-packages/pisi/db/packagedb.py, line 81, in has_package
    return self.pdb.has_item(name, repo)
  File : /usr/lib/python2.7/site-packages/pisi/db/lazydb.py, line 120, in __getattr__
    raise AttributeError, attr

eopkg: backend cannot handle quick successive operations

e.g.

$ pkcon refresh
Refreshing cache                        [=========================]         
Starting                                [=========================]         
Refreshing software list                [=========================]         
Finished                                [=========================]         
$ pkcon resolve firefox
Resolving                               [=========================]         
Fatal error: Package firefox not found

or

pkcon install some-package
pkcon remove some-package

You have to wait some seconds for the backend to become available again. Using --cache-age 1 might resolve the issue.

Error when attempting to update.

Internal error:

The backend exited unexpectedly. This is a serious error as the spawned backend did not complete the pending transaction.

I believe I know the cause of this. I installed a .eopkg from my terminal as I was building something and that caused the safety upgrade of glibc, etc, etc. Then I opened Discover to try to do any remaining updates and just hit update instead of refresh. Thus it's trying to install updates that have already been done.

After refreshing I got this, not sure if related:
Screenshot_20240131_191448
(apologies about pixelation, known spectacle issue) and no copy text button for this error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.