macospackagingexternal-dependencies

Packaging software with dependencies - How deep should I go?


I am developing a cross-platform software and want to distribute it as zip packages.

For Linux, I do not package the dependencies with the package, for Windows, I do distribute the dlls as well in the package.

For Mac OS X I have a script that copies all dylib files recursively to the build folder and changes the links.

Of course, this leads to a list of files that I should probably not package, e.g. libsystem_malloc.dylib, libremovefile.dylib.

Should I just go for dylibs installed in /usr/local/* or is there any other systematic way to not include files that are available on every OS X installation?

Most (OK, all for now) of the dependencies are Homebrew packages, if that helps.

For anyone interested, this is the bash code for recursively copying and relinking:

while true; do
    INSTALLED=0
    for dylib in *.dylib; do
        LIBS=`otool -L $dylib`
        if [ "x$LIBS" != "x" ]; then
            echo "$dylib is using:"
            for lib in $LIBS{@:2}; do
                if echo $lib | grep --quiet 'dylib$'; then
                    echo "    $lib"
                    new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
                    if [ -e  $PD_APP_LIB/$new_lib ]; then
                        echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
                    else
                        install -vp $lib $PD_APP_LIB
                        INSTALLED=1
                    fi
                    install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
                    install_name_tool -change $lib @loader_path/$new_lib $dylib
                fi
            done
            echo " "
        fi
    done
    if [ $INSTALLED -eq 0 ]; then
        break
    fi
done

Solution

  • For now, I only pack libraries from /usr/local/, the script is:

    while true; do
        INSTALLED=0
        for dylib in *.dylib; do
            LIBS=`otool -L $dylib`
            if [ "x$LIBS" != "x" ]; then
                echo "$dylib is using:"
                for lib in $LIBS{@:2}; do
                    # The following line has been changed
                    if echo $lib | grep --quiet '^/usr/local/.*dylib$'; then
                        echo "    $lib"
                        new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
                        if [ -e  $PD_APP_LIB/$new_lib ]; then
                            echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
                        else
                            install -vp $lib $PD_APP_LIB
                            INSTALLED=1
                        fi
                        install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
                        install_name_tool -change $lib @loader_path/$new_lib $dylib
                    fi
                done
                echo " "
            fi
        done
        if [ $INSTALLED -eq 0 ]; then
            break
        fi
    done