diff options
author | Eskil Heyn Olsen <eskil@src.gnome.org> | 2001-01-19 22:14:24 +0000 |
---|---|---|
committer | Eskil Heyn Olsen <eskil@src.gnome.org> | 2001-01-19 22:14:24 +0000 |
commit | 7688a783ad460bdede2b121f53c3871b04780249 (patch) | |
tree | da8194cd960b986dced3340da650f1b6426c490f /components/services | |
parent | c4773539cd4850b67e475af72b8560347279e8b9 (diff) | |
download | nautilus-7688a783ad460bdede2b121f53c3871b04780249.tar.gz |
Wrote test for the fix to 5262
* components/services/install/command-line/eazel-test-packsys.c:
(test_package_load):
Wrote test for the fix to 5262
* components/services/install/lib/eazel-install-logic.c:
Moved get_total_size to logic2.c
* components/services/install/lib/eazel-install-logic2.h:
* components/services/install/lib/eazel-install-logic2.c:
(dump_tree_helper), (eazel_install_check_existing_packages),
(eazel_install_get_total_size_of_packages), (execute):
Setup infoblock so the callback signals make sense, removed a
g_assert_not_reached.
* components/services/install/lib/eazel-install-protocols.c:
(eazel_install_fetch_package):
Don't load dependencies when loading the package after download.
* components/services/install/lib/eazel-package-system-rpm3.c:
(rpm_sense_to_softcat_sense),
(eazel_package_system_rpm3_packagedata_fill_from_header):
Fixed 5262
* components/services/install/lib/eazel-package-system-types.c:
(packagedependency_new), (packagedependency_destroy),
(packagedata_fill_in_missing), (packagedata_dump_int):
Allow fill_in_missing into a packagedata object with depends set.
Moved output of features and provides upwards in dump_int.
* components/services/install/nautilus-view/nautilus-service-instal
l-view.c: (nautilus_service_install_view_update_from_uri):
Deallocate the EazelInstall object in update_from_uri if already
set. The ensures a reload of the install-view doesn't leak
EazelInstall objects.
Diffstat (limited to 'components/services')
9 files changed, 173 insertions, 71 deletions
diff --git a/components/services/install-view/nautilus-service-install-view.c b/components/services/install-view/nautilus-service-install-view.c index e7cbd3489..48340e1ae 100644 --- a/components/services/install-view/nautilus-service-install-view.c +++ b/components/services/install-view/nautilus-service-install-view.c @@ -1438,6 +1438,9 @@ nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view, g_free (out); CORBA_exception_init (&ev); + if (view->details->installer) { + eazel_install_callback_unref (GTK_OBJECT (view->details->installer)); + } view->details->installer = eazel_install_callback_new (); if (view->details->installer == NULL) { GtkWidget *toplevel, *dialog; diff --git a/components/services/install/command-line/eazel-test-packsys.c b/components/services/install/command-line/eazel-test-packsys.c index 643b2f307..545773481 100644 --- a/components/services/install/command-line/eazel-test-packsys.c +++ b/components/services/install/command-line/eazel-test-packsys.c @@ -49,11 +49,13 @@ test_package_load (EazelPackageSystem *packsys, { PackageData *p; int flag; + unsigned int provides_count = 0; flag = PACKAGE_FILL_EVERYTHING; p = eazel_package_system_load_package (packsys, NULL, package_file_name, flag); - if (p->description && p->summary && p->provides) { + if (p->description && p->summary && p->provides && p->depends) { g_message ("load_package test 1 ok"); + provides_count = g_list_length (p->provides); } else { g_message ("load_package test 1 FAIL"); } @@ -70,12 +72,17 @@ test_package_load (EazelPackageSystem *packsys, packagedata_destroy (p, TRUE); - flag = PACKAGE_FILL_NO_PROVIDES; + flag = PACKAGE_FILL_NO_DIRS_IN_PROVIDES; p = eazel_package_system_load_package (packsys, NULL, package_file_name, flag); - if (p->description && p->summary && p->provides==NULL) { - g_message ("load_package test 4 ok"); + if (p->description && p->summary && p->provides) { + if (provides_count > g_list_length (p->provides)) { + g_message ("load_package test 3 ok"); + } else { + g_message ("load_package test 3 FAIL (%d in provides, should have less then %d)", + g_list_length (p->provides), provides_count); + } } else { - g_message ("load_package test 4 FAIL"); + g_message ("load_package test 3 FAIL"); } packagedata_destroy (p, TRUE); } diff --git a/components/services/install/lib/eazel-install-logic.c b/components/services/install/lib/eazel-install-logic.c index 76920ea4a..c300b4423 100644 --- a/components/services/install/lib/eazel-install-logic.c +++ b/components/services/install/lib/eazel-install-logic.c @@ -575,20 +575,6 @@ ei_revert_transaction (EazelInstall *service, return result; } -unsigned long -eazel_install_get_total_size_of_packages (EazelInstall *service, - const GList *packages) -{ - const GList *iterator; - unsigned long result = 0; - for (iterator = packages; iterator; glist_step (iterator)) { - PackageData *pack; - - pack = (PackageData*)iterator->data; - result += pack->bytesize; - } - return result; -} void eazel_install_do_transaction_add_to_transaction (EazelInstall *service, diff --git a/components/services/install/lib/eazel-install-logic2.c b/components/services/install/lib/eazel-install-logic2.c index 281a7c40b..3c77c1bf6 100644 --- a/components/services/install/lib/eazel-install-logic2.c +++ b/components/services/install/lib/eazel-install-logic2.c @@ -78,11 +78,11 @@ dump_tree_helper (GList *packages, char *indent, GList *path) indent, pack, name, - pack->fillflag & MUST_HAVE ? "not_filled":"filled", + pack->fillflag & MUST_HAVE ? "filled":"not_filled", pack->status == PACKAGE_CANNOT_OPEN ? " but failed" : ""); tmp = g_strdup_printf ("%s ", indent); if (g_list_find_custom (path, name, (GCompareFunc)strcmp)) { - trilobite_debug ("%s ... recurses ...", indent); + trilobite_debug ("%s ... recurses ...", indent); } else { path = g_list_prepend (path, name); dump_tree_helper (pack->depends, tmp, path); @@ -254,8 +254,9 @@ eazel_install_check_existing_packages (EazelInstall *service, trilobite_debug ("(which is dangerous by the way....)"); trilobite_debug ("rpm -e --nodeps `rpm -q %s`", pack->name); trilobite_debug ("Or wait for the author to fix bug 3511"); - /* FIXME bugzilla.eazel.com 3511 */ - g_assert_not_reached (); + /* FIXME bugzilla.eazel.com 3511 + g_assert_not_reached (); + */ } for (iterator = existing_packages; iterator; iterator = g_list_next (iterator)) { PackageData *existing_package = (PackageData*)iterator->data; @@ -1345,6 +1346,21 @@ clean_up_dep_ok_hash (char *key, gpointer unused) return TRUE; } +unsigned long +eazel_install_get_total_size_of_packages (EazelInstall *service, + const GList *packages) +{ + const GList *iterator; + unsigned long result = 0; + for (iterator = packages; iterator; glist_step (iterator)) { + PackageData *pack; + + pack = (PackageData*)iterator->data; + result += pack->bytesize; + } + return result; +} + static void execute (EazelInstall *service, GList *packages, @@ -1364,6 +1380,14 @@ execute (EazelInstall *service, flags |= EAZEL_PACKAGE_SYSTEM_OPERATION_TEST; } + /* Init the hack var to emit the old style progress signals */ + service->private->infoblock [0] = 0; + service->private->infoblock [1] = 0; + service->private->infoblock [2] = 0; + service->private->infoblock [3] = g_list_length (flat_packages); + service->private->infoblock [4] = 0; + service->private->infoblock [5] = eazel_install_get_total_size_of_packages (service, flat_packages); + switch (op) { case EAZEL_PACKAGE_SYSTEM_OPERATION_INSTALL: eazel_package_system_install (service->private->package_system, diff --git a/components/services/install/lib/eazel-install-logic2.h b/components/services/install/lib/eazel-install-logic2.h index 969f42917..2021b162b 100644 --- a/components/services/install/lib/eazel-install-logic2.h +++ b/components/services/install/lib/eazel-install-logic2.h @@ -33,6 +33,8 @@ gboolean check_md5_on_files (EazelInstall *service, GList *packages); EazelInstallStatus eazel_install_check_existing_packages (EazelInstall *service, PackageData *pack); +unsigned long eazel_install_get_total_size_of_packages (EazelInstall *service, + const GList *packages); EazelInstallOperationStatus install_packages (EazelInstall *service, GList *categories); EazelInstallOperationStatus uninstall_packages (EazelInstall *service, GList *categories); diff --git a/components/services/install/lib/eazel-install-protocols.c b/components/services/install/lib/eazel-install-protocols.c index b5362be94..804931184 100644 --- a/components/services/install/lib/eazel-install-protocols.c +++ b/components/services/install/lib/eazel-install-protocols.c @@ -634,7 +634,7 @@ eazel_install_fetch_package (EazelInstall *service, package = eazel_package_system_load_package (service->private->package_system, package, targetname, - PACKAGE_FILL_NO_DIRS_IN_PROVIDES); + PACKAGE_FILL_NO_DIRS_IN_PROVIDES|PACKAGE_FILL_NO_DEPENDENCIES); if (name) { if (strcmp (name, package->name)) { diff --git a/components/services/install/lib/eazel-package-system-rpm3.c b/components/services/install/lib/eazel-package-system-rpm3.c index a9add66f0..b7a9a16c6 100644 --- a/components/services/install/lib/eazel-package-system-rpm3.c +++ b/components/services/install/lib/eazel-package-system-rpm3.c @@ -488,6 +488,28 @@ eazel_package_system_rpm3_free_dbs (EazelPackageSystemRpm3 *system) Load Package implemementation *************************************************************/ +static EazelSoftCatSense +rpm_sense_to_softcat_sense (EazelPackageSystemRpm3 *system, + int rpm_sense) +{ + EazelSoftCatSense result = 0; + + if (rpm_sense & RPMSENSE_ANY) { + result |= EAZEL_SOFTCAT_SENSE_ANY; + } else { + if (rpm_sense & RPMSENSE_EQUAL) { + result |= EAZEL_SOFTCAT_SENSE_EQ; + } + if (rpm_sense & RPMSENSE_GREATER) { + result |= EAZEL_SOFTCAT_SENSE_GT; + } + if (rpm_sense & RPMSENSE_LESS) { + result |= EAZEL_SOFTCAT_SENSE_LT; + } + } + + return result; +} void eazel_package_system_rpm3_packagedata_fill_from_header (EazelPackageSystemRpm3 *system, @@ -524,12 +546,14 @@ eazel_package_system_rpm3_packagedata_fill_from_header (EazelPackageSystemRpm3 * int count = 0; int index = 0; int num_paths = 0; + uint_16 *file_modes; g_list_foreach (pack->provides, (GFunc)g_free, NULL); g_list_free (pack->provides); pack->provides = NULL; - /* RPM v.3.0.4 and above has RPMTAG_BASENAMES */ + /* RPM v.3.0.4 and above has RPMTAG_BASENAMES, this will not work + with any version below 3.0.4 */ headerGetEntry (hd, RPMTAG_DIRINDEXES, NULL, @@ -540,6 +564,9 @@ eazel_package_system_rpm3_packagedata_fill_from_header (EazelPackageSystemRpm3 * headerGetEntry (hd, RPMTAG_BASENAMES, NULL, (void**)&names, &count); + headerGetEntry (hd, + RPMTAG_FILEMODES, NULL, + (void**)&file_modes, NULL); /* Copy all paths and shave off last /. This is needed to remove the dir entries from @@ -551,27 +578,23 @@ eazel_package_system_rpm3_packagedata_fill_from_header (EazelPackageSystemRpm3 * } /* Now loop through all the basenames */ - /* NOTE: This algorithm has sizeof (paths) * sizeof (names) - complexity, aka O(nē) */ for (index=0; index<count; index++) { char *fullname = NULL; - int index2 = 0; - if (paths) { fullname = g_strdup_printf ("%s/%s", paths_copy[indexes[index]], names[index]); } else { fullname = g_strdup (names[index]); } if (detail_level & PACKAGE_FILL_NO_DIRS_IN_PROVIDES) { - /* Check it's not a dirname, by looping through all - paths_copy and check that fullname does not occur there */ - for (index2 = 0; index2 < num_paths; index2++) { - if (strcmp (paths_copy[index2], fullname)==0) { - g_free (fullname); - fullname = NULL; - break; - } + if (file_modes[index] & 040000) { + g_free (fullname); + fullname = NULL; } +#if 0 + fprintf (stderr, "file_modes[%s] = 0%o %s\n", + fullname, file_modes[index], + (file_modes[index] & 040000) ? "DIR" : "file" ); +#endif } if (fullname) { /* trilobite_debug ("%s provides %s", pack->name, fullname);*/ @@ -587,11 +610,61 @@ eazel_package_system_rpm3_packagedata_fill_from_header (EazelPackageSystemRpm3 * free ((void*)names); } - /* FIXME: bugzill.eaze.com 5262 - Without this, libeazelinstall --ei2 cannot install starting with - a rpm file - */ + if (~detail_level & PACKAGE_FILL_NO_DEPENDENCIES) { + const char **requires_name, **requires_version; + int *requires_flag; + int count; + int index; + + headerGetEntry (hd, + RPMTAG_REQUIRENAME, NULL, + (void**)&requires_name, + &count); + headerGetEntry (hd, + RPMTAG_REQUIREVERSION, NULL, + (void**)&requires_version, + NULL); + headerGetEntry (hd, + RPMTAG_REQUIREFLAGS, NULL, + (void**)&requires_flag, + NULL); + + for (index = 0; index < count; index++) { + PackageData *package = packagedata_new (); + PackageDependency *pack_dep = packagedependency_new (); + + /* If it's a lib*.so* or a /yadayada, add to provides */ + if ((strncmp (requires_name[index], "lib", 3)==0 && + strstr (requires_name[index], ".so")) || + *requires_name[index]=='/') { + /* Unless it has a ( in the name */ + if (strchr (requires_name[index], '(')==NULL) { + package->provides = g_list_prepend (package->provides, + g_strdup (requires_name[index])); + } + } else { + /* Otherwise, add as a package name */ + package->name = g_strdup (requires_name[index]); + /* and set the version if not empty */ + pack_dep->version = *requires_version[index]=='\0' ? + NULL : g_strdup (requires_version[index]); + } + /* If anything set, add dep */ + if (package->name || package->provides) { + pack_dep->sense = rpm_sense_to_softcat_sense (system, + requires_flag[index]); + package->archtype = trilobite_get_distribution_arch (); + pack_dep->package = package; + pack->depends = g_list_prepend (pack->depends, pack_dep); + } else { + packagedependency_destroy (pack_dep); + gtk_object_unref (GTK_OBJECT (package)); + } + } + free ((void*)requires_name); + free ((void*)requires_version); + } } diff --git a/components/services/install/lib/eazel-package-system-types.c b/components/services/install/lib/eazel-package-system-types.c index a47ed059c..f357ae96c 100644 --- a/components/services/install/lib/eazel-package-system-types.c +++ b/components/services/install/lib/eazel-package-system-types.c @@ -337,6 +337,8 @@ packagedependency_new (void) PackageDependency *dep; dep = g_new0 (PackageDependency, 1); + dep->package = NULL; + dep->version = NULL; return dep; } @@ -357,7 +359,9 @@ packagedependency_copy (const PackageDependency *dep, gboolean deep) void packagedependency_destroy (PackageDependency *dep) { - gtk_object_unref (GTK_OBJECT (dep->package)); + if (dep->package) { + gtk_object_unref (GTK_OBJECT (dep->package)); + } dep->package = NULL; g_free (dep->version); dep->version = NULL; @@ -537,13 +541,13 @@ packagedata_fill_in_missing (PackageData *package, const PackageData *full_packa package->features = g_list_reverse (package->features); } if (! (fill_flags & PACKAGE_FILL_NO_DEPENDENCIES)) { - /* FIXME: if the dependencies are already filled in, should we deep-free them or just - * throw that list away? for now, let's assert that there's never any list to begin - * with, and if that breaks, then figure out what to do. - */ - g_assert (package->soft_depends == NULL); - g_assert (package->hard_depends == NULL); - g_assert (package->depends == NULL); + g_list_foreach (package->soft_depends, (GFunc)gtk_object_unref, NULL); + g_list_foreach (package->hard_depends, (GFunc)gtk_object_unref, NULL); + g_list_foreach (package->depends, (GFunc)packagedependency_destroy, GINT_TO_POINTER (FALSE)); + package->soft_depends = NULL; + package->hard_depends = NULL; + package->depends = NULL; + package->soft_depends = packagedata_list_copy (full_package->soft_depends, TRUE); package->hard_depends = packagedata_list_copy (full_package->hard_depends, TRUE); package->depends = packagedata_deplist_copy (full_package->depends, TRUE); @@ -1362,6 +1366,28 @@ packagedata_dump_int (const PackageData *package, gboolean deep, int indent) g_string_sprintfa (out, "Description:\n%s\n", package->description); } + if (package->features != NULL) { + gstr_indent (out, indent); + g_string_sprintfa (out, "Features: "); + for (iter = g_list_first (package->features); iter != NULL; iter = g_list_next (iter)) { + if (iter == package->features) { + g_string_sprintfa (out, "%s", (char *)(iter->data)); + } else { + g_string_sprintfa (out, "; %s", (char *)(iter->data)); + } + } + g_string_sprintfa (out, "\n"); + } + + if (deep && package->provides != NULL) { + gstr_indent (out, indent); + g_string_sprintfa (out, "Provides:\n"); + for (iter = g_list_first (package->provides); iter != NULL; iter = g_list_next (iter)) { + g_string_sprintfa (out, "\t\t%s\n", (char *)(iter->data)); + } + g_string_sprintfa (out, "\n"); + } + if (package->soft_depends != NULL) { gstr_indent (out, indent); g_string_sprintfa (out, "Soft depends: "); @@ -1393,28 +1419,6 @@ packagedata_dump_int (const PackageData *package, gboolean deep, int indent) g_string_sprintfa (out, "\n"); } - if (package->features != NULL) { - gstr_indent (out, indent); - g_string_sprintfa (out, "Features: "); - for (iter = g_list_first (package->features); iter != NULL; iter = g_list_next (iter)) { - if (iter == package->features) { - g_string_sprintfa (out, "%s", (char *)(iter->data)); - } else { - g_string_sprintfa (out, "; %s", (char *)(iter->data)); - } - } - g_string_sprintfa (out, "\n"); - } - - if (deep && package->provides != NULL) { - gstr_indent (out, indent); - g_string_sprintfa (out, "Provides:\n"); - for (iter = g_list_first (package->provides); iter != NULL; iter = g_list_next (iter)) { - g_string_sprintfa (out, "\t\t%s\n", (char *)(iter->data)); - } - g_string_sprintfa (out, "\n"); - } - indent -= 4; outstr = out->str; diff --git a/components/services/install/nautilus-view/nautilus-service-install-view.c b/components/services/install/nautilus-view/nautilus-service-install-view.c index e7cbd3489..48340e1ae 100644 --- a/components/services/install/nautilus-view/nautilus-service-install-view.c +++ b/components/services/install/nautilus-view/nautilus-service-install-view.c @@ -1438,6 +1438,9 @@ nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view, g_free (out); CORBA_exception_init (&ev); + if (view->details->installer) { + eazel_install_callback_unref (GTK_OBJECT (view->details->installer)); + } view->details->installer = eazel_install_callback_new (); if (view->details->installer == NULL) { GtkWidget *toplevel, *dialog; |