1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
--- configure.ac.old 2012-07-15 23:04:19.083000000 +0200
+++ configure.ac 2012-07-15 23:38:18.799000001 +0200
@@ -516,6 +516,7 @@
AC_ARG_ENABLE(entropy, AS_HELP_STRING([--enable-entropy],[use the entropy backend]),enable_entropy=$enableval,enable_entropy=no)
AC_ARG_ENABLE(opkg, AS_HELP_STRING([--enable-opkg],[use the OPKG backend]),enable_opkg=$enableval,enable_opkg=no)
AC_ARG_ENABLE(pisi, AS_HELP_STRING([--enable-pisi],[use the PiSi backend]),enable_pisi=$enableval,enable_pisi=no)
+AC_ARG_ENABLE(pkg-get, AS_HELP_STRING([--enable-pkg-get],[use the pkg-get backend]),enable_pkg_get=$enableval,enable_pkg_get=yes)
AC_ARG_ENABLE(poldek, AS_HELP_STRING([--enable-poldek],[use the poldek backend]),enable_poldek=$enableval,enable_poldek=no)
AC_ARG_ENABLE(portage, AS_HELP_STRING([--enable-portage],[use the portage backend]),enable_portage=$enableval,enable_portage=no)
AC_ARG_ENABLE(ports, AS_HELP_STRING([--enable-ports],[use the ports backend]),enable_ports=$enableval,enable_ports=no)
@@ -536,6 +537,7 @@
AM_CONDITIONAL(BACKEND_TYPE_ENTROPY, [test x$enable_entropy = xyes])
AM_CONDITIONAL(BACKEND_TYPE_OPKG, [test x$enable_opkg = xyes])
AM_CONDITIONAL(BACKEND_TYPE_PISI, [test x$enable_pisi = xyes])
+AM_CONDITIONAL(BACKEND_TYPE_PKG_GET, [test x$enable_pkg_get = xyes])
AM_CONDITIONAL(BACKEND_TYPE_POLDEK, [test x$enable_poldek = xyes])
AM_CONDITIONAL(BACKEND_TYPE_PORTAGE, [test x$enable_portage = xyes])
AM_CONDITIONAL(BACKEND_TYPE_PORTS, [test x$enable_ports = xyes])
@@ -603,7 +605,7 @@
AC_ARG_WITH([default_backend],
AS_HELP_STRING([--with-default-backend=<option>],
[Default backend to use
- auto,alpm,apt,aptcc,box,conary,dummy,entropy,opkg,pisi,portage,ports,slapt,smart,urpmi,yum,zif,zypp (dummy)]))
+ auto,alpm,apt,aptcc,box,conary,dummy,entropy,opkg,pisi,pkg-get,portage,ports,slapt,smart,urpmi,yum,zif,zypp (dummy)]))
# default to a sane option for the installed tool
if test x$with_default_backend = x; then
if test -f /usr/bin/yum ; then
@@ -624,6 +626,8 @@
with_default_backend=smart
elif test -f /usr/bin/pisi ; then
with_default_backend=pisi
+ elif test -f /usr/bin/pkg-get ; then
+ with_default_backend=pkg-get
elif test -f /usr/bin/poldek ; then
with_default_backend=poldek
elif test -f /usr/bin/urpmq ; then
@@ -823,6 +827,7 @@
backends/ports/Makefile
backends/ports/ruby_packagekit/Makefile
backends/zypp/Makefile
+backends/pkg-get/Makefile
data/Makefile
data/org.freedesktop.PackageKit.conf
data/tests/Makefile
@@ -884,6 +889,7 @@
Entropy backend: ${enable_entropy}
OPKG backend: ${enable_opkg}
PiSi backend: ${enable_pisi}
+ pkg-get backend: ${enable_pkg_get}
poldek backend: ${enable_poldek}
Portage backend: ${enable_portage}
Ports backend: ${enable_ports}
--- backends/Makefile.am.old 2012-07-15 23:07:35.929000000 +0200
+++ backends/Makefile.am 2012-07-15 23:08:56.864000000 +0200
@@ -72,6 +72,10 @@
SUBDIRS += ports
endif
+if BACKEND_TYPE_PKG_GET
+SUBDIRS += pkg-get
+endif
+
clean-local :
rm -f *~
diff -u -r -N -x .deps backends.old/pkg-get/Makefile.am backends/pkg-get/Makefile.am
--- backends.old/pkg-get/Makefile.am 1970-01-01 01:00:00.000000000 +0100
+++ backends/pkg-get/Makefile.am 2012-07-16 05:06:28.817999996 +0200
@@ -0,0 +1,12 @@
+INCLUDES = \
+ -DG_LOG_DOMAIN=\"PackageKit-pkg-get\"
+
+plugindir = $(PK_PLUGIN_DIR)
+plugin_LTLIBRARIES = libpk_backend_pkg-get.la
+libpk_backend_pkg_get_la_SOURCES = pk-backend-pkg-get.c
+libpk_backend_pkg_get_la_LIBADD = $(PK_PLUGIN_LIBS) -lpkg-get -lcurl
+libpk_backend_pkg_get_la_LDFLAGS = -module -avoid-version
+libpk_backend_pkg_get_la_CFLAGS = $(PK_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+
+
+-include $(top_srcdir)/git.mk
diff -u -r -N -x .deps backends.old/pkg-get/pk-backend-pkg-get.c backends/pkg-get/pk-backend-pkg-get.c
--- backends.old/pkg-get/pk-backend-pkg-get.c 1970-01-01 01:00:00.000000000 +0100
+++ backends/pkg-get/pk-backend-pkg-get.c 2012-07-16 05:06:15.193999996 +0200
@@ -0,0 +1,183 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 piernov <piernov@piernov.org>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <pk-backend.h>
+
+#include <pkg-get.h>
+
+static void
+common_progress(int value, gpointer user_data)
+{
+ PkBackend* backend = (PkBackend *) user_data;
+ pk_backend_set_percentage (backend, value);
+}
+
+static void
+backend_get_updates_thread (PkBackend *backend, gpointer user_data)
+{
+ unsigned int i,j;
+ mirList *listOfMirrors=NULL;
+ pkgList *listOfInstPackages=NULL;
+ pkgList *listOfPackages=NULL;
+ pkgInfo *pkg=NULL;
+ gchar *pkg_string = NULL;
+ listOfMirrors = getAvailableMirrors("");
+ listOfPackages = getAvailablePackages(listOfMirrors);
+ if ( listOfPackages != NULL )
+ {
+ listOfInstPackages=getInstalledPackages();
+ addLockStatusToPkgList(listOfInstPackages);
+
+ for (i=0;i<listOfInstPackages->count;i++)
+ {
+ for (j=0;j<listOfPackages->count;j++)
+ {
+ if ( ! strcmp (listOfInstPackages->pkgs[i]->name,listOfPackages->pkgs[j]->name ) )
+ {
+ if (listOfInstPackages->pkgs[i]->isLocked==PKGET_TRUE)
+ {
+ pkg_string = pk_package_id_build(listOfInstPackages->pkgs[i]->name,"locked",NULL,listOfMirrors->mirs[listOfInstPackages->pkgs[i]->mirrorIndex]->url);
+ pk_backend_package (backend, PK_INFO_ENUM_NORMAL, pkg_string, listOfInstPackages->pkgs[i]->description);
+ break;
+ }
+ else
+ {
+ pkg=getNewestPackageFromList(listOfPackages,listOfInstPackages->pkgs[i]->name);
+ if (compareVersionString(listOfInstPackages->pkgs[i]->version,pkg->version) < 0)
+ {
+ pkg_string = pk_package_id_build(listOfInstPackages->pkgs[i]->name,pkg->version,NULL,listOfMirrors->mirs[listOfInstPackages->pkgs[i]->mirrorIndex]->url);
+ pk_backend_package (backend, PK_INFO_ENUM_NORMAL, pkg_string, listOfInstPackages->pkgs[i]->description);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (listOfMirrors!=NULL)
+ freeMirrorList(listOfMirrors);
+ if (listOfPackages !=NULL)
+ freePkgList(listOfPackages);
+ if (listOfInstPackages !=NULL)
+ freePkgList(listOfInstPackages);
+ if (pkg !=NULL)
+ freePkgInfo(pkg);
+ if (pkg_string !=NULL)
+ g_free (pkg_string);
+
+ pk_backend_finished (backend);
+}
+
+static void
+backend_refresh_cache_thread (PkBackend *backend, gpointer user_data)
+{
+ mirList *listOfMirrors=NULL;
+
+ pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+
+ listOfMirrors = getAvailableMirrors("");
+
+ if (listOfMirrors!=NULL)
+ {
+ pkg_get_sync(listOfMirrors);
+ freeMirrorList(listOfMirrors);
+ }
+
+ pk_backend_finished (backend);
+}
+
+/* ===================================================================== */
+
+/**
+ * pk_backend_initialize:
+ */
+void
+pk_backend_initialize (PkBackend *backend)
+{
+}
+
+/**
+ * pk_backend_destroy:
+ */
+void
+pk_backend_destroy (PkBackend *backend)
+{
+}
+
+/**
+ * pk_backend_get_filters:
+ */
+PkBitfield
+pk_backend_get_filters (PkBackend *backend)
+{
+ return pk_bitfield_from_enums (
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ -1);
+}
+
+/**
+ * pk_backend_get_updates:
+ */
+void
+pk_backend_get_updates (PkBackend *backend, PkBitfield filters)
+{
+ /* TODO: filters */
+ pk_backend_thread_create (backend, backend_get_updates_thread, NULL, NULL);
+}
+
+/**
+ * pk_backend_refresh_cache:
+ */
+void
+pk_backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+ /* check network state */
+ if (!pk_backend_is_online (backend)) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished (backend);
+ return;
+ }
+ /* FIXME: support force */
+ pk_backend_thread_create (backend, backend_refresh_cache_thread, NULL, NULL);
+}
+
+/**
+ * pk_backend_get_description:
+ */
+const gchar *
+pk_backend_get_description (PkBackend *backend)
+{
+ return "pkg-get";
+}
+
+/**
+ * pk_backend_get_author:
+ */
+const gchar *
+pk_backend_get_author (PkBackend *backend)
+{
+ return "piernov <piernov@piernov.org>";
+}
|