You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ge...@apache.org on 2010/06/29 09:51:23 UTC

svn commit: r958858 - in /karaf/sandbox/gertv: ./ rename.rb

Author: gertv
Date: Tue Jun 29 07:51:22 2010
New Revision: 958858

URL: http://svn.apache.org/viewvc?rev=958858&view=rev
Log:
Keeping the rename script around for future reference

Added:
    karaf/sandbox/gertv/
    karaf/sandbox/gertv/rename.rb   (with props)

Added: karaf/sandbox/gertv/rename.rb
URL: http://svn.apache.org/viewvc/karaf/sandbox/gertv/rename.rb?rev=958858&view=auto
==============================================================================
--- karaf/sandbox/gertv/rename.rb (added)
+++ karaf/sandbox/gertv/rename.rb Tue Jun 29 07:51:22 2010
@@ -0,0 +1,75 @@
+#!/usr/bin/ruby
+
+require 'ftools'
+
+SOURCES = ["main/java", "main/resources", "main/filtered-resources", "main/descriptors", "main/distribution", "test/java", "test/resources"]
+
+def handlePom(pom)
+  puts "- Changing pom file"
+  filter(pom)
+end
+
+def handleSource(src)
+  puts "- Handing sources"
+  dirs = SOURCES.select { |dir| File.directory?("#{src}/#{dir}") }
+  dirs.each { |dir| handleSourceDir("#{src}/#{dir}") }
+end
+
+def handleSourceDir(src)
+  if File.directory?("#{src}/org/apache/felix/karaf")
+    system "svn move #{src}/org/apache/felix/karaf #{src}/org/apache"
+    if empty?("#{src}/org/apache/felix") then
+       system "svn rm #{src}/org/apache/felix"
+    end
+  end
+
+  filterSources(src)
+end
+
+def empty?(dir)
+	Dir.glob("#{dir}/**/*").delete_if{|file| 
+	  file[0] == "."
+	}.delete_if{|file|
+	  empty?(file) if File.directory?(file)
+	}.empty?
+end
+
+def filterSources(src)
+  Dir.foreach(src) do |file|
+    next if file =~ /^\./
+    if File.directory?("#{src}/#{file}") then
+      filterSources("#{src}/#{file}")
+    else
+      if (file =~ /org\.apache\.felix\.karaf/) then
+        name = file.gsub(/org\.apache\.felix\.karaf/, "org.apache.karaf")
+        puts "  renaming #{file} to #{name} first"
+        system "svn move #{src}/#{file} #{src}/#{name}"
+        filter("#{src}/#{name}")
+      else
+        filter("#{src}/#{file}")      
+      end
+    end
+  end
+end
+
+def filter(file)
+  puts "   #{file}"
+  File.move(file, file + ".orig", false)
+  File.open(file, "w") do |new|
+    IO.foreach(file + ".orig") do |line|
+      new.puts line.gsub(/org\.apache\.felix\.karaf/, "org.apache.karaf").gsub(/Apache Felix Karaf/, "Apache Karaf").gsub(/org\/apache\/felix\/karaf/, "org/apache/karaf").gsub(/apache-felix-karaf/, "apache-karaf")
+    end
+  end
+end
+
+def walk(dir)
+  puts "In #{dir}"
+  Dir.foreach(dir) do |path|
+    handlePom("#{dir}/pom.xml") if path =~ /^pom\.xml$/
+    handleSource("#{dir}/src") if path =~ /src/
+    next if path =~ /^\./ or File.file?("#{dir}/#{path}") or path =~ /target/ or path =~ /src/
+    walk("#{dir}/#{path}") if File.directory?("#{dir}/#{path}")
+  end
+end
+
+walk(".")

Propchange: karaf/sandbox/gertv/rename.rb
------------------------------------------------------------------------------
    svn:executable = *