Skip to content

Commit

Permalink
Create an interim desktop-launch to execute the command-chain in the kf6
Browse files Browse the repository at this point in the history
runtime. Following the gnome way.
  • Loading branch information
ScarlettGatelyMoore committed Oct 10, 2024
1 parent 696ef98 commit c5d0705
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 8 deletions.
13 changes: 13 additions & 0 deletions extensions/desktop/command-chain-kde/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/make -f

BIN_DIR := $(DESTDIR)/snap/command-chain
GPU_WRAPPER :=

scripts = hooks-configure-fonts desktop-launch run $(GPU_WRAPPER)

*:
install -D -m755 "$@" "$(BIN_DIR)"/"$@"

install: $(scripts)

.PHONY: $(scripts)
5 changes: 5 additions & 0 deletions extensions/desktop/command-chain-kde/desktop-launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -- "${SNAP}/kf6/command-chain/desktop-launch6" "$@"
# shellcheck source=/dev/null
source "${SNAP}/snap/command-chain/run"
5 changes: 5 additions & 0 deletions extensions/desktop/command-chain-kde/gpu-2404-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -- "${SNAP}/gpu-2404/bin/gpu-2404-provider-wrapper" "$@"
# shellcheck source=/dev/null
source "${SNAP}/snap/command-chain/run"
5 changes: 5 additions & 0 deletions extensions/desktop/command-chain-kde/hooks-configure-fonts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -- "${SNAP}/kf6/command-chain/hooks-configure-fonts" "$@"
# shellcheck source=/dev/null
source "${SNAP}/snap/command-chain/run"
25 changes: 25 additions & 0 deletions extensions/desktop/command-chain-kde/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "run <command>"
exit 1
fi

if [ -z "${SNAP}" ]; then
echo "Not running inside a snap context: SNAP not declared"
exit
fi


if [ ! -f "$1" ]; then
echo "Content snap command-chain for $1 not found: ensure slot is connected"
exit
fi

# emulate "exec $@" using "source"
# have to disable "unused variables" because checkshell doesn't know that $BASH_ARGV0 is $0
# shellcheck disable=SC2034 # Unused variables left for readability
BASH_ARGV0=$1
shift
# shellcheck source=/dev/null
source "$0"
4 changes: 2 additions & 2 deletions snapcraft/extensions/kde_neon_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def is_experimental(base: Optional[str]) -> bool:

@overrides
def get_app_snippet(self) -> Dict[str, Any]:
command_chain = ["snap/command-chain/desktop-launch6"]
command_chain = ["snap/command-chain/desktop-launch"]
if self.yaml_data["base"] == "core24":
command_chain.insert(0, "snap/command-chain/gpu-2404-wrapper")
return {
Expand Down Expand Up @@ -352,7 +352,7 @@ def get_parts_snippet(self) -> Dict[str, Any]:
# We can change this to the lightweight command-chain when
# the content snap includes the desktop-launch from
# https://github.com/canonical/snapcraft-desktop-integration
source = get_extensions_data_dir() / "desktop" / "kde-neon-6"
source = get_extensions_data_dir() / "desktop" / "command-chain-kde"

gpu_opts = {}
if self.yaml_data["base"] == "core24":
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/extensions/test_kde_neon_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_is_experimental():

def test_get_app_snippet(kde_neon_6_extension):
assert kde_neon_6_extension.get_app_snippet() == {
"command-chain": ["snap/command-chain/desktop-launch6"],
"command-chain": ["snap/command-chain/desktop-launch"],
"plugs": [
"desktop",
"desktop-legacy",
Expand All @@ -153,7 +153,7 @@ def test_get_app_snippet_core24(kde_neon_6_extension_core24):
assert kde_neon_6_extension_core24.get_app_snippet() == {
"command-chain": [
"snap/command-chain/gpu-2404-wrapper",
"snap/command-chain/desktop-launch6",
"snap/command-chain/desktop-launch",
],
"plugs": [
"desktop",
Expand Down Expand Up @@ -705,7 +705,7 @@ def assert_get_part_snippet(kde_neon_6_instance):


def test_get_parts_snippet(kde_neon_6_extension):
source = get_extensions_data_dir() / "desktop" / "kde-neon-6"
source = get_extensions_data_dir() / "desktop" / "command-chain-kde"

assert kde_neon_6_extension.get_parts_snippet() == {
"kde-neon-6/sdk": {
Expand All @@ -729,7 +729,7 @@ def test_get_parts_snippet(kde_neon_6_extension):


def test_get_parts_snippet_core24(kde_neon_6_extension_core24):
source = get_extensions_data_dir() / "desktop" / "kde-neon-6"
source = get_extensions_data_dir() / "desktop" / "command-chain-kde"

assert kde_neon_6_extension_core24.get_parts_snippet() == {
"kde-neon-6/sdk": {
Expand All @@ -755,7 +755,7 @@ def test_get_parts_snippet_core24(kde_neon_6_extension_core24):


def test_get_parts_snippet_with_external_sdk(kde_neon_6_extension_with_build_snap):
source = get_extensions_data_dir() / "desktop" / "kde-neon-6"
source = get_extensions_data_dir() / "desktop" / "command-chain-kde"

assert kde_neon_6_extension_with_build_snap.get_parts_snippet() == {
"kde-neon-6/sdk": {
Expand All @@ -769,7 +769,7 @@ def test_get_parts_snippet_with_external_sdk(kde_neon_6_extension_with_build_sna
def test_get_parts_snippet_with_external_sdk_different_channel(
kde_neon_6_extension_with_default_build_snap_from_latest_edge_core24,
):
source = get_extensions_data_dir() / "desktop" / "kde-neon-6"
source = get_extensions_data_dir() / "desktop" / "command-chain-kde"
assert kde_neon_6_extension_with_default_build_snap_from_latest_edge_core24.get_parts_snippet() == {
"kde-neon-6/sdk": {
"source": str(source),
Expand Down

0 comments on commit c5d0705

Please sign in to comment.