]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
database: Save installed package size.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 2 Mar 2013 18:45:55 +0000 (18:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 2 Mar 2013 18:45:55 +0000 (18:45 +0000)
python/pakfire/constants.py
python/pakfire/packages/installed.py
python/pakfire/repository/database.py

index 206b1f6587a1750e6c8ce2605c987b1be5368269..5dc897157cc9e590edd357d1468e873cf26b733a 100644 (file)
@@ -75,8 +75,8 @@ PACKAGE_FORMATS_SUPPORTED = [0, 1, 2, 3, 4, 5]
 PACKAGE_EXTENSION = "pfm"
 MAKEFILE_EXTENSION = "nm"
 
-DATABASE_FORMAT = 5
-DATABASE_FORMATS_SUPPORTED = [0, 1, 2, 3, 4, 5]
+DATABASE_FORMAT = 6
+DATABASE_FORMATS_SUPPORTED = [0, 1, 2, 3, 4, 5, 6]
 
 PACKAGE_FILENAME_FMT = "%(name)s-%(version)s-%(release)s.%(arch)s.%(ext)s"
 
index 910e965b49d9e93bf886858ec5585edf97587ff0..e216459c7c8eb01f4e42d1afc4d87348d7247741 100644 (file)
@@ -141,8 +141,14 @@ class DatabasePackage(Package):
 
        @property
        def inst_size(self):
-               # XXX to be done
-               return 0
+               inst_size = self.metadata.get("inst_size", None)
+
+               # As install size has not always been saved in the database
+               # use the package size instead.
+               if inst_size is None:
+                       return self.size
+
+               return inst_size
 
        @property
        def provides(self):
index 23bb64cc60591d71331ccd6635b91835f89d6605..fc8a1a94229cfeebe96fd08ee841f37699e972e8 100644 (file)
@@ -31,6 +31,7 @@ log = logging.getLogger("pakfire")
 import pakfire.packages as packages
 
 from pakfire.constants import *
+from pakfire.errors import *
 from pakfire.i18n import _
 
 class Cursor(sqlite3.Cursor):
@@ -264,6 +265,9 @@ class DatabaseLocal(Database):
                if self.format < 5:
                        c.execute("ALTER TABLE files ADD COLUMN datafile INTEGER AFTER config")
 
+               if self.format < 6:
+                       c.execute("ALTER TABLE packages ADD COLUMN inst_size INTEGER AFTER size")
+
                # In the end, we can easily update the version of the database.
                c.execute("UPDATE settings SET val = ? WHERE key = 'version'", (DATABASE_FORMAT,))
                self.__format = DATABASE_FORMAT
@@ -287,6 +291,7 @@ class DatabaseLocal(Database):
                                        groups,
                                        filename,
                                        size,
+                                       inst_size,
                                        hash1,
                                        provides,
                                        requires,
@@ -306,7 +311,7 @@ class DatabaseLocal(Database):
                                        installed,
                                        repository,
                                        reason
-                               ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
+                               ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
                                (
                                        pkg.name,
                                        pkg.epoch,
@@ -316,6 +321,7 @@ class DatabaseLocal(Database):
                                        " ".join(pkg.groups),
                                        pkg.filename,
                                        pkg.size,
+                                       pkg.inst_size,
                                        pkg.hash1,
                                        "\n".join(pkg.provides),
                                        "\n".join(pkg.requires),