Bug 1591751 - Updated snapcraft.yaml and Dockerfile to make use of modern snapcraft features. r=jlorenzo
authorKrish De Souza <koolkrish007+github@gmail.com>
Tue, 26 Nov 2019 14:34:47 +0000
changeset 503859 606408df5b4d712c7bf4e80621dd145f1cd82940
parent 503858 7aff50c10a478e7fb3fc1eaf285908eeef093f03
child 503860 8e9c25f6c1ec1ecbae8eb0506696cc9214be9096
push id101586
push userjlorenzo@mozilla.com
push dateTue, 26 Nov 2019 14:36:55 +0000
treeherderautoland@606408df5b4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlorenzo
bugs1591751, 11739, 13485
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1591751 - Updated snapcraft.yaml and Dockerfile to make use of modern snapcraft features. r=jlorenzo In this patch I have adapted the Docker file to make use of core18 and snapcraft3. This is the recommended approach as stated here. https://snapcraft.io/docks/t/creating-docker-images-for-snapcraft/11739 Specifically the part talking about replacing likes FROM ubuntu:xenial with FROM ubuntu:bionic. In snapcraft.yaml.in, I adjusted the snap by using the gnome-3-28 extensions as described in https://forum.snapcraft.io/t/the-gnome-3-28-extension/13485. In addition, I followed the instructions presented by removing the unnecessary plugs relating to the desktop extension and adding the relevant dbus slot. As part of the build process, it required a bunch of extra staged packages which I have documented. I also used the magic part from Ken Vandine's thunderbird snapcraft for updating mime info. https://bazaar.launchpad.net/~ubuntu-desktop/thunderbird/snap/view/head:/snapcraft.yaml I also removed the xdg-open as that seemed to not be enabling the building of the snap. Differential Revision: https://phabricator.services.mozilla.com/D53355
taskcluster/docker/firefox-snap/Dockerfile
taskcluster/docker/firefox-snap/snapcraft.yaml.in
--- a/taskcluster/docker/firefox-snap/Dockerfile
+++ b/taskcluster/docker/firefox-snap/Dockerfile
@@ -1,11 +1,57 @@
-FROM snapcore/snapcraft:stable
+## The below code is from snapcraft/docker/stable.Dockerfile
+## The modifications done are part of the documentation for enabling core18 snaps.
+## https://snapcraft.io/docs/t/creating-docker-images-for-snapcraft/11739
+
+FROM ubuntu:bionic
+
+# Grab dependencies
+RUN apt-get update && \
+    apt-get dist-upgrade --yes && \
+    apt-get install --yes \
+      curl \
+      jq \
+      squashfs-tools \
+      locales \
+      bzip2 \
+      curl \
+      git \
+      python3 \
+      locales \
+      sudo && \
+    apt-get clean && \
+locale-gen en_US.UTF-8
 
-RUN apt-get update && apt-get install -qy python3 bzip2 curl git && apt-get clean
+ENV LANG="en_US.UTF-8"
+ENV LANGUAGE="en_US:en"
+ENV LC_ALL="en_US.UTF-8"
+ENV PATH="/snap/bin:$PATH"
+ENV SNAP="/snap/snapcraft/current"
+ENV SNAP_NAME="snapcraft"
+ENV SNAP_ARCH="amd64"
+
+# Grab the core snap from the stable channel and unpack it in the proper place
+RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core' | jq '.download_url' -r) --output core.snap && \
+    mkdir -p /snap/core && \
+    unsquashfs -d /snap/core/current core.snap && \
+    rm core.snap
+
+# Grab the snapcraft snap from the stable channel and unpack it in the proper place
+RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel=stable' | jq '.download_url' -r) --output snapcraft.snap && \
+    mkdir -p /snap/snapcraft && \
+    unsquashfs -d /snap/snapcraft/current snapcraft.snap && \
+    rm snapcraft.snap
+
+# Create a snapcraft runner (TODO: move version detection to the core of snapcraft)
+RUN mkdir -p /snap/bin
+RUN echo "#!/bin/sh" > /snap/bin/snapcraft
+RUN snap_version="$(awk '/^version:/{print $2}' /snap/snapcraft/current/meta/snap.yaml)" && echo "export SNAP_VERSION=\"$snap_version\"" >> /snap/bin/snapcraft
+RUN echo 'exec "$SNAP/usr/bin/python3" "$SNAP/bin/snapcraft" "$@"' >> /snap/bin/snapcraft
+RUN chmod +x /snap/bin/snapcraft
 
 RUN mkdir /scripts/
 WORKDIR /scripts/
 # Copy everything in the docker/firefox-snap folder but the Dockerfile
 #
 # XXX The following pattern is neither a regex nor a glob one. It's
 # documented at https://golang.org/pkg/path/filepath/#Match. There's no
 # way of explicitly filtering out "Dockerfile". If one day, someone needs
--- a/taskcluster/docker/firefox-snap/snapcraft.yaml.in
+++ b/taskcluster/docker/firefox-snap/snapcraft.yaml.in
@@ -1,83 +1,88 @@
 name: firefox
 version: @VERSION@-@BUILD_NUMBER@
 summary: Mozilla Firefox web browser
 description:  Firefox is a powerful, extensible web browser with support for modern web application technologies.
 confinement: strict
 grade: stable
+base: core18
 
 apps:
   firefox:
-    command: desktop-launch $SNAP/firefox
+    command: firefox
     desktop: distribution/firefox.desktop
+    extensions: [gnome-3-28]
     environment:
       DISABLE_WAYLAND: 1
       HOME: "$SNAP_USER_COMMON"
+    slots:
+      - dbus-daemon
     plugs:
       - avahi-observe
       - browser-sandbox
       - camera
       - cups-control
-      - desktop
-      - desktop-legacy
       - gsettings
       - home
       - joystick
       - network
       - network-observe
       - opengl
       - pulseaudio
       - removable-media
       - screen-inhibit-control
       - u2f-devices
       - unity7
       - upower-observe
-      - x11
 
 plugs:
   browser-sandbox:
     interface: browser-support
     allow-sandbox: true
 
 parts:
-  desktop-gtk3:
-    source-commit: 6a600b00773e8e4624aa12ee1f8e013ba9f2fc03
   firefox:
     plugin: dump
     source: source
     stage-packages:
       - libxt6
       - libdbus-glib-1-2
       - libasound2
       - libpulse0
       - libgl1-mesa-dri
       - libgl1-mesa-glx
       - libmirclient9
       - desktop-file-utils
       - ffmpeg
       - libc-bin
       - locales-all
       - libcurl3-gnutls
-    after: [desktop-gtk3]
 
   xdg-open:
     after: [firefox]
     plugin: nil
     source: .
-    install: |
+    override-build: |
+      snapcraftctl build
       set -eux
       mkdir -p $SNAPCRAFT_PART_INSTALL/usr/share/applications
       install -m 644 mimeapps.list $SNAPCRAFT_PART_INSTALL/usr/share/applications
       update-desktop-database -v $SNAPCRAFT_PART_INSTALL/usr/share/applications
     build-packages:
       - desktop-file-utils
-    build-attributes: [no-system-libraries]
 
   shared-mime-info:
     after: [xdg-open]
     plugin: nil
     stage-packages:
       - shared-mime-info
-    build-attributes: [no-system-libraries]
-    install: |
+    override-build: |
+      snapcraftctl build
       set -eux
+      mkdir -p $SNAPCRAFT_PART_INSTALL/usr/share/mime
       update-mime-database $SNAPCRAFT_PART_INSTALL/usr/share/mime
+
+slots:
+  dbus-daemon:
+    interface: dbus
+    bus: session
+    name: org.mozilla.firefox