feat: add flatpak application

Change-Id: I4c6dce9eacbd81855fefb314baecb7213b7fcc56
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
Florent Benoit 2022-05-03 09:31:23 +02:00 committed by Florent BENOIT
parent 21fc9b4f5c
commit 037518067a
6 changed files with 72 additions and 5 deletions

View file

@ -45,9 +45,33 @@ const config = {
win: {
target: ['portable', 'nsis'],
},
flatpak: {
license: 'LICENSE',
finishArgs: [
// allow to execute commands remotely
'--socket=session-bus',
'--socket=wayland',
'--socket=x11',
'--share=ipc',
// Open GL
'--device=dri',
// Read/write home directory access
'--filesystem=home',
// Read podman socket
'--filesystem=xdg-run/podman',
// Allow communication with network
'--share=network',
// System notifications with libnotify
'--talk-name=org.freedesktop.Notifications',
],
useWaylandFlags: 'true',
artifactName: 'podman-desktop-${version}.${ext}',
runtimeVersion: '21.08',
branch: 'main',
},
linux: {
target: ['tar.gz'],
icon: './buildResources/icon-512x512.png',
target: ['flatpak', 'tar.gz'],
},
afterSign: 'electron-builder-notarize',
mac: {

View file

@ -105,6 +105,15 @@ jobs:
run: |
yarn --frozen-lockfile --network-timeout 180000
- name: Install flatpak on Linux
if: ${{ matrix.os=='ubuntu-20.04' }}
run: |
sudo apt-get install flatpak -y
sudo apt-get install flatpak-builder -y
sudo apt-get install elfutils -y
flatpak remote-add --if-not-exists flathub --user https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub --user -y org.freedesktop.Platform/x86_64/21.08
- name: Set macOS environment variables
if: ${{ matrix.os=='macos-11' }}
run: |

View file

@ -90,6 +90,14 @@ jobs:
- name: Execute yarn
run: yarn --frozen-lockfile --network-timeout 180000
- name: Install flatpak
run: |
sudo apt-get install flatpak -y
sudo apt-get install flatpak-builder -y
sudo apt-get install elfutils -y
flatpak remote-add --if-not-exists flathub --user https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub --user -y org.freedesktop.Platform/x86_64/21.08
- name: Run Build
timeout-minutes: 20
run: yarn compile:pull-request
@ -102,6 +110,11 @@ jobs:
name: linux
path: ./dist/podman-desktop-*.tar.gz
- uses: actions/upload-artifact@v3
with:
name: flatpak
path: ./dist/podman-desktop-*.flatpak
darwin:
name: macOS
runs-on: macos-11

View file

@ -103,6 +103,15 @@ jobs:
run: |
yarn --frozen-lockfile --network-timeout 180000
- name: Install flatpak on Linux
if: ${{ matrix.os=='ubuntu-20.04' }}
run: |
sudo apt-get install flatpak -y
sudo apt-get install flatpak-builder -y
sudo apt-get install elfutils -y
flatpak remote-add --if-not-exists flathub --user https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub --user -y org.freedesktop.Platform/x86_64/21.08
- name: Set macOS environment variables
if: ${{ matrix.os=='macos-11' }}
run: |

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

View file

@ -210,11 +210,15 @@ async function registerProviderFor(provider: extensionApi.Provider, machineInfo:
storedExtensionContext.subscriptions.push(disposable);
}
function execPromise(command, args?: string[], logger?: extensionApi.Logger): Promise<string> {
function execPromise(command: string, args?: string[], logger?: extensionApi.Logger): Promise<string> {
const env = process.env;
// In production mode, applications don't have access to the 'user' path like brew
if (isMac) {
env.PATH = env.PATH.concat(':/usr/local/bin').concat(':/opt/homebrew/bin');
} else if (env.FLATPAK_ID) {
// need to execute the command on the host
args = ['--host', command, ...args];
command = 'flatpak-spawn';
}
return new Promise((resolve, reject) => {
let output = '';
@ -294,10 +298,18 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
monitorMachines(provider);
} else if (isLinux) {
// on Linux, need to run the system service for unlimited time
const process = spawn('podman', ['system', 'service', '--time=0']);
let command = 'podman';
let args = ['system', 'service', '--time=0'];
const env = process.env;
if (env.FLATPAK_ID) {
// need to execute the command on the host
command = 'flatpak-spawn';
args = ['--host', 'podman', ...args];
}
const podmanProcess = spawn(command, args);
await timeout(500);
const disposable = extensionApi.Disposable.create(() => {
process.kill();
podmanProcess.kill();
});
extensionContext.subscriptions.push(disposable);
initDefaultLinux(provider);