Skip to content

Commit

Permalink
Merge pull request #84 from tkashkin/master
Browse files Browse the repository at this point in the history
Merge master -> dev
  • Loading branch information
tkashkin authored Sep 23, 2018
2 parents 3802672 + aa60f85 commit f193fb6
Show file tree
Hide file tree
Showing 20 changed files with 324 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [GameHub](https://tkashkin.tk/projects/gamehub) [![Build Status](https://travis-ci.com/tkashkin/GameHub.svg?branch=master)](https://travis-ci.com/tkashkin/GameHub)
# [GameHub](https://tkashkin.tk/projects/gamehub) [![Build status](https://ci.appveyor.com/api/projects/status/cgw5hc4kos4uvmy9/branch/master?svg=true)](https://ci.appveyor.com/project/tkashkin/gamehub/branch/master)
Games manager/downloader/library written in Vala for elementary OS

## Game sources
Expand Down
25 changes: 16 additions & 9 deletions appimage/AppRun
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/sh
#!/bin/bash

export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${LD_LIBRARY_PATH}"
export PATH="${APPDIR}/usr/bin:${PATH}"
export XDG_DATA_DIRS="${APPDIR}/usr/share:${XDG_DATA_DIRS}"
echo "[AppRun ] GameHub AppImage"
echo "[AppRun ] AppDir: $APPDIR"

export GSETTINGS_SCHEMA_DIR="${APPDIR}/usr/share/glib-2.0/schemas/:${GSETTINGS_SCHEMA_DIR}"
export GTK_PATH="${APPDIR}/usr/lib/gtk-3.0"
export GTK_DATA_PREFIX="${APPDIR}/usr/"
#export GTK_THEME="Adwaita"
export LD_LIBRARY_PATH="$APPDIR/usr/lib:$LD_LIBRARY_PATH"
export PATH="$APPDIR/usr/bin:$PATH"
export XDG_DATA_DIRS="$APPDIR/usr/share:$XDG_DATA_DIRS"

"${APPDIR}/usr/bin/com.github.tkashkin.gamehub" "$@"
export GSETTINGS_SCHEMA_DIR="$APPDIR/usr/share/glib-2.0/schemas/:$GSETTINGS_SCHEMA_DIR"

export LD_LIBRARY_PATH="$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0:$LD_LIBRARY_PATH"

[ -e "$APPDIR/checkrt.sh" ] && . "$APPDIR/checkrt.sh" || echo "[AppRun] Skipping CheckRT"

echo "[AppRun ] Starting GameHub"

cd "$APPDIR/usr"
"$APPDIR/usr/bin/com.github.tkashkin.gamehub" "$@"
153 changes: 148 additions & 5 deletions appimage/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,84 @@ _ROOT="`pwd`"
_SCRIPTROOT="$(dirname "$(readlink -f "$0")")"
_LINUXDEPLOYQT="linuxdeployqt-continuous-x86_64.AppImage"

_SOURCE="${APPVEYOR_BUILD_VERSION:-local}"
_VERSION="$_SOURCE-$(git rev-parse --short HEAD)"
_BUILD_IMAGE="local"

if [[ "$APPVEYOR_BUILD_WORKER_IMAGE" = "Ubuntu1604" ]]; then
_VERSION="xenial-$_VERSION"
_BUILD_IMAGE="xenial"
elif [[ "$APPVEYOR_BUILD_WORKER_IMAGE" = "Ubuntu1804" ]]; then
_VERSION="bionic-$_VERSION"
_BUILD_IMAGE="bionic"
fi

BUILDROOT="$_ROOT/build/appimage"
BUILDDIR="$BUILDROOT/build"
APPDIR="$BUILDROOT/appdir"

ACTION=${1:-build_local}
CHECKRT=${2:---checkrt}

_usr_patch()
{
set +e
file="$1"
echo "[appimage/build.sh] Patching $file"
sed -i -e 's#/usr#././#g' "$file"
}

_mv_deps()
{
set +e
lib="$1"
src="$2"
dest="$3"
recursive=${4:-true}
echo "[appimage/build.sh] Moving $lib"
[ -e "$src/$lib" ] && mv -f "$src/$lib" "$dest"
[ -e "$dest/$lib" ] && ldd "$dest/$lib" | awk '{print $1}' | while read dep; do
[ -e "$src/$dep" ] && echo "[appimage/build.sh] $dep <- $lib"
if [ "$recursive" = "true" ]; then
[ -e "$src/$dep" ] && _mv_deps "$dep" "$src" "$dest" "$recursive"
else
[ -e "$src/$dep" ] && mv -f "$src/$dep" "$dest"
fi
done
}

deps()
{
set +e
echo "[appimage/build.sh] Installing dependencies"
sudo add-apt-repository ppa:elementary-os/stable -y
sudo add-apt-repository ppa:elementary-os/os-patches -y
sudo add-apt-repository ppa:elementary-os/daily -y
sudo add-apt-repository ppa:vala-team/next -y
sudo apt update -qq
sudo apt install -y meson valac checkinstall build-essential elementary-sdk libgranite-dev libgtk-3-dev libglib2.0-dev libwebkit2gtk-4.0-dev libjson-glib-dev libgee-0.8-dev libsoup2.4-dev libsqlite3-dev libxml2-dev
sudo apt full-upgrade -y
if [[ "$APPVEYOR_BUILD_WORKER_IMAGE" = "Ubuntu1604" ]]; then
sudo dpkg -i "$_SCRIPTROOT/deps/xenial/"*.deb
fi
}

build_deb()
{
set -e
echo "[appimage/build.sh] Building deb package"
cd "$_ROOT"
export DEB_BUILD_OPTIONS="nostrip,nocheck"
dpkg-buildpackage -b -us -uc
mkdir -p "build/$_BUILD_IMAGE"
mv ../*.deb "build/$_BUILD_IMAGE/GameHub-$_VERSION-amd64.deb"
cd "$_ROOT"
}

build()
{
set -e
echo "[appimage/build.sh] Building"
cd "$_ROOT"
mkdir -p "$BUILDROOT"
meson "$BUILDDIR" --prefix=/usr --buildtype=debugoptimized -Ddistro=generic -Dappimage=true
Expand All @@ -33,28 +93,111 @@ build()

appimage()
{
set -e
echo "[appimage/build.sh] Preparing AppImage"
cd "$BUILDROOT"
wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/$_LINUXDEPLOYQT"
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
chmod a+x "./$_LINUXDEPLOYQT"
unset QTDIR; unset QT_PLUGIN_PATH; unset LD_LIBRARY_PATH
export VERSION=$(git rev-parse --short HEAD)
export VERSION="$_VERSION"
export LD_LIBRARY_PATH=$APPDIR/usr/lib:$LD_LIBRARY_PATH
"./$_LINUXDEPLOYQT" "$APPDIR/usr/share/applications/com.github.tkashkin.gamehub.desktop" -appimage -bundle-non-qt-libs -verbose=2
"./$_LINUXDEPLOYQT" "$APPDIR/usr/share/applications/com.github.tkashkin.gamehub.desktop" -appimage -no-plugins -no-copy-copyright-files -verbose=2
}

appimage_tweak()
{
set -e
echo "[appimage/build.sh] Tweaking AppImage"
cd "$BUILDROOT"
rm -f "$APPDIR/AppRun"
cp -f "$_SCRIPTROOT/AppRun" "$APPDIR/AppRun"
glib-compile-schemas "$APPDIR/usr/share/glib-2.0/schemas"
}

appimage_bundle_libs()
{
set +e
echo "[appimage/build.sh] Bundling additional libs"
cd "$BUILDROOT"

mkdir -p "$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/"
cp -rf "/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/injected-bundle/" "$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/"
cp -f "/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/WebKitNetworkProcess" "$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/"
cp -f "/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/WebKitStorageProcess" "$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/"
cp -f "/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/WebKitWebProcess" "$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/"
find "$APPDIR/usr/lib/" -maxdepth 1 -type f -name "libwebkit2gtk-4.0.so.*" -print0 | while read -d $'\0' file; do
_usr_patch "$file"
done
find "$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/" -maxdepth 1 -type f -print0 | while read -d $'\0' file; do
_usr_patch "$file"
done
}

appimage_checkrt()
{
set +e
echo "[appimage/build.sh] Bundling checkrt libs"
cd "$BUILDROOT"
cp -f "$_SCRIPTROOT/checkrt.sh" "$APPDIR/checkrt.sh"
cp -rf "$_SCRIPTROOT/optlib" "$APPDIR/usr/"

echo "[appimage/build.sh] Moving GTK and its dependencies"
mkdir -p "$APPDIR/usr/optlib/libgtk-3.so.0/"
_mv_deps "libgtk-3.so.0" "$APPDIR/usr/lib" "$APPDIR/usr/optlib/libgtk-3.so.0/"

echo "[appimage/build.sh] Moving back non-GTK-specific dependencies"
find "$APPDIR/usr/lib/" -maxdepth 1 -type f -not -name "libgranite.so.*" -not -name "libwebkit2gtk-4.0.so.*" -print0 | while read -d $'\0' dep; do
_mv_deps "$(basename $dep)" "$APPDIR/usr/optlib/libgtk-3.so.0" "$APPDIR/usr/lib/" "false"
done

if [[ "$APPVEYOR_BUILD_WORKER_IMAGE" = "Ubuntu1804" ]]; then
echo "[appimage/build.sh] Removing GTK and its dependencies"
rm -rf "$APPDIR/usr/optlib/libgtk-3.so.0"
fi

for lib in 'libstdc++.so.6' 'libgcc_s.so.1'; do
echo "[appimage/build.sh] Bundling $lib"
mkdir -p "$APPDIR/usr/optlib/$lib"
for dir in "/lib" "/usr/lib"; do
libfile="$dir/x86_64-linux-gnu/$lib"
[ -e "$libfile" ] && cp "$libfile" "$APPDIR/usr/optlib/$lib/"
done
done
}

appimage_pack()
{
set -e
echo "[appimage/build.sh] Packing AppImage"
cd "$BUILDROOT"
unset QTDIR; unset QT_PLUGIN_PATH; unset LD_LIBRARY_PATH
export VERSION="$_VERSION"
export LD_LIBRARY_PATH=$APPDIR/usr/lib:$LD_LIBRARY_PATH
"./$_LINUXDEPLOYQT" --appimage-extract
PATH=./squashfs-root/usr/bin:$PATH ./squashfs-root/usr/bin/appimagetool "$APPDIR"
PATH=./squashfs-root/usr/bin:$PATH ./squashfs-root/usr/bin/appimagetool --no-appstream "$APPDIR"
}

upload()
{
set -e
echo "[appimage/build.sh] Uploading AppImage"
cd "$BUILDROOT"
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
bash upload.sh GameHub*.AppImage*
bash upload.sh "$_ROOT/build/$_BUILD_IMAGE/*.deb" GameHub*.AppImage*
}

mkdir -p "$BUILDROOT"

if [[ "$ACTION" = "deps" ]]; then deps; fi

if [[ "$ACTION" = "build_deb" ]]; then build_deb; fi

if [[ "$ACTION" = "build" || "$ACTION" = "build_local" ]]; then build; fi

if [[ "$ACTION" = "appimage" || "$ACTION" = "build_local" ]]; then appimage; fi
if [[ "$ACTION" = "appimage_tweak" || "$ACTION" = "build_local" ]]; then appimage_tweak; fi
if [[ "$ACTION" = "appimage_bundle_libs" || "$ACTION" = "build_local" ]]; then appimage_bundle_libs; fi
if [[ "$ACTION" = "appimage_checkrt" || ( "$ACTION" = "build_local" && "$CHECKRT" = "--checkrt" ) ]]; then appimage_checkrt; fi
if [[ "$ACTION" = "appimage_pack" || "$ACTION" = "build_local" ]]; then appimage_pack; fi

if [[ "$ACTION" = "upload" ]]; then upload; fi
55 changes: 55 additions & 0 deletions appimage/checkrt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

_CRT_LIB_PATH=""

echo "[CheckRT] Checking library versions"

_CRT_LIBS=(
'libstdc++.so.6':'^GLIBCXX_[0-9]\.[0-9]'
'libgcc_s.so.1':'^GCC_[0-9]\.[0-9]'
)

_CRT_LIBS_PREFER_SYSTEM=(
'libgtk-3.so.0':'^gtk_scrolled_window_set_propagate_natural_width' # GTK 3.22+
)

for lib in ${_CRT_LIBS[@]}; do
lib_filename=$(echo "$lib" | cut -d: -f1)
version_prefix=$(echo "$lib" | cut -d: -f2)
lib_dir="$APPDIR/usr/optlib/$lib_filename"
lib_path="$lib_dir/$lib_filename"
if [ -e "$lib_path" ]; then
lib=$(PATH="/sbin:$PATH" ldconfig -p | grep "$lib_filename" | awk 'NR==1 {print $NF}')
sym_sys=$(tr '\0' '\n' < "$lib" | grep -e "$version_prefix" | tail -n1)
sym_app=$(tr '\0' '\n' < "$lib_path" | grep -e "$version_prefix" | tail -n1)
echo "[CheckRT] $lib_filename: sys: $sym_sys; app: $sym_app"
if [ z$(printf "$sym_sys\n$sym_app" | sort -V | tail -1) != z"$sym_sys" ]; then
_CRT_LIB_PATH="$lib_dir:$_CRT_LIB_PATH"
fi
fi
done

for lib in ${_CRT_LIBS_PREFER_SYSTEM[@]}; do
lib_filename=$(echo "$lib" | cut -d: -f1)
version_prefix=$(echo "$lib" | cut -d: -f2)
lib_dir="$APPDIR/usr/optlib/$lib_filename"
lib_path="$lib_dir/$lib_filename"
if [ -e "$lib_path" ]; then
lib=$(PATH="/sbin:$PATH" ldconfig -p | grep "$lib_filename" | awk 'NR==1 {print $NF}')
sym_sys=$(tr '\0' '\n' < "$lib" | grep -e "$version_prefix" | tail -n1)
if [ -z "$sym_sys" ]; then
_CRT_LIB_PATH="$lib_dir:$_CRT_LIB_PATH"
else
echo "[CheckRT] Using system version of $lib_filename"
fi
fi
done

export LD_LIBRARY_PATH="$_CRT_LIB_PATH:$LD_LIBRARY_PATH"

if [ -e "$APPDIR/usr/optlib/exec.so" ]; then
export LD_PRELOAD="$APPDIR/usr/optlib/exec.so:$LD_PRELOAD"
fi

echo "[CheckRT] LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
echo "[CheckRT] LD_PRELOAD: $LD_PRELOAD"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added appimage/deps/xenial/libkrb5-3_1.16-2_amd64.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added appimage/optlib/exec.so
Binary file not shown.
37 changes: 31 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
version: 0.11.1-{build}-{branch}

pull_requests:
do_not_increment_build_number: true

skip_tags: true

branches:
except:
- flatpak

image:
- Ubuntu1804
- Ubuntu1604

clone_folder: ~/GameHub
clone_folder: ~/build/GameHub
clone_depth: 1

build_script:
- sh: dpkg-buildpackage -b -us -uc
- sh: bash appimage/build.sh build && bash appimage/build.sh appimage
- sh: bash appimage/build.sh build_deb
- sh: bash appimage/build.sh build
- sh: bash appimage/build.sh appimage
- sh: bash appimage/build.sh appimage_tweak
- sh: bash appimage/build.sh appimage_bundle_libs
- sh: bash appimage/build.sh appimage_checkrt
- sh: bash appimage/build.sh appimage_pack

install:
- sh: bash appimage/build.sh deps

test: off

artifacts:
- path: ~/com.github.tkashkin.gamehub*.deb
- path: build/*/*.deb
name: deb
- path: ~/com.github.tkashkin.gamehub*.ddeb
name: deb-dbgsym
- path: build/appimage/GameHub*.AppImage*
name: AppImage

deploy:
- provider: GitHub
description: |
CI build
* Use `bionic` packages for recent distros (>= Ubuntu 18.04)
* Use `xenial` packages for older distros (>= Ubuntu 16.04)
auth_token:
secure: J2LCcNeVYvzbvHRa/LChp+SmN6UKbg1ELsA4jmxnObCbX+ZyZ9DFH+S2aQIoA3dG
artifact: deb,AppImage
draft: false
prerelease: true
5 changes: 5 additions & 0 deletions data/com.github.tkashkin.gamehub.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
</screenshots>

<releases>
<release type="development" version="0.11.1" date="2018-09-19">
<description>
<p>Updated pt_BR localization</p>
</description>
</release>
<release type="development" version="0.11.0" date="2018-09-18">
<description>
<ul>
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
com.github.tkashkin.gamehub (0.11.1) xenial; urgency=low

* Updated pt_BR localization

-- tkashkin <tkashkin@gmail.com> Wed, 19 Sep 2018 03:19:47 +0300

com.github.tkashkin.gamehub (0.11.0) xenial; urgency=low

* Humble Trove support
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.11.0')
project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.11.1')

i18n = import('i18n')
gnome = import('gnome')
Expand Down
Loading

0 comments on commit f193fb6

Please sign in to comment.