-
Notifications
You must be signed in to change notification settings - Fork 340
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
Empty Aptfile Fix #118
Empty Aptfile Fix #118
Conversation
This PR fixes an error that occurs if an Aptfile with no packages is used. This case is detected now and a warning is printed advising that the buildpack and Aptfile should be removed before exiting the build. I've also added a test harness to this project with several variations of Aptfile contents we've seen used. There appears to have been tests in this repository at an earlier point but they were lost or abandoned at some point. This should prevent future accidental breakage if changes are needed for this buildpack.
This PR fixes an error that occurs if an Aptfile with no packages is used. This case is detected now and a warning is printed advising that the buildpack and Aptfile should be removed before exiting the build. I've also added a test harness to this project with several variations of Aptfile contents we've seen used. There appears to have been tests in this repository at an earlier point but they were lost or abandoned at some point. This should prevent future accidental breakage if changes are needed for this buildpack.
|
||
for PACKAGE in $(cat "$BUILD_DIR/Aptfile" | grep -v -s -e '^#' | grep -v -s -e "^:repo:"); do | ||
while IFS= read -r PACKAGE; do | ||
if [[ $PACKAGE == *deb ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're cleaning things up, this should be == *.deb
;)
@@ -29,6 +29,17 @@ function indent() { | |||
esac | |||
} | |||
|
|||
# exit early because we don't need to do any work if the aptfile has no packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're repeating these grep patterns a lot all over the place now.
I'd suggest doing this check a bit later, down before the for DEB in "$APT_CACHE_DIR/archives/"*.deb; do
line, like this:
shopt -s nullglob
debs=( "$APT_CACHE_DIR/archives/"*.deb )
if ! (( ${#debs[@]} )); then
// no packages warning and exit 0
fi
for DEB in "${debs[@]}"; do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. If there are no packages to install then we don't need to do any work including running apt-get update
so I think the exit here makes more sense.
And that way, when packages are installed, the for DEB in "$APT_CACHE_DIR/archives/"*.deb
line will not cause a failure so it can remain unchanged.
This PR fixes an error that occurs if an
Aptfile
with no packages is used, that was introduced by #115. This case is detected now and a warning is printed advising that the buildpack andAptfile
should be removed before exiting the build.I've also added a test harness to this project with several variations of
Aptfile
contents we've seen used. There appears to have been tests in this repository at an earlier point but they were lost or abandoned at some point. This should prevent future accidental breakage if changes are needed for this buildpack.Fixes #117.