Class: RBT::SymlinkFromToCurrent
- Inherits:
-
CompileBase
show all
- Defined in:
- lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb
Overview
RBT::SymlinkFromToCurrent
Constant Summary
collapse
- DO_REGISTER_INTO_THE_LOCAL_YAML_DATABASE =
#
DO_REGISTER_INTO_THE_LOCAL_YAML_DATABASE
#
true
- ARRAY_ALLOWED_SUBDIRECTORIES =
#
RBT::SymlinkFromToCurrent::ARRAY_ALLOWED_SUBDIRECTORIES
Which subdirectories are allowed for this class. bin/, sbin/ and lib/ are the three main directories.
The trailing ‘/’ can be omitted.
#
%w(
bin
sbin
lib
lib64
include
etc
pkgconfig
man
Shared
shared
share
yaml
Settings
)
CompileBaseModule::FILE_AUTOGEN
LeanPrototype::ALL_COLOUR_METHODS, LeanPrototype::ARRAY_KDE_KONSOLE_COLOURS_IN_USE, LeanPrototype::DAY_NAMES, LeanPrototype::NAMESPACE, LeanPrototype::SILENT_REDIRECTION
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === RBT::SymlinkFromToCurrent[] ========================================================================= #.
Instance Method Summary
collapse
-
#assumed_target_of(i) ⇒ Object
# === assumed_target_of ========================================================================= #.
-
#capitalized(i) ⇒ Object
# === capitalized ========================================================================= #.
-
#consider_removing_empty_directories ⇒ Object
# === consider_removing_empty_directories ========================================================================= #.
-
#consider_symlinking_headers ⇒ Object
-
#consider_symlinking_pkgconfig_files(appdir_target = full_path_to_the_target_program? ) ⇒ Object
# === consider_symlinking_pkgconfig_files.
-
#current_target? ⇒ Boolean
(also: #target?)
# === current_target?.
-
#do_force_symlink ⇒ Object
# === do_force_symlink ========================================================================= #.
-
#do_keep_empty_directories ⇒ Object
(also: #keep_empty_directories)
# === do_keep_empty_directories ========================================================================= #.
-
#do_not_register_into_the_local_yaml_database ⇒ Object
(also: #do_not_register)
# === do_not_register_into_the_local_yaml_database ========================================================================= #.
-
#do_not_symlink ⇒ Object
# === do_not_symlink ========================================================================= #.
-
#do_not_symlink=(i) ⇒ Object
# === do_not_symlink= ========================================================================= #.
-
#do_register_into_the_local_yaml_database? ⇒ Boolean
# === do_register_into_the_local_yaml_database? ========================================================================= #.
-
#do_register_into_yaml_database(i = full_path?, , register_program_files_into_the_yaml_database = RBT.register_program_files_into_yaml_database?) ⇒ Object
# === do_register_into_yaml_database ========================================================================= #.
-
#do_remove_empty_directories ⇒ Object
# === do_remove_empty_directories.
-
#do_symlink ⇒ Object
(also: #do_symlink_all_entries)
# === do_symlink.
-
#do_symlink_the_headers ⇒ Object
-
#first_argument_or_current_working_directory ⇒ Object
# === first_argument_or_current_working_directory ========================================================================= #.
-
#force_symlink? ⇒ Boolean
(also: #force_the_symlink_operation?)
# === force_symlink? ========================================================================= #.
-
#inform_the_user_what_will_be_done(program_name = program_name? ) ⇒ Object
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ SymlinkFromToCurrent
constructor
# === initialize ========================================================================= #.
-
#is_it_a_number?(i) ⇒ Boolean
# === is_it_a_number? ========================================================================= #.
-
#keep_empty_directories? ⇒ Boolean
# === keep_empty_directories? ========================================================================= #.
-
#keep_track_which_program_was_last_symlinked ⇒ Object
(also: #try_to_save_the_name_of_the_program_into_a_local_file)
# === keep_track_which_program_was_last_symlinked.
-
#menu(i = hyphen_commandline_arguments? ) ⇒ Object
-
#notify_the_user_processing_this_directory_for_symlinking_into_that_target(name_of_the_subdirectory, target) ⇒ Object
# === notify_the_user_processing_this_directory_for_symlinking_into_that_target ========================================================================= #.
-
#only_allow_bin_as_subdirectory ⇒ Object
(also: #symlink_only_the_bin_subdirectory)
# === only_allow_bin_as_subdirectory.
-
#program_version? ⇒ Boolean
# === program_version?.
-
#register_for_removal(i) ⇒ Object
# === register_for_removal.
-
#remove_empty_directories? ⇒ Boolean
# === remove_empty_directories? ========================================================================= #.
-
#remove_these_directories? ⇒ Boolean
# === remove_these_directories? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#shall_we_symlink_the_headers? ⇒ Boolean
-
#show_help ⇒ Object
# === show_help.
-
#symlink_pkgconfig_files? ⇒ Boolean
# === symlink_pkgconfig_files? ========================================================================= #.
-
#symlink_this_program? ⇒ Boolean
(also: #program_name?, #input?, #name_of_the_program?, #program?)
# === symlink_this_program?.
-
#use_this_program? ⇒ Boolean
(also: #prefix?, #full_path?, #path?, #full_path_to_the_target_program?, #target_directory?)
# === use_this_program? ========================================================================= #.
-
#will_we_symlink? ⇒ Boolean
(also: #we_will_symlink?)
# === will_we_symlink? ========================================================================= #.
#always_show_dependencies?, #capitalize_program_names?, #cflags?, #check_whether_we_will_install_only_programs_from_the_bin_subdirectory, #cleanup_system_tag_directory, #config?, #consider_removing_libtool_la_files, #consider_symlinking_cmake_modules, #consider_symlinking_header_files_into_the_usr_include_hierarchy, #consider_symlinking_lib64_into_lib, #cookbook_dataset_autosymlink_lib64?, #cookbook_dataset_program_version?, #create_a_new_current_symlink_here, #create_architecture_file, #do_invoke_symlink_program, #do_play_song, #editor_to_use?, #email?, #exit_on_unregistered_cookbook_entries?, #has_an_error_occurred?, #host_cpu?, #install_only_binaries?, #installer_constant?, make_command?, #no_error_has_occurred?, #play_song?, #recipes_dir?, #register_program, #remove_compiling_is_in_progress, #report_to_developers, #reset_the_module, #return_build_type, #return_chained_programs, #return_files_from_the_profiles_directory, #return_these_programs, #run_ldconfig?, #shall_we_symlink_the_header_files_into_the_usr_include_hierarchy?, #store_full_configure_command_into_resources_directory, #symlink_into_tags, #symlink_into_usr_lib_dir?, #symlink_m4_macros, #symlink_program, #symlink_program?, #update_kde_apps, #use_ccache?, #use_gobolinux_symlinkprogram?, #use_mrxvt?, #use_porg?, #use_stow?, #use_tags?, #uses_appdir_prefix?, #validate_the_cookbook_aliases
Methods inherited from Base
#cat, #cd_back_to_the_current_working_directory, #consider_reporting_how_many_programs_are_registered, #cookbook_files?, #copy_recursively, #delete_code_of_conduct?, #determine_appdir_prefix_from_this_input, #directory_validation?, #do_not_show_names, #fast_return_file_size_of_this_program, #file_last_symlinked_program?, #file_programs_version_url, #gem_version, #is_a_64bit_system?, #is_ccache_available?, #is_porg_available?, #is_this_binary_registered?, #is_this_program_included?, #make_command?, #make_install_command?, #new_cookbook_instance_for, #program_exists?, #publish_list_of_all_programs_version, #rcp, registered_binaries?, #remove_symlink, #rename_kde_konsole_tab, #repackage, #report_n_programs, #report_working_directory, #return_compile_time_statistics, #return_n_random_characters, #return_version_of_this_program, #run_make_then_make_install, #sanitize_url1_entry, #set_source_directory, #show_overview_over_available_utility_scripts, #symlink_all_files_from_this_directory_to_that_directory, #system_tags?, #upload_list_of_all_programs_version, #use_yaml_database_for_tags?, #warn_and_exit, #wget
#a_or_an?, #abbreviations?, #absolute_path, #action, #add_to_the_commandline_arguments, #all_binaries?, #all_files_from, #all_libraries?, #allowed_cookbook_entries?, #appdir_location_of?, #append_onto_the_internal_hash, #append_what_into, #archive_type_of?, #available_programs?, #be_quiet?, #be_verbose?, #begins_with_a_comment?, #capitalize_first_alphabetical_character, #cd_to_the_log_directory, #cd_to_the_temp_directory, #change_directory, #change_permission, #cheering_person?, #chmod, #chop_off_archive, #clear_commandline_arguments, #cliner, #coloured_and_padded_e, #coloured_and_padded_esystem, #coloured_esystem, #colourize_directory_for_system_results, #colourize_this_error, #colourize_this_file_path, #colourize_this_warning, #commandline_arguments?, #commandline_arguments_without_hyphens?, #comment, #convert_dd_mm_yyyy_to_its_long_variant, #convert_env_variable, #copy_directory, #copy_files, #cpr, #create_directory, #current_hour?, #dd_mmm_yyy, #debug, #debug?, #directory_expanded_cookbooks?, #disable_colours, #display_md5sum?, #do_not_debug, #does_the_cookbook_include_this_program?, #does_this_expanded_cookbook_file_exist_for_this_program?, #does_this_file_exist?, #does_this_file_exist_and_is_it_a_file?, #e, #eblue, #ecomment, #ecrimson, #edir, #editor?, #efancy, #eimp, #enable_colours, #enable_debug, #ensure_main_encoding_for, #eparse, #esystem, #esystem_gold, #etomato, #ewarn, #exit_program, #expanded_cookbooks_directory_exists?, #extract_this_archive, #extract_to?, #file_compiled_programs?, #file_dirname_retaining_trailing_slash, #file_predefined_installation_instructions?, #file_specification_of_registered_cookbook_entries, #find_cookbook_alias_for, #find_this_yaml_file, #first_argument?, #first_non_hyphen_argument?, #get_all_directories_from, #get_all_files_from, #get_all_programs, #get_date, #get_extended_date, #get_files_and_directories_from, #go_to_base_dir, #home_dir?, #host_system?, #infer_the_namespace, #internal_hash?, #internal_hash_set_commandline_arguments, #is_an_archive?, #is_directory?, #is_file?, #is_github_url?, #is_make_available?, #is_meson_installed?, #is_on_gobolinux?, #is_on_windows?, #is_roebe?, #is_superuser?, #is_symlink?, #is_this_a_header?, #is_this_a_library?, #is_this_program_included?, #iso_encoding?, #load_dataset_from_this_expanded_cookbook, #load_yaml, #load_yaml_file_from_the_cookbook_directory_for_this_program, #log_directory?, #main_encoding?, #meson_build_file_exists?, #months?, #move_file, #n_programs_are_available?, #n_programs_available?, #namespace?, #no_directory_exists_at, #no_directory_was_found_at, #no_opn, #no_such_file_exists, #open_in_browser, #open_in_editor, #opncomment, #opne, #opnef, #opnerev, #opnerror, #opnesystem, #opnewarn, #opnfancy, #opnn, #packages_directory?, #path_to_this_expanded_cookbooks_dataset, #pkgconfig_directory?, #populate_the_internal_hash_with_default_values, #predefined_installation_instructions?, #prepend_this_commandline_argument, #program_version_of?, #project_base_directory?, #project_yaml_directory?, #query_path?, #rarrow?, #read_file, #read_file_in_default_encoding, #read_file_with_default_encoding, #readlines, #readlines_with_proper_encoding, #register_sigint, #registered_cookbook_entries?, #remove, #remove_archive_from_the_end, #remove_comments_from_each_line, #remove_directory, #remove_double_slashes, #remove_file, #remove_newlines, #remove_parens, #remove_symlink, #remove_the_first_commandline_argument, #remove_this_commandline_argument, #remove_this_entry_from_the_commandline_arguments, #remove_trailing_ANSII_escape_code, #remove_unnecessary_data_from_url, #rename, #report_pwd, #require_the_rbt_aliases, #reset_the_internal_hash, #return_all_archives_from_this_directory, #return_appdir_prefix, #return_commandline_arguments_with_leading_hyphens, #return_current_hour_minutes_second, #return_date, #return_day_of_the_month_based_on_utc, #return_full_time, #return_hours_minutes_seconds_based_on_utc, #return_location_to_this_programs_yaml_file, #return_month_based_on_this_number, #return_month_based_on_utc, #return_opnn, #return_program_information, #return_program_name_for_gobolinux_systems, #return_pwd, #return_unicode_warning_symbol_or_empty_string, #return_utc, #return_utc_time_in_a_format_similar_to_slackware, #return_weekday_based_on_utc, #return_year_based_on_utc, #rev, #run_simulation=, #run_simulation?, #sdir, #sdir_return_pwd, #set_be_silent, #set_be_verbose, #set_first_commandline_argument, #set_namespace, #set_use_opn, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #silently_create_this_directory_if_it_does_not_yet_exist, #simp, #source_base_directory?, #ssym, #stderr, #store_into_this_directory?, #string_right_arrow?, #swarn, #symlink, #sysbin_directory?, #sysetc_directory?, #sysinclude_directory?, #syslib_directory?, #sysshare_directory?, #system_directory?, #temp_directory?, #to_bool, #to_camelcase, #to_iso_encoding, #to_unicode, #today?, #touch, #try_to_require_beautiful_url, #try_to_require_the_environment_information_gem, #try_to_require_the_extracter_gem, #try_to_require_the_open_gem, #try_to_require_the_xorg_buffer, #try_to_require_wget, #try_to_return_a_special_compile_component, #unicode_cliner, #unicode_middle_cliner, #use_colours=, #use_colours?, #use_opn=, #use_opn?, #utf_encoding?, #verbose_truth, #word_wrap, #write_what_into, #write_what_into_via_unicode, #yes_or_no
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ SymlinkFromToCurrent
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 72
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
case run_already
when :do_not_run_yet,
:dont_run_yet
run_already = false
end
if block_given?
yielded = yield
if yielded.is_a? Hash
if yielded.has_key? :use_opn
disable_opn if (yielded[:use_opn] == false)
end
else
case yielded
when :do_not_run_yet
run_already = false
when :do_not_register
do_not_register_into_the_local_yaml_database
end
end
end
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
RBT::SymlinkFromToCurrent[]
#
959
960
961
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 959
def self.[](i = ARGV)
new(i)
end
|
Instance Method Details
#assumed_target_of(i) ⇒ Object
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 392
def assumed_target_of(i)
target = i.dup
case i
when /bin$/
target = usr_bin?
when /share$/,
/shared$/,
/Shared$/
target = share_dir?
when /lib$/,
/lib64$/ target = lib_dir?
when /etc$/
target = etc_dir?
when /libexec$/
target = '/usr/libexec/'
end
return target
end
|
#capitalized(i) ⇒ Object
383
384
385
386
387
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 383
def capitalized(i)
i = i.dup
i.capitalize! if do_capitalize?
return i
end
|
#consider_removing_empty_directories ⇒ Object
#
consider_removing_empty_directories
#
189
190
191
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 189
def consider_removing_empty_directories
do_remove_empty_directories if remove_empty_directories?
end
|
#
This must be conditionally - some programs will specify that we symlink headers whereas others will not.
#
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 199
def
_ = program_name?
require 'rbt/requires/require_the_cookbook_class.rb'
if
=
else
@dataset = action(:SanitizeCookbook, _) { :fast }
unless == false
= @dataset.
end
end
if
require 'rbt/utility_scripts/symlink_headers.rb'
RBT::SymlinkHeaders.new(_)
end
end
|
#consider_symlinking_pkgconfig_files(appdir_target = full_path_to_the_target_program?
) ⇒ Object
#
consider_symlinking_pkgconfig_files
This method can be used to symlink .pc files into the /usr/lib/pkgconfig hierarchy.
Since as of February 2023 this method is no longer in use, due to a bug that took too long to understand. We may have to rewrite this class eventually.
#
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 613
def consider_symlinking_pkgconfig_files(
appdir_target = full_path_to_the_target_program?
)
if appdir_target.respond_to? :split
splitted = appdir_target.split('/')
unless splitted.last == full_path_to_the_target_program?.split('/').last
appdir_target = full_path_to_the_target_program?
end
else
opne 'A minor problem - '+steelblue('appdir_target')+' does '\
'not respond to the method .split.'
opne 'We will still continue, though.'
end
if @symlink_pkgconfig_files and
appdir_target.include?(programs_dir?)
require 'rbt/utility_scripts/symlink_pkgconfig_files.rb'
opne "Next, we will symlink all .pc files found "\
"under `#{sdir(appdir_target)}`."
SymlinkPkgconfigFiles.new(appdir_target)
end
end
|
#current_target? ⇒ Boolean
Also known as:
target?
#
current_target?
This will yield a String as a result, such as ‘/Programs/Htop/Current/’.
These constitute our the symlink-targets.
We must retain a trailing ‘/’ here.
#
443
444
445
446
447
448
449
450
451
452
453
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 443
def current_target?
_ = programs_directory?.to_s.dup
if name_of_the_program?
_ << capitalized(name_of_the_program?)
else
end
_ << '/Current/' unless _.include? 'Current'
_ = rds(_)
return _
end
|
#do_force_symlink ⇒ Object
501
502
503
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 501
def do_force_symlink
@internal_hash[:force_symlink] = true
end
|
#do_keep_empty_directories ⇒ Object
Also known as:
keep_empty_directories
#
do_keep_empty_directories
#
258
259
260
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 258
def do_keep_empty_directories
@internal_hash[:remove_empty_directories] = false
end
|
#do_not_register_into_the_local_yaml_database ⇒ Object
Also known as:
do_not_register
#
do_not_register_into_the_local_yaml_database
#
592
593
594
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 592
def do_not_register_into_the_local_yaml_database
@internal_hash[:do_register_into_the_local_yaml_database] = false
end
|
#do_not_symlink ⇒ Object
483
484
485
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 483
def do_not_symlink
@will_we_symlink = false
end
|
#do_not_symlink=(i) ⇒ Object
472
473
474
475
476
477
478
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 472
def do_not_symlink=(i)
if i == true
do_not_symlink
else
@will_we_symlink = true
end
end
|
#do_register_into_the_local_yaml_database? ⇒ Boolean
#
do_register_into_the_local_yaml_database?
#
599
600
601
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 599
def do_register_into_the_local_yaml_database?
@internal_hash[:do_register_into_the_local_yaml_database]
end
|
#do_register_into_yaml_database(i = full_path?,
, register_program_files_into_the_yaml_database = RBT.register_program_files_into_yaml_database?) ⇒ Object
#
do_register_into_yaml_database
#
338
339
340
341
342
343
344
345
346
347
348
349
350
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 338
def do_register_into_yaml_database(
i = full_path?,
register_program_files_into_the_yaml_database = RBT.register_program_files_into_yaml_database?
)
if i
unless i.include? '/'
i = static_appdir_prefix_of?(i, program_version?)
end
if register_program_files_into_the_yaml_database
action(:RegisterProgramFilesIntoYamlDatabase, i)
end
end
end
|
#do_remove_empty_directories ⇒ Object
#
do_remove_empty_directories
This method will remove directories that are empty. For this, we will make of the method remove() which resides in shared.rb.
#
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 275
def do_remove_empty_directories
if run_simulation?
opne 'As we are running in simulation mode, we will not remove '
opne 'any of the following directories:'
e
pp remove_these_directories?
e
else unless remove_these_directories?.empty?
orev "Removing these #{slateblue('(empty)')} #{rev}directories next:"
remove_these_directories?.each {|entry|
e " #{sdir(entry)}"
}
remove(remove_these_directories?)
end
end
end
|
#do_symlink ⇒ Object
Also known as:
do_symlink_all_entries
#
do_symlink
Since as of January 2020 the method will also support the –force option, which will first delete the target at /usr/bin, before doing the symlink operation. Only use it if you are certain you wish to do so.
#
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 741
def do_symlink
will_we_symlink = will_we_symlink?
_ = use_this_program?
return unless _ and !_.empty?
if _ and File.directory?(_)
inform_the_user_what_will_be_done
directories = Dir["#{_}**"].select {|entry| File.directory?(entry) }
unless directories.empty?
opnn if use_opn?
e "#{rev}Symlinking from the directory #{sdir(_)} #{rev}next."
end
directories.each {|name_of_the_subdirectory|
if Dir.empty?(name_of_the_subdirectory)
basename = File.basename(name_of_the_subdirectory)
if ARRAY_ALLOWED_SUBDIRECTORIES.include?(basename)
register_for_removal(name_of_the_subdirectory)
end
else
if @array_allowed_subdirectories.any? {|entry|
name_of_the_subdirectory.end_with?(entry)
}
short_name_of_the_subdirectory = File.basename(name_of_the_subdirectory)
@will_we_symlink = true if run_simulation?
opne 'We run in simulation mode, thus we will not '
opne "symlink #{sfile(entry)} into #{sfile(assumed_target_of(entry))}."
else
case short_name_of_the_subdirectory when /bin$/
action(:symlink_into_the_usr_bin_hierarchy, name_of_the_subdirectory) {{
force_symlink: force_symlink?
}}
when /lib$/,
/lib64$/ target = assumed_target_of(name_of_the_subdirectory)
if be_verbose?
opnn if use_opn?
notify_the_user_processing_this_directory_for_symlinking_into_that_target(
name_of_the_subdirectory,
target
)
end
if will_we_symlink
symlink_from_to(name_of_the_subdirectory, target)
pkgconfig_subdirectory = name_of_the_subdirectory+'/pkgconfig/'
if File.directory?(pkgconfig_subdirectory) and
(all_pc_files = Dir[pkgconfig_subdirectory+'*.pc'])
unless all_pc_files.empty?
target = '/usr/lib/pkgconfig/'
all_pc_files.each {|this_pc_file|
real_target = target+
File.basename(this_pc_file)
symlink_this_file(
this_pc_file,
real_target
)
}
end
end
end
when /include$/
target = include_dir?
if @will_we_symlink
opnn if use_opn?
e "#{rev}Symlinking into the main "+
sdir('include/')+
"#{rev} directory at #{sdir(target)}."
symlink_from_to(name_of_the_subdirectory, target) { :include_directories }
end
when /share$/,
/shared$/,
/Shared$/
target = assumed_target_of(name_of_the_subdirectory)
if be_verbose?
opnn if use_opn?
notify_the_user_processing_this_directory_for_symlinking_into_that_target(
name_of_the_subdirectory,
target
)
end
symlink_from_to(name_of_the_subdirectory, target) if @will_we_symlink
when /etc$/
target = assumed_target_of(name_of_the_subdirectory)
if be_verbose?
opnn if use_opn?
notify_the_user_processing_this_directory_for_symlinking_into_that_target(
name_of_the_subdirectory,
target
)
end
symlink_from_to(name_of_the_subdirectory, target) if @will_we_symlink
when /libexec$/
target = assumed_target_of(name_of_the_subdirectory)
if be_verbose?
opnn if use_opn?
notify_the_user_processing_this_directory_for_symlinking_into_that_target(
name_of_the_subdirectory,
target
)
end
symlink_from_to(name_of_the_subdirectory, target) if @will_we_symlink
when 'yaml' @will_we_symlink = false
when 'man'
@will_we_symlink = false
else
@will_we_symlink = false
end
end
end
end
}
end
consider_removing_empty_directories do_register_into_yaml_database if do_register_into_the_local_yaml_database? keep_track_which_program_was_last_symlinked
end
|
458
459
460
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 458
def
@internal_hash[:shall_we_symlink_the_headers] = true
end
|
#first_argument_or_current_working_directory ⇒ Object
#
first_argument_or_current_working_directory
#
579
580
581
582
583
584
585
586
587
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 579
def first_argument_or_current_working_directory
_ = first?
if (_ and _.start_with?('--')) or
(_ and _.empty?) or
_.nil?
_ = return_pwd
end
return _
end
|
#force_symlink? ⇒ Boolean
Also known as:
force_the_symlink_operation?
330
331
332
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 330
def force_symlink?
@internal_hash[:force_symlink]
end
|
707
708
709
710
711
712
713
714
715
716
717
718
719
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 707
def inform_the_user_what_will_be_done(
program_name = program_name?
)
_ = "Working on the program #{sfancy(program_name)}#{rev}. ".dup
if @array_allowed_subdirectories.size == 1
_ << "#{rev}The subdirectory found at\n"
else
_ << "#{rev}The subdirectories found at\n"
end
opnn if use_opn?; e _
_ = "#{rev}`#{sfancy(use_this_program?)}#{rev}` will be symlinked."
opnn if use_opn?; e _
end
|
#is_it_a_number?(i) ⇒ Boolean
355
356
357
358
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 355
def is_it_a_number?(i)
i = i.to_s.dup.delete('.') return i =~ /^\d+$/
end
|
#keep_empty_directories? ⇒ Boolean
#
keep_empty_directories?
#
265
266
267
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 265
def keep_empty_directories?
!remove_empty_directories?
end
|
#keep_track_which_program_was_last_symlinked ⇒ Object
Also known as:
try_to_save_the_name_of_the_program_into_a_local_file
#
keep_track_which_program_was_last_symlinked
This method will save the name of the program that this class has been working on, into a local file.
The reasoning behind this behaviour is so that we can use this in other classes, such as when we use :last on the commandline. The class that will act on :last will then pick up the content of the file that we have been using to store this information into. This then allows us to always refer to the “last program that was symlink_program-ed”, which is quite convenient as we don’t have to remember the name.
#
374
375
376
377
378
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 374
def keep_track_which_program_was_last_symlinked
what = program_name?
into = file_last_symlinked_program?
write_what_into(what, into)
end
|
#
All commandline options for this class can be passed through the menu() method here.
#
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 511
def (
i = hyphen_commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry)}
else
case i
when /^-?-?force$/i,
/^-?-?f$/i
do_force_symlink
when /^-?-?help$/i,
/^-?-?show(-|_)?help$i/
show_help
when /^-?-?bin\/?$/i
symlink_only_the_bin_subdirectory
when /^-?-?symlink(-|_)?headers$/
end
end
end
|
#notify_the_user_processing_this_directory_for_symlinking_into_that_target(name_of_the_subdirectory, target) ⇒ Object
#
notify_the_user_processing_this_directory_for_symlinking_into_that_target
#
724
725
726
727
728
729
730
731
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 724
def notify_the_user_processing_this_directory_for_symlinking_into_that_target(
name_of_the_subdirectory,
target
)
e "#{rev}Processing #{sfancy(name_of_the_subdirectory)}"\
"#{rev} for symlinking into `#{sdir(target)}"\
"#{rev}` next:"
end
|
#only_allow_bin_as_subdirectory ⇒ Object
Also known as:
symlink_only_the_bin_subdirectory
#
only_allow_bin_as_subdirectory
This method will enable that we only symlink the bin/ subdirectory.
#
556
557
558
559
560
561
562
563
564
565
566
567
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 556
def only_allow_bin_as_subdirectory
orev "Only the subdirectory at "\
"#{sdir('bin/')} #{rev}will be symlinked next."
@array_allowed_subdirectories.clear
@array_allowed_subdirectories << 'bin'
@internal_hash[:shall_we_symlink_the_headers] = false
@internal_hash[:do_register_into_the_local_yaml_database] = false
@symlink_pkgconfig_files = false
end
|
#program_version? ⇒ Boolean
#
program_version?
This method should return the program-version of the program at hand.
#
298
299
300
301
302
303
304
305
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 298
def program_version?
_ = program_name?.to_s.dup
i.chop! if _.end_with? '/'
if _.include? '/'
i = i.split('/').last.to_s
end
return _
end
|
#register_for_removal(i) ⇒ Object
#
register_for_removal
This method will register a directory for removal. Store the absolute path here - this simplifies removing said directory..
The check whether the directory is empty or not is done in another part of this class.
#
236
237
238
239
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 236
def register_for_removal(i)
i = rds(i)
@internal_hash[:array_remove_these_directories] << i unless (i == '/')
end
|
#remove_empty_directories? ⇒ Boolean
#
remove_empty_directories?
#
251
252
253
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 251
def remove_empty_directories?
@internal_hash[:remove_empty_directories]
end
|
#remove_these_directories? ⇒ Boolean
#
remove_these_directories?
#
244
245
246
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 244
def remove_these_directories?
@internal_hash[:array_remove_these_directories]
end
|
#reset ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 124
def reset
super()
infer_the_namespace
set_be_verbose
do_use_opn
@internal_hash[:force_symlink] = false
@internal_hash[:remove_empty_directories] = true
@internal_hash[:shall_we_symlink_the_headers] = false
@internal_hash[:array_remove_these_directories] = []
@internal_hash[:do_register_into_the_local_yaml_database] =
DO_REGISTER_INTO_THE_LOCAL_YAML_DATABASE
@array_allowed_subdirectories = ARRAY_ALLOWED_SUBDIRECTORIES
@will_we_symlink = true
@symlink_pkgconfig_files = true
end
|
#run ⇒ Object
948
949
950
951
952
953
954
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 948
def run
set_use_this_program(
first_argument_or_current_working_directory
)
do_symlink if will_we_symlink?
end
|
572
573
574
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 572
def
@internal_hash[:shall_we_symlink_the_headers]
end
|
#show_help ⇒ Object
#
show_help
To invoke this method from the commandline, try:
rnsymc --help
#
315
316
317
318
319
320
321
322
323
324
325
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 315
def show_help
e
e 'The following options are available:'
e
eparse ' --symlink-headers # the .h header files will be '\
'symlinked as well'
eparse ' --bin # symlink ONLY the bin/ subdirectory'
eparse ' --force # delete the target at '+
sdir('/usr/bin/')+' before doing the symlink-operation'
e
end
|
#symlink_pkgconfig_files? ⇒ Boolean
#
symlink_pkgconfig_files?
#
642
643
644
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 642
def symlink_pkgconfig_files?
@symlink_pkgconfig_files
end
|
#symlink_this_program? ⇒ Boolean
Also known as:
program_name?, input?, name_of_the_program?, program?
#
symlink_this_program?
This method will return the NAME of the program at hand, in a downcased manner.
#
418
419
420
421
422
423
424
425
426
427
428
429
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 418
def symlink_this_program?
_ = @use_this_program.to_s.dup
if _.include? _
_.sub!(/#{Regexp.quote(programs_dir?)}/,'')
if _.include? '/'
_ = _.split('/').first
end
end
_.downcase!
return _
end
|
#use_this_program? ⇒ Boolean
Also known as:
prefix?, full_path?, path?, full_path_to_the_target_program?, target_directory?
490
491
492
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 490
def use_this_program?
@use_this_program
end
|
#will_we_symlink? ⇒ Boolean
Also known as:
we_will_symlink?
465
466
467
|
# File 'lib/rbt/utility_scripts/symlink_from_to_current/symlink_from_to_current.rb', line 465
def will_we_symlink?
@will_we_symlink
end
|