Skip to content

Commit

Permalink
package logicrs as appimage
Browse files Browse the repository at this point in the history
  • Loading branch information
Spydr06 committed Apr 3, 2023
1 parent d915ab8 commit 3b3cb04
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 518 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Cargo.lock
vendor/
gtk4-rs/
.vs/
*.zip
*.zip
*.AppImage
*.lrsmod
98 changes: 98 additions & 0 deletions make-appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)

pushd $SCRIPT_DIR

#
# Build Project
#

BUILD_DIR="target"
BIN="$BUILD_DIR/release/logicrs"

cargo build --release

if [ ! -f $BIN ]; then
echo "Release build was not successful."
exit 1
fi

#
# Create AppDir
#

APP_DIR="$BUILD_DIR/appimage/logicrs.AppDir"
if [ -d $APP_DIR ]; then
rm -rf $APP_DIR
fi

mkdir -p $APP_DIR/usr/{bin,lib,share/icons}
cp $BIN $APP_DIR/usr/bin/logicrs

# Copy binary
sed -i -e 's#/usr#././#g' $APP_DIR/usr/bin/logicrs

# Collect libraries
mkdir -p $APP_DIR/usr/lib

LIB_PATH="/usr/lib64"
IFS=' ' read -ra LIBRARIES <<< $(pkg-config --libs gtk4 libadwaita-1)
for i in "${LIBRARIES[@]}"; do
LIB_FILE="lib${i:2}.so"
if [ ! -f $LIB_PATH/$LIB_FILE ]; then
echo "could not find \`$LIB_FILE\` in \`$LIB_PATH\`"
fi
cp $LIB_PATH/$LIB_FILE $APP_DIR/usr/lib/$LIB_FILE
done

# Patch binaries
pushd $APP_DIR/usr/lib
find . -type f -exec sed -i -e 's#/usr#././#g' {} \;
popd

#
# Generate Icons
#

DIR_ICON=".DirIcon"

RELEASE_ICON_FILE="style/icons/hicolor/com.spydr06.logicrs.svg"
DEBUG_ICON_FILE="style/icons/hicolor/com.spydr06.logicrs.Devel.svg"
ICON_FILE=$DEBUG_ICON_FILE

inkscape -z -w 256 -h 256 "$ICON_FILE" -o $APP_DIR/$DIR_ICON.png
if [ ! -f $APP_DIR/$DIR_ICON.png ]; then
echo "Icon generation was not successful."
exit 1
fi
mv $APP_DIR/$DIR_ICON.png $APP_DIR/$DIR_ICON

cp $ICON_FILE $APP_DIR/logicrs.svg

ICONS_DIR=$APP_DIR/usr/share/icons
mkdir -p $ICONS_DIR
cp $ICON_FILE $ICONS_DIR/logicrs.svg

SNIPPETS_DIR="snippets"

#
# Prepare AppDir
#

# Copy desktop file
DESKTOP_FILE="com.spydr06.logicrs.desktop"
cp $SNIPPETS_DIR/$DESKTOP_FILE $APP_DIR/$DESKTOP_FILE

# Create build directory
BUILD_DIR="target/appimage"
mkdir -p $BUILD_DIR

#
# Generate AppImage
#

RECIPE_FILE="$SNIPPETS_DIR/AppImageBuilder.yml"
appimage-builder --recipe $RECIPE_FILE --appdir $APP_DIR --build-dir $BUILD_DIR

popd
14 changes: 14 additions & 0 deletions snippets/AppImageBuilder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 1

AppDir:
path: ./logicrs.AppDir

app_info:
id: com.spydr06.logicrs
name: logicrs
icon: logicrs
version: '0.1'
exec: usr/bin/logicrs

AppImage:
arch: x86_64
15 changes: 15 additions & 0 deletions snippets/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

SELF=$(readlink -f "$0")
HERE=${SELF%/*}

export PATH="${HERE}/usr/bin/:${HERE}/usr/sbin/:${HERE}/usr/games/:${HERE}/bin/:${HERE}/sbin/${PATH:+:$PATH}"
export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/:${HERE}/lib32/:${HERE}/lib64/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PYTHONPATH="${HERE}/usr/share/pyshared/${PYTHONPATH:+:$PYTHONPATH}"
export XDG_DATA_DIRS="${HERE}/usr/share/${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
export PERLLIB="${HERE}/usr/share/perl5/:${HERE}/usr/lib/perl5/${PERLLIB:+:$PERLLIB}"
export GSETTINGS_SCHEMA_DIR="${HERE}/usr/share/glib-2.0/schemas/${GSETTINGS_SCHEMA_DIR:+:$GSETTINGS_SCHEMA_DIR}"
export QT_PLUGIN_PATH="${HERE}/usr/lib/qt4/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt4/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt4/plugins/:${HERE}/usr/lib32/qt4/plugins/:${HERE}/usr/lib64/qt4/plugins/:${HERE}/usr/lib/qt5/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt5/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt5/plugins/:${HERE}/usr/lib32/qt5/plugins/:${HERE}/usr/lib64/qt5/plugins/${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}"

EXEC=${HERE}/usr/bin/logicrs
exec "${EXEC}" "$@"
11 changes: 11 additions & 0 deletions snippets/com.spydr06.logicrs.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=LogicRs
GenericName=LogicRs
Comment=Logic Simulator
Exec=AppRun
Icon=logicrs
Terminal=false
Categories=X-programming;X-coding;X-education;
Keywords=math;logic;programming;coding;education;
2 changes: 1 addition & 1 deletion src/application/gactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl Application {
.filter(&Project::file_filter())
.cancel_label("Cancel")
.build();

save_dialog.connect_response({
let file_chooser = RefCell::new(Some(save_dialog.clone()));
glib::clone!(@weak self as app => move |_, response| {
Expand Down
Loading

0 comments on commit 3b3cb04

Please sign in to comment.