* backends/apt/helpers/aptBackend.py:

- add get_updates() and get_update_detail()
* backends/apt/helpers/get-update-detail.py,
  backends/apt/helpers/get-updates.py:
  - add helper for get-update-detail.py and get-updates.py
* backends/apt/pk-apt-search-plain.c, backends/apt/pk-backend-apt.c:
  - make it build again
* backends/apt/pk-backend-apt.c:
  - set spawn name to "apt"
  - add backend_get_update_detail()
This commit is contained in:
Michael Vogt 2008-02-13 22:45:33 +01:00
parent a744d5e6d3
commit 3b8bddf17b
5 changed files with 80 additions and 8 deletions

View File

@ -426,6 +426,26 @@ class PackageKitAptBackend(PackageKitBaseBackend):
except IOError,e:
self.error(ERROR_INTERNAL_ERROR, "Problem while trying to save repo settings to %s: %s"%(e.filename,e.strerror))
def get_updates(self):
self._apt_cache.upgrade(False)
for pkg in self._apt_cache.getChanges():
self._emit_package(Package(self, pkg))
def get_update_detail(self, package):
self.allow_cancel(True)
self.percentage(None)
self.status(STATUS_INFO)
name, version, arch, data = self.get_package_from_id(package)
update = ""
obsolete = ""
cve_url = ""
bz_url = ""
vendor_url = ""
reboot = "none"
desc = self._apt_cache[name].description
self.update_detail(package,update,obsolete,vendor_url,bz_url,cve_url,reboot,desc)
def install_file (self, inst_file):
'''
Implement the {backend}-install_file functionality

View File

@ -0,0 +1,18 @@
#!/usr/bin/python
#
# Copyright (C) 2008 Michael Vogt <mvo@ubuntu.com>
#
# 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
from aptBackend import PackageKitAptBackend
package=sys.argv[1]
backend = PackageKitAptBackend(sys.argv[2:])
backend.get_update_detail(package)
sys.exit(0)

View File

@ -0,0 +1,17 @@
#!/usr/bin/python
#
# Copyright (C) 2008 Michael Vogt <mvo@ubuntu.com>
#
# 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
from aptBackend import PackageKitAptBackend
backend = PackageKitAptBackend(sys.argv[1:])
backend.get_updates()
sys.exit(0)

View File

@ -23,7 +23,9 @@
#include <glib.h>
#include <string.h>
#include <pk-backend.h>
#include <pk-backend-python.h>
#include <pk-backend-spawn.h>
extern PkBackendSpawn *spawn;
/**
* backend_get_groups:
@ -66,7 +68,8 @@ backend_get_filters (PkBackend *backend, PkEnumList *elist)
void
backend_get_description (PkBackend *backend, const gchar *package_id)
{
pk_backend_python_get_description(backend,package_id);
g_return_if_fail (backend != NULL);
pk_backend_spawn_helper (spawn, "get-description.py", package_id, NULL);
}
/**
@ -76,7 +79,8 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
void
backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
{
pk_backend_python_search_details(backend,filter,search);
g_return_if_fail (backend != NULL);
pk_backend_spawn_helper (spawn, "search-details.py", filter, search, NULL);
}
/**
@ -85,7 +89,8 @@ backend_search_details (PkBackend *backend, const gchar *filter, const gchar *se
void
backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
{
pk_backend_python_search_name(backend,filter,search);
g_return_if_fail (backend != NULL);
pk_backend_spawn_helper (spawn, "search-name.py", filter, search, NULL);
}
/**
@ -94,7 +99,8 @@ backend_search_name (PkBackend *backend, const gchar *filter, const gchar *searc
void
backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
{
pk_backend_python_search_group(backend,filter,search);
g_return_if_fail (backend != NULL);
pk_backend_spawn_helper (spawn, "search-group.py", filter, search, NULL);
}
/* don't need to do any setup/finalize in the plain search mode */

View File

@ -29,7 +29,7 @@
#include "pk-apt-search.h"
#include "config.h"
static PkBackendSpawn *spawn;
PkBackendSpawn *spawn;
static PkNetwork *network;
/**
@ -43,7 +43,7 @@ backend_initalize (PkBackend *backend)
pk_debug ("FILTER: initalize");
network = pk_network_new ();
spawn = pk_backend_spawn_new ();
pk_backend_spawn_set_name (spawn, "yum");
pk_backend_spawn_set_name (spawn, "apt");
backend_init_search (backend);
}
@ -130,6 +130,17 @@ backend_get_updates (PkBackend *backend)
pk_backend_spawn_helper (spawn, "get-updates.py", NULL);
}
/**
* backend_get_update_detail:
*/
static void
backend_get_update_detail (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
pk_backend_spawn_helper (spawn, "get-update-detail.py", package_id, NULL);
}
/**
* backend_install_package:
*/
@ -243,7 +254,7 @@ PK_BACKEND_OPTIONS (
backend_get_description, /* get_description */
NULL, /* get_files */
NULL, /* get_requires */
NULL, /* get_update_detail */
backend_get_update_detail, /* get_update_detail */
backend_get_updates, /* get_updates */
backend_install_package, /* install_package */
NULL, /* install_file */