+remove_cn_bloat() {
+ local installed pkg cn_pkgs dialog_list selection cn_del to_del del_pkgs
+
+ # get installed packages
+ installed=$(mktemp /var/lib/carnet-upgrade/pkglist.XXXXXX)
+ COLUMNS=200 dpkg -l | awk '$1 ~ /^.i/ { print $2 }' >$installed
+
+ # detect installed CN packagees
+ for pkg in $(echo "$cn_bloats" | cut -d' ' -f1); do
+ if grep -qx $pkg $installed; then
+ cn_pkgs="$cn_pkgs $pkg"
+ dialog_list="$dialog_list $pkg '' off"
+ fi
+ done
+ rm -f $installed
+
+ # report status or finish if no CN packages found
+ if [ "$cn_pkgs" ]; then
+ log "Found CN packages:$cn_pkgs"
+ else
+ log "No CN packages found."
+ return
+ fi
+
+ # user selects the packages to delete
+ selection=$(mktemp /var/lib/carnet-upgrade/selection.XXXXXX)
+ eval LC_MESSAGES=hr_HR dialog --nocancel --backtitle \""$title"\" \
+ --checklist \""$msg_remove_cn_bloat"\" 20 75 6 $dialog_list 2>$selection
+
+ # expand the package list to include the services
+ for pkg in $(cat $selection); do
+ pkg=${pkg%\"}
+ pkg=${pkg#\"}
+ cn_del="$cn_del $pkg"
+ to_del=$(echo "$cn_bloats" | grep ^$pkg)
+ del_pkgs="$del_pkgs $to_del"
+ done
+ rm -f $selection
+
+ # report selection or finish if no service selected
+ if [ "$cn_del" ]; then
+ log "Removing CN services:$cn_del"
+ else
+ log "No CN services selected for removal."
+ return
+ fi
+
+ # delete the cn packages and relevant services
+ pkgrm_only $del_pkgs
+}
+