123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #!/bin/bash
- # Assembles an installation archive from a built copy of Slic3r.
- # Requires PAR::Packer to be installed for the version of
- # perl copied.
- # Adapted from script written by bubnikv for Prusa3D.
- # Run from slic3r repo root directory.
- if [ "$#" -lt 1 ]; then
- echo "Usage: $(basename $0) arch_name [source_dir]"
- echo "source_dir is the path to Slic3r's main directory. Default: $(pwd)"
- exit 1;
- fi
- echo "WD: $(dirname $0)"
- WD=./$(dirname $0)
- source $(dirname $0)/../common/util.sh
- # Determine if this is a tagged (release) commit.
- # Change the build id accordingly.
- set_source_dir $2
- set_version
- get_commit
- set_build_id
- set_branch
- set_app_name
- set_pr_id
- install_par
- libdirs=$(find ${SLIC3R_DIR}/local-lib -iname *.so -exec dirname {} \; | sort -u | paste -sd ";" -)
- # If we're on a branch, add the branch name to the app name.
- if [ "$current_branch" == "master" ]; then
- if [ ! -z ${PR_ID+x} ]; then
- dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}-PR${PR_ID}.tar.bz2
- else
- dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}.tar.bz2
- fi
- else
- dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}-${current_branch}.tar.bz2
- fi
- rm -rf $WD/_tmp
- mkdir -p $WD/_tmp
- # Set the application folder infomation.
- appfolder="$WD/${appname}"
- archivefolder=$appfolder
- resourcefolder=$appfolder
- echo "Appfolder: $appfolder, archivefolder: $archivefolder, resourcefolder=$resourcefolder"
- # Our slic3r dir and location of perl
- if [[ -z ${PERL_BIN+x} ]]; then
- PERL_BIN=$(which perl)
- echo "Found perl at $PERL_BIN"
- fi
- if [[ -z ${PP_BIN+x} ]]; then
- PP_BIN=$(which pp)
- echo "Found pp at $PP_BIN"
- fi
- if [[ -d "${appfolder}" ]]; then
- echo "Deleting old working folder: ${appfolder}"
- rm -rf ${appfolder}
- fi
- if [[ -e "${dmgfile}" ]]; then
- echo "Deleting old archive: ${dmgfile}"
- rm -rf ${dmgfile}
- fi
- echo "Creating new app folder: $appfolder"
- mkdir -p $appfolder
- echo "Copying resources... from ${SLIC3R_DIR}/var to $resourcefolder"
- cp -rf ${SLIC3R_DIR}/var $resourcefolder/
- echo "Copying Slic3r..."
- cp $SLIC3R_DIR/slic3r.pl $archivefolder/slic3r.pl
- cp -fRP $SLIC3R_DIR/local-lib $archivefolder/local-lib
- cp -fRP $SLIC3R_DIR/lib/* $archivefolder/local-lib/lib/perl5/
- mkdir $archivefolder/bin
- echo "Installing libraries to $archivefolder/bin ..."
- if [ -z ${WXDIR+x} ]; then
- 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
- echo "$(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}')"
- for dylib in $(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}'); do
- install -v $dylib $archivefolder/bin
- done
- done
- else
- echo "Copying libraries from $WXDIR/lib to $archivefolder/bin"
- for dylib in $(find $WXDIR/lib | grep "so"); do
- cp -P -v $dylib $archivefolder/bin
- done
- fi
- echo "Copying startup script..."
- cp -f $WD/startup_script.sh $archivefolder/$appname
- chmod +x $archivefolder/$appname
- echo "Copying perl from $PERL_BIN"
- # Edit package/common/coreperl to add/remove core Perl modules added to this package, one per line.
- cp -f $PERL_BIN $archivefolder/perl-local
- ${PP_BIN} wxextension .0 \
- -M $(grep -v "^#" ${WD}/../common/coreperl | xargs | awk 'BEGIN { OFS=" -M "}; {$1=$1; print $0}') \
- -B -p -e "print 123" -o $WD/_tmp/test.par
- unzip -qq -o $WD/_tmp/test.par -d $WD/_tmp/
- cp -rf $WD/_tmp/lib/* $archivefolder/local-lib/lib/perl5/
- cp -rf $WD/_tmp/shlib $archivefolder/
- rm -rf $WD/_tmp
- for i in $(cat $WD/libpaths.txt | grep -v "^#" | awk -F# '{print $1}'); do
- install -v $i $archivefolder/bin
- done
- echo "Cleaning local-lib"
- rm -rf $archivefolder/local-lib/bin
- rm -rf $archivefolder/local-lib/man
- rm -f $archivefolder/local-lib/lib/perl5/Algorithm/*.pl
- rm -rf $archivefolder/local-lib/lib/perl5/unicore
- rm -rf $archivefolder/local-lib/lib/perl5/App
- rm -rf $archivefolder/local-lib/lib/perl5/Devel/CheckLib.pm
- rm -rf $archivefolder/local-lib/lib/perl5/ExtUtils
- rm -rf $archivefolder/local-lib/lib/perl5/Module/Build*
- rm -rf $archivefolder/local-lib/lib/perl5/TAP
- rm -rf $archivefolder/local-lib/lib/perl5/Test*
- find $archivefolder/local-lib -type d -path '*/Wx/*' \( -name WebView \
- -or -name DocView -or -name STC -or -name IPC \
- -or -name Calendar -or -name DataView \
- -or -name DateTime -or -name Media -or -name PerlTest \
- -or -name Ribbon \) -exec rm -rf "{}" \;
- rm -rf $archivefolder/local-lib/lib/perl5/*/Alien/wxWidgets/*/include
- find $archivefolder/local-lib -depth -type d -empty -exec rmdir "{}" \;
- echo "Archiving from $appfolder"
- tar -C$WD -cjf $(pwd)/$dmgfile "$(basename $appfolder)"
|