From: "Maiti, Prasun" <prasunmait...@gmail.com>

If we uninstall last target from target/linux/feeds/
then feeds dir will be empty.

So, feeds dir is not needed anymore.

Signed-off-by: Maiti, Prasun <prasunmait...@gmail.com>
---
 scripts/feeds | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/scripts/feeds b/scripts/feeds
index aee73e793f..5fca78fc8d 100755
--- a/scripts/feeds
+++ b/scripts/feeds
@@ -497,6 +497,12 @@ sub is_core_src($) {
        return 0;
 }
 
+sub is_dir_empty {
+       my $dir = shift;
+       opendir(my $dh, $dir);
+       return scalar(grep { $_ ne "." && $_ ne ".." } readdir($dh));
+}
+
 sub install_target {
        my $feed = shift;
        my $name = shift;
@@ -771,6 +777,10 @@ sub uninstall {
                        system("rm -f ./package/feeds/*/$name");
                        $uninstall = 1;
                }
+               my $count = is_dir_empty("target/linux/feeds");
+               if (!$count) {
+                       system("rm -rvf ./target/linux/feeds");
+               }
        }
        $uninstall and refresh_config();
        return 0;
-- 
2.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to