make_archive.sh 4.6 KB

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