appimage.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.pl,perl-local}; 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. cp -R $srcfolder/local-lib ${WD}/${APP}.AppDir/usr/lib/local-lib
  39. cat > $WD/${APP}.AppDir/AppRun << 'EOF'
  40. #!/usr/bin/env bash
  41. # some magic to find out the real location of this script dealing with symlinks
  42. DIR=`readlink "$0"` || DIR="$0";
  43. DIR=`dirname "$DIR"`;
  44. cd "$DIR"
  45. DIR=`pwd`
  46. cd - > /dev/null
  47. # disable parameter expansion to forward all arguments unprocessed to the VM
  48. set -f
  49. # run the VM and pass along all arguments as is
  50. 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 "$@"
  51. EOF
  52. chmod +x AppRun
  53. cp ${WD}/${APP}.AppDir/usr/bin/var/Slic3r_192px_transparent.png $WD/${APP}.AppDir/${APP}.png
  54. cat > $WD/${APP}.AppDir/${APP}.desktop <<EOF
  55. [Desktop Entry]
  56. Type=Application
  57. Name=$APP
  58. Icon=$APP
  59. Exec=AppRun
  60. Categories=Graphics;
  61. X-Slic3r-Version=$SLIC3R_VERSION
  62. Comment=Prepare 3D Models for Printing
  63. EOF
  64. cd ..
  65. wget "https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
  66. chmod a+x appimagetool-x86_64.AppImage
  67. ./appimagetool-x86_64.AppImage Slic3r.AppDir
  68. # If we're on a branch, add the branch name to the app name.
  69. if [ "$current_branch" == "master" ]; then
  70. if [ ! -z ${PR_ID+x} ]; then
  71. outfile=Slic3r-${SLIC3R_BUILD_ID}-PR${PR_ID}-${1}.AppImage
  72. else
  73. outfile=Slic3r-${SLIC3R_BUILD_ID}-${1}.AppImage
  74. fi
  75. else
  76. outfile=Slic3r-${SLIC3R_BUILD_ID}-${current_branch}-${1}.AppImage
  77. fi
  78. mv Slic3r-x86_64.AppImage ${WD}/../../${outfile}