[PATCH] Nested app support for complete-bundle.sh

Поиск
Список
Период
Сортировка
Искать

[PATCH] Nested app support for complete-bundle.sh

От:
"Florian G. Pflug" <fgp@phlo.org>
Дата:
Hi

That symlinking-Framworks idea proved to be easier than I
initially thought - here is a patch ;-)

This patch also moves pkg to the end of the list of subdirs
in the main Makefile.am. If pkg is listed before debugger,
than complete-bundle.sh is run _before_ the debugger binary
is copied into the bundle, which obviously causes all kinds
of trouble ;-)

greetings, Florian Pflug
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 6194)
+++ Makefile.am	(working copy)
@@ -9,7 +9,7 @@
 
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = branding i18n pgadmin pkg xtra debugger
+SUBDIRS = branding i18n pgadmin xtra debugger pkg
 
 EXTRA_DIST = \
 	$(top_srcdir)/BUGS \
Index: pkg/mac/complete-bundle.sh
===================================================================
--- pkg/mac/complete-bundle.sh	(revision 6194)
+++ pkg/mac/complete-bundle.sh	(working copy)
@@ -8,47 +8,70 @@
 
 test -d "$bundle/Contents/Frameworks" || mkdir -p "$bundle/Contents/Frameworks" || exit 1
 
-echo "Completing bundle: $bundle"
+function CompleteSingleApp() {
+	local bundle=$1 tag=$(basename "$1") todo todo_old fw_relpath lib lib_bn nested_app na_relpath
 
-cd "$bundle"
+	echo "Completing app: $bundle"
+	pushd "$bundle" > /dev/null
 
-todo=$(file `find ./ -perm +0111 ! -type d` | grep "Mach-O executable" | awk -F ':| ' '{ORS=" "; print $1}' | uniq)
+	#We skip nested apps here - those are treated specially
+	todo=$(file `find ./ -perm +0111 ! -type d ! -path "*.app/*" ! -name "*.app"` | grep "Mach-O executable" | awk -F ':| ' '{ORS=" "; print $1}' | uniq)
 
-echo "Found executables: $todo"
+	echo "App: $tag: Found executables: $todo"
+	while test "$todo" != ""; do
+		todo_old=$todo ;
+		todo="" ;
+		for todo_obj in $todo_old; do
+			echo "App: $tag: Post-processing: $todo_obj"
 
-while test "$todo" != ""; do
-	todo_old=$todo ;
-	todo="" ;
-	for todo_obj in $todo_old; do
-		echo "Post-processing: $todo_obj"
+			#Figure out the relative path from todo_obj to Contents/Frameworks
+			fw_relpath=$(echo "$todo_obj" |\
+				sed -n 's|^\(\.//*\)\(\([^/][^/]*/\)*\)[^/][^/]*$|\2|gp' | \
+				sed -n 's|[^/][^/]*/|../|gp' \
+			)"Contents/Frameworks"
 
-		#Figure out the relative path from todo_obj to Contents/Frameworks
-		fw_relpath=$(echo "$todo_obj" |\
-			sed -n 's|^\(\.//*\)\(\([^/][^/]*/\)*\)[^/][^/]*$|\2|gp' | \
-			sed -n 's|[^/][^/]*/|../|gp' \
-		)"Contents/Frameworks"
-
-		#Find all libraries $todo_obj depends on, but skip system libraries
-		for lib in $(
-			otool -L $todo_obj | \
-			sed -n 's|^.*[[:space:]]\([^[:space:]]*\.dylib\).*$|\1|p' | \
-			egrep -v '^(/usr/lib)|(/System)|@executable_path@' \
-		); do
-			lib_bn="$(basename "$lib")" ;
-			if ! test -f "Contents/Frameworks/$lib_bn"; then
-				echo "Adding library: $lib_bn (because of: $todo_obj)"
-				cp "$lib" "Contents/Frameworks/$lib_bn"
-				chmod 755 "Contents/Frameworks/$lib_bn"
-				install_name_tool \
-					-id "$lib_bn" \
-					"Contents/Frameworks/$lib_bn" || exit 1
-				todo="$todo .//Contents/Frameworks/$lib_bn"
-			fi
-			install_name_tool -change \
-				"$lib" \
-				"@executable_path/$fw_relpath/$lib_bn" \
-				"$todo_obj" || exit 1
+			#Find all libraries $todo_obj depends on, but skip system libraries
+			for lib in $(
+				otool -L $todo_obj | \
+				sed -n 's|^.*[[:space:]]\([^[:space:]]*\.dylib\).*$|\1|p' | \
+				egrep -v '^(/usr/lib)|(/System)|@executable_path@' \
+			); do
+				lib_bn="$(basename "$lib")" ;
+				if ! test -f "Contents/Frameworks/$lib_bn"; then
+					echo "App: $tag: Adding library: $lib_bn (because of: $todo_obj)"
+					cp "$lib" "Contents/Frameworks/$lib_bn"
+					chmod 755 "Contents/Frameworks/$lib_bn"
+					install_name_tool \
+						-id "$lib_bn" \
+						"Contents/Frameworks/$lib_bn" || exit 1
+					todo="$todo ./Contents/Frameworks/$lib_bn"
+				fi
+				install_name_tool -change \
+					"$lib" \
+					"@executable_path/$fw_relpath/$lib_bn" \
+					"$todo_obj" || exit 1
+			done
 		done
 	done
-done
-echo "Bundle completed"
+
+	#We handle only one level here, because this is recursive anyway
+	for nested_app in $(find ./ -type d -name "*.app" ! -path "*.app/*"); do
+		echo "App: $tag: Post-processing nested app: $nested_app"
+		
+		if ! test -d "$nested_app/Contents/Frameworks"; then
+			echo "App: "$(basename "$nested_app")": Symlinking Frameworks-folder to parent $bundle"
+			na_relpath=$(echo "$nested_app" |\
+				sed -n 's|^\(\.//*\)\(\([^/][^/]*/\)*\)[^/][^/]*$|\2|gp' | \
+				sed -n 's|[^/][^/]*/|../|gp' \
+			)"Contents/Frameworks"
+			ln -s "../../$na_relpath" "$nested_app/Contents/Frameworks"
+		fi
+		
+		CompleteSingleApp "$nested_app"
+	done
+
+	echo "App completed: $bundle"
+	popd > /dev/null
+}
+
+CompleteSingleApp "$bundle"

Re: [PATCH] Nested app support for complete-bundle.sh

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:
Hi.

From: "Florian G. Pflug" 

> That symlinking-Framworks idea proved to be easier than I
> initially thought - here is a patch ;-)
> 
> This patch also moves pkg to the end of the list of subdirs
> in the main Makefile.am. If pkg is listed before debugger,
> than complete-bundle.sh is run _before_ the debugger binary
> is copied into the bundle, which obviously causes all kinds
> of trouble ;-)

Ooops, It was my mistake. and Thank you for correction of MAC-OSX.
It was applied now. Thanks!!:-)

Reagrds,
Hiroshi Saito

Re: [PATCH] Nested app support for complete-bundle.sh

От:
Dave Page <dpage@postgresql.org>
Дата:
Florian G. Pflug wrote:
> Hi
> 
> That symlinking-Framworks idea proved to be easier than I
> initially thought - here is a patch ;-)
> 
> This patch also moves pkg to the end of the list of subdirs
> in the main Makefile.am. If pkg is listed before debugger,
> than complete-bundle.sh is run _before_ the debugger binary
> is copied into the bundle, which obviously causes all kinds
> of trouble ;-)

Cool - I do notice that you haven't removed my 
if-appbundle-force-static-link hack - were you definitely testing a 
dynamic build? Either way, that hack should be removed again to properly 
enable this fix.

Regards, Dave.

Re: [PATCH] Nested app support for complete-bundle.sh

От:
"Florian G. Pflug" <fgp@phlo.org>
Дата:
Dave Page wrote:
> Florian G. Pflug wrote:
>> Hi
>>
>> That symlinking-Framworks idea proved to be easier than I
>> initially thought - here is a patch ;-)
>>
>> This patch also moves pkg to the end of the list of subdirs
>> in the main Makefile.am. If pkg is listed before debugger,
>> than complete-bundle.sh is run _before_ the debugger binary
>> is copied into the bundle, which obviously causes all kinds
>> of trouble ;-)
> 
> Cool - I do notice that you haven't removed my 
> if-appbundle-force-static-link hack - were you definitely testing a 
> dynamic build? Either way, that hack should be removed again to properly 
> enable this fix.

Yeah - I didn't include my changes to acinclude.m4 in the patch, because
it also includes other changes that I want to test more before I submit
them (The cleanup of SSL-Detection & usage of pg_config --libs that
we discussed). I wanted to mention that in my e-mail, but, well, I forgot...

Anyway, I did test the new complete-bundle.sh with a fully dynamic build,
and it seems to work fine. I don't have a postgres instance with the debugger
plugin running, so "fine" means "Complains about not being able to connect
to localhost". ;-)

greetings, Florian Pflug
FAQ