Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | Index: PackageKit-0.6.0/backends/opkg/pk-backend-opkg.c |
| 2 | =================================================================== |
| 3 | --- PackageKit-0.6.0.orig/backends/opkg/pk-backend-opkg.c 2010-01-29 09:39:33.000000000 +0000 |
| 4 | +++ PackageKit-0.6.0/backends/opkg/pk-backend-opkg.c 2010-01-29 11:30:51.000000000 +0000 |
| 5 | @@ -29,8 +29,7 @@ |
| 6 | |
| 7 | +#include <stdio.h> |
| 8 | #include <libopkg/opkg.h> |
| 9 | |
| 10 | -static opkg_t *opkg; |
| 11 | - |
| 12 | enum { |
| 13 | SEARCH_NAME, |
| 14 | SEARCH_DESCRIPTION, |
| 15 | @@ -62,7 +60,7 @@ |
| 16 | * check an opkg package for known GUI dependancies |
| 17 | */ |
| 18 | static gboolean |
| 19 | -opkg_is_gui_pkg (opkg_package_t *pkg) |
| 20 | +opkg_is_gui_pkg (pkg_t *pkg) |
| 21 | { |
| 22 | |
| 23 | /* TODO: check appropriate tag */ |
| 24 | @@ -84,7 +82,7 @@ |
| 25 | * check an opkg package to determine if it is a development package |
| 26 | */ |
| 27 | static gboolean |
| 28 | -opkg_is_devel_pkg (opkg_package_t *pkg) |
| 29 | +opkg_is_devel_pkg (pkg_t *pkg) |
| 30 | { |
| 31 | if (g_strrstr (pkg->name, "-dev")) |
| 32 | return TRUE; |
| 33 | @@ -105,7 +103,7 @@ |
| 34 | * returns true if the tag is present |
| 35 | */ |
| 36 | static gboolean |
| 37 | -opkg_check_tag (opkg_package_t *pkg, const gchar *tag) |
| 38 | +opkg_check_tag (pkg_t *pkg, const gchar *tag) |
| 39 | { |
| 40 | if (pkg->tags && tag) |
| 41 | return (g_strrstr (pkg->tags, tag) != NULL); |
| 42 | @@ -118,7 +116,7 @@ |
| 43 | { |
| 44 | switch (err) |
| 45 | { |
| 46 | - case OPKG_NO_ERROR: |
| 47 | +/* case OPKG_NO_ERROR: |
| 48 | break; |
| 49 | case OPKG_PACKAGE_NOT_INSTALLED: |
| 50 | pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, NULL); |
| 51 | @@ -140,7 +138,7 @@ |
| 52 | break; |
| 53 | case OPKG_PACKAGE_NOT_AVAILABLE: |
| 54 | pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, NULL); |
| 55 | - break; |
| 56 | + break;*/ |
| 57 | default: |
| 58 | opkg_unknown_error (backend, err, "Update package"); |
| 59 | } |
| 60 | @@ -152,7 +150,7 @@ |
| 61 | static void |
| 62 | backend_initialize (PkBackend *backend) |
| 63 | { |
| 64 | - opkg = opkg_new (); |
| 65 | + int opkg = opkg_new (); |
| 66 | |
| 67 | if (!opkg) { |
| 68 | pk_backend_error_code (backend, |
| 69 | @@ -162,8 +160,8 @@ |
| 70 | } |
| 71 | |
| 72 | #ifdef OPKG_OFFLINE_ROOT |
| 73 | - opkg_set_option (opkg, (char *) "offline_root", OPKG_OFFLINE_ROOT); |
| 74 | - opkg_re_read_config_files (opkg); |
| 75 | + opkg_set_option ((char *) "offline_root", OPKG_OFFLINE_ROOT); |
| 76 | + opkg_re_read_config_files (); |
| 77 | #endif |
| 78 | |
| 79 | } |
| 80 | @@ -174,22 +172,22 @@ |
| 81 | static void |
| 82 | backend_destroy (PkBackend *backend) |
| 83 | { |
| 84 | - opkg_free (opkg); |
| 85 | + opkg_free (); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | static void |
| 90 | -pk_opkg_progress_cb (opkg_t *_opkg, const opkg_progress_data_t *pdata, void *data) |
| 91 | +pk_opkg_progress_cb (const opkg_progress_data_t *pdata, void *data) |
| 92 | { |
| 93 | - PkBackend *backend = PK_BACKEND (data); |
| 94 | + PkBackend *backend = (PkBackend*) data; |
| 95 | if (!backend) |
| 96 | return; |
| 97 | |
| 98 | pk_backend_set_percentage (backend, pdata->percentage); |
| 99 | - if (pdata->package) |
| 100 | + if (pdata->pkg) |
| 101 | { |
| 102 | gchar *uid; |
| 103 | - opkg_package_t *pkg = pdata->package; |
| 104 | + pkg_t *pkg = pdata->pkg; |
| 105 | gint status = PK_INFO_ENUM_UNKNOWN; |
| 106 | |
| 107 | uid = g_strdup_printf ("%s;%s;%s;", |
| 108 | @@ -225,12 +223,12 @@ |
| 109 | { |
| 110 | int ret; |
| 111 | |
| 112 | - ret = opkg_update_package_lists (opkg, pk_opkg_progress_cb, backend); |
| 113 | + ret = opkg_update_package_lists (pk_opkg_progress_cb, backend); |
| 114 | |
| 115 | if (ret) { |
| 116 | - if (ret == OPKG_DOWNLOAD_FAILED) |
| 117 | - pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_AVAILABLE, NULL); |
| 118 | - else |
| 119 | +// if (ret == OPKG_DOWNLOAD_FAILED) |
| 120 | +// pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_AVAILABLE, NULL); |
| 121 | +// else |
| 122 | opkg_unknown_error (backend, ret, "Refreshing cache"); |
| 123 | } |
| 124 | pk_backend_finished (backend); |
| 125 | @@ -256,7 +254,7 @@ |
| 126 | */ |
| 127 | |
| 128 | static void |
| 129 | -pk_opkg_package_list_cb (opkg_t *_opkg, opkg_package_t *pkg, void *data) |
| 130 | +pk_opkg_package_list_cb (pkg_t *pkg, void *data) |
| 131 | { |
| 132 | SearchParams *params = (SearchParams*) data; |
| 133 | gchar *uid; |
| 134 | @@ -298,7 +296,7 @@ |
| 135 | uid = g_strdup_printf ("%s;%s;%s;", |
| 136 | pkg->name, pkg->version, pkg->architecture); |
| 137 | |
| 138 | - if (pkg->installed) |
| 139 | + if (pkg->state_status == SS_INSTALLED) |
| 140 | status = PK_INFO_ENUM_INSTALLED; |
| 141 | else |
| 142 | status = PK_INFO_ENUM_AVAILABLE; |
| 143 | @@ -318,10 +316,10 @@ |
| 144 | opkg_is_gui_pkg (pkg)) |
| 145 | goto end_handle; |
| 146 | if (pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED) && |
| 147 | - (!pkg->installed)) |
| 148 | + (pkg->state_status != SS_INSTALLED)) |
| 149 | goto end_handle; |
| 150 | if (pk_bitfield_contain(filters, PK_FILTER_ENUM_NOT_INSTALLED) && |
| 151 | - (pkg->installed)) |
| 152 | + (pkg->state_status == SS_INSTALLED)) |
| 153 | goto end_handle; |
| 154 | |
| 155 | pk_backend_package (params->backend, status, uid, pkg->description); |
| 156 | @@ -338,7 +336,7 @@ |
| 157 | |
| 158 | params = pk_backend_get_pointer (backend, "search-params"); |
| 159 | |
| 160 | - opkg_list_packages (opkg, pk_opkg_package_list_cb, params); |
| 161 | + opkg_list_packages (pk_opkg_package_list_cb, params); |
| 162 | |
| 163 | pk_backend_finished (params->backend); |
| 164 | |
| 165 | @@ -349,7 +347,7 @@ |
| 166 | } |
| 167 | |
| 168 | static void |
| 169 | -backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search) |
| 170 | +backend_search_name (PkBackend *backend, PkBitfield filters, gchar **search) |
| 171 | { |
| 172 | SearchParams *params; |
| 173 | |
| 174 | @@ -360,7 +358,7 @@ |
| 175 | params = g_new0 (SearchParams, 1); |
| 176 | params->filters = filters; |
| 177 | params->search_type = SEARCH_NAME; |
| 178 | - params->needle = g_utf8_strdown (search, -1); |
| 179 | + params->needle = g_utf8_strdown (search[0], -1); |
| 180 | params->backend = backend; |
| 181 | |
| 182 | pk_backend_set_pointer (backend, "search-params", params); |
| 183 | @@ -371,7 +369,7 @@ |
| 184 | * backend_search_description: |
| 185 | */ |
| 186 | static void |
| 187 | -backend_search_description (PkBackend *backend, PkBitfield filters, const gchar *search) |
| 188 | +backend_search_description (PkBackend *backend, PkBitfield filters, gchar **search) |
| 189 | { |
| 190 | SearchParams *params; |
| 191 | |
| 192 | @@ -382,7 +380,7 @@ |
| 193 | params = g_new0 (SearchParams, 1); |
| 194 | params->filters = filters; |
| 195 | params->search_type = SEARCH_DESCRIPTION; |
| 196 | - params->needle = g_utf8_strdown (search, -1); |
| 197 | + params->needle = g_utf8_strdown (search[0], -1); |
| 198 | params->backend = backend; |
| 199 | |
| 200 | pk_backend_set_pointer (backend, "search-params", params); |
| 201 | @@ -390,7 +388,7 @@ |
| 202 | } |
| 203 | |
| 204 | static void |
| 205 | -backend_search_group (PkBackend *backend, PkBitfield filters, const gchar *search) |
| 206 | +backend_search_group (PkBackend *backend, PkBitfield filters, gchar **search) |
| 207 | { |
| 208 | SearchParams *params; |
| 209 | |
| 210 | @@ -401,7 +399,7 @@ |
| 211 | params = g_new0 (SearchParams, 1); |
| 212 | params->filters = filters; |
| 213 | params->search_type = SEARCH_TAG; |
| 214 | - params->needle = g_strdup_printf ("group::%s", search); |
| 215 | + params->needle = g_strdup_printf ("group::%s", search[0]); |
| 216 | params->backend = backend; |
| 217 | |
| 218 | pk_backend_set_pointer (backend, "search-params", params); |
| 219 | @@ -412,9 +410,9 @@ |
| 220 | static gboolean |
| 221 | backend_install_packages_thread (PkBackend *backend) |
| 222 | { |
| 223 | - PkPackageId *pi; |
| 224 | gint err, i; |
| 225 | gchar **package_ids; |
| 226 | + gchar **parts; |
| 227 | |
| 228 | package_ids = pk_backend_get_strv (backend, "pkids"); |
| 229 | |
| 230 | @@ -424,13 +422,13 @@ |
| 231 | { |
| 232 | pk_backend_package (backend, PK_INFO_ENUM_INSTALLING, package_ids[i], NULL); |
| 233 | |
| 234 | - pi = pk_package_id_new_from_string (package_ids[i]); |
| 235 | + parts = pk_package_id_split (package_ids[i]); |
| 236 | |
| 237 | - err = opkg_install_package (opkg, pi->name, pk_opkg_progress_cb, backend); |
| 238 | + err = opkg_install_package (parts[PK_PACKAGE_ID_NAME], pk_opkg_progress_cb, backend); |
| 239 | if (err) |
| 240 | handle_install_error (backend, err); |
| 241 | |
| 242 | - pk_package_id_free (pi); |
| 243 | + g_strfreev (parts); |
| 244 | if (err != 0) |
| 245 | break; |
| 246 | } |
| 247 | @@ -453,9 +451,9 @@ |
| 248 | static gboolean |
| 249 | backend_remove_packages_thread (PkBackend *backend) |
| 250 | { |
| 251 | - PkPackageId *pi; |
| 252 | gint err, i; |
| 253 | gchar **package_ids; |
| 254 | + gchar **parts; |
| 255 | gboolean allow_deps; |
| 256 | gboolean autoremove; |
| 257 | gpointer *data; |
| 258 | @@ -467,29 +465,30 @@ |
| 259 | autoremove = GPOINTER_TO_INT (data[2]); |
| 260 | g_free (data); |
| 261 | |
| 262 | - opkg_set_option (opkg, (char *)"autoremove", &autoremove); |
| 263 | - opkg_set_option (opkg, (char *)"force_removal_of_dependent_packages", &allow_deps); |
| 264 | + opkg_set_option ((char *)"autoremove", &autoremove); |
| 265 | + opkg_set_option ((char *)"force_removal_of_dependent_packages", &allow_deps); |
| 266 | |
| 267 | err = 0; |
| 268 | |
| 269 | for (i = 0; package_ids[i]; i++) |
| 270 | { |
| 271 | - pi = pk_package_id_new_from_string (package_ids[i]); |
| 272 | pk_backend_package (backend, PK_INFO_ENUM_REMOVING, package_ids[i], NULL); |
| 273 | |
| 274 | - err = opkg_remove_package (opkg, pi->name, pk_opkg_progress_cb, backend); |
| 275 | + parts = pk_package_id_split (package_ids[i]); |
| 276 | + |
| 277 | + err = opkg_remove_package (parts[PK_PACKAGE_ID_NAME], pk_opkg_progress_cb, backend); |
| 278 | |
| 279 | switch (err) |
| 280 | { |
| 281 | - case OPKG_NO_ERROR: |
| 282 | - break; |
| 283 | - case OPKG_PACKAGE_NOT_INSTALLED: |
| 284 | - pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, NULL); |
| 285 | - break; |
| 286 | + //case OPKG_NO_ERROR: |
| 287 | + // break; |
| 288 | + //case OPKG_PACKAGE_NOT_INSTALLED: |
| 289 | + // pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, NULL); |
| 290 | + // break; |
| 291 | default: |
| 292 | opkg_unknown_error (backend, err, "Remove"); |
| 293 | } |
| 294 | - pk_package_id_free (pi); |
| 295 | + g_strfreev (parts); |
| 296 | |
| 297 | if (err != 0) |
| 298 | break; |
| 299 | @@ -540,7 +539,7 @@ |
| 300 | gint err; |
| 301 | |
| 302 | /* FIXME: support only_trusted */ |
| 303 | - err = opkg_upgrade_all (opkg, pk_opkg_progress_cb, backend); |
| 304 | + err = opkg_upgrade_all (pk_opkg_progress_cb, backend); |
| 305 | |
| 306 | if (err) |
| 307 | opkg_unknown_error (backend, err, "Upgrading system"); |
| 308 | @@ -564,29 +563,28 @@ |
| 309 | static gboolean |
| 310 | backend_update_package_thread (PkBackend *backend) |
| 311 | { |
| 312 | - PkPackageId *pi; |
| 313 | + gchar **parts; |
| 314 | gint err = 0; |
| 315 | const gchar *package_id; |
| 316 | |
| 317 | /* FIXME: support only_trusted */ |
| 318 | package_id = pk_backend_get_string (backend, "pkgid"); |
| 319 | - pi = pk_package_id_new_from_string (package_id); |
| 320 | + parts = pk_package_id_split (package_id); |
| 321 | |
| 322 | - if (!pi->name || !pi->version) |
| 323 | + if (!parts) |
| 324 | { |
| 325 | pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, |
| 326 | "Package not found"); |
| 327 | - pk_package_id_free (pi); |
| 328 | pk_backend_finished (backend); |
| 329 | return FALSE; |
| 330 | } |
| 331 | |
| 332 | - err = opkg_upgrade_package (opkg, pi->name, pk_opkg_progress_cb, backend); |
| 333 | + err = opkg_upgrade_package (parts[PK_PACKAGE_ID_NAME], pk_opkg_progress_cb, backend); |
| 334 | if (err) |
| 335 | handle_install_error (backend, err); |
| 336 | |
| 337 | |
| 338 | - pk_package_id_free (pi); |
| 339 | + g_strfreev (parts); |
| 340 | pk_backend_finished (backend); |
| 341 | return (err != 0); |
| 342 | } |
| 343 | @@ -610,13 +608,13 @@ |
| 344 | */ |
| 345 | |
| 346 | static void |
| 347 | -pk_opkg_list_upgradable_cb (opkg_t *_opkg, opkg_package_t *pkg, void *data) |
| 348 | +pk_opkg_list_upgradable_cb (pkg_t *pkg, void *data) |
| 349 | { |
| 350 | - PkBackend *backend = PK_BACKEND (data); |
| 351 | + PkBackend *backend = (PkBackend*) data; |
| 352 | gchar *uid; |
| 353 | gint status; |
| 354 | |
| 355 | - if (pkg->installed) |
| 356 | + if (pkg->state_status == SS_INSTALLED) |
| 357 | status = PK_INFO_ENUM_INSTALLED; |
| 358 | else |
| 359 | status = PK_INFO_ENUM_AVAILABLE; |
| 360 | @@ -631,7 +629,7 @@ |
| 361 | static gboolean |
| 362 | backend_get_updates_thread (PkBackend *backend) |
| 363 | { |
| 364 | - opkg_list_upgradable_packages (opkg, pk_opkg_list_upgradable_cb, backend); |
| 365 | + opkg_list_upgradable_packages (pk_opkg_list_upgradable_cb, backend); |
| 366 | pk_backend_finished (backend); |
| 367 | return TRUE; |
| 368 | } |
| 369 | @@ -668,16 +666,18 @@ |
| 370 | static gboolean |
| 371 | backend_get_details_thread (PkBackend *backend) |
| 372 | { |
| 373 | - PkPackageId *pi; |
| 374 | gchar **package_ids; |
| 375 | + gchar **parts; |
| 376 | int group_index; |
| 377 | PkGroupEnum group = 0; |
| 378 | - opkg_package_t *pkg; |
| 379 | + pkg_t *pkg; |
| 380 | gchar *newid; |
| 381 | |
| 382 | package_ids = pk_backend_get_strv(backend, "package_ids"); |
| 383 | - pi = pk_package_id_new_from_string (package_ids[0]); |
| 384 | - if (pi == NULL) |
| 385 | + parts = pk_package_id_split (package_ids[0]); |
| 386 | + |
| 387 | + |
| 388 | + if (!parts) |
| 389 | { |
| 390 | pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); |
| 391 | pk_backend_finished (backend); |
| 392 | @@ -685,8 +685,8 @@ |
| 393 | } |
| 394 | |
| 395 | |
| 396 | - pkg = opkg_find_package (opkg, pi->name, pi->version, pi->arch, pi->data); |
| 397 | - pk_package_id_free (pi); |
| 398 | + pkg = opkg_find_package (parts[PK_PACKAGE_ID_NAME], parts[PK_PACKAGE_ID_VERSION], parts[PK_PACKAGE_ID_ARCH], parts[PK_PACKAGE_ID_DATA]); |
| 399 | + g_strfreev (parts); |
| 400 | |
| 401 | if (!pkg) |
| 402 | { |
| 403 | @@ -695,7 +695,7 @@ |
| 404 | return FALSE; |
| 405 | } |
| 406 | |
| 407 | - newid = g_strdup_printf ("%s;%s;%s;%s", pkg->name, pkg->version, pkg->architecture, pkg->repository); |
| 408 | + newid = g_strdup_printf ("%s;%s;%s;%s", pkg->name, pkg->version, pkg->architecture, pkg->src->name); |
| 409 | |
| 410 | if (pkg->tags) { |
| 411 | for (group_index = 0; group < PK_GROUP_ENUM_LAST; group_index++) { |
| 412 | @@ -706,9 +706,8 @@ |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | - pk_backend_details (backend, newid, NULL, group, pkg->description, pkg->url, pkg->size); |
| 417 | + pk_backend_details (backend, newid, NULL, group, pkg->description, NULL, pkg->size); |
| 418 | g_free (newid); |
| 419 | - opkg_package_free(pkg); |
| 420 | pk_backend_finished (backend); |
| 421 | return TRUE; |
| 422 | } |