appimage.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env bash
  2. ########################################################################
  3. # Package the binaries built on Travis-CI as an AppImage
  4. # By Joseph Lenox 2017
  5. # For more information, see http://appimage.org/
  6. # Assumes that the results from make_archive are present.
  7. ########################################################################
  8. source $(dirname $0)/../common/util.sh
  9. set_version
  10. get_commit
  11. set_build_id
  12. set_branch
  13. set_app_name
  14. set_pr_id
  15. WD=${PWD}/$(dirname $0)
  16. srcfolder="$WD/${appname}"
  17. export ARCH=$(arch)
  18. APP=Slic3r
  19. LOWERAPP=${APP,,}
  20. mkdir -p $WD/${APP}.AppDir/usr/
  21. wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
  22. . ./functions.sh
  23. cd $WD/${APP}.AppDir
  24. mkdir -p $WD/${APP}.AppDir/usr/bin
  25. # Copy primary Slic3r script here and perl-local, as well as var
  26. for i in {var,Slic3r}; do
  27. cp -R $srcfolder/$i $WD/${APP}.AppDir/usr/bin/
  28. done
  29. mkdir -p ${WD}/${APP}.AppDir/usr/lib
  30. # copy Slic3r local-lib here
  31. for i in $(ls $srcfolder/bin); do
  32. install -v $srcfolder/bin/$i ${WD}/${APP}.AppDir/usr/lib
  33. done
  34. # copy other libraries needed to /usr/lib because this is an AppImage build.
  35. for i in $(cat $WD/libpaths.appimage.txt | grep -v "^#" | awk -F# '{print $1}'); do
  36. install -v $i ${WD}/${APP}.AppDir/usr/lib
  37. done
  38. cat > $WD/${APP}.AppDir/AppRun << 'EOF'
  39. #!/usr/bin/env bash
  40. # some magic to find out the real location of this script dealing with symlinks
  41. DIR=`readlink "$0"` || DIR="$0";
  42. DIR=`dirname "$DIR"`;
  43. cd "$DIR"
  44. DIR=`pwd`
  45. cd - > /dev/null
  46. # disable parameter expansion to forward all arguments unprocessed to the VM
  47. set -f
  48. # run the VM and pass along all arguments as is
  49. LD_LIBRARY_PATH="$DIR/usr/lib" "${DIR}/usr/bin/perl-local" -I"${DIR}/usr/lib/local-lib/lib/perl5" "${DIR}/usr/bin/slic3r.pl" --gui "$@"
  50. EOF
  51. chmod +x AppRun
  52. cp ${WD}/${APP}.AppDir/usr/bin/var/Slic3r_192px_transparent.png $WD/${APP}.AppDir/${APP}.png
  53. cat > $WD/${APP}.AppDir/${APP}.desktop <<EOF
  54. [Desktop Entry]
  55. Type=Application
  56. Name=$APP
  57. Icon=$APP
  58. Exec=AppRun
  59. Categories=Graphics;
  60. X-Slic3r-Version=$SLIC3R_VERSION
  61. Comment=Prepare 3D Models for Printing
  62. EOF
  63. cd ..
  64. wget "https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
  65. chmod a+x appimagetool-x86_64.AppImage
  66. ./appimagetool-x86_64.AppImage Slic3r.AppDir
  67. # If we're on a branch, add the branch name to the app name.
  68. if [ "$current_branch" == "master" ]; then
  69. if [ ! -z ${PR_ID+x} ]; then
  70. outfile=Slic3r-${SLIC3R_BUILD_ID}-PR${PR_ID}-${1}.AppImage
  71. else
  72. outfile=Slic3r-${SLIC3R_BUILD_ID}-${1}.AppImage
  73. fi
  74. else
  75. outfile=Slic3r-${SLIC3R_BUILD_ID}-${current_branch}-${1}.AppImage
  76. fi
  77. mv Slic3r-x86_64.AppImage ${WD}/../../${outfile}