package "linux-headers-$(uname -r)" succeeds to install, but always tells diff
sonots opened this issue · comments
INFO : package[linux-headers-$(name -r)] installed will change from 'false' to 'true'
DEBUG : Executing `dpkg-query -f '${Status}' -W linux-headers-\$\(name\ -r\) | grep -E '^(install|hold) ok installed$'`...
DEBUG : stdout | dpkg-query: no packages found matching linux-headers-$(name -r)
DEBUG : exited with 1
DEBUG : Executing `DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install linux-headers-$(name -r)`...
DEBUG : stdout | /bin/sh: 1: name: not found
DEBUG : stdout | Reading package lists... 0%Reading package lists... 100%Reading package lists... Done
DEBUG : stdout | Building dependency tree... 0%Building dependency tree... 0%Building dependency tree... 50%Building dependency tree... 50%Reading state information... 0%Building dependency tree
DEBUG : stdout | Reading state information... 0%Reading state information... Done
DEBUG : stdout | Virtual packages like 'linux-headers' can't be removed
DEBUG : stdout | 0 upgraded, 0 newly installed, 0 to remove and 140 not upgraded.
DEBUG : exited with 0
it looks check_is_installed
escapes package name https://github.com/mizzy/specinfra/blob/2ea588e080e98c267e666693c7b37d1c025a89f0/lib/specinfra/command/debian/base/package.rb#L4, but install
does not do it https://github.com/mizzy/specinfra/blob/2ea588e080e98c267e666693c7b37d1c025a89f0/lib/specinfra/command/debian/base/package.rb#L16-L21.
I am not sure the best way to fix this.
I didn't expect command substitution like $(uname -r)
is passed to install command. How about the following?
uname_release = run_command('uname -r').stdout.chomp
package "linux-headers-#{uname_release}" do
...
end
it looks check_is_installed escapes package name https://github.com/mizzy/specinfra/blob/2ea588e080e98c267e666693c7b37d1c025a89f0/lib/specinfra/command/debian/base/package.rb#L4, but install does not do it https://github.com/mizzy/specinfra/blob/2ea588e080e98c267e666693c7b37d1c025a89f0/lib/specinfra/command/debian/base/package.rb#L16-L21.
I think escaping is correct behavior (but I am not sure which one is correct since I am not author of Specinfra)
@mizzy do you have any concerns for this issue? Changing behavior to have consistency between install
and check_is_installed
breaks either lower version compatibility, anyway.
Escaping is correct behavior. So escaping in install
is correct. But if we fix Specinfra to escape in install
, installing "linux-headers-$(uname -r)" will not work as you intend.
It's difficult ... let me have time to think about it.
@ryotarai wrote:
I didn't expect command substitution like $(uname -r) is passed to install command.
So am I with Specinfra. I didn't expect it.
@sonots
You can also write like this:
package "linux-headers-#{node['kernel']['release']}" do
...
end
Using command substitution is coupled too tightly with internal specification of Specinfra.
I recommend not using command substitution.
Okay, thank you for clarification.
I will send a PR to escape in "install".
I will send a PR to escape in "install".
Thanks a lot!