Use nix to download Desktop bundle base images

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-03-21 17:56:22 +01:00
parent fc5c8c2dc0
commit c53553e137
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
23 changed files with 190 additions and 53 deletions

View File

@ -3,3 +3,5 @@ android-sdk-platform;android-27;
android-sdk;4333796;aa190cfd7299cd6a1c687355bb2764e4 android-sdk;4333796;aa190cfd7299cd6a1c687355bb2764e4
nix;2.2.1; nix;2.2.1;
react_native_cli;2.0.1; react_native_cli;2.0.1;
StatusImAppImage;20181208;
StatusIm-Windows-base-image;20181113;

View File

@ -2,7 +2,7 @@ pipeline {
agent { agent {
docker { docker {
label 'linux' label 'linux'
image 'statusteam/nix:jenkins-1.0.0-4a147dc3' image 'statusteam/nix:jenkins-1.0.0-158e62e1'
args ( args (
"-v /home/jenkins/tmp:/var/tmp:rw "+ "-v /home/jenkins/tmp:/var/tmp:rw "+
"-v /home/jenkins/status-im.keystore:/tmp/status-im.keystore:ro" "-v /home/jenkins/status-im.keystore:/tmp/status-im.keystore:ro"

View File

@ -2,12 +2,11 @@ pipeline {
agent { agent {
docker { docker {
label 'linux' label 'linux'
image 'statusteam/nix:jenkins-1.0.0-4a147dc3' image 'statusteam/nix:jenkins-1.0.0-158e62e1'
args ( args (
"-v /tmp/Android/Sdk:/home/jenkins/.status/Android/Sdk:rw "+ "-v /tmp/Android/Sdk:/home/jenkins/.status/Android/Sdk:rw "+
"-v /var/tmp/lein:/var/tmp/lein:rw "+ "-v /var/tmp/lein:/var/tmp/lein:rw "+
"-v /var/tmp/npm:/var/tmp/npm:rw "+ "-v /var/tmp/npm:/var/tmp/npm:rw "
"-v /opt/desktop-files:/opt/desktop-files:rw"
) )
} }
} }
@ -45,7 +44,6 @@ pipeline {
CI_ENVIRONMENT = 'jenkins' CI_ENVIRONMENT = 'jenkins'
LEIN_HOME = '/var/tmp/lein' LEIN_HOME = '/var/tmp/lein'
NIX_CONF_DIR = "${env.WORKSPACE}/scripts/lib/setup/nix" NIX_CONF_DIR = "${env.WORKSPACE}/scripts/lib/setup/nix"
STATUSIM_APPIMAGE_DIR = '/opt/desktop-files'
VERBOSE_LEVEL = '3' VERBOSE_LEVEL = '3'
} }

View File

@ -3,7 +3,7 @@ pipeline {
/* the -u is necessary for acces to /nix */ /* the -u is necessary for acces to /nix */
docker { docker {
label 'linux' label 'linux'
image 'statusteam/nix:jenkins-1.0.0-4a147dc3' image 'statusteam/nix:jenkins-1.0.0-158e62e1'
} }
} }

View File

@ -2,7 +2,7 @@ pipeline {
agent { agent {
docker { docker {
label 'linux-new' label 'linux-new'
image 'statusteam/nix:jenkins-1.0.0-4a147dc3' image 'statusteam/nix:jenkins-1.0.0-158e62e1'
args ( args (
"-v /var/tmp/lein:/var/tmp/lein:rw "+ "-v /var/tmp/lein:/var/tmp/lein:rw "+
"-v /var/tmp/npm:/var/tmp/npm:rw " "-v /var/tmp/npm:/var/tmp/npm:rw "

View File

@ -46,6 +46,8 @@ ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 LANGUAGE=en_US.UTF-8
ARG NIX_VERSION ARG NIX_VERSION
# DEPS_HASH is not used expect for a new image to be created in case some indirect dependency changes (e.g. a download brought by nix-shell)
ARG DEPS_HASH
ARG ANDROID_SDK_VERSION ARG ANDROID_SDK_VERSION
ARG JENKINS_UID ARG JENKINS_UID
ARG JENKINS_GID ARG JENKINS_GID

View File

@ -23,7 +23,9 @@ DEPS_HASH = $(shell $(GIT_ROOT)/scripts/gen-deps-hash.sh -b $(NIX_SHA) \
-d android-sdk \ -d android-sdk \
-d android-sdk-platform \ -d android-sdk-platform \
-d android-sdk-build-tools \ -d android-sdk-build-tools \
-d nix) -d nix \
-d StatusImAppImage \
-d StatusIm-Windows-base-image)
IMAGE_TAG = jenkins-1.0.0-$(DEPS_HASH) IMAGE_TAG = jenkins-1.0.0-$(DEPS_HASH)
IMAGE_NAME = statusteam/nix:$(IMAGE_TAG) IMAGE_NAME = statusteam/nix:$(IMAGE_TAG)
@ -36,6 +38,7 @@ build: $(NIX_INSTALL) $(ANDROID_SDK_ARCHIVE)
--build-arg="ANDROID_SDK_VERSION=$(ANDROID_SDK_VERSION)" \ --build-arg="ANDROID_SDK_VERSION=$(ANDROID_SDK_VERSION)" \
--build-arg="SDK_BUILD_TOOLS_VERSION=$(SDK_BUILD_TOOLS_VERSION)" \ --build-arg="SDK_BUILD_TOOLS_VERSION=$(SDK_BUILD_TOOLS_VERSION)" \
--build-arg="SDK_PLATFORM_VERSION=$(SDK_PLATFORM_VERSION)" \ --build-arg="SDK_PLATFORM_VERSION=$(SDK_PLATFORM_VERSION)" \
--build-arg="DEPS_HASH=$(DEPS_HASH)" \
-t $(IMAGE_NAME) . -t $(IMAGE_NAME) .
$(NIX_INSTALL): $(NIX_INSTALL):

View File

@ -57,11 +57,15 @@ with pkgs;
++ lib.optional targetDesktop statusDesktop.buildInputs ++ lib.optional targetDesktop statusDesktop.buildInputs
++ lib.optional targetMobile statusMobile.buildInputs; ++ lib.optional targetMobile statusMobile.buildInputs;
shellHook = shellHook =
''
set -e
'' +
lib.optionalString targetDesktop statusDesktop.shellHook + lib.optionalString targetDesktop statusDesktop.shellHook +
lib.optionalString targetMobile statusMobile.shellHook + lib.optionalString targetMobile statusMobile.shellHook +
'' ''
if [ -n "$ANDROID_SDK_ROOT" ] && [ ! -d "$ANDROID_SDK_ROOT" ]; then if [ -n "$ANDROID_SDK_ROOT" ] && [ ! -d "$ANDROID_SDK_ROOT" ]; then
./scripts/setup # we assume that if the Android SDK dir does not exist, make setup needs to be run ./scripts/setup # we assume that if the Android SDK dir does not exist, make setup needs to be run
fi fi
set +e
''; '';
} }

View File

@ -4,6 +4,7 @@
;Unicode true ;Unicode true
;!define top_srcdir @top_srcdir@ ;!define top_srcdir @top_srcdir@
;!define base_image_dir ""
;!define srcdir @srcdir@ ;!define srcdir @srcdir@
!define VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} !define VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}
!define VERSION_FULL ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}.0 !define VERSION_FULL ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}.0
@ -626,7 +627,7 @@ Section "Status Desktop" SecMain
File "${top_srcdir}\.env" File "${top_srcdir}\.env"
File "${top_srcdir}\node_modules\node-notifier\vendor\snoreToast\SnoreToast.exe" File "${top_srcdir}\node_modules\node-notifier\vendor\snoreToast\SnoreToast.exe"
File /r "${top_srcdir}\desktop\bin\" File /r "${top_srcdir}\desktop\bin\"
File /r "${top_srcdir}\StatusImPackage\Windows\" File /r "${base_image_dir}"
SetOutPath "$INSTDIR\notifier" SetOutPath "$INSTDIR\notifier"
File "${top_srcdir}\node_modules\node-notifier\vendor\notifu\*.exe" File "${top_srcdir}\node_modules\node-notifier\vendor\notifu\*.exe"

View File

@ -83,7 +83,6 @@ fi
STATUSREACTPATH="$(cd "$SCRIPTPATH" && cd '..' && pwd)" STATUSREACTPATH="$(cd "$SCRIPTPATH" && cd '..' && pwd)"
WORKFOLDER="$(joinExistingPath "$STATUSREACTPATH" 'StatusImPackage')" WORKFOLDER="$(joinExistingPath "$STATUSREACTPATH" 'StatusImPackage')"
STATUSIM_APPIMAGE_ARCHIVE="StatusImAppImage_20181208.zip"
function init() { function init() {
if [ -z $STATUSREACTPATH ]; then if [ -z $STATUSREACTPATH ]; then
@ -193,20 +192,9 @@ function bundleWindows() {
exit 1 exit 1
fi fi
pushd $WORKFOLDER
rm -rf Windows
mkdir Windows
if [ -z $STATUSIM_WINDOWS_BASEIMAGE_ZIP ]; then
STATUSIM_WINDOWS_BASEIMAGE_ZIP=./StatusIm-Windows-base-image.zip
[ -f $STATUSIM_WINDOWS_BASEIMAGE_ZIP ] || wget https://desktop-app-files.ams3.digitaloceanspaces.com/StatusIm-Windows-base-image_20181113.zip -O StatusIm-Windows-base-image.zip
fi
unzip "$STATUSIM_WINDOWS_BASEIMAGE_ZIP" -d Windows/
pushd $STATUSREACTPATH/desktop/bin pushd $STATUSREACTPATH/desktop/bin
rm -rf cmake_install.cmake Makefile CMakeFiles Status_autogen rm -rf cmake_install.cmake Makefile CMakeFiles Status_autogen
popd popd
popd
local compressionAlgo="lzma" local compressionAlgo="lzma"
local compressionType="/SOLID" local compressionType="/SOLID"
@ -217,11 +205,15 @@ function bundleWindows() {
compressionAlgo="zlib" compressionAlgo="zlib"
fi fi
# TODO this needs to be fixed: status-react/issues/5378
local windowsBaseImagePath="$(nix show-derivation -r -f $STATUSREACTPATH | jq -r '.[] | select(.env.name=="StatusIm-Windows-base-image") | .outputs.out.path')/src"
local top_srcdir=$(joinExistingPath "$STATUSREACTPATH" '.') local top_srcdir=$(joinExistingPath "$STATUSREACTPATH" '.')
VERSION_MAJOR="$(cut -d'.' -f1 <<<"$VERSION")" VERSION_MAJOR="$(cut -d'.' -f1 <<<"$VERSION")"
VERSION_MINOR="$(cut -d'.' -f2 <<<"$VERSION")" VERSION_MINOR="$(cut -d'.' -f2 <<<"$VERSION")"
VERSION_BUILD="$(cut -d'.' -f3 <<<"$VERSION")" VERSION_BUILD="$(cut -d'.' -f3 <<<"$VERSION")"
makensis -Dtop_srcdir=${top_srcdir} \ makensis -Dtop_srcdir=${top_srcdir} \
-Dbase_image_dir=${windowsBaseImagePath} \
-DCOMPRESSION_ALGO=${compressionAlgo} \ -DCOMPRESSION_ALGO=${compressionAlgo} \
-DCOMPRESSION_TYPE=${compressionType} \ -DCOMPRESSION_TYPE=${compressionType} \
-DVERSION_MAJOR=$VERSION_MAJOR \ -DVERSION_MAJOR=$VERSION_MAJOR \
@ -239,24 +231,21 @@ function bundleLinux() {
QTBIN=$(joinExistingPath "$QT_PATH" 'bin') QTBIN=$(joinExistingPath "$QT_PATH" 'bin')
fi fi
# invoke linuxdeployqt to create Status.AppImage
echo "Creating AppImage..." echo "Creating AppImage..."
pushd $WORKFOLDER pushd $WORKFOLDER
rm -rf StatusImAppImage rm -rf StatusImAppImage AppDir
# TODO this needs to be fixed: status-react/issues/5378 # TODO this needs to be fixed: status-react/issues/5378
if [ -z $STATUSIM_APPIMAGE_DIR ]; then local baseAppImagePath="$(nix show-derivation -r -f $STATUSREACTPATH | jq -r '.[] | select(.env.name=="StatusImAppImage") | .outputs.out.path')/src"
STATUSIM_APPIMAGE="./${STATUSIM_APPIMAGE_ARCHIVE}" cp -r $baseAppImagePath/StatusImAppImage .
else chmod -R +w StatusImAppImage/
STATUSIM_APPIMAGE="${STATUSIM_APPIMAGE_DIR}/${STATUSIM_APPIMAGE_ARCHIVE}"
fi
[ -f $STATUSIM_APPIMAGE ] || wget "https://desktop-app-files.ams3.digitaloceanspaces.com/${STATUSIM_APPIMAGE_ARCHIVE}" -O $STATUSIM_APPIMAGE
unzip "$STATUSIM_APPIMAGE" -d .
rm -rf AppDir
mkdir AppDir mkdir AppDir
popd popd
qmakePath="$(joinExistingPath "${QTBIN}" 'qmake')" # invoke linuxdeployqt to create Status.AppImage
usrBinPath="$(joinPath "$WORKFOLDER" "AppDir/usr/bin")" local qmakePath="$(joinExistingPath "${QTBIN}" 'qmake')"
local usrBinPath="$(joinPath "$WORKFOLDER" "AppDir/usr/bin")"
cp -r ./deployment/linux/usr $WORKFOLDER/AppDir cp -r ./deployment/linux/usr $WORKFOLDER/AppDir
cp ./.env $usrBinPath cp ./.env $usrBinPath
cp ./desktop/bin/Status ./desktop/bin/reportApp $usrBinPath cp ./desktop/bin/Status ./desktop/bin/reportApp $usrBinPath
@ -264,13 +253,13 @@ function bundleLinux() {
rm -f Application-x86_64.AppImage Status-x86_64.AppImage rm -f Application-x86_64.AppImage Status-x86_64.AppImage
[ $VERBOSE_LEVEL -ge 1 ] && ldd $(joinExistingPath "$usrBinPath" 'Status') [ $VERBOSE_LEVEL -ge 1 ] && ldd $(joinExistingPath "$usrBinPath" 'Status')
desktopFilePath="$(joinExistingPath "$WORKFOLDER" 'AppDir/usr/share/applications/Status.desktop')"
pushd $WORKFOLDER pushd $WORKFOLDER
cp -r assets/share/assets $usrBinPath cp -r assets/share/assets $usrBinPath
cp -rf StatusImAppImage/* $usrBinPath cp -rf StatusImAppImage/* $usrBinPath
rm -f $usrBinPath/Status.AppImage rm -f $usrBinPath/Status.AppImage
popd popd
local desktopFilePath="$(joinExistingPath "$WORKFOLDER" 'AppDir/usr/share/applications/Status.desktop')"
linuxdeployqt \ linuxdeployqt \
$desktopFilePath \ $desktopFilePath \
-verbose=$VERBOSE_LEVEL -always-overwrite -no-strip \ -verbose=$VERBOSE_LEVEL -always-overwrite -no-strip \
@ -450,14 +439,11 @@ fi
function bundleMacOS() { function bundleMacOS() {
pushd $WORKFOLDER pushd $WORKFOLDER
# download prepared package with mac bundle files (it contains qt libraries, icon) # download prepared package with mac bundle files (it contains qt libraries, icon)
echo "Downloading skeleton of mac bundle..."
rm -rf Status.app rm -rf Status.app
# TODO this needs to be fixed: status-react/issues/5378 # TODO this needs to be fixed: status-react/issues/5378
[ -f ./Status.app.zip ] || curl -L -o Status.app.zip https://desktop-app-files.ams3.digitaloceanspaces.com/Status_20181113.app.zip local baseAppImagePath="$(nix show-derivation -r -f $STATUSREACTPATH | jq -r '.[] | select(.env.name=="StatusImAppBundle") | .outputs.out.path')/src"
echo -e "${GREEN}Downloading done.${NC}" cp -r $baseAppImagePath/Status.app .
echo "" chmod -R +w Status.app/
unzip ./Status.app.zip
local contentsPath='Status.app/Contents' local contentsPath='Status.app/Contents'
local usrBinPath=$(joinExistingPath "$WORKFOLDER" "$contentsPath/MacOS") local usrBinPath=$(joinExistingPath "$WORKFOLDER" "$contentsPath/MacOS")

View File

@ -20,7 +20,7 @@ usage () {
deps=() deps=()
while getopts "hb:d:" opt; do while getopts "hb:d:" opt; do
case $opt in case $opt in
b) base_hash="$OPTARG";; b) base_hash="${base_hash}${OPTARG}";;
d) d)
version=$($toolversion "$OPTARG") version=$($toolversion "$OPTARG")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then

View File

@ -8,13 +8,17 @@ let
"linux" = true; "linux" = true;
"" = isLinux; "" = isLinux;
}.${target-os} or false; }.${target-os} or false;
targetDarwin = {
"macos" = true;
"" = isDarwin;
}.${target-os} or false;
targetWindows = { targetWindows = {
"windows" = true; "windows" = true;
"" = isLinux; "" = isLinux;
}.${target-os} or false; }.${target-os} or false;
linuxPlatform = callPackage ./linux { };
darwinPlatform = callPackage ./macos { };
windowsPlatform = callPackage ./windows { }; windowsPlatform = callPackage ./windows { };
appimagekit = callPackage ./appimagekit { };
linuxdeployqt = callPackage ./linuxdeployqt { inherit appimagekit; };
in in
{ {
@ -22,12 +26,14 @@ in
cmake cmake
extra-cmake-modules extra-cmake-modules
file file
gnupg # Used by appimagetool
go go
] ++ lib.optional targetLinux [ appimagekit linuxdeployqt patchelf ] ] ++ lib.optional targetLinux linuxPlatform.buildInputs
++ lib.optional targetDarwin darwinPlatform.buildInputs
++ lib.optional (! targetWindows) qt5.full ++ lib.optional (! targetWindows) qt5.full
++ lib.optional targetWindows windowsPlatform.buildInputs; ++ lib.optional targetWindows windowsPlatform.buildInputs;
shellHook = (if target-os == "windows" then "unset QT_PATH" else '' shellHook = (if target-os == "windows" then ''
unset QT_PATH
'' else ''
export QT_PATH="${qt5.full}" export QT_PATH="${qt5.full}"
export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH" export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH"
'') + (lib.optionalString isDarwin '' '') + (lib.optionalString isDarwin ''

View File

@ -1,7 +1,7 @@
{ stdenv, fetchFromGitHub { stdenv, fetchFromGitHub
, pkgconfig, cmake, autoconf, automake, libtool , pkgconfig, cmake, autoconf, automake, libtool
, wget, xxd, desktop-file-utils, file , wget, xxd, desktop-file-utils, file
, glib, zlib, cairo, openssl, fuse, xz, squashfuse, inotify-tools, libarchive , gnupg, glib, zlib, cairo, openssl, fuse, xz, squashfuse, inotify-tools, libarchive
, squashfsTools , squashfsTools
, gtest , gtest
}: }:
@ -70,6 +70,7 @@ in stdenv.mkDerivation rec {
]; ];
buildInputs = [ buildInputs = [
gnupg
glib zlib cairo openssl fuse glib zlib cairo openssl fuse
xz inotify-tools libarchive xz inotify-tools libarchive
squashfsTools squashfsTools

View File

@ -0,0 +1,32 @@
{ pkgs, stdenv, fetchurl }:
with pkgs;
stdenv.mkDerivation rec {
name = "StatusImAppImage";
version = "20181208";
src =
if stdenv.hostPlatform.system == "x86_64-linux" then
fetchurl {
url = "https://desktop-app-files.ams3.digitaloceanspaces.com/${name}_${version}.zip";
sha256 = "15c6p5v6325kj2whc298dn1dyigi0yzk2nzh1y10d03aqr4j8mp5";
}
else throw "${name} is not supported on ${stdenv.hostPlatform.system}";
nativeBuildInputs = [ unzip ];
phases = [ "unpackPhase" ];
unpackPhase = ''
mkdir -p $out/src
unzip $src -d $out/src
'';
meta = {
description = "A base image for Linux Status Desktop release distributions";
homepage = https://desktop-app-files.ams3.digitaloceanspaces.com/;
license = stdenv.lib.licenses.gpl3;
maintainers = [ stdenv.lib.maintainers.pombeirp ];
platforms = stdenv.lib.platforms.linux;
};
}

View File

@ -0,0 +1,14 @@
{ stdenv, pkgs }:
with pkgs;
with stdenv;
let
baseImage = callPackage ./base-image { };
appimagekit = callPackage ./appimagekit { };
linuxdeployqt = callPackage ./linuxdeployqt { inherit appimagekit; };
in
{
buildInputs = [ appimagekit linuxdeployqt patchelf baseImage ];
}

View File

@ -0,0 +1,32 @@
{ pkgs, stdenv, fetchurl }:
with pkgs;
stdenv.mkDerivation rec {
name = "StatusImAppBundle";
version = "20181113";
src =
if stdenv.hostPlatform.system == "x86_64-darwin" then
fetchurl {
url = "https://desktop-app-files.ams3.digitaloceanspaces.com/Status_${version}.app.zip";
sha256 = "0n8n6p60dwsr4q5v4vq8fffcy5qmqhp03yy95k66q4yic72r0hhz";
}
else throw "${name} is not supported on ${stdenv.hostPlatform.system}";
nativeBuildInputs = [ unzip ];
phases = [ "unpackPhase" ];
unpackPhase = ''
mkdir -p $out/src
unzip $src -d $out/src
'';
meta = {
description = "A base image for macOS Status Desktop release distributions";
homepage = https://desktop-app-files.ams3.digitaloceanspaces.com/;
license = stdenv.lib.licenses.gpl3;
maintainers = [ stdenv.lib.maintainers.pombeirp ];
platforms = stdenv.lib.platforms.darwin;
};
}

View File

@ -0,0 +1,12 @@
{ stdenv, pkgs }:
with pkgs;
with stdenv;
let
baseImage = callPackage ./base-image { };
in
{
buildInputs = [ baseImage ];
}

View File

@ -0,0 +1,40 @@
{ pkgs, stdenv, fetchurl }:
with pkgs;
stdenv.mkDerivation rec {
name = "StatusIm-Windows-base-image";
version = "20181113";
src =
if stdenv.hostPlatform.system == "x86_64-linux" then
fetchurl {
url = "https://desktop-app-files.ams3.digitaloceanspaces.com/${name}_${version}.zip";
sha256 = "1wrxcss63zlwspmw76k549z72hcycxzd9iw4cdh98l4hs2ayzsk3";
}
else throw "${name} is not supported on ${stdenv.hostPlatform.system}";
nativeBuildInputs = [ unzip ];
phases = [ "unpackPhase" "installPhase" ];
unpackPhase = ''
mkdir -p $out/src
unzip $src -d $out/src
'';
installPhase = ''
runHook preInstall
echo $out
ls $out -al
runHook postInstall
'';
meta = {
description = "A base image for Windows Status Desktop release distributions";
homepage = https://desktop-app-files.ams3.digitaloceanspaces.com/;
license = stdenv.lib.licenses.gpl3;
maintainers = [ stdenv.lib.maintainers.pombeirp ];
platforms = stdenv.lib.platforms.linux;
};
}

View File

@ -3,6 +3,10 @@
with pkgs; with pkgs;
with stdenv; with stdenv;
let
baseImage = callPackage ./base-image { };
in
{ {
buildInputs = lib.optional isLinux [ conan nsis ]; buildInputs = lib.optional isLinux [ conan nsis baseImage ];
} }