-
Notifications
You must be signed in to change notification settings - Fork 847
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
Ensure packages are installed before removing them #2422
Conversation
Thanks for opening this pull request! Make sure
|
I wonder if another PR doing the inverse for installing packages might be nice 🤔 , this PR looks good but needs testing |
I'd say no. Installing over an existing package doesn't result in an error, and may actually be intentional at times. |
Well it is dpkg if the packages doesn't exists just write a string in the command and will move on with the others so is not a blocker. Also if the package exist and you install again it will do the same (I am a debian user). |
but it might let us avoid running |
I can't speak to any other setup, but the install actually does do necessary things on my build. |
yes but on the second provision once all those packages are installed, does it really need to make |
It wasn't part of this pr #2281 |
@Mte90 that PR does something very different, that PR changes when apt is re-run, I'm saying that if |
Well we need to do a lot of check with dpkg and it is something that apt will do automatically for us. |
E.g. instead of: VVV_PACKAGE_LIST+=(nginx) we have something like this: if ! command -v nginx &> /dev/null
then
VVV_PACKAGE_LIST+=(nginx)
fi |
Because it's faster, testing if Nginx or MariaDB are installed is much faster when we know what to look for. It also doesn't require us to update apt sources, clean out apt files, etc. Apt is the biggest time consumer in a fresh provision right now |
Honestly I don't know if it will be more faster to do that on by own or let do it by apt... |
I actually do think it'd be faster to check on our own. |
It's what Ansible does IIRC, it only tries to install things that need installing. Checking if a file exists or is in path will be much faster than checking apt sources and the local dpkg database. As for this PR, it just needs testing, it looks ok from reading the code |
@evertiro I'm not sure why but I can no longer check out this branch locally:
|
I suspect you need to rebase on to the latest |
I manually tested this, and it's functional but I modified the function to this: vvv_package_remove() {
declare -a packages=($@)
# Ensure packages are actually installed before removing them
if [ ${#packages[@]} -ne 0 ]; then
for package in "${packages[@]}"; do
if ! dpkg -s -l "${package}"; then
packages=("${packages[@]/$package}")
fi
done
fi
echo "${packages[@]}"
return 0 and got this:
https://askubuntu.com/questions/703160/running-dpkg-s-or-l-silent should help with remedying that
|
On further inspection this won't work because it's modifying the list as it's looping through it, which mangles the results. I've made tweaks locally to fix this as well as put the inverse logic on the install and the main provisioner went from ~40s to 27s |
Your way is much cleaner than mine, closing this issue |
Fixes outstanding issue on #2408
Checks
develop
branch not thestable
branch.