diff --git a/usr/share/icons/hicolor/scalable/categories/applications-webapps.svg b/data/icons/categories/applications-webapps.svg similarity index 100% rename from usr/share/icons/hicolor/scalable/categories/applications-webapps.svg rename to data/icons/categories/applications-webapps.svg diff --git a/usr/share/icons/hicolor/scalable/apps/webapp-manager.svg b/data/icons/webapp-manager.svg similarity index 100% rename from usr/share/icons/hicolor/scalable/apps/webapp-manager.svg rename to data/icons/webapp-manager.svg diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..6a55b9c --- /dev/null +++ b/data/meson.build @@ -0,0 +1,45 @@ +app_icon_dir = join_paths(datadir, 'icons', 'hicolor', 'scalable', 'apps') +category_icon_dir = join_paths(datadir, 'icons', 'hicolor', 'scalable', 'categories') +schema_dir = join_paths(datadir, 'glib-2.0', 'schemas') +# message(f'Icon dir: @app_icon_dir@') +# message(f'Schema dir: @schema_dir@') + +# install icons +install_emptydir(app_icon_dir) +install_data( + join_paths(meson.current_source_dir(), 'icons', f'@application_id@.svg'), + install_dir: app_icon_dir, +) + +install_data( + join_paths(meson.current_source_dir(), 'icons/categories/applications-webapps.svg'), + install_dir: category_icon_dir, +) + + +# Install desktop file +# desktop_file = i18n.merge_file( +# input: 'webapp-manager.desktop.in', +# output: 'webapp-manager.desktop', +# type: 'desktop', +# po_dir: '../po', +# install: true, +# install_dir: desktop_dir +# ) + +# Install schema file +schema_file = i18n.merge_file( + input: 'org.x.webapp-manager.gschema.xml.in', + output: 'org.x.webapp-manager.gschema.xml', + type: 'xml', + po_dir: '../po', + install: true, + install_dir: schema_dir +) + +compile_schemas = find_program('glib-compile-schemas', required: false) +if compile_schemas.found() + test('Validate schema file', + compile_schemas, + args: ['--strict', '--dry-run', meson.current_source_dir()]) +endif diff --git a/usr/share/glib-2.0/schemas/org.x.webapp-manager.gschema.xml b/data/org.x.webapp-manager.gschema.xml.in similarity index 100% rename from usr/share/glib-2.0/schemas/org.x.webapp-manager.gschema.xml rename to data/org.x.webapp-manager.gschema.xml.in diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control index 150fa3f..c15de87 100644 --- a/debian/control +++ b/debian/control @@ -2,8 +2,15 @@ Source: webapp-manager Section: admin Priority: optional Maintainer: Linux Mint -Build-Depends: debhelper (>= 9) -Standards-Version: 3.9.5 +Build-Depends: debhelper-compat (= 13), + desktop-file-utils, + dh-python, + libglib2.0-bin, + libgtk-4-bin, + meson (>= 1.3.0), + pkg-config, + python3-all, +Standards-Version: 4.6.1 Package: webapp-manager Architecture: all @@ -15,7 +22,8 @@ Depends: gir1.2-xapp-1.0 (>= 1.4), python3-pil, python3-setproctitle, python3-tldextract, - xapps-common, - ${misc:Depends}, + xapps-common,, + ${python3:Depends}, + ${misc:Depends} Description: Web Application Manager Launch websites as if they were apps. diff --git a/debian/postinst b/debian/postinst index af3b796..300a846 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,16 +1,24 @@ #!/bin/sh +# postinst script for webapp-manager +# +# see: dh_installdeb(1) + set -e + case "$1" in configure) - if which glib-compile-schemas >/dev/null 2>&1 - then - glib-compile-schemas /usr/share/glib-2.0/schemas - fi + if which glib-compile-schemas >/dev/null 2>&1 + then + glib-compile-schemas /usr/share/glib-2.0/schemas + fi + if which gtk4-update-icon-cache >/dev/null 2>&1 + then + gtk4-update-icon-cache -q -t -f /usr/share/icons/hicolor + fi ;; abort-upgrade|abort-remove|abort-deconfigure) - ;; *) @@ -18,3 +26,10 @@ case "$1" in exit 1 ;; esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..0e6ed20 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,32 @@ +#!/bin/sh +# postrm script for webapp-manager +# +# see: dh_installdeb(1) + +set -e + + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + if which glib-compile-schemas >/dev/null 2>&1 + then + glib-compile-schemas /usr/share/glib-2.0/schemas + fi + if which gtk4-update-icon-cache >/dev/null 2>&1 + then + gtk4-update-icon-cache -q -t -f /usr/share/icons/hicolor + fi + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules index 097372c..38509f4 100755 --- a/debian/rules +++ b/debian/rules @@ -1,13 +1,23 @@ #!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +# export DH_VERBOSE = 1 -DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ') +export PYBUILD_NAME=webapp-manager +export PYBUILD_SYSTEM=pyproject + +# DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ') %: - dh ${@} - -# Inject version number in the code -override_dh_installdeb: - dh_installdeb - for pkg in $$(dh_listpackages -i); do \ - find debian/$$pkg -type f -exec sed -i -e s/__DEB_VERSION__/$(DEB_VERSION)/g {} +; \ - done + dh ${@} --with=python3 --buildsystem=meson + +# # Inject version number in the code +# override_dh_installdeb: +# dh_installdeb +# for pkg in $$(dh_listpackages -i); do \ +# find debian/$$pkg -type f -exec sed -i -e s/__DEB_VERSION__/$(DEB_VERSION)/g {} +; \ +# done + +override_dh_auto_build: + dh_auto_build -O--buildsystem=meson + make -j8 diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..3a026f7 --- /dev/null +++ b/meson.build @@ -0,0 +1,28 @@ +project('webapp-manager', + version: run_command('head', '-1', 'debian/changelog', check: true).stdout().split(' ')[1].strip('(').strip(')'), + license: ['GPL3'], + meson_version: '>= 1.3.0', + default_options: ['warning_level=3', + 'prefix=/usr', + ] +) + +application_id = meson.project_name() +i18n = import('i18n') +gnome = import('gnome') +pymod = import('python') +python = pymod.find_installation('python3') + +prefix = get_option('prefix') +bindir = get_option('bindir') +datadir = get_option('datadir') + +subdir('src') +subdir('data') +# subdir('po') + +gnome.post_install( + glib_compile_schemas: true, + gtk_update_icon_cache: true, + update_desktop_database: true, +) diff --git a/src/WebappManager/VERSION.in b/src/WebappManager/VERSION.in new file mode 100644 index 0000000..14d2ff6 --- /dev/null +++ b/src/WebappManager/VERSION.in @@ -0,0 +1 @@ +@version@ diff --git a/usr/lib/webapp-manager/common.py b/src/WebappManager/common.py similarity index 100% rename from usr/lib/webapp-manager/common.py rename to src/WebappManager/common.py diff --git a/usr/lib/webapp-manager/webapp-manager.py b/src/WebappManager/main.py old mode 100755 new mode 100644 similarity index 98% rename from usr/lib/webapp-manager/webapp-manager.py rename to src/WebappManager/main.py index fa403bf..c6f5900 --- a/usr/lib/webapp-manager/webapp-manager.py +++ b/src/WebappManager/main.py @@ -6,6 +6,7 @@ import os import shutil import subprocess +import sys import warnings # 2. Related third party imports. @@ -21,7 +22,7 @@ from gi.repository import Gtk, Gdk, Gio, XApp, GdkPixbuf # 3. Local application/library specific imports. -from common import _async, idle, WebAppManager, download_favicon, ICONS_DIR, BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP +from WebappManager.common import _async, idle, WebAppManager, download_favicon, ICONS_DIR, BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP setproctitle.setproctitle("webapp-manager") @@ -33,6 +34,10 @@ gettext.textdomain(APP) _ = gettext.gettext +# get version +version_file = os.path.dirname(os.path.abspath(__file__))+'/VERSION' +__version__ = open(version_file, 'r').readlines()[0] + COL_ICON, COL_NAME, COL_BROWSER, COL_WEBAPP = range(4) CATEGORY_ID, CATEGORY_NAME = range(2) BROWSER_OBJ, BROWSER_NAME = range(2) @@ -248,7 +253,7 @@ def open_about(self, widget): except Exception as e: print(e) - dlg.set_version("__DEB_VERSION__") + dlg.set_version(__version__) dlg.set_icon_name("webapp-manager") dlg.set_logo_icon_name("webapp-manager") dlg.set_website("https://www.github.com/linuxmint/webapp-manager") @@ -542,7 +547,7 @@ def load_webapps(self): self.headerbar.set_subtitle(_("Run websites as if they were apps")) -if __name__ == "__main__": +def main(): + """The application's entry point.""" application = MyApplication("org.x.webapp-manager", Gio.ApplicationFlags.FLAGS_NONE) - application.run() - + return application.run(sys.argv) diff --git a/src/WebappManager/meson.build b/src/WebappManager/meson.build new file mode 100644 index 0000000..839a3ab --- /dev/null +++ b/src/WebappManager/meson.build @@ -0,0 +1,17 @@ +python_sources = files('common.py', 'main.py') + +verconf= configuration_data() +verconf.set('version', meson.project_version()) +version_file = configure_file( + input: 'VERSION.in', + output: 'VERSION', + configuration: verconf, + install: true, + install_dir: pkgdatadir/'WebappManager', +) + +install_data( + python_sources, + preserve_path: true, + install_dir: pkgdatadir/'WebappManager', +) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..dfa88c8 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,17 @@ +pkgdatadir = join_paths(prefix, 'lib', application_id) +message(f'pkgdata dir: @pkgdatadir@') + +conf = configuration_data() +conf.set('PYTHON', python.full_path()) +conf.set('pkgdatadir', pkgdatadir) + +configure_file( + input: 'webapp-manager.in', + output: 'webapp-manager', + configuration: conf, + install: true, + install_dir: get_option('bindir'), + install_mode: 'rwxr-xr-x' +) + +subdir('WebappManager') diff --git a/src/webapp-manager.in b/src/webapp-manager.in new file mode 100644 index 0000000..ca80a6f --- /dev/null +++ b/src/webapp-manager.in @@ -0,0 +1,30 @@ +#!@PYTHON@ + +# webapp-manager.in +# +# Copyright 2024 Linux Mint +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# SPDX-License-Identifier: GPL-3.0-or-later + +import re +import sys + +sys.path.insert(1, '@pkgdatadir@') + +from WebappManager.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/test b/test index b14a952..1d4e794 100755 --- a/test +++ b/test @@ -1,5 +1,9 @@ #!/bin/bash -sudo rm -rf /usr/lib/webapp-manager -sudo rm -rf /usr/share/webapp-manager -sudo cp -R usr / +rm -rf builddir +meson setup -Dprefix=$HOME/.local builddir +meson compile -C builddir --verbose +meson install -C builddir # --dry-run # with dry-run files are not acutally installed webapp-manager + +# To remove installed files uncomment below line +# ninja uninstall -C builddir diff --git a/usr/bin/webapp-manager b/usr/bin/webapp-manager deleted file mode 100755 index 144e87c..0000000 --- a/usr/bin/webapp-manager +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -/usr/lib/webapp-manager/webapp-manager.py &