Skip to content

Commit ba07efe

Browse files
committed
Prepare porting to meson buildsytem
- Setup meson to install python sources during meson builds - Install executable binary using meson - Update debian builds to use meson - Update testing script
1 parent 1418210 commit ba07efe

18 files changed

+238
-29
lines changed

data/meson.build

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
app_icon_dir = join_paths(datadir, 'icons', 'hicolor', 'scalable', 'apps')
2+
category_icon_dir = join_paths(datadir, 'icons', 'hicolor', 'scalable', 'categories')
3+
schema_dir = join_paths(datadir, 'glib-2.0', 'schemas')
4+
# message(f'Icon dir: @app_icon_dir@')
5+
# message(f'Schema dir: @schema_dir@')
6+
7+
# install icons
8+
install_emptydir(app_icon_dir)
9+
install_data(
10+
join_paths(meson.current_source_dir(), 'icons', f'@[email protected]'),
11+
install_dir: app_icon_dir,
12+
)
13+
14+
install_data(
15+
join_paths(meson.current_source_dir(), 'icons/categories/applications-webapps.svg'),
16+
install_dir: category_icon_dir,
17+
)
18+
19+
20+
# Install desktop file
21+
# desktop_file = i18n.merge_file(
22+
# input: 'webapp-manager.desktop.in',
23+
# output: 'webapp-manager.desktop',
24+
# type: 'desktop',
25+
# po_dir: '../po',
26+
# install: true,
27+
# install_dir: desktop_dir
28+
# )
29+
30+
# Install schema file
31+
schema_file = i18n.merge_file(
32+
input: 'org.x.webapp-manager.gschema.xml.in',
33+
output: 'org.x.webapp-manager.gschema.xml',
34+
type: 'xml',
35+
po_dir: '../po',
36+
install: true,
37+
install_dir: schema_dir
38+
)
39+
40+
compile_schemas = find_program('glib-compile-schemas', required: false)
41+
if compile_schemas.found()
42+
test('Validate schema file',
43+
compile_schemas,
44+
args: ['--strict', '--dry-run', meson.current_source_dir()])
45+
endif

debian/compat

-1
This file was deleted.

debian/control

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ Source: webapp-manager
22
Section: admin
33
Priority: optional
44
Maintainer: Linux Mint <[email protected]>
5-
Build-Depends: debhelper (>= 9)
6-
Standards-Version: 3.9.5
5+
Build-Depends: debhelper-compat (= 13),
6+
desktop-file-utils,
7+
dh-python,
8+
libglib2.0-bin,
9+
libgtk-4-bin,
10+
meson (>= 1.3.0),
11+
pkg-config,
12+
python3-all,
13+
Standards-Version: 4.6.1
714

815
Package: webapp-manager
916
Architecture: all
@@ -15,7 +22,8 @@ Depends: gir1.2-xapp-1.0 (>= 1.4),
1522
python3-pil,
1623
python3-setproctitle,
1724
python3-tldextract,
18-
xapps-common,
19-
${misc:Depends},
25+
xapps-common,,
26+
${python3:Depends},
27+
${misc:Depends}
2028
Description: Web Application Manager
2129
Launch websites as if they were apps.

debian/postinst

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
#!/bin/sh
2+
# postinst script for webapp-manager
3+
#
4+
# see: dh_installdeb(1)
5+
26
set -e
37

8+
49
case "$1" in
510
configure)
6-
if which glib-compile-schemas >/dev/null 2>&1
7-
then
8-
glib-compile-schemas /usr/share/glib-2.0/schemas
9-
fi
11+
if which glib-compile-schemas >/dev/null 2>&1
12+
then
13+
glib-compile-schemas /usr/share/glib-2.0/schemas
14+
fi
15+
if which gtk4-update-icon-cache >/dev/null 2>&1
16+
then
17+
gtk4-update-icon-cache -q -t -f /usr/share/icons/hicolor
18+
fi
1019
;;
1120

1221
abort-upgrade|abort-remove|abort-deconfigure)
13-
1422
;;
1523

1624
*)
1725
echo "postinst called with unknown argument \`$1'" >&2
1826
exit 1
1927
;;
2028
esac
29+
30+
# dh_installdeb will replace this with shell code automatically
31+
# generated by other debhelper scripts.
32+
33+
#DEBHELPER#
34+
35+
exit 0

debian/postrm

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
# postrm script for webapp-manager
3+
#
4+
# see: dh_installdeb(1)
5+
6+
set -e
7+
8+
9+
case "$1" in
10+
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
11+
if which glib-compile-schemas >/dev/null 2>&1
12+
then
13+
glib-compile-schemas /usr/share/glib-2.0/schemas
14+
fi
15+
if which gtk4-update-icon-cache >/dev/null 2>&1
16+
then
17+
gtk4-update-icon-cache -q -t -f /usr/share/icons/hicolor
18+
fi
19+
;;
20+
21+
*)
22+
echo "postrm called with unknown argument \`$1'" >&2
23+
exit 1
24+
;;
25+
esac
26+
27+
# dh_installdeb will replace this with shell code automatically
28+
# generated by other debhelper scripts.
29+
30+
#DEBHELPER#
31+
32+
exit 0

debian/rules

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
#!/usr/bin/make -f
2+
# See debhelper(7) (uncomment to enable)
3+
# output every command that modifies files on the build system.
4+
# export DH_VERBOSE = 1
25

3-
DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
6+
export PYBUILD_NAME=webapp-manager
7+
export PYBUILD_SYSTEM=pyproject
8+
9+
# DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
410

511
%:
6-
dh ${@}
7-
8-
# Inject version number in the code
9-
override_dh_installdeb:
10-
dh_installdeb
11-
for pkg in $$(dh_listpackages -i); do \
12-
find debian/$$pkg -type f -exec sed -i -e s/__DEB_VERSION__/$(DEB_VERSION)/g {} +; \
13-
done
12+
dh ${@} --with=python3 --buildsystem=meson
13+
14+
# # Inject version number in the code
15+
# override_dh_installdeb:
16+
# dh_installdeb
17+
# for pkg in $$(dh_listpackages -i); do \
18+
# find debian/$$pkg -type f -exec sed -i -e s/__DEB_VERSION__/$(DEB_VERSION)/g {} +; \
19+
# done
20+
21+
override_dh_auto_build:
22+
dh_auto_build -O--buildsystem=meson
23+
make -j8

meson.build

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
project('webapp-manager',
2+
version: run_command('head', '-1', 'debian/changelog', check: true).stdout().split(' ')[1].strip('(').strip(')'),
3+
license: ['GPL3'],
4+
meson_version: '>= 1.3.0',
5+
default_options: ['warning_level=3',
6+
'prefix=/usr',
7+
]
8+
)
9+
10+
application_id = meson.project_name()
11+
i18n = import('i18n')
12+
gnome = import('gnome')
13+
pymod = import('python')
14+
python = pymod.find_installation('python3')
15+
16+
prefix = get_option('prefix')
17+
bindir = get_option('bindir')
18+
datadir = get_option('datadir')
19+
20+
subdir('src')
21+
subdir('data')
22+
# subdir('po')
23+
24+
gnome.post_install(
25+
glib_compile_schemas: true,
26+
gtk_update_icon_cache: true,
27+
update_desktop_database: true,
28+
)

src/WebappManager/VERSION.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@version@
File renamed without changes.

usr/lib/webapp-manager/webapp-manager.py renamed to src/WebappManager/main.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import shutil
88
import subprocess
9+
import sys
910
import warnings
1011

1112
# 2. Related third party imports.
@@ -21,7 +22,7 @@
2122
from gi.repository import Gtk, Gdk, Gio, XApp, GdkPixbuf
2223

2324
# 3. Local application/library specific imports.
24-
from common import _async, idle, WebAppManager, download_favicon, ICONS_DIR, BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP
25+
from WebappManager.common import _async, idle, WebAppManager, download_favicon, ICONS_DIR, BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP
2526

2627
setproctitle.setproctitle("webapp-manager")
2728

@@ -33,6 +34,10 @@
3334
gettext.textdomain(APP)
3435
_ = gettext.gettext
3536

37+
# get version
38+
version_file = os.path.dirname(os.path.abspath(__file__))+'/VERSION'
39+
__version__ = open(version_file, 'r').readlines()[0]
40+
3641
COL_ICON, COL_NAME, COL_BROWSER, COL_WEBAPP = range(4)
3742
CATEGORY_ID, CATEGORY_NAME = range(2)
3843
BROWSER_OBJ, BROWSER_NAME = range(2)
@@ -248,7 +253,7 @@ def open_about(self, widget):
248253
except Exception as e:
249254
print(e)
250255

251-
dlg.set_version("__DEB_VERSION__")
256+
dlg.set_version(__version__)
252257
dlg.set_icon_name("webapp-manager")
253258
dlg.set_logo_icon_name("webapp-manager")
254259
dlg.set_website("https://www.github.com/linuxmint/webapp-manager")
@@ -542,7 +547,7 @@ def load_webapps(self):
542547
self.headerbar.set_subtitle(_("Run websites as if they were apps"))
543548

544549

545-
if __name__ == "__main__":
550+
def main():
551+
"""The application's entry point."""
546552
application = MyApplication("org.x.webapp-manager", Gio.ApplicationFlags.FLAGS_NONE)
547-
application.run()
548-
553+
return application.run(sys.argv)

src/WebappManager/meson.build

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
python_sources = files('common.py', 'main.py')
2+
3+
verconf= configuration_data()
4+
verconf.set('version', meson.project_version())
5+
version_file = configure_file(
6+
input: 'VERSION.in',
7+
output: 'VERSION',
8+
configuration: verconf,
9+
install: true,
10+
install_dir: pkgdatadir/'WebappManager',
11+
)
12+
13+
install_data(
14+
python_sources,
15+
preserve_path: true,
16+
install_dir: pkgdatadir/'WebappManager',
17+
)

src/meson.build

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pkgdatadir = join_paths(prefix, 'lib', application_id)
2+
message(f'pkgdata dir: @pkgdatadir@')
3+
4+
conf = configuration_data()
5+
conf.set('PYTHON', python.full_path())
6+
conf.set('pkgdatadir', pkgdatadir)
7+
8+
configure_file(
9+
input: 'webapp-manager.in',
10+
output: 'webapp-manager',
11+
configuration: conf,
12+
install: true,
13+
install_dir: get_option('bindir'),
14+
install_mode: 'rwxr-xr-x'
15+
)
16+
17+
subdir('WebappManager')

src/webapp-manager.in

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!@PYTHON@
2+
3+
# webapp-manager.in
4+
#
5+
# Copyright 2024 Linux Mint
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
# SPDX-License-Identifier: GPL-3.0-or-later
21+
22+
import re
23+
import sys
24+
25+
sys.path.insert(1, '@pkgdatadir@')
26+
27+
from WebappManager.main import main
28+
if __name__ == '__main__':
29+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
30+
sys.exit(main())

test

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
2-
sudo rm -rf /usr/lib/webapp-manager
3-
sudo rm -rf /usr/share/webapp-manager
4-
sudo cp -R usr /
2+
rm -rf builddir
3+
meson setup -Dprefix=$HOME/.local builddir
4+
meson compile -C builddir --verbose
5+
meson install -C builddir # --dry-run # with dry-run files are not acutally installed
56
webapp-manager
7+
8+
# To remove installed files uncomment below line
9+
# ninja uninstall -C builddir

usr/bin/webapp-manager

-2
This file was deleted.

0 commit comments

Comments
 (0)