diff --git a/packaging/macos/osxbuild.sh b/packaging/macos/osxbuild.sh index 1e39906e80..8b0b3945fe 100755 --- a/packaging/macos/osxbuild.sh +++ b/packaging/macos/osxbuild.sh @@ -1,415 +1,416 @@ #!/usr/bin/env sh # Stop at any error # For debug purposes # set -e # set -x # osxbuild.sh automates building and installing of krita and krita dependencies # for OSX, the script only needs you to set BUILDROOT environment to work # properly. # # Run with no args for a short help about each command. # builddeps: Attempts to build krita dependencies in the necessary order, # intermediate steps for creating symlinks and fixing rpath of some # packages midway is also managed. Order goes from top to bottom, to add # new steps just place them in the proper place. # rebuilddeps: This re-runs all make and make install of dependencies 3rdparty # this was needed as deleting the entire install directory an rerunning build # step for dependencies does not install if they are already built. This step # forces installation. Have not tested it lately so it might not be needed anymore # build: Runs cmake build and make step for krita sources. It always run cmake step, so # it might take a bit longer than a pure on the source tree. The script tries # to set the make flag -jN to a proper N. # install: Runs install step for krita sources. # fixboost: Search for all libraries using boost and sets a proper @rpath for boost as by # default it fails to set a proper @rpath # buildinstall: Runs build, install and fixboost steps. if test -z $BUILDROOT; then echo "ERROR: BUILDROOT env not set, exiting!" echo "\t Must point to the root of the buildfiles as stated in 3rdparty Readme" exit fi echo "BUILDROOT set to ${BUILDROOT}" export KIS_SRC_DIR=${BUILDROOT}/krita export KIS_TBUILD_DIR=${BUILDROOT}/depbuild export KIS_TDEPINSTALL_DIR=${BUILDROOT}/depinstall export KIS_DOWN_DIR=${BUILDROOT}/down export KIS_BUILD_DIR=${BUILDROOT}/kisbuild export KIS_INSTALL_DIR=${BUILDROOT}/i # flags for OSX environment # We only support from 10.11 up export MACOSX_DEPLOYMENT_TARGET=10.11 export QMAKE_MACOSX_DEPLOYMENT_TARGET=10.11 # Build time variables if test -z $(which cmake); then echo "ERROR: cmake not found, exiting!" exit fi export PATH=${KIS_INSTALL_DIR}/bin:$PATH export C_INCLUDE_PATH=${KIS_INSTALL_DIR}/include:${C_INCLUDE_PATH} export CPLUS_INCLUDE_PATH=${KIS_INSTALL_DIR}/include:${CPLUS_INCLUDE_PATH} export LIBRARY_PATH=${KIS_INSTALL_DIR}/lib:${LIBRARY_PATH} # export CPPFLAGS=-I${KIS_INSTALL_DIR}/include # export LDFLAGS=-L${KIS_INSTALL_DIR}/lib export PYTHONHOME=${KIS_INSTALL_DIR} # export PYTHONPATH=${KIS_INSTALL_DIR}/sip:${KIS_INSTALL_DIR}/lib/python3.5/site-packages:${KIS_INSTALL_DIR}/lib/python3.5 # This will make the debug output prettier export KDE_COLOR_DEBUG=1 export QTEST_COLORED=1 +DEPBUILD_LOG="${BUILDROOT}/builddeps_.log" # configure max core for make compile ((MAKE_THREADS=1)) if test ${OSTYPE} == "darwin*"; then ((MAKE_THREADS = $(sysctl -n hw.ncpu) - 1)) fi -errorlog () { - if [ $1 -ne 0 ]; then - printf "%s\n" "$2" >> "${BUILDROOT}/builddeps_error.log" - exit +# Prints log to file +# $2 error message +# $3 success message +build_errorlog () { + if [[ "${1}" -ne 0 ]]; then + printf "ERROR: %s\n" "$2" >> ${DEPBUILD_LOG} + else + printf "OK: %s\n" "$3" >> ${DEPBUILD_LOG} fi + echo ${1} } + check_dir_path () { printf "%s" "Checking if ${1} exists and is dir... " if test -d ${1}; then echo "OK" return 0 elif test -e ${1}; then echo "\n\tERROR: file ${1} exists but is not a directory!" return 1 else echo "Creating ${1}" mkdir ${1} fi return 0 } # builds dependencies for the first time +osxbuild_count=0 +cmake_3rdparty () { + cd ${KIS_TBUILD_DIR} + for package in ${@:1:${#@}}; do + printf "STATUS: %s\n" "Building ${package}" + cmake --build . --config RelWithDebInfo --target ${package} 2>> "${BUILDROOT}/builddeps_.log" + local build_error=$(build_errorlog ${?} "Failed build ${package}" "Build Success! ${package}") + + # run package fixes + if [[ ${osxbuild_count} -eq 0 ]]; then + build_3rdparty_fixes ${package} + fi + done + # global + osxbuild_count=0 +} + +build_3rdparty_fixes(){ + osxbuild_count=$((${osxbuild_count} + 1)) + pkg=${1} + if [[ "${pkg}" = "ext_qt" ]]; then + ln -sf qmake "${KIS_INSTALL_DIR}/bin/qmake-qt5" + + elif [[ "${pkg}" = "ext_openexr" ]]; then + # open exr will fail the first time is called + # rpath needs to be fixed an build rerun + echo "Fixing rpath on openexr file: b44ExpLogTable" + echo "Fixing rpath on openexr file: dwaLookups" + install_name_tool -add_rpath ${KIS_INSTALL_DIR}/lib ${KIS_TBUILD_DIR}/ext_openexr/ext_openexr-prefix/src/ext_openexr-build/IlmImf/./b44ExpLogTable + install_name_tool -add_rpath ${KIS_INSTALL_DIR}/lib ${KIS_TBUILD_DIR}/ext_openexr/ext_openexr-prefix/src/ext_openexr-build/IlmImf/./dwaLookups + # we must rerun build! + cmake_3rdparty ext_openexr + fi +} + build_3rdparty () { echo "building in ${KIS_TBUILD_DIR}" check_dir_path ${KIS_TBUILD_DIR} check_dir_path ${KIS_DOWN_DIR} check_dir_path ${KIS_INSTALL_DIR} cd ${KIS_TBUILD_DIR} cmake ${KIS_SRC_DIR}/3rdparty/ \ -DCMAKE_INSTALL_PREFIX=${KIS_INSTALL_DIR} \ -DEXTERNALS_DOWNLOAD_DIR=${KIS_DOWN_DIR} \ -DINSTALL_ROOT=${KIS_INSTALL_DIR} # -DCPPFLAGS=-I${KIS_INSTALL_DIR}/include \ # -DLDFLAGS=-L${KIS_INSTALL_DIR}/lib echo "finished 3rdparty build setup" # make preinstall echo "finished make step" - cmake_3rdparty () { - for package in ${@:1:${#@}}; do - echo "Building ${package}" - cmake --build . --config RelWithDebInfo --target ${package} - errorlog $? "failed build ${package}" - done - } - if ! test -z ${1}; then - echo "Starting build of ${1} $(test -n ${1})" - cmake_3rdparty ${1} + cmake_3rdparty ${@} exit fi # build 3rdparty tools # The order must not be changed! cmake_3rdparty \ ext_gettext \ ext_openssl \ - ext_zlib \ ext_qt \ + ext_zlib \ ext_boost \ ext_eigen3 \ ext_exiv2 \ ext_fftw3 \ ext_ilmbase \ ext_jpeg \ ext_lcms2 \ - ext_ocio - - # open exr will fail the first time is called - # rpath needs to be fixed an build rerun - if cmake_3rdparty ext_openexr; then - echo "open_exr built success!" - else - if install_name_tool -add_rpath ${KIS_INSTALL_DIR}/lib ${KIS_TBUILD_DIR}/ext_openexr/ext_openexr-prefix/src/ext_openexr-build/IlmImf/./b44ExpLogTable; then - echo "Added rpath for b44ExpLogTable" - fi - if install_name_tool -add_rpath ${KIS_INSTALL_DIR}/lib ${KIS_TBUILD_DIR}/ext_openexr/ext_openexr-prefix/src/ext_openexr-build/IlmImf/./dwaLookups; then - echo "Added rpath for dwaLookups" - fi - echo "Rerunning ext_openexr build" - cmake_3rdparty ext_openexr - fi + ext_ocio \ + ext_openexr cmake_3rdparty \ ext_png \ ext_tiff \ ext_gsl \ ext_vc \ ext_libraw \ ext_giflib + # Stop if qmake link was not created + # this meant qt build fail and further builds will + # also fail. + test -L "${KIS_INSTALL_DIR}/bin/qmake-qt5" + if [[ $(build_errorlog ${?} "qmake link missing!" "qmake link present, continuing...") -ne 0 ]];then + printf " + link: ${KIS_INSTALL_DIR}/bin/qmake-qt5 missing! + It probably means ext_qt failed!! + check, fix and rerun!\n" + exit + fi + # for python # for sip PYQT_SIP_DIR_OVERRIDE=/usr/local/share/sip/qt5 cmake_3rdparty \ ext_python \ ext_sip \ ext_pyqt - # we need to move the contents of sip/PyQt5 to python-3.x/PyQt5/ - - # on osx qmake is not correctly set to qmake-qt5 for some reason - ln -s -f ${KIS_INSTALL_DIR}/bin/qmake ${KIS_INSTALL_DIR}/bin/qmake-qt5 - cmake_3rdparty \ ext_frameworks \ ext_extra_cmake_modules \ - ext_karchive \ ext_kconfig \ ext_kwidgetsaddons \ ext_kcompletion \ ext_kcoreaddons \ ext_kguiaddons \ ext_ki18n \ ext_kitemmodels \ ext_kitemviews \ ext_kimageformats \ ext_kwindowsystem \ ext_quazip } # Recall cmake for all 3rd party packages # make is only on target first run # subsequent runs only call make install rebuild_3rdparty () { echo "starting rebuild of 3rdparty packages" build_install_ext() { for pkg in ${@:1:${#@}}; do { - cd ${KIS_TBUILD_DIR}/${pkg}/${pkg}-prefix/src/${pkg}-build + cd ${KIS_TBUILD_DIR}/${pkg}/${pkg}-prefix/src/${pkg}-stamp } || { - cd ${KIS_TBUILD_DIR}/${pkg}/${pkg}-prefix/src/${pkg} + cd ${KIS_TBUILD_DIR}/ext_frameworks/${pkg}-prefix/src/${pkg}-stamp } echo "Installing ${pkg} files..." - if test ${pkg} = "ext_boost"; then - echo "Copying boost files..." - cp bin.v2/libs/system/build/darwin-4.2.1/release/threading-multi/libboost_system.dylib ${KIS_INSTALL_DIR}/lib/ - cp bin.v2/libs/system/build/darwin-4.2.1/release/link-static/threading-multi/libboost_system.a ${KIS_INSTALL_DIR}/lib/ - # copy boost into i/include :: - cp -r boost ${KIS_INSTALL_DIR}/include - else - make -j${MAKE_THREADS} - make install - fi - cd ${KIS_TBUILD_DIR} - done - } + rm ${pkg}-configure ${pkg}-build ${pkg}-install - build_install_frameworks() { - for pkg in \ - ext_extra_cmake_modules \ - ext_karchive \ - ext_kconfig \ - ext_kwidgetsaddons \ - ext_kcompletion \ - ext_kcoreaddons \ - ext_kguiaddons \ - ext_ki18n \ - ext_kitemmodels \ - ext_kitemviews \ - ext_kimageformats \ - ext_kwindowsystem \ - ; do - cd ${KIS_TBUILD_DIR}/ext_frameworks/${pkg}-prefix/src/${pkg}-build - echo "Installing ${pkg} files..." - make install ${pkg} + cmake_3rdparty ${pkg} 1> /dev/null + + cd ${KIS_TBUILD_DIR} done } - + # Do not process complete list only pkgs given. if ! test -z ${1}; then - build_install_ext ${1} + build_install_ext ${@} exit fi build_install_ext \ ext_gettext \ ext_openssl \ + ext_zlib \ + ext_qt \ + ext_boost \ + ext_eigen3 \ + ext_exiv2 \ + ext_fftw3 \ + ext_ilmbase \ + ext_jpeg \ + ext_lcms2 \ + ext_ocio \ + ext_openexr \ + ext_png \ + ext_tiff \ + ext_gsl \ + ext_vc \ + ext_libraw \ + ext_giflib \ + ext_python \ + ext_sip \ + ext_pyqt \ - # qt builds inside qt_ext, make install must be run inside. - build_install_ext ext_qt - build_install_ext ext_zlib - - # ext_boost - build_install_ext ext_boost - + # Build kde_frameworks build_install_ext \ - ext_eigen3 \ - ext_exiv2 \ - ext_fftw3 \ - ext_ilmbase \ - ext_jpeg \ - ext_lcms2 \ - ext_ocio \ - ext_openexr \ - ext_png \ - ext_tiff \ - ext_gsl \ - ext_vc \ - ext_libraw \ - ext_giflib - - # for python - build_install_ext ext_python - build_install_ext ext_sip - build_install_ext ext_pyqt - - # force creation of symlink, useful if install dir was wiped out. - ln -s -f ${KIS_INSTALL_DIR}/bin/qmake ${KIS_INSTALL_DIR}/bin/qmake-qt5 - - build_install_frameworks - + ext_extra_cmake_modules \ + ext_karchive \ + ext_kconfig \ + ext_kwidgetsaddons \ + ext_kcompletion \ + ext_kcoreaddons \ + ext_kguiaddons \ + ext_ki18n \ + ext_kitemmodels \ + ext_kitemviews \ + ext_kimageformats \ + ext_kwindowsystem \ + ext_quazip } #not tested set_krita_dirs() { if ! test -z ${1}; then KIS_BUILD_DIR=${BUILDROOT}/b_${1} KIS_INSTALL_DIR=${BUILDROOT}/i_${1} KIS_SRC_DIR=${BUILDROOT}/src_${1} fi } # build_krita # run cmake krita build_krita () { set_krita_dirs ${1} echo ${KIS_BUILD_DIR} echo ${KIS_INSTALL_DIR} check_dir_path ${KIS_BUILD_DIR} cd ${KIS_BUILD_DIR} cmake ${KIS_SRC_DIR} \ -DBoost_INCLUDE_DIR=${KIS_INSTALL_DIR}/include \ -DCMAKE_INSTALL_PREFIX=${KIS_INSTALL_DIR} \ -DDEFINE_NO_DEPRECATED=1 \ -DBUILD_TESTING=OFF \ -DHIDE_SAFE_ASSERTS=ON \ -DKDE_INSTALL_BUNDLEDIR=${KIS_INSTALL_DIR}/bin \ -DPYQT_SIP_DIR_OVERRIDE=$KIS_INSTALL_DIR/share/sip/ \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 # copiling phase make -j${MAKE_THREADS} # compile integrations if test ${OSTYPE} == "darwin*"; then cd ${KIS_BUILD_DIR}/krita/integration/kritaquicklook make -j${MAKE_THREADS} fi } install_krita () { set_krita_dirs ${1} check_dir_path ${KIS_BUILD_DIR} cd ${KIS_BUILD_DIR} make install # compile integrations if test ${OSTYPE} == "darwin*"; then cd ${KIS_BUILD_DIR}/krita/integration/kritaquicklook make install fi } fix_boost_rpath () { set_krita_dirs ${1} # install_name_tool -add_rpath ${KIS_INSTALL_DIR}/lib $BUILDROOT/$KRITA_INSTALL/bin/krita.app/Contents/MacOS/gmic_krita_qt if $(install_name_tool -add_rpath ${KIS_INSTALL_DIR}/lib ${KIS_INSTALL_DIR}/bin/krita.app/Contents/MacOS/krita); then echo "Added rpath ${KIS_INSTALL_DIR}/lib to krita bin" fi # install_name_tool -add_rpath ${BUILDROOT}/deps/lib ${KIS_INSTALL_DIR}/bin/krita.app/Contents/MacOS/krita install_name_tool -change libboost_system.dylib @rpath/libboost_system.dylib ${KIS_INSTALL_DIR}/bin/krita.app/Contents/MacOS/krita FILES=$(find -L ${KIS_INSTALL_DIR} -name '*so' -o -name '*dylib') for FILE in $FILES; do if test -n "$(otool -L $FILE | grep boost)"; then echo "Fixing… $FILE" install_name_tool -change libboost_system.dylib @rpath/libboost_system.dylib $FILE fi done } print_usage () { echo "USAGE: osxbuild.sh [pkg]" echo "BUILDSTEPS:\t\t" echo "\n builddeps \t\t Run cmake step for 3rd party dependencies, optionally takes a [pkg] arg" echo "\n rebuilddeps \t\t Rerun make and make install step for 3rd party deps, optionally takes a [pkg] arg \t\t\t usefull for cleaning install directory and quickly reinstall all deps." echo "\n fixboost \t\t Fixes broken boost \@rpath on OSX" echo "\n build \t\t\t Builds krita" echo "\n install \t\t Installs krita" echo "\n buildinstall \t\t Build and Installs krita, running fixboost after installing" echo "" } if test ${#} -eq 0; then echo "ERROR: No option given!" print_usage exit 1 fi if test ${1} = "builddeps"; then - build_3rdparty ${2} + build_3rdparty "${@:2}" elif test ${1} = "rebuilddeps"; then - rebuild_3rdparty ${2} + rebuild_3rdparty "${@:2}" elif test ${1} = "fixboost"; then fix_boost_rpath elif test ${1} = "build"; then build_krita ${2} elif test ${1} = "install"; then install_krita ${2} + fix_boost_rpath ${2} elif test ${1} = "buildinstall"; then build_krita ${2} install_krita ${2} fix_boost_rpath ${2} elif test ${1} = "test"; then ${KIS_INSTALL_DIR}/bin/krita.app/Contents/MacOS/krita else echo "Option ${1} not supported" print_usage fi # after finishig sometimes it complains about missing matching quotes. \ No newline at end of file diff --git a/packaging/macos/osxdeploy.sh b/packaging/macos/osxdeploy.sh index 09cf6fcab1..1bda97db52 100755 --- a/packaging/macos/osxdeploy.sh +++ b/packaging/macos/osxdeploy.sh @@ -1,451 +1,454 @@ #!/usr/bin/env sh # Krita tool to create dmg from installed source # Copies all files to a folder to be converted into the final dmg # Background image must be set for it to deploy correcly # osxdeploy.sh automates the creation of the release DMG. It needs an image # either png or jpg as first argument as it will use the image to set # the background of the DMG. # Necessary files can be downloaded from https://drive.google.com/drive/folders/15cUhCou7ya9ktjfhbzRaL7_IpntzxG4j?usp=sharing # A short explanation of what it does: # - Creates a copy of "krita-template" folder (this containes Terms of use # and Applications) into kritadmg folder. # Application folder symlink can be created with applescript but Terms of use contents cannot, # also working like this allows to add other files to dmg if needed. # Place the folder in ${BUILDROOT} # - Copies krita.app contents to kritadmg folder # - Copies i/share to Contents/Resources excluding unnecesary files # - Copies translations, qml and quicklook PlugIns # - Copies i/plugins and i/lib/plugins to Contents/PlugIns # - Runs macdeployqt: macdeployqt is not built by default in ext_qt # build by: # cd ${BUILDROOT}/depbuild/ext_qt/ext_qt-prefix/src/ext_qt/qttools/src # make sub-macdeployqt-all # make sub-macdeployqt-install_subtargets # make install # the script changes dir to installation/bin to run macdeployqt as it can be buggy # if not runned from the same folder as the binary is on. # - Fix rpath from krita bin # - Find missing libraries from plugins and copy to Framworks or plugins. # This uses oTool iterative to find all unique libraries, then it searches each # library fond in folder, and if not found attempts to copy contents # to the appropiate folder, either Frameworks (if frameworks is in namefile, or # library has plugin isnot in path), or plugin if otherwise. # - Builds DMG # Building DMG creates a new dmg with the contents of # mounts the dmg and sets the style for dmg. # unmount # Compress resulting dmg into krita_nightly-.dmg # deletes temporary files. if test -z ${BUILDROOT}; then echo "ERROR: BUILDROOT env not set!" echo "\t Must point to the root of the buildfiles as stated in 3rdparty Readme" echo "exiting..." exit fi DMG_title="krita" #if changed krita.temp.dmg must be deleted manually # There is some duplication between build and deploy scripts # a config env file could would be a nice idea. KIS_INSTALL_DIR=${BUILDROOT}/i KIS_BUILD_DIR=${BUILDROOT}/kisbuild # only used for getting git sha number KRITA_DMG=${BUILDROOT}/kritadmg KRITA_DMG_TEMPLATE=${BUILDROOT}/kritadmg-template +export PATH=${KIS_INSTALL_DIR}/bin:$PATH + # flags for OSX environment # We only support from 10.11 up export MACOSX_DEPLOYMENT_TARGET=10.11 export QMAKE_MACOSX_DEPLOYMENT_TARGET=10.11 print_usage () { echo "USAGE: osxdeploy.sh [-s=] " echo "\t -s Code sign identity for codesign" echo "\t osxdeploy needs an input image to add to the dmg background \t image recomended size is at least 950x500\n" } # Attempt to detach previous mouted DMG if [[ -d "/Volumes/${DMG_title}" ]]; then echo "WARNING: Another Krita DMG is mounted!" echo "Attempting eject…" hdiutil detach "/Volumes/${DMG_title}" if [ $? -ne 0 ]; then exit fi echo "Success!" fi # Parse input args if test ${#} -eq 0; then echo "ERROR: no option given" print_usage exit 1 fi for arg in "${@}"; do if [[ -f ${arg} ]]; then DMG_validBG=0 echo "attempting to check background is valid jpg or png..." BG_FORMAT=$(sips --getProperty format ${arg} | awk '{printf $2}') if [[ "png" = ${BG_FORMAT} || "jpeg" = ${BG_FORMAT} ]];then echo "valid image file" DMG_background=${arg} DMG_validBG=1 fi fi # If string starts with -sign if [[ ${arg} = -s=* ]]; then CODE_SIGNATURE="${arg#*=}" fi if [[ ${arg} = "-h" || ${arg} = "--help" ]]; then print_usage exit fi done if [[ ${DMG_validBG} -eq 0 ]]; then echo "No jpg or png valid file detected!!" echo "exiting" exit fi if [[ -z "${CODE_SIGNATURE}" ]]; then echo "WARNING: No signature provided, Code will not be signed" else printf 'Code will be signed with "%s"\n' "${CODE_SIGNATURE}" fi # Helper functions countArgs () { echo "${#}" } stringContains () { echo "$(grep "${2}" <<< "${1}")" } add_lib_to_list() { local llist=${2} if test -z "$(grep ${1##*/} <<< ${llist})" ; then local llist="${llist} ${1##*/} " fi echo ${llist} } # Find all @rpath and Absolute to buildroot path libs # Add to libs_used # converts absolute buildroot path to @rpath find_needed_libs () { echo "Analizing libraries with oTool..." >&2 local libs_used="" # input lib_lists founded for libFile in $(find ${KRITA_DMG}/krita.app/Contents -type f -perm -u+x -not -name "*.pyc"); do if test -z "$(file ${libFile} | grep 'Mach-O')" ; then echo "skipping ${libFile}" >&2 continue fi oToolResult=$(otool -L ${libFile} | awk '{print $1}') resultArray=(${oToolResult}) # convert to array for lib in ${resultArray[@]:1}; do if test "${lib:0:1}" = "@"; then local libs_used=$(add_lib_to_list ${lib} "${libs_used}") fi if test "${lib:0:${#BUILDROOT}}" = "${BUILDROOT}"; then printf "Fixing: %s\n" "${libFile}" >&2 install_name_tool -id ${lib##*/} "${libFile}" install_name_tool -change ${lib} "@rpath/${lib##*${BUILDROOT}/i/lib/}" "${libFile}" local libs_used=$(add_lib_to_list ${lib} "${libs_used}") fi done done echo ${libs_used} # return updated list } find_missing_libs (){ echo "Searching for missing libs on deployment folders…" >&2 local libs_missing="" for lib in ${@}; do if test -z "$(find ${KRITA_DMG}/krita.app/Contents/ -name ${lib})"; then echo "Adding ${lib} to missing libraries." >&2 libs_missing="${libs_missing} ${lib}" fi done echo ${libs_missing} } copy_missing_libs () { for lib in ${@}; do result=$(find "${BUILDROOT}/i" -name "${lib}") if test $(countArgs ${result}) -eq 1; then echo ${result} if [ "$(stringContains "${result}" "plugin")" ]; then echo "copying ${lib} to plugins dir" cp -pv ${result} ${KRITA_DMG}/krita.app/Contents/PlugIns/ else echo "copying ${lib} to Frameworks dir" cp -pv ${result} ${KRITA_DMG}/krita.app/Contents/Frameworks/ fi else echo "${lib} might be a missing framework" if [ "$(stringContains "${result}" "framework")" ]; then echo "copying framework ${BUILDROOT}/i/lib/${lib}.framework to dmg" # rsync only included ${lib} Resources Versions rsync -priul ${BUILDROOT}/i/lib/${lib}.framework/${lib} ${KRITA_DMG}/krita.app/Contents/Frameworks/${lib}.framework/ rsync -priul ${BUILDROOT}/i/lib/${lib}.framework/Resources ${KRITA_DMG}/krita.app/Contents/Frameworks/${lib}.framework/ rsync -priul ${BUILDROOT}/i/lib/${lib}.framework/Versions ${KRITA_DMG}/krita.app/Contents/Frameworks/${lib}.framework/ fi fi done } krita_findmissinglibs() { echo "Starting search for missing libraries" neededLibs=$(find_needed_libs) echo "\nDone!" missingLibs=$(find_missing_libs ${neededLibs}) if test $(countArgs ${missingLibs}) -gt 0; then echo "Found missing libs!" echo "${missingLibs}\n" copy_missing_libs ${missingLibs} else echo "No missing libraries found." fi echo "Done!" } krita_deploy () { # fix_boost_rpath cd ${BUILDROOT} # Update files in krita.app echo "Deleting previous kritadmg run..." rm -rf ./krita.dmg ${KRITA_DMG} # Copy new builtFiles echo "Preparing ${KRITA_DMG} for deployment..." echo "Copying krita.app..." rsync -riul ${KRITA_DMG_TEMPLATE}/ ${KRITA_DMG} rsync -prul ${KIS_INSTALL_DIR}/bin/krita.app ${KRITA_DMG} mkdir -p ${KRITA_DMG}/krita.app/Contents/PlugIns mkdir -p ${KRITA_DMG}/krita.app/Contents/Frameworks echo "Copying share..." # Deletes old copies of translation and qml to be recreated cd ${KIS_INSTALL_DIR}/share/ rsync -prul --delete ./ \ --exclude krita_SRCS.icns \ --exclude aclocal \ --exclude doc \ --exclude ECM \ --exclude eigen3 \ --exclude emacs \ --exclude gettext \ --exclude gettext-0.19.8 \ --exclude info \ --exclude kf5 \ --exclude kservices5 \ --exclude man \ --exclude ocio \ --exclude pkgconfig \ --exclude mime \ --exclude translations \ --exclude qml \ ${KRITA_DMG}/krita.app/Contents/Resources cd ${BUILDROOT} echo "Copying translations..." rsync -prul ${KIS_INSTALL_DIR}/translations/ \ ${KRITA_DMG}/krita.app/Contents/Resources/translations echo "Copying kritaquicklook..." mkdir -p ${KRITA_DMG}/krita.app/Contents/Library/QuickLook rsync -prul ${KIS_INSTALL_DIR}/plugins/kritaquicklook.qlgenerator ${KRITA_DMG}/krita.app/Contents/Library/QuickLook cd ${KRITA_DMG}/krita.app/Contents ln -shF Resources share echo "Copying qml..." rsync -prul ${KIS_INSTALL_DIR}/qml Resources/qml echo "Copying plugins..." # exclude kritaquicklook.qlgenerator/ cd ${KIS_INSTALL_DIR}/plugins/ rsync -prul --delete --delete-excluded ./ \ --exclude kritaquicklook.qlgenerator \ ${KRITA_DMG}/krita.app/Contents/PlugIns cd ${BUILDROOT} rsync -prul ${KIS_INSTALL_DIR}/lib/kritaplugins/ ${KRITA_DMG}/krita.app/Contents/PlugIns # rsync -prul /Volumes/Osiris/programs/krita-master/i/lib/libkrita* Frameworks/ # activate for python enabled Krita # echo "Copying python..." # cp -r ${KIS_INSTALL_DIR}/lib/python3.5 Frameworks/ # cp -r ${KIS_INSTALL_DIR}/lib/krita-python-libs Frameworks/ # XXX: fix rpath for krita.so # echo "Copying sip..." # rsync -Prvul ${KIS_INSTALL_DIR}/sip Frameworks/ # To avoid errors macdeployqt must be run from bin location # ext_qt will not build macdeployqt by default so it must be build manually # cd ${BUILDROOT}/depbuild/ext_qt/ext_qt-prefix/src/ext_qt/qttools/src # make sub-macdeployqt-all # make sub-macdeployqt-install_subtargets # make install echo "Running macdeployqt..." cd ${KIS_INSTALL_DIR}/bin ./macdeployqt ${KRITA_DMG}/krita.app \ -verbose=0 \ -executable=${KRITA_DMG}/krita.app/Contents/MacOS/krita \ -libpath=${KIS_INSTALL_DIR}/lib \ -qmldir=${KIS_INSTALL_DIR}/qml \ # -extra-plugins=${KIS_INSTALL_DIR}/lib/kritaplugins \ # -extra-plugins=${KIS_INSTALL_DIR}/lib/plugins \ # -extra-plugins=${KIS_INSTALL_DIR}/plugins cd ${BUILDROOT} echo "macdeployqt done!" install_name_tool -delete_rpath @loader_path/../../../../lib ${KRITA_DMG}/krita.app/Contents/MacOS/krita rm -rf ${KRITA_DMG}/krita.app/Contents/PlugIns/kf5/org.kde.kwindowsystem.platforms # repair krita for plugins krita_findmissinglibs } +# helper to define function only once +batch_codesign() { + xargs -P4 -I FILE codesign -f -s "${CODE_SIGNATURE}" FILE +} # Code sign must be done as recommended by apple "sign code inside out in individual stages" signBundle() { - # helper to define function only once - batch_codesign() { - xargs -P4 -I FILE codesign -f -s "${CODE_SIGNATURE}" FILE - } cd ${KRITA_DMG} # sign Frameworks and libs cd ${KRITA_DMG}/krita.app/Contents/Frameworks # remove debug version as both versions cant be signed. rm ${KRITA_DMG}/krita.app/Contents/Frameworks/QtScript.framework/Versions/Current/QtScript_debug find . -type d -name "*.framework" | xargs printf "%s/Versions/Current\n" | batch_codesign find . -type f -name "*.dylib" -or -name "*.so" | batch_codesign # Sign all other files in Framework (needed) # there are many files in pyton do we need to sign them? TODO # find krita-python-libs -type f | batch_codesign # find python -type f | batch_codesign # Sing only libraries and plugins cd ${KRITA_DMG}/krita.app/Contents/PlugIns - find . -type f -name "*.dylib" -or -name "*.so" | batch_codesign + find . -type f | batch_codesign cd ${KRITA_DMG}/krita.app/Contents/Library/QuickLook printf "kritaquicklook.qlgenerator" | batch_codesign + # It is recommended to sign every Resource file cd ${KRITA_DMG}/krita.app/Contents/Resources - find . -type f -name "*.dylib" -or -name "*.so" | batch_codesign + find . -type f | batch_codesign #Finally sign krita and krita.app printf "${KRITA_DMG}/krita.app/Contents/MacOS/krita" | batch_codesign printf "${KRITA_DMG}/krita.app" | batch_codesign } createDMG () { echo "Starting creation of dmg..." cd ${BUILDROOT} DMG_size=500 ## Build dmg from folder # create dmg on local system # usage of -fsargs minimze gaps at front of filesystem (reduce size) hdiutil create -srcfolder "${KRITA_DMG}" -volname "${DMG_title}" -fs HFS+ \ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${DMG_size}m krita.temp.dmg # Next line is only useful if we have a dmg as a template! # previous hdiutil must be uncommented # cp krita-template.dmg krita.dmg device=$(hdiutil attach -readwrite -noverify -noautoopen "krita.temp.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}') # rsync -priul --delete ${KRITA_DMG}/krita.app "/Volumes/${DMG_title}" # Set style for dmg if [[ ! -d "/Volumes/${DMG_title}/.background" ]]; then mkdir "/Volumes/${DMG_title}/.background" fi cp ${BUILDROOT}/${DMG_background} "/Volumes/${DMG_title}/.background/" ## Apple script to set style echo ' tell application "Finder" tell disk "'${DMG_title}'" open set current view of container window to icon view set toolbar visible of container window to false set statusbar visible of container window to false set the bounds of container window to {186, 156, 956, 592} set theViewOptions to the icon view options of container window set arrangement of theViewOptions to not arranged set icon size of theViewOptions to 80 set background picture of theViewOptions to file ".background:'${DMG_background}'" set position of item "'krita.app'" of container window to {279, 272} set position of item "Applications" of container window to {597, 272} set position of item "Terms of Use" of container window to {597, 110} update without registering applications delay 1 close end tell end tell ' | osascript chmod -Rf go-w "/Volumes/${DMG_title}" # ensure all writting operations to dmg are over sync hdiutil detach $device hdiutil convert "krita.temp.dmg" -format UDZO -imagekey -zlib-level=9 -o krita-out.dmg # Add git version number GIT_SHA=$(grep "#define KRITA_GIT_SHA1_STRING" ${KIS_BUILD_DIR}/libs/version/kritagitversion.h | awk '{gsub(/"/, "", $3); printf $3}') mv krita-out.dmg krita-nightly_${GIT_SHA}.dmg echo "moved krita-out.dmg to krita-nightly_${GIT_SHA}.dmg" rm krita.temp.dmg echo "dmg done!" } ####################### # Program starts!! ######################## # Run deploy command, instalation is assumed to exist in BUILDROOT/i krita_deploy # Code sign krita.app if signature given if [[ -n "${CODE_SIGNATURE}" ]]; then signBundle fi # Create DMG from files insiede ${KRITA_DMG} folder createDMG