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 --- lib/sisu/v4/sysenv.rb | 295 ++++++++++++++++++++++++++------------------------ 1 file changed, 156 insertions(+), 139 deletions(-) (limited to 'lib/sisu/v4/sysenv.rb') 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