Remove orphaned package libsensors3.
[carnet-upgrade.git] / src / functions.sh
index 19c76b3..527742a 100644 (file)
@@ -897,6 +897,30 @@ remove_skey () {
   fi
 }
 
+# check if package is orphaned (nothing depends on it)
+is_orphaned () {
+  local package deps
+
+  package=$1
+  deps=$(apt-get remove -s $package | grep ^Remv | wc -l)
+  if [ "$deps" -eq 1 ]; then 
+    return 0
+  else 
+    return 1
+  fi
+}
+
+# remove old and unused libraries
+remove_orphaned () {
+  local package
+
+  for package in $orphaned_packages; do
+    if is_orphaned $package; then
+      pkgrm $package
+    fi
+  done
+}
+
 # monit it causing problems for postinst scripts
 # restarting daemons so try to disable it
 disable_monit () {