make_archive.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. if [[ ! -z "$PERL_BIN" ]]; then
  42. PERL_BIN=$(which perl)
  43. fi
  44. if [[! -z "$PP_BIN" ]]; then
  45. PP_BIN=$(which pp)
  46. fi
  47. SLIC3R_DIR="./"
  48. if [[ -d "${appfolder}" ]]; then
  49. echo "Deleting old working folder: ${appfolder}"
  50. rm -rf ${appfolder}
  51. fi
  52. if [[ -e "${dmgfile}" ]]; then
  53. echo "Deleting old archive: ${dmgfile}"
  54. rm -rf ${dmgfile}
  55. fi
  56. echo "Creating new app folder: $appfolder"
  57. mkdir -p $appfolder
  58. echo "Copying resources..."
  59. cp -rf $SLIC3R_DIR/var $resourcefolder/
  60. echo "Copying Slic3r..."
  61. cp $SLIC3R_DIR/slic3r.pl $archivefolder/slic3r.pl
  62. cp -fRP $SLIC3R_DIR/local-lib $archivefolder/local-lib
  63. cp -fRP $SLIC3R_DIR/lib/* $archivefolder/local-lib/lib/perl5/
  64. mkdir $archivefolder/bin
  65. echo "Installing libraries to $archivefolder/bin ..."
  66. if [ -z ${WXDIR+x} ]; then
  67. 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
  68. echo "$(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}')"
  69. for dylib in $(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}'); do
  70. install -v $dylib $archivefolder/bin
  71. done
  72. done
  73. else
  74. echo "Copying libraries from $WXDIR/lib to $archivefolder/bin"
  75. for dylib in $(find $WXDIR/lib | grep "so"); do
  76. cp -P -v $dylib $archivefolder/bin
  77. done
  78. fi
  79. echo "Copying startup script..."
  80. cp -f $WD/startup_script.sh $archivefolder/$appname
  81. chmod +x $archivefolder/$appname
  82. echo "Copying perl from $PERL_BIN"
  83. # Edit package/common/coreperl to add/remove core Perl modules added to this package, one per line.
  84. cp -f $PERL_BIN $archivefolder/perl-local
  85. ${PP_BIN} wxextension .0 \
  86. -M $(grep -v "^#" ${WD}/../common/coreperl | xargs | awk 'BEGIN { OFS=" -M "}; {$1=$1; print $0}') \
  87. -B -p -e "print 123" -o $WD/_tmp/test.par
  88. unzip -qq -o $WD/_tmp/test.par -d $WD/_tmp/
  89. cp -rf $WD/_tmp/lib/* $archivefolder/local-lib/lib/perl5/
  90. cp -rf $WD/_tmp/shlib $archivefolder/
  91. rm -rf $WD/_tmp
  92. for i in $(cat $WD/libpaths.txt | grep -v "^#" | awk -F# '{print $1}'); do
  93. install -v $i $archivefolder/bin
  94. done
  95. echo "Cleaning local-lib"
  96. rm -rf $archivefolder/local-lib/bin
  97. rm -rf $archivefolder/local-lib/man
  98. rm -f $archivefolder/local-lib/lib/perl5/Algorithm/*.pl
  99. rm -rf $archivefolder/local-lib/lib/perl5/unicore
  100. rm -rf $archivefolder/local-lib/lib/perl5/App
  101. rm -rf $archivefolder/local-lib/lib/perl5/Devel/CheckLib.pm
  102. rm -rf $archivefolder/local-lib/lib/perl5/ExtUtils
  103. rm -rf $archivefolder/local-lib/lib/perl5/Module/Build*
  104. rm -rf $(pwd)$archivefolder/local-lib/lib/perl5/TAP
  105. rm -rf $(pwd)/$archivefolder/local-lib/lib/perl5/Test*
  106. find $(pwd)/$archivefolder/local-lib -type d -path '*/Wx/*' \( -name WebView \
  107. -or -name DocView -or -name STC -or -name IPC \
  108. -or -name Calendar -or -name DataView \
  109. -or -name DateTime -or -name Media -or -name PerlTest \
  110. -or -name Ribbon \) -exec rm -rf "{}" \;
  111. rm -rf $archivefolder/local-lib/lib/perl5/*/Alien/wxWidgets/*/include
  112. find $archivefolder/local-lib -depth -type d -empty -exec rmdir "{}" \;
  113. tar -C$(pwd)/$(dirname $appfolder) -cjf $(pwd)/$dmgfile "$appname"