diff --git a/api b/api index 4b57b6f6f7c..9071b2417d1 100755 --- a/api +++ b/api @@ -256,8 +256,9 @@ remove_repofile_if_unused() { #Given a sources.list.d file, delete it if nothing local IFS=$'\n' done elif [ "${file##*.}" == "sources" ]; then - #find empty lines in the file that separate stanzas - local empty_lines="$(grep -n '^$' "$file" | awk '{print $1}' | sed 's/:*//g')" + #find empty lines (empty line, line with all spaces, or line with all tabs) in the file that separate stanzas. empty lines are not allowed between fields within a stanza + #https://manpages.ubuntu.com/manpages/jammy/en/man5/deb822.5.html + local empty_lines="$(grep -P -n '^$|^ +$|^\t+$' "$file" | awk '{print $1}' | sed 's/:*//g')" #get number of lines in file local num_lines=$(wc -l "$file" | awk '{print $1}') @@ -277,9 +278,10 @@ remove_repofile_if_unused() { #Given a sources.list.d file, delete it if nothing sed -n "$line_start","$line_end"p "$file" | grep -q '^Enabled: no' && continue # determine what uri, suite, and components are in a file #each stanza can only have one matching section. if there are multiple matches the last one is used - local uri="$(sed -n "$line_start","$line_end"p "$file" | grep -v '^#' | grep '^URIs: ' | sed 's/URIs: //g' | tail -1)" - local suites="$(sed -n "$line_start","$line_end"p "$file" | grep -v '^#' | grep '^Suites: ' | sed 's/Suites: //g' | tail -1)" - local components="$(sed -n "$line_start","$line_end"p "$file" | grep -v '^#' | grep '^Components: ' | sed 's/Components: //g' | tail -1)" + #case should be ignored for fields + local uri="$(sed -n "$line_start","$line_end"p "$file" | grep -v '^#' | grep -i '^URIs: ' | sed 's/URIs: //Ig' | tail -1)" + local suites="$(sed -n "$line_start","$line_end"p "$file" | grep -v '^#' | grep -i '^Suites: ' | sed 's/Suites: //Ig' | tail -1)" + local components="$(sed -n "$line_start","$line_end"p "$file" | grep -v '^#' | grep -i '^Components: ' | sed 's/Components: //Ig' | tail -1)" local IFS=' ' for suite in $suites ;do if [ -z "$components" ]; then