Skip to content

Commit

Permalink
Fix update_apt_package_in_package_list.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
tkilias committed Oct 25, 2023
1 parent 52bf892 commit 349110c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/update_apt_package_in_package_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ set -o nounset
set -o pipefail

LIST_NEWEST_VERSION_OUTPUT=$1 # Package|Installed|Candidate
FLAVOR=$2
SEARCH_DIRECTORY=$2
REPLACE=$3

PACKAGE=$(echo "$LIST_NEWEST_VERSION_OUTPUT" | cut -f 1 -d "|")
CANDIDATE_VERSION=$(echo "$LIST_NEWEST_VERSION_OUTPUT" | cut -f 3 -d "|")
REPLACE=$3
CURRENT_VERSION=$(echo "$LIST_NEWEST_VERSION_OUTPUT" | cut -f 2 -d "|")

if [[ "$REPLACE" == "yes" ]]
then
SED_REPLACE_OPTION=("-i")
else
SED_REPLACE_OPTION=()
fi
grep -E -R "^$PACKAGE\|" "$FLAVOR" \
grep -E -R "^$PACKAGE\|$CURRENT_VERSION" "$SEARCH_DIRECTORY" \
| cut -f 1 -d ":" \
| xargs -I{} sed "${SED_REPLACE_OPTION=[@]}" -E "s/^($PACKAGE)\|.*$/$PACKAGE|$CANDIDATE_VERSION/g" "{}" \
| xargs -I{} sed "${SED_REPLACE_OPTION[@]}" -E "s/^($PACKAGE\|$CURRENT_VERSION).*$/$PACKAGE|$CANDIDATE_VERSION/g" "{}" \
| grep -E "^$PACKAGE\|"

0 comments on commit 349110c

Please sign in to comment.