Module: Melai::PackageHelpers
- Defined in:
- lib/melai/package_helpers.rb
Overview
This module provides some package helper methods
Instance Method Summary collapse
-
#package_metadata(package_path, repositories_path) ⇒ Object
Return an array of package metadata hashes.
- #repo_template(metadata, repositories_path, url_root) ⇒ Object
- #update_repo_metadata(metadata, repositories_path, packages_path) ⇒ Object
Instance Method Details
#package_metadata(package_path, repositories_path) ⇒ Object
Return an array of package metadata hashes. Each array element describes a particular repository that this package should be a member of.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/melai/package_helpers.rb', line 15 def (package_path, repositories_path) case File.extname(package_path) when '.rpm' return (package_path, repositories_path) when '.deb' if File.fnmatch('*ubuntu*', package_path) return (package_path, repositories_path) else File.fnmatch('*debian*', package_path) return (package_path, repositories_path) end end end |
#repo_template(metadata, repositories_path, url_root) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/melai/package_helpers.rb', line 28 def repo_template(, repositories_path, url_root) repository_path = [:repository_path] case repository_path when /redhat/ source = "redhat.repo.erb" target = "10gen.repo" url_path = File.join([:repository_prefix], [:variant], [:arch]) else source = "debian.list.erb" target = "10gen.list" url_path = File.join([:repository_prefix]) end here = File.dirname(__FILE__) template = ERB.new(File.read(File.join(here, "..", "..", "templates", source))) output = File.new(File.join(repository_path, target), "w") output.write(template.result(binding)) end |
#update_repo_metadata(metadata, repositories_path, packages_path) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/melai/package_helpers.rb', line 47 def (, repositories_path, packages_path) repository_path = [:repository_path] # e.g /data/packages/cache/debian-sysvinit/dists/ cache_path = File.join(packages_path, "cache", [:repository_prefix]) ensure_directory(cache_path) case repository_path when /redhat/ begin # e.g. repo/redhat/2.0/x86_64/ variant_dir = File.join(repositories_path, [:repository_prefix], [:variant], [:arch]) shell_out("createrepo --pretty -c #{cache_path} #{variant_dir}") rescue Exception=>e exit_now!("Could not complete createrepo:\n#{e}", 1) end else # Do Debian-style repo builds here = File.dirname(__FILE__) fileloc = File.join(here, "../..", "templates", "apt-ftparchive.conf.erb") template = ERB.new(File.read(fileloc)) output = Tempfile.new("apt-ftparchive.conf") output.write(template.result(binding)) output.close() begin # Generates the Packages, Contents files shell_out("apt-ftparchive generate #{output.path}") # Generate the Release files on stdout variant_dir = File.join(repositories_path, [:repository_prefix], "dists", [:variant]) result = shell_out("apt-ftparchive -c #{output.path} release #{variant_dir}") # Dump the Release stdout to a Release file release_file = File.join(variant_dir, "Release.new") File.open(release_file, "w").write(result.stdout) # This ensures that the Release file is not included within itself File.rename(release_file, File.join(variant_dir, "Release")) # TODO: GPG Sign the Release file rescue Exception=>e exit_now!("Could not complete apt-ftparchive:\n#{e}", 1) end end end |