Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to help identify bottled / unbottled formulae #2610

Merged
merged 8 commits into from
May 22, 2024

Conversation

scpeters
Copy link
Member

@scpeters scpeters commented Mar 26, 2024

I'm working on a GitHub actions workflows to automate removing broken bottles and rebuilding missing bottles, and I'm starting with two scripts:

  • unbottled_dependencies.sh prints the unbottled dependencies needed by a given formula (useful for rebuilding bottles)
  • bottled_dependents.sh prints the bottled dependents that use a given formula (useful for removing broken bottles)

unbottled_dependencies.sh examples

Gazebo Ionic not yet bottled, so it has lots of unbottled dependencies:

$ ./unbottled_dependencies.sh gz-ionic
osrf/simulation/gz-cmake4
osrf/simulation/gz-common6
osrf/simulation/gz-fuel-tools10
osrf/simulation/gz-gui9
osrf/simulation/gz-launch8
osrf/simulation/gz-math8
osrf/simulation/gz-msgs11
osrf/simulation/gz-physics8
osrf/simulation/gz-plugin3
osrf/simulation/gz-rendering9
osrf/simulation/gz-sensors9
osrf/simulation/gz-sim9
osrf/simulation/gz-transport14
osrf/simulation/gz-utils3
osrf/simulation/sdformat15

but several other collections have some bottles missing:

$ ./unbottled_dependencies.sh gz-harmonic
osrf/simulation/gz-physics7
$ ./unbottled_dependencies.sh gz-garden
osrf/simulation/gz-fuel-tools8
osrf/simulation/gz-gui7
osrf/simulation/gz-launch6
osrf/simulation/gz-msgs9
osrf/simulation/gz-physics6
osrf/simulation/gz-sensors7
osrf/simulation/gz-sim7
osrf/simulation/gz-transport12

bottled_dependents.sh examples

When a new protobuf version lands in homebrew-core, we have to remove bottles for all dependents that use gz-msgs*:

$ ./bottled_dependents.sh gz-msgs10
osrf/simulation/gz-fuel-tools9
osrf/simulation/gz-gui8
osrf/simulation/gz-launch7
osrf/simulation/gz-sensors8
osrf/simulation/gz-sim8
osrf/simulation/gz-transport13

Copy link
Member

@nuclearsandwich nuclearsandwich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of my comments are binding, but I did a shellnerd review.

@@ -0,0 +1,43 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this script has to be run on macOS it may make sense to write it not to use bash, given that the version of Bash available without homebrew is heinously out-of-date. (or it's been removed, I can't remember)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to that; do you recommend zsh?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to /bin/sh in d3e7b1d


FORMULA=${1}

if [[ $# -ne 1 ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ $# -ne 1 ]]; then
if [ $# -ne 1 ]; then

This can use test / [] instead of the bash conditional expression `[[]]``.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to [] in d45f9e6

exit 1
fi

for f in $(brew deps ${FORMULA} --full-name | grep osrf/simulation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is osrf/simulation always at the beginning or end of the full name? You could either use grep -F to do a literal search for this, although it would match gosrf/simulationz as well. Or use an anchored expression such as ^osrf/simulation for matching the start of the line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tightened up as ^osrf/simulation/ in d45f9e6

# but has different output for formulae that are "ready to bottle" or
# that have "unbottled deps". So just echo the name of any formula for which
# `brew unbottled` doesn't print "already bottled"
brew unbottled $f | grep "already bottled" > /dev/null \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU grep has a -q/--quiet flag but I can't recall if it also exists in FreeBSD grep.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call; using --quiet in d45f9e6

Comment on lines 41 to 42
brew unbottled $f | grep "already bottled" > /dev/null \
|| echo $f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly worth phrasing this as a conditional statement since it's already split across multiple lines.

Suggested change
brew unbottled $f | grep "already bottled" > /dev/null \
|| echo $f
if brew unbottled $f | grep "already bottled" > /dev/null; then
echo $f
fi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to if statement in d45f9e6

* Improve regex by starting with ^, ending with /
* [ ] instead of [[ ]]
* Use grep --quiet instead of > /dev/null
* Use if block instead of multi-line command with ||

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters force-pushed the scpeters/unbottled_dependencies_script branch from 7c7573f to 1a07ebf Compare April 2, 2024 18:05
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters force-pushed the scpeters/unbottled_dependencies_script branch from 1a07ebf to 5194681 Compare April 2, 2024 18:06
Useful for removing broken bottles

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters changed the title Add script to help identify unbottled dependencies Add scripts to help identify bottled / unbottled formulae Apr 2, 2024
@scpeters
Copy link
Member Author

scpeters commented Apr 2, 2024

I added another script and updated the pull request description

@scpeters
Copy link
Member Author

thanks for the reviews; I'm going to merge these scripts since I've been using them successfully for quite a few bottle-related pull requests

@scpeters scpeters merged commit 09d590c into master May 22, 2024
1 check passed
@scpeters scpeters deleted the scpeters/unbottled_dependencies_script branch May 22, 2024 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants