Class: Litbuild::SourceCodeManager
- Inherits:
-
Object
- Object
- Litbuild::SourceCodeManager
- Defined in:
- lib/litbuild/source_code_manager.rb
Overview
Find all of the tar files and patch files, possibly compressed, present in any of the directories passed to the constructor or any direct subdirectories of those directories. Given a package blueprint, provide suitable commands to unpack tar files and in-tree source tarfiles, apply patch files, or copy those files to a package user home directory.
Note, SourceCodeManager does not recurse into additional levels of subdirectories – it turns out that makes the test suite really slow.
Instance Method Summary collapse
-
#copy_source_files_commands(package) ⇒ Object
Package Users expect to have tarfiles for the top-level package and any in-tree packages in their ‘src` directory, and patches in their `patches` directory.
-
#initialize(*dirs) ⇒ SourceCodeManager
constructor
A new instance of SourceCodeManager.
- #intree_untar_commands_for(package) ⇒ Object
- #patch_commands_for(package) ⇒ Object
- #untar_command_for(package) ⇒ Object
Constructor Details
#initialize(*dirs) ⇒ SourceCodeManager
Returns a new instance of SourceCodeManager.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/litbuild/source_code_manager.rb', line 18 def initialize(*dirs) all_pkgfiles = dirs.map do |d| Dir.glob("#{d}/*.tar*") + Dir.glob("#{d}/*/*.tar*") + Dir.glob("#{d}/*.patch*") + Dir.glob("#{d}/*/*.patch*") end.flatten abs_paths = all_pkgfiles.map { |f| File.(f) } @available_files = abs_paths.sort.uniq end |
Instance Method Details
#copy_source_files_commands(package) ⇒ Object
Package Users expect to have tarfiles for the top-level package and any in-tree packages in their ‘src` directory, and patches in their `patches` directory. This produces commands that copy needed files from the TARFILE_DIR and PATCH_DIR to those directories, if not already present there.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/litbuild/source_code_manager.rb', line 63 def copy_source_files_commands(package) pkgusr = pkgusr_name(package) mkdir_commands = %w[src patches].map do |dir| "mkdir -p ~#{pkgusr}/#{dir}" end copy_commands = [] package.tar_files_needed.each do |filename| pkgusr_file_available?(package, filename) || (copy_commands << "cp #{find_tarfile(filename)} ~#{pkgusr}/src") end package.patch_files.each do |filename| pkgusr_file_available?(package, filename) || (copy_commands << "cp #{find_file(filename)} ~#{pkgusr}/patches") end mkdir_commands + copy_commands.sort end |
#intree_untar_commands_for(package) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/litbuild/source_code_manager.rb', line 33 def intree_untar_commands_for(package) commands = [] package.in_tree.each do |basename, version, path| intree = "#{basename}-#{version}" commands << unpack_tar(intree) if path commands << "mkdir -p #{File.dirname(path)}" commands << "mv #{intree} #{path}" else commands << "mv #{intree} #{basename}" end end commands end |
#patch_commands_for(package) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/litbuild/source_code_manager.rb', line 48 def patch_commands_for(package) return [] unless package.patch_files package.patch_files.map do |patch_file| full_fn = find_file(patch_file) "#{decompress_command(full_fn)} < #{full_fn} | patch -p1" end end |
#untar_command_for(package) ⇒ Object
29 30 31 |
# File 'lib/litbuild/source_code_manager.rb', line 29 def untar_command_for(package) unpack_tar(package.name_and_version) end |