AppImageCommunity / pkg2appimage

Tool and recipes to convert existing deb packages to AppImage
http://appimage.org
MIT License
699 stars 216 forks source link

Building an OpenRA AppImage: how to make a persistent symlink in the AppImage #106

Open fusion809 opened 8 years ago

fusion809 commented 8 years ago

Hi,

I've been working on an OpenRA AppImage and I think I'm close to it working. The problem is that the mono-runtime package it uses to provide the mono command relies on a symlink to mono-sgen in order to provide the mono command. This symlink is lost whenever I built an AppImage. This is my present recipe:

#!/bin/bash

# In this case the upstream project seems to already
# provide binaries that are supposed to run everywhere,
# so we merely package these as an AppImage

set +e

APP=OpenRA
LOWERAPP=${APP,,}
VERSION="release-20161015"
URL="https://github.com/OpenRA/OpenRA/releases/download/${VERSION}/openra_${VERSION//-/.}_all.deb"
rm -rf ./$APP/$APP.AppDir

mkdir -p ./$APP/$APP.AppDir/usr/bin
mkdir -p ./$APP/$APP.AppDir/usr/lib
cd ./$APP

wget -c "$URL"

wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
. ./functions.sh

generate_status

echo "deb http://archive.ubuntu.com/ubuntu/ trusty main universe
" > sources.list

apt-get $OPTIONS update

URLS=$(apt-get $OPTIONS -y install --print-uris libopenal1 mono-runtime libmono-system-core4.0-cil libmono-system-drawing4.0-cil libmono-system-data4.0-cil libmono-system-numerics4.0-cil libmono-system-runtime-serialization4.0-cil libmono-system-xml-linq4.0-cil libmono-i18n4.0-all libfreetype6 libc6 libasound2 libgl1-mesa-glx libgl1-mesa-dri xdg-utils zenity liblua5.1-0 | cut -d "'" -f 2 | grep -e "^http" )

printf "URLS is \n:$URLS"
wget -c $URLS

wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppRun" # (64-bit)
chmod a+x ./AppRun

cd ./$APP.AppDir/

find ../*.deb -exec dpkg -x {} . \; || true

# The following three lines are what I am attempting to use to fix this symlink issue, unsuccessfully I might add
cd usr/bin
ln -sf mono-sgen mono
cd -

get_desktop
get_icon
get_apprun

rm -rf ./etc/ ./home/ || true

# patch_usr
# Patching only the executable files seems not to be enough for some apps
find usr/ -type f -exec sed -i -e "s|/usr|././|g" {} \;

wget -O ./usr/bin/$LOWERAPP.wrapper https://raw.githubusercontent.com/probonopd/AppImageKit/master/desktopintegration
chmod a+x ./usr/bin/$LOWERAPP.wrapper

cd ..
wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppImageAssistant" # (64-bit)
chmod a+x ./AppImageAssistant
mkdir -p ../out
if [[ -f ../out/$APP"-"$VERSION"-x86_64.AppImage" ]]; then
  rm ../out/$APP"-"$VERSION"-x86_64.AppImage" || true
fi
./AppImageAssistant ./$APP.AppDir/ ../out/$APP"-"$VERSION"-x86_64.AppImage"

Any ideas?

Thanks for your time, Brenton

fusion809 commented 8 years ago

Now I have the Recipe:

#!/bin/bash

# In this case the upstream project seems to already
# provide binaries that are supposed to run everywhere,
# so we merely package these as an AppImage

set +e

APP=OpenRA
LOWERAPP=${APP,,}
VERSION="release-20161015"
URL="https://github.com/OpenRA/OpenRA/releases/download/${VERSION}/openra_${VERSION//-/.}_all.deb"
rm -rf ./$APP/$APP.AppDir

mkdir -p ./$APP/$APP.AppDir/usr/bin
mkdir -p ./$APP/$APP.AppDir/usr/lib
cd ./$APP

wget -c "$URL"

wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
. ./functions.sh

generate_status

echo "deb http://archive.ubuntu.com/ubuntu/ trusty main universe
" > sources.list

apt-get $OPTIONS update

URLS=$(apt-get $OPTIONS -y install --print-uris libopenal1 libmono-corlib2.0-cil mono-runtime libmono-system-core4.0-cil libmono-system-drawing4.0-cil libmono-system-data4.0-cil libmono-system-numerics4.0-cil libmono-system-runtime-serialization4.0-cil libmono-system-xml-linq4.0-cil libmono-i18n4.0-all libfreetype6 libc6 libasound2 libgl1-mesa-glx libgl1-mesa-dri xdg-utils zenity liblua5.1-0 | cut -d "'" -f 2 | grep -e "^http" )

printf "URLS is \n:$URLS"
wget -c $URLS

wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppRun" # (64-bit)
chmod a+x ./AppRun

cd ./$APP.AppDir/

find ../*.deb -exec dpkg -x {} . \; || true

cd usr/games
echo '#!/bin/sh
cd "././/lib/openra"
mono --debug OpenRA.Game.exe "$@"
if [ $? != 0 -a $? != 1 ]
then
ZENITY=`which zenity` || echo "OpenRA needs zenity installed to display a graphical error dialog. See ~/.openra. for log files."
$ZENITY --question --title "OpenRA" --text "OpenRA has encountered a fatal error.
Log Files are available in ~/.openra." --ok-label "Quit" --cancel-label "View FAQ" || xdg-open https://github.com/OpenRA/OpenRA/wiki/FAQ
exit 1
fi' > openra
chmod +x openra
cd ../../lib/openra
ln -sf ../../usr/bin/mono-sgen mono
cd ../..

get_desktop
get_icon
get_apprun

rm -rf ./etc/ ./home/ || true

# patch_usr
# Patching only the executable files seems not to be enough for some apps
find usr/ -type f -exec sed -i -e "s|/usr|././|g" {} \;

wget -O ./usr/bin/$LOWERAPP.wrapper https://raw.githubusercontent.com/probonopd/AppImageKit/master/desktopintegration
chmod a+x ./usr/bin/$LOWERAPP.wrapper

cd ..
wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppImageAssistant" # (64-bit)
chmod a+x ./AppImageAssistant
mkdir -p ../out
if [[ -f ../out/$APP"-"$VERSION"-x86_64.AppImage" ]]; then
  rm ../out/$APP"-"$VERSION"-x86_64.AppImage" || true
fi
./AppImageAssistant ./$APP.AppDir/ ../out/$APP"-"$VERSION"-x86_64.AppImage"

and the error I am getting whenever I run it is:

./games//openra: 3: ./games//openra: mono: not found
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged

So yeah, I am kind of stumped on how to fix this error. Any ideas?

probonopd commented 8 years ago

Please request an OpenRA AppImage from the upstream application authors. I'm happy to help upstreams package their apps as AppImages, but I can't really help on arbitrary apps with no support from the people who know how the app works :-)

fusion809 commented 8 years ago

Done https://github.com/OpenRA/OpenRA/issues/12257.

probonopd commented 8 years ago

Added a yml file for OpenRA: https://github.com/probonopd/AppImages/blob/master/recipes/meta/OpenRA.yml

The game starts to launch on Ubuntu 16.04, but game files fail to be found and/or downloaded. I did not investigate this futher; someone who knows how the game works should take over from here on.

probonopd commented 8 years ago

@fusion809 can you ask the upstream team to have a look at this? Thanks

probonopd commented 8 years ago

Ping @fusion809 did you ask upstream about this?

fusion809 commented 8 years ago

The upstream issue OpenRA/OpenRA#12257 is already pelleted with references to this issue. Didn't think I'd have to add yet another one, rofl.

pchote commented 8 years ago

The game starts to launch on Ubuntu 16.04, but game files fail to be found and/or downloaded. I did not investigate this futher; someone who knows how the game works should take over from here on.

Do you mean the individual mod assets, or the core OpenRA files?

OpenRA expects read/write access to ~/.openra/ for storing userdata. This includes the original game assets (in ~/.openra/Content/) as well as the usual settings, custom maps, replays, etc. I'm not familiar with how AppImages work, but I guess that you will need to whitelist this somewhere?

probonopd commented 8 years ago

The AppImage has no problems writing to ~/.openra. But it wants to download something and fails. I can send you an URL if you want to give it a try, just let me know.