[go: up one dir, main page]

|
|
Log in / Subscribe / Register

Working with xdg-app application bundles

By Nathan Willis
August 12, 2015

GUADEC

One of the oft-recurring topics at GUADEC 2015 was the xdg-app application-packaging system currently being developed. Xdg-app's lead developer Alexander Larsson gave a presentation on its current status on the first day, and it featured prominently in Christian Hergert's keynote about reaching new developers as well as in Bastien Nocera's talk about hardware enablement. Perhaps the most practical discussion of the subject, however, came in Stephan Bergmann's talk about his recent attempts to bundle LibreOffice into an xdg-app package.

Bundles

By way of background, xdg-app is a scheme for bundling individual applications into isolated, standalone packages that can be safely installed on any Linux distribution. The packaged application is isolated from the running system by way of namespaces, control groups, and other standard Linux technologies; the plan is for xdg-app to provide a fully sandboxed environment as well—to secure the host system against misbehavior by the application and to secure applications against one another, although this aspect of the plan is still in development.

[Alexander Larsson]

Key to xdg-app's success will be xdg "runtimes" that are, in a sense, special-purpose application bundles that provide a base level of services and libraries intended for other app bundles to utilize. The plan is for future GNOME releases to be published as runtimes and, since they will be isolated from one another, it will possible for the GNOME 3.20 and (say) GNOME 3.24 runtimes to coexist on a single system. Applications that need one or another specific runtime never even need be aware whether their target runtime is the latest version—nor what the underlying distribution is.

Larsson gave a recap of the latest developments in xdg-app. At the moment, one of the bigger concerns is defining and implementing the suite of system services that a bundled app can use to do meaningful tasks while inside of its sandbox. "Setting up a sandbox is easy," he said; "actually doing something in a sandbox is harder." The xdg-app approach is for the app to "request that a hole be poked in the sandbox" by the system. The host system will define a set of services (network access, file access, printer access, IPC access, and so forth). When a bundled app needs to, say, open a file, the host system will prompt the user to approve or cancel the access (in the file case, for example, by showing a file-chooser dialog).

The team refers to the various services that mediate these requests as "portals." Wayland and PulseAudio are the portals for graphics and audio, a filtered D-Bus service will be the IPC portal, and so on. Several of the portals have yet to be fleshed out and require some more development—such as the printing and geolocation portals. Some of them have not quite been defined yet—it seems clear that users will want a "sharing" portal akin to the ones on iOS and Android (to send files to mobile devices or post material to social media), but its exact make-up is still an open question.

An audience member asked how app bundles request the permissions they want. Larsson replied that they do not—"it's not like Android," he said, where permissions are requested at install time. The portals are designed to trap all requests in a firewall-like (i.e., "deny by default") manner and let the user make the decisions interactively. Larsson invited those interested in further exploring the idea to follow the xdg-app mailing list and to visit the SandboxedApps section of the GNOME wiki.

Office in a box

On August 9, Bergmann, a LibreOffice developer working at Red Hat, presented his results from attempting to bundle LibreOffice with xdg-app. LibreOffice is a complex beast: the project is several million lines of code, has hundreds of submodules and dependencies, and is complex enough that it can break almost any toolchain. "Most of my time with LibreOffice is spent breaking compiler plugins" by triggering corner cases with LibreOffice builds, he commented. Linux is a special challenge because distributions compile and package LibreOffice separately with different configurations—and yet users still want a button they can press on the LibreOffice web site to download the latest release.

[Stephan Bergmann]

The project's current approach is to provide a crippled, somewhat restricted Linux download in both Debian and RPM format. That version uses an old version of GTK+, an old virtual filesystem library, and is missing several optimizations.

Thus, the benefits of xdg-app for LibreOffice are enormous, he said. If the project could provide a cross-distribution xdg-app bundle, that would save LibreOffice developers considerable hassle. In addition, he said, opening strange office files is one of the most common malware vectors, so using xdg-app's sandboxing feature would offer LibreOffice users valuable protection.

There were a handful of up-front challenges to building LibreOffice into an xdg-app bundle, Bergmann said. For starters, the xdg-app SDK is based on Yocto, which is "somewhat obscure" and can be difficult for people not used to embedded development. But Yocto also lacks some necessary packages, like Mesa's GLU or Perl's Archive::Zip module, which is employed during the LibreOffice build process. He also discovered that the Yocto layer's xml-config was hard-coded to always return an exit status of 1, which meant all calls to it failed. Bergmann fixed most of these problems, in some cases by modifying the Yocto side and in others by modifying LibreOffice.

He then set out to find which combination of the over 300 configuration switches in LibreOffice were necessary to build for xdg-app. Some things had to be disabled, such as printing, which is not yet supported in xdg-app. He also removed Java (which is used by the database modules and several extensions), and had to configure the build for GStreamer 1.0 (as opposed to GStreamer 0.10, which is another LibreOffice compile-time option). All told, he said, he had to remove about 30 libraries.

The build he came up with is X11-only and includes only the English localization. The project has not decided whether bundling every localization into one package is a good idea or not; his English-only package weighed in at 350MB already, whereas the every-language-included versions built for Windows are "monster sized" by comparison.

The process took time, but Bergmann eventually did successfully build a LibreOffice xdg-app bundle, which he then demonstrated. The look and feel is identical to a standard LibreOffice window, as one would expect—until one tries to open a file. At that point, all the app bundle sees is an empty home directory, since the file-access portal is not implemented.

On that point, he noted that the permissions model seems clear: if the user opens a file through the file chooser, that should be interpreted by the host system as implicitly granting the bundled app permission to read and write the file. But it turns out that LibreOffice has a more complicated of a model of its own. For example, LibreOffice creates lock files to prevent multiple users from editing the same file simultaneously; this breaks when xdg-app has sandboxed the program: LibreOffice tries and fails to create a lock file, then opens the requested file in read-only mode.

There are some other open questions already, he added, such as how to handle opening files by URL—which LibreOffice supports, but which uses a different code path than local-file access. The program also takes pains not to have more than one instance running at a time for any given user; the first LibreOffice process opens a socket, and any subsequent instances launched communicate with it. How to implement this in xdg-app requires some exploration. So do printing and offline help content, he added—but, all things considered, the experiment was a successful one. Simpler packaging is good, he concluded.

Obviously LibreOffice is only capable of providing one data point, but it is a large and complex point (if that does not stretch the metaphor too far), and is certainly a critical application for a great many users. Xdg-app has the potential to change Linux packaging for several classes of project and software packager: distributions, independent vendors, large project families, and so on. The mostly successful LibreOffice experiments certainly seems to bode well for xdg-app's prospects for third-party application vendors.

[The author would like to thank the GNOME Foundation for travel assistance to attend GUADEC 2015.]

Index entries for this article
ConferenceGUADEC/2015


to post comments

Working with xdg-app application bundles

Posted Aug 13, 2015 12:12 UTC (Thu) by jjmarin (subscriber, #53201) [Link] (1 responses)

Working with xdg-app application bundles

Posted Aug 13, 2015 19:57 UTC (Thu) by alexl (guest, #19068) [Link]

The libreoffice talk is available too:
http://videos.guadec.org/2015/LibreOffice%20in%20a%20Box/

Working with xdg-app application bundles

Posted Aug 13, 2015 20:01 UTC (Thu) by alexl (guest, #19068) [Link]

> Larsson replied that they do not—"it's not like Android," he said, where
> permissions are requested at install time. The portals are designed to
> trap all requests in a firewall-like (i.e., "deny by default") manner
> and let the user make the decisions interactively.

I'd like to clarify this. Certain permissions are indeed requested by
the application and granted (or not) up-front. For instance, something
like sharing the ipc namespace or not is not something we can decide
after a while, it has to be set up when the initial process is created.

However, as much as possible we want to avoid that sort of thing and be
more dynamic.

This is probably the wrong place to ask, but...

Posted Aug 13, 2015 22:59 UTC (Thu) by rahvin (guest, #16953) [Link] (8 responses)

Admission: I know nothing about containers (the new VM like feature) except for the basic premise behind them.

Isn't this what Containers are trying to do? I've never heard of xdg before but this seems to be exactly what the company pushing containers (lxc, etc) are trying to do. How is this different or is it the same thing?

This is probably the wrong place to ask, but...

Posted Aug 14, 2015 0:36 UTC (Fri) by rahulsundaram (subscriber, #21946) [Link] (2 responses)

xdg-app is a type of application container. So it is indeed similar in that sense. It also has some other useful features for desktop use cases. The references cover much of that in far more detail.

This is probably the wrong place to ask, but...

Posted Aug 14, 2015 1:01 UTC (Fri) by rahvin (guest, #16953) [Link] (1 responses)

I'll read the references later when I have a bit more time. I appreciate the reply, I was caught off guard because it sounded like LXC containers but isn't a name I've ever heard of.

Does one of the links explain how these a different than LXC containers or if they will be compatible? It would be nice if the community had one clear system that everyone used rather than the apparently multiple formats being developed. I can honestly see a future where these packaging systems supplant what we currently have, maybe not completely.

This is probably the wrong place to ask, but...

Posted Aug 14, 2015 1:14 UTC (Fri) by rahulsundaram (subscriber, #21946) [Link]

xdg-app is not that new. It has even before covered in LWN before.

https://lwn.net/Articles/630216/

https://blogs.gnome.org/alexl/2015/06/17/testing-rawhide-... has comments on how it compares to Docker.

Also related:

https://fedoraproject.org/wiki/Workstation/AtomicWorkstation

This is probably the wrong place to ask, but...

Posted Aug 14, 2015 1:57 UTC (Fri) by ABCD (subscriber, #53650) [Link] (2 responses)

Just as an aside, "XDG" (or "X Desktop Group") is the former name of the organization now known as "freedesktop.org" (or "FDO"). For various historical reasons, most things from the old XDG retained the "xdg-" prefix when the organization changed its name to freedesktop.org, and many new things from FDO use the xdg- prefix for consistency.

This is probably the wrong place to ask, but...

Posted Aug 14, 2015 7:20 UTC (Fri) by fishface60 (subscriber, #88700) [Link] (1 responses)

I thought the X stood for Cross, so XDG = Cross Desktop Group.

This is probably the wrong place to ask, but...

Posted Aug 14, 2015 14:44 UTC (Fri) by krake (guest, #55996) [Link]

Yes, it does

This is probably the wrong place to ask, but...

Posted Aug 14, 2015 7:26 UTC (Fri) by alexl (guest, #19068) [Link]

At the kernel level all the different container solutions like docker/lxc/nspawn use the same features (cgroups, namespaces, etc). xdg-app use same features (although it additionally critically relies on user namespaces in order to run without privileges).

However, I try to avoid using the term container when I talk about xdg-app to avoid confusion, as they are used in a different contexts. xdg-app always runs as the user in a graphical login session, and assumes a certain setup that desktop applications need. Containers instead generally assume a (mostly network) server kind of setup.

This is probably the wrong place to ask, but...

Posted Aug 15, 2015 11:42 UTC (Sat) by asaz989 (guest, #67798) [Link]

This builds on top of the same mechanisms used by containers (cgroups), but builds an infrastructure on top of it that's suited to desktop GUI applications installed and run by end-users rather than server-based, command-line applications run usually on headless servers and deployed by a devops/sysadmin type. The end result can look very similar, but docker and friends care a *lot* more about scriptability and large scale, while this cares more about user experience and easy third-party distribution.

Single data point maybe, but a very important one

Posted Aug 14, 2015 14:55 UTC (Fri) by krake (guest, #55996) [Link]

While LibreOffice might only be one data point, I think it is a very important one.

Lots of "app store" like systems are built around the concept of simple programs (apps) and have no or very bad support for any non-trivial applications.
They would force a suite like LibreOffice to either have all-in-one huge package, or require each application to bundle libreoffice-core again and again.

I also found the part about not being able to create lock files interesting.
Not locking in specifically but how the sandboxing ensures that atomic rename would still be possible.

Working with xdg-app application bundles

Posted Aug 14, 2015 19:49 UTC (Fri) by drag (guest, #31333) [Link] (1 responses)

Why was it necessary to remove Java from LibreOffice for XDG?

Was it just a expediency to avoid having to deal with Java dependencies in Yocto or was it some other reason?

I figure it's a curious use case because the embedded DB in LibreOffice isn't that bad as far as these things go. I know it's probably unusual for LibOffice users to take advantage of the database features, but it's technically possible to use Libre Office's database features in external programs.

Is it part of the plan then to allow xdg-apps to set up their own 'Portals' for other applications to use?

Another example is if you have a mail client that wants to open up html content in a external html browser. Would it be possible to install firefox via xdg-app and then setup a 'portal' for a mail client to use 'xdg-open' or other tool to launch a file using the existing firefox process?

Can these portals be arbitrary? Like if I have some sort of company-specific corporate ticket tracking software and want to be able to use Emacs extension to write tickets.. Or would it have to be some sort of pre-determined in some xdg standard?

Working with xdg-app application bundles

Posted Aug 27, 2015 22:59 UTC (Thu) by Wol (subscriber, #4433) [Link]

> Why was it necessary to remove Java from LibreOffice for XDG?

Because it's a design goal of the LibreOffice project to get rid of the dependency on Java?

At the moment, the only reason Java is *needed* in LO, is because the old default database is written in Java. They're moving that over to Firebird (I'm not sure whether the default is FB yet or not).

But if you've ever tried to build LO, it has a horrendous mass of dependencies - as was mentioned earlier, it is big enough and complicated enough to seriously stress most toolchains. A lot of the work of simplifying LO is also going towards trying to reduce the horrendous amount of dependencies. Java is one of the casualties :-)

Cheers,
Wol

Working with xdg-app application bundles

Posted Aug 15, 2015 10:56 UTC (Sat) by tdalman (guest, #41971) [Link] (1 responses)

Interesting. I think, this is really a step forward, not only for LibreOffice.

Though I'm puzzled about choosing Yocto. While it is a great project for Embedded Linux applications, it lacks several key features (or packages dependencies as mentioned in the article).

For me, the obvious solution would have been to use parts of the Gentoo build & package system (ofc, I'm biased as a Gentoo user). The bitbake recipies system (the core of the Yocto distribution) is in fact derived from Gentoo ebuilds ...

Working with xdg-app application bundles

Posted Aug 24, 2015 17:34 UTC (Mon) by dbnichol (subscriber, #39622) [Link]

The Yocto runtime is entirely optional. I believe it was chosen because it was a distro neutral base that's designed to bootstrap an OS. However, there's nothing Yocto specific about the runtime. We've been playing with xdg-app at my employer where we have a debian based OS. Creating the runtime was simply a choice of a different set of packages to pass to debootstrap/apt. Alex has a similar runtime he's been testing using Fedora packages and rpm-ostree.

Working with xdg-app application bundles

Posted Aug 15, 2015 11:13 UTC (Sat) by robert_s (subscriber, #42402) [Link]

Yeah, I just use nix.

Working with xdg-app application bundles

Posted Aug 15, 2015 18:05 UTC (Sat) by BlueLightning (subscriber, #38978) [Link] (2 responses)

> He also discovered that the Yocto layer's xml-config was hard-coded to always
> return an exit status of 1, which meant all calls to it failed.

This might sound strange out of context, but we do this quite deliberately. These standalone *-config scripts almost always require manual hacking to return the correct paths in a sysroot context; pkg-config on the other hand just works, so we do this to make it obvious that you need to switch to using pkg-config which can be relied upon.

Working with xdg-app application bundles

Posted Aug 15, 2015 20:05 UTC (Sat) by rahulsundaram (subscriber, #21946) [Link] (1 responses)

Does the documentation make this clearer that you want users to use pkg-config? Does xml-config provide any warning about this?

Working with xdg-app application bundles

Posted Aug 16, 2015 8:16 UTC (Sun) by BlueLightning (subscriber, #38978) [Link]

> Does the documentation make this clearer that you want users to use pkg-config?

There are references to it sprinkled around, but perhaps not in all the places where it might easily be found (well, unless you for example search the reference manual for xml2-config, then you'd find our migration section that mentions it). I have opened up a bug against the documentation to spell this out in more places.

> Does xml-config provide any warning about this?

Sort of. It returns exit code 1 and outputs an invalid option "--should-not-have-used-xml2-config" for configure scripts that don't pay attention to its exit code, but there's no clear human-readable message. I have opened another bug to print something on stderr.

Working with xdg-app application bundles

Posted Aug 16, 2015 8:33 UTC (Sun) by BlueLightning (subscriber, #38978) [Link] (1 responses)

The comment about us being missing Mesa's GLU struck me as odd, so I checked it - we do have it, it's in a separate recipe called "libglu". It's right along side the Mesa recipes and a "git grep glu", search of the OE layer index or even a post on the mailing list would have found it. Any ideas on how we'd have made this more obvious?

We indeed don't have libarchive-zip-perl, but there is an old recipe in OE-Classic that could probably be migrated pretty easily FWIW.

Working with xdg-app application bundles

Posted Aug 17, 2015 8:20 UTC (Mon) by alexl (guest, #19068) [Link]

Its certainly available in openembedded, it just is not built into the runtime. GLU is a pretty useless library that few real apps need.

Working with xdg-app application bundles

Posted Aug 17, 2015 18:54 UTC (Mon) by raven667 (subscriber, #5198) [Link] (2 responses)

I'm sure I'm not the only one who noticed the fundamental similarity to NeXT/MacOSX .app bundles. It would be interesting and probably useful to compare and contrast the two systems to see where they are similar, where they are different and what operational issues caused changes to the .app model, for example the need for dotfiles to live in the users home directory and then for trigger scripts to remove dotfiles and cache files when the .app is removed. It'd be a shame if we didn't learn all that we can about what worked and what didn't from the 20-30 years of experience with .app bundles and avoided making the same mistakes.

Make new and better mistakes!

Working with xdg-app application bundles

Posted Aug 17, 2015 19:50 UTC (Mon) by mathstuf (subscriber, #69389) [Link] (1 responses)

Ideally, apps bundled as an xdg-app would honor XDG_CONFIG_HOME and friends in the environment which could be set in the environment by whatever tool launches an xdg-app.

Working with xdg-app application bundles

Posted Aug 18, 2015 9:46 UTC (Tue) by alexl (guest, #19068) [Link]

In fact, xdg-app sets:

XDG_CACHE_HOME="/home/alex/.var/app/org.gnome.gedit/cache"
XDG_CONFIG_HOME="/home/alex/.var/app/org.gnome.gedit/config"
XDG_DATA_HOME="/home/alex/.var/app/org.gnome.gedit/data"

So many things just work.

Additionally, you can set the persist property on the metadata, like: "persistent=.mozilla"
which will cause ~/.mozilla to be a bind mount of ~/.var/app/org.mozilla.firefox/.mozilla,
in the namespace, thus making things "just work".


Copyright © 2015, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds