-/* Actually, when "message == 1" I have been called from an upgrade, and not from a normal remove
- thus I wan't check for essential, as I'm upgrading.
- I hope it won't break anything :)
-*/
- int err;
- abstract_pkg_t *parent_pkg = NULL;
-
- if (pkg->essential && !message) {
- if (conf->force_removal_of_essential_packages) {
- fprintf(stderr, "WARNING: Removing essential package %s under your coercion.\n"
- "\tIf your system breaks, you get to keep both pieces\n",
- pkg->name);
- } else {
- fprintf(stderr, "ERROR: Refusing to remove essential package %s.\n"
- "\tRemoving an essential package may lead to an unusable system, but if\n"
- "\tyou enjoy that kind of pain, you can force opkg to proceed against\n"
- "\tits will with the option: -force-removal-of-essential-packages\n",
- pkg->name);
- return OPKG_PKG_IS_ESSENTIAL;
- }
- }
-
- if ((parent_pkg = pkg->parent) == NULL)
- return 0;
-
- /* only attempt to remove dependent installed packages if
- * force_depends is not specified or the package is being
- * replaced.
- */
- if (!conf->force_depends
- && !(pkg->state_flag & SF_REPLACE)) {
- abstract_pkg_t **dependents;
- int has_installed_dependents =
- pkg_has_installed_dependents(conf, parent_pkg, pkg, &dependents);
-
- if (has_installed_dependents) {
- /*
- * if this package is depended up by others, then either we should
- * not remove it or we should remove it and all of its dependents
- */
-
- if (!conf->force_removal_of_dependent_packages
- && !user_prefers_removing_dependents(conf, parent_pkg, pkg, dependents)) {
- return OPKG_PKG_HAS_DEPENDENTS;
- }
-
- /* remove packages depending on this package - Karthik */
- err = opkg_remove_dependent_pkgs (conf, pkg, dependents);
- free(dependents);
- if (err) return err;
- }
- }
-
- if ( message==0 ){
- opkg_message (conf, OPKG_NOTICE,
- "Removing package %s from %s...\n", pkg->name, pkg->dest->name);
- fflush(stdout);
- }
- pkg->state_flag |= SF_FILELIST_CHANGED;
-
- pkg->state_want = SW_DEINSTALL;
- opkg_state_changed++;
-
- pkg_run_script(conf, pkg, "prerm", "remove");
-
- /* DPKG_INCOMPATIBILITY: dpkg is slightly different here. It
- maintains an empty filelist rather than deleting it. That seems
- like a big pain, and I don't see that that should make a big
- difference, but for anyone who wants tighter compatibility,
- feel free to fix this. */
- remove_data_files_and_list(conf, pkg);
-
- pkg_run_script(conf, pkg, "postrm", "remove");
-
- remove_maintainer_scripts_except_postrm(conf, pkg);
-
- /* Aman Gupta - Since opkg is made for handheld devices with limited
- * space, it doesn't make sense to leave extra configurations, files,
- * and maintainer scripts left around. So, we make remove like purge,
- * and take out all the crap :) */
-
- remove_postrm(conf, pkg);
- pkg->state_status = SS_NOT_INSTALLED;
-
- if (parent_pkg)
- parent_pkg->state_status = SS_NOT_INSTALLED;
-
-
- /* remove autoinstalled packages that are orphaned by the removal of this one */
- if (conf->autoremove)
- remove_autoinstalled (conf, pkg);
-
-
-
- return 0;