Class: Autobuild::CVSImporter

Inherits:
Importer
  • Object
show all
Defined in:
lib/autobuild/import/cvs.rb

Instance Attribute Summary collapse

Attributes inherited from Importer

#interactive, #options, #post_hooks, #repository_id, #source_id

Instance Method Summary collapse

Methods inherited from Importer

#add_post_hook, add_post_hook, #apply, cache_dirs, #call_patch, #currently_applied_patches, default_cache_dirs, default_cache_dirs=, each_post_hook, #each_post_hook, #execute_post_hooks, fallback, #fallback, #fingerprint, #import, #interactive?, #parse_patch_list, #patch, #patchdir, #patches, #patches_fingerprint, #patchlist, #perform_checkout, #perform_update, #retry_count, #retry_count=, #save_patch_state, set_cache_dirs, #supports_relocation?, #unapply, unset_cache_dirs, #update_retry_count, #vcs_fingerprint

Constructor Details

#initialize(root_name, options = {}) ⇒ CVSImporter

Creates a new importer which gets the module name from the repository in root. The following values are allowed in options:

:cvsup

options to give to ‘cvs up’. Default: -dP.

:cvsco

options to give to ‘cvs co’. Default: -P.

This importer uses the ‘cvs’ tool to perform the import. It defaults to ‘cvs’ and can be configured by doing

Autobuild.programs['cvs'] = 'my_cvs_tool'

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/autobuild/import/cvs.rb', line 11

def initialize(root_name, options = {})
    cvsopts, common = Kernel.filter_options options,
                                            module: nil, cvsup: '-dP', cvsco: '-P'
    @root   = root_name
    @module = cvsopts[:module]
    raise ArgumentError, "no module given" unless @module

    @options_up = cvsopts[:cvsup] || '-dP'
    @options_up = Array[*@options_up]
    @options_co = cvsopts[:cvsco] || '-P'
    @options_co = Array[*@options_co]
    super(common.merge(repository_id: "cvs:#{@root}:#{@module}"))
end

Instance Attribute Details

#options_coObject (readonly)

Array of options to give to ‘cvs checkout’



26
27
28
# File 'lib/autobuild/import/cvs.rb', line 26

def options_co
  @options_co
end

#options_upObject (readonly)

Array of options to give to ‘cvs update’



28
29
30
# File 'lib/autobuild/import/cvs.rb', line 28

def options_up
  @options_up
end

Instance Method Details

#checkout(package, _options = Hash.new) ⇒ Object

:nodoc:



69
70
71
72
73
74
75
76
77
# File 'lib/autobuild/import/cvs.rb', line 69

def checkout(package, _options = Hash.new) # :nodoc:
    head, tail = File.split(package.srcdir)
    cvsroot = @root

    FileUtils.mkdir_p(head) unless File.directory?(head)
    package.run(:import, Autobuild.tool(:cvs), '-d', cvsroot, 'co',
                '-d', tail, *@options_co, modulename,
                retry: true, working_directory: head)
end

#modulenameObject

Returns the module to get



31
32
33
# File 'lib/autobuild/import/cvs.rb', line 31

def modulename
    @module
end

#update(package, options = Hash.new) ⇒ Object

:nodoc:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/autobuild/import/cvs.rb', line 35

def update(package, options = Hash.new) # :nodoc:
    if options[:only_local]
        package.warn "%s: the CVS importer does not support "\
            "local updates, skipping"
        return false
    end

    unless File.exist?("#{package.srcdir}/CVS/Root")
        raise ConfigException.new(package, 'import'),
              "#{package.srcdir} is not a CVS working copy"
    end

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

    # Remove any :ext: in front of the root
    root = root.gsub(/^:ext:/, '')
    expected_root = @root.gsub(/^:ext:/, '')
    # Remove the optional ':' between the host and the path
    root = root.delete(':')
    expected_root = expected_root.delete(':')

    if root != expected_root || mod != @module
        raise ConfigException.new(package, 'import'),
              "checkout in #{package.srcdir} is from #{root}:#{mod}, "\
              "was expecting #{expected_root}:#{@module}"
    end
    package.run(:import, Autobuild.tool(:cvs), 'up', *@options_up,
                retry: true, working_directory: package.importdir)
    # no easy way to check if package was updated, keep previous
    # behavior and consider updated
    true
end