2 # ==============================================================================
3 # portsreinstall library script
5 # Copyright (C) 2013 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 # Input must be given via descriptor 3 if no file is given as the argument.
70 [ "x$opt_batch_mode" = xyes ] && return
71 ncolumns=`misc_get_console_column_size`
74 fold -s -w $ncolumns <&3
76 fold -s -w $ncolumns "$@"
80 # ============= Output a credit =============
84 [ "x$opt_batch_mode" = xyes ] && return
85 ncolumns=`misc_get_console_column_size`
86 message_version | fold -s -w $ncolumns
87 fold -s -w $ncolumns << eof
88 -- Ports upgrading utility for massive forced reinstallation
89 -- And for those who are pursuing the perfect packages environment
90 Copyright (C) 2010 - 2013 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
91 Email: <sakaue.mamoru@samurai.mwghennn.net>
92 Homepage: <http://www.mwghennndo.com/software/portsreinstall/>
96 # ============= Output a time stamp =============
102 # ============= Output an opening notice =============
103 message_opening_notice ()
106 [ "x$opt_batch_mode" = xyes ] && return
107 ncolumns=`misc_get_console_column_size`
108 fold -s -w $ncolumns << eof
110 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.
112 The current time is `message_timestamp`
116 # ============= Report a failure in a process for a port =============
117 message_report_failure_for_a_port ()
121 message_echo "*** Giving up for this port $origin and proceeding to next forcibly..."
125 # ============= Output the relation of the current port with specified targets =============
126 message_target_relations ()
128 [ "x$opt_batch_mode" = xyes ] && return
131 database_query_get_target_attributes it "$origin"
132 [ -z "${it_is_all}" -a -n "${it_is_relevant}" ] || return 0
133 [ -n "${it_is_target}" ] \
134 && message_echo "(Target port)"
135 [ -n "${it_is_requires_dependents}" ] \
136 && message_echo "(Dependent of the target port(s))"
137 [ -n "${it_is_requires_requirements}" ] \
138 && message_echo "(Requirement of the target port(s))"
139 [ -n "${it_is_initial_dependents}" -a -z "${it_is_requires_dependents}" ] \
140 && message_echo "(Former dependent of the target port(s))"
141 [ -n "${it_is_initial_requirements}" -a -z "${it_is_requires_requirements}" ] \
142 && message_echo "(Former requirement of the target port(s))"
143 [ -n "${it_is_requires_requirements_complement}" ] \
144 && message_echo "(Requirement of the target port(s) for installing their requirements)"
149 # ============= Notice that the current run is a restarted one =============
150 message_restarted_process ()
152 message_echo "INFO: Restarting from the previously terminated point."
155 # ============= Output of a section title =============
156 message_section_title ()
158 message_echo "[`message_timestamp`] $*"
161 # ============= Output of a stage title =============
162 message_stage_title ()
164 message_echo "========== $* =========="
165 message_echo "[At `message_timestamp`]"
168 # ============= Dummy output for dry run =============
171 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
172 message_echo "@@@@@@@@@@@@@@@@@ DRY RUN @@@@@@@@@@@@@@@@@"
173 message_echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
177 # ============= Output a summary of a resource recorded in a list =============
178 message_summary_dependents_of_failed_reinstallation ()
180 local subject comment tmpmsg ncolumns
183 tmpmsg=${TMPDIR}/message_summary_dependents_of_failed_reinstallation::message
184 database_query_show_single_list_exec "$subject" \
185 `options_get_dependency_type` `options_get_dependency_level` > $tmpmsg || return 0
186 [ $opt_batch_mode = yes ] && return 1
187 ncolumns=`misc_get_console_column_size`
188 message_echo '****************'
189 message_cat "$tmpmsg"
190 if [ -n "$comment" -a -e "$comment" ]
192 message_echo '****************'
193 message_cat "$comment"
195 message_echo '****************'
200 # ============= Show a message of a dependency scope =============
201 message_dependency_scope ()
204 options_parse_dependency_type "$deptag"
205 options_parse_dependency_level "$level"
206 message_echo "(Evaluated by `options_get_dependency_msgterm` dependency)"
210 # ============= Output an advice on manual solution to (re)installation failures =============
211 message_summary_advice_on_manual_solution ()
213 local tmpcomment command_pkg_updating
214 tmpcomment=${TMPDIR}/message_summary_failed_reinstallation::comment
215 command_pkg_updating=`pkgsys_show_pkg_updating_commands`
216 cat > $tmpcomment << eof
218 [Advices on manual solutions to (re)installation failures]
219 Simple redo processes may resolve the above problems, but otherwise manual solution is needed.
220 In the latter case, you are recommended to read ${PORTSDIR}/UPDATING to resolve the problems.
222 [ -n "$command_pkg_updating" ] && cat >> $tmpcomment << eof
223 $command_pkg_updating will be useful for this purpose.
226 cat >> $tmpcomment << eof
227 For unnecessary failed ports (with their unnecessary dependents), you can register it by
228 ${APPNAME} noneed add [deleted_port_globs]
232 For necessary and manually successful ports, after resolving the problems, execute
233 ${APPNAME} ok add [resolved_port_globs]
237 Refer to "Workaround for failed ports" sections in the manual page for details.
241 message_cat "$tmpcomment"
244 # ============= Output a warning if no progress was achieved =============
245 message_warn_no_achieved_progress ()
247 [ `cat "${DBDIR}/new_success_in_current_run" 2> /dev/null | wc -l` -gt 0 ] && return
248 [ $opt_batch_mode = yes ] && return 1
249 message_echo '****************'
250 message_echo "WARNING: No progress was achieved by this run."
251 message_echo " Manual solution is needed on the failed ports."
252 message_echo '****************'