cuisine icon indicating copy to clipboard operation
cuisine copied to clipboard

`package_ensure` does not safely ensure a package is installed

Open benjmin-r opened this issue 10 years ago • 5 comments

Hi,

I have a pretty bare Ubuntu 12.04 system (actually a hashicorp/precise64 Vagrant box) in which package_ensure('git') reports deinstall ok config-files OK, or rather the following as full output.

10.0.0.100] run: dpkg-query -W -f='${Status} ' git && echo OK;true
[10.0.0.100] out: deinstall ok config-files OK

According to the man dpkg(1), the config-files state means the package is not installed but config files are present.

So I was wondering if it'd make sense to expand the test for not-installed in package_ensure_apt to test for more states or at least report that packages are not installed, but will still not be installed by cuisine and manual intervention (or whatever) is needed.

I can come up with a PR, but would like your opinion on the semantics of package_ensure.

Thanks for your time!

benjmin-r avatar Mar 19 '14 21:03 benjmin-r

Hi Benjamin,

Good catch! I can't remember exactly why we tested for not "OK" or "not-installed" instead of just "not-installed". If there's another way for dpkg to say whether a package is installed or not, we should probably switch to that. A PR would be very welcome, thanks!

sebastien avatar Mar 19 '14 21:03 sebastien

Hi Sebastien,

thanks for your quick feedback! So just to be sure, package_ensure should behave in a way, that if a package is not fully present and installed, as in my case above, then an install should be triggered. In case of dpkg I'd then actually rather test for not 'installed' (slight difference to what you wrote), as this would cover all the not-installed/semi-broken states that dpkg reports. What do you think?

Thanks!

benjmin-r avatar Mar 19 '14 22:03 benjmin-r

Yes, if the package is not fully installed, it should be (re)installed. But the tricky is to make sure find the proper command arguments for dpkg and make sure it work in all the possible situations, including having a non-C (or en) locale (which my change the text to non installé for example with a fr LOCALE).

sebastien avatar Mar 20 '14 15:03 sebastien

I don't think I can make the time in near future to come up with a PR. As you described it's a bit more complicated than just testing for one other value. Feel free to close the issue or leave it open as a reminder. Thanks for taking the time to answer my questions.

benjmin-r avatar May 07 '14 21:05 benjmin-r

same error here!

zodman avatar Aug 25 '14 14:08 zodman