Skip to content

Initial creation of tutorials for 3rd party desktop applications #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions deployment/desktop/hosting-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
---
title: Hosting metadata for software applications
subsection: desktop
description: >
How to host your GUI desktop application's metadata for yum/DNF or Flatpak in self- or Github-hosted repositories
---

# Hosting metadata for yum/DNF or Flatpak

Metadata for distribution tools and GNOME Software must be refreshed
periodically, such as when new versions of [packaged
applications](desktop-software.html) are released for consumption by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where should this link point? I'd say no such path exists. Please use full paths like, f.e. /tech/languages/csharp/csharp-ide.html.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invariably I missed a couple links while rewriting this heavily. It was a very substantial amount of change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, don't worry, we just need those fixed. That's what reviews are for.

users. In many cases, Linux distributions take care of the metadata
extraction, generation, and hosting for these purposes. However, this
section provides information on how to host your own metadata in case
you need to do so.

## Install helper utilities

Install the following software to help parse and generate the metadata needed for hosting:

```console
$ sudo dnf install createrepo_c libappstream-glib-builder flatpak-builder
```

## Generating yum repository metadata

1. Run these commands to create the initial metadata for source
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the numbering here? It's a bit confusing, as the following one is also 1..

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are steps in a procedure. If it's forbidden to number those, I'll leave them out. But using "1." for each step results in a properly numbered set of steps "1., 2., 3.," etc. without having to renumber manually in the event of a change. Is that not acceptable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I did not know that. Does that work with GH-flavored MD? That's what jekyll uses to generate the resuilting website.

Copy link
Contributor

@pvalena pvalena Jan 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean by steps. However, like I said, this should NOT be a complete guide, thus no steps are needed. You can however outline what's usually done and how, but this web is meant only as a reference pointing to the full-featured guides if needed.

packages and the standard *x86_64* architecture:

```console
$ createrepo_c --no-database --simple-md-filenames SRPMS/
$ createrepo_c --no-database --simple-md-filenames x86_64/
```

1. Next, generate the AppStream XML using the *appstream-builder*
tool:

```console
$ appstream-builder \
--origin=yourcompanyname \
--basename=appstream \
--cache-dir=/tmp/asb-cache \
--enable-hidpi \
--max-threads=1 \
--min-icon-size=32 \
--output-dir=/tmp/asb-md \
--packages-dir=x86_64/ \
--temp-dir=/tmp/asb-icons
Scanning packages...
Processing packages...
Merging applications...
Writing /tmp/asb-md/appstream.xml.gz...
Writing /tmp/asb-md/appstream-icons.tar.gz...
Writing /tmp/asb-md/appstream-screenshots.tar...
Done!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do remove the sample output, as someone could accidentally paste it into terminal.

```

The actual build output will depend on your compose server
configuration. At this point you can also verify the application
is visible in the *yourcompanyname.xml.gz* file.

1. Next, take the generated XML and the tarball of icons and add it to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also 1.. What's the purpose of that?

the *repomd.xml* master document, so that GNOME Software
automatically downloads the content for searching:

```console
$ modifyrepo_c \
--no-compress \
--simple-md-filenames \
/tmp/asb-md/appstream.xml.gz \
x86_64/repodata/
$ modifyrepo_c \
--no-compress \
--simple-md-filenames \
/tmp/asb-md/appstream-icons.tar.gz \
x86_64/repodata/
```

Deploying this metadata allows GNOME Software to add the
application metadata the next time the repository is refreshed.

## Hosting a DNF repository on Github
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually a proper workflow? Do many people host their repository on Github? I'm also not sure this is the correct place to insert guide for git. Some git section, or external git guide would be better. This is not exactly relevant to the topic.
Note that this shouldn't in any way by a complete guide, but merely a starting point and links to additional content. We expect the developers do learn themselves.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also probably not a good idea to tell people to do, since it might not necessarily be something GitHub would appreciate...


While Github isn't ideal for hosting DNF repositories, this method currently works:

1. Once you've created a local copy of your repository, create a new
project on Github. Then use the follow commands to import your
repository into Github.

```console
$ cd ~/src/myrepository
$ git init
$ git add -A
$ git commit -a -m "first commit"
$ git remote add origin [email protected]:yourgitaccount/myrepo.git
$ git push -u origin master
```

1. Next, go to the Github web interface and browse down in the file
tree until you find the file called *repomd.xml*, and click on
it. You should now see a button in the Github interface called
*Raw*. Click that to get the raw version of the XML file. In the
URL bar of your browser you should see a URL like this:

```console
https://raw.githubusercontent.com/username/reponame/master/noarch/repodata/repomd.xml
```

Copy that URL, as you'll need it to create the *.repo* file that distributions and users use to reach your new repository.

1. Create a *.repo* file using this example as a template, and edit it to match your data:

```console
[frobnicator]
name=Frobnicator 3D generator
baseurl=https://raw.githubusercontent.com/username/reponame/master/noarch
gpgcheck=0
enabled=1
enabled_metadata=1
```

For more information on this format, consult the [repository
options in the DNF configuration documentation](http://dnf.readthedocs.io/en/latest/conf_ref.html#repo-options).

1. Copy this file to */etc/yum.repos.d* on your computer and load up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is some people would struggle, as you need to use $ sudo for that and you should include at least some sample command here.

GNOME Software. Click on the *Updates* button in GNOME Software,
and then select the refresh button in the top left corner to ensure
your database is up to date. You should then be able to search in
GNOME software and find your new application.

## Generating Flatpak metadata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit lost, because there's too much content for one page. This is line 132 and our pages are usually like 40 lines long. It should be just a quick helpful reference, not a full-featured guide.

Flatpack usage does deserve it's own page....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant issue: #245


The [Flatpak](https://flatpak.org) application packaging standard is another way to provide metadata for consumers. This guide assumes you are familiar with this standard, along with the [manifest and basic build operations required](http://docs.flatpak.org/en/latest/flatpak-builder.html). You can find extensive information on building Flatpaks and on hosting and signing flatpak repostories [here](https://blogs.gnome.org/alexl/2017/02/10/maintaining-a-flatpak-repository/).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guide assumes you are familiar with this standard, along with...

Please do remove that sentence, as well as the following one. I do not think it's relevant, but you can include those two links in a reference section.


Create an empty repository in a *repo* folder with this command:

```console
$ ostree init --mode=archive-z2 --repo=repo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this command need an empty directory? Shouldn't there be a command to create it and cd to it also?

```

To tell flatpak-builder to import the end result of a build into this repository, pass the *--repo* option to use the folder you created:

```console
$ flatpak-builder --verbose --force-clean \
--repo=repo --gpg-homedir=gpg --gpg-sign=$GPG_KEY \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do I find the $GPG_KEY? Do I leave the variable empty?

recipes flatpak/org.example.Frobnicator.json
```

To generate appstream branches and static deltas in this repository use this command:

```console
$ flatpak build-update-repo --generate-static-deltas \
--gpg-homedir=gpg --gpg-sign=$GPG_KEY repo
```

Note that both of these commands take a *--gpg-sign* argument. Flatpak
uses GPG as a means to ensure that the repository can be trusted, so
you should sign your public repositories.

To make your application and its Flatpak repository available to users is to publish a flatpakref file:

```console
[Flatpak Ref]
Title=Frobnicator
Name=org.example.Frobnicator
Url=https://raw.githubusercontent.com/username/reponame/master/repo/
Branch=1.0
IsRuntime=False
GPGKey=...
RuntimeRepo=https://sdk.gnome.org/gnome.flatpakrepo
Comment=GNOME loves to Frobnicate
```

## Hosting a Flatpak repository on Github

Github isn't ideal for hosting Flatpak repositories, but this method currently works.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, probably not a good idea...


1. Once you create a local copy of your repository, create a new
project on Github, enable Github pages for the project and point it
at the master branch.

1. Next, import your repository into Github.

```console
$ git remote add origin [email protected]:yourgitaccount/myrepo.git
$ git push -u origin master
```

Now you should be able to refer to your repo with a
*raw.githubusercontent.com/* URL as shown in the flatpakrepo example
above.

## A note on third party repositories

For more information on inclusion in Fedora as a third party software
repository, consult with the [Fedora Workstation working
group](https://fedoraproject.org/wiki/Workstation).
137 changes: 137 additions & 0 deletions deployment/desktop/software-appdata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
title: Adding Applications to GNOME Software
section: deployment
subsection: desktop
description: >
How to build and package your GUI desktop applications for easy deployment by your users
---

# Adding Applications to GNOME Software

The GNOME Software app provides a cross-distribution software center from which users can browse and manage apps for their Linux system. This guide will help you produce the necessary metadata so your app can be listed in the software center. Note that this guide covers apps as opposed to other system add-on components such as drivers and codecs.

![GNOME Software](/content/deployment/desktop/steam-gnome-software.png "Example of Steam listing in GNOME Software")

This guide assumes an application package called Frobnicator, which contains an executable called *frob*. It also assumes you are running Fedora Workstation with the standard GNOME desktop environment.

## Install helper utilities

Install the following packages on your Fedora system to help assemble
and validate the metadata for your application:

```console
$ sudo dnf install desktop-file-utils appstream-util gnome-shell-extension-screenshot-window-sizer
```

## Create a desktop application file

1. Write a *.desktop* file that follows the [Desktop File
Specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#introduction).
The required fields are *Name*, *Comment*, *Icon*, *Categories*,
*Keywords*, and *Exec*. Here is an example:

```console
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely not a console. You can leave it empty if you cannot decide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is ini.

[Desktop Entry]
Type=Application
Name=Frobnicator
Comment=Frobnicate a PNG into a 3D object
Icon=frob
Exec=frob %f
MimeType=application/x-frob;
Categories=Graphics;3DGraphics;Engineering;
Keywords=3d;solid;geometry;csg;model;stl;
```

Your package should install this file in the
*/usr/share/application* folder. You may assign the desktop file a
short name such as *frob.desktop* in this example. However, new
applications typically use a reverse-DNS style name, for example
*org.example.Frobnicator.desktop*.

1. Create a PNG icon for the file at least 64x64 in size, with a
transparent background. The icon should be named as in the *Icon*
field above, for example *frob.png*. Your package should install
this file in one of the following locations:
- */usr/share/icons*
- */usr/share/icons/hicolor/apps*
- */usr/share/${app_name}/icons*

1. Verify the desktop file with the *desktop-file-validate* command:

```console
$ desktop-file-validate org.example.Frobnicator.desktop
```

## Create an AppData file

The AppData file provides XML metadata that follows the [AppStream
specification](https://www.freedesktop.org/software/appstream/docs/),
and is used by the GNOME Software app to display the app to users in
the software center.

1. Create an XML file for your application that follows the template
below. Note that you should consult the [AppStream
specification](https://www.freedesktop.org/software/appstream/docs/)
to provide correct data for your application in this file. Here is
an example for the Frobnicator app:

```console
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is xml

<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.frobnicator.Frobnicator.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Frobnicator</name>
<summary>Frobnicate a PNG into a 3D object</summary>
<description>
<p>You can use Frobnicator to turn a PNG file into a 3D object magically, if you have the appropriate Frob interface card installed on your system.</p>
</description>
<screenshots>
<screenshot type="default">
<image>https://frobnicator.org/git/browse/frobnicator/plain/data/appdata/frob-startup.png</image>
<caption>Initial screen for the application</caption>
</screenshot>
</screenshots>
<releases>
<release version="1.0.0" date="2017-12-02">
<description>
<p>This is the first stable release</p>
</description>
</release>
</releases>
<url type="homepage">https://example.org/Frobnicator</url>
<provides>
<binary>frob</binary>
</provides>
<mimetypes>
<mimetype>application/x-frob</mimetype>
</mimetypes>
</component>
```

1. Next, make the appropriate 16:9 aspect ratio screenshots for your
package, showing the application in action. To make screenshot
creation easier, use the GNOME Shell extension called *Screenshot
Window Sizer* which you installed earlier. To resize the window of
your application to 16:9 format, focus it and press *Ctrl+Alt+s*.
Your application window is resized to a perfect 16:9 aspect ratio
so you can screenshot it with *Alt+PrtScn*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise I do not think this is a place for a basic usage of any Screenshot tool. You can link to a relevant guide.


Store the screenshots at the URL referenced in your AppData XML file.

1. Validate the AppData XML file:

```console
$ appstream-util validate foo.appdata.xml
```

NOTE: Do not install two applications with one single package. If
necessary, split up a package into multiple subpackages or mark one
*.desktop* file with *NoDisplay=true*. In this case, make sure the
application subpackages depend on any *-common* subpackage, and that
you deal with upgrades (perhaps using a metapackage) if you’ve shipped
the application before.

Normally distributions take care of hosting operations from this
point. However, if you want to host your own metadata for use with
yum/DNF or Flatpak, [this guide](hosting-metadata.html) may be of use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link is also not pointing anywhere.

I also find this whole block / paragraph useless from developer POV.

Binary file added deployment/desktop/steam-gnome-software.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.