2 # ==============================================================================
3 # portsreinstall library script
5 # Copyright (C) 2013-2016 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
6 # This software is distributed under the 2-Clause BSD License.
7 # ==============================================================================
9 # ============= Simple query by y (yes) or n (no) where yes by default =============
10 message_query_yn_default_yes ()
14 case `echo "$answer" | head -c 1` in
24 message_echo 'Pardon? ([y]/n)'
25 message_query_yn_default_yes
30 # ============= Simple query by y (yes) or n (no) where no by default =============
31 message_query_yn_default_no ()
35 case `echo "$answer" | head -c 1` in
45 message_echo 'Pardon? (y/[n])'
46 message_query_yn_default_no
51 # ============= Output the version =============
54 [ "x$opt_batch_mode" = xno ] && echo -n "${APPNAME} version "
58 # ============= Output a message except for the batch mode =============
61 [ "x$opt_batch_mode" = xyes ] && return
62 echo "$@" | fold -s -w `misc_get_console_column_size`
65 # ============= Output a message from stdin except for the batch mode =============
66 # Use via pipe or redirection without argument is discouraged because it violates the screen size detection.
70 [ "x$opt_batch_mode" = xyes ] && return
71 ncolumns=`misc_get_console_column_size`
72 fold -s -w $ncolumns "$@"
75 # ============= Output a credit =============
79 [ "x$opt_batch_mode" = xyes ] && return
80 ncolumns=`misc_get_console_column_size`
81 message_version | fold -s -w $ncolumns
82 fold -s -w $ncolumns << eof
83 -- Ports upgrading utility for massive forced reinstallation
84 -- And for those who are pursuing the perfect packages environment
85 Copyright (C) 2010 - 2015 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
86 Email: <sakaue.mamoru@samurai.mwghennn.net>
87 Homepage: <http://www.mwghennndo.com/software/portsreinstall/>
91 # ============= Output a time stamp =============
97 # ============= Output an opening notice =============
98 message_opening_notice ()
101 [ "x$opt_batch_mode" = xyes ] && return
102 ncolumns=`misc_get_console_column_size`
103 fold -s -w $ncolumns << eof
105 Don't hesitate to terminate by CTRL+C anytime you feel the system is heavy to use because you can restart the operation from the terminated point quickly.
107 The current time is `message_timestamp`
111 # ============= Report a failure in a process for a port =============
112 message_report_failure_for_a_port ()
116 message_echo "*** Giving up for this port $origin and proceeding to next forcibly..."
120 # ============= Output the relation of the current port with specified targets =============
121 message_target_relations ()
123 [ "x$opt_batch_mode" = xyes ] && return
126 database_query_get_target_attributes it "$origin"
127 [ -z "${it_is_all}" -a -n "${it_is_relevant}" ] || return 0
128 [ -n "${it_is_target}" ] \
129 && message_echo "(Target port)"
130 [ -n "${it_is_requires_dependents}" ] \
131 && message_echo "(Dependent of the target port(s))"
132 [ -n "${it_is_requires_requirements}" ] \
133 && message_echo "(Requirement of the target port(s))"
134 [ -n "${it_is_initial_dependents}" -a -z "${it_is_requires_dependents}" ] \
135 && message_echo "(Former dependent of the target port(s))"
136 [ -n "${it_is_initial_requirements}" -a -z "${it_is_requires_requirements}" ] \
137 && message_echo "(Former requirement of the target port(s))"
138 [ -n "${it_is_requires_requirements_complement}" ] \
139 && message_echo "(Requirement of the target port(s) for installing their requirements)"
144 # ============= Notice that the current run is a restarted one =============
145 message_restarted_process ()
147 message_echo "INFO: Restarting from the previously terminated point."
150 # ============= Output of a section title =============
151 message_section_title ()
153 message_echo "[`message_timestamp`] $*"
156 # ============= Output of a stage title =============
157 message_stage_title ()
159 message_echo "========== $* =========="
160 message_echo "[At `message_timestamp`]"
163 # ============= Dummy output for dry run =============
166 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
167 message_echo "@@@@@@@@@@@@@@@@@ DRY RUN @@@@@@@@@@@@@@@@@"
168 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
172 # ============= Output a summary of a resource recorded in a list =============
173 message_summary_dependents_of_failed_reinstallation ()
175 local subject comment tmpmsg ncolumns
178 tmpmsg=${TMPDIR}/message_summary_dependents_of_failed_reinstallation::message
179 database_query_show_single_list_exec "$subject" \
180 `options_get_dependency_type` `options_get_dependency_level` > $tmpmsg || return 0
181 [ $opt_batch_mode = yes ] && return 1
182 ncolumns=`misc_get_console_column_size`
183 message_echo '****************'
184 message_cat "$tmpmsg"
185 if [ -n "$comment" -a -e "$comment" ]
187 message_echo '****************'
188 message_cat "$comment"
190 message_echo '****************'
195 # ============= Show a message of a dependency scope =============
196 message_dependency_scope ()
199 options_parse_dependency_type "$deptag"
200 options_parse_dependency_level "$level"
201 message_echo "(Evaluated by `options_get_dependency_msgterm` dependency)"
205 # ============= Output an advice on manual solution to (re)installation failures =============
206 message_summary_advice_on_manual_solution ()
208 local tmpcomment command_pkg_updating
209 tmpcomment=${TMPDIR}/message_summary_failed_reinstallation::comment
210 command_pkg_updating=`pkgsys_show_pkg_updating_commands`
211 cat > $tmpcomment << eof
213 [Advices on manual solutions to (re)installation failures]
214 Simple redo processes may resolve the above problems, but otherwise manual solution is needed.
215 In the latter case, you are recommended to read ${PORTSDIR}/UPDATING to resolve the problems.
217 [ -n "$command_pkg_updating" ] && cat >> $tmpcomment << eof
218 $command_pkg_updating will be useful for this purpose.
221 cat >> $tmpcomment << eof
222 For unnecessary failed ports (with their unnecessary dependents), you can register it by
223 ${APPNAME} noneed add [deleted_port_globs]
227 For necessary and manually successful ports, after resolving the problems, execute
228 ${APPNAME} ok add [resolved_port_globs]
232 Refer to "Workaround for failed ports" sections in the manual page for details.
236 message_cat "$tmpcomment"
239 # ============= Output a warning if no progress was achieved =============
240 message_warn_no_achieved_progress ()
242 [ `cat "${DBDIR}/new_success_in_current_run" 2> /dev/null | wc -l` -gt 0 ] && return
243 [ $opt_batch_mode = yes ] && return 1
244 message_echo '****************'
245 message_echo "WARNING: No progress was achieved by this run."
246 message_echo " Manual solution is needed on the failed ports."
247 message_echo '****************'