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
|
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 0077329..ba993f0 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -29,6 +29,7 @@
#include "pk-backend-databases.h"
#include "pk-backend-error.h"
#include "pk-backend-groups.h"
+#include "pk-backend-transaction.h"
PkBackend *backend = NULL;
GCancellable *cancellable = NULL;
diff --git a/backends/alpm/pk-backend-error.c b/backends/alpm/pk-backend-error.c
index 6383175..255f1fb 100644
--- a/backends/alpm/pk-backend-error.c
+++ b/backends/alpm/pk-backend-error.c
@@ -25,20 +25,6 @@
#include "pk-backend-error.h"
-static void
-pk_backend_output_locked (PkBackend *self)
-{
- gchar *output;
-
- g_return_if_fail (self != NULL);
-
- output = g_strdup_printf ("If you are certain no other package manager "
- "is running, you can remove %s\n",
- alpm_option_get_lockfile ());
- pk_backend_output (self, output);
- g_free (output);
-}
-
void
pk_backend_error (PkBackend *self, GError *error)
{
@@ -86,7 +72,6 @@ pk_backend_error (PkBackend *self, GError *error)
case PM_ERR_HANDLE_LOCK:
code = PK_ERROR_ENUM_CANNOT_GET_LOCK;
- pk_backend_output_locked (self);
break;
case PM_ERR_DB_OPEN:
@@ -187,15 +172,6 @@ pk_backend_error (PkBackend *self, GError *error)
pk_backend_error_code (self, code, "%s", error->message);
}
-void
-pk_backend_output (PkBackend *self, const gchar *output)
-{
- g_return_if_fail (self != NULL);
- g_return_if_fail (output != NULL);
-
- pk_backend_message (self, PK_MESSAGE_ENUM_UNKNOWN, "%s", output);
-}
-
GQuark
alpm_error_quark (void)
{
diff --git a/backends/alpm/pk-backend-error.h b/backends/alpm/pk-backend-error.h
index b01b06d..83fe4a5 100644
--- a/backends/alpm/pk-backend-error.h
+++ b/backends/alpm/pk-backend-error.h
@@ -32,6 +32,4 @@ enum {
void pk_backend_error (PkBackend *self, GError *error);
-void pk_backend_output (PkBackend *self, const gchar *output);
-
GQuark alpm_error_quark (void);
diff --git a/backends/alpm/pk-backend-transaction.c b/backends/alpm/pk-backend-transaction.c
index f919309..fdb840e 100644
--- a/backends/alpm/pk-backend-transaction.c
+++ b/backends/alpm/pk-backend-transaction.c
@@ -32,6 +32,9 @@ static off_t dtotal = 0;
static pmpkg_t *dpkg = NULL;
static GString *dfiles = NULL;
+static pmpkg_t *tpkg = NULL;
+static GString *toutput = NULL;
+
static gchar *
pk_backend_resolve_path (PkBackend *self, const gchar *basename)
{
@@ -332,6 +335,53 @@ pk_backend_transaction_conv_cb (pmtransconv_t question, gpointer data1,
}
static void
+pk_backend_output_end (PkBackend *self)
+{
+ g_return_if_fail (self != NULL);
+
+ tpkg = NULL;
+
+ if (toutput != NULL) {
+ pk_backend_output (self, toutput->str);
+ g_string_free (toutput, TRUE);
+ toutput = NULL;
+ }
+}
+
+static void
+pk_backend_output_start (PkBackend *self, pmpkg_t *pkg)
+{
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (pkg != NULL);
+
+ if (tpkg != NULL) {
+ pk_backend_output_end (self);
+ }
+
+ tpkg = pkg;
+}
+
+void
+pk_backend_output (PkBackend *self, const gchar *output)
+{
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (output != NULL);
+
+ if (tpkg != NULL) {
+ if (toutput == NULL) {
+ toutput = g_string_new ("<b>");
+ g_string_append (toutput, alpm_pkg_get_name (tpkg));
+ g_string_append (toutput, "</b>\n");
+ }
+
+ g_string_append (toutput, output);
+ } else {
+ PkMessageEnum type = PK_MESSAGE_ENUM_UNKNOWN;
+ pk_backend_message (self, type, "%s", output);
+ }
+}
+
+static void
pk_backend_transaction_dep_resolve (PkBackend *self)
{
g_return_if_fail (self != NULL);
@@ -355,6 +405,7 @@ pk_backend_transaction_add_start (PkBackend *self, pmpkg_t *pkg)
pk_backend_set_status (self, PK_STATUS_ENUM_INSTALL);
pk_backend_pkg (self, pkg, PK_INFO_ENUM_INSTALLING);
+ pk_backend_output_start (self, pkg);
}
static void
@@ -374,20 +425,16 @@ pk_backend_transaction_add_done (PkBackend *self, pmpkg_t *pkg)
optdepends = alpm_pkg_get_optdepends (pkg);
if (optdepends != NULL) {
- GString *depends = g_string_new ("");
-
- g_string_append_printf (depends,
- "Optional dependencies for %s:\n",
- name);
+ pk_backend_output (self, "Optional dependencies:\n");
for (i = optdepends; i != NULL; i = i->next) {
- g_string_append_printf (depends, "%s\n",
- (const gchar *) i->data);
+ const gchar *depend = i->data;
+ gchar *output = g_strdup_printf ("%s\n", depend);
+ pk_backend_output (self, output);
+ g_free (output);
}
-
- pk_backend_output (self, depends->str);
- g_string_free (depends, TRUE);
}
+ pk_backend_output_end (self);
}
static void
@@ -398,6 +445,7 @@ pk_backend_transaction_remove_start (PkBackend *self, pmpkg_t *pkg)
pk_backend_set_status (self, PK_STATUS_ENUM_REMOVE);
pk_backend_pkg (self, pkg, PK_INFO_ENUM_REMOVING);
+ pk_backend_output_start (self, pkg);
}
static void
@@ -413,6 +461,7 @@ pk_backend_transaction_remove_done (PkBackend *self, pmpkg_t *pkg)
alpm_logaction ("removed %s (%s)\n", name, version);
pk_backend_pkg (self, pkg, PK_INFO_ENUM_FINISHED);
+ pk_backend_output_end (self);
}
static void
@@ -438,6 +487,7 @@ pk_backend_transaction_upgrade_start (PkBackend *self, pmpkg_t *pkg,
pk_backend_set_status (self, state);
pk_backend_pkg (self, pkg, info);
+ pk_backend_output_start (self, pkg);
}
static void
@@ -463,22 +513,18 @@ pk_backend_transaction_upgrade_done (PkBackend *self, pmpkg_t *pkg,
alpm_pkg_get_optdepends (old),
(alpm_list_fn_cmp) g_strcmp0);
if (optdepends != NULL) {
- GString *depends = g_string_new ("");
-
- g_string_append_printf (depends,
- "New optional dependencies for %s\n",
- name);
+ pk_backend_output (self, "New optional dependencies:\n");
for (i = optdepends; i != NULL; i = i->next) {
- g_string_append_printf (depends, "%s\n",
- (const gchar *) i->data);
+ const gchar *depend = i->data;
+ gchar *output = g_strdup_printf ("%s\n", depend);
+ pk_backend_output (self, output);
+ g_free (output);
}
- pk_backend_output (self, depends->str);
-
- g_string_free (depends, TRUE);
alpm_list_free (optdepends);
}
+ pk_backend_output_end (self);
}
static void
@@ -896,6 +942,13 @@ pk_backend_transaction_end (PkBackend *self, GError **error)
alpm_option_set_dlcb (NULL);
alpm_option_set_totaldlcb (NULL);
+ if (dpkg != NULL) {
+ pk_backend_transaction_download_end (self);
+ }
+ if (tpkg != NULL) {
+ pk_backend_output_end (self);
+ }
+
if (alpm_trans_release () < 0) {
g_set_error_literal (error, ALPM_ERROR, pm_errno,
alpm_strerrorlast ());
diff --git a/backends/alpm/pk-backend-transaction.h b/backends/alpm/pk-backend-transaction.h
index 7bc1af0..6bb1d69 100644
--- a/backends/alpm/pk-backend-transaction.h
+++ b/backends/alpm/pk-backend-transaction.h
@@ -41,3 +41,6 @@ gboolean pk_backend_transaction_end (PkBackend *self,
gboolean pk_backend_transaction_finish (PkBackend *self,
GError *error);
+
+void pk_backend_output (PkBackend *self,
+ const gchar *output);
|