Mailinglist Archive: opensuse-commit (2092 mails)

< Previous Next >
commit smart
  • From: root@xxxxxxxxxxxxxxx (h_root)
  • Date: Thu, 09 Aug 2007 22:22:11 +0200
  • Message-id: <20070809202211.DD57C67832C@xxxxxxxxxxxxxxx>

Hello community,

here is the log from the commit of package smart
checked in at Thu Aug 9 22:22:11 CEST 2007.

--------
--- smart/smart.changes 2007-08-07 09:41:03.000000000 +0200
+++ /mounts/work_src_done/STABLE/smart/smart.changes    2007-08-07 13:14:45.765325000 +0200
@@ -1,0 +2,6 @@
+Tue Aug  7 13:12:21 CEST 2007 - cthiel@xxxxxxx
+
+- readded smart-trunk.patch (r877), implements cache-loaded and
+  cache-loaded-pre-link hooks
+
+-------------------------------------------------------------------

New:
----
  smart-trunk.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ smart.spec ++++++
--- /var/tmp/diff_new_pack.I32538/_old  2007-08-09 21:26:48.000000000 +0200
+++ /var/tmp/diff_new_pack.I32538/_new  2007-08-09 21:26:48.000000000 +0200
@@ -20,7 +20,7 @@
 %endif
 Summary:        Smart Package Manager
 Version:        0.51
-Release:        30
+Release:        32
 Source:         %{name}-%{version}.tar.bz2
 Source1:        distro.py
 Source2:        %{name}.desktop
@@ -36,6 +36,7 @@
 Patch100:       %{name}-fix-archscore-add-disable-biarch-option.patch
 Patch101:       %{name}-better-x86_64-support.patch
 Patch102:       %{name}-broken-repo-without-summary-or-description-workaround.diff
+Patch999:       %{name}-trunk.patch
 URL:            http://smartpm.org
 Group:          System/Packages
 License:        GPL v2 or later
@@ -105,6 +106,7 @@
 %patch100
 %patch101
 %patch102
+%patch999
 
 %build
 export CFLAGS="$RPM_OPT_FLAGS"
@@ -213,6 +215,9 @@
 
 %changelog
 * Tue Aug 07 2007 - cthiel@xxxxxxx
+- readded smart-trunk.patch (r877), implements cache-loaded and
+  cache-loaded-pre-link hooks
+* Tue Aug 07 2007 - cthiel@xxxxxxx
 - fixed gpg key importing (#296793)
 * Mon Jul 16 2007 - cthiel@xxxxxxx
 - correctly install smart/commands/newer.py





++++++ smart-trunk.patch ++++++
Index: smart/ccache.c
===================================================================
--- smart/ccache.c      (.../tags/0.51) (revision 877)
+++ smart/ccache.c      (.../trunk)     (revision 877)
@@ -128,21 +128,19 @@
     PyObject *_objmap;
 } CacheObject;
 
-/*
 static PyObject *
-getSysConf(void)
+getHooks(void)
 {
-    static PyObject *sysconf = NULL;
-    if (sysconf == NULL) {
+    static PyObject *hooks = NULL;
+    if (hooks == NULL) {
         PyObject *module = PyImport_ImportModule("smart");
         if (module) {
-            sysconf = PyObject_GetAttrString(module, "sysconf");
+            hooks = PyObject_GetAttrString(module, "hooks");
             Py_DECREF(module);
         }
     }
-    return sysconf;
+    return hooks;
 }
-*/
 
 static PyObject *
 getPkgConf(void)
@@ -2766,6 +2764,7 @@
 {
     int i, len;
     int total = 1;
+    PyObject *hooks;
     PyObject *prog;
     PyObject *ret;
 
@@ -2802,12 +2801,15 @@
             CALLMETHOD(loader, "load", NULL);
     }
     CALLMETHOD(self, "loadFileProvides", NULL);
+    hooks = getHooks();
+    CALLMETHOD(hooks, "call", "sO", "cache-loaded-pre-link", self);
     PyDict_Clear(self->_objmap);
     CALLMETHOD(self, "linkDeps", NULL);
     CALLMETHOD(prog, "setDone", NULL);
     CALLMETHOD(prog, "show", NULL);
     CALLMETHOD(prog, "stop", NULL);
     Py_DECREF(prog);
+    CALLMETHOD(hooks, "call", "sO", "cache-loaded", self);
     Py_RETURN_NONE;
 }
 
Index: smart/cache.py
===================================================================
--- smart/cache.py      (.../tags/0.51) (revision 877)
+++ smart/cache.py      (.../trunk)     (revision 877)
@@ -641,11 +641,13 @@
             if not loader._packages:
                 loader.load()
         self.loadFileProvides()
+        hooks.call("cache-loaded-pre-link", self)
         self._objmap.clear()
         self.linkDeps()
         prog.setDone()
         prog.show()
         prog.stop()
+        hooks.call("cache-loaded", self)
 
     def unload(self):
         self.reset()
Index: smart/backends/rpm/pm.py
===================================================================
--- smart/backends/rpm/pm.py    (.../tags/0.51) (revision 877)
+++ smart/backends/rpm/pm.py    (.../trunk)     (revision 877)
@@ -38,7 +38,7 @@
 try:
     ENCODING = locale.getpreferredencoding()
 except locale.Error:
-    ENCODING = "C"
+    ENCODING = "ascii"
 
 class RPMPackageManager(PackageManager):
 
Index: tests/load-hooks.txt
===================================================================
--- tests/load-hooks.txt        (.../tags/0.51) (revision 0)
+++ tests/load-hooks.txt        (.../trunk)     (revision 877)
@@ -0,0 +1,85 @@
+
+In that test we'll add a couple of hooks that should be called by the
+cache when loading packages.
+
+We want everything from the cache.
+
+  >>> from smart.cache import *
+
+  >>> class TestPackage(Package): pass
+  >>> class TestProvides(Provides): pass
+  >>> class TestDepends(Depends):
+  ...   def matches(self, prv):
+  ...     return prv.name == self.name and prv.version == self.version
+  >>> class TestUpgrades(Requires, TestDepends): pass
+
+  >>> class TestLoader(Loader):
+  ...     def load(self):
+  ...         pkg1 = self.buildPackage(
+  ...             (TestPackage, "name1", "version1"),
+  ...             [(TestProvides, "name1", "version1")], [], [], [])
+  ...         pkg1.loaders[self] = 1
+  ...         pkg2 = self.buildPackage(
+  ...             (TestPackage, "name2", "version2"),
+  ...             [], [], [], [])
+  ...         pkg2.loaders[self] = 2
+
+
+Then, we create an instance of it.
+
+  >>> loader = TestLoader()
+
+
+We'll also create a cache, to include the loader into.
+
+  >>> cache = Cache()
+  >>> cache.addLoader(loader)
+
+
+Now we create our hooks, and plug them into the specific places.
+
+The first hook will add an artificial upgrades relation between
+package name2 and name1.
+
+  >>> verify_data = []
+
+  >>> def add_upgrade(cache):
+  ...     # First, check the current state.
+  ...     pkg1 = cache.getPackages("name1")[0]
+  ...     verify_data.append(pkg1.provides[0].upgradedby)
+  ...
+  ...     # Then, stick an artificial upgrades relation.
+  ...     upg = TestUpgrades("name1", "=", "version1")
+  ...     cache._upgrades.append(upg)
+  ...     pkg2 = cache.getPackages("name2")[0]
+  ...     pkg2.upgrades += (upg,)
+
+
+Our second hook will just verify that the relation has been linked.
+
+  >>> def check_upgrade(cache):
+  ...     pkg1 = cache.getPackages("name1")[0]
+  ...     verify_data.append(pkg1.provides[0].upgradedby)
+
+
+Let's link them effectively.
+
+  >>> hooks.register("cache-loaded-pre-link", add_upgrade)
+  >>> hooks.register("cache-loaded", check_upgrade)
+
+
+Loading the cache should run these hooks.
+
+  >>> cache.load()
+  Updating cache...               ######################################## [100%]
+  <BLANKLINE>
+
+
+Let's see if our hooks got called correctly.
+
+  >>> import pprint
+  >>> pprint.pprint(verify_data)
+  [(), [name1 = version1]]
+
+
+vim:ft=doctest

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread