opkg_remove: avoid remove pkg repeatly with option --force-removal-of-dependent-packages
[project/opkg-lede.git] / libopkg / opkg_remove.c
index 96ca558393dbc6b66427ae9d416e593afbcd7f24..c2abf8161e6b4cb81637ca862cc94aebaaf8a732 100644 (file)
@@ -249,6 +249,14 @@ int opkg_remove_pkg(pkg_t * pkg, int from_upgrade)
        if ((parent_pkg = pkg->parent) == NULL)
                return 0;
 
        if ((parent_pkg = pkg->parent) == NULL)
                return 0;
 
+       /* While remove pkg with '--force-removal-of-dependent-packages',
+          pkg may be added to remove list multiple times, add status
+          check to make sure pkg only be removed once. */
+       if (conf->force_removal_of_dependent_packages &&
+               pkg->state_flag & SF_FILELIST_CHANGED &&
+               pkg->state_status == SS_NOT_INSTALLED)
+               return 0;
+
        /* only attempt to remove dependent installed packages if
         * force_depends is not specified or the package is being
         * replaced.
        /* only attempt to remove dependent installed packages if
         * force_depends is not specified or the package is being
         * replaced.