aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-18 00:31:22 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-18 00:31:22 +0000
commit58e0c2ec461df2c08b38a2da771e5640a9dd554a (patch)
tree191d22bdbb951c7a4df0e16b8a4956cb6f9711de
parent67803aefac935c4c06546a70908c1a93fafb73d7 (diff)
downloadpaludis-58e0c2ec461df2c08b38a2da771e5640a9dd554a.tar.gz
paludis-58e0c2ec461df2c08b38a2da771e5640a9dd554a.tar.xz
Add config template support to playman.
-rwxr-xr-xruby/demos/playman.rb77
1 files changed, 50 insertions, 27 deletions
diff --git a/ruby/demos/playman.rb b/ruby/demos/playman.rb
index 6048f53..aeda0b1 100755
--- a/ruby/demos/playman.rb
+++ b/ruby/demos/playman.rb
@@ -30,7 +30,7 @@ include Paludis
Log.instance.log_level = LogLevel::Warning
Log.instance.program_name = $0
-version = "0.1.4"
+version = "0.1.5"
laymanglobal_url = URI.parse('http://www.gentoo.org/proj/en/overlays/layman-global.txt')
opts = GetoptLong.new(
@@ -72,6 +72,11 @@ Options:
Manages paludis configuration for layman overlays. Can add new overlays, and
list the currently available overlays from the global layman list.
+
+If playman.tmpl exists in the Paludis repositories configuration directory, it
+will be used as a template, with the strings @NAME@ and @SYNC@ replaced with
+the name and sync URL of the overlay, respectively. Otherwise, a builtin
+default template will be used.
HELP
exit 0
when '--version'
@@ -120,17 +125,12 @@ HELP
end
end
-if Paludis.const_defined?(:EnvironmentMaker) then
- if ($envspec || "") =~ /^(?:paludis)?(?::(.*))?$/ then
- $env = Paludis::PaludisEnvironment.new($1 || "")
- $config_dir = $env.config_dir
- else
- $stderr.puts "#$0: --environment must specifiy class 'paludis'"
- exit 1
- end
+if ($envspec || "") =~ /^(?:paludis)?(?::(.*))?$/ then
+ $env = Paludis::PaludisEnvironment.new($1 || "")
+ $config_dir = $env.config_dir
else
- $env = DefaultEnvironment.instance
- $config_dir = Paludis::DefaultConfig.instance.config_dir
+ $stderr.puts "#$0: --environment must specifiy class 'paludis'"
+ exit 1
end
if $mode.empty?
@@ -191,28 +191,51 @@ when 'add'
puts "We don't know anything about #{overlay_name}"
exit 1
end
-
+
filename = $config_dir + "/repositories/#{overlay_name}.conf"
- File.open(filename,'w') do |f|
- f.puts "# Config generated by: " + $0 + ", version " + version
- f.puts "location = /var/paludis/repositories/#{overlay_name}"
- f.puts "format = ebuild"
- f.puts "sync = #{layman_srcs[overlay_name]}"
- f.puts
- f.puts "master_repository = gentoo"
+ File.open(filename,'w') do |f|
+ template = $config_dir + "/repositories/playman.tmpl"
+ if File.exist?(template) then
+ substs = {
+ 'NAME' => overlay_name,
+ 'SYNC' => layman_srcs[overlay_name],
+ }
+
+ IO.foreach(template) do |line|
+ line.gsub!(/@([A-Z]+)@/) do
+ if substs.has_key?($1) then
+ substs[$1]
+ else
+ Log.instance.message(LogLevel::Warning, "Unknown variable #$1 in #{template}")
+ ""
+ end
+ end
+ f.puts line
+ end
- if $names_cache
- f.puts "names_cache = ${location}/.cache/names"
else
- f.puts "names_cache = /var/empty"
- end
- if $write_cache
- f.puts "write_cache = /var/cache/paludis/metadata"
- else
- f.puts "write_cache = /var/empty"
+ f.puts "# Config generated by: " + $0 + ", version " + version
+
+ f.puts "location = /var/paludis/repositories/#{overlay_name}"
+ f.puts "format = ebuild"
+ f.puts "sync = #{layman_srcs[overlay_name]}"
+ f.puts
+ f.puts "master_repository = gentoo"
+
+ if $names_cache
+ f.puts "names_cache = ${location}/.cache/names"
+ else
+ f.puts "names_cache = /var/empty"
+ end
+ if $write_cache
+ f.puts "write_cache = /var/cache/paludis/metadata"
+ else
+ f.puts "write_cache = /var/empty"
+ end
end
end
+
puts
puts "You should now run:"
print " paludis"