aboutsummaryrefslogtreecommitdiffstats
path: root/tool/rbuninstall.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-20 12:49:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-20 12:49:43 +0000
commite908adc12a522d8e9ded0bf9b552f1335ac92c29 (patch)
tree78ace4b503c7969139f97a0de83e107a0180f7d0 /tool/rbuninstall.rb
parentfc50b60cb7a7df79a2a8267c0cac5ca6f7fa0b58 (diff)
downloadruby-e908adc12a522d8e9ded0bf9b552f1335ac92c29.tar.gz
common.mk: uninstall
* common.mk (uninstall): uninstall installed file listed in $(INSTALLED_LIST) file. * tool/rbuninstall.rb: simple uninstallation tool. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/rbuninstall.rb')
-rwxr-xr-xtool/rbuninstall.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/tool/rbuninstall.rb b/tool/rbuninstall.rb
new file mode 100755
index 0000000000..2d1612243f
--- /dev/null
+++ b/tool/rbuninstall.rb
@@ -0,0 +1,51 @@
+#! /usr/bin/ruby -nl
+BEGIN {
+ $dryrun = false
+ until ARGV.empty?
+ case ARGV[0]
+ when /\A--destdir=(.*)/
+ $destdir = $1
+ when /\A-n\z/
+ $dryrun = true
+ else
+ break
+ end
+ ARGV.shift
+ end
+ $dirs = []
+ $files = []
+}
+list = (/\/\z/ =~ $_ ? $dirs : $files)
+$_ = File.join($destdir, $_) if $destdir
+list << $_
+END {
+ status = true
+ if $dryrun
+ $files.each do |file|
+ puts "rm #{file}"
+ end
+ $dirs.reverse_each do |dir|
+ puts "rmdir #{dir}"
+ end
+ else
+ $files.each do |file|
+ begin
+ File.unlink(file)
+ rescue Errno::ENOENT
+ rescue
+ status = false
+ puts $!
+ end
+ end
+ $dirs.reverse_each do |dir|
+ begin
+ Dir.rmdir(dir)
+ rescue Errno::ENOENT, Errno::ENOTEMPTY
+ rescue
+ status = false
+ puts $!
+ end
+ end
+ end
+ exit(status)
+}