2 # ==============================================================================
3 # portsreinstall library script
5 # Copyright (C) 2013-2021 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 ()
13 [ $opt_batch_mode = yes ] && return 0
15 case `echo "$answer" | head -c 1` in
25 message_echo 'Pardon? ([y]/n)'
26 message_query_yn_default_yes
31 # ============= Simple query by y (yes) or n (no) where no by default =============
32 message_query_yn_default_no ()
35 [ $opt_batch_mode = yes ] && return 1
37 case `echo "$answer" | head -c 1` in
47 message_echo 'Pardon? (y/[n])'
48 message_query_yn_default_no
53 # ============= Output the version =============
56 [ "x$opt_batch_mode" = xno ] && echo -n "${APPNAME} version "
60 # ============= Output the brief description =============
61 message_brief_description ()
64 -- Ports upgrading utility for massive forced reinstallation
65 -- And for those who are pursuing the perfect packages environment
69 # ============= Output a message except for the batch mode =============
72 [ $opt_batch_mode = yes ] && return
73 echo "$@" | fold -s -w `misc_get_console_column_size`
76 # ============= Output a message from stdin except for the batch mode =============
77 # Use via pipe or redirection without argument is discouraged because it violates the screen size detection.
81 [ $opt_batch_mode = yes ] && return
82 ncolumns=`misc_get_console_column_size`
83 fold -s -w $ncolumns "$@"
86 # ============= Output a credit =============
90 [ $opt_batch_mode = yes -o "x$opt_no_opening_message" = xyes ] && return
91 ncolumns=`misc_get_console_column_size`
92 message_version | fold -s -w $ncolumns
93 message_brief_description | fold -s -w $ncolumns
94 fold -s -w $ncolumns << eof
95 Copyright (C) 2010 - 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
96 Email: <sakaue.mamoru@samurai.mwghennn.net>
97 Homepage: <http://www.mwghennndo.com/software/portsreinstall/>
101 # ============= Output a time stamp =============
107 # ============= Output an opening notice =============
108 message_opening_notice ()
111 [ $opt_batch_mode = yes -o $opt_no_opening_message = yes ] && return
112 ncolumns=`misc_get_console_column_size`
113 fold -s -w $ncolumns << eof
115 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.
117 The current time is `message_timestamp`
121 # ============= Show option settings =============
122 message_show_option_settings ()
124 if [ -e "${DBDIR}/saved_options.sh" \
125 -a $opt_batch_mode = no -a $opt_no_opening_message = no \
126 -a \( $COMMAND_MODE = do -o $COMMAND_MODE = redo \) ]
128 message_echo "INFO: List of option values:"
129 message_echo "-----------------------------------------"
130 message_cat "${DBDIR}/saved_options.sh"
131 message_echo "-----------------------------------------"
136 # ============= Report a failure in a process for a port =============
137 message_report_failure_for_a_port ()
141 message_echo "*** Giving up for this port $origin and proceeding to next forcibly..."
145 # ============= Output the relation of the current port with specified targets =============
146 message_target_relations ()
148 [ $opt_batch_mode = yes ] && return
151 database_query_get_target_attributes it "$origin"
152 [ -z "${it_is_all}" -a -n "${it_is_relevant}" ] || return 0
153 [ -n "${it_is_target}" ] \
154 && message_echo "(Target port)"
155 [ -n "${it_is_requires_dependents}" ] \
156 && message_echo "(Dependent of the target port(s))"
157 [ -n "${it_is_requires_requirements}" ] \
158 && message_echo "(Requirement of the target port(s))"
159 [ -n "${it_is_initial_dependents}" -a -z "${it_is_requires_dependents}" ] \
160 && message_echo "(Former dependent of the target port(s))"
161 [ -n "${it_is_initial_requirements}" -a -z "${it_is_requires_requirements}" ] \
162 && message_echo "(Former requirement of the target port(s))"
163 [ -n "${it_is_requires_requirements_complement}" ] \
164 && message_echo "(Requirement of the target port(s) for installing their requirements)"
169 # ============= Notice that the current run is a restarted one =============
170 message_restarted_process ()
172 message_echo "INFO: Restarting from the previously terminated point."
175 # ============= Output of a section title =============
176 message_section_title ()
178 message_echo "[`message_timestamp`] $*"
181 # ============= Output of a stage title =============
182 message_stage_title ()
184 message_echo "========== $* =========="
185 message_echo "[At `message_timestamp`]"
188 # ============= Message of dry run =============
191 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
192 message_echo "@@@@@@@@@@@@@@@@@ DRY RUN @@@@@@@@@@@@@@@@@"
193 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
197 # ============= Message of fetch-only mode =============
198 message_fetch_only ()
200 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
201 message_echo "@@@@@@@@@@@@@ FETCH-ONLY MODE @@@@@@@@@@@@@"
202 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
206 # ============= Output a summary of a resource recorded in a list =============
207 message_summary_dependents_of_failed_reinstallation ()
209 local subject comment tmpmsg ncolumns
212 tmpmsg=${TMPDIR}/message_summary_dependents_of_failed_reinstallation::message
213 database_query_show_single_list_exec "$subject" \
214 `options_get_dependency_type` `options_get_dependency_level` > $tmpmsg.out 2> $tmpmsg.err || return 0
215 [ $opt_batch_mode = yes ] && return 1
216 ncolumns=`misc_get_console_column_size`
217 message_echo '****************'
218 message_cat "$tmpmsg.err" >&2
219 message_cat "$tmpmsg.out"
220 if [ -n "$comment" -a -e "$comment" ]
222 message_echo '****************'
223 message_cat "$comment"
225 message_echo '****************'
230 # ============= Show a message of a dependency scope =============
231 message_dependency_scope ()
237 options_parse_dependency_type "$deptag"
238 options_parse_dependency_level "$level"
239 message_echo "(Evaluated by `options_get_dependency_msgterm` dependency)"
243 # ============= Output an advice on manual solution to (re)installation failures =============
244 message_summary_advice_on_manual_solution ()
246 local tmpcomment command_pkg_updating
247 tmpcomment=${TMPDIR}/message_summary_failed_reinstallation::comment
248 command_pkg_updating=`pkgsys_show_pkg_updating_commands`
249 cat > $tmpcomment << eof
251 [Advices on manual solutions to (re)installation failures]
252 Simple redo processes may resolve the above problems, but otherwise manual solution is needed.
253 In the latter case, you are recommended to read ${PORTSDIR}/UPDATING to resolve the problems.
255 [ -n "$command_pkg_updating" ] && cat >> $tmpcomment << eof
256 $command_pkg_updating will be useful for this purpose.
259 cat >> $tmpcomment << eof
260 For unnecessary failed ports (with their unnecessary dependents), you can register it by
261 ${APPNAME} noneed add [deleted_port_globs]
265 For necessary and manually successful ports, after resolving the problems, execute
266 ${APPNAME} ok add [resolved_port_globs]
270 Refer to "Workaround for failed ports" sections in the manual page for details.
274 message_cat "$tmpcomment"
277 # ============= Output a warning if no progress was achieved =============
278 message_warn_no_achieved_progress ()
280 [ $opt_batch_mode = yes ] && return
281 message_echo '****************'
282 message_echo "WARNING: Some problems remain. Manual troubleshooting is required."
283 message_echo '****************'