Created
October 18, 2021 16:16
-
-
Save naveenadi/8dbe75c04cae7739f5cce0a260eb3e08 to your computer and use it in GitHub Desktop.
Create AppImage from Flutter App Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
export ARCH=$(uname -m) | |
echo "INFO:Generator:Searching AppDir" | |
read -p "? ID [Eg: com.example.app]: " appId | |
read -p "? Application Name: " appName | |
read -p "? Icon: " appIcon | |
read -p "? Executable path relative to AppDir [usr/bin/app]: " appExec | |
# read -p "? Arguments [Default: $@]: " appExec_args | |
read -p "? Version [Eg: 1.0.0]: " appVersion | |
# read -p "? Update Information [Default: guess]: " guess | |
# read -p "? Architecture: " x86_64 | |
function download_appimagetool() { | |
if [ ! -d ./appimage-build ]; then mkdir ./appimage-build; fi | |
if [ ! -x ./appimage-build/appimagetool-$ARCH.AppImage ]; then | |
curl -L -o ./appimage-build/appimagetool-$ARCH.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$ARCH.AppImage | |
chmod a+x ./appimage-build/appimagetool-$ARCH.AppImage | |
fi | |
} | |
function create_appdir() { | |
if [ -d "$appName.AppDir" ]; then rm -rf $appName.AppDir; fi | |
mkdir $appName.AppDir | |
} | |
function after_bundle() { | |
cp build/linux/x64/release/bundle/assistant $appName.AppDir | |
cp -r build/linux/x64/release/bundle/lib/. $appName.AppDir/lib | |
cp -r build/linux/x64/release/bundle/data $appName.AppDir | |
# cp $appIcon AppDir/usr/share/icons/ | |
# cp -r build/linux/*/release/bundle/ $appName.AppDir | |
# if [[ $(file -b "$appIcon.[ps]*g") =~ ]]; | |
if [ ! -b "$appIcon.[ps]*g" ]; then | |
cp $appIcon.[ps]*g $appName.AppDir | |
# mkdir -p $appName.AppDir/usr/share/icons/ | |
# cp $appIcon.[ps]*g $appName.AppDir/usr/share/icons/ | |
fi | |
} | |
function create_apprun() { | |
touch AppRun | |
echo -e '#!/bin/sh\n\ncd "$(dirname "$0")"\nexec ./'$appExec'' > AppRun | |
chmod +x AppRun | |
mv AppRun $appName.AppDir | |
} | |
function create_desktop() { | |
local de="[Desktop Entry]" | |
local xaa="X-AppImage-Arch=$ARCH" | |
local xav="X-AppImage-Version=$appVersion" | |
local xan="X-AppImage-Name=$appName" | |
local v="Version=1.0" | |
local ty="Type=Application" | |
local te="Terminal=false" | |
local n="Name=$appName" | |
local e="Exec=$appExec %u" | |
local i="Icon=$appIcon" | |
local ca="Categories=Utility;" | |
local co="Comment=" | |
touch $appId.desktop | |
echo -e "$de\n$xaa\n$xav\n$xan\n$v\n$ty\n$te\n$n\n$e\n$i\n$ca\n$co" > $appId.desktop | |
mv $appId.desktop $appName.AppDir | |
} | |
function build_appimage() { | |
# the build command itself: | |
./appimage-build/appimagetool-$ARCH.AppImage $appName.AppDir | |
# move result in build folder | |
mv $appName-$ARCH.AppImage ./appimage-build/$appName-$appVersion-$ARCH.AppImage | |
} | |
download_appimagetool | |
create_appdir | |
after_bundle | |
create_apprun | |
create_desktop | |
build_appimage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment