Skip to content

Commit

Permalink
check debs edits
Browse files Browse the repository at this point in the history
  • Loading branch information
plowsof committed Oct 2, 2024
1 parent 0252f37 commit 4abcaab
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions shared_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -825,35 +825,55 @@ load_combined_tuples() {
# The 'old' hardcoded deb would appear in [MISSING] and the updated version would appear in the 'additional' list.
check_debs() {
local -a apt_packages
local -a missing_files=() # Declare missing_files as an empty array
local -a extra_packages=() # Declare extra_packages as an empty array

mapfile -t apt_packages < <(get_apt_packages)
load_combined_tuples

echo "APT recommended packages:"
printf ' %s\n' "${apt_packages[@]}"

echo -e "\nChecking against combined_tuples:"
local -a missing_files extra_packages

# Check for missing packages
for filename in "${combined_tuples[@]}"; do
if [[ " ${apt_packages[*]} " =~ " $filename " ]]; then
echo " [MATCH] $filename"
else
local found=false
for apt_pkg in "${apt_packages[@]}"; do
if [[ "$filename" == "$apt_pkg" ]]; then
found=true
echo " [MATCH] $filename"
break
fi
done
if [[ "$found" == false ]]; then
missing_files+=("$filename")
fi
done

for package in "${apt_packages[@]}"; do
if [[ ! " ${combined_tuples[*]} " =~ " $package " ]]; then
extra_packages+=("$package")
# Check for extra packages
for apt_pkg in "${apt_packages[@]}"; do
local found=false
for filename in "${combined_tuples[@]}"; do
if [[ "$apt_pkg" == "$filename" ]]; then
found=true
break
fi
done
if [[ "$found" == false ]]; then
extra_packages+=("$apt_pkg")
fi
done

# Output missing packages
if [ ${#missing_files[@]} -gt 0 ]; then
echo -e "\nAPT does not recommend us to install these:"
printf ' [MISSING] %s\n' "${missing_files[@]}"
else
echo -e "\nNo missing files!"
fi

# Output extra packages
if [ ${#extra_packages[@]} -gt 0 ]; then
echo -e "\nAPT recommends us to install these additional packages:"
printf ' %s\n' "${extra_packages[@]}"
Expand Down

0 comments on commit 4abcaab

Please sign in to comment.