From 0f85875f703ae722ba0ebebcd755dd13911df5a8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 13 Mar 2013 21:43:14 -0400 Subject: v4: hub, sysenv, remote, work on rsync of document/site build --- data/doc/sisu/CHANGELOG_v4 | 2 + lib/sisu/v4/hub.rb | 81 +++++++------ lib/sisu/v4/remote.rb | 6 +- lib/sisu/v4/sysenv.rb | 295 ++++++++++++++++++++++++--------------------- 4 files changed, 204 insertions(+), 180 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index 0da67946..813f4d83 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -34,6 +34,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.13.orig.tar.xz * v4: manifest, link to harvest authors & topics if available, else cosmeitc +* v4: hub, sysenv, remote, work on rsync of document/site build + %% 4.0.12.orig.tar.xz (2013-03-08:09/5) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_4.0.12 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_4.0.12-1 diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb index dee13bc1..cf821246 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v4/hub.rb @@ -191,22 +191,22 @@ module SiSU @@n_do=0 end def remote_put_base_site_rsync # -CR -p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on + puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:cyan) if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).rsync_base end def remote_put_base_site_rsync_match # -CCRZ -p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on + puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:cyan) if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).rsync_base_sync end def remote_put_base_site # -Cr -p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on + puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:cyan) if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).scp_base end def remote_put_base_site_all # -CCr -p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on + puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:cyan) if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).scp_base_all end @@ -629,45 +629,50 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on ensure end end - if @opt.act[:site_init][:set]==:on #% -C - require_relative 'conf' # -s conf.rb - SiSU_Initialize::Source.new(@opt).read - end end def actions if @opt.act[:profile][:set]==:on require 'profile' end - action_on_file_ =(@opt.act[:dal][:set]==:on \ - || @opt.act[:manpage][:set]==:on \ - || @opt.act[:texinfo][:set]==:on \ - || @opt.act[:txt][:set]==:on \ - || @opt.act[:html][:set]==:on \ - || @opt.act[:html_scroll][:set]==:on \ - || @opt.act[:html_seg][:set]==:on \ - || @opt.act[:concordance][:set]==:on \ - || @opt.act[:xhtml][:set]==:on \ - || @opt.act[:epub][:set]==:on \ - || @opt.act[:odt][:set]==:on \ - || @opt.act[:xml_sax][:set]==:on \ - || @opt.act[:xml_dom][:set]==:on \ - || @opt.act[:pdf][:set]==:on \ - || @opt.act[:pdf_p][:set]==:on \ - || @opt.act[:pdf_l][:set]==:on \ - || @opt.act[:psql][:set]==:on \ - || @opt.act[:sqlite][:set]==:on \ - || @opt.act[:sqlite_discrete][:set]==:on \ - || @opt.act[:share_source][:set]==:on \ - || @opt.act[:sisupod][:set]==:on \ - || @opt.act[:qrcode][:set]==:on \ - || @opt.act[:hash_digests][:set]==:on \ - || @opt.act[:manifest][:set]==:on \ - || @opt.act[:rsync][:set]==:on \ - || @opt.act[:scp][:set]==:on \ - || @opt.act[:webrick][:set]==:on \ - || @opt.act[:zap][:set]==:on) \ - ? (:true) - : (:false) + action_on_file_ =if @opt.act[:rsync][:set]==:on \ + && @opt.act[:site_init][:set]==:on #\ + #|| @opt.act[:harvest][:set]==:on) + :false + elsif @opt.act[:rsync][:set]==:on \ + && @opt.act[:site_init][:set] !=:on #\ + #&& @opt.act[:harvest][:set] !=:on + :true + else + action_on_file_ =(@opt.act[:dal][:set]==:on \ + || @opt.act[:manpage][:set]==:on \ + || @opt.act[:texinfo][:set]==:on \ + || @opt.act[:txt][:set]==:on \ + || @opt.act[:html][:set]==:on \ + || @opt.act[:html_scroll][:set]==:on \ + || @opt.act[:html_seg][:set]==:on \ + || @opt.act[:concordance][:set]==:on \ + || @opt.act[:xhtml][:set]==:on \ + || @opt.act[:epub][:set]==:on \ + || @opt.act[:odt][:set]==:on \ + || @opt.act[:xml_sax][:set]==:on \ + || @opt.act[:xml_dom][:set]==:on \ + || @opt.act[:pdf][:set]==:on \ + || @opt.act[:pdf_p][:set]==:on \ + || @opt.act[:pdf_l][:set]==:on \ + || @opt.act[:psql][:set]==:on \ + || @opt.act[:sqlite][:set]==:on \ + || @opt.act[:sqlite_discrete][:set]==:on \ + || @opt.act[:share_source][:set]==:on \ + || @opt.act[:sisupod][:set]==:on \ + || @opt.act[:qrcode][:set]==:on \ + || @opt.act[:hash_digests][:set]==:on \ + || @opt.act[:manifest][:set]==:on \ + || @opt.act[:scp][:set]==:on \ + || @opt.act[:webrick][:set]==:on \ + || @opt.act[:zap][:set]==:on) \ + ? (:true) + : (:false) + end if @opt.act[:harvest][:set]==:on require_relative 'harvest' # harvest.rb SiSU_Harvest::Source.new(@opt).read # -h -H html.rb diff --git a/lib/sisu/v4/remote.rb b/lib/sisu/v4/remote.rb index 0da44697..1ef40898 100644 --- a/lib/sisu/v4/remote.rb +++ b/lib/sisu/v4/remote.rb @@ -68,9 +68,9 @@ module SiSU_Remote @opt=opt @dir=SiSU_Env::InfoEnv.new(@opt.fns) @put=(@opt.fns =~/\.ssm\.sst$/) \ - ? @opt.fns.gsub(/(.+)?\.ssm\.sst$/,'\1.ssm') - : @opt.fns - @remote=SiSU_Env::InfoRemote.new(@opt) + ? opt.fns.gsub(/(.+)?\.ssm\.sst$/,'\1.ssm') + : opt.fns + @remote=SiSU_Env::InfoRemote.new(opt) end def rsync SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement ->',@put).dark_grey_title_hi unless @opt.cmd =~/q/ diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb index 5647efd7..7fc11eb6 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -873,19 +873,20 @@ module SiSU_Env elsif @cmd =~/v/; 'v' else '' end - msg='' - msg=" && echo 'OK: #{@input} -> #{@output}'" unless @cmd =~/q/ + cX=SiSU_Screen::Ansi.new(@cmd).cX + msg=(@cmd =~/q/) ? '' : %{ && echo " #{cX.grey}OK: #{@input} -> #{@output}#{cX.off}"} + amp=(@cmd =~/[vVM]/) ? '' : '&' rsync_cmd="rsync -az#{vb} #{action} #{@input} #{@output}" puts rsync_cmd if @cmd =~/[vVM]/ dir_change,dir_return='','' - if chdir \ + if not chdir.nil? \ && chdir != Dir.pwd dir_change=Dir.chdir(chdir) dir_return=Dir.pwd end dir_change system(" - #{rsync_cmd} #{msg} + #{rsync_cmd} #{msg} #{amp} ") dir_return else STDERR.puts "\t*WARN* #{program} not found" @@ -2900,121 +2901,124 @@ WOK @env=(@opt.fns && !(@opt.fns.empty?) \ ? (SiSU_Env::InfoEnv.new(@opt.fns)) : (SiSU_Env::InfoEnv.new('dummy.sst'))) - if @opt.cmd =~/m/; @md=SiSU_Param::Parameters.new(@opt).get - end ft=[] - if @md \ - and defined? @md.fn \ - and @md.fn # used for by_language_code? - if @md.opt.cmd =~ /[hH]/ - ft << @md.fn[:html] - end - if @md.opt.cmd =~ /w/ \ - and @md.opt.cmd !~ /[hH]/ - ft << @md.fn[:concordance] - end - if @md.opt.cmd =~ /y/ \ - and @md.opt.cmd !~ /[hH]/ - ft << @md.fn[:manifest] - end - if @md.opt.cmd =~ /[at]/; ft << @md.fn[:plain] - end - if @md.opt.cmd =~ /b/; ft << @md.fn[:xhtml] - end - if @md.opt.cmd =~ /e/; ft << @md.fn[:epub] - end - if @md.opt.cmd =~ /g/; ft << @md.fn[:wiki] - end - if @md.opt.cmd =~ /i/; ft << @md.fn[:manpage] - end - if @md.opt.cmd =~ /N/; ft << @md.fn[:digest] - end - if @md.opt.cmd =~ /o/; ft << @md.fn[:odf] - end - if @md.opt.cmd =~ /O/; ft << @md.fn[:oai_pmh] - end - if @md.opt.cmd =~ /p/; ft << @md.fn[:pdf_l] << @md.fn[:pdf_p] - end - if @md.opt.cmd =~ /s/; ft << @md.fns - end - if @md.opt.cmd =~ /S/; ft << @md.fn[:sisupod] << '.kdi' - end - if @md.opt.cmd =~ /x/; ft << @md.fn[:sax] - end - if @md.opt.cmd =~ /X/; ft << @md.fn[:dom] - end - if @md.opt.cmd =~ /G/; ft << @md.fn[:pot] - end - @fnb=@md.fnb - else # still needed where/when param is not parsed - if @opt.cmd =~ /[hH]/; ft << '.html' << '.html.??' - end - if @opt.cmd =~ /w/ \ - and @opt.cmd !~ /[hH]/ - ft << 'concordance.html' << '??.concordance.html' << 'concordance.??.html' - end - if @opt.cmd =~ /y/ \ - and @opt.cmd !~ /[hH]/ - ft << 'sisu_manifest.html' << '??.sisu_manifest.html' << 'sisu_manifest.??.html' - end - if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' - end - if @opt.cmd =~ /b/; ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml' - end - if @opt.cmd =~ /e/; ft << @fnb << '.epub' - end - if @opt.cmd =~ /g/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt' - end - if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1' - end - if @opt.cmd =~ /N/; ft << 'digest.txt' << '??.digest.txt' << 'digest.??.txt' - end - if @opt.cmd =~ /o/; ft << 'opendocument.odt' << '??.opendocument.odt' << 'opendocument.??.odt' - end - if @opt.cmd =~ /O/; ft << 'oai_pmh.xml' - end - if @opt.cmd =~ /p/; ft << 'landscape.pdf' << 'portrait.pdf' << '.pdf' - end - if @opt.cmd =~ /s/; ft << '.sst' << '.ssi' << '.ssm' - end - if @opt.cmd =~ /S/; ft << '.zip' << '.kdi' - end - if @opt.cmd =~ /x/; ft << 'sax.xml' << '??.sax.xml' << 'sax.??.xml' - end - if @opt.cmd =~ /X/; ft << 'dom.xml' << '??.dom.xml' << 'dom.??.xml' - end - if @opt.mod.inspect =~ /sxm|sxs|xml/; ft << @fnb << '.sxs.xml' - end - if @opt.mod.inspect =~ /sxd/; ft << @fnb << '.sxd.xml' - end - if @opt.mod.inspect =~ /sxn/; ft << @fnb << '.sxn.xml' + if @opt.act[:dal][:set]==:on + @md=SiSU_Param::Parameters.new(@opt).get + if @md \ + and defined? @md.fn \ + and @md.fn # used for by_language_code? + if @md.opt.cmd =~ /[hH]/ + ft << @md.fn[:html] + end + if @md.opt.cmd =~ /w/ \ + and @md.opt.cmd !~ /[hH]/ + ft << @md.fn[:concordance] + end + if @md.opt.cmd =~ /y/ \ + and @md.opt.cmd !~ /[hH]/ + ft << @md.fn[:manifest] + end + if @md.opt.cmd =~ /[at]/; ft << @md.fn[:plain] + end + if @md.opt.cmd =~ /b/; ft << @md.fn[:xhtml] + end + if @md.opt.cmd =~ /e/; ft << @md.fn[:epub] + end + if @md.opt.cmd =~ /g/; ft << @md.fn[:wiki] + end + if @md.opt.cmd =~ /i/; ft << @md.fn[:manpage] + end + if @md.opt.cmd =~ /N/; ft << @md.fn[:digest] + end + if @md.opt.cmd =~ /o/; ft << @md.fn[:odf] + end + if @md.opt.cmd =~ /O/; ft << @md.fn[:oai_pmh] + end + if @md.opt.cmd =~ /p/; ft << @md.fn[:pdf_l] << @md.fn[:pdf_p] + end + if @md.opt.cmd =~ /s/; ft << @md.fns + end + if @md.opt.cmd =~ /S/; ft << @md.fn[:sisupod] << '.kdi' + end + if @md.opt.cmd =~ /x/; ft << @md.fn[:sax] + end + if @md.opt.cmd =~ /X/; ft << @md.fn[:dom] + end + if @md.opt.cmd =~ /G/; ft << @md.fn[:pot] + end + @fnb=@md.fnb + else # still needed where/when param is not parsed + if @opt.cmd =~ /[hH]/; ft << '.html' << '.html.??' + end + if @opt.cmd =~ /w/ \ + and @opt.cmd !~ /[hH]/ + ft << 'concordance.html' << '??.concordance.html' << 'concordance.??.html' + end + if @opt.cmd =~ /y/ \ + and @opt.cmd !~ /[hH]/ + ft << 'sisu_manifest.html' << '??.sisu_manifest.html' << 'sisu_manifest.??.html' + end + if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + end + if @opt.cmd =~ /b/; ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml' + end + if @opt.cmd =~ /e/; ft << @fnb << '.epub' + end + if @opt.cmd =~ /g/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt' + end + if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1' + end + if @opt.cmd =~ /N/; ft << 'digest.txt' << '??.digest.txt' << 'digest.??.txt' + end + if @opt.cmd =~ /o/; ft << 'opendocument.odt' << '??.opendocument.odt' << 'opendocument.??.odt' + end + if @opt.cmd =~ /O/; ft << 'oai_pmh.xml' + end + if @opt.cmd =~ /p/; ft << 'landscape.pdf' << 'portrait.pdf' << '.pdf' + end + if @opt.cmd =~ /s/; ft << '.sst' << '.ssi' << '.ssm' + end + if @opt.cmd =~ /S/; ft << '.zip' << '.kdi' + end + if @opt.cmd =~ /x/; ft << 'sax.xml' << '??.sax.xml' << 'sax.??.xml' + end + if @opt.cmd =~ /X/; ft << 'dom.xml' << '??.dom.xml' << 'dom.??.xml' + end + if @opt.mod.inspect =~ /sxm|sxs|xml/; ft << @fnb << '.sxs.xml' + end + if @opt.mod.inspect =~ /sxd/; ft << @fnb << '.sxd.xml' + end + if @opt.mod.inspect =~ /sxn/; ft << @fnb << '.sxn.xml' + end end + ft=ft.uniq + filetypes=ft.join(',') + @filetypes=if filetypes !~/..+/; '' # -r called alone, copy all + elsif @opt.cmd =~/u/; '' # -u added, copy all, (used to create remote directory tree see output path), not the usual function of -u + elsif filetypes =~/\S+?,\S+/; '*{' + filetypes + '}' # more than one relevant file type + else '*' + filetypes # one relevant file type + end + @source_path=(@fnb && !(@fnb.empty?) \ + ? "#{@env.path.output}/#{@fnb}" + : @env.path.output) + @source_path_epub=(@fnb && !(@fnb.empty?) \ + ? "#{@env.path.output}/epub" + : @env.path.output_epub) + @source_path_src=(@fnb && !(@fnb.empty?) \ + ? "#{@env.path.output}/src" + : @env.path.output_src) + @source_path_pod=(@fnb && !(@fnb.empty?) \ + ? "#{@env.path.output}/pod" + : @env.path.output_pod) + @source_path_harvest=(@fnb && !(@fnb.empty?) \ + ? "#{@env.path.output}/manifest" + : @env.path.output_harvest) + @local_sisu_source=(@filetypes =~/\S/) \ + ? "#{@source_path}/#{@filetypes}" + : @source_path + end + if @opt.act[:rsync][:set]==:on end - ft=ft.uniq - filetypes=ft.join(',') - @filetypes=if filetypes !~/..+/; '' # -r called alone, copy all - elsif @opt.cmd =~/u/; '' # -u added, copy all, (used to create remote directory tree see output path), not the usual function of -u - elsif filetypes =~/\S+?,\S+/; '*{' + filetypes + '}' # more than one relevant file type - else '*' + filetypes # one relevant file type - end - @source_path=(@fnb && !(@fnb.empty?) \ - ? "#{@env.path.output}/#{@fnb}" - : @env.path.output) - @source_path_epub=(@fnb && !(@fnb.empty?) \ - ? "#{@env.path.output}/epub" - : @env.path.output_epub) - @source_path_src=(@fnb && !(@fnb.empty?) \ - ? "#{@env.path.output}/src" - : @env.path.output_src) - @source_path_pod=(@fnb && !(@fnb.empty?) \ - ? "#{@env.path.output}/pod" - : @env.path.output_pod) - @source_path_harvest=(@fnb && !(@fnb.empty?) \ - ? "#{@env.path.output}/manifest" - : @env.path.output_harvest) - @local_sisu_source=(@filetypes =~/\S/) \ - ? "#{@source_path}/#{@filetypes}" - : @source_path end end class CleanOutput @@ -3254,7 +3258,9 @@ WOK self end def rsync - @f=SiSU_Env::FileOp.new(@md) + @f=(@opt.act[:dal][:set]==:on) \ + ? SiSU_Env::FileOp.new(@md) + : nil def document self.remote_host_base.each do |remote_conn| local_gen=@source_path @@ -3372,10 +3378,6 @@ WOK && (@md.ec[:image].length > 0) local_css=@f.output_path.css.rel images_system='_sisu/image_sys' - if @f.output_path.images.rel.length > 0 \ - && images_from_skin.length > 0 - images_skin=@f.place_file.images.rel + '/' + images_from_skin.join(" #{@f.output_path.images.rel}/") - end end begin ##create file structure without copying files?: @@ -3404,27 +3406,25 @@ WOK end end def site_base #base site + ldest='_sisu/*' + l_rel="#{@env.path.webserv}/#{@env.path.stub_pwd}" + image_sys="#{@env.path.webserv}/_sisu/image_sys" + images="#{@env.path.webserv}/_sisu/image" + self.remote_host_base.each do |remote_conn| + remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}" + remote_conf="#{remote_conn[:name]}/_sisu" + SiSU_Env::SystemCall.new(image_sys,remote_conf).rsync + SiSU_Env::SystemCall.new(ldest,remote).rsync('--relative',l_rel) + end + end + def site_harvest ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu" image_sys="#{@env.path.webserv}/_sisu/image_sys" images="#{@env.path.webserv}/_sisu/image" self.remote_host_base.each do |remote_conn| remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." remote_conf="#{remote_conn[:name]}/_sisu" - if defined? @rc['permission_set']['remote_base_site'] \ - and @rc['permission_set']['remote_base_site'] \ - and @@flag_remote==true \ - and @opt.cmd !~/U/ - SiSU_Env::SystemCall.new("#{image_sys}","#{remote_conf}").rsync - SiSU_Env::SystemCall.new("#{images}","#{remote_conf}").rsync - SiSU_Env::SystemCall.new("#{ldest}","#{remote}").rsync - elsif @opt.cmd =~/U/ - puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - puts "rsync_base: #{local} -> #{remote}" - puts "#{local}/_sisu/image -> #{remote}" - puts "#{local}/_sisu/image_sys/ -> #{remote}" - puts "#{local}/#{@env.path.style}/ -> #{remote}" - else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - end + SiSU_Env::SystemCall.new("#{harvest}","#{remote_manifest}").rsync end end def site_base_sync @@ -3469,10 +3469,27 @@ WOK def rsync_harvest self.remote_host_base.each do |remote_conn| local=@source_path_harvest - remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." - if @@flag_remote + @env=SiSU_Env::InfoEnv.new + harvest_pth,file='','' + lng='en' + if @env.output_dir_structure.by? == :language + harvest_out_pth="#{@env.path.webserv}/#{@opt.base_stub}/#{lng}/manifest" + harvest_pth="#{@opt.base_stub}/#{lng}/manifest" + files="#{harvest_out_pth}/authors.html #{harvest_out_pth}/topics.html" + elsif @env.output_dir_structure.by? == :filetype + harvest_out_pth="#{@env.path.webserv}/#{@opt.base_stub}/manifest" + harvest_pth="#{@opt.base_stub}/manifest" + files="#{harvest_out_pth}/authors.#{lng}.html #{harvest_out_pth}/topics.#{lng}.html" + elsif @env.output_dir_structure.by? == :filename + harvest_out_pth="#{@env.path.webserv}/#{@opt.base_stub}" + harvest_pth="#{@opt.base_stub}" + files="#{harvest_out_pth}/authors.#{lng}.html #{harvest_out_pth}/topics.#{lng}.html" + end + remote="#{remote_conn[:name]}/#{harvest_pth}/." + if @opt.act[:harvest][:set] \ + && @opt.act[:rsync][:set] delete_extra_files='--delete' # '--delete-after' - SiSU_Env::SystemCall.new(local,remote).rsync(delete_extra_files) + SiSU_Env::SystemCall.new(files,remote).rsync(delete_extra_files) elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_sitemaps: #{local} -> #{remote}" -- cgit v1.2.3