Forcing a downgrade/upgrade of an apt package


#1

Aló chefs,

I am writing a recipe for installing and going back from ruby enterprise
edition to regular ruby in ubuntu. The guys at brightbox provide a nice apt
repo for ree. In that repo ree is packaged to overwrite regular ruby
locations.

The recipe that installs ruby enterprise from regular ruby basically adds a
file to /etc/apt/sources.list.d/ruby-ee with the repository parameters, this
notifies imediately an apt-get update, and then I have the following code
that tries to install ruby.

packages = %w(ruby ruby-dev rubygems libopenssl-ruby libreadline-ruby
librmagick-ruby librmagick-ruby1.8 rubygems1.8 ruby1.8 ruby1.8-dev
libopenssl-ruby1.8 librmagick-ruby1.8 libruby1.8)

packages.each do |p|
package p do
action [ :install, :upgrade ]
end
end

The reverse operation is performed in a similar way, I just check if ree is
installed, then I remove the /etc/apt/sources.list.d/ruby-ee file, apt-get
update, and the code above.

My problem: chef does not notice the change (apt-cache show ruby gives the
candidate though.)

Is this a problem on how chef handles the apt resource?
Should I pass an extra parameter to the package resource to force the
"upgrade"?

Thanks.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a


#2

On Tue, Feb 22, 2011 at 7:07 AM, Jacobo García jacobo.garcia@gmail.com wrote:

My problem: chef does not notice the change (apt-cache show ruby gives the
candidate though.)

Can you provide the package related output from running chef with “-l
debug”? For example:

[Tue, 22 Feb 2011 17:31:02 +0000] DEBUG: Checking apt-cache policy for
libmysqlclient-dev
[Tue, 22 Feb 2011 17:31:02 +0000] DEBUG: Current version is 5.1.41-3ubuntu12.9
[Tue, 22 Feb 2011 17:31:02 +0000] DEBUG: Current version is 5.1.41-3ubuntu12.9

Note that due to CHEF-1276 [1] the second one is the Candidate version.

Bryan

[1] http://tickets.opscode.com/browse/CHEF-1276


#3

Hi Brian,

I did not answer sooner (my apologies) because I had to re-create the tests
environment, and then I figured it out what was going on.

It was not a chef problem at all, it was an apt problem.

According to brightbox wiki[1] to “downgrade” to regular ruby you need to do
some apt-pinning. The thing got a bit more complicated since there’s a
bug[2] in aptitude and I had to workaround it through chef (that meant more
coding and testing) but now I am able to change back and forth from regular
ruby to ree with easily.

Thanks for your time.

[1] http://wiki.brightbox.co.uk/docs:ruby-enterprise
[2] https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/508545

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a

On Tue, Feb 22, 2011 at 7:15 PM, Bryan McLellan btm@loftninjas.org wrote:

On Tue, Feb 22, 2011 at 7:07 AM, Jacobo García jacobo.garcia@gmail.com
wrote:

My problem: chef does not notice the change (apt-cache show ruby gives
the
candidate though.)

Can you provide the package related output from running chef with “-l
debug”? For example:

[Tue, 22 Feb 2011 17:31:02 +0000] DEBUG: Checking apt-cache policy for
libmysqlclient-dev
[Tue, 22 Feb 2011 17:31:02 +0000] DEBUG: Current version is
5.1.41-3ubuntu12.9
[Tue, 22 Feb 2011 17:31:02 +0000] DEBUG: Current version is
5.1.41-3ubuntu12.9

Note that due to CHEF-1276 [1] the second one is the Candidate version.

Bryan

[1] http://tickets.opscode.com/browse/CHEF-1276