Skip to content

Commit

Permalink
Apply shellcheck's recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Sep 19, 2024
1 parent 60d11a0 commit 3235f52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{ github.token }}
HOMEBREW_GITHUB_PACKAGES_USER: ${{ github.actor }}
PULL_REQUEST: ${{ github.event.pull_request.number }}
run: brew pr-pull --debug --tap=$GITHUB_REPOSITORY $PULL_REQUEST
run: brew pr-pull --debug --tap="$GITHUB_REPOSITORY" "$PULL_REQUEST"

- name: Push commits
uses: Homebrew/actions/git-try-push@master
Expand All @@ -32,4 +32,4 @@ jobs:
if: github.event.pull_request.head.repo.fork == false
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
run: git push --delete origin $BRANCH
run: git push --delete origin "$BRANCH"
46 changes: 22 additions & 24 deletions transform_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,51 @@

VERSION=$1

if [ -z "${VERSION}" ]; then
if [[ -z "${VERSION}" ]]; then
echo >&2 "Fatal error: VERSION not set"
echo >&2 "Fatal error: Need to provide version, example: 5.62.0"
exit 2
fi

CBMC_STRING="CbmcAT"
VERSION_PROCESSED="${VERSION//./}"
FORMULA_VERSION="$CBMC_STRING$VERSION_PROCESSED"
FORMULA_VERSION="${CBMC_STRING}${VERSION_PROCESSED}"

echo "bottle do"
echo " root_url \"https://github.com/diffblue/homebrew-cbmc/releases/download/bag-of-goodies\""
for TAG in "arm64_sonoma" "arm64_ventura" "arm64_monterey" "sonoma" "ventura" "monterey" "x86_64_linux"
do
#echo "Processing bottle for $VERSION -- $TAG"
OUTPUT=$(brew fetch cbmc --bottle-tag=$TAG)
OUTPUT=$(echo "$OUTPUT" | tail -n -2)
OUTPUT=$(brew fetch cbmc --bottle-tag="${TAG}")
OUTPUT=$(echo "${OUTPUT}" | tail -n -2)

pat1='Downloaded to: (.*\.{1})(tgz|tar\.gz)'
pat2='Already downloaded: (.*\.{1})(tgz|tar\.gz)'

if [[ $OUTPUT =~ $pat1 ]]; then
if [[ ${OUTPUT} =~ ${pat1} ]]; then
BOTTLE_NAME=${BASH_REMATCH[1]}
BOTTLE_NAME+="tar.gz"

tar -xzf $BOTTLE_NAME
mv cbmc cbmc@$1
sed -iu "s/class Cbmc/class $FORMULA_VERSION/g" cbmc@$1/$1/.brew/cbmc.rb
tar czf cbmc@$1-$1.$TAG.bottle.tar.gz cbmc@$1
rm -rf cbmc@$1
#SHA=$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz)
#echo "$SHA"
LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz | awk '{print $1}')\""
echo "$LINE"
elif [[ $OUTPUT =~ $pat2 ]]; then
tar -xzf "${BOTTLE_NAME}"
mv cbmc cbmc@"${VERSION}"
sed -iu "s/class Cbmc/class ${FORMULA_VERSION}/g" "cbmc@${VERSION}/${VERSION}/.brew/cbmc.rb"
tar czf "cbmc@${VERSION}-${VERSION}.${TAG}.bottle.tar.gz" cbmc@"${VERSION}"
rm -rf cbmc@"${VERSION}"
SHA=$(shasum -a 256 "cbmc@${VERSION}-${VERSION}.$TAG.bottle.tar.gz" | awk '{print $1}')

Check failure on line 35 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

Check failure on line 35 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

Prefer putting braces around variable references even when not strictly required.

Check failure on line 35 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (macos-latest)

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

Check failure on line 35 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (macos-latest)

Prefer putting braces around variable references even when not strictly required.
LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"${SHA}\""

Check failure on line 36 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

Prefer putting braces around variable references even when not strictly required.

Check failure on line 36 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (macos-latest)

Prefer putting braces around variable references even when not strictly required.
echo "${LINE}"
elif [[ ${OUTPUT} =~ ${pat2} ]]; then
BOTTLE_NAME=${BASH_REMATCH[1]}
BOTTLE_NAME+="tar.gz"

tar -xzf $BOTTLE_NAME
mv cbmc cbmc@$1
sed -iu "s/class Cbmc/class $FORMULA_VERSION/g" cbmc@$1/$1/.brew/cbmc.rb
tar czf cbmc@$1-$1.$TAG.bottle.tar.gz cbmc@$1
rm -rf cbmc@$1
#SHA=$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz)
#echo "$SHA"
LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz | awk '{print $1}')\""
echo "$LINE"
tar -xzf "${BOTTLE_NAME}"
mv cbmc cbmc@"${VERSION}"
sed -iu "s/class Cbmc/class $FORMULA_VERSION/g" "cbmc@${VERSION}/${VERSION}/.brew/cbmc.rb"

Check failure on line 44 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

Prefer putting braces around variable references even when not strictly required.

Check failure on line 44 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (macos-latest)

Prefer putting braces around variable references even when not strictly required.
tar czf "cbmc@${VERSION}-${VERSION}.${TAG}.bottle.tar.gz" cbmc@"${VERSION}"
rm -rf cbmc@"${VERSION}"
SHA=$(shasum -a 256 "cbmc@${VERSION}-${VERSION}.$TAG.bottle.tar.gz" | awk '{print $1}')

Check failure on line 47 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

Check failure on line 47 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

Prefer putting braces around variable references even when not strictly required.

Check failure on line 47 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (macos-latest)

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

Check failure on line 47 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (macos-latest)

Prefer putting braces around variable references even when not strictly required.
LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"${SHA}\""

Check failure on line 48 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

Prefer putting braces around variable references even when not strictly required.

Check failure on line 48 in transform_binary.sh

View workflow job for this annotation

GitHub Actions / test-bot (macos-latest)

Prefer putting braces around variable references even when not strictly required.
echo "${LINE}"
fi
done
echo end

0 comments on commit 3235f52

Please sign in to comment.