From 11d97848200b6de959a1692989763644dae8e76f Mon Sep 17 00:00:00 2001 From: rgaudin Date: Tue, 6 May 2014 08:16:18 +0000 Subject: [PATCH 1/4] changed osx bundle/.app layout to reflect XR29/tbird --- src/macosx/Info.plist | 32 ++++++++++++++++++++++++++------ src/macosx/InfoPlist.strings | 3 +++ src/macosx/PkgInfo | 1 + src/macosx/cleanup_rpath.py | 9 ++++++--- 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 src/macosx/InfoPlist.strings create mode 100644 src/macosx/PkgInfo diff --git a/src/macosx/Info.plist b/src/macosx/Info.plist index 6be9e38..17e5547 100644 --- a/src/macosx/Info.plist +++ b/src/macosx/Info.plist @@ -3,7 +3,9 @@ CFBundleExecutable - xulrunner + kiwix + CFBundleDisplayName + Kiwix CFBundleGetInfoString 0.9 rc3 CFBundleIconFile @@ -11,16 +13,18 @@ CFBundleIdentifier org.kiwix.kiwix CFBundleInfoDictionaryVersion - 0.1 + 6.0 CFBundleName Kiwix CFBundlePackageType APPL CFBundleShortVersionString - 0.9 - CFBundleSignature - ???? + 0.9 rc3 CFBundleURLTypes + CFBundleDevelopmentRegion + English + CFBundleSignature + KIWI CFBundleURLIconFile @@ -34,7 +38,7 @@ CFBundleVersion - 1.0 + 1.0.1 CFBundleDocumentTypes @@ -53,5 +57,21 @@ Viewer + LSApplicationCategoryType + public.app-category.productivity + LSMinimumSystemVersion + 10.6.0 + LSMinimumSystemVersionByArchitecture + + i386 + 10.6.0 + x86_64 + 10.6.0 + + NSSupportsAutomaticGraphicsSwitching + + NSPrincipalClass + GeckoNSApplication + UTExportedTypeDeclarations diff --git a/src/macosx/InfoPlist.strings b/src/macosx/InfoPlist.strings new file mode 100644 index 0000000..2375798 --- /dev/null +++ b/src/macosx/InfoPlist.strings @@ -0,0 +1,3 @@ + +CFBundleName = "Kiwix"; +NSHumanReadableCopyright = "Copyright © 2006-2014 Contributors."; diff --git a/src/macosx/PkgInfo b/src/macosx/PkgInfo new file mode 100644 index 0000000..255ca26 --- /dev/null +++ b/src/macosx/PkgInfo @@ -0,0 +1 @@ +APPLMOZM \ No newline at end of file diff --git a/src/macosx/cleanup_rpath.py b/src/macosx/cleanup_rpath.py index 5c167eb..477a810 100755 --- a/src/macosx/cleanup_rpath.py +++ b/src/macosx/cleanup_rpath.py @@ -63,7 +63,7 @@ libname = u'lib%s%s.0.dylib' % (name[0].upper(), name[1:]) # change ID if component to match new name/path if is_component: - os.system('install_name_tool -id %s %s' % (basename, component)) + os.system('install_name_tool -id %s %s' % (basename, component)) # run otool to get a list of deps. otool = subprocess.Popen(['otool', '-L', component], stdout=subprocess.PIPE) @@ -73,6 +73,7 @@ for line in otool_out.split('\n'): if ('executable_path' in line or 'libSystem' in line or 'libstdc++' in line + or 'libgcc' in line or ':' in line or not len(line) or 'aria2c' in basename): @@ -90,9 +91,11 @@ for line in otool_out.split('\n'): if match: print("match: %s" % match.groups()[0]) if is_component: - newpath = u'@executable_path/../Frameworks/lib%s.dylib' % match.groups()[0] + # newpath = u'@executable_path/../Frameworks/lib%s.dylib' % match.groups()[0] + newpath = u'@executable_path/lib%s.dylib' % match.groups()[0] elif is_binary: - newpath = u'@executable_path/../../Frameworks/lib%s.dylib' % match.groups()[0] + # newpath = u'@executable_path/../../Frameworks/lib%s.dylib' % match.groups()[0] + newpath = u'@executable_path/../lib%s.dylib' % match.groups()[0] else: newpath = u'@loader_path/lib%s.dylib' % match.groups()[0] From 22886e20d2ac3fe591501b5e3d1f51381c70f6b8 Mon Sep 17 00:00:00 2001 From: rgaudin Date: Tue, 6 May 2014 09:33:54 +0000 Subject: [PATCH 2/4] Fixed typo in Info.plist preventing icon from working --- src/macosx/Info.plist | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/macosx/Info.plist b/src/macosx/Info.plist index 17e5547..44975c7 100644 --- a/src/macosx/Info.plist +++ b/src/macosx/Info.plist @@ -20,11 +20,11 @@ APPL CFBundleShortVersionString 0.9 rc3 - CFBundleURLTypes CFBundleDevelopmentRegion English CFBundleSignature KIWI + CFBundleURLTypes CFBundleURLIconFile @@ -73,5 +73,29 @@ NSPrincipalClass GeckoNSApplication UTExportedTypeDeclarations + + + UTTypeIdentifier + org.kiwix.kiwix.zim + UTTypeReferenceURL + http://www.kiwix.org + UTTypeDescription + Kiwix ZIM File + UTTypeConformsTo + + public.data + public.content + + UTTypeTagSpecification + + com.apple.ostype + TBMZ + public.filename-extension + + zim + + + + - + \ No newline at end of file From e1e163ffe4d84fe5929a800615ce69565025fb28 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Wed, 7 May 2014 16:08:43 +0200 Subject: [PATCH 3/4] + Introduction of base url in kiwix-serve (to handle relative urls in ZIM files) --- src/server/kiwix-serve.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 9d6ef94..8175a78 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -273,8 +273,10 @@ static int accessHandlerCallback(void *cls, /* Display the content of a ZIM article */ else if (reader != NULL) { pthread_mutex_lock(&readerLock); + std::string baseUrl; + try { - found = reader->getContentByDecodedUrl(urlStr, content, contentLength, mimeType); + found = reader->getContentByDecodedUrl(urlStr, content, contentLength, mimeType, baseUrl); if (found) { if (isVerbose()) { cout << "Found " << urlStr << endl; @@ -300,6 +302,9 @@ static int accessHandlerCallback(void *cls, "(href|src)(=[\"|\']{0,1}/)([A-Z|\\-])/"); content = replaceRegex(content, "$1$2" + humanReadableBookId + "/$3/", "(@import[ ]+)([\"|\']{0,1}/)([A-Z|\\-])/"); + content = replaceRegex(content, + "", + ""); } else if (mimeType.find("text/css") != string::npos) { content = replaceRegex(content, "$1$2" + humanReadableBookId + "/$3/", "(url|URL)(\\([\"|\']{0,1}/)([A-Z|\\-])/"); From a18a16e9d30a0f3b429c56a7772e949818339dd5 Mon Sep 17 00:00:00 2001 From: rgaudin Date: Thu, 8 May 2014 16:49:07 +0000 Subject: [PATCH 4/4] updated to handle libstdc++ and libgcc_s --- src/macosx/cleanup_rpath.py | 98 ++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/macosx/cleanup_rpath.py b/src/macosx/cleanup_rpath.py index 477a810..1315f36 100755 --- a/src/macosx/cleanup_rpath.py +++ b/src/macosx/cleanup_rpath.py @@ -10,8 +10,8 @@ MODE_BINARY = 2 MODE_LIBRARY = 3 MODES = {'c': MODE_COMPONENT, - 'b': MODE_BINARY, - 'l': MODE_LIBRARY} + 'b': MODE_BINARY, + 'l': MODE_LIBRARY} is_library = False is_component = False @@ -19,88 +19,88 @@ is_binary = False def usage(): - print(u"Usage: %s MODE component/path.dylib" % sys.argv[0]) - print(u" MODE is c: component or b: binary or l: library") + print(u"Usage: %s MODE component/path.dylib" % sys.argv[0]) + print(u" MODE is c: component or b: binary or l: library") if len(sys.argv) < 3: - usage() - exit(0) + usage() + exit(0) component = sys.argv[-1] mode = MODES.get(sys.argv[-2].lower()) if not mode: - usage() - exit(1) + usage() + exit(1) # mode switchers if mode == MODE_COMPONENT: - is_component = True + is_component = True elif mode == MODE_LIBRARY: - is_library = True + is_library = True else: - is_binary = True + is_binary = True if not os.path.exists(component): - print(u"Unable to access component at: %s" % component) - exit(1) + print(u"Unable to access component at: %s" % component) + exit(1) # we'll also allow binaries to be fixed. # if (is_library or is_component) and not component.endswith('.dylib'): - print(u"%s is not a dylib component" % component) - exit(1) + print(u"%s is not a dylib component" % component) + exit(1) print("Fixing %s..." % component) basename = os.path.basename(component) try: - name, ext = basename.rsplit('.', 1) + name, ext = basename.rsplit('.', 1) except ValueError: - name = basename - ext = '' + name = basename + ext = '' libname = u'lib%s%s.0.dylib' % (name[0].upper(), name[1:]) # change ID if component to match new name/path if is_component: - os.system('install_name_tool -id %s %s' % (basename, component)) + os.system('install_name_tool -id %s %s' % (basename, component)) # run otool to get a list of deps. otool = subprocess.Popen(['otool', '-L', component], stdout=subprocess.PIPE) otool_out, otool_err = otool.communicate() for line in otool_out.split('\n'): - if ('executable_path' in line - or 'libSystem' in line - or 'libstdc++' in line - or 'libgcc' in line - or ':' in line - or not len(line) - or 'aria2c' in basename): - continue - path, junk = line.strip().split(' (', 1) - # erroneous_links.append(path) - - _basename = os.path.basename(path).strip() - - if _basename == basename: - continue - - # is it a library link? - match = re.match(r'lib([a-z\_\-\d]+)([\.?\d]*)\.dylib', _basename) - if match: - print("match: %s" % match.groups()[0]) - if is_component: + if ('executable_path' in line + or 'libSystem' in line + or ':' in line + or not len(line) + or 'aria2c' in basename): + continue + path, junk = line.strip().split(' (', 1) + # erroneous_links.append(path) + + _basename = os.path.basename(path).strip() + + if _basename == basename: + continue + + # is it a library link? + match = re.match(r'lib([a-z\_\-\d\+]+)([\.?\d]*)\.dylib', _basename) + if match: + print("match: %s" % match.groups()[0]) + if 'libstdc++' in line or 'libgcc' in line: + newpath = u'/usr/lib/lib%s%s.dylib' % (match.groups()[0], match.groups()[1]) + elif is_component: # newpath = u'@executable_path/../Frameworks/lib%s.dylib' % match.groups()[0] - newpath = u'@executable_path/lib%s.dylib' % match.groups()[0] - elif is_binary: + newpath = u'@executable_path/lib%s.dylib' % match.groups()[0] + elif is_binary: # newpath = u'@executable_path/../../Frameworks/lib%s.dylib' % match.groups()[0] - newpath = u'@executable_path/../lib%s.dylib' % match.groups()[0] - else: - newpath = u'@loader_path/lib%s.dylib' % match.groups()[0] + newpath = u'@executable_path/../lib%s.dylib' % match.groups()[0] + else: + newpath = u'@loader_path/lib%s.dylib' % match.groups()[0] - print('install_name_tool -change %s %s %s' % (path, newpath, component)) - os.system('install_name_tool -change %s %s %s' % (path, newpath, component)) - continue + print('install_name_tool -change %s %s %s' % (path, newpath, component)) + os.system('install_name_tool -change %s %s %s' % (path, newpath, component)) + continue - print('\tUnmatched: %s' % path) \ No newline at end of file + print('\tUnmatched: %s' % path) \ No newline at end of file