Author: ks156
Date: 2009-03-12 11:42:55 +0100 (Thu, 12 Mar 2009)
New Revision: 3983

Modified:
   
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/misc/installedFileDB.py
   
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
Log:
* Added a new configuration variable to know the architecture.
  Some packages, like the server, are differents for 64 bits. Now I can detect
  the architecture, and skip the packages if they're not for the current arch.


Modified: 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/misc/installedFileDB.py
===================================================================
--- 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/misc/installedFileDB.py
     2009-03-12 10:37:38 UTC (rev 3982)
+++ 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/misc/installedFileDB.py
     2009-03-12 10:42:55 UTC (rev 3983)
@@ -6,7 +6,7 @@
 def isInstalledDb():
     return os.path.isfile("/etc/tuxdroid/software.db")
 
-def parseDb(data):
+def parseDb(data, ARCH):
     tempList = []
     toInstall = []
     toUpdate = []
@@ -43,20 +43,39 @@
             f = open("/etc/tuxdroid/software.db")
             stream = f.read()
             lines = stream.split('\n')
+            # Read each entry
             for entry in data:
-                found = False
-                for line in lines:
-                    # Known destination but new md5Tag
-                    if line.find(entry['md5Tag']) == -1 and \
-                            line.find(entry['destination']) != -1:
+                # Check if the entry is for the correct arch
+                if __isRightArchitecture(entry, ARCH):
+
+                    # Check each line of the file
+                    found = False
+                    for line in lines:
+                        # Extract the source and the destination from the db
+                        try:
+                            dest = line.split("|")[2]
+                            src = line.split("|")[3]
+                        except:
+                            continue
+                        
+                        # Be sure the current line is for the right 
architecture
+                        if __isRightArchitecture({'source' : src}, ARCH):
+                            # Known destination but new md5Tag
+                            if line.find(entry['md5Tag']) == -1 and \
+                                    dest == entry['destination']:
+                                toInstall.append(entry)
+                                found = True
+                            # Known destination, same md5Tag 
+                            elif line.find(entry['md5Tag']) != -1 and \
+                                    dest == entry['destination']:
+                                found = True
+                        # Bad architecture : skip line
+                        else:
+                            continue
+
+                    # Item not found on the DB : new item to install
+                    if not found:
                         toInstall.append(entry)
-                        found = True
-                    # Known destination, same md5Tag 
-                    if line.find(entry['md5Tag']) != -1 and \
-                            line.find(entry['destination']) != -1:
-                        found = True
-                if not found:
-                    toInstall.append(entry)
     
     return toInstall, toRemove                       
 
@@ -70,3 +89,20 @@
     f.close()
     os.system("mv /etc/tuxdroid/software.db1 /etc/tuxdroid/software.db")
 
+
+def __isRightArchitecture(item, ARCH):
+    # Unix32 file (x86)
+    if item['source'].find("unix32") != -1:
+        if ARCH == "x86":
+            return True
+        else:
+            return False
+    # Unix 64 file (x86_64)
+    elif item['source'].find("unix64") != -1:
+        if ARCH == "x86":
+            return False
+        else:
+            return True
+    else:
+        return True
+

Modified: 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
===================================================================
--- 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
     2009-03-12 10:37:38 UTC (rev 3982)
+++ 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
     2009-03-12 10:42:55 UTC (rev 3983)
@@ -10,6 +10,8 @@
 import sys
 import os
 
+ARCH = None
+
 DEBUG = 0
 
 def __usage():
@@ -51,7 +53,7 @@
 
     # Retrieve the DB file
     if isInstalledDb():
-        toInstall, toRemove = parseDb(data)
+        toInstall, toRemove = parseDb(data, ARCH)
     else:
         toInstall = data
         toRemove = []
@@ -143,11 +145,44 @@
                 if os.path.isdir(dest):
                     RMDirs(dest)
 
+def __isRightArchitecture(item):
+    global ARCH
+    # Unix32 file (x86)
+    if item['source'].find("unix32") != -1:
+        if ARCH == "x86":
+            return True
+        else:
+            return False
+    # Unix 64 file (x86_64)
+    elif item['source'].find("unix64") != -1:
+        if ARCH == "x86":
+            return False
+        else:
+            return True
+    else:
+        return True
+
+def __retrieveArchitecture():
+    global ARCH
+    if os.path.isfile("/etc/tuxdroid/tuxdroid.conf"):
+        f = open("/etc/tuxdroid/tuxdroid.conf")
+        stream = f.read()
+        lines = stream.split('\n')
+        for line in lines:
+            if line.find("ARCH=") != -1:
+                ARCH=line[5:]
+        f.close()
+        if ARCH == None:
+            ARCH="x86"
+        return 0
+    return -1
+
 def main():
     global DEBUG
     
     # Set the default version type
     VERSION="Online"
+    __retrieveArchitecture()
     
     # Set the options parameters
     try:


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to