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/remove snapcraft entries #1

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/app-builder-lib/src/targets/snap.ts
Expand Up @@ -124,7 +124,6 @@ export default class SnapTarget extends Target {
const archTriplet = archNameToTriplet(arch)
appDescriptor.environment = {
DISABLE_WAYLAND: options.allowNativeWayland ? "" : "1",
TMPDIR: "$XDG_RUNTIME_DIR",
PATH: "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
SNAP_DESKTOP_RUNTIME: "$SNAP/gnome-platform",
LD_LIBRARY_PATH: [
Expand Down Expand Up @@ -175,6 +174,7 @@ export default class SnapTarget extends Target {
})

const snap = await this.createDescriptor(arch)

if (this.isUseTemplateApp) {
delete snap.parts
}
Expand Down Expand Up @@ -210,6 +210,16 @@ export default class SnapTarget extends Target {
args.push("--compression", snap.compression)
}

if (this.isUseTemplateApp) {
// remove fields that are valid in snapcraft.yaml, but not snap.yaml
delete snap.compression
delete snap.contact
delete snap.donation
delete snap.issues
delete snap["source-code"]
delete snap.website
}

if (packager.packagerOptions.effectiveOptionComputed != null && (await packager.packagerOptions.effectiveOptionComputed({ snap, desktopFile, args }))) {
return
}
Expand Down
80 changes: 69 additions & 11 deletions test/snapshots/linux/snapTest.js.snap
Expand Up @@ -22,7 +22,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -93,7 +92,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -316,7 +314,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -387,7 +384,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -458,7 +454,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -528,7 +523,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -1262,7 +1256,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"foo",
Expand Down Expand Up @@ -1323,7 +1316,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"browser-sandbox",
Expand Down Expand Up @@ -1525,7 +1517,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"browser-sandbox",
Expand Down Expand Up @@ -1726,7 +1717,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -1800,7 +1790,6 @@ Object {
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
"TMPDIR": "$XDG_RUNTIME_DIR",
},
"plugs": Array [
"desktop",
Expand Down Expand Up @@ -1880,3 +1869,72 @@ Object {
],
}
`;

exports[`use template app 1`] = `
Object {
"apps": Object {
"testapp": Object {
"command": "command.sh",
"environment": Object {
"DISABLE_WAYLAND": "1",
"LD_LIBRARY_PATH": "$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu",
"PATH": "$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH",
"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform",
},
"plugs": Array [
"desktop",
"desktop-legacy",
"home",
"x11",
"wayland",
"unity7",
"browser-support",
"network",
"gsettings",
"audio-playback",
"pulseaudio",
"opengl",
],
},
},
"architectures": Array [
"amd64",
],
"base": "core18",
"confinement": "strict",
"description": "Test Application (test quite “ #378)",
"grade": "stable",
"name": "testapp",
"plugs": Object {
"gnome-3-28-1804": Object {
"default-provider": "gnome-3-28-1804",
"interface": "content",
"target": "$SNAP/gnome-platform",
},
"gtk-3-themes": Object {
"default-provider": "gtk-common-themes",
"interface": "content",
"target": "$SNAP/data-dir/themes",
},
"icon-themes": Object {
"default-provider": "gtk-common-themes",
"interface": "content",
"target": "$SNAP/data-dir/icons",
},
"sound-themes": Object {
"default-provider": "gtk-common-themes",
"interface": "content",
"target": "$SNAP/data-dir/sounds",
},
},
"summary": "Test App ßW",
"title": "Test App ßW",
"version": "1.1.0",
}
`;

exports[`use template app 2`] = `
Object {
"linux": Array [],
}
`;
2 changes: 1 addition & 1 deletion test/src/helpers/packTester.ts
Expand Up @@ -27,7 +27,7 @@ if (process.env.TRAVIS !== "true") {
}

export const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET)
export const snapTarget = Platform.LINUX.createTarget("snap")
export const snapTarget = Platform.LINUX.createTarget("snap", Arch.x64)

export interface AssertPackOptions {
readonly projectDirCreated?: (projectDir: string, tmpDir: TmpDir) => Promise<any>
Expand Down
39 changes: 32 additions & 7 deletions test/src/linux/snapTest.ts
Expand Up @@ -40,7 +40,7 @@ test.ifAll.ifDevOrLinuxCi(
test.ifAll.ifDevOrLinuxCi("default stagePackages", async () => {
for (const p of [["default"], ["default", "custom"], ["custom", "default"], ["foo1", "default", "foo2"]]) {
await assertPack("test-app-one", {
targets: Platform.LINUX.createTarget("snap"),
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
Expand Down Expand Up @@ -82,7 +82,7 @@ test.ifAll.ifDevOrLinuxCi(

test.ifAll.ifDevOrLinuxCi("buildPackages", async () => {
await assertPack("test-app-one", {
targets: Platform.LINUX.createTarget("snap"),
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
Expand Down Expand Up @@ -122,7 +122,7 @@ test.ifDevOrLinuxCi("plugs option", async () => {
},
]) {
await assertPack("test-app-one", {
targets: Platform.LINUX.createTarget("snap"),
targets: snapTarget,
config: {
snap: {
plugs: p,
Expand Down Expand Up @@ -154,7 +154,7 @@ test.ifDevOrLinuxCi("slots option", async () => {
],
]) {
await assertPack("test-app-one", {
targets: Platform.LINUX.createTarget("snap"),
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
Expand All @@ -175,7 +175,7 @@ test.ifDevOrLinuxCi("slots option", async () => {
test.ifDevOrLinuxCi(
"custom env",
app({
targets: Platform.LINUX.createTarget("snap"),
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
Expand All @@ -197,7 +197,7 @@ test.ifDevOrLinuxCi(
test.ifDevOrLinuxCi(
"custom after, no desktop",
app({
targets: Platform.LINUX.createTarget("snap"),
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
Expand All @@ -217,7 +217,7 @@ test.ifDevOrLinuxCi(
test.ifDevOrLinuxCi(
"no desktop plugs",
app({
targets: Platform.LINUX.createTarget("snap"),
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
Expand Down Expand Up @@ -294,3 +294,28 @@ test.ifDevOrLinuxCi(
},
})
)

test.ifDevOrLinuxCi(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this test should include the compression field, then we can check that it is still undefined but that it is also included in args?

"use template app",
app({
targets: snapTarget,
config: {
snap: {
useTemplateApp: true,
},
},
effectiveOptionComputed: async ({ snap, args }) => {
expect(snap).toMatchSnapshot()
expect(snap.parts).toBeUndefined()
expect(snap.compression).toBeUndefined()
expect(snap.contact).toBeUndefined()
expect(snap.donation).toBeUndefined()
expect(snap.issues).toBeUndefined()
expect(snap.parts).toBeUndefined()
expect(snap["source-code"]).toBeUndefined()
expect(snap.website).toBeUndefined()
expect(args).toEqual(expect.arrayContaining(["--exclude", "chrome-sandbox"]))
return true
},
})
)