-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_appimage.sh
executable file
·95 lines (80 loc) · 2.6 KB
/
build_appimage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# App name
PROJECT_NAME=$(grep 'APP_NAME' ./src/utils/constant.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs)
VERSION=$(grep '__version__' ./src/version.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs)
BITCOIN_NETWORK=$(grep '__network__' ./src/flavour.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs)
echo $BITCOIN_NETWORK
APPDIR="AppDir"
ICON_DIR="$APPDIR/usr/share/icons/hicolor/256x256/apps"
ICON_NAME="iriswallet.png"
PROJECT_NAME_WITH_VERSION="${PROJECT_NAME}-${VERSION}"
#remove already exits file and dir
rm -rf build
rm -rf dist
rm -rf AppDir
rm -rf *.AppImage # Full path to the icon file
# Ensure the necessary development packages are installed
#if ! dpkg -s python3-dev &> /dev/null; then
# echo "python3.12-dev not found. Installing..."
# sudo apt-get install python3-dev
#fi
# Ensure the libfuse2 package is installed
#if ! dpkg -s libfuse2 &> /dev/null; then
# echo "libfuse2 not found. Installing..."
# sudo apt-get install libfuse2
#fi
# Ensure the AppImage tools are installed
if ! command -v appimagetool &> /dev/null; then
echo "appimagetool not found. Downloading..."
wget -q https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
if [ ! -f appimagetool-x86_64.AppImage ]; then
echo "Error: Failed to download appimagetool."
exit 1
fi
chmod +x appimagetool-x86_64.AppImage
APPIMAGETOOL=./appimagetool-x86_64.AppImage
else
APPIMAGETOOL=$(which appimagetool)
fi
# Run PyInstaller
poetry run pyinstaller iris_wallet_desktop.spec
# Verify the build was successful
if [ ! -d "dist/$PROJECT_NAME" ]; then
echo "Error: PyInstaller build failed."
exit 1
fi
# Create AppDir structure
mkdir -p $APPDIR/usr/bin
mkdir -p $ICON_DIR
# Copy application files
cp -r dist/$PROJECT_NAME/* $APPDIR/usr/bin/
# Copy icon
cp ./src/assets/icons/$BITCOIN_NETWORK-icon.png $ICON_DIR/$ICON_NAME
cp ./src/assets/icons/$BITCOIN_NETWORK-icon.png $APPDIR/iriswallet_icon.png
# Create .desktop file
cat > $APPDIR/$PROJECT_NAME.desktop << EOF
[Desktop Entry]
Name=$PROJECT_NAME_WITH_VERSION
Exec=AppRun
Icon=iriswallet_icon
Type=Application
Categories=Utility;
EOF
# Create AppRun file
cat > $APPDIR/AppRun << EOF
#!/bin/bash
HERE="\$(dirname "\$(readlink -f "\${0}")")"
# Set environment variables for file paths
export XDG_DOWNLOAD_DIR="\$HOME/Downloads"
exec "\$HERE/usr/bin/$PROJECT_NAME" "\$@"
EOF
chmod +x $APPDIR/AppRun
# Build the AppImage
if [ -f "$APPIMAGETOOL" ]; then
echo "Building AppImage..."
$APPIMAGETOOL $APPDIR
else
echo "Error: appimagetool not found."
exit 1
fi
echo "AppImage created successfully."