From ccf3113d9e9a30185c777c2194d003eeed8cb95b Mon Sep 17 00:00:00 2001 From: matrinox Date: Mon, 1 Feb 2016 00:21:47 -0800 Subject: [PATCH] Update File calls to FileUtils for ruby versions 1.9.x and above --- CHANGELOG | 4 +-- ev/dependencies.rb | 2 +- ev/ftools.rb | 8 +++--- init.rb | 66 +++++++++++++++++++++++----------------------- require2lib.rb | 14 +++++----- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0a47709..7811b01 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,7 +8,7 @@ 0.5.3 - 29.05.2007 -* Added a bit of Config::CONFIG magic to make RubyScript2Exe +* Added a bit of RbConfig::CONFIG magic to make RubyScript2Exe work with RubyGems >= 0.9.3. * Moved the embedded bin directory to the front of $PATH. @@ -151,7 +151,7 @@ * Added --rubyscript2exe-tk (experimental). * Added a check for the existence of - Config::CONFIG["bindir"]/ruby (RubyScript2Exe doesn't work + RbConfig::CONFIG["bindir"]/ruby (RubyScript2Exe doesn't work without it...). * Fixed a bug concerning program arguments with spaces on diff --git a/ev/dependencies.rb b/ev/dependencies.rb index 7f9b560..444f72f 100755 --- a/ev/dependencies.rb +++ b/ev/dependencies.rb @@ -66,7 +66,7 @@ def ldds(file, notthedefaults=true) todo = [] todo2.each do |file| - File.copy(file, tempfile) # Libraries on Debian are no executables. + FileUtils.copy(file, tempfile) # Libraries on Debian are no executables. File.chmod(0755, tempfile) libs = `ldd #{tempfile}`.split(/\r*\n/).collect{|line| line.split(/\s+/)[3]} if linux? diff --git a/ev/ftools.rb b/ev/ftools.rb index 6dfb821..612a1ae 100755 --- a/ev/ftools.rb +++ b/ev/ftools.rb @@ -1,4 +1,4 @@ -require "ftools" +require "fileutils" class Dir def self.copy(from, to) @@ -6,7 +6,7 @@ def self.copy(from, to) pdir = Dir.pwd todir = File.expand_path(to) - File.mkpath(todir) + FileUtils.mkpath(todir) Dir.chdir(from) Dir.open(".") do |dir| @@ -18,9 +18,9 @@ def self.copy(from, to) else todir = File.dirname(File.expand_path(to)) - File.mkpath(todir) + FileUtils.mkpath(todir) - File.copy(from, to) + FileUtils.copy(from, to) end end diff --git a/init.rb b/init.rb index 24f3109..8d74123 100644 --- a/init.rb +++ b/init.rb @@ -39,7 +39,7 @@ def cygwin? end def target_os - Config::CONFIG["target_os"] or "" + RbConfig::CONFIG["target_os"] or "" end def copyto(files, dest) @@ -48,7 +48,7 @@ def copyto(files, dest) $stderr.puts "Copying #{fromfile} ..." if VERBOSE - File.copy(fromfile, tofile) unless File.file?(tofile) + FileUtils.copy(fromfile, tofile) unless File.file?(tofile) end end @@ -100,8 +100,8 @@ def copyto(files, dest) exit 1 end -bindir1 = Config::CONFIG["bindir"] -libdir1 = Config::CONFIG["libdir"] +bindir1 = RbConfig::CONFIG["bindir"] +libdir1 = RbConfig::CONFIG["libdir"] bindir2 = tmplocation("bin/") libdir2 = tmplocation("lib/") appdir2 = tmplocation("app/") @@ -261,32 +261,32 @@ def copyto(files, dest) f.puts "require 'rbconfig'" - f.puts "Config::CONFIG['archdir'] = dir + '/lib'" # /usr/local/lib/ruby/1.8/i686-linux - f.puts "Config::CONFIG['bindir'] = dir + '/bin'" # /usr/local/bin - f.puts "Config::CONFIG['datadir'] = dir + '/share'" # /usr/local/share - f.puts "Config::CONFIG['datarootdir'] = dir + '/share'" # /usr/local/share - f.puts "Config::CONFIG['docdir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) - f.puts "Config::CONFIG['dvidir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) - f.puts "Config::CONFIG['exec_prefix'] = dir + ''" # /usr/local - f.puts "Config::CONFIG['htmldir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) - f.puts "Config::CONFIG['includedir'] = dir + '/include'" # /usr/local/include - f.puts "Config::CONFIG['infodir'] = dir + '/share/info'" # /usr/local/share/info - f.puts "Config::CONFIG['libdir'] = dir + '/lib'" # /usr/local/lib - f.puts "Config::CONFIG['libexecdir'] = dir + '/libexec'" # /usr/local/libexec - f.puts "Config::CONFIG['localedir'] = dir + '/share/locale'" # /usr/local/share/locale - f.puts "Config::CONFIG['localstatedir'] = dir + '/var'" # /usr/local/var - f.puts "Config::CONFIG['mandir'] = dir + '/share/man'" # /usr/local/share/man - f.puts "Config::CONFIG['pdfdir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) - f.puts "Config::CONFIG['prefix'] = dir + ''" # /usr/local - f.puts "Config::CONFIG['psdir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) - f.puts "Config::CONFIG['rubylibdir'] = dir + '/lib'" # /usr/local/lib/ruby/1.8 - f.puts "Config::CONFIG['sbindir'] = dir + '/sbin'" # /usr/local/sbin - f.puts "Config::CONFIG['sharedstatedir'] = dir + '/com'" # /usr/local/com - f.puts "Config::CONFIG['sitearchdir'] = dir + '/lib'" # /usr/local/lib/ruby/site_ruby/1.8/i686-linux - f.puts "Config::CONFIG['sitedir'] = dir + '/lib'" # /usr/local/lib/ruby/site_ruby - f.puts "Config::CONFIG['sitelibdir'] = dir + '/lib'" # /usr/local/lib/ruby/site_ruby/1.8 - f.puts "Config::CONFIG['sysconfdir'] = dir + '/etc'" # /usr/local/etc - f.puts "Config::CONFIG['topdir'] = dir + '/lib'" # /usr/local/lib/ruby/1.8/i686-linux + f.puts "RbConfig::CONFIG['archdir'] = dir + '/lib'" # /usr/local/lib/ruby/1.8/i686-linux + f.puts "RbConfig::CONFIG['bindir'] = dir + '/bin'" # /usr/local/bin + f.puts "RbConfig::CONFIG['datadir'] = dir + '/share'" # /usr/local/share + f.puts "RbConfig::CONFIG['datarootdir'] = dir + '/share'" # /usr/local/share + f.puts "RbConfig::CONFIG['docdir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) + f.puts "RbConfig::CONFIG['dvidir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) + f.puts "RbConfig::CONFIG['exec_prefix'] = dir + ''" # /usr/local + f.puts "RbConfig::CONFIG['htmldir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) + f.puts "RbConfig::CONFIG['includedir'] = dir + '/include'" # /usr/local/include + f.puts "RbConfig::CONFIG['infodir'] = dir + '/share/info'" # /usr/local/share/info + f.puts "RbConfig::CONFIG['libdir'] = dir + '/lib'" # /usr/local/lib + f.puts "RbConfig::CONFIG['libexecdir'] = dir + '/libexec'" # /usr/local/libexec + f.puts "RbConfig::CONFIG['localedir'] = dir + '/share/locale'" # /usr/local/share/locale + f.puts "RbConfig::CONFIG['localstatedir'] = dir + '/var'" # /usr/local/var + f.puts "RbConfig::CONFIG['mandir'] = dir + '/share/man'" # /usr/local/share/man + f.puts "RbConfig::CONFIG['pdfdir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) + f.puts "RbConfig::CONFIG['prefix'] = dir + ''" # /usr/local + f.puts "RbConfig::CONFIG['psdir'] = dir + '/share/doc/$(PACKAGE)'" # /usr/local/share/doc/$(PACKAGE) + f.puts "RbConfig::CONFIG['rubylibdir'] = dir + '/lib'" # /usr/local/lib/ruby/1.8 + f.puts "RbConfig::CONFIG['sbindir'] = dir + '/sbin'" # /usr/local/sbin + f.puts "RbConfig::CONFIG['sharedstatedir'] = dir + '/com'" # /usr/local/com + f.puts "RbConfig::CONFIG['sitearchdir'] = dir + '/lib'" # /usr/local/lib/ruby/site_ruby/1.8/i686-linux + f.puts "RbConfig::CONFIG['sitedir'] = dir + '/lib'" # /usr/local/lib/ruby/site_ruby + f.puts "RbConfig::CONFIG['sitelibdir'] = dir + '/lib'" # /usr/local/lib/ruby/site_ruby/1.8 + f.puts "RbConfig::CONFIG['sysconfdir'] = dir + '/etc'" # /usr/local/etc + f.puts "RbConfig::CONFIG['topdir'] = dir + '/lib'" # /usr/local/lib/ruby/1.8/i686-linux f.puts "# Load eee.info" @@ -370,7 +370,7 @@ def copyto(files, dest) from = oldlocation(eeeexe) unless File.file?(from) to = tmplocation(eeeexe) -File.copy(from, to) unless from == to +FileUtils.copy(from, to) unless from == to File.chmod(0755, to) if linux? or darwin? tmplocation do @@ -401,7 +401,7 @@ def copyto(files, dest) from = eeebin1 to = eeebin2 - File.copy(from, to) unless from == to + FileUtils.copy(from, to) unless from == to File.chmod(0755, to) if linux? or darwin? system(backslashes("#{eeebin2} #{appeee} #{appexe}")) @@ -410,7 +410,7 @@ def copyto(files, dest) from = tmplocation(appexe) to = oldlocation(appexe) -File.copy(from, to) unless from == to +FileUtils.copy(from, to) unless from == to oldlocation do system(backslashes("reshacker -modify #{tmplocation(appexe)}, #{appexe}, #{appico}, icon,appicon,")) if File.file?(appico) and (windows? or cygwin?) diff --git a/require2lib.rb b/require2lib.rb index bdb3e3c..85c55e7 100755 --- a/require2lib.rb +++ b/require2lib.rb @@ -21,8 +21,8 @@ module REQUIRE2LIB THISFILE = File.expand_path(__FILE__) LIBDIR = File.expand_path((ENV["REQUIRE2LIB_LIBDIR"] or ".")) LOADSCRIPT = File.expand_path((ENV["REQUIRE2LIB_LOADSCRIPT"] or ".")) - RUBYLIBDIR = Config::CONFIG["rubylibdir"] - SITELIBDIR = Config::CONFIG["sitelibdir"] + RUBYLIBDIR = RbConfig::CONFIG["rubylibdir"] + SITELIBDIR = RbConfig::CONFIG["sitelibdir"] at_exit do Dir.chdir(ORGDIR) @@ -33,7 +33,7 @@ module REQUIRE2LIB def self.gatherlibs $stderr.puts "Gathering files..." unless QUIET - File.makedirs(LIBDIR) + FileUtils.makedirs(LIBDIR) if RUBYGEMS begin @@ -66,7 +66,7 @@ def self.gatherlibs fromfile = File.join(fromdir, "#{gem.full_name}.gemspec") tofile = File.join(todir, "#{gem.full_name}.gemspec") - File.copy(fromfile, tofile) + FileUtils.copy(fromfile, tofile) fromdir = gem.full_gem_path todir = File.expand_path(File.join("rubyscript2exe.gems/gems", gem.full_name), LIBDIR) @@ -79,7 +79,7 @@ def self.gatherlibs unless lib.empty? lib = File.expand_path(lib, todir) lib = lib + "/" - + requireablefiles << file[lib.length..-1] if file =~ /^#{lib.gsub('+', '\+')}/ end end @@ -102,8 +102,8 @@ def self.gatherlibs (JUSTSITELIB and fromfile.include?(SITELIBDIR)) $stderr.puts "Found #{fromfile} ." if VERBOSE - File.makedirs(File.dirname(tofile)) unless File.directory?(File.dirname(tofile)) - File.copy(fromfile, tofile) + FileUtils.makedirs(File.dirname(tofile)) unless File.directory?(File.dirname(tofile)) + FileUtils.copy(fromfile, tofile) pureruby = false unless req =~ /\.(rbw?|ruby)$/i else