From b4946f883a96c944d5f19e448b9f3cb13250e518 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 27 Jul 2007 20:32:37 +0100 Subject: rant installer adjustments --- CHANGELOG | 10 ++- Rantfile | 282 +++++++++++++++++++++++++++++++++++--------------------------- 2 files changed, 164 insertions(+), 128 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2db96703..f7cad6b7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,16 +12,18 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_0.55.6.orig.tar.gz sisu_0.55.6-1.dsc sisu_0.55.6-1.diff.gz - * matching of multiple urls within a paragraph - * db html (html_lite), bug fix - * multiple uls listed, refinement: html, html_lite, xml, odf, texpdf + * matching multiple and consecutive urls within a paragraph, refinements + * db html (html_lite), multiple urls, bug fix + * consecutive url matching: html, html_lite, xml, odf, texpdf * open archive initiative for metadata harvesting, initial implementation, Dublin Core, XML output available (-O), decide use later (filenames, output dir etc.) + * rant installer, minor adjustments + * debian vim - * moved vim install back to addons + * moved installation of syntax and ftplugin back to vim/addons * added recommends vim-addon-manager (thanks zack) diff --git a/Rantfile b/Rantfile index f46c89ec..d1238822 100644 --- a/Rantfile +++ b/Rantfile @@ -2,9 +2,9 @@ raise 'Please, use ruby1.8.4 or later.' if RUBY_VERSION < '1.8.4' =begin Rantfile installer for SiSU - * Homepage: - * Download: - + * Homepage: + + * Download: Copyright (C) 2007 Ralph Amissah @@ -19,7 +19,6 @@ raise 'Please, use ruby1.8.4 or later.' if RUBY_VERSION < '1.8.4' http://make.rubyforge.org/ Notes on use: - rant -T SiSU can also be Setup/Installation using: @@ -31,35 +30,76 @@ raise 'Please, use ruby1.8.4 or later.' if RUBY_VERSION < '1.8.4' #create_makefile("sisu") require 'find' require 'fileutils' +#require 'ftools' require 'rbconfig.rb' +require 'yaml' include FileUtils -@dir=Hash.new -@proj=Hash.new - #%% project specific variables -@proj[:name]='SiSU' -@proj[:rant]="Rantfile for the installation/setup of #{@proj[:name]}" -@proj[:platform_notice]="[#{@proj[:name]} is for the Linux/Unix Platforms]" -@dir[:proj]='sisu' -Version=` pwd | grep -o "[0-9]+\.[0-9]+\.[0-9]+$" | grep -o "^[0-9]+\.[0-9]+"` #%% NOTE placing version number permits fine grained removal of version directories if used in lib and conf / etc - #%% system configuration -@env=Config::CONFIG -PKG_VERSION=Version -@dir[:version]=Version -@host=@env['host'] -@dir[:arch]=@env['archdir'] -@dir[:sitearch]=@env['sitearchdir'] -@dir[:bin]=@env['bindir'] -#@dir_lib=@env['rubylibdir'] -@dir[:lib]=@env['sitelibdir'] -#@dir_lib='/usr/local/lib/site_ruby/1.9' #@env['sitelibdir'] -@dir[:data]=@env['datadir'] -@dir[:share]="#{@env['datadir']}/sisu" -@dir[:conf]=@env['sysconfdir'] #etc -@dir[:man]=@env['mandir'] -@dir[:vim]="#{@env['datadir']}/sisu/vim" -@dir[:out]="#{@env['localstatedir']}/#{@dir[:proj]}" -@rubylib=@env['LIBRUBYARG_SHARED'] -@pwd=Dir.pwd +class Project_details + def name + 'SiSU' + end + def rant + "Rantfile for the installation/setup of #{name}" + end + def platform_notice + "[#{name} is for the Linux/Unix Platforms]" + end + def dir_proj + 'sisu' + end + def env + Config::CONFIG + end + def host + env['host'] + end + def dir_arch + env['archdir'] + end + def dir_sitearch + env['sitearchdir'] + end + def dir_bin + env['bindir'] + end + def dir_lib + env['sitelibdir'] + end + def dir_data + env['datadir'] + end + def dir_share + "#{env['datadir']}/sisu" + end + def dir_conf + env['sysconfdir'] + end + def dir_man + env['mandir'] + end + def dir_vim + "#{env['datadir']}/sisu/vim" + end + def dir_out + "#{env['localstatedir']}/#{dir_proj}" + end + def dir_rubylib + env['LIBRUBYARG_SHARED'] + end + def dir_pwd + Dir.pwd #ENV['PWD'] + end + def version + stamp={} + v="#{dir_pwd}/conf/sisu/version.yml" + version=if File.exist?(v) + stamp=YAML::load(File::open(v)) + stamp[:version] + else '' + end + end +end +@p=Project_details.new def answer?(ask) resp='redo' print ask + " ['yes', 'no' or 'quit']: " @@ -73,10 +113,10 @@ def answer?(ask) end end def default_notice - ans= %{#{@proj[:rant]} + ans= %{#{@p.rant} Information on alternative actions is available using: "rant help" or "rant -T" - Default action selected - "install and to setup #{@proj[:name]}" proceed? } + Default action selected - "install and to setup #{@p.name}" proceed? } resp=answer?(ans) exit unless resp end @@ -95,8 +135,8 @@ def chmod_util(place) end #%% using a directory and its mapping def setup_find_create(dir_get,dir_put) #primary, - Find.find("#@pwd/#{dir_get}") do |f| - stub=f.scan(/#@pwd\/#{dir_get}\/(\S+)/).join + Find.find("#{@p.dir_pwd}/#{dir_get}") do |f| + stub=f.scan(/#{@p.dir_pwd}\/#{dir_get}\/(\S+)/).join place="#{dir_put}/#{stub}" action=case when File.file?(f) @@ -112,8 +152,8 @@ def setup_find_create(dir_get,dir_put) #primary, end end def setup_find_cp_r(dir_get,dir_put) #secondary, using recursive copy - Find.find("#@pwd/#{dir_get}") do |f| - stub=f.scan(/#@pwd\/#{dir_get}\/(\S+)/).join + Find.find("#{@p.dir_pwd}/#{dir_get}") do |f| + stub=f.scan(/#{@p.dir_pwd}\/#{dir_get}\/(\S+)/).join place="#{dir_put}/#{stub}" case when File.file?(f) @@ -126,52 +166,52 @@ def setup_find_cp_r(dir_get,dir_put) #secondary, using rec end def rant_system_info puts < [:default_notice,:project] #task :default => [:help,:notice,:project] -desc "Setup/Install #{@proj[:name]} and try generate a file" +desc "Setup/Install #{@p.name} and try generate a file" task :project=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_data,:setup_man,:setup_vim,:post_install_note] -desc "Setup/Install #{@proj[:name]}" +desc "Setup/Install #{@p.name}" task :setup=> [:setup_bin, :setup_lib,:setup_conf,:setup_share,:setup_data] #, :help] -desc "Setup/Install #{@proj[:name]}: bin, lib and conf (no data)" +desc "Setup/Install #{@p.name}: bin, lib and conf (no data)" task :setup_base=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_man,:setup_vim] -desc "Setup/Install #{@proj[:name]} bin, lib and conf (no data and no attempt to do postinstall setup)" +desc "Setup/Install #{@p.name} bin, lib and conf (no data and no attempt to do postinstall setup)" task :base=> [:setup_base] if File.directory?('bin') #bin - desc "Setup #{@proj[:name]} bin only, synonym :bin" + desc "Setup #{@p.name} bin only, synonym :bin" task :setup_bin => [:setup_bin] task :bin => [:setup_bin] end if File.directory?('lib') #lib - desc "Setup #{@proj[:name]} lib only, synonym :lib" + desc "Setup #{@p.name} lib only, synonym :lib" task :setup_lib => [:setup_lib] task :lib => [:setup_lib] end if File.directory?('conf') #conf or etc - desc "Setup #{@proj[:name]} conf only, synonyms :conf & :etc" + desc "Setup #{@p.name} conf only, synonyms :conf & :etc" task :setup_conf => [:setup_conf] task :conf => [:setup_conf] task :setup_etc => [:setup_conf] task :etc => [:setup_conf] end if File.directory?('data') #data - desc "Setup #{@proj[:name]} data only, synonyms :data & :examples" + desc "Setup #{@p.name} data only, synonyms :data & :examples" task :setup_data => [:setup_data] task :data => [:setup_data] task :setup_examples => [:setup_data] task :examples => [:setup_data] end if File.directory?('data/sisu') #share (odf shared-images) - desc "Setup #{@proj[:name]} shared data only (odf & shared images)" + desc "Setup #{@p.name} shared data only (odf & shared images)" task :setup_share => [:setup_share] task :share => [:setup_share] end if File.directory?('man') #man pages - desc "Setup #{@proj[:name]} man pages only, synonyms :man" + desc "Setup #{@p.name} man pages only, synonyms :man" task :setup_man => [:setup_man] task :man => [:setup_man] end if File.directory?('data/vim') #man pages - desc "Setup #{@proj[:name]} vim config files only, synonyms :vim" + desc "Setup #{@p.name} vim config files only, synonyms :vim" task :setup_vim => [:setup_vim] task :vim => [:setup_vim] end -desc "Setup/Install #{@proj[:name]}: bin, lib, conf and data (no attempt to do postinstall setup)" +desc "Setup/Install #{@p.name}: bin, lib, conf and data (no attempt to do postinstall setup)" task :setup_only=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_data,:help] -#desc "Remove #{@proj[:name]} version: #{Version}" -#task :remove => [:remove_version] -desc "Remove #{@proj[:name]} (all versions)" #remove project +desc "Remove #{@p.name} (all versions)" #remove project task :remove_package => [:remove_bin, :remove_lib, :remove_conf] if File.directory?('bin') #bin - desc "Remove #{@proj[:name]} bin only" #remove bin + desc "Remove #{@p.name} bin only" #remove bin task :remove_bin => [:remove_bin] end if File.directory?('lib') #lib - desc "Remove #{@proj[:name]} lib only" #remove lib + desc "Remove #{@p.name} lib only" #remove lib task :remove_lib => [:remove_lib] end if File.directory?('conf') #conf - desc "Remove #{@proj[:name]} conf only" #remove conf + desc "Remove #{@p.name} conf only" #remove conf task :remove_conf => [:remove_conf] end #if File.directory?('data') #data -# desc "Remove #{@proj[:name]} data only" #remove data +# desc "Remove #{@p.name} data only" #remove data # task :remove_data => [:remove_data] #end -desc "Re-setup #{@proj[:name]}, synonym :reinstall" #resetup reinstall +desc "Re-setup #{@p.name}, synonym :reinstall" #resetup reinstall task :resetup => [:remove, :setup] task :reinstall => [:remove, :setup] -desc "Re-setup #{@proj[:name]}: bin, lib, conf (ignore data), synonym :reinstall" #partial reinstall +desc "Re-setup #{@p.name}: bin, lib, conf (ignore data), synonym :reinstall" #partial reinstall task :resetup_base => [:remove, :setup_base] task :reinstall_base => [:remove, :setup_base] if File.directory?('bin') #bin - desc "Re-setup #{@proj[:name]} bin, synonym :reinstall" + desc "Re-setup #{@p.name} bin, synonym :reinstall" task :resetup_bin => [:remove_bin, :setup_bin] task :reinstall_bin => [:remove_bin, :setup_bin] end if File.directory?('lib') #lib - desc "Re-setup #{@proj[:name]} lib, synonym :reinstall_lib" + desc "Re-setup #{@p.name} lib, synonym :reinstall_lib" task :resetup_lib => [:remove_lib, :setup_lib] task :reinstall_lib => [:remove_lib, :setup_lib] end if File.directory?('conf') #conf - desc "Re-setup #{@proj[:name]} conf, synonyms :reinstall_conf & :resetup_etc" + desc "Re-setup #{@p.name} conf, synonyms :reinstall_conf & :resetup_etc" task :resetup_conf => [:remove_conf, :setup_conf] task :reinstall_conf => [:remove_conf, :setup_conf] task :resetup_etc => [:remove_conf, :setup_conf] task :reinstall_etc => [:remove_conf, :setup_conf] end if File.directory?('data/sisu') #share - desc "Re-setup #{@proj[:name]} shared data, (odf & images)" + desc "Re-setup #{@p.name} shared data, (odf & images)" task :resetup_share => [:remove_share, :setup_share] task :reinstall_share => [:remove_share, :setup_share] end if File.directory?('man') #man - desc "Re-setup #{@proj[:name]} man, synonym :reinstall_man" + desc "Re-setup #{@p.name} man, synonym :reinstall_man" task :resetup_man => [:remove_man, :setup_man] task :reinstall_man => [:remove_man, :setup_man] end -desc "Setup Note" +desc 'Setup Note' task :setup_note => [:help] -desc "System information used by #{@proj[:name]}" +desc "System information used by #{@p.name}" task :system => [:system_info,:project_help,:post_install_note] desc "show all system info available - parameters found" task :system_param => [:system_param] -desc "Help" -task :help => [:project_help,:system_info,:rant_tasks,:pi?] -#desc "Setup/Install #{@proj[:name]} (uses filelist)" +desc 'Help' +task :help => [:project_help,:system_info,:rant_tasks] +#desc "Setup/Install #{@p.name} (uses filelist)" task :install => [:default_notice,:project] task :install_bin => [:setup_bin] -desc "[make rant install file]" +desc '[make rant install file]' task :create_rant_independent_task_file => [:rant_independence] #%% setup/install tasks task :rant_independence do #notice resp='' while resp.length < 4 resp='sisu-install' #default name install - print %{#{@proj[:rant]} + print %{#{@p.rant} Create a rant dependency independent file provide filename default name is "install" [Warning, will overwrite file of name provided @@ -326,63 +364,59 @@ task :default_notice do #notice default_notice end task :rant_default2 do #secondary - setup_find_cp_r('bin',@dir[:bin]) if File.directory?('bin') - setup_find_cp_r('lib',@dir[:lib]) if File.directory?('lib') - setup_find_cp_r('conf',@dir[:conf]) if File.directory?('conf') - setup_find_cp_r('data/sisu',"#{@dir[:share]}") if File.directory?('data/sisu') # - setup_find_cp_r('data',@dir[:data]) if File.directory?('data') - setup_find_cp_r('data/vim',"#{@dir[:data]}/vim") if File.directory?('data/vim') - setup_find_cp_r('man',@dir[:man]) if File.directory?('man') + setup_find_cp_r('bin',@p.dir_bin) if File.directory?('bin') + setup_find_cp_r('lib',@p.dir_lib) if File.directory?('lib') + setup_find_cp_r('conf',@p.dir_conf) if File.directory?('conf') + setup_find_cp_r('data/sisu',@p.dir_share) if File.directory?('data/sisu') # + setup_find_cp_r('data',@p.dir_data) if File.directory?('data') + setup_find_cp_r('data/vim',"#{@p.dir_data}/vim") if File.directory?('data/vim') + setup_find_cp_r('man',@p.dir_man) if File.directory?('man') end task :setup_bin do #bin - setup_find_create('bin',@dir[:bin]) if File.directory?('bin') + setup_find_create('bin',@p.dir_bin) if File.directory?('bin') end task :setup_lib do #lib - setup_find_create('lib',@dir[:lib]) if File.directory?('lib') + setup_find_create('lib',@p.dir_lib) if File.directory?('lib') end task :setup_conf do #conf - setup_find_create('conf',@dir[:conf]) if File.directory?('conf') + setup_find_create('conf',@p.dir_conf) if File.directory?('conf') end task :setup_share do #share - setup_find_create('data/sisu',@dir[:share]) if File.directory?('data/sisu') + setup_find_create('data/sisu',@p.dir_share) if File.directory?('data/sisu') end task :setup_data do #data - setup_find_create('data',@dir[:data]) if File.directory?('data') + setup_find_create('data',@p.dir_data) if File.directory?('data') end task :setup_man do #man - setup_find_create('man',@dir[:man]) if File.directory?('man') #man pages - setup_find_create('man.deb/man',@dir[:man]) if File.directory?('man.deb/man') #man pages + setup_find_create('man',@p.dir_man) if File.directory?('man') #man pages + setup_find_create('man.deb/man',@p.dir_man) if File.directory?('man.deb/man') #man pages end task :setup_vim do #man - setup_find_create('data/vim',@dir[:vim]) if File.directory?('data/vim') #man pages + setup_find_create('data/vim',@p.dir_vim) if File.directory?('data/vim') #man pages end #%% post install #%% clobber/remove tasks task :remove_bin do - rm_r "#{@dir[:bin]}/#{@dir[:proj]}" if FileTest.file?("#{@dir[:bin]}/#{@dir[:proj]}") + rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") end task :remove_lib do - rm_r "#{@dir[:lib]}/#{@dir[:proj]}" if FileTest.directory?("#{@dir[:lib]}/#{@dir[:proj]}") + rm_r "#{@p.dir_lib}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}") end task :remove_conf do - rm_r "#{@dir[:conf]}/#{@dir[:proj]}" if FileTest.directory?("#{@dir[:conf]}/#{@dir[:proj]}") + rm_r "#{@p.dir_conf}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") end -#task :remove_data do -# rm_r "#{@dir[:data]}/#{@dir[:proj_eg]}" if FileTest.directory?("#{@dir[:data]}/#{@dir[:proj_eg]}") -#end task :remove_man do - rm_r "#{@dir[:man]}/**/#{@dir[:proj]}" if FileTest.directory?("#{@dir[:man]}/man1/#{@dir[:proj]}") + rm_r "#{@p.dir_man}/**/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_man}/man1/#{@p.dir_proj}") end task :remove_version do - rm_r "#{@dir[:bin]}/#{@dir[:proj]}" if FileTest.file?("#{@dir[:bin]}/#{@dir[:proj]}") - rm_r "#{@dir[:lib]}/#{@dir[:proj]}/#{Version}" if FileTest.directory?("#{@dir[:lib]}/#{@dir[:proj]}/#{Version}") - rm_r "#{@dir[:conf]}/#{@dir[:proj]} if FileTest.directory?("#{@dir[:conf]}/#{@dir[:proj]}") - #rm_r "#@dir_data/#{@dir[:proj]}" + rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") + rm_r "#{@p.dir_lib}/#{@p.dir_proj}/#{@p.version}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}/#{@p.version}") + rm_r "#{@p.dir_conf}/#{@p.dir_proj} if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") end task :remove_package do - rm_r "#{@dir[:bin]}/#{@dir[:proj]}" if FileTest.file?("#{@dir[:bin]}/#{@dir[:proj]}") - rm_r "#{@dir[:lib]}/#{@dir[:proj]}" if FileTest.directory?("#{@dir[:lib]}/#{@dir[:proj]}") - rm_r "#{@dir[:conf]}/#{@dir[:proj]}" if FileTest.directory?("#{@dir[:conf]}/#{@dir[:proj]}") + rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") + rm_r "#{@p.dir_lib}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}") + rm_r "#{@p.dir_conf}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") end task :post_install_note do puts < Date: Fri, 27 Jul 2007 21:08:44 +0100 Subject: maintain rinstall as a common rant (Rantfile), rake (Rakefile) --- CHANGELOG | 4 +- Rakefile | 1 + Rantfile | 444 +------------------------------------------------------------- rinstall | 438 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 443 insertions(+), 444 deletions(-) create mode 120000 Rakefile mode change 100644 => 120000 Rantfile create mode 100644 rinstall diff --git a/CHANGELOG b/CHANGELOG index f7cad6b7..21658049 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,7 +20,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_0.55.6.orig.tar.gz Dublin Core, XML output available (-O), decide use later (filenames, output dir etc.) - * rant installer, minor adjustments + * rinstall as both a rant and rake installer for sisu + * Rakefile softlink to rinstall + * Rantfile softlink to rinstall * debian vim * moved installation of syntax and ftplugin back to vim/addons diff --git a/Rakefile b/Rakefile new file mode 120000 index 00000000..0bae78d7 --- /dev/null +++ b/Rakefile @@ -0,0 +1 @@ +rinstall \ No newline at end of file diff --git a/Rantfile b/Rantfile deleted file mode 100644 index d1238822..00000000 --- a/Rantfile +++ /dev/null @@ -1,443 +0,0 @@ -#!/usr/bin/env ruby -raise 'Please, use ruby1.8.4 or later.' if RUBY_VERSION < '1.8.4' -=begin - Rantfile installer for SiSU - * Homepage: - - * Download: - - Copyright (C) 2007 Ralph Amissah - - * License: LGPL - GNU Lesser General Public License - [same license as Rant provided within the Rant package] - - * Ralph Amissah - Ralph Amissah - - Rant is a Ruby 'ant' by Stefan Lang - * Rant may be downloaded and installed from: - http://make.rubyforge.org/ - - Notes on use: - rant -T - - SiSU can also be Setup/Installation using: - * Minero Aoki's setup.rb, provided along with SiSU, or - -=end -#%% produce a makefile suitable for the target platform -#require 'mkmf' -#create_makefile("sisu") -require 'find' -require 'fileutils' -#require 'ftools' -require 'rbconfig.rb' -require 'yaml' -include FileUtils -class Project_details - def name - 'SiSU' - end - def rant - "Rantfile for the installation/setup of #{name}" - end - def platform_notice - "[#{name} is for the Linux/Unix Platforms]" - end - def dir_proj - 'sisu' - end - def env - Config::CONFIG - end - def host - env['host'] - end - def dir_arch - env['archdir'] - end - def dir_sitearch - env['sitearchdir'] - end - def dir_bin - env['bindir'] - end - def dir_lib - env['sitelibdir'] - end - def dir_data - env['datadir'] - end - def dir_share - "#{env['datadir']}/sisu" - end - def dir_conf - env['sysconfdir'] - end - def dir_man - env['mandir'] - end - def dir_vim - "#{env['datadir']}/sisu/vim" - end - def dir_out - "#{env['localstatedir']}/#{dir_proj}" - end - def dir_rubylib - env['LIBRUBYARG_SHARED'] - end - def dir_pwd - Dir.pwd #ENV['PWD'] - end - def version - stamp={} - v="#{dir_pwd}/conf/sisu/version.yml" - version=if File.exist?(v) - stamp=YAML::load(File::open(v)) - stamp[:version] - else '' - end - end -end -@p=Project_details.new -def answer?(ask) - resp='redo' - print ask + " ['yes', 'no' or 'quit']: " - resp=File.new('/dev/tty').gets.strip - #resp=gets.strip - ans=if resp == 'yes'; true - elsif resp == 'no'; false - elsif resp =~/^quit|exit$/; exit - else puts "[please type: 'yes', 'no' or 'quit']" - answer?(ask) - end -end -def default_notice - ans= %{#{@p.rant} - Information on alternative actions is available using: - "rant help" or "rant -T" - Default action selected - "install and to setup #{@p.name}" proceed? } - resp=answer?(ans) - exit unless resp -end -def get_username - gets.strip -end -def chmod_file(place) - if place =~/\/bin/; File.chmod(0755,place) - else File.chmod(0644,place) - end -end -def chmod_util(place) - if place =~/\/bin/; chmod(0755,place) - else chmod(0644,place) - end -end - #%% using a directory and its mapping -def setup_find_create(dir_get,dir_put) #primary, - Find.find("#{@p.dir_pwd}/#{dir_get}") do |f| - stub=f.scan(/#{@p.dir_pwd}\/#{dir_get}\/(\S+)/).join - place="#{dir_put}/#{stub}" - action=case - when File.file?(f) - cp(f,place) - chmod_file(place) - "-> #{dir_put}/" - when File.directory?(f) - FileUtils.mkpath(place) unless FileTest.directory?(place) - "./#{dir_get}/" - else '?' - end - puts "#{action}#{stub}" - end -end -def setup_find_cp_r(dir_get,dir_put) #secondary, using recursive copy - Find.find("#{@p.dir_pwd}/#{dir_get}") do |f| - stub=f.scan(/#{@p.dir_pwd}\/#{dir_get}\/(\S+)/).join - place="#{dir_put}/#{stub}" - case - when File.file?(f) - cp_r(f,place) - chmod_util(place) - when File.directory?(f) - mkdir(place) unless FileTest.directory?(place) - end - end -end -def rant_system_info - puts < [:default_notice,:project] -#task :default => [:help,:notice,:project] -desc "Setup/Install #{@p.name} and try generate a file" -task :project=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_data,:setup_man,:setup_vim,:post_install_note] -desc "Setup/Install #{@p.name}" -task :setup=> [:setup_bin, :setup_lib,:setup_conf,:setup_share,:setup_data] #, :help] -desc "Setup/Install #{@p.name}: bin, lib and conf (no data)" -task :setup_base=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_man,:setup_vim] -desc "Setup/Install #{@p.name} bin, lib and conf (no data and no attempt to do postinstall setup)" -task :base=> [:setup_base] -if File.directory?('bin') #bin - desc "Setup #{@p.name} bin only, synonym :bin" - task :setup_bin => [:setup_bin] - task :bin => [:setup_bin] -end -if File.directory?('lib') #lib - desc "Setup #{@p.name} lib only, synonym :lib" - task :setup_lib => [:setup_lib] - task :lib => [:setup_lib] -end -if File.directory?('conf') #conf or etc - desc "Setup #{@p.name} conf only, synonyms :conf & :etc" - task :setup_conf => [:setup_conf] - task :conf => [:setup_conf] - task :setup_etc => [:setup_conf] - task :etc => [:setup_conf] -end -if File.directory?('data') #data - desc "Setup #{@p.name} data only, synonyms :data & :examples" - task :setup_data => [:setup_data] - task :data => [:setup_data] - task :setup_examples => [:setup_data] - task :examples => [:setup_data] -end -if File.directory?('data/sisu') #share (odf shared-images) - desc "Setup #{@p.name} shared data only (odf & shared images)" - task :setup_share => [:setup_share] - task :share => [:setup_share] -end -if File.directory?('man') #man pages - desc "Setup #{@p.name} man pages only, synonyms :man" - task :setup_man => [:setup_man] - task :man => [:setup_man] -end -if File.directory?('data/vim') #man pages - desc "Setup #{@p.name} vim config files only, synonyms :vim" - task :setup_vim => [:setup_vim] - task :vim => [:setup_vim] -end -desc "Setup/Install #{@p.name}: bin, lib, conf and data (no attempt to do postinstall setup)" -task :setup_only=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_data,:help] -desc "Remove #{@p.name} (all versions)" #remove project -task :remove_package => [:remove_bin, :remove_lib, :remove_conf] -if File.directory?('bin') #bin - desc "Remove #{@p.name} bin only" #remove bin - task :remove_bin => [:remove_bin] -end -if File.directory?('lib') #lib - desc "Remove #{@p.name} lib only" #remove lib - task :remove_lib => [:remove_lib] -end -if File.directory?('conf') #conf - desc "Remove #{@p.name} conf only" #remove conf - task :remove_conf => [:remove_conf] -end -#if File.directory?('data') #data -# desc "Remove #{@p.name} data only" #remove data -# task :remove_data => [:remove_data] -#end -desc "Re-setup #{@p.name}, synonym :reinstall" #resetup reinstall -task :resetup => [:remove, :setup] -task :reinstall => [:remove, :setup] -desc "Re-setup #{@p.name}: bin, lib, conf (ignore data), synonym :reinstall" #partial reinstall -task :resetup_base => [:remove, :setup_base] -task :reinstall_base => [:remove, :setup_base] -if File.directory?('bin') #bin - desc "Re-setup #{@p.name} bin, synonym :reinstall" - task :resetup_bin => [:remove_bin, :setup_bin] - task :reinstall_bin => [:remove_bin, :setup_bin] -end -if File.directory?('lib') #lib - desc "Re-setup #{@p.name} lib, synonym :reinstall_lib" - task :resetup_lib => [:remove_lib, :setup_lib] - task :reinstall_lib => [:remove_lib, :setup_lib] -end -if File.directory?('conf') #conf - desc "Re-setup #{@p.name} conf, synonyms :reinstall_conf & :resetup_etc" - task :resetup_conf => [:remove_conf, :setup_conf] - task :reinstall_conf => [:remove_conf, :setup_conf] - task :resetup_etc => [:remove_conf, :setup_conf] - task :reinstall_etc => [:remove_conf, :setup_conf] -end -if File.directory?('data/sisu') #share - desc "Re-setup #{@p.name} shared data, (odf & images)" - task :resetup_share => [:remove_share, :setup_share] - task :reinstall_share => [:remove_share, :setup_share] -end -if File.directory?('man') #man - desc "Re-setup #{@p.name} man, synonym :reinstall_man" - task :resetup_man => [:remove_man, :setup_man] - task :reinstall_man => [:remove_man, :setup_man] -end -desc 'Setup Note' -task :setup_note => [:help] -desc "System information used by #{@p.name}" -task :system => [:system_info,:project_help,:post_install_note] -desc "show all system info available - parameters found" -task :system_param => [:system_param] -desc 'Help' -task :help => [:project_help,:system_info,:rant_tasks] -#desc "Setup/Install #{@p.name} (uses filelist)" -task :install => [:default_notice,:project] -task :install_bin => [:setup_bin] -desc '[make rant install file]' -task :create_rant_independent_task_file => [:rant_independence] - #%% setup/install tasks -task :rant_independence do #notice - resp='' - while resp.length < 4 - resp='sisu-install' #default name install - print %{#{@p.rant} - Create a rant dependency independent file - provide filename default name is "install" - [Warning, will overwrite file of name provided - provide name or "quit" to exit]: } - exit if resp =~/^(?:n|quit|exit)$/ - end - remove='y' #remove='n' - if remove =~/y/ - system("rant-import --force --auto #{resp}; - chmod 755 #{resp} - ") - else #puts "#{resp} not replaced" - end -end - -task :default_notice do #notice - default_notice -end -task :rant_default2 do #secondary - setup_find_cp_r('bin',@p.dir_bin) if File.directory?('bin') - setup_find_cp_r('lib',@p.dir_lib) if File.directory?('lib') - setup_find_cp_r('conf',@p.dir_conf) if File.directory?('conf') - setup_find_cp_r('data/sisu',@p.dir_share) if File.directory?('data/sisu') # - setup_find_cp_r('data',@p.dir_data) if File.directory?('data') - setup_find_cp_r('data/vim',"#{@p.dir_data}/vim") if File.directory?('data/vim') - setup_find_cp_r('man',@p.dir_man) if File.directory?('man') -end -task :setup_bin do #bin - setup_find_create('bin',@p.dir_bin) if File.directory?('bin') -end -task :setup_lib do #lib - setup_find_create('lib',@p.dir_lib) if File.directory?('lib') -end -task :setup_conf do #conf - setup_find_create('conf',@p.dir_conf) if File.directory?('conf') -end -task :setup_share do #share - setup_find_create('data/sisu',@p.dir_share) if File.directory?('data/sisu') -end -task :setup_data do #data - setup_find_create('data',@p.dir_data) if File.directory?('data') -end -task :setup_man do #man - setup_find_create('man',@p.dir_man) if File.directory?('man') #man pages - setup_find_create('man.deb/man',@p.dir_man) if File.directory?('man.deb/man') #man pages -end -task :setup_vim do #man - setup_find_create('data/vim',@p.dir_vim) if File.directory?('data/vim') #man pages -end - #%% post install - #%% clobber/remove tasks -task :remove_bin do - rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") -end -task :remove_lib do - rm_r "#{@p.dir_lib}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}") -end -task :remove_conf do - rm_r "#{@p.dir_conf}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") -end -task :remove_man do - rm_r "#{@p.dir_man}/**/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_man}/man1/#{@p.dir_proj}") -end -task :remove_version do - rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") - rm_r "#{@p.dir_lib}/#{@p.dir_proj}/#{@p.version}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}/#{@p.version}") - rm_r "#{@p.dir_conf}/#{@p.dir_proj} if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") -end -task :remove_package do - rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") - rm_r "#{@p.dir_lib}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}") - rm_r "#{@p.dir_conf}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") -end -task :post_install_note do - puts < + + * Download: + + Copyright (C) 2007 Ralph Amissah + + * License: LGPL - GNU Lesser General Public License + [same license as Rant provided within the Rant package] + + * Ralph Amissah + Ralph Amissah + + Rant is a Ruby 'ant' by Stefan Lang + * Rant may be downloaded and installed from: + http://make.rubyforge.org/ + + Notes on use: + rant -T + + SiSU can also be Setup/Installation using: + * Minero Aoki's setup.rb, provided along with SiSU, or + +=end +#%% produce a makefile suitable for the target platform +#require 'mkmf' +#create_makefile("sisu") +require 'find' +require 'fileutils' +#require 'ftools' +require 'rbconfig.rb' +require 'yaml' +include FileUtils +class Project_details + def name + 'SiSU' + end + def rant + "Rantfile for the installation/setup of #{name}" + end + def platform_notice + "[#{name} is for the Linux/Unix Platforms]" + end + def dir_proj + 'sisu' + end + def env + Config::CONFIG + end + def host + env['host'] + end + def dir_arch + env['archdir'] + end + def dir_sitearch + env['sitearchdir'] + end + def dir_bin + env['bindir'] + end + def dir_lib + env['sitelibdir'] + end + def dir_data + env['datadir'] + end + def dir_share + "#{env['datadir']}/sisu" + end + def dir_conf + env['sysconfdir'] + end + def dir_man + env['mandir'] + end + def dir_vim + "#{env['datadir']}/sisu/vim" + end + def dir_out + "#{env['localstatedir']}/#{dir_proj}" + end + def dir_rubylib + env['LIBRUBYARG_SHARED'] + end + def dir_pwd + Dir.pwd #ENV['PWD'] + end + def version + stamp={} + v="#{dir_pwd}/conf/sisu/version.yml" + version=if File.exist?(v) + stamp=YAML::load(File::open(v)) + stamp[:version] + else '' + end + end +end +@p=Project_details.new +def answer?(ask) + resp='redo' + print ask + " ['yes', 'no' or 'quit']: " + resp=File.new('/dev/tty').gets.strip + #resp=gets.strip + ans=if resp == 'yes'; true + elsif resp == 'no'; false + elsif resp =~/^quit|exit$/; exit + else puts "[please type: 'yes', 'no' or 'quit']" + answer?(ask) + end +end +def default_notice + ans= %{#{@p.rant} + Information on alternative actions is available using: + "rant help" or "rant -T" + Default action selected - "install and to setup #{@p.name}" proceed? } + resp=answer?(ans) + exit unless resp +end +def get_username + gets.strip +end +def chmod_file(place) + if place =~/\/bin/; File.chmod(0755,place) + else File.chmod(0644,place) + end +end +def chmod_util(place) + if place =~/\/bin/; chmod(0755,place) + else chmod(0644,place) + end +end + #%% using a directory and its mapping +def setup_find_create(dir_get,dir_put) #primary, + Find.find("#{@p.dir_pwd}/#{dir_get}") do |f| + stub=f.scan(/#{@p.dir_pwd}\/#{dir_get}\/(\S+)/).join + place="#{dir_put}/#{stub}" + action=case + when File.file?(f) + cp(f,place) + chmod_file(place) + "-> #{dir_put}/" + when File.directory?(f) + FileUtils.mkpath(place) unless FileTest.directory?(place) + "./#{dir_get}/" + else '?' + end + puts "#{action}#{stub}" + end +end +def setup_find_cp_r(dir_get,dir_put) #secondary, using recursive copy + Find.find("#{@p.dir_pwd}/#{dir_get}") do |f| + stub=f.scan(/#{@p.dir_pwd}\/#{dir_get}\/(\S+)/).join + place="#{dir_put}/#{stub}" + case + when File.file?(f) + cp_r(f,place) + chmod_util(place) + when File.directory?(f) + mkdir(place) unless FileTest.directory?(place) + end + end +end +def rant_system_info + puts < [:default_notice,:project] +#task :default => [:help,:notice,:project] +desc "Setup/Install #{@p.name} and try generate a file" +task :project=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_data,:setup_man,:setup_vim,:post_install_note] +desc "Setup/Install #{@p.name}" +task :setup=> [:setup_bin, :setup_lib,:setup_conf,:setup_share,:setup_data] #, :help] +desc "Setup/Install #{@p.name}: bin, lib and conf (no data)" +task :setup_base=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_man,:setup_vim] +desc "Setup/Install #{@p.name} bin, lib and conf (no data and no attempt to do postinstall setup)" +task :base=> [:setup_base] +if File.directory?('bin') #bin + desc "Setup #{@p.name} bin only, synonym :bin" + task :bin => [:setup_bin] +end +if File.directory?('lib') #lib + desc "Setup #{@p.name} lib only, synonym :lib" + task :lib => [:setup_lib] +end +if File.directory?('conf') #conf or etc + desc "Setup #{@p.name} conf only, synonyms :conf & :etc" + task :conf => [:setup_conf] + task :setup_etc => [:setup_conf] + task :etc => [:setup_conf] +end +if File.directory?('data') #data + desc "Setup #{@p.name} data only, synonyms :data & :examples" + task :data => [:setup_data] + task :setup_examples => [:setup_data] + task :examples => [:setup_data] +end +if File.directory?('data/sisu') #share (odf shared-images) + desc "Setup #{@p.name} shared data only (odf & shared images)" + task :share => [:setup_share] +end +if File.directory?('man') #man pages + desc "Setup #{@p.name} man pages only, synonyms :man" + task :man => [:setup_man] +end +if File.directory?('data/vim') #man pages + desc "Setup #{@p.name} vim config files only, synonyms :vim" + task :setup_vim => [:setup_vim] + task :vim => [:setup_vim] +end +desc "Setup/Install #{@p.name}: bin, lib, conf and data (no attempt to do postinstall setup)" +task :setup_only=> [:setup_bin,:setup_lib,:setup_conf,:setup_share,:setup_data,:help] +desc "Remove #{@p.name} (all versions)" #remove project +task :remove_package => [:remove_bin, :remove_lib, :remove_conf] +if File.directory?('bin') #bin + desc "Remove #{@p.name} bin only" #remove bin + task :remove_bin => [:remove_bin] +end +if File.directory?('lib') #lib + desc "Remove #{@p.name} lib only" #remove lib + task :remove_lib => [:remove_lib] +end +if File.directory?('conf') #conf + desc "Remove #{@p.name} conf only" #remove conf + task :remove_conf => [:remove_conf] +end +#if File.directory?('data') #data +# desc "Remove #{@p.name} data only" #remove data +# task :remove_data => [:remove_data] +#end +desc "Re-setup #{@p.name}, synonym :reinstall" #resetup reinstall +task :resetup => [:remove, :setup] +task :reinstall => [:remove, :setup] +desc "Re-setup #{@p.name}: bin, lib, conf (ignore data), synonym :reinstall" #partial reinstall +task :resetup_base => [:remove, :setup_base] +task :reinstall_base => [:remove, :setup_base] +if File.directory?('bin') #bin + desc "Re-setup #{@p.name} bin, synonym :reinstall" + task :resetup_bin => [:remove_bin, :setup_bin] + task :reinstall_bin => [:remove_bin, :setup_bin] +end +if File.directory?('lib') #lib + desc "Re-setup #{@p.name} lib, synonym :reinstall_lib" + task :resetup_lib => [:remove_lib, :setup_lib] + task :reinstall_lib => [:remove_lib, :setup_lib] +end +if File.directory?('conf') #conf + desc "Re-setup #{@p.name} conf, synonyms :reinstall_conf & :resetup_etc" + task :resetup_conf => [:remove_conf, :setup_conf] + task :reinstall_conf => [:remove_conf, :setup_conf] + task :resetup_etc => [:remove_conf, :setup_conf] + task :reinstall_etc => [:remove_conf, :setup_conf] +end +if File.directory?('data/sisu') #share + desc "Re-setup #{@p.name} shared data, (odf & images)" + task :resetup_share => [:remove_share, :setup_share] + task :reinstall_share => [:remove_share, :setup_share] +end +if File.directory?('man') #man + desc "Re-setup #{@p.name} man, synonym :reinstall_man" + task :resetup_man => [:remove_man, :setup_man] + task :reinstall_man => [:remove_man, :setup_man] +end +desc 'Setup Note' +task :setup_note => [:help] +desc "System information used by #{@p.name}" +task :system => [:system_info,:project_help,:post_install_note] +desc "show all system info available - parameters found" +task :system_param => [:system_param] +desc 'Help' +task :help => [:project_help,:system_info,:rant_tasks] +#desc "Setup/Install #{@p.name} (uses filelist)" +task :install => [:default_notice,:project] +task :install_bin => [:setup_bin] +desc '[make rant install file]' +task :create_rant_independent_task_file => [:rant_independence] + #%% setup/install tasks +task :rant_independence do #notice + resp='' + while resp.length < 4 + resp='sisu-install' #default name install + print %{#{@p.rant} + Create a rant dependency independent file + provide filename default name is "install" + [Warning, will overwrite file of name provided + provide name or "quit" to exit]: } + exit if resp =~/^(?:n|quit|exit)$/ + end + remove='y' #remove='n' + if remove =~/y/ + system("rant-import --force --auto #{resp}; + chmod 755 #{resp} + ") + else #puts "#{resp} not replaced" + end +end + +task :default_notice do #notice + default_notice +end +task :rant_default2 do #secondary + setup_find_cp_r('bin',@p.dir_bin) if File.directory?('bin') + setup_find_cp_r('lib',@p.dir_lib) if File.directory?('lib') + setup_find_cp_r('conf',@p.dir_conf) if File.directory?('conf') + setup_find_cp_r('data/sisu',@p.dir_share) if File.directory?('data/sisu') # + setup_find_cp_r('data',@p.dir_data) if File.directory?('data') + setup_find_cp_r('data/vim',"#{@p.dir_data}/vim") if File.directory?('data/vim') + setup_find_cp_r('man',@p.dir_man) if File.directory?('man') +end +task :setup_bin do #bin + setup_find_create('bin',@p.dir_bin) if File.directory?('bin') +end +task :setup_lib do #lib + setup_find_create('lib',@p.dir_lib) if File.directory?('lib') +end +task :setup_conf do #conf + setup_find_create('conf',@p.dir_conf) if File.directory?('conf') +end +task :setup_share do #share + setup_find_create('data/sisu',@p.dir_share) if File.directory?('data/sisu') +end +task :setup_data do #data + setup_find_create('data',@p.dir_data) if File.directory?('data') +end +task :setup_man do #man + setup_find_create('man',@p.dir_man) if File.directory?('man') #man pages + setup_find_create('man.deb/man',@p.dir_man) if File.directory?('man.deb/man') #man pages +end +task :setup_vim do #man + setup_find_create('data/vim',@p.dir_vim) if File.directory?('data/vim') #man pages +end + #%% post install + #%% clobber/remove tasks +task :remove_bin do + rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") +end +task :remove_lib do + rm_r "#{@p.dir_lib}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}") +end +task :remove_conf do + rm_r "#{@p.dir_conf}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") +end +task :remove_man do + rm_r "#{@p.dir_man}/**/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_man}/man1/#{@p.dir_proj}") +end +task :remove_version do + rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") + rm_r "#{@p.dir_lib}/#{@p.dir_proj}/#{@p.version}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}/#{@p.version}") + rm_r "#{@p.dir_conf}/#{@p.dir_proj} if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") +end +task :remove_package do + rm_r "#{@p.dir_bin}/#{@p.dir_proj}" if FileTest.file?("#{@p.dir_bin}/#{@p.dir_proj}") + rm_r "#{@p.dir_lib}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_lib}/#{@p.dir_proj}") + rm_r "#{@p.dir_conf}/#{@p.dir_proj}" if FileTest.directory?("#{@p.dir_conf}/#{@p.dir_proj}") +end +task :post_install_note do + puts < + + and: + + +WOK +end +task :system_info do #%% system info + rant_system_info +end +task :system_param do + @env.each {|c| puts c.inspect } +end +task :project_help do #%% help + rant_project_help +end +task :rant_tasks do #%% help + rant_tasks +end -- cgit v1.2.3