[packagekit] packagekit: Branch 'master' - 7 commits

Richard Hughes hughsient at kemper.freedesktop.org
Tue Oct 23 06:45:42 PDT 2007


 AUTHORS                                |    3 
 Makefile.am                            |   70 +++++++--------
 NEWS                                   |   84 ++++++++++++++----
 backends/BACKENDS                      |   44 ++++-----
 backends/Makefile.am                   |    4 
 backends/pisi/.gitignore               |   10 ++
 backends/pisi/Makefile.am              |    8 +
 backends/pisi/helpers/Makefile.am      |   21 ++++
 backends/pisi/helpers/get-repo-list.py |   19 ++++
 backends/pisi/helpers/get-updates.py   |   19 ++++
 backends/pisi/helpers/install.py       |   19 ++++
 backends/pisi/helpers/pisiBackend.py   |  127 +++++++++++++++++++++++++++
 backends/pisi/helpers/refresh-cache.py |   19 ++++
 backends/pisi/helpers/remove.py        |   19 ++++
 backends/pisi/helpers/resolve.py       |   19 ++++
 backends/pisi/helpers/update.py        |   19 ++++
 backends/pisi/pk-backend-pisi.c        |  153 +++++++++++++++++++++++++++++++++
 backends/yum/helpers/yumBackend.py     |    4 
 client/pk-console.c                    |   20 ++++
 configure.ac                           |    3 
 docs/pk-introduction.xml               |    4 
 html/pk-download.html                  |    1 
 libpackagekit/pk-enum.c                |    1 
 libpackagekit/pk-enum.h                |    1 
 python/packagekit/backend.py           |    2 
 src/pk-spawn.c                         |    2 
 26 files changed, 617 insertions(+), 78 deletions(-)

New commits:
commit cf58996592ec16abd10a809f20da6c9613501e97
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 23 14:39:16 2007 +0100

    prepare for release

diff --git a/NEWS b/NEWS
index 5d622ac..46fb3c7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,22 +1,68 @@
-=============
+~~~~~~~~~~~~~
+Version 0.1.1
+~~~~~~~~~~~~~
+
+* New backends:
+ - A SMART backend (James Bowes)
+ - A PiSi backend (S.Çağlar Onur)
+
+* New features:
+ - A better, easier to use website; http://www.packagekit.org (Richard Hughes)
+ - Added missing install-file.py so we can do local rpm installs (Tim Lauridsen)
+ - Be ultra-paranoid about validating input from the user (Richard Hughes)
+ - Send SIGQUIT and then SIGKILL after a little delay, so we can clean up the
+   backends nicely by unlocking when we cancel (Richard Hughes)
+ - Add resolve functionality in pkcon to allow non-package_id use, for instance
+   'pkcon remove gimp' now does the right thing (Richard Hughes)
+ - Display a pulsing progress bar for no-progress-updates and percentage-update
+   that is shown when using a console (James Bowes)
+ - Remove the hard dependency on NetworkManager so other networking stacks
+   can be used instead (S.Çağlar Onur, Richard Hughes)
+ - Add a filter parameter for Resolve() so we can do the filtering in the
+   spawned backend without duplicating code (James Bowes, Richard Hughes)
+ - Substantial additions to the box backend (Grzegorz Dabrowski)
+ - Add GetRepoList and RepoEnable to the yum backend (Tim Lauridsen)
+ - Add bash completion script for pkcon (James Bowes)
+ - Get the repo list for the aplm backend (Andreas Obergrusberger)
+
+* API changes:
+ - Store the transaction database in /var/lib rather than /var/db (James Bowes)
+ - Don't expose the private list in PkTaskList, instead use verified functions
+   to ensure we can't corrupt data accidentally (Richard Hughes)
+ - Don't export the private data array in PkClient or PkPackageList - this
+   breaks API, so the library version has been bumped (Richard Hughes)
+
+* Bugfixes:
+ - Fix the resolve method parameter passing - now pk-install-package should work
+   correctly (James Bowes)
+ - Fix all the copyright notices to be a standard GPL2+ boilerplate licence
+   text (Tom Parker, Robin Norwood)
+ - Dist the local apt headers so the apt backend can be compiled from a tarball
+   rather than just from git (Richard Hughes)
+ - Fix a 1-in-10 random daemon startup crash when backends do libnm_glib init,
+   shutdown, init, shutdown repeatedly (Richard Hughes)
+ - Added locking in the yum backend to allow simultaneous use of the yum command
+   line tool or yum-updatesd (Tim Lauridsen)
+ - Fix NoPercentageUpdates validity checking (James Bowes)
+
+~~~~~~~~~~~~~
 Version 0.1.0
-=============
+~~~~~~~~~~~~~
 
-- The first public release of PackageKit!
-- New gobject client library for session software to easily talk to PackageKit.
-- Asynchronous API that does not block.
-- Daemon that can queue and manage multiple simultaneous blocking and
-  non-blocking transactions
-- Client applications (pkcon and pkmon) that interact with PackageKit on the
-  command line without any GUI dependencies
-- Many compiled and scripted backends: conary, yum, apt, box, alpm
-- Comprehensive docbook documentation
-- Daemon configuration parameters in etc
-- Module level unit tests as standard
-- Python backend and frontend helper libraries
-- Transaction logging and capability exports for GUI tools
-- HAL locking supported for not-to-be interrupted phases of the transaction
-- NetworkManager integration for network state (other network detection
-  stacks can also be used in the future)
-- PolicyKit integration for fine-grained permission control.
+* The first public release of PackageKit:
+ - New gobject client library for session software to easily talk to PackageKit.
+ - Asynchronous API that does not block.
+ - Daemon that can queue and manage multiple simultaneous blocking and
+   non-blocking transactions
+ - Client applications (pkcon and pkmon) that interact with PackageKit on the
+   command line without any GUI dependencies
+ - Many compiled and scripted backends: conary, yum, apt, box, alpm
+ - Comprehensive docbook documentation
+ - Daemon configuration parameters in etc
+ - Module level unit tests as standard
+ - Python backend and frontend helper libraries
+ - Transaction logging and capability exports for GUI tools
+ - HAL locking supported for not-to-be interrupted phases of the transaction
+ - NetworkManager integration for network state
+ - PolicyKit integration for fine-grained permission control.
 
commit 2790f854a0ed214db130b2a0a0b3f314701bc0fa
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 23 14:18:47 2007 +0100

    make the daemon understand Tims' new error constant

diff --git a/docs/pk-introduction.xml b/docs/pk-introduction.xml
index 2b81240..4979c8e 100644
--- a/docs/pk-introduction.xml
+++ b/docs/pk-introduction.xml
@@ -322,6 +322,10 @@
               <entry><literal>transaction-error</literal></entry>
               <entry>There was a generic transaction error</entry>
             </row>
+            <row>
+              <entry><literal>repo-not-found</literal></entry>
+              <entry>The repository name could not be found</entry>
+            </row>
           </tbody>
         </tgroup>
       </informaltable>
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 060fd95..63a016f 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -98,6 +98,7 @@ static PkTaskEnumMatch task_error[] = {
 	{PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED,	"package-download-failed"},
 	{PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,	"dep-resolution-failed"},
 	{PK_ERROR_ENUM_CREATE_THREAD_FAILED,	"create-thread-failed"},
+	{PK_ERROR_ENUM_REPO_NOT_FOUND,		"repo-not-found"},
 	{0, NULL},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 09c94df..9673685 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -106,6 +106,7 @@ typedef enum {
 	PK_ERROR_ENUM_CREATE_THREAD_FAILED,
 	PK_ERROR_ENUM_TRANSACTION_ERROR,
 	PK_ERROR_ENUM_NO_CACHE,
+	PK_ERROR_ENUM_REPO_NOT_FOUND,
 	PK_ERROR_ENUM_UNKNOWN
 } PkErrorCodeEnum;
 
commit 0d050df43d2588c2f3c5f6a995b03e106c624929
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Tue Oct 23 15:15:55 2007 +0200

    yum: fixed traceback in repo-enable if repo dont exist, Make it send a ERROR_REPO_NOT_FOUND error

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 68129e5..e4372e8 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -743,8 +743,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 if not repo.isEnabled():
                     repo.enablePersistent()
                 
-        except Errors.RepoError,e:
-            self.error(ERROR_INTERNAL_ERROR, "repo %s is not found" % repoid)
+        except yum.Errors.RepoError,e:
+            self.error(ERROR_REPO_NOT_FOUND, "repo %s is not found" % repoid)
         
 
     def get_repo_list(self):
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 73b2545..216a965 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -40,6 +40,8 @@ ERROR_FILTER_INVALID = "filter-invalid"
 ERROR_TRANSACTION_ERROR = "transaction-error"
 ERROR_TRANSACTION_ERROR = "transaction-error"
 ERROR_NO_CACHE = "no-cache"
+ERROR_REPO_NOT_FOUND = "repo-not-found"
+
 
 STATE_DOWNLOAD = "download"
 STATE_INSTALL = "install"
commit 919a352b4c545902c2a89b181fefbcecca5e592e
Merge: 1d7fe66... e04439f...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 23 13:38:12 2007 +0100

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 1d7fe6690a37d07577a016dc2f0e46993689cfe1
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 23 13:37:42 2007 +0100

    add support for make security-check

diff --git a/Makefile.am b/Makefile.am
index 5904601..74331df 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,44 +31,48 @@ packagekitpython_PYTHON =				\
 	$(NULL)
 	
 
-EXTRA_DIST =			\
-	PackageKit.conf.in	\
-	packagekit.pc.in	\
-	COPYING			\
-	MAINTAINERS		\
-	AUTHORS			\
-	INSTALL			\
-	README			\
-	HACKING			\
-	NEWS			\
-	ChangeLog		\
+EXTRA_DIST =						\
+	PackageKit.conf.in				\
+	packagekit.pc.in				\
+	COPYING						\
+	MAINTAINERS					\
+	AUTHORS						\
+	INSTALL						\
+	README						\
+	HACKING						\
+	NEWS						\
+	ChangeLog					\
 	$(NULL)
 
 clean-local :
 	rm -f *~
 
-DISTCLEANFILES =		\
-	PackageKit-*.tar.gz	\
-	packagekit.pc		\
-	intltool-extract	\
-	intltool-merge		\
-	intltool-update		\
+security-check:
+	flawfinder `find -name "*.c"`
+
+DISTCLEANFILES =					\
+	PackageKit-*.tar.gz				\
+	packagekit.pc					\
+	intltool-extract				\
+	intltool-merge					\
+	intltool-update					\
 	$(NULL)
 
-MAINTAINERCLEANFILES =		\
-	*~			\
-	intltool-*.in		\
-	compile			\
-	configure		\
-	INSTALL			\
-	install-sh		\
-	missing			\
-	mkinstalldirs		\
-	config.guess		\
-	ltmain.sh		\
-	config.sub		\
-	depcomp			\
-	Makefile.in		\
-	config.h.*		\
-	aclocal.m4		\
+MAINTAINERCLEANFILES =					\
+	*~						\
+	intltool-*.in					\
+	compile						\
+	configure					\
+	INSTALL						\
+	install-sh					\
+	missing						\
+	mkinstalldirs					\
+	config.guess					\
+	ltmain.sh					\
+	config.sub					\
+	depcomp						\
+	Makefile.in					\
+	config.h.*					\
+	aclocal.m4					\
 	$(NULL)
+
diff --git a/src/pk-spawn.c b/src/pk-spawn.c
index bf559ab..e517e3b 100644
--- a/src/pk-spawn.c
+++ b/src/pk-spawn.c
@@ -86,7 +86,7 @@ pk_spawn_read_fd_into_buffer (gint fd, GString *string)
 	gint bytes_read;
 	gchar buffer[1024];
 
-	/* read as much as we can, TODO: should probably use g_io_channel */
+	/* ITS4: ignore, we manually NULL terminate and GString cannot overflow */
 	while ((bytes_read = read (fd, buffer, 1023)) > 0) {
 		buffer[bytes_read] = '\0';
 		g_string_append (string, buffer);
commit e04439f7c405dd34dc3927ff61d13583b1844be5
Author: S.Çağlar Onur <caglar at pardus.org.tr>
Date:   Tue Oct 23 15:27:50 2007 +0300

    Add PiSi backend

diff --git a/AUTHORS b/AUTHORS
index 806a96b..2a6628c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -7,3 +7,6 @@ Luke Macken <lmacken at redhat.com>
 Backend: conary
     Og Maciel <omaciel at foresightlinux.org>
     Elliot Peele <elliot at bentlogic.net>
+
+Backend: pisi
+    S.Çağlar Onur <caglar at pardus.org.tr>
diff --git a/backends/BACKENDS b/backends/BACKENDS
index bd149e7..3192cf5 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -1,25 +1,25 @@
 Current status of the backends
 
-                  | conary | yum | apt | box | alpm | smart |
--------------------------------------------------------------
-resolve           |        |  X  |     |  X  |      |   X
-refresh-cache     |   X    |  X  |  X  |  X  |      |
-get-updates       |   X    |  X  |     |  X  |      |
-update-system     |   X    |  X  |     |  X  |      |
-search-name       |   X    |  X  |  X  |  X  |  X   |
-search-details    |        |  X  |  X  |  X  |      |
-search-file       |        |  X  |     |  X  |      |
-search-group      |        |     |     |     |      |
-install-package   |   X    |  X  |     |  X  |  X   |
-install-file      |        |  X  |     |  X  |      |
-remove-package    |   X    |  X  |     |  X  |  X   |   X
-update-package    |        |     |     |  X  |      |
-get-depends       |        |  X  |     |  X  |      |
-get-requires      |   X    |     |     |  X  |      |
-get-description   |   X    |  X  |  X  |  X  |      |
-get-update-detail |        |     |     |     |      |
-get-repo-list     |        |  X  |     |     |  X   |
-repo-enable       |        |  X  |     |     |      |
-repo-set-data     |        |     |     |     |      |
-cancel-transaction|        |     |     |     |      |
+                  | conary | yum | apt | box | alpm | smart | pisi |
+--------------------------------------------------------------------
+resolve           |        |  X  |     |  X  |      |   X   |   X  |
+refresh-cache     |   X    |  X  |  X  |  X  |      |       |   X  |
+get-updates       |   X    |  X  |     |  X  |      |       |   X  |
+update-system     |   X    |  X  |     |  X  |      |       |      |
+search-name       |   X    |  X  |  X  |  X  |  X   |       |      |
+search-details    |        |  X  |  X  |  X  |      |       |      |
+search-file       |        |  X  |     |  X  |      |       |      |
+search-group      |        |     |     |     |      |       |      |
+install-package   |   X    |  X  |     |  X  |  X   |       |   X  |
+install-file      |        |  X  |     |  X  |      |       |      |
+remove-package    |   X    |  X  |     |  X  |  X   |   X   |   X  |
+update-package    |        |     |     |  X  |      |       |   X  |
+get-depends       |        |  X  |     |  X  |      |       |      |
+get-requires      |   X    |     |     |  X  |      |       |      |
+get-description   |   X    |  X  |  X  |  X  |      |       |      |
+get-update-detail |        |     |     |     |      |       |      |
+get-repo-list     |        |  X  |     |     |  X   |       |   X  |
+repo-enable       |        |  X  |     |     |      |       |      |
+repo-set-data     |        |     |     |     |      |       |      |
+cancel-transaction|        |     |     |     |      |       |      |
 
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 9420821..e04d333 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -24,6 +24,10 @@ if BACKEND_TYPE_YUM
 SUBDIRS += yum
 endif
 
+if BACKEND_TYPE_PISI
+SUBDIRS += pisi
+endif
+
 clean-local :
 	rm -f *~
 
diff --git a/backends/pisi/.gitignore b/backends/pisi/.gitignore
new file mode 100644
index 0000000..c851833
--- /dev/null
+++ b/backends/pisi/.gitignore
@@ -0,0 +1,10 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.la
+*.lo
+*.loT
+*.o
+*~
+
diff --git a/backends/pisi/Makefile.am b/backends/pisi/Makefile.am
new file mode 100644
index 0000000..e0c28d0
--- /dev/null
+++ b/backends/pisi/Makefile.am
@@ -0,0 +1,8 @@
+SUBDIRS = helpers
+plugindir = @PK_PLUGIN_DIR@
+plugin_LTLIBRARIES = libpk_backend_pisi.la
+libpk_backend_pisi_la_SOURCES = pk-backend-pisi.c
+libpk_backend_pisi_la_LIBADD = @PK_PLUGIN_LIBS@
+libpk_backend_pisi_la_LDFLAGS = -module -avoid-version
+libpk_backend_pisi_la_CFLAGS = @PK_PLUGIN_CFLAGS@
+
diff --git a/backends/pisi/helpers/Makefile.am b/backends/pisi/helpers/Makefile.am
new file mode 100644
index 0000000..6773d6c
--- /dev/null
+++ b/backends/pisi/helpers/Makefile.am
@@ -0,0 +1,21 @@
+
+helperdir = $(datadir)/PackageKit/helpers/pisi
+
+NULL =
+
+dist_helper_DATA = 			\
+	resolve.py			\
+	remove.py			\
+	refresh-cache.py 		\
+	get-updates.py			\
+	get-repo-list.py 		\
+	install.py			\
+	update.py			\
+	pisiBackend.py			\
+	$(NULL)
+
+install-data-hook:
+	chmod a+rx $(DESTDIR)$(helperdir)/*.py
+
+clean-local :
+	rm -f *~
diff --git a/backends/pisi/helpers/get-repo-list.py b/backends/pisi/helpers/get-repo-list.py
new file mode 100644
index 0000000..b14903d
--- /dev/null
+++ b/backends/pisi/helpers/get-repo-list.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
+backend.get_repo_list()
+
+sys.exit()
diff --git a/backends/pisi/helpers/get-updates.py b/backends/pisi/helpers/get-updates.py
new file mode 100644
index 0000000..5710a02
--- /dev/null
+++ b/backends/pisi/helpers/get-updates.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[2:])
+backend.get_updates()
+
+sys.exit()
diff --git a/backends/pisi/helpers/install.py b/backends/pisi/helpers/install.py
new file mode 100644
index 0000000..f818ee7
--- /dev/null
+++ b/backends/pisi/helpers/install.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
+backend.install(sys.argv[1])
+
+sys.exit()
diff --git a/backends/pisi/helpers/pisiBackend.py b/backends/pisi/helpers/pisiBackend.py
new file mode 100644
index 0000000..8c8f5ad
--- /dev/null
+++ b/backends/pisi/helpers/pisiBackend.py
@@ -0,0 +1,127 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+
+import pisi
+from packagekit.backend import *
+
+class PackageKitPisiBackend(PackageKitBaseBackend):
+    def __init__(self, args):
+        PackageKitBaseBackend.__init__(self, args)
+
+        self.installdb = pisi.db.installdb.InstallDB()
+        self.componentdb = pisi.db.componentdb.ComponentDB()
+        self.packagedb = pisi.db.packagedb.PackageDB()
+        self.repodb = pisi.db.repodb.RepoDB()
+
+    def resolve(self, filter, package_id):
+        """ turns a single package name into a package_id suitable for the other methods. """
+
+        self.allow_interrupt(True);
+        self.percentage(None)
+
+        if self.installdb.has_package(package_id):
+            status = INFO_INSTALLED
+            pkg = self.installdb.get_package(package_id)
+        elif self.packagedb.has_package(package_id):
+            status = INFO_AVAILABLE
+            pkg = self.packagedb.get_package(package_id)
+        else:
+            self.error(ERROR_INTERNAL_ERROR, "Package was not found")
+
+        if pkg.build is not None:
+            version = "%s-%s-%s" % (pkg.version, pkg.release, pkg.build)
+        else:
+            version = "%s-%s" % (pkg.version, pkg.release)
+
+        # Currently we only support i686
+        arch = "i686"
+        id = self.get_package_id(pkg.name, version, arch, "")
+        self.package(id, status, pkg.summary)
+
+    def remove(self, deps, package_id):
+        """ removes given package """
+        package = self.get_package_from_id(package_id)[0]
+
+        self.allow_interrupt(False);
+        self.percentage(None)
+
+        if self.installdb.has_package(package):
+            self.status(STATE_REMOVE)
+            try:
+                pisi.api.remove([package])
+            except pisi.Error,e:
+                self.error(ERROR_INTERNAL_ERROR, e)
+        else:
+            self.error(ERROR_PACKAGE_NOT_INSTALLED, "Package is not installed")
+
+    def install(self, package_id):
+        """ installs given package """
+        package = self.get_package_from_id(package_id)[0]
+
+        self.allow_interrupt(False);
+        self.percentage(None)
+
+        if self.packagedb.has_package(package):
+            self.status(STATE_INSTALL)
+            try:
+                pisi.api.install([package])
+            except pisi.Error,e:
+                self.error(ERROR_INTERNAL_ERROR, e)
+        else:
+            self.error(ERROR_PACKAGE_NOT_INSTALLED, "Package is already installed")
+
+    def update(self, package_id):
+        # FIXME: fetch/install progress
+        self.allow_interrupt(False);
+        self.percentage(0)
+
+        package = self.get_package_from_id(package_id)[0]
+
+        if self.installdb.has_package(package):
+            try:
+                pisi.api.upgrade([package])
+            except pisi.Error,e:
+                self.error(ERROR_INTERNAL_ERROR, e)
+        else:
+            self.error(ERROR_PACKAGE_NOT_INSTALLED, "Package is already installed")
+
+    def get_repo_list(self):
+        for repo in pisi.api.list_repos():
+            self.repo_detail(repo, self.repodb.get_repo(repo).indexuri.get_uri(), "true")
+
+    def get_updates(self):
+        for package in pisi.api.list_upgradable():
+            pkg = self.installdb.get_package(package)
+            id = self.get_package_id(pkg.name, pkg.version, "", "")
+            # FIXME: type INFO_SECURITY or INFO_NORMAL
+            self.package(id, INFO_NORMAL, pkg.summary)
+
+    def refresh_cache(self):
+        self.percentage(0)
+
+        slice = (100/len(pisi.api.list_repos()))/2
+
+        percentage = 0
+        for repo in pisi.api.list_repos():
+            pisi.api.update_repo(repo)
+            percentage += slice
+            self.percentage(percentage)
+
+        self.percentage(100)
diff --git a/backends/pisi/helpers/refresh-cache.py b/backends/pisi/helpers/refresh-cache.py
new file mode 100644
index 0000000..8a0d15e
--- /dev/null
+++ b/backends/pisi/helpers/refresh-cache.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
+backend.refresh_cache()
+
+sys.exit()
diff --git a/backends/pisi/helpers/remove.py b/backends/pisi/helpers/remove.py
new file mode 100644
index 0000000..7e91fe1
--- /dev/null
+++ b/backends/pisi/helpers/remove.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[2:])
+backend.remove(sys.argv[1], sys.argv[2])
+
+sys.exit()
diff --git a/backends/pisi/helpers/resolve.py b/backends/pisi/helpers/resolve.py
new file mode 100644
index 0000000..1627bfa
--- /dev/null
+++ b/backends/pisi/helpers/resolve.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[2:])
+backend.resolve(sys.argv[1], sys.argv[2])
+
+sys.exit()
diff --git a/backends/pisi/helpers/update.py b/backends/pisi/helpers/update.py
new file mode 100644
index 0000000..22ccf14
--- /dev/null
+++ b/backends/pisi/helpers/update.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
+backend.update(sys.argv[1])
+
+sys.exit()
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
new file mode 100644
index 0000000..3d7dc10
--- /dev/null
+++ b/backends/pisi/pk-backend-pisi.c
@@ -0,0 +1,153 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ * Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+/**
+ * backend_resolve:
+ */
+static void
+backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_spawn_helper (backend, "resolve.py", filter, package_id, NULL);
+}
+
+/**
+ * backend_remove_package:
+ */
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+	const gchar *deps;
+	if (allow_deps == TRUE) {
+		deps = "yes";
+	} else {
+		deps = "no";
+	}
+	pk_backend_spawn_helper (backend, "remove.py", deps, package_id, NULL);
+}
+
+/**
+ * backend_install_package:
+ */
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot install when offline");
+		pk_backend_finished (backend);
+		return;
+	}
+	pk_backend_spawn_helper (backend, "install.py", package_id, NULL);
+}
+
+/**
+ * backend_update_package:
+ */
+static void
+backend_update_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update when offline");
+		pk_backend_finished (backend);
+		return;
+	}
+	pk_backend_spawn_helper (backend, "update.py", package_id, NULL);
+}
+
+/**
+ * backend_get_repo_list:
+ */
+static void
+backend_get_repo_list (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_spawn_helper (backend, "get-repo-list.py", NULL);
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	g_return_if_fail (backend != NULL);
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+		pk_backend_finished (backend);
+		return;
+	}
+	pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
+}
+
+/**
+ * backend_get_updates:
+ */
+static void
+backend_get_updates (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_spawn_helper (backend, "get-updates.py", NULL);
+}
+
+
+PK_BACKEND_OPTIONS (
+	"PiSi",						/* description */
+	"0.0.1",					/* version */
+	"S.Çağlar Onur <caglar at pardus.org.tr>",		/* author */
+	NULL,						/* initalize */
+	NULL,						/* destroy */
+	NULL,						/* get_groups */
+	NULL,						/* get_filters */
+	NULL,						/* cancel */
+	NULL,						/* get_depends */
+	NULL,						/* get_description */
+	NULL,						/* get_requires */
+	NULL,						/* get_update_detail */
+	backend_get_updates,				/* get_updates */
+	backend_install_package,			/* install_package */
+	NULL,						/* install_file */
+	backend_refresh_cache,				/* refresh_cache */
+	backend_remove_package,				/* remove_package */
+	backend_resolve,				/* resolve */
+	NULL,						/* rollback */
+	NULL,						/* search_details */
+	NULL,						/* search_file */
+	NULL,						/* search_group */
+	NULL,						/* search_name */
+	backend_update_package,				/* update_package */
+	NULL,						/* update_system */
+	backend_get_repo_list,				/* get_repo_list */
+	NULL,						/* repo_enable */
+	NULL						/* repo_set_data */
+);
diff --git a/configure.ac b/configure.ac
index 21824a7..c1a6b31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -398,6 +398,7 @@ AM_CONDITIONAL(BACKEND_TYPE_CONARY, [test x$with_default_backend = xconary], [us
 AM_CONDITIONAL(BACKEND_TYPE_BOX, [test x$with_default_backend = xbox], [using BOX backend])
 AM_CONDITIONAL(BACKEND_TYPE_ALPM, [test x$with_default_backend = xalpm], [using ALPM backend])
 AM_CONDITIONAL(BACKEND_TYPE_SMART, [test x$with_default_backend = xsmart], [using SMART backend])
+AM_CONDITIONAL(BACKEND_TYPE_PISI, [test x$with_default_backend = xpisi], [using PiSi backend])
 
 
 dnl ---------------------------------------------------------------------------
@@ -426,6 +427,8 @@ backends/test/Makefile
 backends/test/helpers/Makefile
 backends/yum/Makefile
 backends/yum/helpers/Makefile
+backends/pisi/Makefile
+backends/pisi/helpers/Makefile
 data/Makefile
 data/tests/Makefile
 libselftest/Makefile
diff --git a/html/pk-download.html b/html/pk-download.html
index 62006e4..71b9dd5 100644
--- a/html/pk-download.html
+++ b/html/pk-download.html
@@ -97,6 +97,7 @@ For instance:
 <li>apt (40% complete)</li>
 <li>pacman/alpm (10% complete)</li>
 <li>smart (10% complete)</li>
+<li>pisi (25% complete)</li>
 </ul>
 
 <p>
commit 1b342ef70ac3a4db30244361bcc4a5f8a9bf5f74
Author: S.Çağlar Onur <caglar at pardus.org.tr>
Date:   Tue Oct 23 14:17:26 2007 +0300

    Following patch adds resolve support to pkcon so "pkcon update PACKAGE" works as expected

diff --git a/client/pk-console.c b/client/pk-console.c
index d6f77e8..5aa1e1a 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -436,6 +436,24 @@ pk_console_remove_package (PkClient *client, const gchar *package)
 }
 
 /**
+ * pk_console_update_package:
+ **/
+static gboolean
+pk_console_update_package (PkClient *client, const gchar *package)
+{
+	gboolean ret;
+	gchar *package_id;
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_INSTALLED, package);
+	if (package_id == NULL) {
+		g_print ("Could not find a package with that name to update\n");
+		return FALSE;
+	}
+	ret = pk_client_update_package (client, package_id);
+	g_free (package_id);
+	return ret;
+}
+
+/**
  * pk_console_process_commands:
  **/
 static gboolean
@@ -509,7 +527,7 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
 			g_set_error (error, 0, 0, "you need to specify a package to update");
 			return FALSE;
 		} else {
-			wait = pk_client_update_package (client, value);
+			wait = pk_console_update_package (client, value);
 		}
 	} else if (strcmp (mode, "resolve") == 0) {
 		if (value == NULL) {



More information about the PackageKit mailing list