Commits

Ivan Vučica committed 52eb2aa

Added check if the dependencies are actually accessible.

Comments (0)

Files changed (1)

 # Current list of checks:
 # * Does the executable depend on some external libs?[1]
 # * Does any framework depend on some external libs?[1]
+# * Are all the frameworks executable depends on included/accessible?[2]
+# * Are all the frameworks all frameworks depend on included/accessible?[2]
 
 # Extra descriptions:
 # [0] Presumptions
 #    to read Info.plist.
 # b) Any frameworks you use are in ~/Library/Frameworks or 
 #    /Library/Frameworks
+# c) Frameworks you use contain the library (or a symlink) directly
+#    in their root, and the library is named the same way.
+#    For example, something.framework/something
 #
 # [1] Dependancies on external libs
 # This is checked by running 'otool -L'. If output contains a line that
 # Note that "default install name" containing an external dependency appears
 # to be a valid reason for rejection.
 #
+# [2] System & internal dependencies
+# Each dependency printed by otool -L is verified to be accessible.
+# @executable_name is replaced with full path to executable.
+# We don't check for @rpath or @loaderpath
+#
 
 # And now for the code:
 
 EXENAME="${APPNAME%.app}"
 cd "$1"
 APPPATH="`pwd`"
+EXEPATH="$APPPATH/Contents/MacOS"
 
 # * Does the executable depend on some external libs?[1]
+cd "$APPPATH"
 cd "Contents/MacOS"
 BADLIBS=`otool -L "$EXENAME"|grep Library\/Frameworks | grep -v System`
 if [ ! -z "${BADLIBS}" ] ; then
-	echo "== PROBLEM WITH EXECUTABLE "
+	echo "== EXTERNAL DEPENDENCY IN EXECUTABLE "
 	echo $BADLIBS
 	VALIDATED=0
 	REASON="${REASON}Executable has external dependencies.\n"
 	
 	BADLIBS=`otool -L ${i%.framework}|grep Library\/Frameworks | grep -v System`
 	if [ ! -z "${BADLIBS}" ] ; then
-		echo "== PROBLEM WITH $i"
+		echo "== EXTERNAL DEPENDENCY IN $i"
 		echo $BADLIBS
 
 		VALIDATED=0
 done
 
 
-# Ok... are we done?
+# * Are all the frameworks executable depends on included/accessible?
+cd "$APPPATH"
+cd "Contents/MacOS"
+FIRSTLINE=1
+otool -L "$EXENAME" | while read DEP; do
+	if [ "$FIRSTLINE" -eq 1 ] ; then
+		FIRSTLINE=0
+		continue
+	fi
+	DEP=`sed 's/^\(.*\) (.*)$/\1/g' <<< $DEP` 
+	DEPCHECK=`sed "s:@executable_path:$EXEPATH:g" <<< $DEP`
+	if [ ! -e "$DEPCHECK" ] ; then
+		echo "== MISSING DEPENDENCY IN EXECUTABLE "
+		echo $DEPCHECK
+	
+		VALIDATED=0
+		REASON="${REASON}Executable has missing dependencies.\n"
+	fi
+done
+
+
+# * Are all the frameworks all frameworks depend on included/accessible?[2]
+# NOTE: This check was not tested.
+
+cd "$APPPATH"
+cd Contents/Frameworks
+for i in * ; do 
+	cd $i
+	
+	FIRSTLINE=1
+	otool -L "${i%.framework}" | while read DEP; do
+		if [ "$FIRSTLINE" -eq 1 ] ; then
+			FIRSTLINE=0
+			continue
+		fi
+		DEP=`sed 's/^\(.*\) (.*)$/\1/g' <<< $DEP` 
+		DEPCHECK=`sed "s:@executable_path:$EXEPATH:g" <<< $DEP`
+		if [ ! -e "$DEPCHECK" ] ; then
+			echo "== MISSING DEPENDENCY IN EXECUTABLE "
+			echo $DEPCHECK
+		
+			VALIDATED=0
+			REASON="${REASON}Executable has missing dependencies.\n"
+		fi
+	done
+	cd ..
+done
+
+# Ok... we are done!
 
 if [ $VALIDATED -eq 1 ] ; then
 	echo