diff options
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v4 | 5 | ||||
| -rw-r--r-- | lib/sisu/v4/remote.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v4/sysenv.rb | 370 | 
3 files changed, 189 insertions, 188 deletions
| diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index fc773627..fda7ce46 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -34,6 +34,11 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.14.orig.tar.xz  * v4: manifest, links for output_by? alternatives, harvest & qrcode related +* v4: sysenv, rsync remote placement, output_by? alternatives, tuning, including +  * site_harvest +  * pdf fix +  * backround rsync only for processing of single sisu markup files +  %% 4.0.13.orig.tar.xz (2013-03-13:10/3)  http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_4.0.13  http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_4.0.13-1 diff --git a/lib/sisu/v4/remote.rb b/lib/sisu/v4/remote.rb index 1ef40898..3906e966 100644 --- a/lib/sisu/v4/remote.rb +++ b/lib/sisu/v4/remote.rb @@ -90,7 +90,7 @@ module SiSU_Remote      end      def rsync_harvest        SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement metadata harvest ->','rsync_harvest').dark_grey_title_hi unless @opt.cmd =~/q/ -      @remote.rsync_harvest +      @remote.rsync.site_harvest      end      def scp        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 7fc11eb6..e95a0b1e 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -656,8 +656,11 @@ module SiSU_Env    end    class SystemCall      @@locale_flag=false -    def initialize(input='',output='',cmd='') -      @input,@output,@cmd=input,output,cmd +    def initialize(input='',output='',opt_or_cmd='') +      @input,@output=input,output +      (opt_or_cmd.is_a?(SiSU_Commandline::Options)) \ +      ? (@cmd,@opt=opt_or_cmd.cmd,opt_or_cmd) +      : (@cmd,@opt=opt_or_cmd,nil) #cmd.is_a?(String)        @prog=SiSU_Env::InfoProgram.new        @sys=InfoSystem.instance      end @@ -875,7 +878,10 @@ module SiSU_Env          end          cX=SiSU_Screen::Ansi.new(@cmd).cX          msg=(@cmd =~/q/) ? '' : %{ && echo " #{cX.grey}OK: #{@input} -> #{@output}#{cX.off}"} -        amp=(@cmd =~/[vVM]/) ? '' : '&' +        amp=(@opt \ +        && @opt.files.length > 1) \ +        ? '' +        : ((@cmd =~/[vVM]/) ? '' : '&')          rsync_cmd="rsync -az#{vb} #{action} #{@input} #{@output}"          puts rsync_cmd if @cmd =~/[vVM]/          dir_change,dir_return='','' @@ -3258,150 +3264,181 @@ WOK        self      end      def rsync -      @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 -          #local_gen_image="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" -          #local_gen_image_external="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" -          remote_gen="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." -          remote_rel=remote_conn[:name] + '/' + @f.output_path.stub.rcp -          src_txt=@opt.fnc -          if (local_gen =~/\S/ \ -          and local_gen !~/\/\//) \ -          and (remote_gen =~/\S/ \ -          and remote_gen !~/\/\//) \ -          and @@flag_remote==true \ -          and @opt.cmd !~/U/ -#           SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync -            delete_extra_files='--delete' # '--delete-after' -            inp=[] -            if (@opt.act[:html][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.html_scroll.dir) -              inp << @f.output_path.html_seg.rel << @f.place_file.html_scroll.rel -            end -            if (@opt.act[:concordance][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.html_concordance.dir) -              inp << @f.place_file.html_concordance.rel -            end -            if (@opt.act[:epub][:set]==:on \ -            || @opt.cmd =~/^-R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.epub.dir) -              inp << @f.place_file.epub.rel -            end -            if (@opt.act[:odt][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.odt.dir) -              inp << @f.place_file.odt.rel -            end -            if (@opt.act[:xhtml][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.xhtml.dir) -              inp << @f.place_file.xhtml.rel -            end -            if (@opt.act[:xml_sax][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.xml_sax.dir) -              inp << @f.place_file.xml_sax.rel -            end -            if (@opt.act[:xml_dom][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.xml_dom.dir) -              inp << @f.place_file.xml_dom.rel -            end -            if (@opt.act[:txt][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.txt.dir) -              inp << @f.place_file.txt.rel -            end -            if (@opt.act[:manpage][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*i[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.manpage.dir) -              inp << @f.place_file.manpage.rel -            end -            if (@opt.act[:texinfo][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*I[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.info.dir) -              inp << @f.place_file.info.rel -            end -            if (@opt.act[:hash_digests][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.hash_digest.dir) -              inp << @f.place_file.hash_digest.rel -            end -            if (@opt.act[:share_source][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.src.dir) -              inp << @f.place_file.src.rel -            end -            if (@opt.act[:sisupod][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.sisupod.dir) -              inp << @f.place_file.sisupod.rel -            end -            if (@opt.act[:pdf][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) -              inp << @f.output_path.pdf.rel + '/' + @opt.fnb + '*' -            end -            if (@opt.act[:sqlite_discrete][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.sqlite_discrete.dir) -              inp << @f.place_file.sqlite_discrete.rel -            end -            if (@opt.act[:qrcode][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.qrcode_md.dir) -              inp << @f.place_file.qrcode_md.rel << @f.place_file.qrcode_title.rel -            end -            if (@opt.act[:manifest][:set]==:on \ -            || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ -            && FileTest.file?(@f.place_file.manifest.dir) -              inp << @f.place_file.manifest.rel -            end -            local_gen=if inp.length > 0 -              inp.join(' ') -            else '' -            end -            local_css,images,images_external,images_system='','','','' -            images_gen=images=images_skin=images_system=local_css='' -            if @opt.cmd =~/[hwbxX]/ \ -            && (defined? @md.ec[:image]) \ -            && (@md.ec[:image].length > 0) -              images=@f.place_file.images.rel + '/' + @md.ec[:image].join(" #{@f.output_path.images.rel}/") -            end -            if @opt.cmd =~/[yhwbxX]/ \ -            && (defined? @md.ec[:image]) \ -            && (@md.ec[:image].length > 0) -              local_css=@f.output_path.css.rel -              images_system='_sisu/image_sys' -            end -            begin -              ##create file structure without copying files?: -              ##rsync -av -f"+ */" -f"- *" @f.output_path.base.dir remote:./path/. -              #local_dirs=%{-f"+ */" -f"- *" #{@f.output_path.base.dir}/*} -              #SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync -              local=local_gen + ' ' + images + ' ' + images_skin + ' ' + images_system + ' ' + local_css -              SiSU_Env::SystemCall.new(local,remote_rel,@opt.cmd).rsync('--relative',@f.output_path.base.dir) -            rescue -              p __LINE__.to_s + ':' + __FILE__ -              local_dirs=%{--include='*/' --exclude='*' #{@f.output_path.base.dir}} -              SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync +        f=(@opt.act[:dal][:set]==:on) \ +        ? SiSU_Env::FileOp.new(@md) +        : nil +        if f +          self.remote_host_base.each do |remote_conn| +            local_gen=@source_path +            #local_gen_image="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" +            #local_gen_image_external="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" +            remote_gen="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." +            remote_rel=remote_conn[:name] + '/' + f.output_path.stub.rcp +            src_txt=@opt.fnc +            if (local_gen =~/\S/ \ +            and local_gen !~/\/\//) \ +            and (remote_gen =~/\S/ \ +            and remote_gen !~/\/\//) \ +            and @@flag_remote==true \ +            and @opt.cmd !~/U/ +#             SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync +              delete_extra_files='--delete' # '--delete-after' +              inp=[] +              if (@opt.act[:html][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.html_scroll.dir) +                inp << f.output_path.html_seg.rel << f.place_file.html_scroll.rel +              end +              if (@opt.act[:concordance][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.html_concordance.dir) +                inp << f.place_file.html_concordance.rel +              end +              if (@opt.act[:epub][:set]==:on \ +              || @opt.cmd =~/^-R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.epub.dir) +                inp << f.place_file.epub.rel +              end +              if (@opt.act[:odt][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.odt.dir) +                inp << f.place_file.odt.rel +              end +              if (@opt.act[:xhtml][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.xhtml.dir) +                inp << f.place_file.xhtml.rel +              end +              if (@opt.act[:xml_sax][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.xml_sax.dir) +                inp << f.place_file.xml_sax.rel +              end +              if (@opt.act[:xml_dom][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.xml_dom.dir) +                inp << f.place_file.xml_dom.rel +              end +              if (@opt.act[:txt][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.txt.dir) +                inp << f.place_file.txt.rel +              end +              if (@opt.act[:manpage][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*i[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.manpage.dir) +                inp << f.place_file.manpage.rel +              end +              if (@opt.act[:texinfo][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*I[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.info.dir) +                inp << f.place_file.info.rel +              end +              if (@opt.act[:hash_digests][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.hash_digest.dir) +                inp << f.place_file.hash_digest.rel +              end +              if (@opt.act[:share_source][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.src.dir) +                inp << f.place_file.src.rel +              end +              if (@opt.act[:sisupod][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.sisupod.dir) +                inp << f.place_file.sisupod.rel +              end +              if (@opt.act[:pdf][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) +                inp <<=(@opt.dir_structure_by == :filename) \ +                ? (f.output_path.pdf.rel + '/*.pdf') +                : (f.output_path.pdf.rel + '/' + @opt.fnb + '*.pdf') +              end +              if (@opt.act[:sqlite_discrete][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.sqlite_discrete.dir) +                inp << f.place_file.sqlite_discrete.rel +              end +              if (@opt.act[:qrcode][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.qrcode_md.dir) +                inp << f.place_file.qrcode_md.rel << f.place_file.qrcode_title.rel +              end +              if (@opt.act[:manifest][:set]==:on \ +              || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ +              && FileTest.file?(f.place_file.manifest.dir) +                inp << f.place_file.manifest.rel +              end +              local_gen=if inp.length > 0 +                inp.join(' ') +              else '' +              end +              local_css,images,images_external,images_system='','','','' +              images_gen=images=images_skin=images_system=local_css='' +              if @opt.cmd =~/[hwbxX]/ \ +              && (defined? @md.ec[:image]) \ +              && (@md.ec[:image].length > 0) +                images=f.place_file.images.rel + '/' + @md.ec[:image].join(" #{f.output_path.images.rel}/") +              end +              if @opt.cmd =~/[yhwbxX]/ \ +              && (defined? @md.ec[:image]) \ +              && (@md.ec[:image].length > 0) +                local_css=f.output_path.css.rel +                images_system='_sisu/image_sys' +              end +              begin +                ##create file structure without copying files?: +                ##rsync -av -f"+ */" -f"- *" f.output_path.base.dir remote:./path/. +                #local_dirs=%{-f"+ */" -f"- *" #{f.output_path.base.dir}/*} +                #SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync +                local=local_gen + ' ' + images + ' ' + images_skin + ' ' + images_system + ' ' + local_css +                SiSU_Env::SystemCall.new(local,remote_rel,@opt.cmd).rsync('--relative',f.output_path.base.dir) +              rescue +                p __LINE__.to_s + ':' + __FILE__ +                local_dirs=%{--include='*/' --exclude='*' #{f.output_path.base.dir}} +                SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync +              end +            elsif @opt.cmd =~/U/ +              puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ +              puts "#{local_gen} -> #{remote_gen}" +              if FileTest.file?("#{local_src}/#{src_doc}") \ +              or FileTest.file?("#{local_src}/#{src_doc}.txz") +                puts "#{local_src}/#{src_doc}* -> #{remote_src}" +              end +            else +              puts 'suspect rsync request, ignored' +              puts "#{local_gen} -> #{remote_gen} remote flag: #{@@flag_remote}" +              puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/              end +          end +        end +      end +      def site_harvest +        self.remote_host_base.each do |remote_conn| +          local=@source_path_harvest +          l_rel="#{@env.path.webserv}/#{@env.path.stub_pwd}" +          lng='en' +          if @env.output_dir_structure.by? == :language +            ldest="#{lng}/manifest" +            files="#{ldest}/authors.html #{ldest}/topics.html" +          elsif @env.output_dir_structure.by? == :filetype +            ldest="manifest" +            files="#{ldest}/authors.#{lng}.html #{ldest}/topics.#{lng}.html" +          elsif @env.output_dir_structure.by? == :filename +            files="#{l_rel}/authors.#{lng}.html #{l_rel}/topics.#{lng}.html" +          end +          remote="#{remote_conn[:name]}/#{@opt.base_stub}" +          if @opt.act[:harvest][:set] \ +          && @opt.act[:rsync][:set] +            (@env.output_dir_structure.by? == :filename) \ +            ? (SiSU_Env::SystemCall.new(files,remote).rsync) +            : (SiSU_Env::SystemCall.new(ldest,remote).rsync('--relative',l_rel))            elsif @opt.cmd =~/U/              puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ -            puts "#{local_gen} -> #{remote_gen}" -            if FileTest.file?("#{local_src}/#{src_doc}") \ -            or FileTest.file?("#{local_src}/#{src_doc}.txz") -              puts "#{local_src}/#{src_doc}* -> #{remote_src}" -            end -          else -            puts 'suspect rsync request, ignored' -            puts "#{local_gen} -> #{remote_gen} remote flag: #{@@flag_remote}" -            puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ +            puts "rsync_harvest: #{local} -> #{remote}" +          else  puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/            end          end        end @@ -3417,16 +3454,6 @@ WOK              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" -          SiSU_Env::SystemCall.new("#{harvest}","#{remote_manifest}").rsync -        end -      end        def site_base_sync          self.remote_host_base.each do |remote_conn|            local=@source_path @@ -3466,37 +3493,6 @@ WOK          end        end      end -    def rsync_harvest -      self.remote_host_base.each do |remote_conn| -        local=@source_path_harvest -        @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(files,remote).rsync(delete_extra_files) -        elsif @opt.cmd =~/U/ -          puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ -          puts "rsync_sitemaps: #{local} -> #{remote}" -        else  puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ -        end -      end -    end    end    class InfoVersion <InfoEnv      include Singleton @@ -4222,7 +4218,7 @@ WOK          @@filename_html_scroll=File.new(p_fn,'w+')        end        def html_seg_index -        pth=((by_filename?) \ +        pth=((output_dir_structure.by_filename?) \            || (output_dir_structure.dump?)) \          ? "#{output_path.html.dir}"          : "#{output_path.html.dir}/#{@md.fnb}" @@ -4232,7 +4228,7 @@ WOK          @@filename_html_index=File.new(p_fn,'w+')        end        def html_segtoc -        pth=((by_filename?) \ +        pth=((output_dir_structure.by_filename?) \            || (output_dir_structure.dump?) \            || (output_dir_structure.redirect?)) \          ? "#{output_path.html.dir}" @@ -5432,7 +5428,7 @@ WOK            elsif output_dir_structure.by_language_code?              '../../_sisu/image'            elsif output_dir_structure.by_filetype? -            '../../_sisu/image' +            '../_sisu/image'            else              '../_sisu/image'            end | 
