diff --git a/scripts/osx-bundle.sh b/scripts/osx-bundle.sh index 340247be1..57c66a82b 100755 --- a/scripts/osx-bundle.sh +++ b/scripts/osx-bundle.sh @@ -1,19 +1,35 @@ #!/bin/bash -test -f aegisub/.libs/aegisub && test -x aegisub/.libs/aegisub || ( exit "Make sure you're in the right dir"; exit 1 ) -test -e $1 && ( echo "$1 already exists, will not overwrite."; exit 1 ) +PKG_DIR=${1}.app +SKEL_DIR="packages/osx_bundle" -echo "Making directory structure..." -mkdir $1 || ( echo "Failed creating directory $1"; exit 1 ) -mkdir $1/Contents $1/Contents/MacOS $1/Contents/Resources +if ! test -d packages/osx_bundle; then + echo "Make sure you're in the toplevel source directory" + exit 1; +fi -echo "Copying files into package..." -cp aegisub/macosx/Info.plist $1/Contents -cp aegisub/.libs/aegisub $1/Contents/MacOS -cp aegisub/macosx/*.icns $1/Contents/Resources +echo "Removing ${PKG_DIR}" +rm -rf ${PKG_DIR} -echo "Now about to collect and fix up shared libraries..." +echo +echo "---- Directory Structure ----" +mkdir -v ${PKG_DIR} +mkdir -v ${PKG_DIR}/Contents +mkdir -v ${PKG_DIR}/Contents/MacOS +mkdir -v ${PKG_DIR}/Contents/Resources -python scripts/osx-fix-libs.py "$1/Contents/MacOS/aegisub" +echo +echo "---- Copying Skel Files ----" +cp -v ${SKEL_DIR}/Contents/Resources/* ${PKG_DIR}/Contents/Resources +cp -v ${SKEL_DIR}/Contents/Info.plist ${PKG_DIR}/Contents -echo "Done creating $1!" +echo +echo "---- Binaries ----" +cp -v aegisub/.libs/aegisub ${PKG_DIR}/Contents/MacOS + +echo +echo "---- Libraries ----" +python scripts/osx-fix-libs.py "${PKG_DIR}/Contents/MacOS/aegisub" + +echo +echo "Done Creating ${PKG_DIR}" diff --git a/scripts/osx-fix-libs.py b/scripts/osx-fix-libs.py index 2f5e72f1d..fa78e9448 100755 --- a/scripts/osx-fix-libs.py +++ b/scripts/osx-fix-libs.py @@ -8,6 +8,7 @@ import shutil is_bad_lib = re.compile(r'(/usr/local|/opt)').match is_sys_lib = re.compile(r'(/usr|/System)').match otool_libname_extract = re.compile(r'\s+(/.*?)[\(\s:]').search +goodlist = [] def otool(cmdline): pipe = os.popen("otool " + cmdline, 'r') @@ -16,6 +17,7 @@ def otool(cmdline): return output def collectlibs(lib, masterlist, targetdir): + global goodlist liblist = otool("-L " + lib) locallist = [] for l in liblist: @@ -26,9 +28,11 @@ def collectlibs(lib, masterlist, targetdir): sys.exit("Linking with library in blacklisted location: " + l) if not is_sys_lib(l) and not l in masterlist: locallist.append(l) - print " ...found ", l, + print "found ", l, shutil.copy(l, targetdir) print " ...copied to target" + elif not l in goodlist and not l in masterlist: + goodlist.append(l) masterlist.extend(locallist) for l in locallist: collectlibs(l, masterlist, targetdir) @@ -39,7 +43,15 @@ print "Searching for libraries in ", binname, "..." libs = [binname] collectlibs(sys.argv[1], libs, targetdir) -print " ...done. Will now fix up library install names..." +print +print "System libraries used..." +goodlist.sort() +for l in goodlist: + print l + + +print +print "Fixing library install names..." in_tool_cmdline = "install_name_tool " for lib in libs: libbase = os.path.basename(lib) @@ -47,7 +59,8 @@ for lib in libs: for lib in libs: libbase = os.path.basename(lib) os.system("%s -id @executable_path/%s '%s/%s'" % (in_tool_cmdline, libbase, targetdir, libbase)) - print libbase, + print lib, "-> @executable_path/" + libbase sys.stdout.flush() + print print "All done!"