10

Let's say that I am building an application to a DEB package, which has as recommended dependency a package, let's call it package1.

So, package1, if installed, can provide extra functionality to my program, but not directly related to my program's basic functionality (that's why it is a recommended package)

So, the user doesn't choose initially to install the recommended package (in Ubuntu Software Center you can choose by ticking/unticking to install or not to install the recommended packages), but in the future, while using my application, it asks for the corresponding functionality.

What is the best way to tell him that an extra package has to be installed in order for this functionality to work? What program can I use so as to install this package directly from my program with a dialog indicating how the installation process is going?

I want to do this via the default way, and, preferably a way that is Linux Desktop Environment independent.

In short, I want a way to install a package from my program neither by opening Ubuntu Software Center (via an apt:// URL) nor by doing it at the background.

Ideally, it would be a dialog like the one that is used by the Update Manager (or, for the ones that remember, from the Synaptic Package Manager).

PS: I would prefer something that could be implemented using C++ !

3 Answers 3

9
+25

If you're using python, python-aptdaemon-gtk is probably the way to go. For a good example of how to do this, look at /usr/share/doc/python-aptdaemon.gtk3widgets/examples/gtk3-demo.py.gz

You get nice install prompts like:

install prompt

In the case of using C++, you could could use the AptDaemon D-Bus interface, but I don't know of any examples and you wouldn't get the widgets for free.

The D-Bus API of AptDaemon is documented here: http://packages.python.org/aptdaemon/dbus.html

I can't find much in the way of C++ DBus tutorials on the web, so your best bet is probably the documentation and examples in the libdbus-c++-doc Install libdbus-c++-doc package.

4
  • sorry, I'm not using python, but I like it as a solution. Any C++ alternative (I will edit my answer so as to include this detail)?
    – hytromo
    Aug 15, 2012 at 23:08
  • Hmm... You could could use the AptDaemon D-Bus interface from C++ I suppose, but I don't know of any examples and you wouldn't get the widgets for free. Aug 15, 2012 at 23:34
  • Nice. Do you know where I can find documentation and examples of using this DBUS interface?
    – hytromo
    Aug 16, 2012 at 9:09
  • I don't really need a tutorial for sending messages via DBus in general. I know how to do this. I just need to know what messages to send and where!
    – hytromo
    Aug 16, 2012 at 20:42
5

You might take example on the totem media player when it prompts the user to install missing codecs, or when you open share options of a directory in nautilus via right click, it prompts to install samba.

I think they use the sessioninstaller package to do that. See man session-installer, and https://launchpad.net/sessioninstaller

You could also use the command xdg-open apt://package: it will open the default package manager with the possibility to install your package (ubuntu software center in recent releases).

1
  • Please extend your answer and include more details on how to work with session-installer. As for the xdg-open solution, I clearly mentioned that I don't want them to open in USC, but, as you said, to install with an independent dialog, like when installing codecs in totem or samba in nautilus.
    – hytromo
    Aug 14, 2012 at 11:30
1

This is an old question but I've found the answer, which is apturl.

It works as follows:

apturl apt:packagename and it is exactly what I need and what nautilus uses!

Importantly, it is available pre-installed on many linux distros :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .