Building Glimpse/Linux

From GlimpseWiki
Jump to: navigation, search

This page contains instructions specific to building the Glimpse source code locally on GNU/Linux systems.

Building

Build in Gnome Builder

GNOME Builder is an IDE built around Flatpak technology, which makes it extremely easy to build and run your own changes as you contribute to Glimpse.

First, clone Glimpse in Builder: (if you already have a clone, simply open it with Builder)

Cloning Glimpse in Builder

If you are prompted to install the Sdk required to build Glimpse, you should accept as this is required. You will then be taken to the Builder workspace, where you can edit the Glimpse source code.

Next, click the build button in the top bar:

The "build" button

Builder will build Glimpse with Flatpak. This means it will build both Glimpse and its dependencies, which might take some time. Fortunately, this is only done once. Subsequent builds will only build the changes you have made to Glimpse.

Finally, when the build completes, you can click the run button:

The "run" button

The Glimpse main window should now appear.

Build in a Virtual Machine with Vagrant

For developer convenience we have provided a "development environment in a box" that can be provisioned and run on any distribution. You may also want to choose this approach if you do not want build dependency packages affecting the stability of workstations you rely on for daily productivity tasks.

  1. Install the latest version of Oracle Virtualbox with "Guest Additions".
  2. Also install Vagrant, the scripting engine you will use to provision the virtual machine.
  3. After cloning the Glimpse source code from Github, run this command from inside the cloned directory:
  4. $ vagrant up
  5. Once the virtual machine has finished being provisioned, log in to the virtual machine:
  6. $ vagrant ssh
  7. Change to the /vagrant directory, as that is where the source code is mounted on the virtual guest operating system.
  8. Run the provided build script inside the virtual machine:
  9. $ sh glimpse-vagrant.sh

Because X11 forwarding is already enabled you should be able to launch your built copy of Glimpse from inside the virtual machine:

$ ./glimpse-prefix/bin/glimpse

The vagrant up command uses Vagrantfile to determine the parameters of the virtual machine, and glimpse-vagrant.yml is used by Ansible to install the prerequisite packages.

Build on Ubuntu or Debian

This will build locally to the system and install in /usr/local.

  • First, currently there is a library namespace conflict, so GNU Image Manipulation Program must first be removed from the system.
 $ sudo dpkg --purge libgimp2.0 libgimp2.0 gimp-data gimp-data

If you experience dependency errors, simply add the packages that depend on gimp to the list to purge and try again.

  • Next install build dependencies
$ sudo apt install build-essential git
$ sudo apt build-dep gimp

Now follow the steps in Building Glimpse. If you discover there are still missing dependencies, you can use the packages listed in glimpse-vagrant.yml as a reference.

If you decide to use system locations instead of a dedicated folder set with the --prefix flag you will need root permissions for the make install stages.

Packaging

Package as a Flatpak

Build from Git

The Glimpse source code comes with a Flatpak manifest (at build/flatpak/org.glimpse_editor.Glimpse.json).

Before building Glimpse, you need to install the required Platform and Sdk runtimes. You can find the required versions in the manifest. As of today, it says:

     "runtime": "org.gnome.Platform",
     "runtime-version": "3.32",
     "sdk": "org.gnome.Sdk",

This means you need to install the runtimes with:

   $ flatpak install flathub org.gnome.Platform//3.32 org.gnome.Sdk//3.32

From a Git clone of Glimpse, you can trivially build a Git snapshot with:

   $ flatpak-builder --force-clean --ccache _build build/flatpak/org.glimpse_editor.Glimpse.json

Note that Flatpak will build Glimpse as well as all its dependencies which aren't already in the Sdk. This could take a long time. Fortunately Flatpak is smart enough to cache builds and only rebuild what changed, so subsequent builds should be much faster.

Stable Releases

To make a stable release (e.g for Flathub), you need to first edit the manifest to build from a stable point.

Find the Glimpse section in the manifest:

       {
         "name": "glimpse",
         "sources": [
           {
             "type": "dir",
             "path": "../.."
           }
         ],
       }

And replace it by something like the following (adapt to the actual release):

       {
         "name": "glimpse",
         "sources": [
           {
             "type": "git",
             "url": "https://github.com/glimpse-editor/glimpse",
             "tag": "0.1.0",
             "commit": "175d402049d2737673b700a87f08dd0baddafc08"
           }
         ],
       }

At this point, you can build the Glimpse stable release you chose with the same command as above:

   $ flatpak-builder --force-clean --ccache _build build/flatpak/org.glimpse_editor.Glimpse.json

Publish

To publish this build, you need to commit it to a repository, ideally signing it with a GPG key:

   $ flatpak-builder --force-clean --ccache --repo=path/to/repository --gpg-sign=${GPG_KEY_ID} _build build/flatpak/org.glimpse_editor.Glimpse.json
   $ flatpak build-update-repo --title="Glimpse" --prune --prune-depth=4 --gpg-sign=${GPG_KEYID} --generate-static-deltas path/to/repository

You can then rsync the repository to a server somewhere, behind something like Nginx serving its contents statically.

Package as a Snap

To build the snap, you'll need to have snapd, snapcraft, and multipass installed.

  • snapd is typically provided by your distro. For more info, see installing snapd.
  • Both snapcraft and multipass are best to be installed from the snap store (will be more up to date than what distros provide):
   $ sudo snap install snapcraft --classic
   $ sudo snap install multipass --classic

Once snapd, snapcraft, and multipass are installed, you are ready to build the glimpse snap (from glimpse's root directory):

   $ snapcraft

The build will take ~30 min and once completed, you'll have a message similar to:

   Snapped glimpse-editor_0+git.5f458ddc43_amd64.snap

You can install this snap and then run it by either clicking the application icon installed or run it from the command line:

   $ sudo snap install glimpse-editor_0+git.5f458ddc43_amd64.snap --dangerous
   $ snap run glimpse-editor

Package as an AppImage

TODO