diff --git a/build/flatpak/element.desktop.in b/build/flatpak/element.desktop.in new file mode 100644 index 0000000000..04c8024558 --- /dev/null +++ b/build/flatpak/element.desktop.in @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=${FLATPAK_APPNAME} +Icon=${FLATPAK_ID} +Exec=element %U +Categories=Network;InstantMessaging;Chat;VideoConference; +MimeType=x-scheme-handler/element; +StartupWMClass=element +Keywords=Matrix;matrix.org;chat;irc;communications;talk;riot;vector; diff --git a/build/flatpak/element.sh b/build/flatpak/element.sh new file mode 100644 index 0000000000..7a60354edb --- /dev/null +++ b/build/flatpak/element.sh @@ -0,0 +1,2 @@ +#!/bin/bash +env TMPDIR="$XDG_RUNTIME_DIR/app/${FLATPAK_ID}" /app/element/element-desktop --no-sandbox "$@" diff --git a/build/flatpak/metainfo.xml.in b/build/flatpak/metainfo.xml.in new file mode 100644 index 0000000000..be1172ba0b --- /dev/null +++ b/build/flatpak/metainfo.xml.in @@ -0,0 +1,40 @@ + + + ${FLATPAK_ID} + ${FLATPAK_APPNAME} + Apache-2.0 + New Vector Ltd + Create, share, communicate, chat and call securely, and bridge to other apps + CC0-1.0 + https://element.io/ + https://element.io/help + https://translate.element.io/ + +

More than group chat: communication

+ +
+ + + Element logged-in frontend + https://user-images.githubusercontent.com/2221064/137519256-655fe0f9-55f0-44a4-b681-83711654fff0.png + + + + + + + intense + intense + intense + + + im.riot.Riot + + ${FLATPAK_ID}.desktop +
diff --git a/dockerbuild/Dockerfile b/dockerbuild/Dockerfile index 3e9566f59d..23f0127c2b 100644 --- a/dockerbuild/Dockerfile +++ b/dockerbuild/Dockerfile @@ -1,8 +1,7 @@ -FROM buildpack-deps:xenial-curl +FROM buildpack-deps:bionic-curl ENV DEBIAN_FRONTEND noninteractive -RUN curl -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv yarn-* /yarn && ln -s /yarn/bin/yarn /usr/bin/yarn RUN apt-get -qq update && apt-get -qq dist-upgrade && \ # add repo for git-lfs curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \ @@ -17,7 +16,13 @@ RUN apt-get -qq update && apt-get -qq dist-upgrade && \ libsqlcipher-dev && \ # git-lfs git lfs install && \ - apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/* + # used by flathub client \ + apt-get -qq install -y --no-install-recommends flatpak ostree gettext appstream-util curl && \ + apt-get -qq install -y python3 python3-dev python3-pip libgirepository1.0-dev gir1.2-ostree-1.0 libcairo2-dev && \ + curl -sSL https://raw.githubusercontent.com/flatpak/flat-manager/master/flat-manager-client -o /usr/local/bin/flat-manager-client && \ + chmod +x /usr/local/bin/flat-manager-client && \ + pip3 install aiohttp tenacity PyGObject && \ + apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/ WORKDIR /project @@ -36,7 +41,8 @@ ENV NODE_VERSION 14.17.0 RUN curl -L https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz | tar xz -C /usr/local --strip-components=1 && \ unlink /usr/local/CHANGELOG.md && unlink /usr/local/LICENSE && unlink /usr/local/README.md && \ # https://github.com/npm/npm/issues/4531 - npm config set unsafe-perm true + npm config set unsafe-perm true && \ + npm install --global yarn ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ diff --git a/package.json b/package.json index 29a67e0005..630fa260cc 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "docker:install": "scripts/in-docker.sh yarn install", "debrepo": "scripts/mkrepo.sh", "clean": "rimraf webapp.asar dist packages deploys lib", - "hak": "ts-node scripts/hak/index.ts" + "hak": "ts-node scripts/hak/index.ts", + "flatpak": "yarn build && scripts/in-docker.sh scripts/build-flatpak.sh" }, "dependencies": { "auto-launch": "^5.0.5", @@ -104,7 +105,7 @@ "webapp.asar" ], "linux": { - "target": "deb", + "target": ["deb", "dir"], "category": "Network;InstantMessaging;Chat", "maintainer": "support@element.io", "desktop": { diff --git a/scripts/build-flatpak.sh b/scripts/build-flatpak.sh new file mode 100755 index 0000000000..3448950f73 --- /dev/null +++ b/scripts/build-flatpak.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -eu + +: "${FLATPAK_ID:=io.element.ElementNightly}" +: "${FLATPAK_APPNAME:=Element Nightly}" +: "${FLATPAK_VERSION:="0.0.0-nightly$(date +%Y%m%d)"}" +: "${FLATPAK_DATE:="$(date +%Y-%m-%d)"}" +: "${FLATPAK_BRANCH:=nightly}" + +export FLATPAK_ID FLATPAK_APPNAME FLATPAK_VERSION FLATPAK_DATE FLATPAK_BRANCH + +[[ -d dist/flatpak ]] && rm -rf dist/flatpak +install -d dist/flatpak/ +install -d dist/flatpak/build/files + +cd dist/flatpak + +cat < build/metadata +[Application] +name=${FLATPAK_ID} +runtime=org.freedesktop.Platform/x86_64/21.08 +sdk=org.freedesktop.Sdk/x86_64/21.08 +EOF + +cp -r ../linux-unpacked build/files/element +install -d build/files/share/applications build/files/share/metainfo +install -Dm755 ../../build/flatpak/element.sh build/files/bin/element +install -Dm644 ../../build/icons/512x512.png build/files/share/icons/hicolor/512x512/apps/${FLATPAK_ID}.png +envsubst < ../../build/flatpak/element.desktop.in > build/files/share/applications/${FLATPAK_ID}.desktop +envsubst < ../../build/flatpak/metainfo.xml.in > build/files/share/metainfo/${FLATPAK_ID}.metainfo.xml + +appstream-compose --prefix=build/files --origin=flatpak --basename=${FLATPAK_ID} ${FLATPAK_ID} +appstream-util mirror-screenshots build/files/share/app-info/xmls/${FLATPAK_ID}.xml.gz \ + "https://dl.flathub.org/repo/screenshots/${FLATPAK_ID}-${FLATPAK_BRANCH}" \ + build/screenshots "build/screeshots/${FLATPAK_ID}-${FLATPAK_BRANCH}" + +# TODO: baseapp with deps +# TODO: zypak-wrapper + +flatpak build-finish build \ + --socket=x11 \ + --share=ipc \ + --socket=pulseaudio \ + --device=all \ + --share=network \ + --filesystem=xdg-download \ + --talk-name=org.freedesktop.Notifications \ + --talk-name=org.kde.StatusNotifierWatcher \ + --talk-name=org.freedesktop.ScreenSaver \ + --own-name='org.kde.*' \ + --talk-name=org.freedesktop.portal.Fcitx \ + --filesystem=xdg-run/keyring \ + --command=element + +flatpak build-export repo build $FLATPAK_BRANCH +flatpak build-update-repo --generate-static-deltas repo +flatpak build-bundle --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo \ + repo ../element.flatpak $FLATPAK_ID $FLATPAK_BRANCH