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
This commit is contained in:
parent
fc50b60cb7
commit
e908adc12a
@ -323,6 +323,9 @@ dont-install-all: $(PROGRAM)
|
|||||||
post-no-install-all:: post-no-install-local post-no-install-ext post-no-install-doc
|
post-no-install-all:: post-no-install-local post-no-install-ext post-no-install-doc
|
||||||
@$(NULLCMD)
|
@$(NULLCMD)
|
||||||
|
|
||||||
|
uninstall: $(INSTALLED_LIST)
|
||||||
|
$(Q)$(SUDO) $(MINIRUBY) $(srcdir)/tool/rbuninstall.rb --destdir=$(DESTDIR) $(INSTALLED_LIST)
|
||||||
|
|
||||||
what-where-nodoc: no-install-nodoc
|
what-where-nodoc: no-install-nodoc
|
||||||
no-install-nodoc: pre-no-install-nodoc dont-install-nodoc post-no-install-nodoc
|
no-install-nodoc: pre-no-install-nodoc dont-install-nodoc post-no-install-nodoc
|
||||||
pre-no-install-nodoc:: pre-no-install-local pre-no-install-ext
|
pre-no-install-nodoc:: pre-no-install-local pre-no-install-ext
|
||||||
|
51
tool/rbuninstall.rb
Executable file
51
tool/rbuninstall.rb
Executable file
@ -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)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user