librarian-puppet-0.9.10+dfsg.orig/0000755000000000000000000000000012253024160015426 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/README.md0000644000000000000000000001454112252267506016726 0ustar rootroot# Librarian-puppet ## Introduction Librarian-puppet is a bundler for your puppet infrastructure. You can use librarian-puppet to manage the puppet modules your infrastructure depends on. It is based on [Librarian](https://github.com/applicationsonline/librarian), a framework for writing bundlers, which are tools that resolve, fetch, install, and isolate a project's dependencies. Librarian-puppet manages your `modules/` directory for you based on your `Puppetfile`. Your `Puppetfile` becomes the authoritative source for what modules you require and at what version, tag or branch. Once using Librarian-puppet you should not modify the contents of your `modules` directory. The individual modules' repos should be updated, tagged with a new release and the version bumped in your Puppetfile. ## The Puppetfile Every Puppet repository that uses Librarian-puppet will have a file named `Puppetfile` in the root directory of that repository. The full specification for which modules your puppet infrastructure repository depends goes in here. ### Example Puppetfile forge "http://forge.puppetlabs.com" mod "puppetlabs/razor" mod "puppetlabs/ntp", "0.0.3" mod "apt", :git => "git://github.com/puppetlabs/puppetlabs-apt.git" mod "stdlib", :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git" *See [jenkins-appliance](https://github.com/aussielunix/jenkins-appliance) for a puppet repo already setup to use librarian-puppet.* ### Puppetfile Breakdown forge "http://forge.puppetlabs.com" This declares that we want to use the official Puppet Labs Forge as our default source when pulling down modules. If you run your own local forge, you may want to change this. mod "puppetlabs/razor" Pull in the latest version of the Puppet Labs Razor module from the default source. mod "puppetlabs/ntp", "0.0.3" Pull in version 0.0.3 of the Puppet Labs NTP module from the default source. mod "apt", :git => "git://github.com/puppetlabs/puppetlabs-apt.git" Our puppet infrastructure repository depends on the `apt` module from the Puppet Labs GitHub repos and checks out the `master` branch. mod "apt", :git => "git://github.com/puppetlabs/puppetlabs-apt.git", :ref => '0.0.3' Our puppet infrastructure repository depends on the `apt` module from the Puppet Labs GitHub repos and checks out a tag of `0.0.3`. mod "apt", :git => "git://github.com/puppetlabs/puppetlabs-apt.git", :ref => 'feature/master/dans_refactor' Our puppet infrastructure repository depends on the `apt` module from the Puppet Labs GitHub repos and checks out the `dans_refactor` branch. When using a Git source, we do not have to use a `:ref =>`. If we do not, then librarian-puppet will assume we meant the `master` branch. If we use a `:ref =>`, we can use anything that Git will recognize as a ref. This includes any branch name, tag name, SHA, or SHA unique prefix. If we use a branch, we can later ask Librarian-puppet to update the module by fetching the most recent version of the module from that same branch. The Git source also supports a `:path =>` option. If we use the path option, Librarian-puppet will navigate down into the Git repository and only use the specified subdirectory. Some people have the habit of having a single repository with many modules in it. If we need a module from such a repository, we can use the `:path =>` option here to help Librarian-puppet drill down and find the module subdirectory. mod "apt", :git => "git://github.com/fake/puppet-modules.git", :path => "modules/apt" Our puppet infrastructure repository depends on the `apt` module, which we have stored as a directory under our `puppet-modules` git repos. ## How to Use Install librarian-puppet: $ gem install librarian-puppet Prepare your puppet infrastructure repository: $ cd ~/path/to/puppet-inf-repos $ (git) rm -rf modules $ librarian-puppet init Librarian-puppet takes over your `modules/` directory, and will always reinstall (if missing) the modules listed the `Puppetfile.lock` into your `modules/` directory, therefore you do not need your `modules/` directory to be tracked in Git. Librarian-puppet uses a `.tmp/` directory for tempfiles and caches. You should not track this directory in Git. Running `librarian-puppet init` will create a skeleton Puppetfile for you as well as adding `tmp/` and `modules/` to your `.gitignore`. $ librarian-puppet install [--clean] [--verbose] This command looks at each `mod` declaration and fetches the module from the source specified. This command writes the complete resolution into `Puppetfile.lock` and then copies all of the fetched modules into your `modules/` directory, overwriting whatever was there before. Get an overview of your `Puppetfile.lock` with: $ librarian-puppet show Inspect the details of specific resolved dependencies with: $ librarian-puppet show NAME1 [NAME2, ...] Find out which dependencies are outdated and may be updated: $ librarian-puppet outdated [--verbose] Update the version of a dependency: $ librarian-puppet update apt [--verbose] $ git diff Puppetfile.lock $ git add Puppetfile.lock $ git commit -m "bumped the version of apt up to 0.0.4." ## How to Contribute * Pull requests please. * Bonus points for feature branches. ## Reporting Issues Bug reports to the github issue tracker please. Please include: * Relevant `Puppetfile` and `Puppetfile.lock` files * Version of ruby, librarian-puppet * What distro * Please run the `librarian-puppet` commands in verbose mode by using the `--verbose` flag, and include the verbose output in the bug report as well. ## Changelog ### 0.9.0 * Initial release ### 0.9.1 * Proper error message when a module that is sourced from the forge does not exist. * Added support for annotated tags as git references. * `librarian-puppet init` adds `.tmp/` to gitignore instead of `tmp/`. * Fixed syntax error in the template Puppetfile created by `librarian-puppet init`. * Checks for `lib/puppet` as well as `manifests/` when checking if the git repository is a valid module. * When a user specifies `/` as the name of a module sources from a git repository, assume the module name is actually ``. * Fixed gem description and summary in gemspec. ## License Please see the [LICENSE](https://github.com/rodjek/librarian-puppet/blob/master/LICENSE) file. librarian-puppet-0.9.10+dfsg.orig/LICENSE0000644000000000000000000000203612252267506016450 0ustar rootrootCopyright (c) 2012 Tim Sharpe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. librarian-puppet-0.9.10+dfsg.orig/metadata.yml0000644000000000000000000002102512252267506017745 0ustar rootroot--- !ruby/object:Gem::Specification name: librarian-puppet version: !ruby/object:Gem::Version version: 0.9.10 prerelease: platform: ruby authors: - Tim Sharpe autorequire: bindir: bin cert_chain: [] date: 2013-08-21 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: thor requirement: !ruby/object:Gem::Requirement none: false requirements: - - ~> - !ruby/object:Gem::Version version: '0.15' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ~> - !ruby/object:Gem::Version version: '0.15' - !ruby/object:Gem::Dependency name: json requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: cucumber requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: aruba requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: puppet requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' description: ! "Simplify deployment of your Puppet infrastructure by\n automatically pulling in modules from the forge and git repositories with\n a single command." email: - tim@sharpe.id.au executables: - librarian-puppet extensions: [] extra_rdoc_files: [] files: - .gitignore - LICENSE - README.md - bin/librarian-puppet - lib/librarian/puppet/cli.rb - lib/librarian/puppet/dsl.rb - lib/librarian/puppet/environment.rb - lib/librarian/puppet/extension.rb - lib/librarian/puppet/lockfile/parser.rb - lib/librarian/puppet/requirement.rb - lib/librarian/puppet/source/forge.rb - lib/librarian/puppet/source/git.rb - lib/librarian/puppet/source/githubtarball.rb - lib/librarian/puppet/source/local.rb - lib/librarian/puppet/source/path.rb - lib/librarian/puppet/source.rb - lib/librarian/puppet/templates/Puppetfile - lib/librarian/puppet/version.rb - lib/librarian/puppet.rb - vendor/librarian/bin/librarian-chef - vendor/librarian/bin/librarian-mock - vendor/librarian/CHANGELOG.md - vendor/librarian/config/cucumber.yaml - vendor/librarian/features/chef/cli/init.feature - vendor/librarian/features/chef/cli/install.feature - vendor/librarian/features/chef/cli/show.feature - vendor/librarian/features/chef/cli/version.feature - vendor/librarian/features/support/env.rb - vendor/librarian/Gemfile - vendor/librarian/lib/librarian/action/base.rb - vendor/librarian/lib/librarian/action/clean.rb - vendor/librarian/lib/librarian/action/ensure.rb - vendor/librarian/lib/librarian/action/install.rb - vendor/librarian/lib/librarian/action/resolve.rb - vendor/librarian/lib/librarian/action/update.rb - vendor/librarian/lib/librarian/action.rb - vendor/librarian/lib/librarian/chef/cli.rb - vendor/librarian/lib/librarian/chef/dsl.rb - vendor/librarian/lib/librarian/chef/environment.rb - vendor/librarian/lib/librarian/chef/extension.rb - vendor/librarian/lib/librarian/chef/integration/knife.rb - vendor/librarian/lib/librarian/chef/manifest_reader.rb - vendor/librarian/lib/librarian/chef/source/git.rb - vendor/librarian/lib/librarian/chef/source/local.rb - vendor/librarian/lib/librarian/chef/source/path.rb - vendor/librarian/lib/librarian/chef/source/site.rb - vendor/librarian/lib/librarian/chef/source.rb - vendor/librarian/lib/librarian/chef/templates/Cheffile - vendor/librarian/lib/librarian/chef.rb - vendor/librarian/lib/librarian/cli/manifest_presenter.rb - vendor/librarian/lib/librarian/cli.rb - vendor/librarian/lib/librarian/config/database.rb - vendor/librarian/lib/librarian/config/file_source.rb - vendor/librarian/lib/librarian/config/hash_source.rb - vendor/librarian/lib/librarian/config/source.rb - vendor/librarian/lib/librarian/config.rb - vendor/librarian/lib/librarian/dependency.rb - vendor/librarian/lib/librarian/dsl/receiver.rb - vendor/librarian/lib/librarian/dsl/target.rb - vendor/librarian/lib/librarian/dsl.rb - vendor/librarian/lib/librarian/environment.rb - vendor/librarian/lib/librarian/error.rb - vendor/librarian/lib/librarian/helpers.rb - vendor/librarian/lib/librarian/lockfile/compiler.rb - vendor/librarian/lib/librarian/lockfile/parser.rb - vendor/librarian/lib/librarian/lockfile.rb - vendor/librarian/lib/librarian/logger.rb - vendor/librarian/lib/librarian/manifest.rb - vendor/librarian/lib/librarian/manifest_set.rb - vendor/librarian/lib/librarian/mock/cli.rb - vendor/librarian/lib/librarian/mock/dsl.rb - vendor/librarian/lib/librarian/mock/environment.rb - vendor/librarian/lib/librarian/mock/extension.rb - vendor/librarian/lib/librarian/mock/source/mock/registry.rb - vendor/librarian/lib/librarian/mock/source/mock.rb - vendor/librarian/lib/librarian/mock/source.rb - vendor/librarian/lib/librarian/mock.rb - vendor/librarian/lib/librarian/resolution.rb - vendor/librarian/lib/librarian/resolver/implementation.rb - vendor/librarian/lib/librarian/resolver.rb - vendor/librarian/lib/librarian/source/git/repository.rb - vendor/librarian/lib/librarian/source/git.rb - vendor/librarian/lib/librarian/source/local.rb - vendor/librarian/lib/librarian/source/path.rb - vendor/librarian/lib/librarian/source.rb - vendor/librarian/lib/librarian/spec.rb - vendor/librarian/lib/librarian/spec_change_set.rb - vendor/librarian/lib/librarian/specfile.rb - vendor/librarian/lib/librarian/support/abstract_method.rb - vendor/librarian/lib/librarian/ui.rb - vendor/librarian/lib/librarian/version.rb - vendor/librarian/lib/librarian.rb - vendor/librarian/librarian.gemspec - vendor/librarian/MIT-LICENSE - vendor/librarian/Rakefile - vendor/librarian/README.md - vendor/librarian/spec/functional/chef/source/git_spec.rb - vendor/librarian/spec/functional/chef/source/site_spec.rb - vendor/librarian/spec/functional/source/git/repository_spec.rb - vendor/librarian/spec/unit/action/base_spec.rb - vendor/librarian/spec/unit/action/clean_spec.rb - vendor/librarian/spec/unit/action/ensure_spec.rb - vendor/librarian/spec/unit/action/install_spec.rb - vendor/librarian/spec/unit/config/database_spec.rb - vendor/librarian/spec/unit/dependency_spec.rb - vendor/librarian/spec/unit/dsl_spec.rb - vendor/librarian/spec/unit/environment_spec.rb - vendor/librarian/spec/unit/lockfile/parser_spec.rb - vendor/librarian/spec/unit/lockfile_spec.rb - vendor/librarian/spec/unit/manifest_set_spec.rb - vendor/librarian/spec/unit/manifest_spec.rb - vendor/librarian/spec/unit/manifest_version_spec.rb - vendor/librarian/spec/unit/mock/source/mock_spec.rb - vendor/librarian/spec/unit/resolver_spec.rb - vendor/librarian/spec/unit/source/git_spec.rb - vendor/librarian/spec/unit/spec_change_set_spec.rb homepage: https://github.com/rodjek/librarian-puppet licenses: [] post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 1.8.23 signing_key: specification_version: 3 summary: Bundler for your Puppet modules test_files: [] librarian-puppet-0.9.10+dfsg.orig/lib/0000755000000000000000000000000012252267506016210 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/lib/librarian/0000755000000000000000000000000012252267506020153 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet.rb0000644000000000000000000000064112252267506022016 0ustar rootrootrequire 'librarian' require 'fileutils' begin require 'puppet' rescue LoadError $stderr.puts <<-EOF Unable to load puppet. Either install it using native packages for your platform (eg .deb, .rpm, .dmg, etc) or as a gem (gem install puppet). EOF exit 1 end require 'librarian/puppet/extension' require 'librarian/puppet/version' require 'librarian/action/install' module Librarian module Puppet end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/0000755000000000000000000000000012252267506021470 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/dsl.rb0000644000000000000000000000050412252267506022576 0ustar rootrootrequire 'librarian/dsl' require 'librarian/puppet/source' module Librarian module Puppet class Dsl < Librarian::Dsl dependency :mod source :forge => Source::Forge source :git => Source::Git source :path => Source::Path source :github_tarball => Source::GitHubTarball end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/lockfile/0000755000000000000000000000000012252267506023260 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/lockfile/parser.rb0000644000000000000000000000361712252267506025110 0ustar rootrootrequire 'librarian/manifest' require 'librarian/dependency' require 'librarian/manifest_set' module Librarian class Lockfile class Parser def parse(string) string = string.dup source_type_names_map = Hash[dsl_class.source_types.map{|t| [t[1].lock_name, t[1]]}] source_type_names = dsl_class.source_types.map{|t| t[1].lock_name} lines = string.split(/(\r|\n|\r\n)+/).select{|l| l =~ /\S/} sources = [] while source_type_names.include?(lines.first) source = {} source_type_name = lines.shift source[:type] = source_type_names_map[source_type_name] options = {} while lines.first =~ /^ {2}([\w\-\/]+):\s+(.+)$/ lines.shift options[$1.to_sym] = $2 end source[:options] = options lines.shift # specs manifests = {} while lines.first =~ /^ {4}([\w\-\/]+) \((.*)\)$/ # This change allows forward slash lines.shift name = $1 manifests[name] = {:version => $2, :dependencies => {}} while lines.first =~ /^ {6}([\w\-\/]+) \((.*)\)$/ lines.shift manifests[name][:dependencies][$1] = $2.split(/,\s*/) end end source[:manifests] = manifests sources << source end manifests = compile(sources) manifests_index = Hash[manifests.map{|m| [m.name, m]}] raise StandardError, "Expected DEPENDENCIES topic!" unless lines.shift == "DEPENDENCIES" dependencies = [] while lines.first =~ /^ {2}([\w\-\/]+)(?: \((.*)\))?$/ # This change allows forward slash lines.shift name, requirement = $1, $2.split(/,\s*/) dependencies << Dependency.new(name, requirement, manifests_index[name].source) end Resolution.new(dependencies, manifests) end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/extension.rb0000644000000000000000000000017112252267506024030 0ustar rootrootrequire 'librarian/puppet/environment' module Librarian module Puppet extend self extend Librarian end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/environment.rb0000644000000000000000000000203012252267506024354 0ustar rootrootrequire "librarian/environment" require "librarian/puppet/dsl" require "librarian/puppet/source" require "librarian/puppet/lockfile/parser" module Librarian module Puppet class Environment < Librarian::Environment def adapter_name "puppet" end def install_path part = config_db["path"] || "modules" project_path.join(part) end def vendor_path project_path.join('vendor/puppet') end def vendor_cache vendor_path.join('cache') end def vendor_source vendor_path.join('source') end def cache_path project_path.join(".tmp/librarian/cache") end def scratch_path project_path.join(".tmp/librarian/scratch") end def vendor! vendor_cache.mkpath unless vendor_cache.exist? vendor_source.mkpath unless vendor_source.exist? end def vendor? vendor_path.exist? end def local? config_db['mode'] == 'local' end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/requirement.rb0000644000000000000000000000126212252267506024356 0ustar rootrootmodule Librarian module Puppet class Requirement attr_reader :requirement def initialize(requirement) @requirement = requirement end def gem_requirement if range_requirement? [@range_match[1], @range_match[2]] elsif pessimistic_requirement? "~> #{@pessimistic_match[1]}" else requirement end end private def range_requirement? @range_match ||= requirement.match(/(>=? ?\d+(?:\.\d+){0,2}) (<=? ?\d+(?:\.\d+){0,2})/) end def pessimistic_requirement? @pessimistic_match ||= requirement.match(/(\d+(?:\.\d+)?)\.x/) end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/source/0000755000000000000000000000000012252267506022770 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/source/forge.rb0000644000000000000000000001732312252267506024425 0ustar rootrootrequire 'uri' require 'net/http' require 'json' module Librarian module Puppet module Source class Forge class Repo attr_accessor :source, :name private :source=, :name= def initialize(source, name) self.source = source self.name = name end def versions data = api_call("#{name}.json") if data.nil? raise Error, "Unable to find module '#{name}' on #{source}" end data['releases'].map { |r| r['version'] }.sort.reverse end def dependencies(version) data = api_call("api/v1/releases.json?module=#{name}&version=#{version}") data[name].first['dependencies'] end def manifests versions.map do |version| Manifest.new(source, name, version) end end def install_version!(version, install_path) if environment.local? && !vendored?(name, version) raise Error, "Could not find a local copy of #{name} at #{version}." end if environment.vendor? vendor_cache(name, version) unless vendored?(name, version) end cache_version_unpacked! version if install_path.exist? install_path.rmtree end unpacked_path = version_unpacked_cache_path(version).join(name.split('/').last) unless unpacked_path.exist? raise Error, "#{unpacked_path} does not exist, something went wrong. Try removing it manually" else FileUtils.cp_r(unpacked_path, install_path) end end def environment source.environment end def cache_path @cache_path ||= source.cache_path.join(name) end def version_unpacked_cache_path(version) cache_path.join('version').join(hexdigest(version.to_s)) end def hexdigest(value) Digest::MD5.hexdigest(value) end def cache_version_unpacked!(version) path = version_unpacked_cache_path(version) return if path.directory? # The puppet module command is only available from puppet versions >= 2.7.13 # # Specifying the version in the gemspec would force people to upgrade puppet while it's still usable for git # So we do some more clever checking # # Executing older versions or via puppet-module tool gives an exit status = 0 . # check_puppet_module_options path.mkpath target = vendored?(name, version) ? vendored_path(name, version) : name command = "puppet module install --target-dir '#{path}' --module_repository '#{source}' --modulepath '#{path}' --ignore-dependencies '#{target}'" output = `#{command}` # Check for bad exit code unless $? == 0 # Rollback the directory if the puppet module had an error path.unlink raise Error, "Error executing puppet module install:\n#{command}\nError:\n#{output}" end end def check_puppet_module_options min_version = Gem::Version.create('2.7.13') puppet_version = Gem::Version.create(`puppet --version`.split(' ').first.strip.gsub('-', '.')) if puppet_version < min_version raise Error, "To get modules from the forge, we use the puppet faces module command. For this you need at least puppet version 2.7.13 and you have #{puppet_version}" end end def vendored?(name, version) vendored_path(name, version).exist? end def vendored_path(name, version) environment.vendor_cache.join("#{name.sub("/", "-")}-#{version}.tar.gz") end def vendor_cache(name, version) File.open(vendored_path(name, version).to_s, 'w') do |f| download(name, version) do |data| f << data end end end def download(name, version, &block) data = api_call("api/v1/releases.json?module=#{name}&version=#{version}") info = data[name].detect {|h| h['version'] == version.to_s } stream(info['file'], &block) end def stream(file, &block) Net::HTTP.get_response(URI.parse("#{source}#{file}")) do |res| res.code res.read_body(&block) end end private def api_call(path) base_url = source.to_s resp = Net::HTTP.get_response(URI.parse("#{base_url}/#{path}")) if resp.code.to_i != 200 nil else data = resp.body JSON.parse(data) end end end class << self LOCK_NAME = 'FORGE' def lock_name LOCK_NAME end def from_lock_options(environment, options) new(environment, options[:remote], options.reject { |k, v| k == :remote }) end def from_spec_args(environment, uri, options) recognised_options = [] unrecognised_options = options.keys - recognised_options unless unrecognised_options.empty? raise Error, "unrecognised options: #{unrecognised_options.join(", ")}" end new(environment, uri, options) end end attr_accessor :environment private :environment= attr_reader :uri def initialize(environment, uri, options = {}) self.environment = environment @uri = uri @cache_path = nil end def to_s uri end def ==(other) other && self.class == other.class && self.uri == other.uri end alias :eql? :== def hash self.to_s.hash end def to_spec_args [uri, {}] end def to_lock_options {:remote => uri} end def pinned? false end def unpin! end def install!(manifest) manifest.source == self or raise ArgumentError name = manifest.name version = manifest.version install_path = install_path(name) repo = repo(name) repo.install_version! version, install_path end def manifest(name, version, dependencies) manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end def cache_path @cache_path ||= begin dir = Digest::MD5.hexdigest(uri) environment.cache_path.join("source/puppet/forge/#{dir}") end end def install_path(name) environment.install_path.join(name.split('/').last) end def fetch_version(name, version_uri) versions = repo(name).versions if versions.include? version_uri version_uri else versions.first end end def fetch_dependencies(name, version, version_uri) repo(name).dependencies(version).map do |k, v| v = Requirement.new(v).gem_requirement Dependency.new(k, v, nil) end end def manifests(name) repo(name).manifests end private def repo(name) @repo ||= {} @repo[name] ||= Repo.new(self, name) end end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/source/local.rb0000644000000000000000000000275512252267506024420 0ustar rootrootmodule Librarian module Puppet module Source module Local def install!(manifest) manifest.source == self or raise ArgumentError debug { "Installing #{manifest}" } name, version = manifest.name, manifest.version found_path = found_path(name) if name.include? '/' new_name = name.split('/').last debug { "Invalid module name '#{name}', guessing you meant '#{new_name}'" } name = new_name end install_path = environment.install_path.join(name) if install_path.exist? debug { "Deleting #{relative_path_to(install_path)}" } install_path.rmtree end install_perform_step_copy!(found_path, install_path) end def fetch_version(name, extra) cache! found_path = found_path(name) '0.0.1' end def fetch_dependencies(name, version, extra) {} end private def install_perform_step_copy!(found_path, install_path) debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" } FileUtils.cp_r(found_path, install_path) end def manifest?(name, path) return true if path.join('manifests').exist? return true if path.join('lib').join('puppet').exist? return true if path.join('lib').join('facter').exist? false end end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/source/path.rb0000644000000000000000000000033112252267506024246 0ustar rootrootrequire 'librarian/source/path' require 'librarian/puppet/source/local' module Librarian module Puppet module Source class Path < Librarian::Source::Path include Local end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/source/githubtarball.rb0000644000000000000000000001557612252267506026157 0ustar rootrootrequire 'uri' require 'net/https' require 'json' require 'librarian/puppet/version' module Librarian module Puppet module Source class GitHubTarball class Repo attr_accessor :source, :name private :source=, :name= def initialize(source, name) self.source = source self.name = name end def versions data = api_call("/repos/#{source.uri}/tags") if data.nil? raise Error, "Unable to find module '#{source.uri}' on https://github.com" end all_versions = data.map { |r| r['name'] }.sort.reverse all_versions = all_versions.map do |version| version.gsub(/^v/, '') end all_versions.delete_if do |version| version !~ /\A\d\.\d(\.\d.*)?\z/ end all_versions.compact end def manifests versions.map do |version| Manifest.new(source, name, version) end end def install_version!(version, install_path) if environment.local? && !vendored?(source.uri, version) raise Error, "Could not find a local copy of #{source.uri} at #{version}." end vendor_cache(source.uri, version) unless vendored?(source.uri, version) cache_version_unpacked! version if install_path.exist? install_path.rmtree end unpacked_path = version_unpacked_cache_path(version).children.first FileUtils.cp_r(unpacked_path, install_path) end def environment source.environment end def cache_path @cache_path ||= source.cache_path.join(name) end def version_unpacked_cache_path(version) cache_path.join('version').join(hexdigest(version.to_s)) end def hexdigest(value) Digest::MD5.hexdigest(value) end def cache_version_unpacked!(version) path = version_unpacked_cache_path(version) return if path.directory? path.mkpath target = vendored?(source.uri, version) ? vendored_path(source.uri, version) : name `tar xzf #{target} -C #{path}` end def vendored?(name, version) vendored_path(name, version).exist? end def vendored_path(name, version) environment.vendor_cache.mkpath environment.vendor_cache.join("#{name.sub("/", "-")}-#{version}.tar.gz") end def vendor_cache(name, version) clean_up_old_cached_versions(name) url = "https://api.github.com/repos/#{name}/tarball/#{version}" url << "?access_token=#{ENV['GITHUB_API_TOKEN']}" if ENV['GITHUB_API_TOKEN'] `curl #{url} -o #{vendored_path(name, version).to_s} -L 2>&1` end def clean_up_old_cached_versions(name) Dir["#{environment.vendor_cache}/#{name.sub('/', '-')}*.tar.gz"].each do |old_version| FileUtils.rm old_version end end private def api_call(path) url = "https://api.github.com#{path}" url << "?access_token=#{ENV['GITHUB_API_TOKEN']}" if ENV['GITHUB_API_TOKEN'] uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri.request_uri) request.add_field "User-Agent", "librarian-puppet v#{Librarian::Puppet::VERSION}" resp = http.request(request) data = resp.body if resp.code.to_i == 403 begin message = JSON.parse(data)['message'] if message.include? 'API rate limit exceeded' raise Error, message end rescue JSON::ParserError # 403 response does not return json, skip. end elsif resp.code.to_i != 200 nil else JSON.parse(data) end end end class << self LOCK_NAME = 'GITHUBTARBALL' def lock_name LOCK_NAME end def from_lock_options(environment, options) new(environment, options[:remote], options.reject { |k, v| k == :remote }) end def from_spec_args(environment, uri, options) recognised_options = [] unrecognised_options = options.keys - recognised_options unless unrecognised_options.empty? raise Error, "unrecognised options: #{unrecognised_options.join(", ")}" end new(environment, uri, options) end end attr_accessor :environment private :environment= attr_reader :uri def initialize(environment, uri, options = {}) self.environment = environment @uri = uri @cache_path = nil end def to_s uri end def ==(other) other && self.class == other.class && self.uri == other.uri end alias :eql? :== def hash self.to_s.hash end def to_spec_args [uri, {}] end def to_lock_options {:remote => uri} end def pinned? false end def unpin! end def install!(manifest) manifest.source == self or raise ArgumentError name = manifest.name version = manifest.version install_path = install_path(name) repo = repo(name) repo.install_version! version, install_path end def manifest(name, version, dependencies) manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end def cache_path @cache_path ||= begin dir = Digest::MD5.hexdigest(uri) environment.cache_path.join("source/puppet/githubtarball/#{dir}") end end def install_path(name) environment.install_path.join(name.split('/').last) end def fetch_version(name, version_uri) versions = repo(name).versions if versions.include? version_uri version_uri else versions.first end end def fetch_dependencies(name, version, version_uri) {} end def manifests(name) repo(name).manifests end private def repo(name) @repo ||= {} @repo[name] ||= Repo.new(self, name) end end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/source/git.rb0000644000000000000000000000557212252267506024111 0ustar rootrootrequire 'librarian/source/git' require 'librarian/puppet/source/local' module Librarian module Source class Git class Repository def hash_from(remote, reference) branch_names = remote_branch_names[remote] if branch_names.include?(reference) reference = "#{remote}/#{reference}" end command = %W(rev-parse #{reference}^{commit} --quiet) run!(command, :chdir => true).strip end # Naming this method 'version' causes an exception to be raised. def module_version return '0.0.1' unless modulefile? metadata = ::Puppet::ModuleTool::Metadata.new ::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile) metadata.version end def dependencies return {} unless modulefile? metadata = ::Puppet::ModuleTool::Metadata.new ::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile) metadata.dependencies.inject({}) do |h, dependency| name = dependency.instance_variable_get(:@full_module_name) version = dependency.instance_variable_get(:@version_requirement) h.update(name => version) end end def modulefile File.join(path, 'Modulefile') end def modulefile? File.exists?(modulefile) end end end end module Puppet module Source class Git < Librarian::Source::Git include Local def cache! return vendor_checkout! if vendor_cached? if environment.local? raise Error, "Could not find a local copy of #{uri} at #{sha}." end super cache_in_vendor(repository.path) if environment.vendor? end def vendor_tgz environment.vendor_source + "#{sha}.tar.gz" end def vendor_cached? vendor_tgz.exist? end def vendor_checkout! repository.path.rmtree if repository.path.exist? repository.path.mkpath Dir.chdir(repository.path.to_s) do %x{tar xzf #{vendor_tgz}} end repository_cached! end def cache_in_vendor(tmp_path) Dir.chdir(tmp_path.to_s) do %x{git archive #{sha} | gzip > #{vendor_tgz}} end end def fetch_version(name, extra) cache! found_path = found_path(name) repository.module_version end def fetch_dependencies(name, version, extra) repository.dependencies.map do |k, v| v = Requirement.new(v).gem_requirement Dependency.new(k, v, forge_source) end end def forge_source Forge.from_lock_options(environment, :remote=>"http://forge.puppetlabs.com") end end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/version.rb0000644000000000000000000000010212252267506023473 0ustar rootrootmodule Librarian module Puppet VERSION = "0.9.10" end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/cli.rb0000644000000000000000000000512512252267506022567 0ustar rootrootrequire 'librarian/helpers' require 'librarian/cli' require 'librarian/puppet' module Librarian module Puppet class Cli < Librarian::Cli module Particularity def root_module Puppet end end include Particularity extend Particularity source_root Pathname.new(__FILE__).dirname.join("templates") def init copy_file environment.specfile_name if File.exists? ".gitignore" gitignore = File.read('.gitignore').split("\n") else gitignore = [] end gitignore << ".tmp/" unless gitignore.include? ".tmp/" gitignore << "modules/" unless gitignore.include? "modules/" File.open(".gitignore", 'w') do |f| f.puts gitignore.join("\n") end end desc "install", "Resolves and installs all of the dependencies you specify." option "quiet", :type => :boolean, :default => false option "verbose", :type => :boolean, :default => false option "line-numbers", :type => :boolean, :default => false option "clean", :type => :boolean, :default => false option "strip-dot-git", :type => :boolean option "path", :type => :string option "destructive", :type => :boolean, :default => false option "local", :type => :boolean, :default => false def install ensure! clean! if options["clean"] unless options["destructive"].nil? environment.config_db.local['destructive'] = options['destructive'].to_s end if options.include?("strip-dot-git") strip_dot_git_val = options["strip-dot-git"] ? "1" : nil environment.config_db.local["install.strip-dot-git"] = strip_dot_git_val end if options.include?("path") environment.config_db.local["path"] = options["path"] end environment.config_db.local['mode'] = options['local'] ? 'local' : nil resolve! install! end desc "package", "Cache the puppet modules in vendor/puppet/cache." option "quiet", :type => :boolean, :default => false option "verbose", :type => :boolean, :default => false option "line-numbers", :type => :boolean, :default => false option "clean", :type => :boolean, :default => false option "strip-dot-git", :type => :boolean option "path", :type => :string option "destructive", :type => :boolean, :default => false def package environment.vendor! install end def version say "librarian-puppet v#{Librarian::Puppet::VERSION}" end end end end librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/templates/0000755000000000000000000000000012252267506023466 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/templates/Puppetfile0000644000000000000000000000040312252267506025523 0ustar rootrootforge "http://forge.puppetlabs.com" # mod 'puppetlabs/stdlib' # mod 'ntp', # :git => 'git://github.com/puppetlabs/puppetlabs-ntp.git' # mod 'apt', # :git => 'https://github.com/puppetlabs/puppetlabs-apt.git', # :ref => 'feature/master/dans_refactor' librarian-puppet-0.9.10+dfsg.orig/lib/librarian/puppet/source.rb0000644000000000000000000000031412252267506023313 0ustar rootrootrequire 'librarian/puppet/requirement' require 'librarian/puppet/source/path' require 'librarian/puppet/source/git' require 'librarian/puppet/source/forge' require 'librarian/puppet/source/githubtarball' librarian-puppet-0.9.10+dfsg.orig/vendor/0000755000000000000000000000000012253024160016723 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/bin/0000755000000000000000000000000012252267506016212 5ustar rootrootlibrarian-puppet-0.9.10+dfsg.orig/bin/librarian-puppet0000755000000000000000000000042712252267506021421 0ustar rootroot#!/usr/bin/env ruby lib = File.expand_path('../../lib', __FILE__) vendor = File.expand_path('../../vendor/librarian/lib', __FILE__) $:.unshift(lib) unless $:.include?(lib) $:.unshift(vendor) unless $:.include?(vendor) require 'librarian/puppet/cli' Librarian::Puppet::Cli.bin!