Closed lusis closed 12 years ago
First thing that comes to mind is how bundler is doing it with the platforms
stuff. So the following might be one possible attempt.
class Cassandra < FPM::Cookery::Recipe
name "cassandra"
version "1.0.0"
platform [:centos, :rhel] do
depends "java-1.6.0-openjdk"
pre_install "pre-inst.sh"
end
platform :debian do
depends "openjdk-6-jre"
section "database"
end
end
I just read https://github.com/jordansissel/fpm/wiki/Ideas-for-Hackfest again. There you used different depends based on the package target. (deb, rpm) Does that really work or do we have to set dependencies based on the operating system. (SuSE (rpm) might not have the same package names as CentOS (rpm as well))
I think at this point, target-based determination is probably the best route. Sure SuSE and RHEL+clones share RPM but short of requiring ohai or facter as a dep, I have no idea the best way to do OS level detection.
Doing the thought exercise, facter would probably be the best bet. It has no external dependencies. ohai pulls in yajl and various mixlib packages. I've not dealt with the facter API in a while but I don't recall it being cumbersome in the least.
I've got a working tentative here: ade56935ff40f17317497e1b74392ff2ddb815fb
Not sure how best to do the specs for it. It works though.
I also just realized that there might be a use case where you'd want to override the detection. I think I'll add a CLI opt for that. In my case, it's pretty safe to build noarch RPMS on ubuntu but I still need the conditional there. Hrmmm....
+1 for platform-specific dependencies also +1 for overriding what the 'detected' platform shows as.
I pulled your commit and I'm currently working on a cli flag. Thanks!
Ahh nice. I actually have some unpushed work on a cli flag as well at home that I did last night but I'll wait and see what you do ;)
One thing I went ahead and did was add this to the cli:
if @target.nil?
case @platform
when :centos, :redhat, :suse
@target = "rpm"
when :debian, :ubuntu
@target = "deb"
else
puts "No target given and we're unable to detect your platform"
exit(1)
end
puts "No --target given, assuming #{@target} based on platform detection"
end
I just pushed my stuff. Please review. :)
I like your stuff better than MY stuff. Wanna adopt some of my projects? Looks good to me. Much cleaner. Gives me a good idea of the style you want to go down for newer patches as well.
Don't worry too much about style. I can always adjust the code afterwards if I want to change something. I want to keep the barrier for contributors low. Working code is better than no code. :)
Thank you!
Thinking about the issue where I have an application like ActiveMQ or Cassandra where I need a JDK installed. The problem is that hard coding a dep there doesn't work thanks to the clusterfuck that is distro package naming.
Right now I plan on managing this with Chef in my Brisk cookbook but a general dependency conditional based on target would be neat.