From 2dee3abf48159ac1e7f2cd9a4d5dd40d01c5a0cd Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 12 May 2012 19:28:12 -0400 Subject: v3: sisupod make, re-fixed, check again --- data/doc/sisu/CHANGELOG_v3 | 2 + lib/sisu/v3/composite.rb | 3 ++ lib/sisu/v3/param.rb | 3 +- lib/sisu/v3/sisupod_make.rb | 53 +++++++++++----------- lib/sisu/v3/sysenv.rb | 106 +++++++++++++++++++++++++++++++------------- 5 files changed, 107 insertions(+), 60 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index fa594e2e..70bf8967 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -21,6 +21,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.2.8.orig.tar.xz sisu_3.2.8-1.dsc sisu_3.2.8-1.debian.tar.gz +* v3: sisupod make, re-fixed, check again + * v3: hub, fixes, still a construction zone * v3: po4a, runs, needs checking diff --git a/lib/sisu/v3/composite.rb b/lib/sisu/v3/composite.rb index 3d28cfcb..a3a1c433 100644 --- a/lib/sisu/v3/composite.rb +++ b/lib/sisu/v3/composite.rb @@ -108,9 +108,12 @@ module SiSU_Assemble end def read begin + pwd=Dir.pwd + Dir.chdir(@opt.f_pth[:pth]) @fns_array=IO.readlines(@opt.fno,'') assembled=insertions? write(assembled) + Dir.chdir(pwd) rescue SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error do __LINE__.to_s + ':' + __FILE__ diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 0e77cf3e..0f721468 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -1462,7 +1462,8 @@ module SiSU_Param @papersize=determine_papersize(@opt.mod.inspect) end @papersize_array=@papersize.scan(/(?:a4|letter|legal|book|a5|b5)/i) - fn=@fns=~/\.ssm\.sst$/ ? @fns.gsub(/.sst/,'') : @fns #decide what to do a filesize on .ssm tells very little about actual document size + fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size + #fn=@fns=~/\.ssm\.sst$/ ? @fns.gsub(/.sst/,'') : @fns #decide what to do a filesize on .ssm tells very little about actual document size @filesize=(File.size(fn)).to_s if @sys.openssl !=false skin=@doc_skin \ diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb index ef467444..b4ef43de 100644 --- a/lib/sisu/v3/sisupod_make.rb +++ b/lib/sisu/v3/sisupod_make.rb @@ -69,30 +69,28 @@ module SiSU_Doc @env=SiSU_Env::InfoEnv.new(@opt.fns) @ver=SiSU_Env::InfoVersion.instance.get_version @ans=SiSU_Response::Response.new - pod_path="#{@env.processing_path.processing}/sisupod" + pod_path="#{@env.processing_path.processing_sisupod(@opt)}" @v=(@opt.cmd =~/[VM]/) ? 'v' : '' @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @file=@particulars.file @local_path="#{@file.output_path.sisupod.dir}" - @zipfile=(@opt.fns =~/\.ssm\.sst$/) \ - ? @opt.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm') - : @opt.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') + @zipfile=@opt.fno.gsub(/(?:\~\S{2,3})?(\.ss[tm])$/,'\1') FileUtils::mkdir_p(pod_path) unless FileTest.directory?(pod_path) - FileUtils::rm_rf("#{@env.processing_path.processing}sisupod/*") if FileTest.directory?("#{@env.processing_path.processing}sisupod") + FileUtils::rm_rf("#{@env.processing_path.processing_sisupod(@opt)}/*") if FileTest.directory?("#{@env.processing_path.processing_sisupod(@opt)}") end def read unless @opt.cmd =~/q/ - @opt.cmd=~/[MVvz]/ \ + @opt.cmd=~/[MVv]/ \ ? SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (txz)',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue : SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (txz)',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_title_hi end unless @opt.fns.empty? - unless @opt.cmd =~/q/ + if @opt.cmd=~/[MVv]/ SiSU_Screen::Ansi.new(@opt.cmd,'Make sisu document (txz) and place in output directory',"#{@opt.fns} -> file://#{@file.output_path.sisupod.dir}/#{@zipfile}.txz").warn if @opt.cmd =~/[MVv]/ end directories sisupod_build - sisupod_xz + #sisupod_tar_xz else if @opt.cmd =~/[MVv]/ SiSU_Screen::Ansi.new(@opt.cmd,'Make (zip (txz)) of sisu work directory',"#{@env.stub_pwd}\_#{@date}.txz").warn @@ -141,7 +139,7 @@ module SiSU_Doc "#{@env.path.pwd}/_sisu/skin", "#{@env.path.home}/.sisu/skin", '/etc/sisu/skin', - "#{@env.processing_path.processing}/external_document/skin" + "#{@env.processing_path.processing_sisupod(@opt)}/external_document/skin" ] sk_doc,sk_dir="doc/#{skin}.rb","dir/skin_#{@env.stub_pwd}.rb" skin_path.each do |v| #document skin priority 1 @@ -174,10 +172,7 @@ module SiSU_Doc @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ @rgx_skin=/^\s+:skin:\s+(\S+)/ @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/ - use_file=@opt.fns =~/(?:\.ssm|\.ssm\.sst)$/ \ - ? @opt.fns.gsub(/\.ssm\.sst$/,'.ssm') - : @opt.fns - file_array=IO.readlines(use_file,'') + file_array=IO.readlines(@opt.fno,'') skin,images,doc_import=[],[],[] doc_import_dir=@opt.sub_location file_array.each do |f| #% work area @@ -188,7 +183,7 @@ module SiSU_Doc and f =~@rgx_image images=images_extract(f,images) end - if use_file =~/\.ssm$/ + if @opt.fno =~/\.ssm$/ doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import end end @@ -213,7 +208,8 @@ module SiSU_Doc else skin_source=select_skin end - docskin_place="#{@env.processing_path.processing}/sisupod/doc/_sisu/skin/#{skin_source[:type]}" + docskin_place="#{@env.processing_path.processing_sisupod(@opt)}/doc/_sisu/skin/#{skin_source[:type]}" + FileUtils::mkdir_p(docskin_place) if skin_source[:type] =~/dir/ docskin_with_path="#{docskin_place}/skin_#{@env.stub_pwd}.rb" docskin=[docskin_with_path.gsub(/.+?\/(skin_\S+?)\.rb/,'\1')] @@ -241,9 +237,10 @@ module SiSU_Doc images=images.flatten.uniq images.delete_if {|x| x =~/https?:\/\// } #images=images.sort - path_pod="#{@env.processing_path.processing}/sisupod" - path_pod_conf="#{@env.processing_path.processing}/sisupod/_sisu" + path_pod="#{@env.processing_path.processing_sisupod(@opt)}" + path_pod_conf="#{@env.processing_path.processing_sisupod(@opt)}/_sisu" images_path_pod="#{path_pod}/image" + FileUtils::mkdir_p(images_path_pod) #unattractive hard coding ... ! image_path='_sisu/image' images_pwd="#{@env.path.pwd}/#{image_path}" @@ -265,29 +262,31 @@ module SiSU_Doc end end if doc_import.length > 0 \ - and use_file =~/\.ssm$/ + and @opt.fno =~/\.ssm$/ doc_import.each do |f| - FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing}/sisupod/doc/#{@opt.lng}/#{f}") + FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f}") end end x=@env.document_language_versions_found #check multiple document language versions (param not used) if x[:f] \ and x[:f].length > 0 #store multiple document language versions, sisupod x[:f].each do |f| - (use_file =~/\.ssm$/) \ - ? FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}","#{@env.processing_path.processing}/sisupod/doc/#{f[:l]}/#{f[:n]}") - : FileUtils::cp_r("#{@env.path.pwd}/#{f[:f]}","#{@env.processing_path.processing}/sisupod/doc/#{f[:l]}/#{f[:n]}") + pth="#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}" + FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) + (@opt.fno =~/\.ssm$/) \ + ? FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") + : FileUtils::cp_r("#{@env.path.pwd}/#{f[:f]}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") end end #NB not all possibilies met, revisit, also in case of composite file may wish to add README end - def sisupod_xz + def sisupod_tar_xz FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir) tree=(@opt.cmd =~/[vVM]/ \ && SiSU_Env::SystemCall.new.program_found?('tree')) \ ? 'tree sisupod' : '' - if FileTest.directory?(@env.processing_path.processing) - Dir.chdir(@env.processing_path.processing) + if FileTest.directory?(@env.processing_path.processing_sisupod(@opt)) + Dir.chdir("#{@env.processing_path.root_dir}/#{@env.processing_path.user}/pods/#{@opt.fns}") system(%{ #{tree} tar -cJf #{@zipfile}.txz sisupod @@ -296,9 +295,9 @@ module SiSU_Doc FileUtils::mv("#{@zipfile}.txz",@file.place_file.sisupod.dir) FileUtils::rm_r(Dir.glob("sisupod/*")) Dir.chdir(@env.path.pwd) - SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab if @opt.cmd=~/[MVv]/ else - SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab + SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab if @opt.cmd=~/[MVv]/ end end end diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 09dd5d6e..23f88ad7 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -1671,19 +1671,6 @@ WOK file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst') "#{source_file_path}/#{file}" end - def read_source_file(fns) - fns_array=if RUBY_VERSION < '1.9' - x=unless fns =~/\.ssm.sst$/ - IO.readlines(fns,'') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'') - end - else #ruby version >= '1.9' - x=unless fns =~/\.ssm.sst$/ - IO.readlines(fns,'r:utf-8') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8') - end - end - end def font def texpdf def main @@ -1794,6 +1781,19 @@ WOK end self end + def read_source_file(fns) + fns_array=if RUBY_VERSION < '1.9' + x=unless fns =~/\.ssm.sst$/ + IO.readlines(fns,'') + else IO.readlines("#{processing_path.composite_file}/#{fns}",'') + end + else #ruby version >= '1.9' + x=unless fns =~/\.ssm.sst$/ + IO.readlines(fns,'r:utf-8') + else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8') + end + end + end def path #dir def home @sys.home @@ -2043,6 +2043,34 @@ WOK ? ("#{root_dir}/#{user}/#{stub_pwd}") : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path] end + def stub_dir_orig # ends up with lang, if lang dir + (usr_dir?) \ + ? ("#{root_dir}/#{user}/#{stub_pwd}") + : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path] + end + def processing_sisupod(opt=nil) #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) + unless FileTest.directory?(root_dir) + FileUtils::mkdir_p(root_dir) + File.chmod(0777,root_dir) + end + if usr_dir? + processing_path_usr="#{root_dir}/#{user}" + FileUtils::mkdir_p(processing_path_usr) unless FileTest.directory?(processing_path_usr) + File.chmod(0700,processing_path_usr) + end + sisupod_processing_path=processing_path_usr + '/pods/' + opt.fno + '/sisupod' + FileUtils::mkdir_p(sisupod_processing_path) unless FileTest.directory?(sisupod_processing_path) + sisupod_processing_path_lng=if defined? opt.lng + sisupod_processing_path + '/doc/' + opt.lng + else + sisupod_processing_path + '/doc' + end + unless FileTest.directory?(sisupod_processing_path_lng) + FileUtils::mkdir_p(sisupod_processing_path_lng) + File.chmod(0700,sisupod_processing_path_lng) + end + sisupod_processing_path + end def processing #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) unless FileTest.directory?(root_dir) FileUtils::mkdir_p(root_dir) @@ -2060,7 +2088,6 @@ WOK path_processing.each do |v| # processing=v unless FileTest.directory?(processing) - puts "a processing directory (#{processing}) is being created for use by sisu" FileUtils::mkdir_p(processing) File.chmod(0700,processing) end @@ -3537,7 +3564,8 @@ WOK true elsif cmd_rc[:ocn][:set]==:off false - elsif @md.make.ocn? ==:off + elsif defined? @md.make.ocn? \ + and @md.make.ocn? ==:off false elsif env_rc.build.ocn? ==:off false @@ -3550,7 +3578,8 @@ WOK true elsif cmd_rc[:toc][:set]==:off false - elsif @md.make.toc? ==:off + elsif defined? @md.make.toc? \ + and @md.make.toc? ==:off false elsif env_rc.build.toc? ==:off false @@ -3563,7 +3592,8 @@ WOK true elsif cmd_rc[:manifest][:set]==:off false - elsif @md.make.manifest? ==:off + elsif defined? @md.make.manifest? \ + and @md.make.manifest? ==:off false elsif env_rc.build.manifest? ==:off false @@ -3576,7 +3606,8 @@ WOK true elsif cmd_rc[:links_to_manifest][:set]==:off false - elsif @md.make.links_to_manifest? ==:off + elsif defined? @md.make.links_to_manifest? \ + and @md.make.links_to_manifest? ==:off false elsif env_rc.build.links_to_manifest? ==:off false @@ -3589,7 +3620,8 @@ WOK true elsif cmd_rc[:metadata][:set]==:off false - elsif @md.make.metadata? ==:off + elsif defined? @md.make.metadata? \ + and @md.make.metadata? ==:off false elsif env_rc.build.metadata? ==:off false @@ -3604,7 +3636,8 @@ WOK true elsif cmd_rc[:minitoc][:set]==:off false - elsif @md.make.minitoc? ==:off + elsif defined? @md.make.minitoc? \ + and @md.make.minitoc? ==:off false elsif env_rc.build.minitoc? ==:off false @@ -3621,8 +3654,9 @@ WOK elsif cmd_rc[:manifest_minitoc][:set]==:off \ || cmd_rc[:minitoc][:set]==:off false - elsif @md.make.manifest_minitoc? ==:off \ - || @md.make.minitoc? ==:off + elsif defined? @md.make.manifest_minitoc? \ + and (@md.make.manifest_minitoc? ==:off \ + || @md.make.minitoc? ==:off) false elsif env_rc.build.manifest_minitoc? ==:off \ || env_rc.build.minitoc? ==:off @@ -3642,8 +3676,9 @@ WOK elsif cmd_rc[:html_minitoc][:set]==:off \ || cmd_rc[:minitoc][:set]==:off false - elsif @md.make.html_minitoc? ==:off \ - || @md.make.minitoc? ==:off + elsif defined? @md.make.html_minitoc? \ + and (@md.make.html_minitoc? ==:off \ + || @md.make.minitoc? ==:off) false elsif env_rc.build.html_minitoc? ==:off \ || env_rc.build.minitoc? ==:off @@ -3659,7 +3694,8 @@ WOK true elsif cmd_rc[:html_top_band][:set]==:off false - elsif @md.make.html_top_band? ==:off + elsif defined? @md.make.html_top_band? \ + and @md.make.html_top_band? ==:off false elsif env_rc.build.html_top_band? ==:off false @@ -3672,7 +3708,8 @@ WOK true elsif cmd_rc[:html_navigation][:set]==:off false - elsif @md.make.html_navigation? ==:off + elsif defined? @md.make.html_navigation? \ + and @md.make.html_navigation? ==:off false elsif env_rc.build.html_navigation? ==:off false @@ -3685,7 +3722,8 @@ WOK true elsif cmd_rc[:html_navigation_bar][:set]==:off false - elsif @md.make.html_navigation_bar? ==:off + elsif defined? @md.make.html_navigation_bar? \ + and @md.make.html_navigation_bar? ==:off false elsif env_rc.build.html_navigation_bar? ==:off false @@ -3698,7 +3736,8 @@ WOK true elsif cmd_rc[:search_form][:set]==:off false - elsif @md.make.search_form? ==:off + elsif defined? @md.make.html_search_form? \ + and @md.make.search_form? ==:off false elsif env_rc.build.search_form? ==:off false @@ -3713,8 +3752,9 @@ WOK elsif cmd_rc[:html_search_form][:set]==:off \ || cmd_rc[:search_form][:set]==:off false - elsif @md.make.html_search_form? ==:off \ - || @md.make.search_form? ==:off + elsif defined? @md.make.html_search_form? \ + and (@md.make.html_search_form? ==:off \ + || @md.make.search_form? ==:off) false elsif env_rc.build.html_search_form? ==:off \ || env_rc.build.search_form? ==:off @@ -3730,7 +3770,8 @@ WOK true elsif cmd_rc[:html_right_pane][:set]==:off false - elsif @md.make.html_right_pane? ==:off + elsif defined? @md.make.html_right_pane? \ + and @md.make.html_right_pane? ==:off false elsif env_rc.build.html_right_pane? ==:off false @@ -3743,7 +3784,8 @@ WOK true elsif cmd_rc[:segsubtoc][:set]==:off false - elsif @md.make.segsubtoc? ==:off + elsif defined? @md.make.segsubtoc? \ + and @md.make.segsubtoc? ==:off false elsif env_rc.build.segsubtoc? ==:off false -- cgit v1.2.3