howto_py_appimage.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #Step 0: Prepare your system
  2. #Install git and virtualenv:
  3. sudo apt install git python-virtualenv
  4. #Install the build dependencies for Python 2.7.13:
  5. sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline-gplv2-dev libssl-dev libdb-dev
  6. #Install the build dependencies for pygame:
  7. sudo apt-get install libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev libv4l-dev python-dev mercurial
  8. #We need to set one symbolic link to make sure that pygame can be compiled correctly.
  9. cd /usr/include/linux
  10. sudo ln -s ../libv4l1-videodev.h videodev.h
  11. cd ~
  12. #Step 1: Setup the building enviorment
  13. #First we need to declare some variables:
  14. APP=Labyrinth
  15. LOWERAPP=${APP,,}
  16. VERSION=0.1.1
  17. ARCH=i686
  18. #Now we have to get a little script which will provide us some extra functionalities for the bash.
  19. wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
  20. #By default this script is made for x86_64 mashines. So, if we want to build our AppImage for another platform we need to do an extra step.
  21. sed -i -e 's/x86_64/$ARCH/g' functions.sh
  22. #Now we can run the script.
  23. . ./functions.sh
  24. #And now we create some directories.
  25. mkdir -p $APP/$APP.AppDir/usr
  26. cd $APP/$APP.AppDir
  27. #Next we can get Python 2.7.13 and compile it.
  28. wget http://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
  29. tar -xzf Python-2.7.13.tgz
  30. rm Python-2.7.13.tgz
  31. cd Python-2.7.13
  32. ./configure --prefix=$HOME/$APP/$APP.AppDir/usr #the prefix is important for this whole thing to work
  33. make && make install
  34. cd ..
  35. rm -r Python-2.7.13
  36. #Now we add pip to our installation
  37. wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
  38. $HOME/$APP/$APP.AppDir/usr/bin/python ./get-pip.py
  39. rm ./get-pip.py
  40. #Now we should have a working Python installation inside ./usr
  41. #We can check this by typing: ./usr/bin/python
  42. #In the next step we will add pygame to our local Python installtion.
  43. hg clone https://bitbucket.org/pygame/pygame
  44. cd pygame
  45. $HOME/$APP/$APP.AppDir/usr/bin/python ./setup.py build
  46. $HOME/$APP/$APP.AppDir/usr/bin/python ./setup.py install
  47. cd ..
  48. rm -r pygame
  49. #At this point we should have a working Python installation which includes pygame.
  50. #Maybe it would be a good idea to make a backup uf this.
  51. #Now let us add the game itself.
  52. git clone --depth 1 https://gitlab.com/ericxdu/labyrinth-demo
  53. cp -r ./labyrinth-demo/* ./usr/bin
  54. rm -r -f ./labyrinth-demo
  55. chmod a+x ./usr/bin/play.py #I am not sure if this really needs to be done.
  56. #Step 2: Building the AppImage
  57. #First let us create another little shellscript. This one will be part of our Appimage.
  58. #Inside this script we can set enviorment variables or pass options to your programm (like in this little example).
  59. cat > usr/bin/$LOWERAPP <<\EOF
  60. #!/bin/sh
  61. play.py --fullscreen
  62. EOF
  63. chmod a+x usr/bin/$LOWERAPP
  64. #Now we use one of the new functions to get an AppRun executable.
  65. get_apprun
  66. #Next we have to generate a dektop entry.
  67. cat > $LOWERAPP.desktop <<EOF
  68. [Desktop Entry]
  69. Name=$APP
  70. Exec=$LOWERAPP
  71. Icon=$LOWERAPP
  72. Category=Game
  73. Comment=A labyrinth game by Eric Duhamel.
  74. EOF
  75. #With this command we allow the AppImage to ask for desktop integration.
  76. get_desktopintegration $LOWERAPP
  77. #Now we need a icon file.
  78. cp usr/bin/data/Game_Icon.png $LOWERAPP.png
  79. #Time to let the magic happen!
  80. copy_deps ; copy_deps ; copy_deps
  81. move_lib
  82. LIBPULSE=$(find -name libpulsecommon-9.0.so)
  83. PARENT=${LIBPULSE/'pulseaudio/libpulsecommon-9.0.so'/}
  84. cp $LIBPULSE $PARENT
  85. cd ..
  86. generate_appimage