bioroebe 0.10.80 → 0.12.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3946 -2817
  3. data/bin/bioroebe +13 -2
  4. data/bin/bioroebe_hash +7 -0
  5. data/bin/codon_to_aminoacid +6 -4
  6. data/bin/compacter +7 -0
  7. data/bin/plain_palindrome +7 -0
  8. data/bioroebe.gemspec +3 -3
  9. data/doc/README.gen +3918 -2793
  10. data/doc/quality_control/commandline_applications.md +3 -3
  11. data/doc/statistics/statistics.md +7 -7
  12. data/doc/todo/bioroebe_GUI_todo.md +19 -14
  13. data/doc/todo/bioroebe_java_todo.md +22 -0
  14. data/doc/todo/bioroebe_todo.md +2075 -2620
  15. data/lib/bioroebe/C++/DNA.cpp +69 -0
  16. data/lib/bioroebe/C++/RNA.cpp +58 -0
  17. data/lib/bioroebe/C++/sequence.cpp +35 -0
  18. data/lib/bioroebe/abstract/README.md +1 -0
  19. data/lib/bioroebe/abstract/features.rb +29 -0
  20. data/lib/bioroebe/aminoacids/aminoacid_substitution.rb +1 -9
  21. data/lib/bioroebe/aminoacids/codon_percentage.rb +1 -9
  22. data/lib/bioroebe/aminoacids/deduce_aminoacid_sequence.rb +1 -9
  23. data/lib/bioroebe/aminoacids/display_aminoacid_table.rb +1 -0
  24. data/lib/bioroebe/aminoacids/show_hydrophobicity.rb +1 -6
  25. data/lib/bioroebe/base/base_module/base_module.rb +36 -0
  26. data/lib/bioroebe/base/colours_for_base/colours_for_base.rb +18 -8
  27. data/lib/bioroebe/base/commandline_application/commandline_application.rb +13 -9
  28. data/lib/bioroebe/base/commandline_application/commandline_arguments.rb +24 -19
  29. data/lib/bioroebe/base/commandline_application/misc.rb +66 -49
  30. data/lib/bioroebe/base/commandline_application/opn.rb +8 -8
  31. data/lib/bioroebe/base/commandline_application/reset.rb +5 -3
  32. data/lib/bioroebe/base/internal_hash_module/internal_hash_module.rb +42 -0
  33. data/lib/bioroebe/base/misc.rb +35 -0
  34. data/lib/bioroebe/base/prototype/misc.rb +15 -9
  35. data/lib/bioroebe/base/prototype/reset.rb +10 -0
  36. data/lib/bioroebe/cleave_and_digest/digestion.rb +10 -2
  37. data/lib/bioroebe/cleave_and_digest/trypsin.rb +104 -50
  38. data/lib/bioroebe/codon_tables/frequencies/parse_frequency_table.rb +2 -10
  39. data/lib/bioroebe/codons/codons.rb +1 -1
  40. data/lib/bioroebe/codons/convert_this_codon_to_that_aminoacid.rb +208 -59
  41. data/lib/bioroebe/codons/possible_codons_for_this_aminoacid.rb +1 -9
  42. data/lib/bioroebe/codons/show_codon_tables.rb +8 -3
  43. data/lib/bioroebe/codons/show_codon_usage.rb +15 -4
  44. data/lib/bioroebe/colours/rev.rb +4 -1
  45. data/lib/bioroebe/constants/aminoacids_and_proteins.rb +1 -0
  46. data/lib/bioroebe/constants/database_constants.rb +1 -1
  47. data/lib/bioroebe/constants/files_and_directories.rb +31 -4
  48. data/lib/bioroebe/constants/misc.rb +20 -0
  49. data/lib/bioroebe/constants/nucleotides.rb +7 -0
  50. data/lib/bioroebe/conversions/dna_to_aminoacid_sequence.rb +109 -39
  51. data/lib/bioroebe/count/count_amount_of_aminoacids.rb +3 -2
  52. data/lib/bioroebe/count/count_amount_of_nucleotides.rb +3 -0
  53. data/lib/bioroebe/cpp +1 -0
  54. data/lib/bioroebe/crystal/README.md +2 -0
  55. data/lib/bioroebe/crystal/to_rna.cr +19 -0
  56. data/lib/bioroebe/data/README.md +11 -8
  57. data/lib/bioroebe/data/electron_microscopy/pos_example.pos +396 -0
  58. data/lib/bioroebe/data/electron_microscopy/test_particles.star +36 -0
  59. data/lib/bioroebe/data/fasta/human/Homo_sapiens_hemoglobin_subunit_alpha_HBB_mRNA.fasta +9 -0
  60. data/lib/bioroebe/data/fasta/human/Homo_sapiens_hemoglobin_subunit_beta_HBB_mRNA.fasta +8 -0
  61. data/lib/bioroebe/data/fasta/human/README.md +2 -0
  62. data/lib/bioroebe/dotplots/advanced_dotplot.rb +1 -1
  63. data/lib/bioroebe/electron_microscopy/coordinate_analyzer.rb +15 -18
  64. data/lib/bioroebe/{fasta_and_fastq/parse_fasta/run.rb → electron_microscopy/electron_microscopy_module.rb} +16 -8
  65. data/lib/bioroebe/electron_microscopy/fix_pos_file.rb +1 -9
  66. data/lib/bioroebe/electron_microscopy/flipy.rb +83 -0
  67. data/lib/bioroebe/electron_microscopy/parse_coordinates.rb +2 -10
  68. data/lib/bioroebe/electron_microscopy/read_file_xmd.rb +1 -9
  69. data/lib/bioroebe/electron_microscopy/simple_star_file_generator.rb +4 -9
  70. data/lib/bioroebe/enzymes/has_this_restriction_enzyme.rb +10 -3
  71. data/lib/bioroebe/enzymes/restriction_enzyme.rb +23 -1
  72. data/lib/bioroebe/enzymes/restriction_enzymes/statistics.rb +65 -0
  73. data/lib/bioroebe/fasta_and_fastq/autocorrect_the_name_of_this_fasta_file.rb +1 -9
  74. data/lib/bioroebe/fasta_and_fastq/compact_fasta_file/compact_fasta_file.rb +7 -9
  75. data/lib/bioroebe/fasta_and_fastq/fasta_defline/fasta_defline.rb +1 -5
  76. data/lib/bioroebe/fasta_and_fastq/fasta_to_yaml/fasta_to_yaml.rb +81 -0
  77. data/lib/bioroebe/fasta_and_fastq/parse_fasta/parse_fasta.rb +1518 -7
  78. data/lib/bioroebe/fasta_and_fastq/return_fasta_subsection_of_this_file.rb +11 -2
  79. data/lib/bioroebe/fasta_and_fastq/show_fasta_headers.rb +27 -12
  80. data/lib/bioroebe/fasta_and_fastq/simplify_fasta_header/simplify_fasta_header.rb +1 -5
  81. data/lib/bioroebe/fasta_and_fastq/split_this_fasta_file_into_chromosomes/constants.rb +0 -5
  82. data/lib/bioroebe/genome/README.md +4 -0
  83. data/lib/bioroebe/genome/genome.rb +130 -0
  84. data/lib/bioroebe/genomes/genome_pattern.rb +3 -9
  85. data/lib/bioroebe/gui/gtk +1 -0
  86. data/lib/bioroebe/gui/gtk3/alignment/alignment.rb +106 -137
  87. data/lib/bioroebe/gui/gtk3/aminoacid_composition/aminoacid_composition.rb +27 -61
  88. data/lib/bioroebe/gui/gtk3/aminoacid_composition/customized_dialog.rb +1 -1
  89. data/lib/bioroebe/gui/gtk3/blosum_matrix_viewer/blosum_matrix_viewer.rb +1 -2
  90. data/lib/bioroebe/gui/gtk3/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria.rb +1 -2
  91. data/lib/bioroebe/gui/gtk3/controller/controller.rb +46 -29
  92. data/lib/bioroebe/gui/gtk3/dna_to_aminoacid_widget/dna_to_aminoacid_widget.rb +77 -52
  93. data/lib/bioroebe/gui/gtk3/dna_to_reverse_complement_widget/dna_to_reverse_complement_widget.rb +1 -2
  94. data/lib/bioroebe/gui/gtk3/fasta_table_widget/fasta_table_widget.rb +100 -23
  95. data/lib/bioroebe/gui/gtk3/format_converter/format_converter.rb +1 -2
  96. data/lib/bioroebe/gui/gtk3/gene/gene.rb +1 -2
  97. data/lib/bioroebe/gui/gtk3/hamming_distance/hamming_distance.rb +43 -30
  98. data/lib/bioroebe/gui/gtk3/levensthein_distance/levensthein_distance.rb +1 -2
  99. data/lib/bioroebe/gui/gtk3/nucleotide_analyser/nucleotide_analyser.rb +120 -73
  100. data/lib/bioroebe/gui/gtk3/primer_design_widget/primer_design_widget.rb +1 -2
  101. data/lib/bioroebe/gui/gtk3/protein_to_DNA/protein_to_DNA.rb +19 -20
  102. data/lib/bioroebe/gui/gtk3/random_sequence/random_sequence.rb +20 -13
  103. data/lib/bioroebe/gui/gtk3/restriction_enzymes/restriction_enzymes.rb +1 -2
  104. data/lib/bioroebe/gui/gtk3/show_codon_table/misc.rb +97 -22
  105. data/lib/bioroebe/gui/gtk3/show_codon_table/show_codon_table.rb +3 -73
  106. data/lib/bioroebe/gui/gtk3/show_codon_usage/show_codon_usage.rb +1 -2
  107. data/lib/bioroebe/gui/gtk3/sizeseq/sizeseq.rb +1 -2
  108. data/lib/bioroebe/gui/gtk3/three_to_one/three_to_one.rb +1 -2
  109. data/lib/bioroebe/gui/gtk3/www_finder/www_finder.rb +1 -2
  110. data/lib/bioroebe/gui/javafx/bioroebe/Bioroebe.class +0 -0
  111. data/lib/bioroebe/gui/javafx/bioroebe/Bioroebe.java +104 -0
  112. data/lib/bioroebe/gui/javafx/bioroebe.jar +0 -0
  113. data/lib/bioroebe/gui/javafx/bioroebe.mf +1 -0
  114. data/lib/bioroebe/gui/javafx/module-info.class +0 -0
  115. data/lib/bioroebe/gui/javafx/module-info.java +5 -0
  116. data/lib/bioroebe/gui/jruby/alignment/alignment.rb +165 -0
  117. data/lib/bioroebe/gui/jruby/aminoacid_composition/aminoacid_composition.rb +166 -0
  118. data/lib/bioroebe/gui/libui/alignment/alignment.rb +3 -1
  119. data/lib/bioroebe/gui/libui/controller/controller.rb +116 -0
  120. data/lib/bioroebe/gui/libui/random_sequence/random_sequence.rb +18 -2
  121. data/lib/bioroebe/gui/libui/show_codon_table/show_codon_table.rb +2 -0
  122. data/lib/bioroebe/gui/libui/three_to_one/three_to_one.rb +8 -6
  123. data/lib/bioroebe/gui/shared_code/alignment/alignment_module.rb +102 -0
  124. data/lib/bioroebe/gui/shared_code/aminoacid_composition/aminoacid_composition_module.rb +94 -0
  125. data/lib/bioroebe/gui/shared_code/levensthein_distance/levensthein_distance_module.rb +18 -16
  126. data/lib/bioroebe/gui/shared_code/protein_to_DNA/protein_to_DNA_module.rb +14 -14
  127. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne$1.class +0 -0
  128. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne$CloseListener.class +0 -0
  129. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne.class +0 -0
  130. data/lib/bioroebe/gui/swing/three_to_one/ThreeToOne.java +141 -0
  131. data/lib/bioroebe/images/FORWARD_PRIMER.png +0 -0
  132. data/lib/bioroebe/images/REVERSE_PRIMER.png +0 -0
  133. data/lib/bioroebe/images/images.html +29845 -0
  134. data/lib/bioroebe/java/README.md +5 -0
  135. data/lib/bioroebe/java/bioroebe/AllInOne.java +1 -0
  136. data/lib/bioroebe/java/bioroebe/Base.class +0 -0
  137. data/lib/bioroebe/java/bioroebe/Base.java +39 -5
  138. data/lib/bioroebe/java/bioroebe/IsPalindrome.java +23 -5
  139. data/lib/bioroebe/java/bioroebe/SanitizeNucleotideSequence.java +0 -0
  140. data/lib/bioroebe/java/bioroebe/Sequence.java +28 -3
  141. data/lib/bioroebe/java/bioroebe/ToCamelcase.class +0 -0
  142. data/lib/bioroebe/java/bioroebe/ToCamelcase.java +16 -4
  143. data/lib/bioroebe/java/bioroebe/ToRNA.java +43 -0
  144. data/lib/bioroebe/java/bioroebe/ToplevelMethods.java +6 -0
  145. data/lib/bioroebe/java/bioroebe/{BisulfiteTreatment.class → src/BisulfiteTreatment.class} +0 -0
  146. data/lib/bioroebe/java/bioroebe/{Codons.class → src/Codons.class} +0 -0
  147. data/lib/bioroebe/java/bioroebe/src/Codons.java +35 -0
  148. data/lib/bioroebe/java/bioroebe/src/Commandline.class +0 -0
  149. data/lib/bioroebe/java/bioroebe/src/Commandline.java +101 -0
  150. data/lib/bioroebe/java/bioroebe/{Esystem.class → src/Esystem.class} +0 -0
  151. data/lib/bioroebe/java/bioroebe/{Esystem.java → src/Esystem.java} +6 -1
  152. data/lib/bioroebe/java/bioroebe/{GenerateRandomDnaSequence.class → src/GenerateRandomDnaSequence.class} +0 -0
  153. data/lib/bioroebe/java/bioroebe/{GenerateRandomDnaSequence.java → src/GenerateRandomDnaSequence.java} +8 -2
  154. data/lib/bioroebe/java/bioroebe/src/PartnerNucleotide.class +0 -0
  155. data/lib/bioroebe/java/bioroebe/src/PartnerNucleotide.java +56 -0
  156. data/lib/bioroebe/java/bioroebe/{RemoveFile.java → src/RemoveFile.java} +10 -4
  157. data/lib/bioroebe/java/bioroebe/{RemoveNumbers.class → src/RemoveNumbers.class} +0 -0
  158. data/lib/bioroebe/java/bioroebe/{RemoveNumbers.java → src/RemoveNumbers.java} +1 -0
  159. data/lib/bioroebe/java/bioroebe/src/toplevel_methods/BaseComposition.class +0 -0
  160. data/lib/bioroebe/java/bioroebe/src/toplevel_methods/BaseComposition.java +75 -0
  161. data/lib/bioroebe/misc/ruler.rb +11 -2
  162. data/lib/bioroebe/nucleotides/most_likely_nucleotide_sequence_for_this_aminoacid_sequence.rb +1 -9
  163. data/lib/bioroebe/nucleotides/sanitize_nucleotide_sequence.rb +59 -18
  164. data/lib/bioroebe/nucleotides/show_nucleotide_sequence.rb +7 -7
  165. data/lib/bioroebe/parsers/genbank_parser.rb +347 -26
  166. data/lib/bioroebe/parsers/gff.rb +1 -9
  167. data/lib/bioroebe/patterns/scan_for_repeat.rb +1 -5
  168. data/lib/bioroebe/pdb/fetch_fasta_sequence_from_pdb.rb +1 -9
  169. data/lib/bioroebe/pdb/parse_mmCIF_file.rb +1 -9
  170. data/lib/bioroebe/pdb/parse_pdb_file.rb +4 -10
  171. data/lib/bioroebe/project/project.rb +1 -1
  172. data/lib/bioroebe/python/README.md +1 -0
  173. data/lib/bioroebe/python/__pycache__/mymodule.cpython-39.pyc +0 -0
  174. data/lib/bioroebe/python/gui/gtk3/all_in_one.css +4 -0
  175. data/lib/bioroebe/python/gui/gtk3/all_in_one.py +59 -0
  176. data/lib/bioroebe/python/gui/gtk3/widget1.py +20 -0
  177. data/lib/bioroebe/python/gui/tkinter/all_in_one.py +91 -0
  178. data/lib/bioroebe/python/mymodule.py +8 -0
  179. data/lib/bioroebe/python/protein_to_dna.py +33 -0
  180. data/lib/bioroebe/python/shell/shell.py +19 -0
  181. data/lib/bioroebe/python/to_rna.py +14 -0
  182. data/lib/bioroebe/python/toplevel_methods/convert_dna_to_aminoacid_sequence.py +137 -0
  183. data/lib/bioroebe/python/toplevel_methods/esystem.py +12 -0
  184. data/lib/bioroebe/python/toplevel_methods/open_in_browser.py +20 -0
  185. data/lib/bioroebe/python/toplevel_methods/palindromes.py +52 -0
  186. data/lib/bioroebe/python/toplevel_methods/rds.py +13 -0
  187. data/lib/bioroebe/python/toplevel_methods/shuffleseq.py +23 -0
  188. data/lib/bioroebe/python/toplevel_methods/three_delimiter.py +37 -0
  189. data/lib/bioroebe/python/toplevel_methods/time_and_date.py +43 -0
  190. data/lib/bioroebe/python/toplevel_methods/to_camelcase.py +21 -0
  191. data/lib/bioroebe/requires/require_cleave_and_digest.rb +3 -1
  192. data/lib/bioroebe/requires/require_the_bioroebe_project.rb +3 -1
  193. data/lib/bioroebe/sequence/alignment.rb +14 -4
  194. data/lib/bioroebe/sequence/dna.rb +1 -0
  195. data/lib/bioroebe/sequence/nucleotide_module/nucleotide_module.rb +28 -25
  196. data/lib/bioroebe/sequence/protein.rb +105 -3
  197. data/lib/bioroebe/sequence/rna.rb +220 -0
  198. data/lib/bioroebe/sequence/sequence.rb +128 -40
  199. data/lib/bioroebe/shell/menu.rb +3815 -3696
  200. data/lib/bioroebe/shell/misc.rb +9019 -3133
  201. data/lib/bioroebe/shell/readline/readline.rb +1 -1
  202. data/lib/bioroebe/shell/shell.rb +1137 -28
  203. data/lib/bioroebe/siRNA/siRNA.rb +81 -1
  204. data/lib/bioroebe/string_matching/find_longest_substring.rb +3 -2
  205. data/lib/bioroebe/string_matching/hamming_distance.rb +1 -9
  206. data/lib/bioroebe/taxonomy/class_methods.rb +3 -8
  207. data/lib/bioroebe/taxonomy/constants.rb +4 -3
  208. data/lib/bioroebe/taxonomy/edit.rb +2 -1
  209. data/lib/bioroebe/taxonomy/help/help.rb +10 -10
  210. data/lib/bioroebe/taxonomy/help/helpline.rb +2 -2
  211. data/lib/bioroebe/taxonomy/info/check_available.rb +15 -9
  212. data/lib/bioroebe/taxonomy/info/info.rb +18 -11
  213. data/lib/bioroebe/taxonomy/info/is_dna.rb +46 -36
  214. data/lib/bioroebe/taxonomy/interactive.rb +140 -104
  215. data/lib/bioroebe/taxonomy/menu.rb +27 -18
  216. data/lib/bioroebe/taxonomy/parse_fasta.rb +3 -1
  217. data/lib/bioroebe/taxonomy/shared.rb +1 -0
  218. data/lib/bioroebe/taxonomy/taxonomy.rb +1 -0
  219. data/lib/bioroebe/toplevel_methods/aminoacids_and_proteins.rb +31 -24
  220. data/lib/bioroebe/toplevel_methods/colourize_related_methods.rb +164 -0
  221. data/lib/bioroebe/toplevel_methods/databases.rb +1 -1
  222. data/lib/bioroebe/toplevel_methods/digest.rb +18 -8
  223. data/lib/bioroebe/toplevel_methods/fasta_and_fastq.rb +107 -63
  224. data/lib/bioroebe/toplevel_methods/file_and_directory_related_actions.rb +14 -2
  225. data/lib/bioroebe/toplevel_methods/frequencies.rb +8 -1
  226. data/lib/bioroebe/toplevel_methods/misc.rb +175 -11
  227. data/lib/bioroebe/toplevel_methods/nucleotides.rb +118 -46
  228. data/lib/bioroebe/toplevel_methods/open_in_browser.rb +2 -0
  229. data/lib/bioroebe/toplevel_methods/palindromes.rb +75 -47
  230. data/lib/bioroebe/toplevel_methods/taxonomy.rb +3 -3
  231. data/lib/bioroebe/toplevel_methods/to_camelcase.rb +5 -0
  232. data/lib/bioroebe/utility_scripts/align_open_reading_frames.rb +1 -9
  233. data/lib/bioroebe/utility_scripts/check_for_mismatches/check_for_mismatches.rb +1 -9
  234. data/lib/bioroebe/utility_scripts/compacter/compacter.rb +251 -0
  235. data/lib/bioroebe/utility_scripts/compseq/compseq.rb +1 -9
  236. data/lib/bioroebe/utility_scripts/consensus_sequence.rb +6 -6
  237. data/lib/bioroebe/utility_scripts/create_batch_entrez_file.rb +1 -9
  238. data/lib/bioroebe/utility_scripts/dot_alignment.rb +1 -9
  239. data/lib/bioroebe/utility_scripts/move_file_to_its_correct_location.rb +1 -4
  240. data/lib/bioroebe/utility_scripts/parse_taxonomy.rb +2 -2
  241. data/lib/bioroebe/utility_scripts/permutations.rb +36 -9
  242. data/lib/bioroebe/utility_scripts/showorf/constants.rb +0 -5
  243. data/lib/bioroebe/utility_scripts/showorf/reset.rb +1 -4
  244. data/lib/bioroebe/version/version.rb +2 -2
  245. data/lib/bioroebe/www/embeddable_interface.rb +121 -58
  246. data/lib/bioroebe/www/sinatra/sinatra.rb +186 -71
  247. data/lib/bioroebe/yaml/aminoacids/amino_acids_long_name_to_one_letter.yml +2 -2
  248. data/lib/bioroebe/yaml/aminoacids/weight_of_common_proteins.yml +17 -17
  249. data/lib/bioroebe/yaml/configuration/browser.yml +1 -1
  250. data/lib/bioroebe/yaml/configuration/temp_dir.yml +1 -1
  251. data/lib/bioroebe/yaml/consensus_sequences/consensus_sequences.yml +1 -0
  252. data/lib/bioroebe/yaml/genomes/README.md +3 -4
  253. data/lib/bioroebe/yaml/nucleotides/nucleotides.yml +5 -0
  254. data/lib/bioroebe/yaml/restriction_enzymes/restriction_enzymes.yml +57 -57
  255. data/spec/README.md +6 -0
  256. data/spec/project_wide_specification/classes.md +5 -0
  257. metadata +107 -70
  258. data/doc/setup.rb +0 -1655
  259. data/lib/bioroebe/fasta_and_fastq/parse_fasta/constants.rb +0 -50
  260. data/lib/bioroebe/fasta_and_fastq/parse_fasta/initialize.rb +0 -86
  261. data/lib/bioroebe/fasta_and_fastq/parse_fasta/menu.rb +0 -117
  262. data/lib/bioroebe/fasta_and_fastq/parse_fasta/misc.rb +0 -981
  263. data/lib/bioroebe/fasta_and_fastq/parse_fasta/report.rb +0 -156
  264. data/lib/bioroebe/fasta_and_fastq/parse_fasta/reset.rb +0 -128
  265. data/lib/bioroebe/genbank/genbank_parser.rb +0 -291
  266. data/lib/bioroebe/java/bioroebe/AllInOne.class +0 -0
  267. data/lib/bioroebe/java/bioroebe/Cat.class +0 -0
  268. data/lib/bioroebe/java/bioroebe/Codons.java +0 -22
  269. data/lib/bioroebe/java/bioroebe/IsPalindrome.class +0 -0
  270. data/lib/bioroebe/java/bioroebe/PartnerNucleotide.class +0 -0
  271. data/lib/bioroebe/java/bioroebe/PartnerNucleotide.java +0 -19
  272. data/lib/bioroebe/java/bioroebe/SanitizeNucleotideSequence.class +0 -0
  273. data/lib/bioroebe/java/bioroebe/ToplevelMethods.class +0 -0
  274. data/lib/bioroebe/java/bioroebe.jar +0 -0
  275. data/lib/bioroebe/shell/add.rb +0 -108
  276. data/lib/bioroebe/shell/assign.rb +0 -360
  277. data/lib/bioroebe/shell/chop_and_cut.rb +0 -281
  278. data/lib/bioroebe/shell/constants.rb +0 -166
  279. data/lib/bioroebe/shell/download.rb +0 -335
  280. data/lib/bioroebe/shell/enable_and_disable.rb +0 -158
  281. data/lib/bioroebe/shell/enzymes.rb +0 -310
  282. data/lib/bioroebe/shell/fasta.rb +0 -345
  283. data/lib/bioroebe/shell/gtk.rb +0 -76
  284. data/lib/bioroebe/shell/history.rb +0 -132
  285. data/lib/bioroebe/shell/initialize.rb +0 -217
  286. data/lib/bioroebe/shell/loop.rb +0 -74
  287. data/lib/bioroebe/shell/prompt.rb +0 -107
  288. data/lib/bioroebe/shell/random.rb +0 -289
  289. data/lib/bioroebe/shell/reset.rb +0 -335
  290. data/lib/bioroebe/shell/scan_and_parse.rb +0 -135
  291. data/lib/bioroebe/shell/search.rb +0 -337
  292. data/lib/bioroebe/shell/sequences.rb +0 -200
  293. data/lib/bioroebe/shell/show_report_and_display.rb +0 -2901
  294. data/lib/bioroebe/shell/startup.rb +0 -127
  295. data/lib/bioroebe/shell/taxonomy.rb +0 -14
  296. data/lib/bioroebe/shell/tk.rb +0 -23
  297. data/lib/bioroebe/shell/user_input.rb +0 -88
  298. data/lib/bioroebe/shell/xorg.rb +0 -45
  299. data/lib/bioroebe/utility_scripts/compacter.rb +0 -131
  300. /data/lib/bioroebe/java/bioroebe/{BisulfiteTreatment.java → src/BisulfiteTreatment.java} +0 -0
  301. /data/lib/bioroebe/java/bioroebe/{RemoveFile.class → src/RemoveFile.class} +0 -0
data/doc/setup.rb DELETED
@@ -1,1655 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # Encoding: UTF-8
3
- # frozen_string_literal: true
4
- # =========================================================================== #
5
- # === setup.rb
6
- #
7
- # Copyright (c) 2000-2005 Minero Aoki
8
- #
9
- # This program is free software.
10
- #
11
- # You can distribute/modify this program under the terms of
12
- # the GNU LGPL, Lesser General Public License version 2.1.
13
- #
14
- # Note that this was modified in 2021 - a few begin/rescue clauses
15
- # were added.
16
- # =========================================================================== #
17
- unless Errno.const_defined?(:ENOTEMPTY) # Windows?
18
- module Errno
19
- class ENOTEMPTY
20
- # We do not raise this exception, implementation is not needed.
21
- end
22
- end
23
- end
24
-
25
- def File.binread(fname)
26
- open(fname, 'rb') {|f|
27
- return f.read
28
- }
29
- end
30
-
31
- # for corrupted Windows' stat(2)
32
- def File.dir?(path)
33
- File.directory?((path[-1,1] == '/') ? path : path + '/')
34
- end
35
-
36
- class ConfigTable
37
-
38
- include Enumerable
39
-
40
- # ========================================================================= #
41
- # === initialize
42
- # ========================================================================= #
43
- def initialize(rbconfig)
44
- @rbconfig = rbconfig
45
- @items = []
46
- @table = {}
47
- # options
48
- @install_prefix = nil
49
- @config_opt = nil
50
- @verbose = true
51
- @no_harm = false
52
- end
53
-
54
- attr_accessor :install_prefix
55
- attr_accessor :config_opt
56
-
57
- attr_writer :no_harm
58
- attr_writer :verbose
59
-
60
- # ========================================================================= #
61
- # === verbose?
62
- # ========================================================================= #
63
- def verbose?
64
- @verbose
65
- end
66
-
67
- # ========================================================================= #
68
- # === no_harm?
69
- # ========================================================================= #
70
- def no_harm?
71
- @no_harm
72
- end
73
-
74
- # ========================================================================= #
75
- # === []
76
- # ========================================================================= #
77
- def [](key)
78
- lookup(key).resolve(self)
79
- end
80
-
81
- def []=(key, val)
82
- lookup(key).set val
83
- end
84
-
85
- # ========================================================================= #
86
- # === names
87
- # ========================================================================= #
88
- def names
89
- @items.map {|i| i.name }
90
- end
91
-
92
- def each(&block)
93
- @items.each(&block)
94
- end
95
-
96
- # === key?
97
- def key?(i)
98
- @table.key?(i)
99
- end
100
-
101
- # ========================================================================= #
102
- # === lookup
103
- # ========================================================================= #
104
- def lookup(name)
105
- @table[name] or setup_rb_error "no such config item: #{name}"
106
- end
107
-
108
- # ========================================================================= #
109
- # === add
110
- # ========================================================================= #
111
- def add(item)
112
- @items.push item
113
- @table[item.name] = item
114
- end
115
-
116
- # ========================================================================= #
117
- # === remove
118
- # ========================================================================= #
119
- def remove(name)
120
- item = lookup(name)
121
- @items.delete_if {|i| i.name == name }
122
- @table.delete_if {|inner_name, i| i.name == inner_name }
123
- item
124
- end
125
-
126
- # ========================================================================= #
127
- # === load_script
128
- # ========================================================================= #
129
- def load_script(path, inst = nil)
130
- if File.file?(path)
131
- MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path
132
- end
133
- end
134
-
135
- # ========================================================================= #
136
- # === savefile
137
- # ========================================================================= #
138
- def savefile
139
- '.config'
140
- end
141
-
142
- # ========================================================================= #
143
- # === load_savefile
144
- # ========================================================================= #
145
- def load_savefile
146
- begin
147
- File.foreach(savefile()) { |line|
148
- k, v = *line.split(/=/, 2)
149
- self[k] = v.strip
150
- }
151
- rescue Errno::ENOENT
152
- setup_rb_error $!.message + "\n#{File.basename($0)} config first"
153
- end
154
- end
155
-
156
- # ========================================================================= #
157
- # === save
158
- # ========================================================================= #
159
- def save
160
- @items.each {|i| i.value }
161
- File.open(savefile(), 'w') {|f|
162
- @items.each do |i|
163
- f.printf "%s=%s\n", i.name, i.value if i.value? and i.value
164
- end
165
- }
166
- end
167
-
168
- # ========================================================================= #
169
- # === load_standard_entries
170
- # ========================================================================= #
171
- def load_standard_entries
172
- standard_entries(@rbconfig).each {|entry|
173
- add entry
174
- }
175
- end
176
-
177
- # ========================================================================= #
178
- # === standard_entries
179
- # ========================================================================= #
180
- def standard_entries(rbconfig)
181
- c = rbconfig
182
-
183
- rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT'])
184
-
185
- major = c['MAJOR'].to_i
186
- minor = c['MINOR'].to_i
187
- teeny = c['TEENY'].to_i
188
- version = "#{major}.#{minor}"
189
-
190
- # ======================================================================= #
191
- # ruby ver. >= 1.4.4?
192
- # ======================================================================== #
193
- newpath_p = ((major >= 2) or
194
- ((major == 1) and
195
- ((minor >= 5) or
196
- ((minor == 4) and (teeny >= 4)))))
197
-
198
- if c['rubylibdir']
199
- # V > 1.6.3
200
- libruby = "#{c['prefix']}/lib/ruby"
201
- librubyver = c['rubylibdir']
202
- librubyverarch = c['archdir']
203
- siteruby = c['sitedir']
204
- siterubyver = c['sitelibdir']
205
- siterubyverarch = c['sitearchdir']
206
- elsif newpath_p
207
- # 1.4.4 <= V <= 1.6.3
208
- libruby = "#{c['prefix']}/lib/ruby"
209
- librubyver = "#{c['prefix']}/lib/ruby/#{version}"
210
- librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
211
- siteruby = c['sitedir']
212
- siterubyver = "$siteruby/#{version}"
213
- siterubyverarch = "$siterubyver/#{c['arch']}"
214
- else
215
- # V < 1.4.4
216
- libruby = "#{c['prefix']}/lib/ruby"
217
- librubyver = "#{c['prefix']}/lib/ruby/#{version}"
218
- librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
219
- siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby"
220
- siterubyver = siteruby
221
- siterubyverarch = "$siterubyver/#{c['arch']}"
222
- end
223
- parameterize = lambda {|path|
224
- path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')
225
- }
226
-
227
- if arg = c['configure_args'].split.detect {|inner_arg| /--with-make-prog=/ =~ inner_arg }
228
- makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
229
- else
230
- makeprog = 'make'
231
- end
232
-
233
- [
234
- ExecItem.new('installdirs', 'std/site/home',
235
- 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\
236
- {|val, table|
237
- case val
238
- when 'std'
239
- table['rbdir'] = '$librubyver'
240
- table['sodir'] = '$librubyverarch'
241
- when 'site'
242
- table['rbdir'] = '$siterubyver'
243
- table['sodir'] = '$siterubyverarch'
244
- when 'home'
245
- setup_rb_error '$HOME was not set' unless ENV['HOME']
246
- table['prefix'] = ENV['HOME']
247
- table['rbdir'] = '$libdir/ruby'
248
- table['sodir'] = '$libdir/ruby'
249
- end
250
- },
251
- PathItem.new('prefix', 'path', c['prefix'],
252
- 'path prefix of target environment'),
253
- PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
254
- 'the directory for commands'),
255
- PathItem.new('libdir', 'path', parameterize.call(c['libdir']),
256
- 'the directory for libraries'),
257
- PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
258
- 'the directory for shared data'),
259
- PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
260
- 'the directory for man pages'),
261
- PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
262
- 'the directory for system configuration files'),
263
- PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']),
264
- 'the directory for local state data'),
265
- PathItem.new('libruby', 'path', libruby,
266
- 'the directory for ruby libraries'),
267
- PathItem.new('librubyver', 'path', librubyver,
268
- 'the directory for standard ruby libraries'),
269
- PathItem.new('librubyverarch', 'path', librubyverarch,
270
- 'the directory for standard ruby extensions'),
271
- PathItem.new('siteruby', 'path', siteruby,
272
- 'the directory for version-independent aux ruby libraries'),
273
- PathItem.new('siterubyver', 'path', siterubyver,
274
- 'the directory for aux ruby libraries'),
275
- PathItem.new('siterubyverarch', 'path', siterubyverarch,
276
- 'the directory for aux ruby binaries'),
277
- PathItem.new('rbdir', 'path', '$siterubyver',
278
- 'the directory for ruby scripts'),
279
- PathItem.new('sodir', 'path', '$siterubyverarch',
280
- 'the directory for ruby extentions'),
281
- PathItem.new('rubypath', 'path', rubypath,
282
- 'the path to set to #! line'),
283
- ProgramItem.new('rubyprog', 'name', rubypath,
284
- 'the ruby program using for installation'),
285
- ProgramItem.new('makeprog', 'name', makeprog,
286
- 'the make program to compile ruby extentions'),
287
- SelectItem.new('shebang', 'all/ruby/never', 'ruby',
288
- 'shebang line (#!) editing mode'),
289
- BoolItem.new('without-ext', 'yes/no', 'no',
290
- 'does not compile/install ruby extentions')
291
- ]
292
- end
293
- private :standard_entries
294
-
295
- # ========================================================================= #
296
- # === load_multipackage_entries
297
- # ========================================================================= #
298
- def load_multipackage_entries
299
- multipackage_entries().each do |ent|
300
- add ent
301
- end
302
- end
303
-
304
- # ========================================================================= #
305
- # === multipackage_entries
306
- # ========================================================================= #
307
- def multipackage_entries
308
- [
309
- PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
310
- 'package names that you want to install'),
311
- PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
312
- 'package names that you do not want to install')
313
- ]
314
- end
315
- private :multipackage_entries
316
-
317
- ALIASES = {
318
- 'std-ruby' => 'librubyver',
319
- 'stdruby' => 'librubyver',
320
- 'rubylibdir' => 'librubyver',
321
- 'archdir' => 'librubyverarch',
322
- 'site-ruby-common' => 'siteruby', # For backward compatibility
323
- 'site-ruby' => 'siterubyver', # For backward compatibility
324
- 'bin-dir' => 'bindir',
325
- 'rb-dir' => 'rbdir',
326
- 'so-dir' => 'sodir',
327
- 'data-dir' => 'datadir',
328
- 'ruby-path' => 'rubypath',
329
- 'ruby-prog' => 'rubyprog',
330
- 'ruby' => 'rubyprog',
331
- 'make-prog' => 'makeprog',
332
- 'make' => 'makeprog'
333
- }
334
-
335
- # ========================================================================= #
336
- # === fixup
337
- # ========================================================================= #
338
- def fixup
339
- ALIASES.each { |ali, name|
340
- @table[ali] = @table[name]
341
- }
342
- @items.freeze
343
- @table.freeze
344
- @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/
345
- end
346
-
347
- # ========================================================================= #
348
- # === parse_opt
349
- # ========================================================================= #
350
- def parse_opt(opt)
351
- m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}"
352
- m.to_a[1,2]
353
- end
354
-
355
- def dllext
356
- @rbconfig['DLEXT']
357
- end
358
-
359
- def value_config?(name)
360
- lookup(name).value?
361
- end
362
-
363
- class Item
364
- def initialize(name, template, default, desc)
365
- @name = name.freeze
366
- @template = template
367
- @value = default
368
- @default = default
369
- @description = desc
370
- end
371
-
372
- attr_reader :name
373
- attr_reader :description
374
-
375
- attr_accessor :default
376
- alias help_default default
377
-
378
- def help_opt
379
- "--#{@name}=#{@template}"
380
- end
381
-
382
- def value?
383
- true
384
- end
385
-
386
- def value
387
- @value
388
- end
389
-
390
- def resolve(table)
391
- @value.gsub(%r<\$([^/]+)>) { table[$1] }
392
- end
393
-
394
- def set(val)
395
- @value = check(val)
396
- end
397
-
398
- private
399
-
400
- def check(val)
401
- setup_rb_error "config: --#{name} requires argument" unless val
402
- val
403
- end
404
- end
405
-
406
- class BoolItem < Item
407
- def config_type
408
- 'bool'
409
- end
410
-
411
- def help_opt
412
- "--#{@name}"
413
- end
414
-
415
- private
416
-
417
- def check(val)
418
- return 'yes' unless val
419
- case val
420
- when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes'
421
- when /\An(o)?\z/i, /\Af(alse)\z/i then 'no'
422
- else
423
- setup_rb_error "config: --#{@name} accepts only yes/no for argument"
424
- end
425
- end
426
- end
427
-
428
- class PathItem < Item
429
- def config_type
430
- 'path'
431
- end
432
-
433
- private
434
-
435
- def check(path)
436
- setup_rb_error "config: --#{@name} requires argument" unless path
437
- path[0,1] == '$' ? path : File.expand_path(path)
438
- end
439
- end
440
-
441
- class ProgramItem < Item
442
- def config_type
443
- 'program'
444
- end
445
- end
446
-
447
- class SelectItem < Item
448
- def initialize(name, selection, default, desc)
449
- super
450
- @ok = selection.split('/')
451
- end
452
-
453
- def config_type
454
- 'select'
455
- end
456
-
457
- private
458
-
459
- def check(val)
460
- unless @ok.include?(val.strip)
461
- setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
462
- end
463
- val.strip
464
- end
465
- end
466
-
467
- class ExecItem < Item
468
- def initialize(name, selection, desc, &block)
469
- super name, selection, nil, desc
470
- @ok = selection.split('/')
471
- @action = block
472
- end
473
-
474
- def config_type
475
- 'exec'
476
- end
477
-
478
- def value?
479
- false
480
- end
481
-
482
- def resolve(table)
483
- setup_rb_error "$#{name()} wrongly used as option value"
484
- end
485
-
486
- undef set
487
-
488
- def evaluate(val, table)
489
- v = val.strip.downcase
490
- unless @ok.include?(v)
491
- setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})"
492
- end
493
- @action.call v, table
494
- end
495
- end
496
-
497
- class PackageSelectionItem < Item
498
- def initialize(name, template, default, help_default, desc)
499
- super name, template, default, desc
500
- @help_default = help_default
501
- end
502
-
503
- attr_reader :help_default
504
-
505
- def config_type
506
- 'package'
507
- end
508
-
509
- private
510
-
511
- def check(val)
512
- unless File.dir?("packages/#{val}")
513
- setup_rb_error "config: no such package: #{val}"
514
- end
515
- val
516
- end
517
- end
518
-
519
- class MetaConfigEnvironment
520
- def initialize(config, installer)
521
- @config = config
522
- @installer = installer
523
- end
524
-
525
- def config_names
526
- @config.names
527
- end
528
-
529
- def config?(name)
530
- @config.key?(name)
531
- end
532
-
533
- def bool_config?(name)
534
- @config.lookup(name).config_type == 'bool'
535
- end
536
-
537
- def path_config?(name)
538
- @config.lookup(name).config_type == 'path'
539
- end
540
-
541
- def value_config?(name)
542
- @config.lookup(name).config_type != 'exec'
543
- end
544
-
545
- def add_config(item)
546
- @config.add item
547
- end
548
-
549
- def add_bool_config(name, default, desc)
550
- @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc)
551
- end
552
-
553
- def add_path_config(name, default, desc)
554
- @config.add PathItem.new(name, 'path', default, desc)
555
- end
556
-
557
- def set_config_default(name, default)
558
- @config.lookup(name).default = default
559
- end
560
-
561
- def remove_config(name)
562
- @config.remove(name)
563
- end
564
-
565
- # For only multipackage
566
- def packages
567
- raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer
568
- @installer.packages
569
- end
570
-
571
- # For only multipackage
572
- def declare_packages(list)
573
- raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer
574
- @installer.packages = list
575
- end
576
- end
577
-
578
- end # class ConfigTable
579
-
580
- # This module requires: #verbose?, #no_harm?
581
- module FileOperations
582
-
583
- def mkdir_p(dirname, prefix = nil)
584
- dirname = prefix + File.expand_path(dirname) if prefix
585
- $stderr.puts "mkdir -p #{dirname}" if verbose?
586
- return if no_harm?
587
-
588
- # Does not check '/', it's too abnormal.
589
- dirs = File.expand_path(dirname).split(%r<(?=/)>)
590
- if /\A[a-z]:\z/i =~ dirs[0]
591
- disk = dirs.shift
592
- dirs[0] = disk + dirs[0]
593
- end
594
- dirs.each_index do |idx|
595
- path = dirs[0..idx].join('')
596
- Dir.mkdir path unless File.dir?(path)
597
- end
598
- end
599
-
600
- def rm_f(path)
601
- $stderr.puts "rm -f #{path}" if verbose?
602
- return if no_harm?
603
- force_remove_file path
604
- end
605
-
606
- def rm_rf(path)
607
- $stderr.puts "rm -rf #{path}" if verbose?
608
- return if no_harm?
609
- remove_tree path
610
- end
611
-
612
- def remove_tree(path)
613
- if File.symlink?(path)
614
- remove_file path
615
- elsif File.dir?(path)
616
- remove_tree0 path
617
- else
618
- force_remove_file path
619
- end
620
- end
621
-
622
- def remove_tree0(path)
623
- Dir.foreach(path) do |ent|
624
- next if ent == '.'
625
- next if ent == '..'
626
- entpath = "#{path}/#{ent}"
627
- if File.symlink?(entpath)
628
- remove_file entpath
629
- elsif File.dir?(entpath)
630
- remove_tree0 entpath
631
- else
632
- force_remove_file entpath
633
- end
634
- end
635
- begin
636
- Dir.rmdir path
637
- rescue Errno::ENOTEMPTY
638
- # directory may not be empty
639
- end
640
- end
641
-
642
- def move_file(src, dest)
643
- force_remove_file dest
644
- begin
645
- File.rename src, dest
646
- rescue
647
- File.open(dest, 'wb') {|f|
648
- f.write File.binread(src)
649
- }
650
- File.chmod File.stat(src).mode, dest
651
- File.unlink src
652
- end
653
- end
654
-
655
- def force_remove_file(path)
656
- begin
657
- remove_file path
658
- rescue
659
- end
660
- end
661
-
662
- def remove_file(path)
663
- File.chmod 0777, path
664
- File.unlink path
665
- end
666
-
667
- # === install
668
- def install(from, dest, mode, prefix = nil)
669
- $stderr.puts "install #{from} #{dest}" if verbose?
670
- return if no_harm?
671
-
672
- realdest = prefix ? prefix + File.expand_path(dest) : dest
673
- realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
674
- str = File.binread(from)
675
- if diff?(str, realdest)
676
- verbose_off {
677
- rm_f realdest if File.exist?(realdest)
678
- }
679
- begin
680
- File.open(realdest, 'wb') {|f|
681
- f.write(str)
682
- }
683
- rescue Errno::ENOENT => error
684
- pp error
685
- end
686
- File.chmod(mode, realdest) if File.exist? realdest
687
-
688
- File.open("#{objdir_root()}/InstalledFiles", 'a') {|f|
689
- if prefix
690
- f.puts realdest.sub(prefix, '')
691
- else
692
- f.puts realdest
693
- end
694
- }
695
- end
696
- end
697
-
698
- # === diff?
699
- def diff?(new_content, path)
700
- return true unless File.exist?(path)
701
- new_content != File.binread(path)
702
- end
703
-
704
- def command(*args)
705
- $stderr.puts args.join(' ') if verbose?
706
- system(*args) or raise RuntimeError,
707
- "system(#{args.map{|a| a.inspect }.join(' ')}) failed"
708
- end
709
-
710
- def ruby(*args)
711
- command config('rubyprog'), *args
712
- end
713
-
714
- def make(task = nil)
715
- command(*[config('makeprog'), task].compact)
716
- end
717
-
718
- def extdir?(dir)
719
- File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb")
720
- end
721
-
722
- def files_of(dir)
723
- Dir.open(dir) {|d|
724
- return d.select {|ent| File.file?("#{dir}/#{ent}") }
725
- }
726
- end
727
-
728
- DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn )
729
-
730
- def directories_of(dir)
731
- Dir.open(dir) {|d|
732
- return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT
733
- }
734
- end
735
-
736
- end
737
-
738
-
739
- # This module requires: #srcdir_root, #objdir_root, #relpath
740
- module HookScriptAPI
741
-
742
- def get_config(key)
743
- @config[key]
744
- end
745
-
746
- alias config get_config
747
-
748
- # obsolete: use metaconfig to change configuration
749
- def set_config(key, val)
750
- @config[key] = val
751
- end
752
-
753
- #
754
- # srcdir/objdir (works only in the package directory)
755
- #
756
-
757
- def curr_srcdir
758
- "#{srcdir_root()}/#{relpath()}"
759
- end
760
-
761
- def curr_objdir
762
- "#{objdir_root()}/#{relpath()}"
763
- end
764
-
765
- def srcfile(path)
766
- "#{curr_srcdir()}/#{path}"
767
- end
768
-
769
- def srcexist?(path)
770
- File.exist?(srcfile(path))
771
- end
772
-
773
- def srcdirectory?(path)
774
- File.dir?(srcfile(path))
775
- end
776
-
777
- def srcfile?(path)
778
- File.file?(srcfile(path))
779
- end
780
-
781
- def srcentries(path = '.')
782
- Dir.open("#{curr_srcdir()}/#{path}") {|d|
783
- return d.to_a - %w(. ..)
784
- }
785
- end
786
-
787
- def srcfiles(path = '.')
788
- srcentries(path).select {|fname|
789
- File.file?(File.join(curr_srcdir(), path, fname))
790
- }
791
- end
792
-
793
- def srcdirectories(path = '.')
794
- srcentries(path).select {|fname|
795
- File.dir?(File.join(curr_srcdir(), path, fname))
796
- }
797
- end
798
-
799
- end
800
-
801
-
802
- class ToplevelInstaller
803
-
804
- Version = '3.4.1'
805
- Copyright = 'Copyright (c) 2000-2005 Minero Aoki'
806
-
807
- TASKS = [
808
- [ 'all', 'do config, setup, then install' ],
809
- [ 'config', 'saves your configurations' ],
810
- [ 'show', 'shows current configuration' ],
811
- [ 'setup', 'compiles ruby extentions and others' ],
812
- [ 'install', 'installs files' ],
813
- [ 'test', 'run all tests in test/' ],
814
- [ 'clean', "does `make clean' for each extention" ],
815
- [ 'distclean',"does `make distclean' for each extention" ]
816
- ]
817
-
818
- def ToplevelInstaller.invoke
819
- config = ConfigTable.new(load_rbconfig())
820
- config.load_standard_entries
821
- config.load_multipackage_entries if multipackage?
822
- config.fixup
823
- klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller)
824
- klass.new(File.dirname($0), config).invoke
825
- end
826
-
827
- def ToplevelInstaller.multipackage?
828
- File.dir?(File.dirname($0) + '/packages')
829
- end
830
-
831
- def ToplevelInstaller.load_rbconfig
832
- if arg = ARGV.detect {|inner_arg| /\A--rbconfig=/ =~ inner_arg }
833
- ARGV.delete(arg)
834
- load File.expand_path(arg.split(/=/, 2)[1])
835
- $".push 'rbconfig.rb'
836
- else
837
- require 'rbconfig'
838
- end
839
- ::RbConfig::CONFIG
840
- end
841
-
842
- def initialize(ardir_root, config)
843
- @ardir = File.expand_path(ardir_root)
844
- @config = config
845
- # cache
846
- @valid_task_re = nil
847
- end
848
-
849
- # ========================================================================= #
850
- # === config
851
- # ========================================================================= #
852
- def config(key)
853
- @config[key]
854
- end
855
-
856
- def inspect
857
- "#<#{self.class} #{__id__()}>"
858
- end
859
-
860
- def invoke
861
- run_metaconfigs
862
- case task = parsearg_global()
863
- when nil, 'all'
864
- parsearg_config
865
- init_installers
866
- exec_config
867
- exec_setup
868
- exec_install
869
- else
870
- case task
871
- # === config
872
- when 'config', 'test'
873
- ;
874
- when 'clean', 'distclean'
875
- @config.load_savefile if File.exist?(@config.savefile)
876
- else
877
- @config.load_savefile
878
- end
879
- __send__ "parsearg_#{task}"
880
- init_installers
881
- __send__ "exec_#{task}"
882
- end
883
- end
884
-
885
- def run_metaconfigs
886
- @config.load_script "#{@ardir}/metaconfig"
887
- end
888
-
889
- def init_installers
890
- @installer = Installer.new(@config, @ardir, File.expand_path('.'))
891
- end
892
-
893
- #
894
- # Hook Script API bases
895
- #
896
-
897
- def srcdir_root
898
- @ardir
899
- end
900
-
901
- def objdir_root
902
- '.'
903
- end
904
-
905
- def relpath
906
- '.'
907
- end
908
-
909
- #
910
- # Option Parsing
911
- #
912
-
913
- def parsearg_global
914
- while arg = ARGV.shift
915
- case arg
916
- when /\A\w+\z/
917
- setup_rb_error "invalid task: #{arg}" unless valid_task?(arg)
918
- return arg
919
- when '-q', '--quiet'
920
- @config.verbose = false
921
- when '--verbose'
922
- @config.verbose = true
923
- when '--help'
924
- print_usage $stdout
925
- exit 0
926
- when '--version'
927
- puts "#{File.basename($0)} version #{Version}"
928
- exit 0
929
- when '--copyright'
930
- puts Copyright
931
- exit 0
932
- else
933
- setup_rb_error "unknown global option '#{arg}'"
934
- end
935
- end
936
- nil
937
- end
938
-
939
- def valid_task?(t)
940
- valid_task_re() =~ t
941
- end
942
-
943
- def valid_task_re
944
- @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/
945
- end
946
-
947
- def parsearg_no_options
948
- unless ARGV.empty?
949
- task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1)
950
- setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}"
951
- end
952
- end
953
-
954
- alias parsearg_show parsearg_no_options
955
- alias parsearg_setup parsearg_no_options
956
- alias parsearg_test parsearg_no_options
957
- alias parsearg_clean parsearg_no_options
958
- alias parsearg_distclean parsearg_no_options
959
-
960
- def parsearg_config
961
- evalopt = []
962
- set = []
963
- @config.config_opt = []
964
- while i = ARGV.shift
965
- if /\A--?\z/ =~ i
966
- @config.config_opt = ARGV.dup
967
- break
968
- end
969
- name, value = *@config.parse_opt(i)
970
- if @config.value_config?(name)
971
- @config[name] = value
972
- else
973
- evalopt.push [name, value]
974
- end
975
- set.push name
976
- end
977
- evalopt.each do |inner_name, inner_value|
978
- @config.lookup(inner_name).evaluate inner_value, @config
979
- end
980
- # Check if configuration is valid
981
- set.each do |n|
982
- @config[n] if @config.value_config?(n)
983
- end
984
- end
985
-
986
- def parsearg_install
987
- @config.no_harm = false
988
- @config.install_prefix = ''
989
- while a = ARGV.shift
990
- case a
991
- when '--no-harm'
992
- @config.no_harm = true
993
- when /\A--prefix=/
994
- path = a.split(/=/, 2)[1]
995
- path = File.expand_path(path) unless path[0,1] == '/'
996
- @config.install_prefix = path
997
- else
998
- setup_rb_error "install: unknown option #{a}"
999
- end
1000
- end
1001
- end
1002
-
1003
- def print_usage(out)
1004
- out.puts 'Typical Installation Procedure:'
1005
- out.puts " $ ruby #{File.basename $0} config"
1006
- out.puts " $ ruby #{File.basename $0} setup"
1007
- out.puts " # ruby #{File.basename $0} install (may require root privilege)"
1008
- out.puts
1009
- out.puts 'Detailed Usage:'
1010
- out.puts " ruby #{File.basename $0} <global option>"
1011
- out.puts " ruby #{File.basename $0} [<global options>] <task> [<task options>]"
1012
-
1013
- fmt = " %-24s %s\n"
1014
- out.puts
1015
- out.puts 'Global options:'
1016
- out.printf fmt, '-q,--quiet', 'suppress message outputs'
1017
- out.printf fmt, ' --verbose', 'output messages verbosely'
1018
- out.printf fmt, ' --help', 'print this message'
1019
- out.printf fmt, ' --version', 'print version and quit'
1020
- out.printf fmt, ' --copyright', 'print copyright and quit'
1021
- out.puts
1022
- out.puts 'Tasks:'
1023
- TASKS.each do |name, desc|
1024
- out.printf fmt, name, desc
1025
- end
1026
-
1027
- fmt = " %-24s %s [%s]\n"
1028
- out.puts
1029
- out.puts 'Options for CONFIG or ALL:'
1030
- @config.each do |item|
1031
- out.printf fmt, item.help_opt, item.description, item.help_default
1032
- end
1033
- out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's"
1034
- out.puts
1035
- out.puts 'Options for INSTALL:'
1036
- out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
1037
- out.printf fmt, '--prefix=path', 'install path prefix', ''
1038
- out.puts
1039
- end
1040
-
1041
- #
1042
- # Task Handlers
1043
- #
1044
-
1045
- def exec_config
1046
- @installer.exec_config
1047
- @config.save # must be final
1048
- end
1049
-
1050
- def exec_setup
1051
- @installer.exec_setup
1052
- end
1053
-
1054
- def exec_install
1055
- @installer.exec_install
1056
- end
1057
-
1058
- def exec_test
1059
- @installer.exec_test
1060
- end
1061
-
1062
- def exec_show
1063
- @config.each do |i|
1064
- printf "%-20s %s\n", i.name, i.value if i.value?
1065
- end
1066
- end
1067
-
1068
- def exec_clean
1069
- @installer.exec_clean
1070
- end
1071
-
1072
- def exec_distclean
1073
- @installer.exec_distclean
1074
- end
1075
-
1076
- end # class ToplevelInstaller
1077
-
1078
-
1079
- class ToplevelInstallerMulti < ToplevelInstaller
1080
-
1081
- include FileOperations
1082
-
1083
- def initialize(ardir_root, config)
1084
- super
1085
- @packages = directories_of("#{@ardir}/packages")
1086
- raise 'no package exists' if @packages.empty?
1087
- @root_installer = Installer.new(@config, @ardir, File.expand_path('.'))
1088
- end
1089
-
1090
- def run_metaconfigs
1091
- @config.load_script "#{@ardir}/metaconfig", self
1092
- @packages.each do |name|
1093
- @config.load_script "#{@ardir}/packages/#{name}/metaconfig"
1094
- end
1095
- end
1096
-
1097
- attr_reader :packages
1098
-
1099
- def packages=(list)
1100
- raise 'package list is empty' if list.empty?
1101
- list.each do |name|
1102
- raise "directory packages/#{name} does not exist"\
1103
- unless File.dir?("#{@ardir}/packages/#{name}")
1104
- end
1105
- @packages = list
1106
- end
1107
-
1108
- def init_installers
1109
- @installers = {}
1110
- @packages.each do |pack|
1111
- @installers[pack] = Installer.new(@config,
1112
- "#{@ardir}/packages/#{pack}",
1113
- "packages/#{pack}")
1114
- end
1115
- with = extract_selection(config('with'))
1116
- without = extract_selection(config('without'))
1117
- @selected = @installers.keys.select {|name|
1118
- (with.empty? or with.include?(name)) \
1119
- and not without.include?(name)
1120
- }
1121
- end
1122
-
1123
- def extract_selection(list)
1124
- a = list.split(/,/)
1125
- a.each do |name|
1126
- setup_rb_error "no such package: #{name}" unless @installers.key?(name)
1127
- end
1128
- a
1129
- end
1130
-
1131
- def print_usage(f)
1132
- super
1133
- f.puts 'Inluded packages:'
1134
- f.puts ' ' + @packages.sort.join(' ')
1135
- f.puts
1136
- end
1137
-
1138
- #
1139
- # Task Handlers
1140
- #
1141
-
1142
- def exec_config
1143
- run_hook 'pre-config'
1144
- each_selected_installers {|inst| inst.exec_config }
1145
- run_hook 'post-config'
1146
- @config.save # must be final
1147
- end
1148
-
1149
- def exec_setup
1150
- run_hook 'pre-setup'
1151
- each_selected_installers {|inst| inst.exec_setup }
1152
- run_hook 'post-setup'
1153
- end
1154
-
1155
- def exec_install
1156
- run_hook 'pre-install'
1157
- each_selected_installers {|inst| inst.exec_install }
1158
- run_hook 'post-install'
1159
- end
1160
-
1161
- def exec_test
1162
- run_hook 'pre-test'
1163
- each_selected_installers {|inst| inst.exec_test }
1164
- run_hook 'post-test'
1165
- end
1166
-
1167
- def exec_clean
1168
- rm_f @config.savefile
1169
- run_hook 'pre-clean'
1170
- each_selected_installers {|inst| inst.exec_clean }
1171
- run_hook 'post-clean'
1172
- end
1173
-
1174
- def exec_distclean
1175
- rm_f @config.savefile
1176
- run_hook 'pre-distclean'
1177
- each_selected_installers {|inst| inst.exec_distclean }
1178
- run_hook 'post-distclean'
1179
- end
1180
-
1181
- #
1182
- # lib
1183
- #
1184
-
1185
- def each_selected_installers
1186
- Dir.mkdir 'packages' unless File.dir?('packages')
1187
- @selected.each do |pack|
1188
- $stderr.puts "Processing the package `#{pack}' ..." if verbose?
1189
- Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}")
1190
- Dir.chdir "packages/#{pack}"
1191
- yield @installers[pack]
1192
- Dir.chdir '../..'
1193
- end
1194
- end
1195
-
1196
- def run_hook(id)
1197
- @root_installer.run_hook id
1198
- end
1199
-
1200
- # module FileOperations requires this
1201
- def verbose?
1202
- @config.verbose?
1203
- end
1204
-
1205
- # module FileOperations requires this
1206
- def no_harm?
1207
- @config.no_harm?
1208
- end
1209
-
1210
- end # class ToplevelInstallerMulti
1211
-
1212
-
1213
- class Installer
1214
-
1215
- FILETYPES = %w( bin lib ext data conf man )
1216
-
1217
- include FileOperations
1218
- include HookScriptAPI
1219
-
1220
- def initialize(config, srcroot, objroot)
1221
- @config = config
1222
- @srcdir = File.expand_path(srcroot)
1223
- @objdir = File.expand_path(objroot)
1224
- @currdir = '.'
1225
- end
1226
-
1227
- def inspect
1228
- "#<#{self.class} #{File.basename(@srcdir)}>"
1229
- end
1230
-
1231
- def noop(rel)
1232
- end
1233
-
1234
- #
1235
- # Hook Script API base methods
1236
- #
1237
-
1238
- def srcdir_root
1239
- @srcdir
1240
- end
1241
-
1242
- def objdir_root
1243
- @objdir
1244
- end
1245
-
1246
- def relpath
1247
- @currdir
1248
- end
1249
-
1250
- #
1251
- # Config Access
1252
- #
1253
-
1254
- # module FileOperations requires this
1255
- def verbose?
1256
- @config.verbose?
1257
- end
1258
-
1259
- # module FileOperations requires this
1260
- def no_harm?
1261
- @config.no_harm?
1262
- end
1263
-
1264
- def verbose_off
1265
- begin
1266
- save, @config.verbose = @config.verbose?, false
1267
- yield
1268
- ensure
1269
- @config.verbose = save
1270
- end
1271
- end
1272
-
1273
- #
1274
- # TASK config
1275
- #
1276
-
1277
- def exec_config
1278
- exec_task_traverse 'config'
1279
- end
1280
-
1281
- alias config_dir_bin noop
1282
- alias config_dir_lib noop
1283
-
1284
- def config_dir_ext(rel)
1285
- extconf if extdir?(curr_srcdir())
1286
- end
1287
-
1288
- alias config_dir_data noop
1289
- alias config_dir_conf noop
1290
- alias config_dir_man noop
1291
-
1292
- def extconf
1293
- ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt
1294
- end
1295
-
1296
- #
1297
- # TASK setup
1298
- #
1299
-
1300
- def exec_setup
1301
- exec_task_traverse 'setup'
1302
- end
1303
-
1304
- def setup_dir_bin(rel)
1305
- # files_of(curr_srcdir()).each do |fname|
1306
- # update_shebang_line "#{curr_srcdir()}/#{fname}"
1307
- # end # The above line was modifed by shevy Sep 2014.
1308
- end
1309
-
1310
- alias setup_dir_lib noop
1311
-
1312
- def setup_dir_ext(rel)
1313
- make if extdir?(curr_srcdir())
1314
- end
1315
-
1316
- alias setup_dir_data noop
1317
- alias setup_dir_conf noop
1318
- alias setup_dir_man noop
1319
-
1320
- def update_shebang_line(path)
1321
- return if no_harm?
1322
- return if config('shebang') == 'never'
1323
- old = Shebang.load(path)
1324
- if old
1325
- $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1
1326
- new = new_shebang(old)
1327
- return if new.to_s == old.to_s
1328
- else
1329
- return unless config('shebang') == 'all'
1330
- new = Shebang.new(config('rubypath'))
1331
- end
1332
- $stderr.puts "updating shebang: #{File.basename(path)}" if verbose?
1333
- open_atomic_writer(path) {|output|
1334
- File.open(path, 'rb') {|f|
1335
- f.gets if old # discard
1336
- output.puts new.to_s
1337
- output.print f.read
1338
- }
1339
- }
1340
- end
1341
-
1342
- def new_shebang(old)
1343
- if /\Aruby/ =~ File.basename(old.cmd)
1344
- Shebang.new(config('rubypath'), old.args)
1345
- elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby'
1346
- Shebang.new(config('rubypath'), old.args[1..-1])
1347
- else
1348
- return old unless config('shebang') == 'all'
1349
- Shebang.new(config('rubypath'))
1350
- end
1351
- end
1352
-
1353
- def open_atomic_writer(path, &block)
1354
- tmpfile = File.basename(path) + '.tmp'
1355
- begin
1356
- File.open(tmpfile, 'wb', &block)
1357
- File.rename tmpfile, File.basename(path)
1358
- ensure
1359
- File.unlink tmpfile if File.exist?(tmpfile)
1360
- end
1361
- end
1362
-
1363
- class Shebang
1364
- def Shebang.load(path)
1365
- line = nil
1366
- File.open(path) {|f|
1367
- line = f.gets
1368
- }
1369
- return nil unless /\A#!/ =~ line
1370
- parse(line)
1371
- end
1372
-
1373
- def Shebang.parse(line)
1374
- cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ')
1375
- new(cmd, args)
1376
- end
1377
-
1378
- def initialize(cmd, args = [])
1379
- @cmd = cmd
1380
- @args = args
1381
- end
1382
-
1383
- attr_reader :cmd
1384
- attr_reader :args
1385
-
1386
- def to_s
1387
- "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}")
1388
- end
1389
- end
1390
-
1391
- #
1392
- # TASK install
1393
- #
1394
-
1395
- GLOB2REGEX = {
1396
- '.' => '\.',
1397
- '$' => '\$',
1398
- '#' => '\#',
1399
- '*' => '.*'
1400
- }
1401
-
1402
- def exec_install
1403
- rm_f 'InstalledFiles'
1404
- exec_task_traverse 'install'
1405
- end
1406
-
1407
- # ========================================================================= #
1408
- # === install_dir_bin
1409
- # ========================================================================= #
1410
- def install_dir_bin(rel)
1411
- install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755
1412
- end
1413
-
1414
- def install_dir_lib(rel)
1415
- install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644
1416
- end
1417
-
1418
- def install_dir_ext(rel)
1419
- return unless extdir?(curr_srcdir())
1420
- install_files rubyextentions('.'),
1421
- "#{config('sodir')}/#{File.dirname(rel)}",
1422
- 0555
1423
- end
1424
-
1425
- def install_dir_data(rel)
1426
- install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644
1427
- end
1428
-
1429
- def install_dir_conf(rel)
1430
- # FIXME: should not remove current config files
1431
- # (rename previous file to .old/.org)
1432
- install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644
1433
- end
1434
-
1435
- def install_dir_man(rel)
1436
- install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644
1437
- end
1438
-
1439
- def install_files(list, dest, mode)
1440
- mkdir_p dest, @config.install_prefix
1441
- list.each { |fname|
1442
- install fname, dest, mode, @config.install_prefix
1443
- }
1444
- end
1445
-
1446
- def libfiles
1447
- glob_reject(%w(*.y *.output), targetfiles())
1448
- end
1449
-
1450
- def rubyextentions(dir)
1451
- ents = glob_select("*.#{@config.dllext}", targetfiles())
1452
- if ents.empty?
1453
- setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
1454
- end
1455
- ents
1456
- end
1457
-
1458
- def targetfiles
1459
- mapdir(existfiles() - hookfiles())
1460
- end
1461
-
1462
- def mapdir(ents)
1463
- ents.map {|ent|
1464
- if File.exist?(ent)
1465
- then ent # objdir
1466
- else "#{curr_srcdir()}/#{ent}" # srcdir
1467
- end
1468
- }
1469
- end
1470
-
1471
- # picked up many entries from cvs-1.11.1/src/ignore.c
1472
- JUNK_FILES = %w(
1473
- core RCSLOG tags TAGS .make.state
1474
- .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
1475
- *~ *.old *.bak *.BAK *.orig *.rej _$* *$
1476
-
1477
- *.org *.in .*
1478
- )
1479
-
1480
- def existfiles
1481
- glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.')))
1482
- end
1483
-
1484
- def hookfiles
1485
- %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
1486
- %w( config setup install clean ).map {|t| sprintf(fmt, t) }
1487
- }.flatten
1488
- end
1489
-
1490
- def glob_select(pat, ents)
1491
- re = globs2re([pat])
1492
- ents.select {|ent| re =~ ent }
1493
- end
1494
-
1495
- # ========================================================================= #
1496
- # === glob_reject
1497
- # ========================================================================= #
1498
- def glob_reject(pats, ents)
1499
- re = globs2re(pats)
1500
- begin
1501
- ents.reject {|ent| re =~ ent }
1502
- rescue ArgumentError => error
1503
- pp error
1504
- end
1505
- end
1506
-
1507
- def globs2re(pats)
1508
- /\A(?:#{
1509
- pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|')
1510
- })\z/
1511
- end
1512
-
1513
- #
1514
- # TASK test
1515
- #
1516
-
1517
- TESTDIR = 'test'
1518
-
1519
- def exec_test
1520
- unless File.directory?('test')
1521
- $stderr.puts 'no test in this package' if verbose?
1522
- return
1523
- end
1524
- $stderr.puts 'Running tests...' if verbose?
1525
- begin
1526
- require 'test/unit'
1527
- rescue LoadError
1528
- setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.'
1529
- end
1530
- runner = Test::Unit::AutoRunner.new(true)
1531
- runner.to_run << TESTDIR
1532
- runner.run
1533
- end
1534
-
1535
- #
1536
- # TASK clean
1537
- #
1538
-
1539
- def exec_clean
1540
- exec_task_traverse 'clean'
1541
- rm_f @config.savefile
1542
- rm_f 'InstalledFiles'
1543
- end
1544
-
1545
- alias clean_dir_bin noop
1546
- alias clean_dir_lib noop
1547
- alias clean_dir_data noop
1548
- alias clean_dir_conf noop
1549
- alias clean_dir_man noop
1550
-
1551
- def clean_dir_ext(rel)
1552
- return unless extdir?(curr_srcdir())
1553
- make 'clean' if File.file?('Makefile')
1554
- end
1555
-
1556
- #
1557
- # TASK distclean
1558
- #
1559
-
1560
- def exec_distclean
1561
- exec_task_traverse 'distclean'
1562
- rm_f @config.savefile
1563
- rm_f 'InstalledFiles'
1564
- end
1565
-
1566
- alias distclean_dir_bin noop
1567
- alias distclean_dir_lib noop
1568
-
1569
- def distclean_dir_ext(rel)
1570
- return unless extdir?(curr_srcdir())
1571
- make 'distclean' if File.file?('Makefile')
1572
- end
1573
-
1574
- alias distclean_dir_data noop
1575
- alias distclean_dir_conf noop
1576
- alias distclean_dir_man noop
1577
-
1578
- #
1579
- # Traversing
1580
- #
1581
-
1582
- def exec_task_traverse(task)
1583
- run_hook "pre-#{task}"
1584
- FILETYPES.each do |type|
1585
- if type == 'ext' and config('without-ext') == 'yes'
1586
- $stderr.puts 'skipping ext/* by user option' if verbose?
1587
- next
1588
- end
1589
- traverse task, type, "#{task}_dir_#{type}"
1590
- end
1591
- run_hook "post-#{task}"
1592
- end
1593
-
1594
- # ========================================================================= #
1595
- # === traverse
1596
- #
1597
- # This method can fail when it comes to Encoding-related issues.
1598
- # ========================================================================= #
1599
- def traverse(task, rel, mid)
1600
- dive_into(rel) {
1601
- run_hook "pre-#{task}"
1602
- __send__(mid, rel.sub(%r[\A.*?(?:/|\z)], ''))
1603
- directories_of(curr_srcdir()).each { |d|
1604
- traverse task, "#{rel}/#{d}", mid
1605
- }
1606
- run_hook "post-#{task}"
1607
- }
1608
- end
1609
-
1610
- def dive_into(rel)
1611
- return unless File.dir?("#{@srcdir}/#{rel}")
1612
-
1613
- dir = File.basename(rel)
1614
- Dir.mkdir dir unless File.dir?(dir)
1615
- prevdir = Dir.pwd
1616
- Dir.chdir dir
1617
- $stderr.puts '---> ' + rel if verbose?
1618
- @currdir = rel
1619
- yield
1620
- Dir.chdir prevdir
1621
- $stderr.puts '<--- ' + rel if verbose?
1622
- @currdir = File.dirname(rel)
1623
- end
1624
-
1625
- def run_hook(id)
1626
- path = [ "#{curr_srcdir()}/#{id}",
1627
- "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) }
1628
- return unless path
1629
- begin
1630
- instance_eval File.read(path), path, 1
1631
- rescue
1632
- raise if $DEBUG
1633
- setup_rb_error "hook #{path} failed:\n" + $!.message
1634
- end
1635
- end
1636
-
1637
- end # class Installer
1638
-
1639
-
1640
- class SetupError < StandardError; end
1641
-
1642
- def setup_rb_error(msg)
1643
- raise SetupError, msg
1644
- end
1645
-
1646
- if $0 == __FILE__
1647
- begin
1648
- ToplevelInstaller.invoke
1649
- rescue SetupError
1650
- raise if $DEBUG
1651
- $stderr.puts $!.message
1652
- $stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
1653
- exit 1
1654
- end
1655
- end