Skip to content

Commit

Permalink
api: anything_installed_from_uri_suite_component simplify function
Browse files Browse the repository at this point in the history
  • Loading branch information
theofficialgman committed Feb 25, 2024
1 parent e69b7dd commit 7023ec6
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ anything_installed_from_uri_suite_component() { #Given an apt repository uri, su
debug "$repofiles"

#for every repo-file, check if any of them have an installed file
local found=0
local IFS=$'\n'
local repofile
for repofile in $repofiles ;do
Expand All @@ -253,23 +252,15 @@ anything_installed_from_uri_suite_component() { #Given an apt repository uri, su

if [ -z "$3" ]; then
if echo "$apt_cache_policy_output" | grep -B1 "$(echo "$1" | sed 's+.*://++g' | sed "s,/$,,") $2" | awk '{print $1}' | grep -Fq '***' ;then
found=1
break
return 0
fi
else
if echo "$apt_cache_policy_output" | grep -B1 "$(echo "$1" | sed 's+.*://++g' | sed "s,/$,,") $2/$3" | awk '{print $1}' | grep -Fq '***' ;then
found=1
break
return 0
fi
fi
done

#return an exit code
if [ $found == 1 ];then
return 0
else
return 1
fi
return 1
}

remove_repofile_if_unused() { #Given a sources.list.d file, delete it if nothing from that repository is currently installed. Deletion skipped if $2 is 'test'
Expand Down

0 comments on commit 7023ec6

Please sign in to comment.