Ubuntu Pastebin

Paste from a at Wed, 11 Feb 2015 13:23:06 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def create_language_specific_doc_lists!(dir, language, software_name)
    if File.exist?("#{dir}/index.docbook")
      # When there is an index.docbook we mustn't copy the en_US version as
      # we have to write our own CMakeLists in order to have things installed
      # in the correct language directory! Also see kdoctools_create_handbook
      # arguments.
      write_handbook(dir, language, software_name)
    elsif !Dir.glob("#{dir}/*").select { |f| File.directory?(f) }.empty?
      # -- Recyle en_US' CMakeLists --
      enusdir = "#{dir}/../en_US/"
      enuscmake = "#{enusdir}/CMakeLists.txt"
      if File.exist?(enuscmake)
        # FIXME: naughty
        FileUtils.cp(enuscmake, dir) unless File.basename(dir) == 'en_US'
        Dir.glob("#{dir}/**/**").each do |current_dir|
          next unless File.directory?(current_dir)
          next if File.basename(dir) == 'en_US'
          dir_pathname = Pathname.new(dir)
          current_dir_pathname = Pathname.new(current_dir)
          relative_path = current_dir_pathname.relative_path_from(dir_pathname)
          # FIXME: this will fail if the cmakelists doesn't exist, which is
          #        possible but also a bit odd, not sure if we should just
          #        ignore that...
          # FIXME: has no test backing I think
          cmakefile = "#{enusdir}/#{relative_path}/CMakeLists.txt"
          FileUtils.cp(cmakefile, current_dir) if File.exist?(cmakefile)
        end
        Dir.glob("#{dir}/**/index.docbook").each do |docbook|
          # FIXME: subdir logic needs testing through documentation class
          # FIXME: this is not tested via our tests
          dirname = File.dirname(docbook)

          dir_pathname = Pathname.new(dir)
          current_dir_pathname = Pathname.new(dirname)
          relative_path = current_dir_pathname.relative_path_from(dir_pathname)

          subdir = File.join(relative_path)
          subdir.chomp!(File::SEPARATOR)
          # FIXME: no test backing
          write_handbook(dirname, language, subdir)
        end
      else
        fail 'there is no cmakelists in enUS and also no index.docbook'
      end
    else
      fail 'There is no index.docbook but also no directories'
    end

    # en_US may already have a super cmakelists, do not twiddle with it!
    log_debug "Writing main cmakelists #{dir}/../CMakeLists.txt"
    File.open("#{dir}/../CMakeLists.txt", 'a') do |f|
      f.write(add_subdirectory(dir))
    end
  end
Download as text