Re: 64 bit support, finally!

"Jan Niklas Hasse" <[email protected]>
Newsgroups gmane.comp.autopackage.devel
Message-ID <[email protected]>
Ah I forgot: Here's a slightly new version of the patch. I did this
one with "svn diff", hope it works.

---------------------------------------------------------------------
To unsubscribe, e-mail: autopackage-dev-unsubscribe-OfajU3CKLf1/[email protected]
For additional commands, e-mail: autopackage-dev-help-OfajU3CKLf1/[email protected]
x86_64.diff (text/x-diff, 12.2 KB)
Index: release/autopackage-build
===================================================================
--- release/autopackage-build	(Revision 2439)
+++ release/autopackage-build	(Arbeitskopie)
@@ -409,12 +409,16 @@
 
 tar -c --bzip2 --file "autopackage.tar.bz2" "autopackage/"
 ! "$autopackage_silent" && out "finished."
-# copy to native x86 architecture directory for downloading
-mkdir -p "$target/x86"
-cp -f "autopackage.tar.bz2" "$target/x86/"
+# copy to native architecture directory for downloading
+
+cpu_architecture="x86"
+if [[ $(uname -m) == "x86_64" ]]; then cpu_architecture="x86_64"; fi
+
+mkdir -p "$target/$cpu_architecture"
+cp -f "autopackage.tar.bz2" "$target/$cpu_architecture/"
 ! "$autopackage_silent" && out " "
 
-cd "$target/x86"
+cd "$target/$cpu_architecture"
 ! "$autopackage_silent" && out "Moved tools package to $PWD/autopackage.tar.bz2 ."
 
 rm -fr "$apkg_build_dir"
Index: makepackage
===================================================================
--- makepackage	(Revision 2439)
+++ makepackage	(Arbeitskopie)
@@ -694,12 +694,7 @@
 		return 1
 	fi
 
-	if [[ "$CPUARCHITECTURES" != "x86" ]] && [[ "$CPUARCHITECTURES" != "" ]]; then
-		red; outn "ERROR: "; normal; out "Sorry, autopackage is x86 only for now. Please do not request non-x86 architectures."
-		return 1
-	fi
 
-
 	# **********************************************************
 	#  2.4 Set Meta Defaults
 	# **********************************************************
@@ -750,8 +745,17 @@
 		COMPRESSION="bzip2"
 	fi
 
-	CPUARCHITECTURE=x86
-	CPUARCHITECTURES=x86
+	cpu_architecture=x86
+	if [[ $(uname -r) == "x86_64" ]]; then
+		cpu_architecture=x86_64
+	fi
+	if [[ -n $CPUARCHITECTURE ]]; then
+		red; outn "WARNING: "; normal; out "CPUArchitecture is deprecated. Use CPUArchitectures instead."
+	else
+		CPUARCHITECTURE=$cpu_architecture
+	fi
+	
+	CPUARCHITECTURES=$cpu_architecture
 
 	# determine interface version and normalize
 	local interfaceversion_major=`getMajor "$INTERFACEVERSION"`
@@ -903,7 +907,7 @@
 	stub=$( echo "$stub" | replaceStr "%SoftwareVersion%" "$SOFTWAREVERSION" )
 	stub=$( echo "$stub" | replaceStr "%InterfaceVersion%" "$INTERFACEVERSION" )
 	stub=$( echo "$stub" | replaceStr "%PackageVersion%" "$PACKAGEVERSION" )
-	stub=$( echo "$stub" | replaceStr "%CPUArchitecture%" "$CPUARCHITECTURE" )
+	stub=$( echo "$stub" | replaceStr "%CPUArchitectures%" "$CPUARCHITECTURES" )
 	stub=$( echo "$stub" | replaceStr "%AutopackageTarget%" "$AUTOPACKAGETARGET" )
 
 	# Make the built package require the current autopackage version
Index: share/apkg-script-utils
===================================================================
--- share/apkg-script-utils	(Revision 2439)
+++ share/apkg-script-utils	(Arbeitskopie)
@@ -419,6 +419,62 @@
 
 
 ##
+# _getLibraryPath <LIBRARY>
+# LIBRARY: The name of the library
+# Outputs: Paths of the library
+# Returns: non-zero if the library isn't found at all
+#
+# Get's the path of a library and automatically filters by the architecture.
+# For example if $cpu_architecture is "x86_64" it will return the path of the 64 bit library.
+# If $cpu_architecture is "x86" or isn't set, only 32 bit libraries will be returned.
+### START GETLIBRARYPATHS
+function _getLibraryPaths() {
+	local lib=""
+	lib=$1
+	if [[ "$lib" == "" ]]; then
+		err "must specify the library to check for"
+		popOptE
+		return 1
+	fi
+	
+    local cacheresult
+    cacheresult=$( /sbin/ldconfig -p | grep "${lib}\(\.[[:digit:]\.]*\)\?$" | awk 'BEGIN {FS=" => "} { print $2 }' | while read; do test -f "$REPLY" && echo $REPLY; done )
+	local libpathresult=`_scanLDLibPath "${lib}"`
+    local liblist=`echo -e "${libpathresult}\n${cacheresult}" | grep "\(.\)" | sort | uniq`
+    local result="";
+    if [[ "$liblist" == "" ]]; then warn "$1 not found"; popOptE; return 1; fi; # not found in cache
+
+    # make sure that libraries in $liblist are compatible with our architecture
+    local proper_architecture=false
+
+    local oIFS="$IFS"
+    IFS=$'\n';
+
+    local l
+    local -a liblist_array
+    liblist_array=($liblist);
+    liblist=""
+    for l in "${liblist_array[@]}"; do
+        if isLibrary32 "$l"; then
+        	if [[ "$cpu_architecture" != "x86_64" ]]; then
+            	proper_architecture=true
+            	liblist=$(echo -e "$liblist$l\n")
+            fi
+        else
+        	if [[ "$cpu_architecture" == "x86_64" ]]; then
+            	proper_architecture=true
+            	liblist=$(echo -e "$liblist$l\n")
+            fi
+        fi
+    done
+
+    IFS="$oIFS"
+    
+    echo $liblist
+}
+### END GETLIBRARYPATHS
+
+##
 # testForLib [-v] [-i] LibraryName
 # -v: Verbose mode. Print each version number out on stdout.
 # -i: Print each unique interface version found on stdout.
@@ -471,47 +527,8 @@
 	return 1
     fi
 
-    local cacheresult
-    cacheresult=$( /sbin/ldconfig -p | grep "${lib}\(\.[[:digit:]\.]*\)\?$" | awk 'BEGIN {FS=" => "} { print $2 }' | while read; do test -f "$REPLY" && echo $REPLY; done )
-    trace cacheresult=$cacheresult
-    local libpathresult=`_scanLDLibPath "${lib}"`
-    trace libpathresult=$libpathresult
-    local liblist=`echo -e "${libpathresult}\n${cacheresult}" | grep "\(.\)" | sort | uniq`
-    local result="";
-    if [[ "$liblist" == "" ]]; then warn "$1 not found"; popOptE; return 1; fi; # not found in cache
-    trace liblist=$liblist
+    liblist=$(_getLibraryPaths $lib)
 
-    # make sure that libraries in $liblist are only valid 32-bit libs
-    local found_32bit=false
-
-    local oIFS="$IFS"
-    IFS=$'\n';
-
-    local l
-    local -a liblist_array
-    liblist_array=($liblist);
-    for l in "${liblist_array[@]}"; do
-        if isLibrary32 "$l"; then
-            found_32bit=true
-            break;
-        fi
-    done
-
-    IFS="$oIFS"
-
-    trace $found_32bit
-
-    if ! $found_32bit; then
-        warn "only 64-bit libraries were found, returning 1"
-        popOptE;
-        return 1
-    fi
-
-    if ! $verbose && ! $verbose_i; then
-	popOptE
-	return 0
-    fi
-
     # we want to loop over the results until we find a library that matches the required version
     (
     echo "$liblist" | while read; do
@@ -3360,12 +3377,16 @@
 # Checks the system C library for the given version symbols. The missing symbols, if any
 # will be output to stdout.
 function _checkForGlibcVersions() {
-    if isLibrary32 /lib/libc.so.6; then
-        dumpverdefs32 /lib/libc.so.6 $@
+	local lib=$(_getLibraryPaths libc.so.6)
+	#FIXME: _getLibraryPaths might return more then one path
+
+    if isLibrary32 $lib; then
+        dumpverdefs32 $lib $@
     else
-        dumpverdefs64 /lib/libc.so.6 $@
+        dumpverdefs64 $lib $@
     fi
 }
+	
 
 ##
 # getPythonLibDir
Index: share/apkg-dep
===================================================================
--- share/apkg-dep	(Revision 2439)
+++ share/apkg-dep	(Arbeitskopie)
@@ -377,8 +377,20 @@
 
 	# Verify package matches machine cpu architecture
 	c=$( echo "$header" | grep CPUArchitecture | sed 's/# CPUArchitecture //' )
-	trace package cpuarchitecture is \"$c\"
-	if [[ "$cpu_architecture" != "$c" ]]; then
+	if [[ $c != "" ]]; then
+		trace package cpuarchitecture is \"$c\"
+		if [[ "$cpu_architecture" != "$c" ]]; then
+			continue
+		fi
+	fi
+	# TODO: I haven't tested this:
+	c=$( echo "$header" | grep CPUArchitectures | sed 's/# CPUArchitectures //' )
+	trace package cpuarchitectures are \"$c\"
+	local found=false
+	for a in $c; do
+		if [[ "$a" == "$c" ]]; then found=true; fi
+	done
+	if ! $found; then
 		continue
 	fi
 
Index: share/backend.template
===================================================================
--- share/backend.template	(Revision 2439)
+++ share/backend.template	(Arbeitskopie)
@@ -97,15 +97,28 @@
 
     # check if binary is usable on target machine, if not error
     found=false
+    x86found=false
     for a in $CPUARCHITECTURES; do
         if [[ "$a" == "$cpu_architecture" ]]; then
             found=true
+            break
         fi
+        if [[ "$a" == "x86" ]]; then
+        	x86found=true
+        fi
     done
     if ! $found; then
-        err failed cpu architecture payload check
-        __cleanup_backend
-        exit 1
+		if $x86found && [[ "$cpu_architecture" == "x86_64" ]]; then
+		    # if we are on x86_64 we are able to run x86 code
+			cpu_architecture="x86"
+			trace cpu architecture changed to x86
+			found=true
+			break
+		else
+			err failed cpu architecture payload check
+			__cleanup_backend
+			exit 1
+		fi
     fi
     trace passed cpu architecture payload check
 
Index: share/apkg-funclib
===================================================================
--- share/apkg-funclib	(Revision 2439)
+++ share/apkg-funclib	(Arbeitskopie)
@@ -403,8 +403,10 @@
 	    # like Fedora. But, it's not right for pure64 distros like
 	    # Debian/Ubuntu or Gentoo
 
-            i386 | i486 | i586 | i686 | x86_64 | athlon)
+            i386 | i486 | i586 | i686 | athlon)
                 export cpu_architecture="x86";;
+            x86_64)
+            	export cpu_architexture="x86_64";;
 
         esac
     fi
@@ -2206,20 +2208,28 @@
                 # check CPU arch is OK before we run any native code
                 needed_archs=$( echo "$tmp" | sed -n '1p' )
                 local found=false
+				local x86found=false
                 for a in $needed_archs; do
                     if [[ "$a" == "$cpu_architecture" ]]; then found=true; fi
+					if [[ "$a" == "x86" ]]; then x86found=true; fi
                 done
-
+				trace "needed: $needed_archs arch: $cpu_architecture x86found: $x86found found: $found"
                 if ! $found; then
-
-                    # arch command is not consistent like ia32.linux != i686 so use uname
-                    locateCommand uname
-                    this_arch=`"$lc_location" -m`
-                    out
-                    out "$intl_UNSUPPORTED_CPU_ARCH" "$needed_archs" "$this_arch"
-                    out
-                    unset this_arch
-                    return 1
+					if $x86found && [[ "$cpu_architecture" == "x86_64" ]]; then
+						# if we are on x86_64 we are able to run x86 code
+						cpu_architecture="x86"
+						trace cpu architecture changed to x86
+						found=true
+					else
+		                # arch command is not consistent like ia32.linux != i686 so use uname
+		                locateCommand uname
+		                this_arch=`"$lc_location" -m`
+		                out
+		                out "$intl_UNSUPPORTED_CPU_ARCH" "$needed_archs" "$this_arch"
+		                out
+		                unset this_arch
+		                return 1
+		            fi
                 fi
 
                 trace passed cpu arch test
Index: share/installer.template
===================================================================
--- share/installer.template	(Revision 2439)
+++ share/installer.template	(Arbeitskopie)
@@ -24,22 +24,6 @@
 
 %ErrorMessage%
 
-# are we on 32bit (or 64bit + compat libs?)
-locateCommand uname
-cpu_architecture=`"$lc_location" -m`
-case "$cpu_architecture" in
-	i386 | i486 | i586 | i686 )
-		export cpu_architecture="x86";;
-esac
-
-if [[ "$cpu_architecture" != "x86" ]]; then
-	if [ ! -d /usr/lib32 ]; then
-		errorMessage "Sorry, Autopackage only supports x86 32-bit systems, or 64-bit systems with compatibility libraries installed. Please install the compatibility libraries and rerun install." "Error Installing Autopackage"
-		rm -rf "$WORKING_DIRECTORY"
-		exit 1
-	fi
-fi
-
 # setup XDG configuration variables scoped for autopackage
 #
 #   AUTOPACKAGE_CONFIG_HOME     User configuration directory
Index: share/installer.2.template
===================================================================
--- share/installer.2.template	(Revision 2439)
+++ share/installer.2.template	(Arbeitskopie)
@@ -24,22 +24,6 @@
 
 %ErrorMessage%
 
-# are we on 32bit (or 64bit + compat libs?)
-locateCommand uname
-cpu_architecture=`"$lc_location" -m`
-case "$cpu_architecture" in
-	i386 | i486 | i586 | i686 )
-		export cpu_architecture="x86";;
-esac
-
-if [[ "$cpu_architecture" != "x86" ]]; then
-	if [ ! -d /usr/lib32 ]; then
-		errorMessage "Sorry, Autopackage only supports x86 32-bit systems, or 64-bit systems with compatibility libraries installed. Please install the compatibility libraries and rerun install." "Error Installing Autopackage"
-		rm -rf "$WORKING_DIRECTORY"
-		exit 1
-	fi
-fi
-
 # setup XDG configuration variables scoped for autopackage
 #
 #   AUTOPACKAGE_CONFIG_HOME     User configuration directory
apgcc64.patch (text/x-diff, 619 B)
--- autopackage.old/apbuild/apsymbols.h	2008-04-19 22:08:26.000000000 +0200
+++ autopackage/apbuild/apsymbols.h	2008-04-19 22:06:49.000000000 +0200
@@ -46,7 +46,9 @@
 __asm__(".symver pthread_cond_signal,pthread_cond_signal@GLIBC_2.0");
 __asm__(".symver pthread_cond_timedwait,pthread_cond_timedwait@GLIBC_2.0");
 __asm__(".symver pthread_cond_wait,pthread_cond_wait@GLIBC_2.0");
+#ifndef __x86_64
 __asm__(".symver realpath,realpath@GLIBC_2.0");
+#endif
 __asm__(".symver regexec,regexec@GLIBC_2.0");
 __asm__(".symver __strcasecmp_l,__strcasecmp_l@GLIBC_2.1");
 __asm__(".symver __strcoll_l,__strcoll_l@GLIBC_2.1");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.