Adding icons, desktop file and appdata xml

This commit adds the desktop files that flatpak expects for a proper
desktop integration according to the FreeDesktop specs.

Signed-off-by: David Cassany <dcassany@suse.com>
This commit is contained in:
David Cassany
2021-09-22 17:37:58 +02:00
parent cf0150272e
commit 68697abf14
13 changed files with 68 additions and 8 deletions

4
.gitignore vendored
View File

@@ -1,7 +1,9 @@
/node_modules/
.DS_Store
/resources/darwin/
/resources/linux/
/resources/linux/*
!/resources/linux/misc/*.in
!/resources/linux/misc/*.desktop
/resources/win32/
/coverage/
/dist/**

View File

@@ -7,6 +7,7 @@ extraResources:
- resources/
- '!resources/darwin/lima-*.tgz'
- '!resources/linux/lima-*.tar.gz'
- '!resources/linux/misc/*.in'
files:
- dist/app/**/*
mac:
@@ -26,6 +27,7 @@ win:
signingHashAlgorithms: [ sha256 ] # We only support Windows 10 + WSL2
requestedExecutionLevel: asInvoker # The _app_ doesn't need privileges
linux:
category: Utility
executableName: rancher-desktop
target: [ flatpak, zip ]
nsis:
@@ -44,6 +46,7 @@ flatpak:
runtimeVersion: "21.08"
sdk: org.freedesktop.Sdk
branch: main
useWaylandFlags: true
finishArgs:
- --filesystem=xdg-config/rancher-desktop:create
- --filesystem=xdg-cache/rancher-desktop:create
@@ -57,6 +60,10 @@ flatpak:
- --socket=wayland
- --share=network
- --talk-name=org.freedesktop.Notifications # Is it really needed?
files:
- ["dist/linux-unpacked/resources/resources/linux/misc/io.rancherdesktop.app.appdata.xml", "/share/metainfo/io.rancherdesktop.app.appdata.xml"]
- ["dist/linux-unpacked/resources/resources/linux/misc/io.rancherdesktop.app.desktop", "/share/applications/io.rancherdesktop.app.desktop"]
- ["dist/linux-unpacked/resources/resources/icons/linux", "/share/icons/hicolor"]
modules:
- name: qemu
config-opts:

View File

@@ -8,7 +8,7 @@ base: org.electronjs.Electron2.BaseApp
base-version: '21.08'
sdk-extensions:
- org.freedesktop.Sdk.Extension.node14
command: run.sh
command: electron-wrapper
separate-locales: false
finish-args:
- --share=ipc
@@ -26,20 +26,33 @@ finish-args:
modules:
- name: rancher-desktop
buildsystem: simple
subdir: main
subdir: lib
sources:
- type: dir
path: ..
dest: main
dest: lib
- type: script
dest-filename: run.sh
dest-filename: electron-wrapper
commands:
- zypak-wrapper.sh /app/main/rancher-desktop "$@"
- |
export TMPDIR="$XDG_RUNTIME_DIR/app/$FLATPAK_ID"
if [ "${XDG_SESSION_TYPE}" == "wayland" ]; then
zypak-wrapper /app/lib/io.rancherdesktop.app/rancher-desktop --enable-features=UseOzonePlatform --ozone-platform=wayland "$@"
else
zypak-wrapper.sh /app/lib/io.rancherdesktop.app/rancher-desktop "$@"
fi
build-commands:
# Bundle electron build after npm run build -- --linux --publish=never
- cp -a dist/linux*unpacked /app/main
- cp -a dist/linux*unpacked /app/lib/io.rancherdesktop.app
# Include FreeDesktop integration files at expected locations
- rm -rf /app/share/metainfo /app/share/icons /app/share/applications
- mkdir -p /app/share/metainfo /app/share/icons /app/share/applications
- cp /app/lib/io.rancherdesktop.app/resources/resources/linux/misc/io.rancherdesktop.app.appdata.xml /app/share/metainfo
- cp /app/lib/io.rancherdesktop.app/resources/resources/linux/misc/io.rancherdesktop.app.desktop /app/share/applications
- cp -r /app/lib/io.rancherdesktop.app/resources/resources/icons/linux /app/share/icons/hicolor
# Install app wrapper
- install -Dm755 -t /app/bin/ ../run.sh
- install -Dm755 -t /app/bin/ ../electron-wrapper
modules:
- name: qemu
config-opts:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>io.rancherdesktop.app.desktop</id>
<metadata_license>Apache-2.0</metadata_license>
<project_license>Apache-2.0</project_license>
<name>Rancher Desktop</name>
<summary>Kubernetes and container management on the desktop</summary>
<description>
<p>
Rancher Desktop is an open-source project to bring Kubernetes and container management to the desktop
</p>
</description>
<provides>
<binary>rancher-desktop</binary>
</provides>
<releases>
<release version="" date=""/>
</releases>
<url type="homepage">https://rancherdesktop.io/</url>
<url type="bugtracker">https://github.com/rancher-sandbox/rancher-desktop/issues</url>
</component>

View File

@@ -0,0 +1,7 @@
[Desktop Entry]
Name=Rancher Desktop
Exec=electron-wrapper
Type=Application
Icon=io.rancherdesktop.app
Categories=Utility;
Terminal=true

View File

@@ -61,6 +61,13 @@ class Builder {
await buildUtils.buildMain();
}
async replaceInFile(srcFile, pattern, replacement, dstFile = undefined) {
dstFile = dstFile || srcFile;
await fs.stat(srcFile);
const data = await fs.readFile(srcFile, 'utf8');
await fs.writeFile(dstFile, data.replace(pattern, replacement));
}
async package() {
console.log('Packaging...');
const args = process.argv.slice(2).filter(x => x !== '--serial');
@@ -73,7 +80,10 @@ class Builder {
const env = { ...process.env, __COMPAT_LAYER: 'RunAsInvoker' };
const fullBuildVersion = childProcess.execFileSync('git', ['describe', '--tags']).toString().trim();
const finalBuildVersion = fullBuildVersion.replace(/^v/, '');
const appData = 'resources/linux/misc/io.rancherdesktop.app.appdata.xml';
const release = `<release version="${finalBuildVersion}" date="${new Date().toISOString()}"/>`;
await this.replaceInFile(appData + '.in', /<release.*\/>/g, release, appData);
args.push(`-c.extraMetadata.version=${ finalBuildVersion }`);
await buildUtils.spawn('node', 'node_modules/electron-builder/out/cli/cli.js', ...args, { env });
}