Sha256: 4f7a5188e932c0ac9a87c0724f8fc9a0a02ea92784ca9d38d3d95f92394a1ec5

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require 'autobuild/config'
require 'autobuild/subcommand'
require 'autobuild/importer'

module Autobuild
    class CVSImporter < Importer
        def initialize(root, name, options = {})
            @root = root
            @module = name

            @program    = Autobuild.tool('cvs')
            @options_up = options[:cvsup] || '-dP'
            @options_up = Array[*@options_up]
            @options_co = options[:cvsco] || '-P'
            @options_co = Array[*@options_co]
            super(options)
        end
        
        def modulename
            @module
        end

        private

        def update(package)
            Dir.chdir(package.srcdir) do
		if !File.exists?("#{package.srcdir}/CVS/Root")
		    raise ConfigException, "#{package.srcdir} is not a CVS working copy"
		end

		root = File.open("#{package.srcdir}/CVS/Root") { |io| io.read }.chomp
		mod  = File.open("#{package.srcdir}/CVS/Repository") { |io| io.read }.chomp

		if root != @root || mod != @module
		    raise ConfigException, "checkout in #{package.srcdir} is from #{root}:#{mod}, was expecting #{@root}:#{@module}"
		end
                Subprocess.run(package.name, :import, @program, 'up', *@options_up)
	    end
        end

        def checkout(package)
            head, tail = File.split(package.srcdir)
            cvsroot = @root
               
            FileUtils.mkdir_p(head) if !File.directory?(head)
            Dir.chdir(head) {
                options = [ @program, '-d', cvsroot, 'co', '-d', tail ] + @options_co + [ modulename ]
                Subprocess.run(package.name, :import, *options)
            }
        end
    end

    def self.cvs(repo, name, package_options = {})
        CVSImporter.new(repo, name, package_options)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
autobuild-0.6.4 lib/autobuild/import/cvs.rb