diff options
author | davidovski <david@davidovski.xyz> | 2022-02-20 21:33:41 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-02-20 21:33:41 +0000 |
commit | 42352a35a057c8315e8acd8ea4217df8353ae16a (patch) | |
tree | 73dc6600425d8d39d97a1acc480ddf028ce7be40 /src/remove.sh | |
parent | 0e307ec9997b94a2a782746d2a28ab15a9ea2a87 (diff) |
added remove command
Diffstat (limited to 'src/remove.sh')
-rw-r--r-- | src/remove.sh | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/remove.sh b/src/remove.sh index 727bcec..3e722fb 100644 --- a/src/remove.sh +++ b/src/remove.sh @@ -1,8 +1,44 @@ #!/bin/sh remove () { + local packages=$@ + + local to_remove="${CACHE_DIR}/toremove" + [ -f $to_remove ] && rm $to_remove + local real="" + + for package in $@; do + local package_dir="${INSTALLED_DIR}/$package" + local filesfile="${package_dir}/files" + if [ -d $package_dir ]; then + [ -f $filesfile ] && + cat $filesfile >> $to_remove + echo $package_dir >> $to_remove + real="$real $package" + else + >&2 printf "${RED}Package ${LIGHT_RED}$package${RED} is not installed" + fi + done + + local total=$(cat $to_remove | wc -l) + + ${QUIET} || printf "${LIGHT_RED}The following packages will be removed from the system:\n\t${RED}%s\n" $real + ${QUIET} || printf "${LIGHT_RED}Files to remove: ${RED}%s\n" $total + + if prompt_question "Continue?"; then + + local removed=0 + ${QUIET} || hbar + for file in $(cat $to_remove); do + rm -rf $file + + removed=$((removed+1)) + ${QUIET} || hbar ${HBAR_RED} -T "removing files" $removed $total + done + ${QUIET} || hbar -t ${HBAR_COMPLETE} -T "removing files" $removed $total + else + ${QUIET} || printf "${LIGHT_BLACK}Action cancled by user\n" + fi - # TODO ask to remove package - # TODO calculate broken dependencies - # TODO } + |