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

Empty Aptfile Fix #118

Closed
wants to merge 2 commits into from
Closed

Empty Aptfile Fix #118

wants to merge 2 commits into from

Conversation

colincasey
Copy link
Contributor

@colincasey colincasey commented Mar 18, 2024

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 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.

Fixes #117.

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.
@colincasey colincasey self-assigned this Mar 18, 2024
@colincasey colincasey requested a review from a team as a code owner March 18, 2024 22:04
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.
@edmorley edmorley mentioned this pull request Mar 19, 2024
@edmorley edmorley requested review from dzuelke and removed request for a team March 19, 2024 10:15

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
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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.

@colincasey
Copy link
Contributor Author

Closing this in favor of #126 so it's easier to see the changes required to fix #117. The equivalent to this PR is #121 and it's stack of related changes.

@colincasey colincasey closed this Mar 21, 2024
@edmorley edmorley deleted the fix_empty_aptfile branch March 25, 2024 09:08
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.

Fail when there's no packages to install
2 participants