Commit c9e6a498 authored by Johan Lorenzo's avatar Johan Lorenzo
Browse files

Bug 1655669 - part 1: Improve logging by notably outputting what snap...

Bug 1655669 - part 1: Improve logging by notably outputting what snap dependencies are downloaded. r=sfraser, a=release

Differential Revision: https://phabricator.services.mozilla.com/D85150
parent 49e961ad
Loading
Loading
Loading
Loading
+19 −41
Original line number Diff line number Diff line
@@ -4,6 +4,15 @@

FROM ubuntu:bionic

ENV LANG='en_US.UTF-8' \
    LANGUAGE='en_US:en' \
    LC_ALL='en_US.UTF-8' \
    PATH="/snap/bin:$PATH" \
    SNAP='/snap/snapcraft/current' \
    SNAP_NAME='snapcraft' \
    SNAP_ARCH='amd64' \
    TERM='dumb'

# Grab dependencies
RUN apt-get update && \
    apt-get dist-upgrade --yes && \
@@ -20,50 +29,19 @@ RUN apt-get update && \
      locales \
      sudo && \
    apt-get clean && \
locale-gen en_US.UTF-8

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 (for backwards compatibility) 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 core18 snap (which snapcraft uses as a base) 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/core18' | jq '.download_url' -r) --output core18.snap
RUN mkdir -p /snap/core18
RUN unsquashfs -d /snap/core18/current core18.snap

# Grab the gnome-3-34-1804 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/gnome-3-34-1804?channel=stable' | jq '.download_url' -r) --output gnome-3-34-1804.snap
RUN mkdir -p /snap/gnome-3-34-1804
RUN unsquashfs -d /snap/gnome-3-34-1804/current gnome-3-34-1804.snap
locale-gen "$LANG"

# Grab the gnome-3-34-1804-sdk 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/gnome-3-34-1804-sdk?channel=stable' | jq '.download_url' -r) --output gnome-3-34-1804-sdk.snap
RUN mkdir -p /snap/gnome-3-34-1804-sdk
RUN unsquashfs -d /snap/gnome-3-34-1804-sdk/current gnome-3-34-1804-sdk.snap
COPY download_and_install_snap.sh .

# 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
# Grab the core snap (for backwards compatibility)
RUN bash download_and_install_snap.sh 'core' 
# Grab the core18 snap (which snapcraft uses as a base)
RUN bash download_and_install_snap.sh 'core18'
RUN bash download_and_install_snap.sh 'gnome-3-34-1804'
RUN bash download_and_install_snap.sh 'gnome-3-34-1804-sdk'
RUN bash download_and_install_snap.sh 'snapcraft'

# Create a snapcraft runner (TODO: move version detection to the core of
# snapcraft).
# 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
+27 −0
Original line number Diff line number Diff line
#!/bin/bash

set -ex

SNAP_NAME="$1"
SNAP_CHANNEL="${2:-stable}"
SNAP_INSTALL_LOCATION="${3:-/snap}"

SNAP_METADATA="$(curl --header 'X-Ubuntu-Series: 16' "https://api.snapcraft.io/api/v1/snaps/details/$SNAP_NAME?channel=$SNAP_CHANNEL")"

set +x
SNAP_SHA512="$(echo "$SNAP_METADATA" | jq '.download_sha512' -r)"
SNAP_DOWNLOAD_URL="$(echo "$SNAP_METADATA" | jq '.download_url' -r)"
SNAP_LAST_UPDATED="$(echo "$SNAP_METADATA" | jq '.last_updated' -r)"
SNAP_REVISION="$(echo "$SNAP_METADATA" | jq '.revision' -r)"
SNAP_VERSION="$(echo "$SNAP_METADATA" | jq '.version' -r)"
set -x

echo "Downloading $SNAP_NAME, version $SNAP_VERSION, revision $SNAP_REVISION (last updated: $SNAP_LAST_UPDATED)..."
curl --location "$SNAP_DOWNLOAD_URL" --output "$SNAP_NAME.snap"
sha512sum -c <(echo "$SNAP_SHA512  $SNAP_NAME.snap") 

mkdir -p "$SNAP_INSTALL_LOCATION/$SNAP_NAME"
unsquashfs -d "$SNAP_INSTALL_LOCATION/$SNAP_NAME/current" "$SNAP_NAME.snap"
rm "$SNAP_NAME.snap"

echo "$SNAP_NAME version $SNAP_VERSION has correctly been uploaded and installed."
 No newline at end of file