[gnome-maps/wip/mlundblad/dual-installation] Set up dual installation support




commit dfd8a5ddf2dd53dc5b08a976e693067636af6620
Author: Marcus Lundblad <ml update uu se>
Date:   Mon Oct 18 23:04:25 2021 +0200

    Set up dual installation support
    
    Add support for building dual-installable .Devel packages.
    Based on an original WIP merge request by Bilal Elmoussaoui.

 .gitignore                                         |  2 ++
 .gitlab-ci.yml                                     |  2 +-
 data/icons/meson.build                             | 14 ++++++++---
 data/meson.build                                   | 28 +++++++++++++++-------
 ...ata.xml.in => org.gnome.Maps.appdata.xml.in.in} |  4 ++--
 ...aps.desktop.in => org.gnome.Maps.desktop.in.in} |  4 ++--
 data/org.gnome.Maps.service.in                     |  4 ++--
 meson.build                                        |  8 ++++++-
 meson_options.txt                                  |  1 +
 meson_post_install.py                              |  4 +++-
 org.gnome.Maps.json                                |  5 +++-
 po/POTFILES.in                                     |  6 ++---
 src/application.js                                 |  2 +-
 src/geoclue.js                                     |  2 +-
 src/mainWindow.js                                  |  5 +++-
 src/meson.build                                    | 14 +++++++++--
 ...rce.xml => org.gnome.Maps.src.gresource.xml.in} |  2 +-
 17 files changed, 77 insertions(+), 30 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b7aecf88..80640f6c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ missing
 
 data/org.gnome.Maps.appdata.xml
 data/org.gnome.Maps.desktop
+data/org.gnome.Maps.gschema.xml.in
 data/org.gnome.Maps.gschema.valid
 
 m4/*.m4
@@ -40,6 +41,7 @@ po/*.header
 
 src/gnome-maps
 src/*.gresource
+src/*.gresource.xml
 src/org.gnome.Maps.service
 
 /lib/GnomeMaps-1.0.gir
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 387a98ec..96a624a8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,7 +10,7 @@ flatpak:
         RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo";
         # Replace with your application name, as written in the manifest
         FLATPAK_MODULE: "gnome-maps"
-        APP_ID: "org.gnome.Maps"
+        APP_ID: "org.gnome.Maps.Devel"
         BUNDLE: "gnome-maps-git.flatpak"
 
 nightly:
diff --git a/data/icons/meson.build b/data/icons/meson.build
index f741a0b7..924d12de 100644
--- a/data/icons/meson.build
+++ b/data/icons/meson.build
@@ -1,6 +1,14 @@
-install_subdir(
-       join_paths('public', 'hicolor'),
-       install_dir: join_paths(datadir, 'icons')
+# install the app icon (the regular or .Devel one)
+install_data(
+       join_paths('public', 'hicolor', 'scalable', 'apps', app_id + '.svg'),
+       install_dir: join_paths(datadir, 'icons', 'hicolor', 'scalable', 'apps')
+)
+
+# install the symbolic app icon with the current name (optionally with .Devel suffix)
+install_data(
+       join_paths('public', 'hicolor', 'symbolic', 'apps', 'org.gnome.Maps-symbolic.svg'),
+       install_dir: join_paths(datadir, 'icons', 'hicolor', 'symbolic', 'apps'),
+       rename: '@0 -symbolic svg'.format(app_id)
 )
 
 install_subdir(
diff --git a/data/meson.build b/data/meson.build
index 2be4ee73..30d45db1 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,6 +1,6 @@
 gnome.compile_resources(
        app_id + '.data',
-       app_id + '.data.gresource.xml',
+       'org.gnome.Maps.data.gresource.xml',
        gresource_bundle: true,
        install: true,
        install_dir: pkgdatadir
@@ -12,9 +12,14 @@ install_data(
 )
 
 desktop = app_id + '.desktop'
-
+desktop_config = configuration_data()
+desktop_config.set('app-id', app_id)
 desktop_file = custom_target('desktop-file',
-  input: desktop + '.in',
+  input: configure_file(
+       input: 'org.gnome.Maps.desktop.in.in',
+       output: 'org.gnome.Maps.desktop.in',
+       configuration: desktop_config
+  ),
   output: desktop,
   install: true,
   install_dir: join_paths(datadir, 'applications'),
@@ -26,15 +31,21 @@ desktop_file = custom_target('desktop-file',
 )
 
 install_data(
-       app_id + '.gschema.xml',
+       'org.gnome.Maps.gschema.xml',
        install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
 )
 
 appdata = app_id + '.appdata.xml'
-
+appdata_config = configuration_data()
+appdata_config.set('app-id', app_id)
+appdata_config.set('gettext-package', 'gnome-maps')
 appdata_file = i18n.merge_file(
        appdata,
-       input: appdata + '.in',
+       input: configure_file(
+               input: 'org.gnome.Maps.appdata.xml.in.in',
+               output: 'org.gnome.Maps.appdata.xml.in',
+               configuration: appdata_config
+       ),
        output: appdata,
        po_dir: po_dir,
        install: true,
@@ -44,9 +55,10 @@ appdata_file = i18n.merge_file(
 service_conf = configuration_data()
 service_conf.set('PACKAGE_NAME', meson.project_name())
 service_conf.set('pkgdatadir', pkgdatadir)
+service_conf.set('app-id', app_id)
 
 configure_file(
-       input: app_id + '.service.in',
+       input: 'org.gnome.Maps.service.in',
        output: app_id + '.service',
        configuration: service_conf,
        install: true,
@@ -77,4 +89,4 @@ if appstream_util.found()
        )
 endif
 
-subdir('icons')
\ No newline at end of file
+subdir('icons')
diff --git a/data/org.gnome.Maps.appdata.xml.in b/data/org.gnome.Maps.appdata.xml.in.in
similarity index 99%
rename from data/org.gnome.Maps.appdata.xml.in
rename to data/org.gnome.Maps.appdata.xml.in.in
index ffa40792..1963e23e 100644
--- a/data/org.gnome.Maps.appdata.xml.in
+++ b/data/org.gnome.Maps.appdata.xml.in.in
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <component type="desktop-application">
-  <id>org.gnome.Maps.desktop</id>
+  <id>@app-id@.desktop</id>
   <metadata_license>CC0-1.0</metadata_license>
   <project_license>GPL-2.0-or-later</project_license>
   <name>Maps</name>
@@ -17,7 +17,7 @@
     </p>
   </description>
 
-  <launchable type="desktop-id">org.gnome.Maps.desktop</launchable>
+  <launchable type="desktop-id">@app-id@.desktop</launchable>
 
   <screenshots>
     <screenshot type="default">
diff --git a/data/org.gnome.Maps.desktop.in b/data/org.gnome.Maps.desktop.in.in
similarity index 91%
rename from data/org.gnome.Maps.desktop.in
rename to data/org.gnome.Maps.desktop.in.in
index 85a58a9b..da57c3fe 100644
--- a/data/org.gnome.Maps.desktop.in
+++ b/data/org.gnome.Maps.desktop.in.in
@@ -2,9 +2,9 @@
 Version=1.0
 Name=Maps
 Comment=A simple maps application
-Exec=gapplication launch org.gnome.Maps %U
+Exec=gapplication launch @app-id@ %U
 # Translators: Do NOT translate or transliterate this text (this is an icon file name)!
-Icon=org.gnome.Maps
+Icon=@app-id@
 Terminal=false
 Type=Application
 StartupNotify=true
diff --git a/data/org.gnome.Maps.service.in b/data/org.gnome.Maps.service.in
index f8a854f6..df2f1888 100644
--- a/data/org.gnome.Maps.service.in
+++ b/data/org.gnome.Maps.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
-Name=org.gnome.Maps
-Exec=@pkgdatadir@/org.gnome.Maps --gapplication-service
+Name=@app-id@
+Exec=@pkgdatadir@/@app-id@ --gapplication-service
diff --git a/meson.build b/meson.build
index 611289dd..74852167 100644
--- a/meson.build
+++ b/meson.build
@@ -4,6 +4,11 @@ project('gnome-maps', 'c',
 )
 
 app_id = 'org.gnome.Maps'
+
+if get_option('profile') == 'development'
+       app_id = 'org.gnome.Maps.Devel'
+endif
+
 gnome = import('gnome')
 i18n = import('i18n')
 
@@ -60,5 +65,6 @@ subdir('tests')
 meson.add_install_script(
   'meson_post_install.py',
   datadir,
-  bindir
+  bindir,
+  app_id
 )
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..e5648028
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('profile', type: 'combo', choices: ['default', 'development'], value: 'default')
diff --git a/meson_post_install.py b/meson_post_install.py
index bb6b67c9..d804b3b8 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -11,12 +11,14 @@ datadir = sys.argv[1]
 destdir = os.environ.get('DESTDIR', '')
 bindir = os.path.normpath(destdir + os.sep + sys.argv[2])
 
+appid = sys.argv[3];
+
 # FIXME: meson will not track the creation of these files
 #        https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39
 if not os.path.exists(bindir):
   os.makedirs(bindir)
 
-src = os.path.join(datadir, 'gnome-maps', 'org.gnome.Maps')
+src = os.path.join(datadir, 'gnome-maps', appid)
 dest = os.path.join(bindir, 'gnome-maps')
 subprocess.call(['ln', '-s', '-f', src, dest])
 
diff --git a/org.gnome.Maps.json b/org.gnome.Maps.json
index a6c3358c..5d99ada9 100644
--- a/org.gnome.Maps.json
+++ b/org.gnome.Maps.json
@@ -1,5 +1,5 @@
 {
-    "app-id" : "org.gnome.Maps",
+    "app-id" : "org.gnome.Maps.Devel",
     "runtime" : "org.gnome.Platform",
     "runtime-version" : "master",
     "sdk" : "org.gnome.Sdk",
@@ -235,6 +235,9 @@
             "name" : "gnome-maps",
             "buildsystem" : "meson",
             "builddir" : true,
+            "config-opts": [
+                "-Dprofile=development"
+            ],
             "sources" : [
                 {
                     "type" : "git",
diff --git a/po/POTFILES.in b/po/POTFILES.in
index dd6119c4..cd5628f7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,8 +1,8 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
-data/org.gnome.Maps.appdata.xml.in
-data/org.gnome.Maps.desktop.in
-data/org.gnome.Maps.gschema.xml
+data/org.gnome.Maps.appdata.xml.in.in
+data/org.gnome.Maps.desktop.in.in
+data/org.gnome.Maps.gschema.xml.in
 data/ui/check-in-dialog.ui
 data/ui/context-menu.ui
 data/ui/export-view-dialog.ui
diff --git a/src/application.js b/src/application.js
index 32d309b0..5985c87c 100644
--- a/src/application.js
+++ b/src/application.js
@@ -96,7 +96,7 @@ var Application = GObject.registerClass({
         /* Needed to be able to use in UI files */
         _ensuredTypes.forEach((type) => GObject.type_ensure(type));
 
-        super._init({ application_id: 'org.gnome.Maps',
+        super._init({ application_id: pkg.name,
                       flags: Gio.ApplicationFlags.HANDLES_OPEN |
                              Gio.ApplicationFlags.HANDLES_COMMAND_LINE });
         this._connected = false;
diff --git a/src/geoclue.js b/src/geoclue.js
index 14f60ecb..864d9897 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -70,7 +70,7 @@ var Geoclue = GObject.registerClass({
     }
 
     start(callback) {
-        let id = 'org.gnome.Maps';
+        let id = pkg.name;
         let level = GClue.AccuracyLevel.EXACT;
 
         GClue.Simple.new(id, level, null, (object, result) => {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 08446e36..8c63faf3 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -112,6 +112,9 @@ var MainWindow = GObject.registerClass({
         this._contextMenu = new ContextMenu.ContextMenu({ mapView: this._mapView,
                                                           mainWindow: this });
 
+        if (pkg.name.endsWith('.Devel'))
+            this.get_style_context().add_class('devel');
+
         this._initActions();
         this._initHeaderbar();
         this._initSignals();
@@ -592,7 +595,7 @@ var MainWindow = GObject.registerClass({
             program_name: _("Maps"),
             comments: _("A map application for GNOME"),
             license_type: Gtk.License.GPL_2_0,
-            logo_icon_name: 'org.gnome.Maps',
+            logo_icon_name: pkg.name,
             version: pkg.version,
             website: 'https://live.gnome.org/Apps/Maps',
             wrap_license: true,
diff --git a/src/meson.build b/src/meson.build
index 49706a85..be7e6636 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -5,16 +5,26 @@ script_conf.set('libdir', libdir)
 script_conf.set('prefix', prefix)
 
 configure_file(
-       input: app_id + '.in',
+       input: 'org.gnome.Maps.in',
        output: app_id,
        configuration: script_conf,
        install: true,
        install_dir: pkgdatadir
 )
 
+sources_conf = configuration_data()
+if (get_option('profile') == 'development')
+       sources_conf.set('suffix', '/Devel')
+else
+       sources_conf.set('suffix', '')
+endif
 gnome.compile_resources(
        app_id + '.src',
-       app_id + '.src.gresource.xml',
+       configure_file(
+               input: 'org.gnome.Maps.src.gresource.xml.in',
+               output: 'org.gnome.Maps.src.gresource.xml',
+               configuration: sources_conf
+       ),
        gresource_bundle: true,
        install: true,
        install_dir: pkgdatadir,
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml.in
similarity index 98%
rename from src/org.gnome.Maps.src.gresource.xml
rename to src/org.gnome.Maps.src.gresource.xml.in
index 70877dee..c4f10655 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml.in
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/org/gnome/Maps/js">
+  <gresource prefix="/org/gnome/Maps@suffix@/js">
     <file>accountListBox.js</file>
     <file>address.js</file>
     <file>application.js</file>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]