[packagekit] [PATCH] Bug #12883, PackageKit has a hard dependency on libnm_glib
S.Çağlar Onur
caglar at pardus.org.tr
Tue Oct 23 05:08:41 PDT 2007
23 Eki 2007 Sal tarihinde, Richard Hughes şunları yazmıştı:
> That's great, thanks. I'll probably do a release tonight, as NEWS is
> getting a little long now...
Could you please review and ACK/NACK following?
AUTHORS | 3 +
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 | 20 ++++
backends/pisi/helpers/get-updates.py | 20 ++++
backends/pisi/helpers/install.py | 20 ++++
backends/pisi/helpers/pisiBackend.py | 127 ++++++++++++++++++++++++++
backends/pisi/helpers/refresh-cache.py | 20 ++++
backends/pisi/helpers/remove.py | 20 ++++
backends/pisi/helpers/resolve.py | 20 ++++
backends/pisi/helpers/update.py | 20 ++++
backends/pisi/pk-backend-pisi.c | 153 ++++++++++++++++++++++++++++++++
configure.ac | 3 +
html/pk-download.html | 1 +
17 files changed, 492 insertions(+), 22 deletions(-)
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..967e733
--- /dev/null
+++ b/backends/pisi/helpers/get-repo-list.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# -*- coding: utf-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.
+
+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..0086c4b
--- /dev/null
+++ b/backends/pisi/helpers/get-updates.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# -*- coding: utf-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.
+
+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..3f1f736
--- /dev/null
+++ b/backends/pisi/helpers/install.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# -*- coding: utf-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.
+
+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..e675258
--- /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_INTERNAL_ERROR, "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_INTERNAL_ERROR, "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_INTERNAL_ERROR, "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..db57a3b
--- /dev/null
+++ b/backends/pisi/helpers/refresh-cache.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# -*- coding: utf-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.
+
+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..f3e7c8d
--- /dev/null
+++ b/backends/pisi/helpers/remove.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# -*- coding: utf-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.
+
+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..1a91cc1
--- /dev/null
+++ b/backends/pisi/helpers/resolve.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# -*- coding: utf-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.
+
+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..42680ef
--- /dev/null
+++ b/backends/pisi/helpers/update.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# -*- coding: utf-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.
+
+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..f0065bc
--- /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>
Cheers
--
S.Çağlar Onur <caglar at pardus.org.tr>
http://cekirdek.pardus.org.tr/~caglar/
Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
More information about the PackageKit
mailing list