def package(manager, package, version): if manager.name == package: return if manager.name in ('apt', 'yum'): c.package(package, version=version) # See comments on this section in `puppet` above. match = re.match(r'^rubygems(\d+\.\d+(?:\.\d+)?)$', package) if match is not None and util.rubygems_update(): c.execute('/usr/bin/gem{0} install --no-rdoc --no-ri ' 'rubygems-update'.format(match.group(1))) c.execute('/usr/bin/ruby{0} ' '$(PATH=$PATH:/var/lib/gems/{0}/bin ' 'which update_rubygems)"'.format(match.group(1))) # All types of gems get to have package resources. elif 'rubygems' == manager.name: c.gem_package(package, version=version) elif re.search(r'ruby', manager.name) is not None: match = re.match(r'^ruby(?:gems)?(\d+\.\d+(?:\.\d+)?)', manager.name) c.gem_package(package, gem_binary='/usr/bin/gem{0}'.format(match.group(1)), version=version) # Everything else is an execute resource. else: c.execute(manager(package, version))
def package(manager, package, version): if manager.name == package: return s.add(manager(package, version)) if manager.name not in ('apt', 'yum'): return # See comments on this section in `puppet` above. match = re.match(r'^rubygems(\d+\.\d+(?:\.\d+)?)$', package) if match is not None and util.rubygems_update(): s.add('/usr/bin/gem{0} install --no-rdoc --no-ri ' 'rubygems-update', match.group(1)) s.add('/usr/bin/ruby{0} $(PATH=$PATH:/var/lib/gems/{0}/bin ' 'which update_rubygems)', match.group(1))
def package(manager, package, version): # `apt` and `yum` are easy since they're the default for their # respective platforms. if manager.name in ('apt', 'yum'): m['packages'][manager].add(puppet.Package(package, ensure=version)) # If APT is installing RubyGems, get complicated. This would # make sense to do with Yum, too, but there's no consensus on # where, exactly, you might find RubyGems from Yum. Going # the other way, it's entirely likely that doing this sort of # forced upgrade goes against the spirit of Blueprint itself. match = re.match(r'^rubygems(\d+\.\d+(?:\.\d+)?)$', package) if match is not None and util.rubygems_update(): m['packages'][manager].add(puppet.Exec('/bin/sh -c "' '/usr/bin/gem{0} install --no-rdoc --no-ri ' 'rubygems-update; ' '/usr/bin/ruby{0} $(PATH=$PATH:/var/lib/gems/{0}/bin ' 'which update_rubygems)"'.format(match.group(1)), require=puppet.Package.ref(package))) # RubyGems for Ruby 1.8 is easy, too, because Puppet has a # built in provider. This is called simply "rubygems" on # RPM-based distros. elif manager.name in ('rubygems', 'rubygems1.8'): m['packages'][manager].add(puppet.Package(package, ensure=version, provider='gem')) # Other versions of RubyGems are slightly more complicated. elif re.search(r'ruby', manager.name) is not None: match = re.match(r'^ruby(?:gems)?(\d+\.\d+(?:\.\d+)?)', manager.name) m['packages'][manager].add(puppet.Exec( manager(package, version), creates='{0}/{1}/gems/{2}-{3}'.format(util.rubygems_path(), match.group(1), package, version))) # Python works basically like alternative versions of Ruby # but follows a less predictable directory structure so the # directory is not known ahead of time. This just so happens # to be the way everything else works, too. else: m['packages'][manager].add(puppet.Exec( manager(package, version)))