make_archive.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/bash
  2. # Assembles an installation archive from a built copy of Slic3r.
  3. # Requires PAR::Packer to be installed for the version of
  4. # perl copied.
  5. # Adapted from script written by bubnikv for Prusa3D.
  6. # Run from slic3r repo root directory.
  7. if [ "$#" -ne 1 ]; then
  8. echo "Usage: $(basename $0) arch_name"
  9. exit 1;
  10. fi
  11. libdirs=$(find ./local-lib -iname *.so -exec dirname {} \; | sort -u | paste -sd ";" -)
  12. WD=./$(dirname $0)
  13. source $(dirname $0)/../common/util.sh
  14. # Determine if this is a tagged (release) commit.
  15. # Change the build id accordingly.
  16. set_version
  17. get_commit
  18. set_build_id
  19. set_branch
  20. set_app_name
  21. set_pr_id
  22. install_par
  23. # If we're on a branch, add the branch name to the app name.
  24. if [ "$current_branch" == "master" ]; then
  25. if [ ! -z ${PR_ID+x} ]; then
  26. dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}-PR${PR_ID}.tar.bz2
  27. else
  28. dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}.tar.bz2
  29. fi
  30. else
  31. dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}-${current_branch}.tar.bz2
  32. fi
  33. rm -rf $WD/_tmp
  34. mkdir -p $WD/_tmp
  35. # Set the application folder infomation.
  36. appfolder="$WD/${appname}"
  37. archivefolder=$appfolder
  38. resourcefolder=$appfolder
  39. echo "Appfolder: $appfolder, archivefolder: $archivefolder"
  40. # Our slic3r dir and location of perl
  41. PERL_BIN=$(which perl)
  42. PP_BIN=$(which pp)
  43. SLIC3R_DIR="./"
  44. if [[ -d "${appfolder}" ]]; then
  45. echo "Deleting old working folder: ${appfolder}"
  46. rm -rf ${appfolder}
  47. fi
  48. if [[ -e "${dmgfile}" ]]; then
  49. echo "Deleting old archive: ${dmgfile}"
  50. rm -rf ${dmgfile}
  51. fi
  52. echo "Creating new app folder: $appfolder"
  53. mkdir -p $appfolder
  54. echo "Copying resources..."
  55. cp -rf $SLIC3R_DIR/var $resourcefolder/
  56. echo "Copying Slic3r..."
  57. cp $SLIC3R_DIR/slic3r.pl $archivefolder/slic3r.pl
  58. cp -fRP $SLIC3R_DIR/local-lib $archivefolder/local-lib
  59. cp -fRP $SLIC3R_DIR/lib/* $archivefolder/local-lib/lib/perl5/
  60. mkdir $archivefolder/bin
  61. echo "Installing libraries to $archivefolder/bin ..."
  62. if [ -z ${WXDIR+x} ]; then
  63. for bundle in $(find $archivefolder/local-lib/lib/perl5 -name '*.so' | grep "Wx") $(find $archivefolder/local-lib/lib/perl5 -name '*.so' -type f | grep "wxWidgets"); do
  64. echo "$(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}')"
  65. for dylib in $(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}'); do
  66. install -v $dylib $archivefolder/bin
  67. done
  68. done
  69. else
  70. echo "Copying libraries from $WXDIR/lib to $archivefolder/bin"
  71. for dylib in $(find $WXDIR/lib | grep "so"); do
  72. cp -P -v $dylib $archivefolder/bin
  73. done
  74. fi
  75. echo "Copying startup script..."
  76. cp -f $WD/startup_script.sh $archivefolder/$appname
  77. chmod +x $archivefolder/$appname
  78. echo "Copying perl from $PERL_BIN"
  79. # Edit package/common/coreperl to add/remove core Perl modules added to this package, one per line.
  80. cp -f $PERL_BIN $archivefolder/perl-local
  81. ${PP_BIN} wxextension .0 \
  82. -M $(grep -v "^#" ${WD}/../common/coreperl | xargs | awk 'BEGIN { OFS=" -M "}; {$1=$1; print $0}') \
  83. -B -p -e "print 123" -o $WD/_tmp/test.par
  84. unzip -qq -o $WD/_tmp/test.par -d $WD/_tmp/
  85. cp -rf $WD/_tmp/lib/* $archivefolder/local-lib/lib/perl5/
  86. cp -rf $WD/_tmp/shlib $archivefolder/
  87. rm -rf $WD/_tmp
  88. for i in $(cat $WD/libpaths.txt | grep -v "^#" | awk -F# '{print $1}'); do
  89. install -v $i $archivefolder/bin
  90. done
  91. echo "Cleaning local-lib"
  92. rm -rf $archivefolder/local-lib/bin
  93. rm -rf $archivefolder/local-lib/man
  94. rm -f $archivefolder/local-lib/lib/perl5/Algorithm/*.pl
  95. rm -rf $archivefolder/local-lib/lib/perl5/unicore
  96. rm -rf $archivefolder/local-lib/lib/perl5/App
  97. rm -rf $archivefolder/local-lib/lib/perl5/Devel/CheckLib.pm
  98. rm -rf $archivefolder/local-lib/lib/perl5/ExtUtils
  99. rm -rf $archivefolder/local-lib/lib/perl5/Module/Build*
  100. rm -rf $(pwd)$archivefolder/local-lib/lib/perl5/TAP
  101. rm -rf $(pwd)/$archivefolder/local-lib/lib/perl5/Test*
  102. find $(pwd)/$archivefolder/local-lib -type d -path '*/Wx/*' \( -name WebView \
  103. -or -name DocView -or -name STC -or -name IPC \
  104. -or -name Calendar -or -name DataView \
  105. -or -name DateTime -or -name Media -or -name PerlTest \
  106. -or -name Ribbon \) -exec rm -rf "{}" \;
  107. rm -rf $archivefolder/local-lib/lib/perl5/*/Alien/wxWidgets/*/include
  108. find $archivefolder/local-lib -depth -type d -empty -exec rmdir "{}" \;
  109. tar -C$(pwd)/$(dirname $appfolder) -cjf $(pwd)/$dmgfile "$appname"