[neon/snap-packaging/snapcraft-desktop-integration] kde-neon-6: Move our launchers / env here so we have more control.

Scarlett Moore null at kde.org
Thu Jun 27 19:15:33 BST 2024


Git commit 71f4a580a6803c1f0af397b027566d30aa76e8d4 by Scarlett Moore.
Committed on 27/06/2024 at 18:14.
Pushed by scarlettmoore into branch 'master'.

Move our launchers / env here so we have more control.
`

A  +34   -0    kde-neon-6/Makefile
A  +1    -0    kde-neon-6/desktop-exports
A  +1    -0    kde-neon-6/fonts
A  +1    -0    kde-neon-6/init
A  +47   -0    kde-neon-6/launcher-specific
A  +62   -0    kde-neon-6/locale-gen
A  +1    -0    kde-neon-6/mark-and-exec

https://invent.kde.org/neon/snap-packaging/snapcraft-desktop-integration/-/commit/71f4a580a6803c1f0af397b027566d30aa76e8d4

diff --git a/kde-neon-6/Makefile b/kde-neon-6/Makefile
new file mode 100644
index 0000000..be0c279
--- /dev/null
+++ b/kde-neon-6/Makefile
@@ -0,0 +1,34 @@
+#!/usr/bin/make -f
+
+SRC_DIR ?= .
+
+DATA_DIR             := $(DESTDIR)/data-dir
+BIN_DIR              := $(DESTDIR)/snap/command-chain
+LIB_DIR              := $(DESTDIR)/lib
+DEST_LAUNCHER        := desktop-launch6
+LOCALE_GENERATOR     := locale-gen
+DEST_CONFIGURE_HOOK  := hooks-configure-desktop
+
+build: $(DEST_LAUNCHER) $(DEST_CONFIGURE_HOOK)
+
+clean:
+	rm -f $(DEST_LAUNCHER)
+	rm -f $(DEST_CONFIGURE_HOOK)
+	rm -f $(BINDTEXTDOMAIN)
+
+$(DEST_LAUNCHER):
+	@cat $(SRC_DIR)/init > $(DEST_LAUNCHER)
+  # tail -n +2 to remove the shebang
+	@tail -n +2 $(SRC_DIR)/desktop-exports | sed -e "s/%PLATFORM_PLUG%/$${PLATFORM_PLUG:?}/" >> $(DEST_LAUNCHER)
+	@tail -n +2 $(SRC_DIR)/launcher-specific >> $(DEST_LAUNCHER)
+	@tail -n +2 $(SRC_DIR)/mark-and-exec >> $(DEST_LAUNCHER)
+
+$(DEST_CONFIGURE_HOOK):
+	@cat $(SRC_DIR)/fonts > $(DEST_CONFIGURE_HOOK)
+
+install: $(DEST_LAUNCHER) $(DEST_CONFIGURE_HOOK)
+	install -d $(DATA_DIR)
+	install -d $(DATA_DIR)/kf6
+	install -D -m755 $(DEST_LAUNCHER) "$(BIN_DIR)"/$(DEST_LAUNCHER)
+	install -D -m755 $(LOCALE_GENERATOR) "$(BIN_DIR)"/$(LOCALE_GENERATOR)
+	install -D -m755 $(DEST_CONFIGURE_HOOK) "$(BIN_DIR)"/$(DEST_CONFIGURE_HOOK)
diff --git a/kde-neon-6/desktop-exports b/kde-neon-6/desktop-exports
new file mode 120000
index 0000000..8013267
--- /dev/null
+++ b/kde-neon-6/desktop-exports
@@ -0,0 +1 @@
+../common/desktop-exports
\ No newline at end of file
diff --git a/kde-neon-6/fonts b/kde-neon-6/fonts
new file mode 120000
index 0000000..3ef54f4
--- /dev/null
+++ b/kde-neon-6/fonts
@@ -0,0 +1 @@
+../common/fonts
\ No newline at end of file
diff --git a/kde-neon-6/init b/kde-neon-6/init
new file mode 120000
index 0000000..350b7be
--- /dev/null
+++ b/kde-neon-6/init
@@ -0,0 +1 @@
+../common/init
\ No newline at end of file
diff --git a/kde-neon-6/launcher-specific b/kde-neon-6/launcher-specific
new file mode 100644
index 0000000..736c290
--- /dev/null
+++ b/kde-neon-6/launcher-specific
@@ -0,0 +1,47 @@
+#!/bin/bash
+###################################
+# KDE NEON launcher specific part #
+###################################
+
+# Add paths for games
+append_dir PATH "$SNAP/usr/games"
+append_dir PATH "$SNAP_DESKTOP_RUNTIME/usr/games"
+
+# Qt Libs
+prepend_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH"
+
+# Add QT_PLUGIN_PATH (Qt Modules).
+append_dir QT_PLUGIN_PATH "$SNAP/usr/lib/$ARCH/qt6/plugins"
+append_dir QT_PLUGIN_PATH "$SNAP/usr/lib/$ARCH"
+append_dir QT_PLUGIN_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/qt6/plugins"
+append_dir QT_PLUGIN_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/"
+# And QML2_IMPORT_PATH (Qt Modules).
+append_dir QML2_IMPORT_PATH "$SNAP/usr/lib/$ARCH/qt6/qml"
+append_dir QML2_IMPORT_PATH "$SNAP/lib/$ARCH"
+append_dir QML2_IMPORT_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/qt6/qml"
+append_dir QML2_IMPORT_PATH "$SNAP_DESKTOP_RUNTIME/lib/$ARCH"
+
+# Fix locating the QtWebEngineProcess executable
+export QTWEBENGINEPROCESS_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/qt6/libexec/QtWebEngineProcess"
+
+# Removes Qt warning: Could not find a location
+# of the system Compose files
+export QTCOMPOSE="$SNAP_DESKTOP_RUNTIME/usr/share/X11/locale"
+export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb"
+
+# KIO specific
+# Directly fork slaves.
+export KDE_FORK_SLAVES=1
+# Path to KIO slaves.
+export KF6_LIBEXEC_DIR="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/libexec/kf6"
+
+# Add path to VLC plugins
+export VLC_PLUGIN_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/vlc/plugins"
+
+if [ -e "$SNAP_DESKTOP_RUNTIME/usr/share/i18n" ]; then
+    export I18NPATH="$SNAP_DESKTOP_RUNTIME/usr/share/i18n"
+    locpath="$XDG_DATA_HOME/locale"
+    ensure_dir_exists "$locpath"
+    export LOCPATH="$locpath:/usr/lib/locale"
+    LC_ALL=C.UTF-8 async_exec "$SNAP/snap/command-chain/locale-gen"
+fi
diff --git a/kde-neon-6/locale-gen b/kde-neon-6/locale-gen
new file mode 100755
index 0000000..2c8b605
--- /dev/null
+++ b/kde-neon-6/locale-gen
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+
+use strict;
+
+sub uniq
+{
+    my %seen;
+    grep !$seen{$_}++, @_;
+}
+
+# TODO support for KDE's in-app language switch feature.
+sub get_languages
+{
+    # Initialize with sane defaults.
+    my @found_languages = ($ENV{'LANG'} or 'C.UTF-8');
+
+    # Go through LC_.
+    foreach (sort keys %ENV)
+    {
+        if (substr($_, 0, length("LC_")) eq "LC_")
+        {
+            push(@found_languages, $ENV{$_});
+        }
+    }
+    # And finally LANGUAGE, but normalize it.
+    if (my $language = $ENV{'LANGUAGE'})
+    {
+        foreach (split(':', $language))
+        {
+            push(@found_languages, "$_.UTF-8");
+        }
+    }
+
+    # Remove duplicates before returning.
+    @found_languages = uniq(@found_languages);
+
+    return @found_languages
+}
+
+my $env_locpath = $ENV{'LOCPATH'} or die "LOCPATH must be set";
+my @locpaths = split(/:/, $env_locpath);
+
+foreach my $lang (get_languages())
+{
+    my $found = 0;
+    foreach my $locpath (@locpaths)
+    {
+        my $loc_target = "$locpath/$lang";
+        if (-e $loc_target)
+        {
+            $found = 1;
+            last;
+        }
+    }
+    next if $found;
+    my $target = "@locpaths[0]/$lang";
+
+    # localedef will exit !0 for unknown reasons, even when everything was
+    # generated fine.
+    my ($locale, $encoding) = split(/\./, $lang);
+    system('localedef', '-i', $locale, '-f', $encoding, $target);
+}
diff --git a/kde-neon-6/mark-and-exec b/kde-neon-6/mark-and-exec
new file mode 120000
index 0000000..1bf8626
--- /dev/null
+++ b/kde-neon-6/mark-and-exec
@@ -0,0 +1 @@
+../common/mark-and-exec
\ No newline at end of file


More information about the Neon-commits mailing list