Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: snapcraft core22 and core24 support [#8548] #8549

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-toes-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix snapcraft support for core22 and core24
8 changes: 4 additions & 4 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@
},
"GenericServerOptions": {
"additionalProperties": false,
"description": "Generic (any HTTP(S) server) options.\nIn all publish options [File Macros](./file-patterns.md#file-macros) are supported.",
"description": "Generic (any HTTP(S) server) options.\nIn all publish options [File Macros](/file-patterns#file-macros) are supported.",
"properties": {
"channel": {
"default": "latest",
Expand Down Expand Up @@ -1356,7 +1356,7 @@
]
},
"private": {
"description": "Whether to use private github auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitHub Update Repo](./auto-update.md#private-github-update-repo).",
"description": "Whether to use private github auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitHub Update Repo](/auto-update#private-github-update-repo).",
"type": [
"null",
"boolean"
Expand Down Expand Up @@ -1438,7 +1438,7 @@
]
},
"token": {
"description": "The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for [setFeedURL](./auto-update.md#appupdatersetfeedurloptions).",
"description": "The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for [setFeedURL](/auto-update#appupdatersetfeedurloptions).",
"type": [
"null",
"string"
Expand Down Expand Up @@ -5396,7 +5396,7 @@
"type": "boolean"
},
"base": {
"description": "A snap of type base to be used as the execution environment for this snap. Examples: `core`, `core18`, `core20`, `core22`. Defaults to `core20`",
"description": "A snap of type base to be used as the execution environment for this snap. Examples: `core`, `core18`, `core20`, `core22`, `core24`. Defaults to `core20`",
"type": [
"null",
"string"
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/options/SnapOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CommonLinuxOptions } from "./linuxOptions"

export interface SnapOptions extends CommonLinuxOptions, TargetSpecificOptions {
/**
* A snap of type base to be used as the execution environment for this snap. Examples: `core`, `core18`, `core20`, `core22`. Defaults to `core20`
* A snap of type base to be used as the execution environment for this snap. Examples: `core`, `core18`, `core20`, `core22`, `core24`. Defaults to `core20`
*/
readonly base?: string | null

Expand Down
39 changes: 37 additions & 2 deletions packages/app-builder-lib/src/targets/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ import { Configuration } from "../configuration"

const defaultPlugs = ["desktop", "desktop-legacy", "home", "x11", "wayland", "unity7", "browser-support", "network", "gsettings", "audio-playback", "pulseaudio", "opengl"]

const defaultPlugsCore22And24 = [
"desktop",
"desktop-legacy",
"home",
"x11",
"wayland",
"unity7",
"browser-sandbox",
"network",
"gsettings",
"audio-playback",
"pulseaudio",
"opengl",
"mount-observe",
"calendar-service",
]

export default class SnapTarget extends Target {
readonly options: SnapOptions = { ...this.packager.platformSpecificBuildOptions, ...(this.packager.config as any)[this.name] }

Expand Down Expand Up @@ -51,7 +68,14 @@ export default class SnapTarget extends Target {

const plugs = normalizePlugConfiguration(this.options.plugs)

const plugNames = this.replaceDefault(plugs == null ? null : Object.getOwnPropertyNames(plugs), defaultPlugs)
let plugsToAdd = defaultPlugs //default

if (options.base != null) {
if (Number(options.base.split("core")[1]) >= 22) {
plugsToAdd = defaultPlugsCore22And24
}
}
const plugNames = this.replaceDefault(plugs == null ? null : Object.getOwnPropertyNames(plugs), plugsToAdd)

const slots = normalizePlugConfiguration(this.options.slots)

Expand All @@ -71,7 +95,18 @@ export default class SnapTarget extends Target {
adapter: "none",
}

const snap: any = load(await readFile(path.join(getTemplatePath("snap"), "snapcraft.yaml"), "utf-8"))
let snapTemplateFile = "snapcraft.yaml" // default

if (options.base != null) {
if (Number(options.base.split("core")[1]) == 22) {
snapTemplateFile = "snapcraft-core22.yaml"
}
if (Number(options.base.split("core")[1]) == 24) {
snapTemplateFile = "snapcraft-core24.yaml"
}
}

const snap: any = load(await readFile(path.join(getTemplatePath("snap"), snapTemplateFile), "utf-8"))
if (this.isUseTemplateApp) {
delete appDescriptor.adapter
}
Expand Down
147 changes: 147 additions & 0 deletions packages/app-builder-lib/templates/snap/snapcraft-core22.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
base: core22
grade: stable
confinement: strict
parts:
launch-scripts:
plugin: dump
source: scripts
gnome-platform-empty-dirs:
plugin: nil
override-build: >
mkdir -p "$SNAPCRAFT_PART_INSTALL/data-dir/themes"
mkdir -p "$SNAPCRAFT_PART_INSTALL/data-dir/icons"
mkdir -p "$SNAPCRAFT_PART_INSTALL/data-dir/sounds"
mkdir $SNAPCRAFT_PART_INSTALL/gnome-platform

app-files:
plugin: dump
source: app
organize:
'*': app/
stage:
- -app/chrome-sandbox
- -LICENSES.chromium.html
app:
plugin: "nil"
stage:
- '-usr/lib/python*'
- '-usr/bin/python*'
- '-var/lib/ucf'
- '-usr/include'
- '-usr/lib/X11'
- '-usr/share'
- '-usr/sbin'
- '-usr/bin'
- "-usr/lib/*/libicudata.*"
- "-usr/lib/*/libicui18n.*"
- "-usr/lib/*/libgtk-*"
- "-usr/lib/*/libgdk-*"
- "-usr/lib/*/glib-*"
- "-usr/lib/*/gtk-*"
- "-usr/lib/*/gdk-*"
- "-usr/lib/*/krb5"
- "-usr/lib/systemd"
- "-usr/lib/glib-networking"
- "-usr/lib/dconf"
- "-usr/lib/*/avahi"
- "-usr/lib/*/gio"
- "-usr/lib/*/libatk*"
- "-usr/lib/*/libatspi*"
- "-usr/lib/*/libavahi*"
- "-usr/lib/*/libcairo*"
- "-usr/lib/*/libcolordprivate*"
- "-usr/lib/*/libcolord*"
- "-usr/lib/*/libcroco*"
- "-usr/lib/*/libcups*"
- "-usr/lib/*/libdatrie*"
- "-usr/lib/*/libdconf*"
- "-usr/lib/*/libepoxy*"
- "-usr/lib/*/libexpatw*"
- "-usr/lib/*/libffi*"
- "-usr/lib/*/libfontconfig*"
- "-usr/lib/*/libfreetype*"
- "-usr/lib/*/libgdk_pixbuf*"
- "-usr/lib/*/libgdk_pixbuf_xlib*"
- "-usr/lib/*/libgio*"
- "-usr/lib/*/libglib*"
- "-usr/lib/*/libgmodule*"
- "-usr/lib/*/libgmp*"
- "-usr/lib/*/libgnutls*"
- "-usr/lib/*/libgobject*"
- "-usr/lib/*/libgraphite2*"
- "-usr/lib/*/libgssapi_krb5*"
- "-usr/lib/*/libgthread*"
- "-usr/lib/*/libharfbuzz*"
- "-usr/lib/*/libhogweed*"
- "-usr/lib/*/libicuio*"
- "-usr/lib/*/libicutest*"
- "-usr/lib/*/libicutu*"
- "-usr/lib/*/libicuuc*"
- "-usr/lib/*/libidn2*"
- "-usr/lib/*/libjbig*"
- "-usr/lib/*/libjpeg*"
- "-usr/lib/*/libjson*"
- "-usr/lib/*/libk5crypto*"
- "-usr/lib/*/libkrb5*"
- "-usr/lib/*/libkrb5support*"
- "-usr/lib/*/liblcms2*"
- "-usr/lib/*/libnettle*"
- "-usr/lib/*/libp11*"
- "-usr/lib/*/libpango*"
- "-usr/lib/*/libpangocairo*"
- "-usr/lib/*/libpangoft2*"
- "-usr/lib/*/libpixman*"
- "-usr/lib/*/libpng16*"
- "-usr/lib/*/libproxy*"
- "-usr/lib/*/librest*"
- "-usr/lib/*/librsvg*"
- "-usr/lib/*/libsecret*"
- "-usr/lib/*/libsoup*"
- "-usr/lib/*/libsqlite3*"
- "-usr/lib/*/libtasn1*"
- "-usr/lib/*/libthai*"
- "-usr/lib/*/libtiff*"
- "-usr/lib/*/libunistring*"
- "-usr/lib/*/libwayland*"
- "-usr/lib/*/libX11*"
- "-usr/lib/*/libXau*"
- "-usr/lib/*/libxcb.so*"
- "-usr/lib/*/libxcb-dri2*"
- "-usr/lib/*/libxcb-dri3*"
- "-usr/lib/*/libxcb-glx*"
- "-usr/lib/*/libxcb-present*"
- "-usr/lib/*/libxcb-render*"
- "-usr/lib/*/libxcb-shm*"
- "-usr/lib/*/libxcb-sync*"
- "-usr/lib/*/libxcb-xfixes*"
- "-usr/lib/*/libXcomposite*"
- "-usr/lib/*/libXcursor*"
- "-usr/lib/*/libXdamage*"
- "-usr/lib/*/libXdmcp*"
- "-usr/lib/*/libXext*"
- "-usr/lib/*/libXfixes*"
- "-usr/lib/*/libXinerama*"
- "-usr/lib/*/libXi*"
- "-usr/lib/*/libxkbcommon*"
- "-usr/lib/*/libxml2*"
- "-usr/lib/*/libXrandr*"
- "-usr/lib/*/libXrender*"
plugs:
desktop:
mount-host-font-cache: false
gtk-3-themes:
interface: content
target: $SNAP/data-dir/themes
default-provider: gtk-common-themes
icon-themes:
interface: content
target: $SNAP/data-dir/icons
default-provider: gtk-common-themes
sound-themes:
interface: content
target: $SNAP/data-dir/sounds
default-provider: gtk-common-themes
gnome-42-2204:
interface: content
target: $SNAP/gnome-platform
default-provider: gnome-42-2204
Loading
Loading