Skip to content
Snippets Groups Projects
Unverified Commit 4c58ef1c authored by Amin Bandali's avatar Amin Bandali
Browse files

packaging: add snap

Change-Id: I5b24b809cec3763c44808fe9f056cba862336531
parent cbf6824d
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@ DEBIAN_OCI_PKG_DIR:="packaging/rules/debian-one-click-install"
#####################
TMPDIR := $(shell mktemp -d)
CURRENT_UID:=$(shell id -u)
CURRENT_GID:=$(shell id -g)
#############################
## Release tarball targets ##
......@@ -118,13 +119,25 @@ package-all: package-debian_9 \
package-opensuse-leap_15.1 \
package-opensuse-leap_15.2 \
package-opensuse-tumbleweed \
package-gentoo
package-gentoo \
package-snap
# Append the output of make-packaging-target to this Makefile
# see Makefile.packaging.distro_targets
$(shell scripts/make-packaging-target.py --generate-all > Makefile.packaging.distro_targets)
include Makefile.packaging.distro_targets
docker/Dockerfile_snap: patches/docker-snap-build-scripts.patch
if patch -p1 -fR --dry-run < $< >/dev/null 2>&1; then \
echo "Patching $@... skipped (already patched)"; \
else \
echo "Patching $@..."; \
patch -p1 -Ns < $< || { echo "Patching $@... failed" >&2 && exit 1; }; \
echo "Patching $@... done"; \
fi
.PHONY: docker/Dockerfile_snap
###################
## Other targets ##
###################
......
FROM ubuntu:xenial as builder
# Grab dependencies
RUN apt-get update
RUN apt-get dist-upgrade --yes
RUN apt-get install --yes \
curl \
jq \
squashfs-tools
# 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
RUN mkdir -p /snap/core
RUN unsquashfs -d /snap/core/current 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 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
RUN mkdir -p /snap/snapcraft
RUN unsquashfs -d /snap/snapcraft/current 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
# Multi-stage build, only need the snaps from the builder. Copy them one at a
# time so they can be cached.
FROM ubuntu:xenial
COPY --from=builder /snap/core /snap/core
COPY --from=builder /snap/core18 /snap/core18
COPY --from=builder /snap/snapcraft /snap/snapcraft
COPY --from=builder /snap/bin/snapcraft /snap/bin/snapcraft
# Generate locale and install dependencies.
RUN apt-get update && apt-get dist-upgrade --yes && apt-get install --yes snapd sudo locales && locale-gen en_US.UTF-8
# Set the proper environment.
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"
......@@ -25,3 +25,12 @@ hub organization. These images are generated with the following method:
### Fedora
TODO
### Snap
`Dockerfile_snap` is from [stable.Dockerfile](stable.Dockerfile)
upstream, under GPLv3-only, and is not considered part of the project.
It is patched with `../patches/docker-snap-build-scripts.patch` to
add and invoke our build script.
[stable.Dockerfile]: https://raw.githubusercontent.com/snapcore/snapcraft/master/docker/stable.Dockerfile
This diff is collapsed.
#!/bin/sh
$SNAP/usr/lib/ring/dring -cd &
exec "$@"
# Copyright (C) 2019-2020 Savoir-faire Linux Inc.
#
# Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
# Author: Amin Bandali <amin.bandali@savoirfairelinux.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is based on earlier work by Daniel Llewellyn, under the
# Expat License (also referred to as "the MIT License"), per the
# following notice:
# Copyright (C) 2017-2020 Daniel Llewellyn <daniel@bowlhat.net>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: jami
version: "RELEASE_VERSION"
adopt-info: jami
icon: icons/jami.svg
summary: 'Jami: secure, distributed communication software & SIP client'
description: >
Jami is free software which allows its users to communicate in multiple ways.
* A telephone: a simple tool to connect, communicate and share.
* A teleconferencing tool: easily join calls to create conferences with multiple participants.
* A media sharing tool: Jami supports a variety of video input options, including mutliple cameras and image and video files, and the selection of audio inputs and outputs; all this is supported by multiple high quality audio and video codecs.
* A messenger: send text messeges during calls or out of calls (as long as your peer is connected).
* A building block for your IoT project: re-use the universal communications technology of Jami with its portable library on your system of choice.
confinement: strict
grade: stable
base: core18
plugs:
gnome-3-28-1804:
interface: content
target: $SNAP/gnome-platform
default-provider: gnome-3-28-1804:gnome-3-28-1804
gtk-3-themes:
interface: content
target: $SNAP/data-dir/themes
default-provider: gtk-common-themes:gtk-3-themes
icon-themes:
interface: content
target: $SNAP/data-dir/icons
default-provider: gtk-common-themes:icon-themes
sound-themes:
interface: content
target: $SNAP/data-dir/sounds
default-provider: gtk-common-themes:sounds-themes
slots:
dbus-jami:
interface: dbus
bus: session
name: net.jami.Jami
dbus-ring:
interface: dbus
bus: session
name: cx.ring.Ring
dbus-jamignome:
interface: dbus
bus: session
name: cx.ring.RingGnome
layout:
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0:
bind: $SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
/usr/local/share/jami-gnome:
bind: $SNAP/usr/share/jami-gnome
environment:
DISABLE_WAYLAND: 'true'
XDG_CURRENT_DESKTOP: Unity
apps:
jami:
command: usr/bin/jami-gnome
command-chain:
- bin/desktop-launch
- snap/command-chain/alsa-launch
- bin/jami-gnome-wrapper
common-id: net.jami.Jami
desktop: usr/share/applications/jami-gnome.desktop
slots:
- dbus-jami
- dbus-ring
- dbus-jamignome
plugs:
- audio-playback
- audio-record
- browser-support
- camera
- desktop
- desktop-legacy
- gsettings
- hardware-observe
- home
- network
- network-bind
- opengl
- removable-media
- unity7
- wayland
- x11
parts:
desktop-launch:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
plugin: nil
build-packages:
- gcc-8
- qtbase5-dev
- dpkg-dev
stage-packages:
- libqt5gui5
- libqt5svg5 # for loading icon themes which are svg
- try: [appmenu-qt5] # not available on core18
override-pull: |
snapcraftctl pull
sed -i -E 's|\. \$SNAP/flavor-select|USE_gtk3=true|' gtk/launcher-specific
sed -i -E 's|\. \$SNAP/flavor-select|USE_qt5=true|' qt/launcher-specific
sed -i -E 's|(append_dir GTK_PATH \$RUNTIME/usr/lib/\$ARCH/gtk-2.0)|#\1|' qt/launcher-specific
sed -i -E 's|\$RUNTIME|$SNAP|g' qt/launcher-specific
sed -i -E 's|\$WITH_RUNTIME|no|g' qt/launcher-specific
override-build: |
snapcraftctl build
gcc -Wall -O2 -o bindtextdomain.so -fPIC -shared src/bindtextdomain.c -ldl
echo "#!/bin/bash" > desktop-launch
cat common/init >> desktop-launch
cat qt/runtime-exports >> desktop-launch
cat gtk/runtime-exports >> desktop-launch
cat common/desktop-exports >> desktop-launch
cat qt/launcher-specific >> desktop-launch
cat gtk/launcher-specific >> desktop-launch
cat common/mark-and-exec >> desktop-launch
install -D -m755 desktop-launch $SNAPCRAFT_PART_INSTALL/bin/desktop-launch
install -D -m644 bindtextdomain.so $SNAPCRAFT_PART_INSTALL/lib/bindtextdomain.so
mkdir -pv $SNAPCRAFT_PART_INSTALL/gnome-platform
scripts:
plugin: dump
source: scripts
organize:
jami-gnome-wrapper: bin/jami-gnome-wrapper
alsa-mixin:
plugin: dump
source: https://github.com/diddlesnaps/snapcraft-alsa.git
source-subdir: snapcraft-assets
build-packages:
- libasound2-dev
stage-packages:
- libasound2
- libasound2-plugins
jami:
after: [alsa-mixin]
source: ../../..
source-type: local
plugin: nil
parse-info: [usr/share/metainfo/jami-gnome.appdata.xml]
override-pull: |
snapcraftctl pull
sed -i -E 's|(tmpName) << (PACKAGE_NAME << "_shm_")|\1 << "snap.jami." << \2|' daemon/src/media/video/sinkclient.cpp
for file in jami-gnome.desktop jami-gnome.desktop.autostart; do
sed -i -E 's|^Icon=.*|Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/jami.svg|' client-gnome/$file
done
override-build: |
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 20
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 10
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 20
cd $SNAPCRAFT_PART_BUILD/daemon/contrib
mkdir -p native
cd native
../bootstrap
make .ffmpeg
make
cd $SNAPCRAFT_PART_BUILD/daemon
./autogen.sh
./configure --prefix=/usr --disable-shared
make -j$SNAPCRAFT_PARALLEL_BUILD_COUNT
DESTDIR=$SNAPCRAFT_PART_INSTALL make install
cd $SNAPCRAFT_PART_BUILD/lrc
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_PREFIX_PATH=$SNAPCRAFT_PART_INSTALL/usr \
-DRING_BUILD_DIR=$SNAPCRAFT_PART_BUILD/daemon/src
make -j$SNAPCRAFT_PARALLEL_BUILD_COUNT
DESTDIR=$SNAPCRAFT_PART_INSTALL make install
sed -i "s|/usr|$SNAPCRAFT_PART_INSTALL/usr|g" $SNAPCRAFT_PART_INSTALL/usr/lib/cmake/LibRingClient/LibRingClientConfig.cmake
cd $SNAPCRAFT_PART_BUILD/client-gnome
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_PREFIX_PATH=$SNAPCRAFT_PART_INSTALL/usr \
-DLibRingClient_DIR=$SNAPCRAFT_PART_INSTALL/usr/lib/cmake/LibRingClient
make -j$SNAPCRAFT_PARALLEL_BUILD_COUNT
DESTDIR=$SNAPCRAFT_PART_INSTALL make install
build-packages:
- autoconf
- autoconf-archive
- automake
- autopoint
- bzip2
- cmake
- curl
- g++-8
- gettext
- gnome-icon-theme-symbolic
- gzip
- libappindicator3-dev
- libayatana-appindicator3-dev
- libasound2-dev
- libavcodec-dev
- libavdevice-dev
- libavformat-dev
- libboost-dev
- libcanberra-gtk3-dev
- libclutter-gtk-1.0-dev
- libdbus-1-dev
- libdbus-c++-dev
- libexpat1-dev
- libgnutls28-dev
- libgsm1-dev
- libgtk-3-dev
- libjack-jackd2-dev
- libjsoncpp-dev
- libnotify-dev
- libopus-dev
- libpcre3-dev
- libpulse-dev
- libqrencode-dev
- libsamplerate0-dev
- libsndfile1-dev
- libspeex-dev
- libspeexdsp-dev
- libsrtp0-dev
- libswscale-dev
- libtool
- libudev-dev
- libupnp-dev
- libva-dev
- libvdpau-dev
- libwebkit2gtk-4.0-dev
- libyaml-cpp-dev
- nasm # seems to be needed for building libvpx on an 18.04 base
- qtbase5-dev
- qttools5-dev
- uuid-dev
- yasm
stage-packages:
- freeglut3
- libappindicator3-1
- libayatana-appindicator3-1
- libavcodec-extra
- libavcodec57
- libavdevice57
- libavformat57
- libdbus-1-3
- libdbus-c++-1-0v5
- libebook-1.2-19
- libexpat1
- libglu1-mesa
- libgnutls30
- libgsm1
- libjack-jackd2-0
- libjsoncpp1
- libopus0
- libpcre3
- libqrencode3
- libqt5core5a
- libqt5dbus5
- libqt5gui5
- libqt5sql5
- libqt5sql5-sqlite
- libsamplerate0
- libslang2
- libsndfile1
- libspeex1
- libspeexdsp1
- libswscale4
- libudev1
- libupnp6
- libuuid1
- libva-drm2
- libva-glx2
- libva-wayland2
- libva2
- libvdpau-va-gl1
- libvdpau1
- va-driver-all
Description: add and run our build script
Also, use bionic (18.04) as the base image, since xenial lacks
libayatana-appindicator3-dev.
Author: Amin Bandali <amin.bandali@savoirfairelinux.com>
--- ../docker/Dockerfile_snap.original 2020-11-23 15:51:17.211591055 -0500
+++ ../docker/Dockerfile_snap 2020-11-23 15:52:29.247759416 -0500
@@ -1,4 +1,4 @@
-FROM ubuntu:xenial as builder
+FROM ubuntu:bionic as builder
# Grab dependencies
RUN apt-get update
@@ -36,7 +36,7 @@
# Multi-stage build, only need the snaps from the builder. Copy them one at a
# time so they can be cached.
-FROM ubuntu:xenial
+FROM ubuntu:bionic
COPY --from=builder /snap/core /snap/core
COPY --from=builder /snap/core18 /snap/core18
COPY --from=builder /snap/snapcraft /snap/snapcraft
@@ -53,3 +53,7 @@
ENV SNAP="/snap/snapcraft/current"
ENV SNAP_NAME="snapcraft"
ENV SNAP_ARCH="amd64"
+
+ADD scripts/build-package-snap.sh /opt/build-package-snap.sh
+
+CMD /opt/build-package-snap.sh
#!/usr/bin/env bash
#
# Copyright (C) 2020 Savoir-faire Linux Inc.
#
# Author: Amin Bandali <amin.bandali@savoirfairelinux.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script is used in the packaging containers to build a snap
# package on an ubuntu base distro.
set -e
cp -rp /opt/ring-project-ro /opt/ring-project
cd /opt/ring-project/packaging/rules/snap/
# set the version and tarball filename
sed -i "s/RELEASE_VERSION/${RELEASE_VERSION}/g" snapcraft.yaml
snapcraft
# move the built snap to output
mv *.snap /opt/output/
chown ${CURRENT_UID}:${CURRENT_GID} /opt/output/*.snap
......@@ -182,6 +182,33 @@ EOF
}
####################
## Snap packaging ##
####################
function package_snap()
{
echo "####################"
echo "## deploying snap ##"
echo "####################"
if [[ "${CHANNEL:0:19}" == "internal_experiment" ]];
then
DISTRIBUTION_REPOSITOIRY_FOLDER=$(realpath repositories)/${DISTRIBUTION}
mkdir -p ${DISTRIBUTION_REPOSITOIRY_FOLDER}
cp packages/${DISTRIBUTION}*/*.snap ${DISTRIBUTION_REPOSITOIRY_FOLDER}/
elif [[ "${CHANNEL:0:7}" == "nightly" ]];
then
snapcraft login --with ${SNAPCRAFT_LOGIN}
snapcraft push packages/${DISTRIBUTION}*/*.snap --release edge
elif [[ "${CHANNEL:0:6}" == "stable" ]];
then
snapcraft login --with ${SNAPCRAFT_LOGIN}
snapcraft push packages/${DISTRIBUTION}*/*.snap --release stable
fi
}
################################################
## Deploy packages on given remote repository ##
################################################
......@@ -221,6 +248,9 @@ function package()
elif [[ "${DISTRIBUTION:0:6}" == "fedora" || "${DISTRIBUTION:0:4}" == "rhel" || "${DISTRIBUTION:0:13}" == "opensuse-leap" || "${DISTRIBUTION:0:19}" == "opensuse-tumbleweed" ]];
then
package_rpm
elif [[ "${DISTRIBUTION:0:4}" == "snap" ]];
then
package_snap
else
echo "ERROR: Distribution '${DISTRIBUTION}' is unsupported"
fi
......@@ -257,6 +287,10 @@ case $i in
SSH_IDENTIY_FILE="${i#*=}"
shift
;;
--snapcraft-login=*)
SNAPCRAFT_LOGIN="${i#*=}"
shift
;;
*)
echo "Unrecognized option ${i}"
exit 1
......
......@@ -47,6 +47,7 @@ PACKAGE_%(distribution)s_DOCKER_RUN_COMMAND = docker run \\
-e DEBIAN_VERSION=%(version)s \\
-e DEBIAN_PACKAGING_OVERRIDE=%(debian_packaging_override)s \\
-e CURRENT_UID=$(CURRENT_UID) \\
-e CURRENT_GID=$(CURRENT_GID) \\
-e DISTRIBUTION=%(distribution)s \\
-v $(CURDIR):/opt/ring-project-ro:ro \\
-v $(CURDIR)/packages/%(distribution)s:/opt/output \\
......@@ -400,6 +401,12 @@ def run_generate_all(parsed_args):
"debian_packaging_override": "",
"output_file": ".packages-built",
},
# Snap
{
"distribution": "snap",
"debian_packaging_override": "",
"output_file": ".packages-built",
},
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment