- if (pkg->essential && !from_upgrade) {
- 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 upon 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) {
- print_dependents_warning(conf, parent_pkg, pkg, dependents);
- free(dependents);
- return OPKG_PKG_HAS_DEPENDENTS;
- }
-
- /* remove packages depending on this package - Karthik */
- err = opkg_remove_dependent_pkgs (conf, pkg, dependents);
- if (err) {
- free(dependents);
- return err;
- }
- }
- if (dependents)
- free(dependents);
- }
-
- if (from_upgrade == 0) {
- opkg_message (conf, OPKG_NOTICE,
- "Removing package %s from %s...\n", pkg->name, pkg->dest->name);
- }
- 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(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;
+ if (pkg->essential && !from_upgrade) {
+ if (conf->force_removal_of_essential_packages) {
+ opkg_msg(NOTICE,
+ "Removing essential package %s under your coercion.\n"
+ "\tIf your system breaks, you get to keep both pieces\n",
+ pkg->name);
+ } else {
+ opkg_msg(NOTICE,
+ "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 -1;
+ }
+ }
+
+ 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(pkg, &dependents);
+
+ if (has_installed_dependents) {
+ /*
+ * if this package is depended upon 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) {
+ print_dependents_warning(pkg, dependents);
+ free(dependents);
+ return -1;
+ }
+
+ /* remove packages depending on this package - Karthik */
+ err = opkg_remove_dependent_pkgs(pkg, dependents);
+ if (err) {
+ free(dependents);
+ return err;
+ }
+ }
+ if (dependents)
+ free(dependents);
+ }
+
+ if (from_upgrade == 0) {
+ opkg_msg(NOTICE, "Removing package %s from %s...\n",
+ pkg->name, pkg->dest->name);
+ }
+ pkg->state_flag |= SF_FILELIST_CHANGED;
+
+ pkg->state_want = SW_DEINSTALL;
+ opkg_state_changed++;
+
+ if (pkg_run_script(pkg, "prerm", "remove") != 0) {
+ if (!conf->force_remove) {
+ opkg_msg(ERROR, "not removing package \"%s\", "
+ "prerm script failed\n", pkg->name);
+ opkg_msg(NOTICE,
+ "You can force removal of packages with failed "
+ "prerm scripts with the option: \n"
+ "\t--force-remove\n");
+ return -1;
+ }
+ }
+
+ /* 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(pkg);
+
+ err = pkg_run_script(pkg, "postrm", "remove");
+
+ remove_maintainer_scripts(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) {
+ if (remove_autoinstalled(pkg) != 0) {
+ err = -1;
+ }
+ }
+ return err;