• R/O
  • HTTP
  • SSH
  • HTTPS

current: Commit

This is for active development.
New funtionalities are to be added actively.


Commit MetaInfo

Revision12c96c00c54d1b56c2472457377339c11e0a00d9 (tree)
Time2022-03-24 02:10:15
AuthorMamoru Sakaue <sakaue.mamoru@mwgh...>
CommiterMamoru Sakaue

Log Message

[IMPROVED] Adapt to the behavior change grep(1) as of 12.0-RELEASE that the case distinction is ineffective in some locale, which as a result prevented the execution by users in such locales.
[BUG FIX] Directories mounted by ZFS were not correctly treated by portsreinstall-chroot(8).
[BUG FIX] The mount command of portsreinstall-chroot(8) failed if the base directory path is under a directory to be mounted for the chroot environment (ex. when /home is a link to /usr/home).
[BUG FIX] Restarted runs failed if paths set to option values or their parent paths are symbolic links.
[BUG FIX] The mount command of portsreinstall-chroot(8) failed to detect mounted and unmounted file systems on mount points under symbolic links.

Changes to be committed:

modified: HISTORY
modified: lib/chroot-mount/liboptions.sh
modified: lib/chroot/libfs.sh
modified: lib/chroot/liboptions.sh
modified: lib/libcommand_do.sh
modified: lib/libcommand_flexconf.sh
modified: lib/libcommand_forget.sh
modified: lib/libcommand_pkgs.sh
modified: lib/libconf.sh
modified: lib/libdatabase_build.sh
modified: lib/libdatabase_maintain.sh
modified: lib/libdatabase_query.sh
modified: lib/libdatabase_record.sh
modified: lib/libdeinstall.sh
modified: lib/libfileedit.sh
modified: lib/libfs.sh
modified: lib/libmain.sh
modified: lib/libmisc.sh
modified: lib/liboptions.sh
modified: lib/libpkgsys.sh
modified: lib/libprogram.sh
modified: lib/libreinstall.sh
modified: lib/main/liboptions.sh
modified: lib/upgrade/libcommand_do.sh
modified: lib/upgrade/liboptions.sh
modified: man/portsreinstall-chroot.8

Change Summary

Incremental Difference

--- a/HISTORY
+++ b/HISTORY
@@ -1,5 +1,10 @@
1-4.1.1 (?? October 2021)
1+4.1.1 (?? December 2021)
22 [IMPROVED] Adapt to the specification change of pkg-create(8) that the default extension of the package files become "pkg".
3+[IMPROVED] Adapt to the behavior change grep(1) as of 12.0-RELEASE that the case distinction is ineffective in some locale, which as a result prevented the execution by users in such locales.
4+[BUG FIX] Directories mounted by ZFS were not correctly treated by portsreinstall-chroot(8).
5+[BUG FIX] The mount command of portsreinstall-chroot(8) failed if the base directory path is under a directory to be mounted for the chroot environment (ex. when /home is a link to /usr/home).
6+[BUG FIX] Restarted runs failed if paths set to option values or their parent paths are symbolic links.
7+[BUG FIX] The mount command of portsreinstall-chroot(8) failed to detect mounted and unmounted file systems on mount points under symbolic links.
38 4.1.0 (22 September 2018)
49 [NEW] Options -j and -x are added.
510 [NEW] Option -J is added to the all utilities.
--- a/lib/chroot-mount/liboptions.sh
+++ b/lib/chroot-mount/liboptions.sh
@@ -9,7 +9,7 @@
99
1010 # ============= Database of options which are given at each run and not saved =============
1111 # [Syntax of option databases]
12-# short_name, long_name, variable, defult_vaule, set_value
12+# short_name, long_name, variable, default_value, set_value
1313 # Columns are delimited by tab characters.
1414 options_db_onetime ()
1515 {
--- a/lib/chroot/libfs.sh
+++ b/lib/chroot/libfs.sh
@@ -61,14 +61,18 @@ fs_save_mounttime_systembase ()
6161 # ============= Get the system base observed currently =============
6262 fs_get_current_systembase ()
6363 {
64- cat "${TMPDIR}/fs_save_current_systembase" 2> /dev/null
64+ local systembase
65+ systembase=`cat "${TMPDIR}/fs_save_current_systembase" 2> /dev/null`
66+ [ -z "$systembase" ] || realpath "$systembase"
6567 }
6668
6769 # ============= Get the system base observed at the time of mounting =============
6870 # Non-zero return means no file system was attempted to mount
6971 fs_get_mounttime_systembase ()
7072 {
71- cat "${DBDIR}/fs_systembase" 2> /dev/null
73+ local systembase
74+ systembase=`cat "${DBDIR}/fs_systembase" 2> /dev/null`
75+ [ -z "$systembase" ] || realpath "$systembase"
7276 }
7377
7478 # ============= Get the system base in the scope of accessing =============
@@ -104,40 +108,89 @@ fs_build_chroot ()
104108 fs_safeguard_basedir "$opt_basedir"
105109 fs_unmount || return
106110 mkdir -p "$opt_basedir"
107- # Prescan the f file system of the original environment
111+ # Prescan the file system of the original environment
108112 cp /dev/null "${TMPDIR}/fs_build_chroot:directories"
109113 (
114+ real_basedir=`realpath "$opt_basedir"`
110115 {
116+# echo bin compat etc lib libexec root sbin sys usr | tr ' ' '\n'
111117 echo bin compat etc lib libexec root sbin sys usr var | tr ' ' '\n'
112118 echo "$opt_extra_dirs" | tr "$opt_extra_dirs_delim" '\n'
113- } | grep -v '^[[:space:]]*$' | sort -u > ${TMPDIR}/fs_build_chroot:sys_dirs
114- sysdirs_ptn="^/*(`str_escape_regexp_filter < ${TMPDIR}/fs_build_chroot:sys_dirs | tr '\n' '|' | sed 's/\|$//'`)/+"
115- while read directory
119+ } | env LANG=C grep -v '^[[:space:]]*$' | sort -u | while read node
116120 do
117- [ -e "/$directory" ] || continue
118- if [ -L "/$directory" ]
121+ [ -e "/$node" ] || continue
122+ src_mountpoint_real=`realpath "/$node"`
123+ ptn_src_mountpoint_real=`str_escape_regexp "$src_mountpoint_real/"`
124+ if echo "$real_basedir" | grep -Eq "^$ptn_src_mountpoint_real"
119125 then
120- src_mountpoint_real=`realpath "/$directory"`
121- printf '%s\t%s\n' link "$directory" >> ${TMPDIR}/fs_build_chroot:directories
122- if ! echo "$src_mountpoint_real/" | grep -qE "$sysdirs_ptn"
126+ (
127+ node_cur=$node
128+ rm -f "${TMPDIR}/fs_build_chroot:hit_exact"
129+ while [ ! -e "${TMPDIR}/fs_build_chroot:hit_exact" ]
130+ do
131+ rm -f "${TMPDIR}/fs_build_chroot:hit_subnode"
132+ cd "/$node_cur"
133+ ls -a | while read subnode
134+ do
135+ if [ "$subnode" = . -o "$subnode" = .. ]
136+ then
137+ continue
138+ elif [ -L "$subnode" -o -f "$subnode" ]
139+ then
140+ echo "$node_cur/$subnode"
141+ elif [ -d "$subnode" ]
142+ then
143+ node_cur_tmp_real=`realpath "/$node_cur/$subnode"`
144+ ptn_node_cur_tmp_real=`str_escape_regexp "$node_cur_tmp_real/"`
145+ if [ "$real_basedir" = "$node_cur_tmp_real" ]
146+ then
147+ touch "${TMPDIR}/fs_build_chroot:hit_exact"
148+ elif echo "$real_basedir" | grep -Eq "^$ptn_node_cur_tmp_real"
149+ then
150+ echo "$subnode" > ${TMPDIR}/fs_build_chroot:hit_subnode
151+ else
152+ echo "$node_cur/$subnode"
153+ fi
154+ fi
155+ done
156+ [ -e "${TMPDIR}/fs_build_chroot:hit_subnode" ] || break
157+ node_cur=$node_cur/`cat "${TMPDIR}/fs_build_chroot:hit_subnode"`
158+ done
159+ )
160+ else
161+ echo "$node"
162+ fi
163+ done > ${TMPDIR}/fs_build_chroot:sys_nodes
164+ sysdirs_ptn="^/*(`str_escape_regexp_filter < ${TMPDIR}/fs_build_chroot:sys_nodes | tr '\n' '|' | sed 's/\|$//'`)/+"
165+ while read node
166+ do
167+ [ -e "/$node" ] || continue
168+ if [ -L "/$node" -a -d "/$node" ]
169+ then
170+ src_mountpoint_real=`realpath "/$node"`
171+ printf '%s\t%s\n' link "$node" >> ${TMPDIR}/fs_build_chroot:directories
172+ if ! echo "$src_mountpoint_real/" | env LANG=C grep -qE "$sysdirs_ptn"
123173 then
124174 printf '%s\t%s\n' real "$src_mountpoint_real" >> ${TMPDIR}/fs_build_chroot:directories
125175 tmpdir_descendant=${TMPDIR}/fs_build_chroot:descendant/$src_mountpoint_real
126176 mkdir -p "$tmpdir_descendant"
127177 fs_get_descendant_mount_info "/$src_mountpoint_real" > $tmpdir_descendant/list
128178 fi
129- elif [ -d "/$directory" ]
179+ elif [ -d "/$node" ]
130180 then
131- printf '%s\t%s\n' real $directory >> ${TMPDIR}/fs_build_chroot:directories
132- tmpdir_descendant=${TMPDIR}/fs_build_chroot:descendant/$directory
181+ printf '%s\t%s\n' real $node >> ${TMPDIR}/fs_build_chroot:directories
182+ tmpdir_descendant=${TMPDIR}/fs_build_chroot:descendant/$node
133183 mkdir -p "$tmpdir_descendant"
134- fs_get_descendant_mount_info "/$directory" > $tmpdir_descendant/list
184+ fs_get_descendant_mount_info "/$node" > $tmpdir_descendant/list
185+ elif [ -L "/$node" -o -f "/$node" ]
186+ then
187+ cp -p "/$node" "$node"
135188 fi
136- done < ${TMPDIR}/fs_build_chroot:sys_dirs
189+ done < ${TMPDIR}/fs_build_chroot:sys_nodes
137190 )
138191 # Prepare the grand base of the chroot environment
139192 (
140- cd "/$opt_basedir"
193+ cd "$opt_basedir"
141194 for directory in builder mask store
142195 do
143196 [ -d $directory ] || mkdir $directory
@@ -149,14 +202,16 @@ fs_build_chroot ()
149202 echo "$PORTSDIR"
150203 echo "$PORTSNAP_WORKDIR"
151204 echo "$PKGNG_PKG_CACHEDIR"
152- fi | str_regularize_df_path_filter | grep -v '^[[:space:]]*$' | sort -u > ${DBDIR}/shared_dirs.lst
205+ fi | str_regularize_df_path_filter | env LANG=C grep -v '^[[:space:]]*$' | sort -u > ${DBDIR}/shared_dirs.lst
153206 str_escape_regexp_filter < ${DBDIR}/shared_dirs.lst | sed 's|^|^|;s|$|\/|' > ${TMPDIR}/fs_build_chroot:shared_dirs.regexp.tmp
154207 paste "${DBDIR}/shared_dirs.lst" "${TMPDIR}/fs_build_chroot:shared_dirs.regexp.tmp" > ${TMPDIR}/fs_build_chroot:shared_dirs.regexp
155208 cp /dev/null "${TMPDIR}/fs_build_chroot:shared_dirs:added"
156209 # Build target directories and the manifest for mounting
210+ mkdir -p "$opt_basedir/mask"
157211 cp /dev/null "${DBDIR}/mount_manifest.tmp"
158212 (
159- cd "/$opt_basedir"/builder
213+ real_basedir=`realpath "$opt_basedir"`
214+ cd "$real_basedir"/builder
160215 while read srcline
161216 do
162217 type=`echo "$srcline" | cut -f 1`
@@ -167,7 +222,7 @@ fs_build_chroot ()
167222 ;;
168223 real )
169224 mkdir -p "./$directory"
170- masktarget=/$opt_basedir/mask/$directory
225+ masktarget=$real_basedir/mask/$directory
171226 mkdir -p "$masktarget"
172227 printf '%s\t%s\t%s\t%s\n' nullfs "/$directory" "$directory" ro >> ${DBDIR}/mount_manifest.tmp
173228 printf '%s\t%s\t%s\t%s\n' unionfs "$masktarget" "$directory" rw,noatime >> ${DBDIR}/mount_manifest.tmp
@@ -181,10 +236,10 @@ fs_build_chroot ()
181236 rm -f "${TMPDIR}/fs_build_chroot:shared_dirs:is_itself"
182237 while read -r shared_path shared_path_regexp
183238 do
184- echo "$fullpath/" | grep -qE "$shared_path_regexp" || continue
239+ echo "$fullpath/" | env LANG=C grep -qE "$shared_path_regexp" || continue
185240 echo "$shared_path"$'\n'"$fullpath" | while read mpath
186241 do
187- if ! grep -qFx "$mpath" "${TMPDIR}/fs_build_chroot:shared_dirs:added"
242+ if ! env LANG=C grep -qFx "$mpath" "${TMPDIR}/fs_build_chroot:shared_dirs:added"
188243 then
189244 echo "$mpath" >> ${TMPDIR}/fs_build_chroot:shared_dirs:added
190245 mkdir -p "/$mpath"
@@ -197,7 +252,7 @@ fs_build_chroot ()
197252 [ -e "${TMPDIR}/fs_build_chroot:shared_dirs:is_under" ] && continue
198253 case $fs in
199254 normal )
200- masktarget=`str_regularize_df_path "/$opt_basedir/mask/$fullpath"`
255+ masktarget=`str_regularize_df_path "$real_basedir/mask/$fullpath"`
201256 mkdir -p "$masktarget"
202257 printf '%s\t%s\t%s\t%s\n' nullfs "$mp" "$fullpath" ro >> ${DBDIR}/mount_manifest.tmp
203258 printf '%s\t%s\t%s\t%s\n' unionfs "$masktarget" "$fullpath" rw,noatime >> ${DBDIR}/mount_manifest.tmp
@@ -222,7 +277,7 @@ fs_build_chroot ()
222277 ;;
223278 esac
224279 done < ${TMPDIR}/fs_build_chroot:directories
225- grep -Ev -f "${TMPDIR}/fs_build_chroot:shared_dirs:added" "${DBDIR}/shared_dirs.lst" | while read shared_dir
280+ env LANG=C grep -Ev -f "${TMPDIR}/fs_build_chroot:shared_dirs:added" "${DBDIR}/shared_dirs.lst" | while read shared_dir
226281 do
227282 mkdir -p "$shared_dir"
228283 mp_share=`realpath "$shared_dir"`
@@ -237,7 +292,7 @@ fs_build_chroot ()
237292 printf '%s\t%s\t%s\t%s\n' procfs proc proc rw >> ${DBDIR}/mount_manifest.tmp
238293 printf '%s\t%s\t%s\t%s\n' tmpfs tmpfs tmp rw,mode=1777 >> ${DBDIR}/mount_manifest.tmp
239294 mkdir -p ."${PROGRAM}"
240- cd "/$opt_basedir/mask"
295+ cd "$real_basedir/mask"
241296 if [ ! -e root/.cshrc ]
242297 then
243298 tmp_cshrc=${TMPDIR}/fs_build_chroot:.cshrc
@@ -257,7 +312,7 @@ fs_build_chroot ()
257312 echo 'set prompt="%N@[builder]%m:%~ %# "' >> $tmp_cshrc
258313 mv "$tmp_cshrc" root/.cshrc
259314 fi
260- printf '%s\t%s\t%s\t%s\n' nullfs "/$opt_basedir"/store ".${PROGRAM}" rw >> ${DBDIR}/mount_manifest.tmp
315+ printf '%s\t%s\t%s\t%s\n' nullfs "$real_basedir"/store ".${PROGRAM}" rw >> ${DBDIR}/mount_manifest.tmp
261316 )
262317 mv "${DBDIR}/mount_manifest.tmp" "${DBDIR}/mount_manifest"
263318 }
@@ -279,7 +334,8 @@ fs_chk_mount ()
279334 directory=`echo "$srcline" | cut -f 3`
280335 opt=`echo "$srcline" | cut -f 4`
281336 mp=`str_regularize_df_path "$systembase_mp/$opt_basedir/builder/$directory"`
282- if ! fs_chk_mounted "$type" "$target" "$mp"
337+ expr "$target" : \\/ && target=`realpath "$target"`
338+ if ! real_mp=`realpath "$mp" 2> /dev/null` || ! fs_chk_mounted "$type" "$target" "$real_mp"
283339 then
284340 printf '%s\t%s\t%s\n' "$type" "$target" "$mp" >> $tmp_remains
285341 fi
@@ -412,8 +468,9 @@ fs_chk_unmount ()
412468 [ "x$type" = xnullfs -o "x$type" = xunionfs ] && target=$systembase_target/$target
413469 directory=`echo "$srcline" | cut -f 3`
414470 opt=`echo "$srcline" | cut -f 4`
415- mp=$systembase_mp/$opt_basedir/builder/$directory
416- fs_chk_mounted "$type" "$target" "$mp" || continue
471+ mp=`str_regularize_df_path "$systembase_mp/$opt_basedir/builder/$directory"`
472+ real_mp=`realpath "$mp" 2> /dev/null` || continue
473+ fs_chk_mounted "$type" "$target" "$real_mp" || continue
417474 str_regularize_df_path "$mp" >> $tmp_remains
418475 done
419476 ! cat "$tmp_remains" 2> /dev/null
--- a/lib/chroot/liboptions.sh
+++ b/lib/chroot/liboptions.sh
@@ -9,7 +9,7 @@
99
1010 # ============= Database of options which are given at each run and not saved =============
1111 # [Syntax of option databases]
12-# short_name, long_name, variable, defult_vaule, set_value
12+# short_name, long_name, variable, default_value, set_value
1313 # Columns are delimited by tab characters.
1414 options_db_onetime ()
1515 {
@@ -43,8 +43,16 @@ s share-port-pkgs-dirs opt_share_port_pkgs_dirs no yes
4343 eof
4444 }
4545
46-# ============= Regularize the option value =============
47-options_regularize ()
46+# ============= Definitions of value regulator functions =============
47+options_db_value_regulators ()
4848 {
49- opt_basedir=`fs_global_path "$opt_basedir"`
49+ cat << eof
50+opt_basedir options_regularize_to_global_path
51+eof
52+}
53+
54+# ============= Regularize a value of an option value: conversion of a oath into the global path =============
55+options_regularize_to_global_path ()
56+{
57+ fs_global_path "$1"
5058 }
--- a/lib/libcommand_do.sh
+++ b/lib/libcommand_do.sh
@@ -274,10 +274,10 @@ command_do_reset_changed_portdb ()
274274 str_escape_regexp_filter < $tmp_ls.uninspected.dbfile | sed 's/^/^/;s/$/[[:space:]]/' > $tmp_ls.uninspected.dbfile_ptn
275275 paste "$tmp_ls.uninspected.dbfile_ptn" "$tmp_ls.uninspected.logname" | while read -r dbfile_ptn logname
276276 do
277- grep -E "$dbfile_ptn" < $tmp_ls.log > ${DBDIR}/ls_dbdir/$logname.log 2> /dev/null || :
277+ env LANG=C grep -E "$dbfile_ptn" < $tmp_ls.log > ${DBDIR}/ls_dbdir/$logname.log 2> /dev/null || :
278278 done
279279 str_escape_regexp_filter < $tmp_ls.nonexistent.db | sed 's/^/^/;s/$/[[:space:]]/' > $tmp_ls.nonexistent.db_ptn
280- grep -E -f "$tmp_ls.nonexistent.db_ptn" < $tmp_ls.log | pkgsys_register_list_nonexistent_portopriondb
280+ env LANG=C grep -E -f "$tmp_ls.nonexistent.db_ptn" < $tmp_ls.log | pkgsys_register_list_nonexistent_portopriondb
281281 message_echo
282282 [ ! -e "$tmp_ls.updated" ]
283283 }
@@ -329,7 +329,7 @@ command_do_convert_dependency_lists_to_actual_ones ()
329329 if [ -e "$target.src" ]
330330 then
331331 sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "$target.src" \
332- | grep -v '^$' | sort -u > $target.tmp
332+ | env LANG=C grep -v '^$' | sort -u > $target.tmp
333333 [ -e "$target" ] && ! diff -q "$target.tmp" "$target" > /dev/null \
334334 && echo "$origin" >> ${DBDIR}/update_dependencies
335335 mv "$target.tmp" "$target"
@@ -354,13 +354,13 @@ command_do_convert_dependency_lists_to_actual_ones ()
354354 find . -depth 3 -type f -name requirements.${tag}.full -or -name requirements.${tag}.full.orig ) \
355355 | sort -u \
356356 | sed 's|^./||;s|/[^/]*$||' \
357- | grep -v -Fx -f "${DBDIR}/update_dependencies" \
357+ | env LANG=C grep -v -Fx -f "${DBDIR}/update_dependencies" \
358358 > ${TMPDIR}/convert_requirements_list:full_complete.grep_pattern || :
359359 ( cd "${DBDIR}/requires" && \
360360 find . -depth 3 -type f -name requirements.${tag}.direct -or -name requirements.${tag}.direct.orig ) \
361361 | sort -u \
362362 | sed 's|^./||;s|/[^/]*$||' \
363- | grep -v -Fx -f "${TMPDIR}/convert_requirements_list:full_complete.grep_pattern" \
363+ | env LANG=C grep -v -Fx -f "${TMPDIR}/convert_requirements_list:full_complete.grep_pattern" \
364364 > ${DBDIR}/stage.loop_list/complete_recursive_${tag}time_reqlists || :
365365 done
366366 for inspected_level_tmp in direct node
@@ -423,7 +423,7 @@ command_do_trim_dependency_lists_by_removing_uninspected_ports ()
423423 do
424424 srcdb=requirements.${tag}.${level}
425425 [ -e "$dbpath/$srcdb" ] || continue
426- grep -Fx -f "${DBDIR}/inspected_ports" "$dbpath/$srcdb" > $dbpath/$srcdb.tmp || :
426+ env LANG=C grep -Fx -f "${DBDIR}/inspected_ports" "$dbpath/$srcdb" > $dbpath/$srcdb.tmp || :
427427 mv "$dbpath/$srcdb.tmp" "$dbpath/$srcdb"
428428 done
429429 done
@@ -621,7 +621,7 @@ command_do_post_process_after_the_preparation_of_target_attribute_information ()
621621 {
622622 message_section_title "Post-process after the preparation of target attribute information"
623623 sort -u "${DBDIR}/all_targets.lst" 2> /dev/null \
624- | grep -Fx -f "${DBDIR}/inspected_ports" \
624+ | env LANG=C grep -Fx -f "${DBDIR}/inspected_ports" \
625625 | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" 2> /dev/null \
626626 > ${DBDIR}/all_targets.lst.tmp || :
627627 mv "${DBDIR}/all_targets.lst.tmp" "${DBDIR}/all_targets.lst"
@@ -792,7 +792,7 @@ command_do_preparation_for_inspection_of_new_leaf_ports ()
792792 fileedit_manipulate_new_lines \
793793 "${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:nonleaf_ports" \
794794 "${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:inspected_ports" \
795- | grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null \
795+ | env LANG=C grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null \
796796 > ${DBDIR}/stage.loop_list/leaf_ports_primary_candidates || :
797797 cp /dev/null "${DBDIR}/leaf_ports.filter"
798798 cp /dev/null "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates"
@@ -815,8 +815,8 @@ command_do_inspection_of_new_primary_leaf_ports ()
815815 origin=$1
816816 pkgsys_is_pkgtool "$origin" && return
817817 dbpath=${DBDIR}/requires/$origin
818- grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return
819- if ! grep -q -Fx "$origin" "${DBDIR}/noneed.list" 2> /dev/null
818+ env LANG=C grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return
819+ if ! env LANG=C grep -q -Fx "$origin" "${DBDIR}/noneed.list" 2> /dev/null
820820 then
821821 if [ -e "$dbpath/initial_orig" ]
822822 then
@@ -832,7 +832,7 @@ command_do_inspection_of_new_primary_leaf_ports ()
832832 if [ -e "$dbpath/requirements.all.full" -o -e "$dbpath/ignored_requirements.all" ]
833833 then
834834 cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null | \
835- grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null| \
835+ env LANG=C grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null| \
836836 fileedit_add_lines_if_new "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" || :
837837 fi
838838 fileedit_add_a_line_if_new "$origin" "${DBDIR}/leaf_ports.filter"
@@ -871,9 +871,9 @@ command_do_inspection_of_requirements_of_new_leaf_ports ()
871871 origin=$1
872872 pkgsys_is_pkgtool "$origin" && return
873873 dbpath=${DBDIR}/requires/$origin
874- grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return
874+ env LANG=C grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return
875875 cat "$dbpath/dependents.all.full" "$dbpath/ignored_dependents.all" 2> /dev/null \
876- | grep -Fxq -v -f "${DBDIR}/leaf_ports.filter" 2> /dev/null && return
876+ | env LANG=C grep -Fxq -v -f "${DBDIR}/leaf_ports.filter" 2> /dev/null && return
877877 cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null \
878878 >> ${DBDIR}/leaf_ports_secondary_candidates.new_requirements || :
879879 fileedit_add_a_line_if_new "$origin" "${DBDIR}/leaf_ports.filter"
@@ -889,10 +889,10 @@ command_do_inspection_of_requirements_of_new_leaf_ports ()
889889 break
890890 fi
891891 {
892- grep -Fx -v -f "${DBDIR}/leaf_ports.filter" \
892+ env LANG=C grep -Fx -v -f "${DBDIR}/leaf_ports.filter" \
893893 "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" || :
894894 cat "${DBDIR}/leaf_ports_secondary_candidates.new_requirements" || :
895- } 2> /dev/null | grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null | sort -u \
895+ } 2> /dev/null | env LANG=C grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null | sort -u \
896896 > ${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates.tmp || :
897897 program_reset_loop_for_stage INSPECT_REQUIREMENTS_OF_LEAF_PORTS
898898 mv "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates.tmp" \
@@ -902,7 +902,7 @@ command_do_inspection_of_requirements_of_new_leaf_ports ()
902902 num_inspect=`wc -l < ${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates | tr -d ' '`
903903 message_echo " $num_leaves_new leaf port(s) is/are newly found; continue for $num_inspect candidate(s)."
904904 done
905- grep -Fx -f "${DBDIR}/leaf_ports.filter" "${DBDIR}/inspected_ports" 2> /dev/null | sort -u > ${DBDIR}/leaf_ports || :
905+ env LANG=C grep -Fx -f "${DBDIR}/leaf_ports.filter" "${DBDIR}/inspected_ports" 2> /dev/null | sort -u > ${DBDIR}/leaf_ports || :
906906 message_echo
907907 }
908908 program_exec_and_record_completion INSPECT_REQUIREMENTS_OF_LEAF_PORTS
@@ -1008,7 +1008,7 @@ command_do_collection_of_obsolete_ports_to_delete ()
10081008 cat "${DBDIR}/initial/$origin/requirements.run.full" || :
10091009 cat "${DBDIR}/obsolete/$origin/requirements.run.full" || :
10101010 done | sort -u > $reqptn_file
1011- grep -v -Fx -f "$reqptn_file" "$src_selected" > $dst_selected 2> /dev/null || :
1011+ env LANG=C grep -v -Fx -f "$reqptn_file" "$src_selected" > $dst_selected 2> /dev/null || :
10121012 message_echo
10131013 }
10141014 program_exec_and_record_completion COLLECT_OBSOLETE_PORTS_TO_DELETE
@@ -1049,7 +1049,7 @@ command_do_composition_of_a_list_for_deinstallation_of_obsolete_and_leaf_package
10491049 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
10501050 then
10511051 cat "$reqptn_leaf" "$reqptn_obs" 2> /dev/null | sort -u > $grepptn
1052- grep -v -Fx -f "$grepptn" "$leaf_selected_src" 2> /dev/null \
1052+ env LANG=C grep -v -Fx -f "$grepptn" "$leaf_selected_src" 2> /dev/null \
10531053 | database_query_add_initial_origins > $leaf_selected || :
10541054 cat "$obs_selected" "$leaf_selected" 2> /dev/null || :
10551055 else
@@ -1059,11 +1059,11 @@ command_do_composition_of_a_list_for_deinstallation_of_obsolete_and_leaf_package
10591059 str_escape_regexp_filter < ${DBDIR}/stage.loop_list/ports_to_delete \
10601060 | sed 's/^/^/;s/$/[[:space:]]/' > $grepptn_col1
10611061 cat "${DBDIR}/leaf_ports.with_ini" "${DBDIR}/obsolete_ports" 2> /dev/null \
1062- | grep -Fx -v -f "${DBDIR}/stage.loop_list/ports_to_delete" > ${DBDIR}/stage.loop_list/ports_to_restore 2> /dev/null || :
1062+ | env LANG=C grep -Fx -v -f "${DBDIR}/stage.loop_list/ports_to_delete" > ${DBDIR}/stage.loop_list/ports_to_restore 2> /dev/null || :
10631063 if [ $opt_batch_mode = no ]
10641064 then
10651065 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ] && \
1066- grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$leaf_selected_src" > $preserved 2> /dev/null
1066+ env LANG=C grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$leaf_selected_src" > $preserved 2> /dev/null
10671067 then
10681068 message_echo "INFO: Following leaf ports are preserved because required by other preserved leaf/obsolete ports."
10691069 message_echo "----------------"
@@ -1079,7 +1079,7 @@ command_do_composition_of_a_list_for_deinstallation_of_obsolete_and_leaf_package
10791079 done < $preserved
10801080 message_echo "----------------"
10811081 fi
1082- if grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$obs_selected_src" > $preserved 2> /dev/null
1082+ if env LANG=C grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$obs_selected_src" > $preserved 2> /dev/null
10831083 then
10841084 message_echo "INFO: Following obsolete ports are preserved because required by other obsolete ports."
10851085 message_echo "----------------"
@@ -1112,7 +1112,7 @@ command_do_collect_entire_distfiles_list ()
11121112 {
11131113 message_section_title "Collecting entire distfiles list"
11141114 find "${PORTSDIR}" -depth 3 -name distinfo -exec cat {} \; \
1115- | grep '^SHA256 ' | sed -E 's/^SHA256 \(([^)]*)\).*/\1/' \
1115+ | env LANG=C grep '^SHA256 ' | sed -E 's/^SHA256 \(([^)]*)\).*/\1/' \
11161116 | sort -u > ${DBDIR}/distfiles.entire.tmp
11171117 mv "${DBDIR}/distfiles.entire.tmp" "${DBDIR}/distfiles.entire"
11181118 message_echo
@@ -1292,7 +1292,7 @@ command_do_rebuild_of_package_database ()
12921292 {
12931293 which -s pkgdb || return 0
12941294 message_section_title "Rebuilding package database for portupgrade"
1295- if grep -q @ "${DBDIR}/stage.loop_list/reinst_todo"
1295+ if env LANG=C grep -q @ "${DBDIR}/stage.loop_list/reinst_todo"
12961296 then
12971297 message_echo "INFO: Skipped because of lacking flavor support."
12981298 else
--- a/lib/libcommand_flexconf.sh
+++ b/lib/libcommand_flexconf.sh
@@ -100,8 +100,8 @@ command_flexconf_update_freeze ()
100100 fileedit_combine_lists "${DBDIR}/conf/FREEZE:PORTS.parsed" "${DBDIR}/freeze.list" > ${DBDIR}/freeze.all.list
101101 rm -f "$tmp_list:exists_update"
102102 {
103- grep -vFx -f "$tmp_list:old" "${DBDIR}/freeze.all.list"
104- grep -vFx -f "${DBDIR}/freeze.all.list" "$tmp_list:old"
103+ env LANG=C grep -vFx -f "$tmp_list:old" "${DBDIR}/freeze.all.list"
104+ env LANG=C grep -vFx -f "${DBDIR}/freeze.all.list" "$tmp_list:old"
105105 } | while read origin
106106 do
107107 touch "$tmp_list:exists_update"
--- a/lib/libcommand_forget.sh
+++ b/lib/libcommand_forget.sh
@@ -74,7 +74,7 @@ command_forget ()
7474 origin=$1
7575 origins_init=`database_query_initial_orgins "$origin"`
7676 if [ -z "$origins_init" ] \
77- && ! grep -qv -Fx -f "${DBDIR}/forget/remove.scope.filter" \
77+ && ! env LANG=C grep -qv -Fx -f "${DBDIR}/forget/remove.scope.filter" \
7878 "${DBDIR}/requires/$origin/dependents.all.full" \
7979 2> /dev/null
8080 then
@@ -94,7 +94,7 @@ command_forget ()
9494 cat "${DBDIR}/forget/remove" || :
9595 } 2> /dev/null | sort -u > ${DBDIR}/forget/remove.filter
9696 cat "${DBDIR}/inspected_ports.update" 2> /dev/null | sort -u \
97- | grep -v -Fx -f "${DBDIR}/forget/remove.filter" \
97+ | env LANG=C grep -v -Fx -f "${DBDIR}/forget/remove.filter" \
9898 > ${DBDIR}/inspected_ports.update.tmp 2> /dev/null || :
9999 mv "${DBDIR}/inspected_ports.update.tmp" "${DBDIR}/inspected_ports.update"
100100 message_echo
--- a/lib/libcommand_pkgs.sh
+++ b/lib/libcommand_pkgs.sh
@@ -77,7 +77,7 @@ command_pkgs_restore ()
7777 do
7878 pkgsys_register_evaluated_globs remove "${DBDIR}/taboo.list" "$origin"
7979 message_echo " Deregistered $origin from taboo."
80- grep -Fx -q "$origin" "$tmp_done_orig" 2> /dev/null || :
80+ env LANG=C grep -Fx -q "$origin" "$tmp_done_orig" 2> /dev/null || :
8181 if pkgsys_exists_from_orig "$origin"
8282 then
8383 pkg=`pkgsys_get_installed_pkg_from_origin "$origin"`
@@ -159,7 +159,7 @@ command_pkgs_pkgsanity ()
159159 while read origin
160160 do
161161 pkgsys_get_installed_pkg_from_origin "$origin"
162- done < $tmp_list.orgs | grep -v '^[[:space:]]*$' > $tmp_list.pkgs || {
162+ done < $tmp_list.orgs | env LANG=C grep -v '^[[:space:]]*$' > $tmp_list.pkgs || {
163163 message_echo "WARNING: No such globs match any installed package." >&2
164164 temp_terminate_process () { :; }
165165 exit 1
@@ -212,7 +212,7 @@ command_pkgs_pkgsanity ()
212212 iline=$((${iline}+1))
213213 origin=`pkg_info_flavored_origin "$pkg"`
214214 [ -n "$origin" ] || continue
215- grep -q -Fx "$origin" "${DBDIR}/damaged_package" 2>/dev/null && continue
215+ env LANG=C grep -q -Fx "$origin" "${DBDIR}/damaged_package" 2>/dev/null && continue
216216 pkgsys_sanitychk_pkgcontents "$pkg" is_reinstall_encouraged && continue
217217 port_path=`pkgsys_get_portpath_from_origin "$origin"`
218218 if [ ! -d "$port_path" ]
@@ -312,7 +312,7 @@ command_pkgs_packupgrade_create__manifest_reinst ()
312312 PROGRAM_DEPENDS=COMMAND_PACKUPGRADE_PREPARE
313313 _program_exec_restartable_loop_operation__routine ()
314314 {
315- local origin dstdir tmp_manifest dbdir_new pkgname pkgarc timestamp_inst timestamp_arc origin_old
315+ local origin dstdir tmp_manifest dbdir_new pkgname pkgarc timestamp_inst timestamp_arc origin_old origin_equiv
316316 origin=$1
317317 dstdir=${DBDIR}/command_packupgrade
318318 tmp_manifest=${TMPDIR}/packupgrade::manifest
@@ -320,14 +320,14 @@ command_pkgs_packupgrade_create__manifest_reinst ()
320320 dbdir_new=${DBDIR}/requires/$origin
321321 pkgname=`pkgsys_get_installed_pkg_from_origin "$origin"`
322322 [ -n "$pkgname" ] || return 0
323- if ! grep -Fxq "$pkgname" "$dstdir/etc/created_packages.lst" 2> /dev/null
323+ if ! env LANG=C grep -Fxq "$pkgname" "$dstdir/etc/created_packages.lst" 2> /dev/null
324324 then
325325 if pkg_info_e "$pkgname"
326326 then
327327 if pkgarc=`pkgsys_pkgname_to_pkgarc "${PACKAGESDIR}" "$pkgname"`
328328 then
329329 timestamp_inst=`pkg_get_pkg_timestamp "$pkgname" 2> /dev/null` || :
330- timestamp_arc=`ls -lD %s "$pkgarc" 2> /dev/null | sed -E 's/[[:space:]]+/ /g' | cut -w -f 6 | grep -v '^$'` || :
330+ timestamp_arc=`ls -lD %s "$pkgarc" 2> /dev/null | sed -E 's/[[:space:]]+/ /g' | cut -w -f 6 | env LANG=C grep -v '^$'` || :
331331 else
332332 timestamp_inst=1
333333 timestamp_arc=0
@@ -340,10 +340,14 @@ command_pkgs_packupgrade_create__manifest_reinst ()
340340 exit 1
341341 fi
342342 fi
343- elif grep -Fxq "$origin" ${DBDIR}/success.run.full.list
343+ elif env LANG=C grep -Fxq "$origin" ${DBDIR}/success.run.full.list
344344 then
345- message_echo "ERROR: Necessary package is missing [$origin]." >&2
346- exit 1
345+ origin_equiv=`database_query_get_equivalent_orgin "$origin"`
346+ if [ -z "$origin_equiv" ] || env LANG=C grep -Fxq "$origin_equiv" ${DBDIR}/success.run.full.list
347+ then
348+ message_echo "ERROR: Necessary package is missing [$origin]." >&2
349+ exit 1
350+ fi
347351 fi
348352 fileedit_add_a_line_if_new "$pkgname" "$dstdir/etc/created_packages.lst"
349353 fi
--- a/lib/libconf.sh
+++ b/lib/libconf.sh
@@ -55,7 +55,7 @@ conf_parse_vars_for_each_port_glob ()
5555 {
5656 local section
5757 section=$1
58- misc_get_all_vardefs | grep -e "^_CONF_${section}_" | cut -d = -f 1 | while read var
58+ misc_get_all_vardefs | env LANG=C grep -e "^_CONF_${section}_" | cut -d = -f 1 | while read var
5959 do
6060 eval glob_pattern=\${$var}
6161 pkgsys_eval_ports_glob "$glob_pattern"
@@ -69,7 +69,7 @@ conf_parse_vars_for_each_port_glob_with_bound_val ()
6969 section=$1
7070 tag_target=$2
7171 tag_val=$3
72- misc_get_all_vardefs | grep -e "^_CONF_${section}_${tag_target}_" | cut -d = -f 1 | while read var
72+ misc_get_all_vardefs | env LANG=C grep -e "^_CONF_${section}_${tag_target}_" | cut -d = -f 1 | while read var
7373 do
7474 eval glob_pattern=\${$var}
7575 eval val=\$\{`echo "$var" | sed "s/^_CONF_${section}_${tag_target}_/_CONF_${section}_${tag_val}_/"`\}
@@ -210,13 +210,13 @@ conf_manipulate_available_var_defs ()
210210 _CONFVARS='ENV ALT_MOVED HOLD TABOO FREEZE NOPKG REPLACE_FROM REPLACE_TO CONFLICT_TARGET CONFLICT_DEF BUILDCONFLICT_TARGET BUILDCONFLICT_DEF INSTCONFLICT_TARGET INSTCONFLICT_DEF MARG_TARGET MARG_DEF MENV_TARGET MENV_DEF BEFOREBUILD BEFOREDEINSTALL AFTERINSTALL'
211211 for item in ${_CONFVARS}
212212 do
213- misc_get_all_vardefs | grep -e "^${item}_" | cut -d = -f 1 | sed 's/^/unset /'
213+ misc_get_all_vardefs | env LANG=C grep -e "^${item}_" | cut -d = -f 1 | sed 's/^/unset /'
214214 done > $tmpfile_unsetvars
215215 . "$tmpfile_unsetvars"
216216 . "${DBDIR}/conf/complete_setup.sh"
217217 for item in ${_CONFVARS}
218218 do
219- misc_get_all_vardefs | grep -e "^${item}_" | sed 's/^/_CONF_/'
219+ misc_get_all_vardefs | env LANG=C grep -e "^${item}_" | sed 's/^/_CONF_/'
220220 done | sort -u > ${DBDIR}/conf/manipulated_defs.sh
221221 ) || { message_echo "ERROR: Failed to manipulate available variable definitions from the configuration file." >&2; exit 1; }
222222 }
@@ -224,12 +224,12 @@ conf_manipulate_available_var_defs ()
224224 # ============= Build an effective MOVED database =============
225225 conf_build_effective_MOVED ()
226226 {
227- grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "${PORTS_MOVED_DB}" > ${DBDIR}/conf/MOVED.parsed
228- misc_get_all_vardefs | grep -e '^_CONF_ALT_MOVED_' | cut -d = -f 1 | while read var
227+ env LANG=C grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "${PORTS_MOVED_DB}" > ${DBDIR}/conf/MOVED.parsed
228+ misc_get_all_vardefs | env LANG=C grep -e '^_CONF_ALT_MOVED_' | cut -d = -f 1 | while read var
229229 do
230230 eval movedsb_path=\${$var}
231231 cat "$movedsb_path"
232- done | grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' > ${DBDIR}/conf/MOVED_ALT.parsed || :
232+ done | env LANG=C grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' > ${DBDIR}/conf/MOVED_ALT.parsed || :
233233 cat "${DBDIR}/conf/MOVED_ALT.parsed" >> ${DBDIR}/conf/MOVED.parsed
234234 }
235235
@@ -241,7 +241,7 @@ conf_setup_effective_env ()
241241 do
242242 eval $key=\$\{_CONF_ENV_$key:-\$\{$key\}\}
243243 done
244- misc_get_all_vardefs | grep -e '^LOCALBASE=' -e '^LINUXBASE=' -e '^PORT_DBDIR=' -e '^PORTSDIR=' -e '^DISTDIR=' -e 'PACKAGES=' -e '^PKG_PATH=' -e '^PKGREPOSITORY=' -e '^PACKAGECHECKSUMROOTS=' -e '^PACKAGECHECKSUMDIR=' -e '^PACKAGEROOTS=' -e '^PACKAGEDIR='
244+ misc_get_all_vardefs | env LANG=C grep -e '^LOCALBASE=' -e '^LINUXBASE=' -e '^PORT_DBDIR=' -e '^PORTSDIR=' -e '^DISTDIR=' -e 'PACKAGES=' -e '^PKG_PATH=' -e '^PKGREPOSITORY=' -e '^PACKAGECHECKSUMROOTS=' -e '^PACKAGECHECKSUMDIR=' -e '^PACKAGEROOTS=' -e '^PACKAGEDIR='
245245 )
246246 echo '[ -n "$PKG_PATH" ] && PKGREPOSITORY=$PKG_PATH'
247247 echo 'conf_setup_ports_envs'
@@ -257,7 +257,7 @@ conf_build_replacement_patterns_from_REPLACE ()
257257 cp /dev/null "${DBDIR}/conf/REPLACE.filter"
258258 cp /dev/null "${DBDIR}/conf/REPLACE.sed_pattern"
259259 cp /dev/null "${DBDIR}/conf/REPLACE.csv"
260- misc_get_all_vardefs | grep -e '^_CONF_REPLACE_FROM_' | cut -d = -f 1 | while read var
260+ misc_get_all_vardefs | env LANG=C grep -e '^_CONF_REPLACE_FROM_' | cut -d = -f 1 | while read var
261261 do
262262 eval glob_pattern=\$\{$var\}
263263 eval to=\$\{`echo "$var" | sed 's/^_CONF_REPLACE_FROM_/_CONF_REPLACE_TO_/'`\}
--- a/lib/libdatabase_build.sh
+++ b/lib/libdatabase_build.sh
@@ -41,7 +41,7 @@ database_build_convert_and_register_origin_if_obsolete ()
4141 echo "$origin" > ${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origin
4242 pkgsys_exists_port "$origin" && return
4343 database_build_register_obsolete_port "$origin"
44- grep -n -m 1 -E "^`str_escape_regexp \"$origin\"`\|" "$recursedb" 2> /dev/null > ${TMPDIR}/moved.info || :
44+ env LANG=C grep -n -m 1 -E "^`str_escape_regexp \"$origin\"`\|" "$recursedb" 2> /dev/null > ${TMPDIR}/moved.info || :
4545 if [ `wc -l < ${TMPDIR}/moved.info` -eq 0 ]
4646 then
4747 fileedit_add_a_line_if_new "$origin" "${DBDIR}/obsolete_ports"
@@ -206,7 +206,7 @@ database_build_setup_replace_node ()
206206 rm -rf "$dbpath"
207207 mkdir -p "$dbpath"
208208 origin_trial=$origin_orig
209- if echo "$origin_orig" | grep -q -Fx -f "${DBDIR}/conf/REPLACE.filter" 2> /dev/null
209+ if echo "$origin_orig" | env LANG=C grep -q -Fx -f "${DBDIR}/conf/REPLACE.filter" 2> /dev/null
210210 then
211211 origin_trial=`echo "$origin_orig" | sed -E -f "${DBDIR}/conf/REPLACE.sed_pattern"`
212212 if [ "x$origin_orig" != "x$origin_trial" ]
@@ -279,9 +279,9 @@ database_build_get_inspected_level ()
279279 then
280280 echo full
281281 elif ! pkgsys_exists_or_existed_from_orig "$origin" \
282- || grep -qFx "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null \
282+ || env LANG=C grep -qFx "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null \
283283 || [ ! -e "${DBDIR}/moved_from/$origin_dependent/installed_version" ] \
284- || grep -qFx "$origin_dependent" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null
284+ || env LANG=C grep -qFx "$origin_dependent" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null
285285 then
286286 echo direct
287287 else
@@ -302,7 +302,7 @@ database_build_is_port_already_inspected_in_required_level ()
302302 cat "${DBDIR}/ports.inspected.${inspected_level}.list" || :
303303 cat "${DBDIR}/moved_ports" || :
304304 cat "${DBDIR}/obsolete_ports" || :
305- } 2> /dev/null | grep -q -Fx "$origin_actual" || return
305+ } 2> /dev/null | env LANG=C grep -q -Fx "$origin_actual" || return
306306 fileedit_rm_a_line "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect.remain"
307307 [ "x$origin" = "$origin_actual" ] || \
308308 fileedit_rm_a_line "$origin_actual" "${DBDIR}/stage.loop_list/ports_to_inspect.remain"
@@ -374,7 +374,7 @@ database_build_get_full_run_requirement_pkgs ()
374374 while read origin
375375 do
376376 database_build_get_new_pkgname "$origin"
377- done < $srcfile | grep -v '^[[:space:]]*$' | sort -u > $savefile
377+ done < $srcfile | env LANG=C grep -v '^[[:space:]]*$' | sort -u > $savefile
378378 fi
379379 cat "$savefile" 2> /dev/null || :
380380 }
@@ -471,7 +471,7 @@ database_build_determine_flavored_origin ()
471471 if [ -n "$flavor_trial" ]
472472 then
473473 flavors_ptn="^("`database_build_make "$origin" -V FLAVORS 2> /dev/null | sed -E 's/[[:space:]]+/|/g'`")$"
474- echo "$flavor_trial" | grep -qE "$flavors_ptn" || flavor_trial=
474+ echo "$flavor_trial" | env LANG=C grep -qE "$flavors_ptn" || flavor_trial=
475475 fi
476476 origin_trial=`pkgsys_compose_flavored_origin "$origin_unflavored" "$flavor_trial"`
477477 flavor=`database_build_make "$origin_trial" -V FLAVOR 2> /dev/null || :`
@@ -576,7 +576,7 @@ database_build_inspect_dependencies ()
576576 [ "x$origin_orig" = "x$origin" ] || fileedit_add_a_line_if_new "$origin_orig" "$frompath/initial_orig"
577577 [ -e "${DBDIR}/initial/$origin_orig/SUPPRESSED_SELF" ] && touch "$frompath/SUPPRESSED_SELF"
578578 [ -e "${DBDIR}/initial/$origin_orig/SUPPRESSED_PKGNG" ] && touch "$frompath/SUPPRESSED_PKGNG"
579- if ! grep -qFx "$origin" "${DBDIR}/done_required_ports_to_inspect" 2> /dev/null
579+ if ! env LANG=C grep -qFx "$origin" "${DBDIR}/done_required_ports_to_inspect" 2> /dev/null
580580 then
581581 fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports"
582582 fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
@@ -588,7 +588,7 @@ database_build_inspect_dependencies ()
588588 # Notify reconfiguration of the port option
589589 conf_updated=
590590 if [ -e "$dbpath/complete_as_node" ] || \
591- grep -q -Fx -e "$origin_orig" -e "$origin" "${DBDIR}/to_be_reconf" 2> /dev/null
591+ env LANG=C grep -q -Fx -e "$origin_orig" -e "$origin" "${DBDIR}/to_be_reconf" 2> /dev/null
592592 then
593593 message_echo "${DEPTH_INDEX} ===> Reconfigured"
594594 conf_updated=y
@@ -647,7 +647,7 @@ database_build_inspect_dependencies ()
647647 do
648648 tr ' ' '\n' < ${TMPDIR}/database_build_inspect_dependencies:${tag}_depends_list | \
649649 sed -E 's#.*:([^:/]+/[^:/]+|[^:/]+/[^:/]+:[^:/]*)$#\1#' | cut -d : -f 1 | sort -u | \
650- grep -Ev "`pkgsys_pkgtools_ports_filter_regexp`" \
650+ env LANG=C grep -Ev "`pkgsys_pkgtools_ports_filter_regexp`" \
651651 | while read origin_flavor_incomplete
652652 do
653653 ( set -e
@@ -655,9 +655,9 @@ database_build_inspect_dependencies ()
655655 database_build_determine_port_option "$origin_flavor_incomplete"
656656 )
657657 database_build_determine_flavored_origin "$origin_flavor_incomplete"
658- done | grep -v '^$' | sort -u > $dbpath/requirements.$tag.orig || :
658+ done | env LANG=C grep -v '^$' | sort -u > $dbpath/requirements.$tag.orig || :
659659 sed -E -f "${DBDIR}/conf/REPLACE.sed_pattern" "$dbpath/requirements.$tag.orig" \
660- | grep -v '^$' | sort -u > $dbpath/requirements.$tag.src || :
660+ | env LANG=C grep -v '^$' | sort -u > $dbpath/requirements.$tag.src || :
661661 done
662662 for stage in orig src
663663 do
@@ -695,12 +695,12 @@ database_build_inspect_dependencies ()
695695 inspected_level=`database_build_get_inspected_level "$origin" "$origin_dependent"`
696696 case $inspected_level in
697697 full )
698- grep -v -Fx -f "${DBDIR}/installed_ports" \
698+ env LANG=C grep -v -Fx -f "${DBDIR}/installed_ports" \
699699 "$dbpath/requirements.all.direct.src" > ${TMPDIR}/missing.$origin_id || :
700700 inspected_levels_compatible='full direct node'
701701 ;;
702702 direct )
703- grep -v -Fx -f "${DBDIR}/installed_ports" \
703+ env LANG=C grep -v -Fx -f "${DBDIR}/installed_ports" \
704704 "$dbpath/requirements.all.direct.src" > ${TMPDIR}/missing.$origin_id || :
705705 inspected_levels_compatible='direct node'
706706 ;;
@@ -716,7 +716,7 @@ database_build_inspect_dependencies ()
716716 do
717717 origin_dependency=`sed -n ${iline}p "${TMPDIR}/missing.$origin_id"`
718718 iline=$(($iline+1))
719- grep -q -Fx "$origin_dependency" "${DBDIR}/ports.inspected.list" 2> /dev/null && \
719+ env LANG=C grep -q -Fx "$origin_dependency" "${DBDIR}/ports.inspected.list" 2> /dev/null && \
720720 continue
721721 database_build_inspect_dependencies "$origin_dependency" "$origin"
722722 done
@@ -737,7 +737,7 @@ database_build_inspect_dependencies ()
737737 # Transfer data from the previous database if existent, successful and no change
738738 pkg_new=`cat "$dbpath/new_version"`
739739 if [ ! -e "$dbpath/conf_updated" -a -d "$dbpath_prev" ] && pkg_info_e "$pkg_new" 2> /dev/null && \
740- ! grep -qFx "$origin" "$dbpath_prev/to_be_reconf" 2> /dev/null
740+ ! env LANG=C grep -qFx "$origin" "$dbpath_prev/to_be_reconf" 2> /dev/null
741741 then
742742 same_as_prevset=yes
743743 for dbfile in new_version CONFLICT.conf BUILDCONFLICT.conf MARG.conf MENV.conf \
@@ -772,7 +772,7 @@ database_build_inspect_dependencies ()
772772 then
773773 for dbfile in failed.list damaged_package manually_done.list
774774 do
775- if grep -qFx "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null
775+ if env LANG=C grep -qFx "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null
776776 then
777777 same_as_prevset=no
778778 break
@@ -799,7 +799,7 @@ database_build_inspect_dependencies ()
799799 done
800800 } | while read dbfile
801801 do
802- if grep -Fxq "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null
802+ if env LANG=C grep -Fxq "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null
803803 then
804804 fileedit_add_a_line_if_new "$origin" "${DBDIR}/$dbfile"
805805 fi
@@ -856,7 +856,7 @@ database_build_filter_ignored_requirements ()
856856 pattern=${DBDIR}/requires/$origin/ignored_requirements.filter
857857 if [ -e "$pattern" ]
858858 then
859- grep -Fxvq -f "$pattern"
859+ env LANG=C grep -Fxvq -f "$pattern"
860860 else
861861 cat
862862 fi 2> /dev/null || :
@@ -882,9 +882,9 @@ database_build_get_complete_recursive_dependency ()
882882 then
883883 touch "$tmppath.parents"
884884 num_parents=`wc -l < $tmppath.parents`
885- if grep -Fxq "$origin" "$tmppath.parents"
885+ if env LANG=C grep -Fxq "$origin" "$tmppath.parents"
886886 then
887- loophead=`grep -Fxn "$origin" "$tmppath.parents" | tail -n 1 | cut -d : -f 1`
887+ loophead=`env LANG=C grep -Fxn "$origin" "$tmppath.parents" | tail -n 1 | cut -d : -f 1`
888888 if [ "x$opt_force_continuation_for_looped_dependency" = xno ]
889889 then
890890 message_echo "ERROR: The following loop was found for requirements.${tag}${suffix}:" >&2
@@ -913,8 +913,8 @@ database_build_get_complete_recursive_dependency ()
913913 origin_target=`sed -n ${index_loop}p "$tmppath.ports_in_loop"`
914914 origin_ref=`sed -n $((${index_loop}+1))p "$tmppath.ports_in_loop"`
915915 dbpath_target=${DBDIR}/requires/$origin_target
916- if ! grep -Fxq "$origin_ref" "$dbpath_target/requirements.run.direct${suffix}" 2> /dev/null || \
917- ! grep -Fxq "$origin_ref" "$dbpath_target/requirements.build.direct${suffix}" 2> /dev/null
916+ if ! env LANG=C grep -Fxq "$origin_ref" "$dbpath_target/requirements.run.direct${suffix}" 2> /dev/null || \
917+ ! env LANG=C grep -Fxq "$origin_ref" "$dbpath_target/requirements.build.direct${suffix}" 2> /dev/null
918918 then
919919 message_echo 'INFO: The dependency of '$origin_target' on '$origin_ref' is ignored to terminate the loop.' >&2
920920 break
@@ -929,7 +929,7 @@ database_build_get_complete_recursive_dependency ()
929929 do
930930 for tag_tmp in run build
931931 do
932- grep -Fxq "$origin_ref" "$dbpath_target/requirements.${tag_tmp}.direct${suffix_tmp}" 2> /dev/null && \
932+ env LANG=C grep -Fxq "$origin_ref" "$dbpath_target/requirements.${tag_tmp}.direct${suffix_tmp}" 2> /dev/null && \
933933 fileedit_add_a_line_if_new "$origin_ref" "$dbpath_target/ignored_requirements.${tag_tmp}${suffix_tmp}"
934934 done
935935 cat "$dbpath_target/ignored_requirements.run${suffix_tmp}" "$dbpath_target/ignored_requirements.build${suffix_tmp}" 2> /dev/null | sort -u > $dbpath_target/ignored_requirements.all${suffix_tmp}
@@ -948,7 +948,7 @@ database_build_get_complete_recursive_dependency ()
948948 [ "x$tag" = xbuild ] && tag_dep=run
949949 recursive_dependency=`database_build_get_complete_recursive_dependency "$tag_dep" "$origin_requirement" "$suffix"`
950950 [ -e "$dbpath/ignored_requirements.filter" ] && \
951- echo "$origin_requirement" | grep -Fxq -f "$dbpath/ignored_requirements.filter" 2> /dev/null && \
951+ echo "$origin_requirement" | env LANG=C grep -Fxq -f "$dbpath/ignored_requirements.filter" 2> /dev/null && \
952952 continue
953953 echo "$origin_requirement"
954954 echo "$recursive_dependency"
@@ -957,7 +957,7 @@ database_build_get_complete_recursive_dependency ()
957957 mv "$tmppath.parents.tmp" "$tmppath.parents"
958958 if [ ! -e "$dstfile" ]
959959 then
960- sort -u "$dstfile_tmp" | grep -v '^$' > $dstfile || :
960+ sort -u "$dstfile_tmp" | env LANG=C grep -v '^$' > $dstfile || :
961961 rm "$dstfile_tmp"
962962 fi
963963 fi
@@ -1095,7 +1095,7 @@ database_build_order_ports_considering_dependencies ()
10951095 (cd "${DBDIR}/requires" && \
10961096 find . -depth 3 -name requirements.all.full -exec echo {} \; -exec cat {} \; -exec echo \;) | \
10971097 env "DBDIR=${DBDIR}" awk -f "${LIBEXECDIR}"/order_dependencies.awk || return
1098- grep -v '^$' "${DBDIR}/reinst_order.list.tmp" > "${DBDIR}/reinst_order.list" || :
1098+ env LANG=C grep -v '^$' "${DBDIR}/reinst_order.list.tmp" > "${DBDIR}/reinst_order.list" || :
10991099 }
11001100
11011101 # ============= [Sub-function] Common operations for resetting configurations for a port =============
@@ -1187,7 +1187,7 @@ database_build_post_inspect_dependencies ()
11871187 cat "${DBDIR}/conf/HOLD:PORTS.parsed" || :
11881188 cat "${DBDIR}/need.list" || :
11891189 } 2> /dev/null | sort -u > $tmpfile.obsolete_ports.exclude
1190- grep -v -Fx -f "$tmpfile.obsolete_ports.exclude" "${DBDIR}/obsolete_ports" > ${DBDIR}/obsolete_ports.can_be_deleted || :
1190+ env LANG=C grep -v -Fx -f "$tmpfile.obsolete_ports.exclude" "${DBDIR}/obsolete_ports" > ${DBDIR}/obsolete_ports.can_be_deleted || :
11911191 cp /dev/null "${DBDIR}/REPLACE.complete_sed_pattern.tmp"
11921192 find "${DBDIR}/replace" -depth 3 -type f -name origin | while read nodepath
11931193 do
@@ -1200,7 +1200,7 @@ database_build_post_inspect_dependencies ()
12001200 mv "${DBDIR}/REPLACE.complete_sed_pattern.tmp" "${DBDIR}/REPLACE.complete_sed_pattern"
12011201 if [ `cat "${DBDIR}/inspected_ports.update" 2> /dev/null | wc -l` -gt 0 ]
12021202 then
1203- grep -Fx -f "${DBDIR}/inspected_ports.all" "${DBDIR}/inspected_ports.update" \
1203+ env LANG=C grep -Fx -f "${DBDIR}/inspected_ports.all" "${DBDIR}/inspected_ports.update" \
12041204 > ${DBDIR}/inspected_ports.update.tmp 2> /dev/null || :
12051205 mv "${DBDIR}/inspected_ports.update.tmp" "${DBDIR}/inspected_ports.update"
12061206 if [ $opt_only_target_scope = yes ]
--- a/lib/libdatabase_maintain.sh
+++ b/lib/libdatabase_maintain.sh
@@ -52,7 +52,7 @@ database_maintain_create ()
5252 misc_lock_duplicated_executions "${DBDIR}/.lock"
5353 if [ -e "${DBDIR}/MYVERSION" ]
5454 then
55- if ! grep -q -E "$COMPATIBLE_VERSIONS" "${DBDIR}/MYVERSION" 2> /dev/null
55+ if ! env LANG=C grep -q -E "$COMPATIBLE_VERSIONS" "${DBDIR}/MYVERSION" 2> /dev/null
5656 then
5757 message_echo "ERROR: The current temporary database is incompatible. You must delete it by" >&2
5858 message_echo " ${APPNAME} clean force" >&2
--- a/lib/libdatabase_query.sh
+++ b/lib/libdatabase_query.sh
@@ -16,10 +16,10 @@ database_query_show_list_failure ()
1616 message_echo "INFO: No item is registered in this list."
1717 return 1
1818 fi
19- grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern" "${DBDIR}/failed.list" 2> /dev/null \
19+ env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern" "${DBDIR}/failed.list" 2> /dev/null \
2020 | while read origin
2121 do
22- grep -q -Fx "$origin" "${DBDIR}/stage.loop_list/ports_to_delete" 2> /dev/null \
22+ env LANG=C grep -q -Fx "$origin" "${DBDIR}/stage.loop_list/ports_to_delete" 2> /dev/null \
2323 || echo "$origin"
2424 done > $tmp_valid
2525 if [ `cat "$tmp_valid" 2> /dev/null | wc -l` -eq 0 ]
@@ -31,7 +31,7 @@ database_query_show_list_failure ()
3131 do
3232 note=`cat "${DBDIR}/notes/$origin/note_failtre" 2> /dev/null || :`
3333 resolved=no
34- grep -q -Fx "$origin" "${DBDIR}/manually_done.list" 2> /dev/null && resolved=yes
34+ env LANG=C grep -q -Fx "$origin" "${DBDIR}/manually_done.list" 2> /dev/null && resolved=yes
3535 pkgtag=`cat "${DBDIR}/moved_from/$origin/pkgtag" 2> /dev/null || :`
3636 if [ $opt_batch_mode = no ]
3737 then
@@ -66,11 +66,11 @@ database_query_show_list_failed_conflicts_restoration ()
6666 message_echo "INFO: No item is registered in this list."
6767 return 1
6868 fi
69- grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" \
69+ env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" \
7070 | while read origin pkg
7171 do
7272 pkg_regexp=`str_escape_regexp "$pkg"`
73- against=`grep -E "^$pkg_regexp:" "${DBDIR}/forbidden_conflicts" 2> /dev/null | cut -d : -f 2,3 | sort -u`
73+ against=`env LANG=C grep -E "^$pkg_regexp:" "${DBDIR}/forbidden_conflicts" 2> /dev/null | cut -d : -f 2,3 | sort -u`
7474 if [ $opt_batch_mode = no ]
7575 then
7676 if [ -n "$pkg" ]
@@ -256,7 +256,7 @@ database_query_is_default_conf ()
256256 echo "Non-default port options," >> $tmp_msg
257257 is_customized=yes
258258 fi
259- if grep -q -Fx "$origin" "${DBDIR}/conf/NOPKG:PORTS.parsed" 2> /dev/null
259+ if env LANG=C grep -q -Fx "$origin" "${DBDIR}/conf/NOPKG:PORTS.parsed" 2> /dev/null
260260 then
261261 echo "Explicit specification as non-default in ${APPNAME}.conf," >> $tmp_msg
262262 is_customized=yes
@@ -546,7 +546,7 @@ database_query_show_single_list ()
546546 matches_negative=no
547547 for negative_listdb in $flag_negative_listdb
548548 do
549- if grep -qFx "$origin" "${DBDIR}/$negative_listdb" 2> /dev/null
549+ if env LANG=C grep -qFx "$origin" "${DBDIR}/$negative_listdb" 2> /dev/null
550550 then
551551 matches_negative=yes
552552 break
@@ -833,8 +833,8 @@ database_query_exists_in_list ()
833833 list=`ls "${DBDIR}"/fossil_pkgs/fossil_since_* | head -n 1`
834834 ;;
835835 conflict )
836- grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" 2> /dev/null \
837- | grep -q -E "^${origin_esc}[[:space:]]"
836+ env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" 2> /dev/null \
837+ | env LANG=C grep -q -E "^${origin_esc}[[:space:]]"
838838 return
839839 ;;
840840 taboo )
@@ -856,7 +856,7 @@ database_query_exists_in_list ()
856856 list=stage.loop_list/ports_to_delete
857857 ;;
858858 esac
859- grep -q -Fx "$origin" "${DBDIR}/$list" 2> /dev/null
859+ env LANG=C grep -q -Fx "$origin" "${DBDIR}/$list" 2> /dev/null
860860 }
861861
862862 # ============= Check whether the requirements of installed packages match the port configuration =============
@@ -870,7 +870,7 @@ database_query_dependency_matching ()
870870 pkg=`database_build_get_new_pkgname "$origin"`
871871 [ -n "$pkg" ] || return
872872 pkg_info_e "$pkg" || return
873- pkg_info_qr "$pkg" | grep -v '^[[:space:]]*$' | sort -u > $tmp_inst
873+ pkg_info_qr "$pkg" | env LANG=C grep -v '^[[:space:]]*$' | sort -u > $tmp_inst
874874 database_build_get_full_run_requirement_pkgs "$origin" > $tmp_db
875875 diff "$tmp_inst" "$tmp_db" > /dev/null 2>/dev/null
876876 }
@@ -883,7 +883,7 @@ database_query_are_requirements_not_locked ()
883883 cat "${DBDIR}/requires/$origin/requirements.all.direct" 2> /dev/null | while read origin_requirement
884884 do
885885 pkg_requirement=`pkgsys_get_installed_pkg_from_origin "$origin_requirement"` || :
886- if grep -q -Fx "$origin_requirement" "${DBDIR}/freeze.all.list" 2> /dev/null
886+ if env LANG=C grep -q -Fx "$origin_requirement" "${DBDIR}/freeze.all.list" 2> /dev/null
887887 then
888888 [ -n "$pkg_requirement" ] || return
889889 elif [ -z "$pkg_requirement" ]
@@ -916,3 +916,21 @@ database_query_initial_orgins ()
916916 fi
917917 :
918918 }
919+
920+# ============= Get an unflavored or flavored equivalence of an origin with the same package name, which is deemed the same version =============
921+# If the input is unflavored and a flavored equivalence is inspected as a required port, the flavored origin is returned.
922+# If the input is flavored and an unflavored equivalence is inspected as a required port, the unflavored origin is returned.
923+# Otherwise, a blank value is returned.
924+database_query_get_equivalent_orgin ()
925+{
926+ local origin origin_esc pkg_origin pkg_origin_esc flavor origin_unflavored_esc origin_search
927+ origin=$1
928+ origin_esc=`str_escape_regexp "$origin"`
929+ pkg_origin=`env LANG=C grep -E "[[:space:]]$origin_esc$" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" | cut -f 2 || :`
930+ [ -n "$pkg_origin" ] || return 0
931+ pkg_origin_esc=`str_escape_regexp "$pkg_origin"`
932+ flavor=`pkgsys_get_flavor_from_origin "$origin"`
933+ origin_search=$origin_unflavored_esc$
934+ [ -n "$flavor" ] || origin_search=$origin_esc@
935+ env LANG=C grep -E "^$pkg_origin_esc[[:space:]]$origin_search" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" | cut -f 2 | head -n 1 || :
936+}
--- a/lib/libdatabase_record.sh
+++ b/lib/libdatabase_record.sh
@@ -33,7 +33,7 @@ database_record_success ()
3333 {
3434 cat "$nodedir/requirements.$dbsuffix" 2> /dev/null
3535 [ $level = full ] && cat "$nodedir/ignored_requirements.$tag" 2> /dev/null
36- } | grep -q -Fx -f "${DBDIR}/failed.list" 2> /dev/null
36+ } | env LANG=C grep -q -Fx -f "${DBDIR}/failed.list" 2> /dev/null
3737 then
3838 fileedit_rm_a_line "$origin" "${DBDIR}/success.$dbsuffix.list"
3939 fileedit_add_a_line_if_new "$origin" "${DBDIR}/todo_after_requirements_succeed.$dbsuffix.list"
--- a/lib/libdeinstall.sh
+++ b/lib/libdeinstall.sh
@@ -20,11 +20,11 @@ deinstall_select_leaf_ports_to_delete_dialog ()
2020 do
2121 pkgtag=`cat "${DBDIR}/moved_from/$origin/pkgtag" 2> /dev/null` || :
2222 val=on
23- grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off
23+ env LANG=C grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off
2424 printf '%s\t"(%s)"\t%s\n' "$origin" "$pkgtag" "$val"
2525 done < $src > $itemlist
2626 misc_dialog_checklist "$title" "$desc" "$dst_selected" "$itemlist"
27- grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || :
27+ env LANG=C grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || :
2828 }
2929
3030 # ============= Automatic selection of removing ports =============
@@ -41,11 +41,11 @@ deinstall_select_auto ()
4141 cat "$dst_add" "$dst_rem" 2> /dev/null | sort -u > $tmp_srcprev
4242 cat "$src" 2> /dev/null | sort -u > $tmp_srcnew
4343 fileedit_manipulate_old_new_lines "$tmp_srcprev" "$tmp_srcnew" "$diff_removed" "$diff_added" || return 0
44- grep -v -Fx -f "$diff_removed" "$dst_rem" 2> /dev/null | \
45- grep -Fx -f "$src" > $dst_rem.tmp || :
44+ env LANG=C grep -v -Fx -f "$diff_removed" "$dst_rem" 2> /dev/null | \
45+ env LANG=C grep -Fx -f "$src" > $dst_rem.tmp || :
4646 mv "$dst_rem.tmp" "$dst_rem"
4747 cat "$dst_add" "$diff_added" 2> /dev/null | sort -u | \
48- grep -Fx -f "$src" > $dst_add.tmp || :
48+ env LANG=C grep -Fx -f "$src" > $dst_add.tmp || :
4949 mv "$dst_add.tmp" "$dst_add"
5050 }
5151
@@ -109,11 +109,11 @@ deinstall_select_obsolete_ports_to_delete_dialog ()
109109 do
110110 pkgtag=`cat "${DBDIR}/initial/$origin/installed_version"`
111111 val=on
112- grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off
112+ env LANG=C grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off
113113 printf '%s\t"(%s)"\t%s\n' "$origin" "$pkgtag" "$val"
114114 done < $src > $itemlist
115115 misc_dialog_checklist "$title" "$desc" "$dst_selected" "$itemlist"
116- grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || :
116+ env LANG=C grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || :
117117 }
118118
119119 # ============= Selection of removing obsolete ports =============
@@ -217,7 +217,7 @@ deinstall_exec ()
217217 for origin in `{ echo "$origin_master"; database_query_initial_orgins "$origin_master"; } | sort -u`
218218 do
219219 origin_regexp=`str_escape_regexp "$origin"`
220- grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || :
220+ env LANG=C grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || :
221221 mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
222222 currentpkg=`pkgsys_get_installed_pkg_from_origin "$origin" | tr '\n' ' ' | sed 's/ *$//'`
223223 [ -n "$currentpkg" ] || continue
@@ -248,7 +248,7 @@ deinstall_exec ()
248248 backup_pkgdir=${PKGREPOSITORY}
249249 fi
250250 mkdir -p "$backup_pkgdir"
251- pkg=`echo "$currentpkg" | tr ' ' '\n' | grep -v '^$' | tail -n 1`
251+ pkg=`echo "$currentpkg" | tr ' ' '\n' | env LANG=C grep -v '^$' | tail -n 1`
252252 backup_pkg=`pkgsys_create_backup_pkg "$pkg" "$backup_pkgdir"` || :
253253 if [ -n "$backup_pkg" ]
254254 then
@@ -260,7 +260,7 @@ deinstall_exec ()
260260 fi
261261 fi
262262 message_echo "-- (Deleting package for $origin as $currentpkg)"
263- echo "$currentpkg" | tr ' ' '\n' | grep -v '^$' | while read pkg
263+ echo "$currentpkg" | tr ' ' '\n' | env LANG=C grep -v '^$' | while read pkg
264264 do
265265 if ! pkg_delete_f "$currentpkg"
266266 then
--- a/lib/libfileedit.sh
+++ b/lib/libfileedit.sh
@@ -15,7 +15,7 @@ fileedit_rm_a_line ()
1515 [ -n "$item" ] || return 0
1616 [ -e "$dstpath" ] || return 0
1717 tmpfile=$dstpath.fileedit_rm_a_line.tmp
18- grep -v -Fx "$item" "$dstpath" 2> /dev/null > $tmpfile || :
18+ env LANG=C grep -v -Fx "$item" "$dstpath" 2> /dev/null > $tmpfile || :
1919 mv "$tmpfile" "$dstpath"
2020 }
2121
@@ -31,7 +31,7 @@ fileedit_add_a_line_if_new ()
3131 if [ -e "$dstpath" ]
3232 then
3333 cp "$dstpath" "$tmpfile"
34- grep -q -Fx "$item" "$dstpath" \
34+ env LANG=C grep -q -Fx "$item" "$dstpath" \
3535 || echo "$item" >> $tmpfile
3636 else
3737 dstdir=`dirname "$dstpath"`
@@ -77,7 +77,7 @@ fileedit_add_lines_if_new ()
7777 then
7878 while read origin
7979 do
80- grep -q -Fx "$origin" "$dstpath" \
80+ env LANG=C grep -q -Fx "$origin" "$dstpath" \
8181 || echo "$origin"
8282 done > $tmpclip
8383 if [ "@$advance" = @advance ]
@@ -110,8 +110,8 @@ fileedit_manipulate_old_new_lines ()
110110 newdiff=$4
111111 [ -e "$oldsrc" ] || oldsrc=/dev/null
112112 [ -e "$newsrc" ] || newsrc=/dev/null
113- grep -vFx -f "$newsrc" "$oldsrc" > $olddiff 2> /dev/null || :
114- grep -vFx -f "$oldsrc" "$newsrc" > $newdiff 2> /dev/null || :
113+ env LANG=C grep -vFx -f "$newsrc" "$oldsrc" > $olddiff 2> /dev/null || :
114+ env LANG=C grep -vFx -f "$oldsrc" "$newsrc" > $newdiff 2> /dev/null || :
115115 [ `cat "$olddiff" "$newdiff" | wc -l` -gt 0 ]
116116 }
117117
@@ -123,7 +123,7 @@ fileedit_manipulate_old_lines ()
123123 newsrc=$2
124124 [ -e "$oldsrc" ] || oldsrc=/dev/null
125125 [ -e "$newsrc" ] || newsrc=/dev/null
126- grep -vFx -f "$newsrc" "$oldsrc" 2> /dev/null
126+ env LANG=C grep -vFx -f "$newsrc" "$oldsrc" 2> /dev/null
127127 }
128128
129129 # ============= Manipulate new lines from an old and a new versions of a file =============
@@ -134,7 +134,7 @@ fileedit_manipulate_new_lines ()
134134 newsrc=$2
135135 [ -e "$oldsrc" ] || oldsrc=/dev/null
136136 [ -e "$newsrc" ] || newsrc=/dev/null
137- grep -vFx -f "$oldsrc" "$newsrc" 2> /dev/null
137+ env LANG=C grep -vFx -f "$oldsrc" "$newsrc" 2> /dev/null
138138 }
139139
140140 # ============= Check whether removed lines exists in updating from an old and a new versions of a file =============
@@ -145,5 +145,5 @@ fileedit_exists_old_lines ()
145145 newsrc=$2
146146 [ -e "$oldsrc" ] || oldsrc=/dev/null
147147 [ -e "$newsrc" ] || newsrc=/dev/null
148- grep -qvFx -f "$newsrc" "$oldsrc" 2> /dev/null
148+ env LANG=C grep -qvFx -f "$newsrc" "$oldsrc" 2> /dev/null
149149 }
--- a/lib/libfs.sh
+++ b/lib/libfs.sh
@@ -152,14 +152,17 @@ fs_get_actual_mount_point_pattern ()
152152 # ============= Get mount info at the descendant directory levels required for builder chroot environment =============
153153 fs_get_descendant_mount_info ()
154154 {
155- local mountpoint mountpoint_real_regexp basedir
155+ local mountpoint mountpoint_real_regexp basedir basedir_ptn zpools_ptn ptns
156156 mountpoint=$1
157157 mountpoint_real_regexp=`fs_get_actual_mount_point_pattern "$mountpoint"` || return
158158 basedir=`fs_get_system_basedir`
159159 basedir_ptn=`str_escape_regexp "$basedir"`
160- df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp\/" | while read fs data
160+ zpools_ptn=`zpool list -H -o name | str_escape_regexp_filter | tr \\n '|' | sed 's/|$//'`
161+ ptns='/|<above>:'
162+ [ -z "$zpools_ptn" ] || ptns="$ptns|$zpools_ptn"
163+ df | sed 1d | env LANG=C grep -E "%[[:space:]]+$mountpoint_real_regexp\/" | while read fs data
161164 do
162- echo "$fs" | grep -q -e '^/' -e '^<above>:' && fs=normal
165+ echo "$fs" | env LANG=C grep -Eq "^$ptns" && fs=normal
163166 mp_abs=`echo "$data" | sed -E 's|.*%[[:space:]]+(/.+)$|\1|'`
164167 mp=`echo "$mp_abs" | sed -E "s|^$basedir_ptn||"`
165168 relative=`echo "$mp_abs" | sed -E "s|^$mountpoint_real_regexp||"`
@@ -186,7 +189,7 @@ fs_fix_unionfs_image_if_hidden ()
186189 needlepath_cur=$needlepath_next
187190 done
188191 [ -e "$needlepath" ] && return
189- if [ -n "$needlepath_lowest_exist" ] && df "$needlepath_lowest_exist" | sed 1d | grep -q '^<above>:'
192+ if [ -n "$needlepath_lowest_exist" ] && df "$needlepath_lowest_exist" | sed 1d | env LANG=C grep -q '^<above>:'
190193 then
191194 message_echo "ERROR: Failed to recover a lost mandatory file, probably due to the bug of unionfs: $needlepath" >&2
192195 mkdir -p "${DBDIR}/execflag"
@@ -206,19 +209,19 @@ fs_chk_mounted ()
206209 mountpoint=`str_regularize_df_path "$3"`
207210 target_ptn=`str_escape_regexp "$target"`
208211 mountpoint_real_regexp=`str_escape_regexp "$mountpoint"`
209- tmpsrc=`df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp$"`
212+ tmpsrc=`df | sed 1d | env LANG=C grep -E "%[[:space:]]+$mountpoint_real_regexp$"`
210213 case $type in
211214 nullfs )
212- echo "$tmpsrc" | grep -qE "^${target_ptn}[[:space:]]" && return
215+ echo "$tmpsrc" | env LANG=C grep -qE "^${target_ptn}[[:space:]]" && return
213216 ;;
214217 unionfs )
215- echo "$tmpsrc" | grep -qE "^<above>:${target_ptn}[[:space:]]" && return
218+ echo "$tmpsrc" | env LANG=C grep -qE "^<above>:${target_ptn}[[:space:]]" && return
216219 ;;
217220 devfs | fdescfs | procfs | linprocfs | tmpfs )
218- echo "$tmpsrc" | grep -q "^$type" && return
221+ echo "$tmpsrc" | env LANG=C grep -q "^$type" && return
219222 ;;
220223 *)
221- message_echo "ERROR: Unsupported fyle system [$type]" >&2
224+ message_echo "ERROR: Unsupported file system [$type]" >&2
222225 exit 1
223226 ;;
224227 esac
--- a/lib/libmain.sh
+++ b/lib/libmain.sh
@@ -13,7 +13,7 @@ main_set_version ()
1313 COMPATIBLE_VERSIONS='^(4\.[1]\.[0-9])$'
1414 # Template for development versions
1515 MYVERSION=4.1.0+toward_4.1.1_20211011024526
16- COMPATIBLE_VERSIONS='^(4\.[0-1]\.[0-9]]|4\.[0]\.[0]+(|\+toward_4\.[0-1]\.[0-9]+_[0-9]+))$'
16+ COMPATIBLE_VERSIONS='^(4\.[0-1]\.[0-9]]|4\.[0-1]\.[0]+(|\+toward_4\.[0-1]\.[0-9]+_[0-9]+))$'
1717 }
1818
1919 # ============= Parse options, arguments and control parameters =============
@@ -523,7 +523,7 @@ main_reflect_conf_changes ()
523523 if fileedit_manipulate_old_new_lines \
524524 "${DBDIR}/conf.prev/setenv.sh" "${DBDIR}/conf/setenv.sh" "$tmpfile_old" "$tmpfile_new"
525525 then
526- if grep -q -e ^LOCALBASE= -e ^LINUXBASE= -e ^PORTSDIR= "$tmpfile_old" "$tmpfile_new"
526+ if env LANG=C grep -q -e ^LOCALBASE= -e ^LINUXBASE= -e ^PORTSDIR= "$tmpfile_old" "$tmpfile_new"
527527 then
528528 message_echo "ERROR: Migration of the temporary database is unavailable because LOCALBASE, LINUXBASE or PORTSDIR was changed." >&2
529529 message_echo " ${APPNAME} clean" >&2
--- a/lib/libmisc.sh
+++ b/lib/libmisc.sh
@@ -56,7 +56,7 @@ misc_get_all_vardefs ()
5656 # ============= Initialize shell variable definitions =============
5757 misc_init_vardefs ()
5858 {
59- eval `misc_get_all_vardefs | grep -E '^[a-z_][a-zA-Z0-9_]+=' | sed 's/=.*//;s/^/unset /'`
59+ eval `misc_get_all_vardefs | env LANG=C grep -E '^[a-z_][a-zA-Z0-9_]+=' | sed 's/=.*//;s/^/unset /'`
6060 }
6161
6262 # ============= Get the size of the current console =============
--- a/lib/liboptions.sh
+++ b/lib/liboptions.sh
@@ -12,7 +12,7 @@ OPTIONS_SHIFT=0
1212
1313 # ============= Database of options which are given at each run and not saved =============
1414 # [Syntax of option databases]
15-# short_name, long_name, variable, defult_vaule, set_value
15+# short_name, long_name, variable, default_value, set_value
1616 # Columns are delimited by tab characters.
1717 options_db_onetime ()
1818 {
@@ -48,9 +48,44 @@ options_db_saved_and_non_renewable ()
4848 eof
4949 }
5050
51+
52+# ============= Definitions of value regulator functions =============
53+options_db_value_regulators ()
54+{
55+ cat << eof
56+eof
57+}
58+
5159 # ============= Regularize the option value =============
5260 options_regularize ()
5361 {
62+ local nlines iline srcline var fnc
63+ options_db_value_regulators > ${TMPDIR}/options_regularize::db
64+ nlines=`wc -l < ${TMPDIR}/options_regularize::db`
65+ iline=1
66+ while [ $iline -le $nlines ]
67+ do
68+ srcline=`sed -n ${iline}p "${TMPDIR}/options_regularize::db"`
69+ var=`echo "$srcline" | cut -f 1`
70+ fnc=`echo "$srcline" | cut -f 2`
71+ eval $var=\`$fnc \"\$$var\"\`
72+ iline=$(($iline+1))
73+ done
74+}
75+
76+# ============= Regularize a value of an option value =============
77+options_regularize_a_value ()
78+{
79+ local variable value fnc
80+ variable=$1
81+ value=$2
82+ fnc=`options_db_value_regulators | grep "^$variable[[:space:]]" | cut -f 2`
83+ if [ -n "$fnc" ]
84+ then
85+ eval $fnc "$value"
86+ else
87+ echo "$value"
88+ fi
5489 }
5590
5691 # ============= Database of all options to be saved =============
@@ -114,7 +149,7 @@ options_convert_shortname_to_varname ()
114149 {
115150 local shortname
116151 shortname=$1
117- options_db_all | grep -m 1 "^${shortname}[[:space:]]" | cut -f 3 | sort -u
152+ options_db_all | env LANG=C grep -m 1 "^${shortname}[[:space:]]" | cut -f 3 | sort -u
118153 }
119154
120155 # ============= Dump all command line arguments and options =============
@@ -144,7 +179,7 @@ options_set_default ()
144179 # ============= Get the argument for getopts =============
145180 options_getopts_arg ()
146181 {
147- options_db_all | cut -f 1,5 | grep -v '^[[:space:]]' | sort -u \
182+ options_db_all | cut -f 1,5 | env LANG=C grep -v '^[[:space:]]' | sort -u \
148183 | sed -E 's/[[:space:]]:$/:/;s/[[:space:]].*$//' | tr -d '\n'
149184 }
150185
@@ -157,7 +192,7 @@ options_getopts_only_short ()
157192 while getopts $getopts_option option > /dev/null
158193 do
159194 val=`str_escape_replaceval "$OPTARG"`
160- command=`options_db_all | grep -m 1 "^${option}[[:space:]]" \
195+ command=`options_db_all | env LANG=C grep -m 1 "^${option}[[:space:]]" \
161196 | cut -f 3,5 | sed -E 's/[[:space:]]/=/;s/:$/'$val'/' || :`
162197 [ -n "$command" ] || return 1
163198 echo -n "$command;OPTIND=$OPTIND;"
@@ -182,7 +217,7 @@ options_getopts ()
182217 [ $# -eq 0 ] && break
183218 erropt=$1
184219 option=`expr "x$1" : '^x--\([a-zA-Z0-9][a-zA-Z0-9-]*\).*'` || break
185- command=`options_db_all | cut -f 2,3,5 | grep -m 1 "^${option}[[:space:]]" \
220+ command=`options_db_all | cut -f 2,3,5 | env LANG=C grep -m 1 "^${option}[[:space:]]" \
186221 | cut -f 2,3 | sed -E 's/[[:space:]]/=/' || :`
187222 [ -n "$command" ] || break
188223 if expr "$command" : '^[^=]*=:$' > /dev/null
@@ -208,21 +243,23 @@ options_getopts ()
208243 # ============= Filter option value definitions to pick up selected groups =============
209244 options_filter ()
210245 {
211- grep `options_db "$@" | cut -f 3 | sed 's/^/-e ^/;s/$/=/'`
246+ env LANG=C grep `options_db "$@" | cut -f 3 | sed 's/^/-e ^/;s/$/=/'`
212247 }
213248
214249 # ============= Compose an option set in a command line form from the current settings =============
215250 options_inverse_parse ()
216251 {
217- options_db "$@" | while read short_name long_name variable defult_vaule set_value
252+ options_db "$@" | while read short_name long_name variable default_value set_value
218253 do
254+ eval default_value_eval=$default_value
255+ default_value_regular=`options_regularize_a_value "$variable" "$default_value_eval"`
219256 eval val=\$$variable
220- eval val_def=$defult_vaule
257+ eval val_def=\$default_value_regular
221258 eval val_set=$set_value
222259 if [ "x$set_value" = x: ]
223260 then
224261 [ "x$val" = "x$val_def" ] \
225- || misc_get_all_vardefs | grep -m 1 "^$variable=" \
262+ || misc_get_all_vardefs | env LANG=C grep -m 1 "^$variable=" \
226263 | sed "s/^[^=]*=/-$short_name /"
227264 elif [ "x$val" = "x$val_set" ]
228265 then
@@ -237,13 +274,15 @@ options_filter_configured ()
237274 {
238275 local tmpptn
239276 tmpptn=${TMPDIR}/options_filter_configured:ptn
240- options_db "$@" | while read short_name long_name variable defult_vaule set_value
277+ options_db "$@" | while read short_name long_name variable default_value set_value
241278 do
279+ eval default_value_eval=$default_value
280+ default_value_regular=`options_regularize_a_value "$variable" "$default_value_eval"`
242281 eval val=\$$variable
243- eval val_def=$defult_vaule
282+ eval val_def=\$default_value_regular
244283 [ "x$val" = "x$val_def" ] || echo "^$variable="
245284 done > $tmpptn
246- grep -f "$tmpptn"
285+ env LANG=C grep -f "$tmpptn"
247286 }
248287
249288 # ============= Check inclusion of invalid options intending to be renewed =============
@@ -298,7 +337,7 @@ options_select_new_ports_if_duplicated ()
298337 itemlist=${TMPDIR}/options_select_new_ports_if_duplicated::itemlist
299338 cp /dev/null "$dstfile.tmp"
300339 echo "$optargs" | sed -E 's/[ :]+/\
301-/g' | grep -v '^$' | sort -u > $globs_list
340+/g' | env LANG=C grep -v '^$' | sort -u > $globs_list
302341 nlines=`wc -l < $globs_list`
303342 iline=1
304343 while [ $iline -le $nlines ]
@@ -318,7 +357,7 @@ options_select_new_ports_if_duplicated ()
318357 do
319358 if pkgsys_exists_or_existed_from_orig "$origin" \
320359 || cat "${DBDIR}/installed_ports" "${DBDIR}/targets_specified_so_far" 2> /dev/null \
321- | grep -q -Fx "$origin"
360+ | env LANG=C grep -q -Fx "$origin"
322361 then
323362 echo "$origin" >> $tmp_existing_ports
324363 else
--- a/lib/libpkgsys.sh
+++ b/lib/libpkgsys.sh
@@ -229,7 +229,7 @@ pkgsys_fetch_legacy_remote ()
229229 pkg_regexp=`str_escape_regexp "$pkg"`
230230 pkgsys_ready_checksum_file || return
231231 checksumpath=`pkgsys_ready_checksum_file__fetched_file`
232- validMD5=`grep -m 1 -E -e "^MD5[[:space:]]*\($pkg_regexp\.tbz\)[[:space:]]*=" "$checksumpath" | sed -E "s/^[^=]*=[[:space:]]*(.*)/\1/"`
232+ validMD5=`env LANG=C grep -m 1 -E -e "^MD5[[:space:]]*\($pkg_regexp\.tbz\)[[:space:]]*=" "$checksumpath" | sed -E "s/^[^=]*=[[:space:]]*(.*)/\1/"`
233233 if [ -z "$validMD5" ]
234234 then
235235 message_echo "WARNING: No check sum for $pkg.tbz." >&2
@@ -297,7 +297,7 @@ pkgsys_is_dependency_of_a_legacypkg_latest ()
297297 rm -rf "$tmp_extract"
298298 mkdir "$tmp_extract"
299299 tar xf "$pkgarc" -C "$tmp_extract" +CONTENTS
300- grep -e '^@pkgdep[[:space:]]' -e '^@comment[[:space:]]*DEPORIGIN:' "$tmp_extract/+CONTENTS" \
300+ env LANG=C grep -e '^@pkgdep[[:space:]]' -e '^@comment[[:space:]]*DEPORIGIN:' "$tmp_extract/+CONTENTS" \
301301 | sed 's/^@pkgdep[[:space:]]*//;s/^@comment[[:space:]]*DEPORIGIN://' > $tmp_contents
302302 nlines=`wc -l < $tmp_contents`
303303 iline=1
@@ -442,7 +442,7 @@ pkgsys_def_pkgtools ()
442442 {
443443 local glob_unflavored
444444 glob_unflavored=$1
445- pkg query -g '%At\t%Av' "$glob_unflavored" 2> /dev/null | grep -E '^flavor[[:space:]]' | cut -f 2
445+ pkg query -g '%At\t%Av' "$glob_unflavored" 2> /dev/null | env LANG=C grep -E '^flavor[[:space:]]' | cut -f 2
446446 }
447447 pkg_info_flavored_origin ()
448448 {
@@ -457,9 +457,9 @@ pkgsys_def_pkgtools ()
457457 {
458458 local tmp_flavored tmp_flavored_ptn
459459 tmp_flavored_ptn=${TMPDIR}/pkg_info_all_flavored_origins:flavored_ptn
460- pkg query '%o\t%At\t%Av' 2> /dev/null | grep -E '^[^[:space:]]+[[:space:]]flavor[[:space:]]' | cut -f 1,3 | tr '\t' @ | sed 's/@$//'
461- pkg query '%n\t%At' 2> /dev/null | grep -E '^[^[:space:]]+[[:space:]]flavor$' | cut -f 1 > $tmp_flavored_ptn
462- pkg query '%n\t%o' 2> /dev/null | grep -vFx -f "$tmp_flavored_ptn" | cut -f 2
460+ pkg query '%o\t%At\t%Av' 2> /dev/null | env LANG=C grep -E '^[^[:space:]]+[[:space:]]flavor[[:space:]]' | cut -f 1,3 | tr '\t' @ | sed 's/@$//'
461+ pkg query '%n\t%At' 2> /dev/null | env LANG=C grep -E '^[^[:space:]]+[[:space:]]flavor$' | cut -f 1 > $tmp_flavored_ptn
462+ pkg query '%n\t%o' 2> /dev/null | env LANG=C grep -vFx -f "$tmp_flavored_ptn" | cut -f 2
463463 }
464464 pkg_check_sanity ()
465465 {
@@ -469,9 +469,9 @@ pkgsys_def_pkgtools ()
469469 tmp_stderr=${TMPDIR}/pkgng:pkg_check_sanity:stderr
470470 pkg check -s "$pkg" > $tmp_stdout 2> $tmp_stderr || :
471471 {
472- grep '^[^:]*: checksum mismatch for ' "$tmp_stderr" | sed 's/^[^:]*: checksum mismatch for //' || :
473- grep '^[^:]*: missing file ' "$tmp_stderr" | sed 's/^[^:]*: missing file //' || :
474- if grep -q '^pkg: .*: No such file or directory$' "$tmp_stderr" # For the old specification of pkg(8)
472+ env LANG=C grep '^[^:]*: checksum mismatch for ' "$tmp_stderr" | sed 's/^[^:]*: checksum mismatch for //' || :
473+ env LANG=C grep '^[^:]*: missing file ' "$tmp_stderr" | sed 's/^[^:]*: missing file //' || :
474+ if env LANG=C grep -q '^pkg: .*: No such file or directory$' "$tmp_stderr" # For the old specification of pkg(8)
475475 then
476476 pkg info -ql "$pkg" 2> /dev/null | while read filepath
477477 do
@@ -720,16 +720,16 @@ pkgsys_def_pkgtools ()
720720 PKGNG_AUTODEPS=NO
721721 PKGNG_PORTAUDIT_SITE='http=//portaudit.FreeBSD.org/auditfile.tbz'
722722 # Load configuration for pkg(1)
723- pkg_conf=`pkg query %Fp pkg 2> /dev/null | grep '/etc/pkg\.conf\.sample$' | sed 's/\.sample$//'` || :
723+ pkg_conf=`pkg query %Fp pkg 2> /dev/null | env LANG=C grep '/etc/pkg\.conf\.sample$' | sed 's/\.sample$//'` || :
724724 [ -n "$pkg_conf" ] || pkg_conf=${MYPREFIX}/etc/pkg.conf
725- grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "$pkg_conf" 2> /dev/null \
726- | grep -e '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*.*' \
725+ env LANG=C grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "$pkg_conf" 2> /dev/null \
726+ | env LANG=C grep -e '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*.*' \
727727 | while read srcline
728728 do
729729 var=`expr "$srcline" : '^[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*:.*'` || :
730730 val=`expr "$srcline" : '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*\(.*\)'` || :
731731 eval PKGNG_$var=\$val
732- misc_get_all_vardefs | grep "^PKGNG_$var="
732+ misc_get_all_vardefs | env LANG=C grep "^PKGNG_$var="
733733 done > ${TMPDIR}/pkgsys_def_pkgtools:pkg.conf.sh
734734 . "${TMPDIR}/pkgsys_def_pkgtools:pkg.conf.sh"
735735 }
@@ -746,10 +746,10 @@ pkgsys_def_pkgtools ()
746746 message_echo "INFO: Installing pkgng by legacy package tool."
747747 checksumpath=`pkgsys_ready_checksum_file__fetched_file`
748748 pkgname=`sed 's/^MD5[[:space:]]*(//;s/\.tbz)[[:space:]]*=[^=]*$//' "$checksumpath" \
749- | grep -m 1 '^pkg-[0-9]'` || :
749+ | env LANG=C grep -m 1 '^pkg-[0-9]'` || :
750750 [ -n "$pkgname" ] && pkg_inst_remote_wild "$pkgname" && return
751751 message_echo "INFO: Failed by package, so installing pkgng by port."
752- grep -Ev '^[[:space:]]*WITH_PKG(|NG)=' /etc/make.conf > ${TMPDIR}/make.conf 2> /dev/null || :
752+ env LANG=C grep -Ev '^[[:space:]]*WITH_PKG(|NG)=' /etc/make.conf > ${TMPDIR}/make.conf 2> /dev/null || :
753753 echo WITHOUT_PKG=yes >> ${TMPDIR}/make.conf
754754 echo WITHOUT_PKGNG=yes >> ${TMPDIR}/make.conf
755755 dev_out=/dev/stdout
@@ -851,7 +851,7 @@ pkgsys_def_pkgtools ()
851851 }
852852 pkg_info_qR ()
853853 {
854- pkg_info -qR "$@" 2> /dev/null | grep -v '^$'
854+ pkg_info -qR "$@" 2> /dev/null | env LANG=C grep -v '^$'
855855 }
856856 pkg_info_Ex ()
857857 {
@@ -1123,6 +1123,7 @@ pkgsys_get_installed_pkg_from_glob ()
11231123 local glob regexp
11241124 for glob in "$@"
11251125 do
1126+ [ -z "$glob" ] && continue
11261127 if regexp=`expr "$glob" : ':\(.*\)'`
11271128 then
11281129 pkg_info_Ex "$regexp"
@@ -1158,7 +1159,7 @@ pkgsys_exists_or_existed_from_orig ()
11581159 local origin
11591160 origin=$1
11601161 cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
1161- | grep -q -Fx "$origin" || pkgsys_exists_from_orig "$origin"
1162+ | env LANG=C grep -q -Fx "$origin" || pkgsys_exists_from_orig "$origin"
11621163 }
11631164
11641165 # ============= Get the name of an initially installed package for a flavored origin =============
@@ -1221,7 +1222,7 @@ pkgsys_init_pkg_orig_by_ambiguous_matching ()
12211222 while :
12221223 do
12231224 pkg_regexp=`str_escape_regexp "$pkg"`$ambsuffix
1224- grep -E "^${pkg_regexp}[[:space:]]" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
1225+ env LANG=C grep -E "^${pkg_regexp}[[:space:]]" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
12251226 | cut -f 2 > $tmporigin
12261227 norigins=`wc -l < $tmporigin`
12271228 [ $norigins -gt 0 ] && break
@@ -1298,23 +1299,23 @@ pkgsys_eval_ports_glob ()
12981299 glob_regexp_unflavored=`expr "$glob_regexp" : '\([^@]*\)' || :`$
12991300 glob_regexp_flavor=^`expr "$glob_regexp" : '[^@]*@\([^@]*\)' || :`
13001301
1301- grep -E "$glob_regexp_unflavored" "$unflavored_origlist" 2>&1 | while read origin_unflavored
1302+ env LANG=C grep -E "$glob_regexp_unflavored" "$unflavored_origlist" 2>&1 | while read origin_unflavored
13021303 do
13031304 fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored"
13041305 make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \
1305- tr '[:space:]' '\n' | grep -v '^$' | grep -E "$glob_regexp_flavor" | sed -E "s|^|$origin_unflavored@|"
1306+ tr '[:space:]' '\n' | env LANG=C grep -v '^$' | env LANG=C grep -E "$glob_regexp_flavor" | sed -E "s|^|$origin_unflavored@|"
13061307 done
13071308 {
13081309 pkg_info_all_flavored_origins
13091310 cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null
1310- } | grep -E "$glob_regexp" 2>&1 || :
1311+ } | env LANG=C grep -E "$glob_regexp" 2>&1 || :
13111312 else
1312- grep -E "$glob_regexp" "$unflavored_origlist" 2>&1 | while read origin_unflavored
1313+ env LANG=C grep -E "$glob_regexp" "$unflavored_origlist" 2>&1 | while read origin_unflavored
13131314 do
13141315 origin_unflavored_rpl=`str_escape_replaceval "$origin_unflavored"`
13151316 fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored"
13161317 make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \
1317- tr '[:space:]' '\n' | grep -v '^$' > $tmp_flavors || :
1318+ tr '[:space:]' '\n' | env LANG=C grep -v '^$' > $tmp_flavors || :
13181319 if [ `wc -l < $tmp_flavors` -gt 0 ]
13191320 then
13201321 sed -E "s|^|$origin_unflavored_rpl@|" "$tmp_flavors"
@@ -1327,7 +1328,7 @@ pkgsys_eval_ports_glob ()
13271328 {
13281329 pkg_info_all_flavored_origins
13291330 cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null
1330- } | grep -E "$glob_regexp_allflavors" 2>&1 || :
1331+ } | env LANG=C grep -E "$glob_regexp_allflavors" 2>&1 || :
13311332 else
13321333 if expr "$glob" : '[a-z][a-zA-Z0-9_.+-]*[a-zA-Z0-9_.+]$' > /dev/null 2>&1 && \
13331334 [ `expr "$glob" : '.*-[0-9]' 2>&1` -eq 0 ]
@@ -1336,7 +1337,7 @@ pkgsys_eval_ports_glob ()
13361337 else
13371338 glob_regexp2=$glob_regexp
13381339 fi
1339- grep -n -E "$glob_regexp2" "$pkglist" 2>&1 | cut -d : -f 1 \
1340+ env LANG=C grep -n -E "$glob_regexp2" "$pkglist" 2>&1 | cut -d : -f 1 \
13401341 | while read index
13411342 do
13421343 sed -n ${index}p "$unflavored_origlist"
@@ -1345,7 +1346,7 @@ pkgsys_eval_ports_glob ()
13451346 origin_unflavored_rpl=`str_escape_replaceval "$origin_unflavored"`
13461347 fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored"
13471348 make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \
1348- tr '[:space:]' '\n' | grep -v '^$' > $tmp_flavors || :
1349+ tr '[:space:]' '\n' | env LANG=C grep -v '^$' > $tmp_flavors || :
13491350 [ `wc -l < $tmp_flavors` -gt 0 ] || echo > $tmp_flavors
13501351 sed -E "s/^/$origin_unflavored_rpl /" "$tmp_flavors"
13511352 done | while read origin_unflavored flavor
@@ -1353,20 +1354,20 @@ pkgsys_eval_ports_glob ()
13531354 if [ -n "$flavor" ]
13541355 then
13551356 if make -C "${PORTSDIR}/$origin_unflavored" package-name FLAVOR=$flavor 2> /dev/null | \
1356- grep -qE "$glob_regexp2"
1357+ env LANG=C grep -qE "$glob_regexp2"
13571358 then
13581359 echo "$origin_unflavored@$flavor"
13591360 fi
13601361 else
13611362 if make -C "${PORTSDIR}/$origin_unflavored" package-name 2> /dev/null | \
1362- grep -qE "$glob_regexp2"
1363+ env LANG=C grep -qE "$glob_regexp2"
13631364 then
13641365 echo "$origin_unflavored"
13651366 fi
13661367 fi
13671368 done || :
13681369 glob_regexp2=`echo "$glob_regexp" | sed -E 's/\$*$//' 2>&1 || :`'[[:space:]]'
1369- grep -E "$glob_regexp2" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
1370+ env LANG=C grep -E "$glob_regexp2" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
13701371 | cut -f 2 || :
13711372 pkg_info_Ex "$glob_regexp" | while read pkgname
13721373 do
@@ -1396,7 +1397,7 @@ pkgsys_create_backup_pkg ()
13961397 then
13971398 pkgname_ptn=`str_escape_regexp "$pkgname"`
13981399 backup_pkg=`ls "${TMPDIR}"/package.tmp | \
1399- grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || :
1400+ env LANG=C grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || :
14001401 fi
14011402 if [ -z "$backup_pkg" ]
14021403 then
@@ -1431,12 +1432,12 @@ pkgsys_delete_backup_pkg ()
14311432 local origin origin_regexp
14321433 origin=$1
14331434 origin_regexp=`str_escape_regexp "$origin"`
1434- grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \
1435+ env LANG=C grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \
14351436 | cut -f 2 | while read pkgpath_cur
14361437 do
14371438 rm -f "$pkgpath_cur"
14381439 done
1439- grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" \
1440+ env LANG=C grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" \
14401441 2> /dev/null > ${DBDIR}/backup_pkgarcs.lst.tmp || :
14411442 mv "${DBDIR}/backup_pkgarcs.lst.tmp" "${DBDIR}/backup_pkgarcs.lst"
14421443 }
@@ -1449,7 +1450,7 @@ pkgsys_get_backup_pkg ()
14491450 tmpnewest=${TMPDIR}/pkgsys_get_backup_pkg::newest
14501451 origin_regexp=`str_escape_regexp "$origin"`
14511452 rm -f "$tmpnewest"
1452- grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \
1453+ env LANG=C grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \
14531454 | cut -f 2 | while read pkgpath
14541455 do
14551456 pkgpath_newest=`cat "$tmpnewest" 2> /dev/null` || :
@@ -1475,7 +1476,7 @@ pkgsys_chk_match_to_restored_files_by_backup_pkg ()
14751476 origin=$1
14761477 filelist=$2
14771478 dbfile=${DBDIR}/backup/$origin/previously_installed_files
1478- grep -qFx -f "$filelist" "$dbfile" 2> /dev/null
1479+ env LANG=C grep -qFx -f "$filelist" "$dbfile" 2> /dev/null
14791480 }
14801481
14811482 # ============= Get a package name from a package archive file name =============
@@ -1497,7 +1498,7 @@ pkgsys_pkgname_to_pkgarc ()
14971498 if [ "x$PKGSYS_USE_PKGNG" = xyes ]
14981499 then
14991500 pkgname_ptn=`str_escape_regexp "$pkgname"`
1500- pkgnode=`ls "$pkgdir" 2> /dev/null | grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || :
1501+ pkgnode=`ls "$pkgdir" 2> /dev/null | env LANG=C grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || :
15011502 elif [ -e "$pkgdir/$pkgname.tbz" ]
15021503 then
15031504 pkgnode=$pkgname.tbz
@@ -1513,8 +1514,8 @@ pkgsys_eval_ports_glob_even_if_nonexistent ()
15131514 glob_pattern=$1
15141515 {
15151516 pkgsys_eval_ports_glob "$glob_pattern" 2> /dev/null || :
1516- echo "$glob_pattern" | grep -E '^[a-z]+/[a-zA-Z0-9_.+-]+(|@[a-zA-Z0-9_.+-]+)$' || :
1517- } | grep -v -e '^$' | sort -u
1517+ echo "$glob_pattern" | env LANG=C grep -E '^[a-z]+/[a-zA-Z0-9_.+-]+(|@[a-zA-Z0-9_.+-]+)$' || :
1518+ } | env LANG=C grep -v -e '^$' | sort -u
15181519 }
15191520
15201521 # ============= Evaluate glob patterns and add/remove non-existing/existing ones of them to/from a file =============
@@ -1527,7 +1528,7 @@ pkgsys_register_evaluated_globs ()
15271528 dirpath=`dirname "$listpath"`
15281529 tmp_evaluated=${TMPDIR}/pkgsys_register_evaluated_globs:pkgsys_eval_ports_glob
15291530 echo "$@" | sed -E 's/[ :]+/\
1530-/g' | grep -v '^$' | sort -u | while read -r glob
1531+/g' | env LANG=C grep -v '^$' | sort -u | while read -r glob
15311532 do
15321533 pkgsys_eval_ports_glob "$glob" > $tmp_evaluated
15331534 [ `wc -l < $tmp_evaluated` -ge 1 ] || \
@@ -1583,7 +1584,7 @@ pkgsys_get_conflicting_pkgs_patterns ()
15831584 conflicts_config=
15841585 ;;
15851586 esac
1586- echo "$conflicts $conflicts_makevar $conflicts_config" | tr ' ' '\n' | grep -v '^$' | sort -u
1587+ echo "$conflicts $conflicts_makevar $conflicts_config" | tr ' ' '\n' | env LANG=C grep -v '^$' | sort -u
15871588 }
15881589
15891590 # ============= Get conflicting installed packages of a port =============
@@ -1611,7 +1612,7 @@ pkgsys_chk_conflict_by_a_pkg ()
16111612 tmp_conflicts_ptn=${TMPDIR}/pkgsys_chk_conflict_by_a_pkg::conflicts_ptn
16121613 pkgsys_get_conflicting_pkgs_patterns "$mode" "$origin" \
16131614 | str_convert_glob_to_regexp_pattern > $tmp_conflicts_ptn
1614- echo "$pkg" | grep -q -E -f "$tmp_conflicts_ptn"
1615+ echo "$pkg" | env LANG=C grep -q -E -f "$tmp_conflicts_ptn"
16151616 }
16161617
16171618 # ============= Check whether installed files are lost or broken for a package =============
@@ -1642,7 +1643,7 @@ pkgsys_sanitychk_pkgcontents ()
16421643 break
16431644 fi
16441645 filename_esc=`str_escape_regexp "$filename"`
1645- if file "$filename" | sed -E "s/^$filename_esc:[[:space:]]//" | grep -q '^ELF '
1646+ if file "$filename" | sed -E "s/^$filename_esc:[[:space:]]//" | env LANG=C grep -q '^ELF '
16461647 then
16471648 _is_reinstall_encouraged=yes
16481649 break
@@ -1683,7 +1684,7 @@ pkgsys_get_current_port_oprions_timestamp ()
16831684 {
16841685 ls -lD %Y%m%d:%H%M%S "${PORT_DBDIR}" | if [ -n "$portdb_needle_regexp" ]
16851686 then
1686- grep -E "[[:space:]]$portdb_needle_regexp$" || :
1687+ env LANG=C grep -E "[[:space:]]$portdb_needle_regexp$" || :
16871688 else
16881689 cat
16891690 fi
@@ -1743,12 +1744,12 @@ pkgsys_get_changed_port_oprions ()
17431744 current_log=$2
17441745 tmp_log=${TMPDIR}/pkgsys_get_changed_port_oprions.log
17451746 {
1746- grep -vxF -f "$current_log" "$saved_log" || :
1747- grep -vxF -f "$saved_log" "$current_log" || :
1748- } | cut -w -f 1 | grep -v '^$' | sort -u > $tmp_log
1747+ env LANG=C grep -vxF -f "$current_log" "$saved_log" || :
1748+ env LANG=C grep -vxF -f "$saved_log" "$current_log" || :
1749+ } | cut -w -f 1 | env LANG=C grep -v '^$' | sort -u > $tmp_log
17491750 if pkgsys_is_dialog4ports_used
17501751 then
1751- grep '_' "$tmp_log" || :
1752+ env LANG=C grep '_' "$tmp_log" || :
17521753 else
17531754 cat "$tmp_log"
17541755 fi
--- a/lib/libprogram.sh
+++ b/lib/libprogram.sh
@@ -174,7 +174,7 @@ program_exec_restartable_loop_operation ()
174174 iline=$(($iline+1))
175175 PROGRAM_STEP_PROGRESS=$(($PROGRAM_STEP_PROGRESS+1))
176176 PROGRAM_STEP_COUNTER="[$PROGRAM_STEP_PROGRESS/$PROGRAM_NUM_STEPS $(($PROGRAM_STEP_PROGRESS*100/$PROGRAM_NUM_STEPS))%]"
177- if ! grep -q -Fx "$item" "$looplist.remain" 2> /dev/null
177+ if ! env LANG=C grep -q -Fx "$item" "$looplist.remain" 2> /dev/null
178178 then
179179 [ $iline -gt $nlines ] && PROGRAM_STEP_COUNTER_LAST_SKIPPED=yes
180180 continue
--- a/lib/libreinstall.sh
+++ b/lib/libreinstall.sh
@@ -25,23 +25,23 @@ reinstall_skip ()
2525 message_target_relations "$REINSTALL_ORIGIN"
2626 }
2727
28-# ============= Check whether a package is forbidden due to conflict =============
28+# ============= Check whether a package is forbidden due to conflict (only by referring to the record) =============
2929 reinstall_quick_chk_forbidden_conflicts ()
3030 {
3131 local pkg pkg_regexp_esc
3232 pkg=$1
3333 pkg_regexp_esc=`str_escape_regexp "$pkg"`
34- grep -qE "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" 2> /dev/null
34+ env LANG=C grep -qE "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" 2> /dev/null
3535 }
3636
37-# ============= Check whether a package is forbidden due to conflict =============
37+# ============= Check whether a package is forbidden due to conflict (referring to both the record and the actual installation) =============
3838 reinstall_chk_forbidden_conflicts ()
3939 {
4040 local pkg tmp_forbidden pkg_regexp_esc
4141 pkg=$1
4242 tmp_forbidden=${TMPDIR}/reinstall_chk_forbidden_conflicts:forbidden
4343 pkg_regexp_esc=`str_escape_regexp "$pkg"`
44- grep -E "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" > $tmp_forbidden 2> /dev/null || return
44+ env LANG=C grep -E "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" > $tmp_forbidden 2> /dev/null || return
4545 pkg_info_e `cut -d : -f 3 "$tmp_forbidden"`
4646 }
4747
@@ -97,7 +97,12 @@ reinstall_skip_if_in_a_list ()
9797 message=$1
9898 list=$2
9999 mode=$3
100- grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/$list" 2> /dev/null || return
100+ env LANG=C grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/$list" 2> /dev/null || return
101+ REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"`
102+ if [ -n "$REINSTALL_ORIGIN_equiv" ]
103+ then
104+ env LANG=C grep -q -Fx "$REINSTALL_ORIGIN_equiv" "${DBDIR}/$list" 2> /dev/null || return
105+ fi
101106 [ "x$mode" = xrestore ] && reinstall_restore_if_temporarily_deinstalled
102107 reinstall_skip "$message" || :
103108 }
@@ -240,13 +245,15 @@ reinstall_deregister_stage_complete ()
240245 # Package names of conflict are given via stdin.
241246 reinstall_backup_and_delete_conflicts ()
242247 {
243- local pkg origin origin_regexp_esc backup_pkgdir backup_pkg
248+ local pkg origin origin_equiv origin_regexp_esc origin_equiv_regexp_esc backup_pkgdir backup_pkg
244249 message_echo "INFO: Deinstalling conflicting packages for $REINSTALL_ORIGPKGTAG."
245250 while read pkg
246251 do
247252 origin=`pkg_info_flavored_origin "$pkg"`
253+ origin_equiv=`database_query_get_equivalent_orgin "$origin"`
248254 message_echo "INFO: Backing up and deleting a conflict, $origin ($pkg)."
249255 origin_regexp_esc=`str_escape_regexp "$origin"`
256+ origin_equiv_regexp_esc=`str_escape_regexp "$origin_equiv"`
250257 if [ -d "${DBDIR}/requires/$origin" ]
251258 then
252259 backup_pkgdir=${DBDIR}/backup_packages
@@ -254,7 +261,7 @@ reinstall_backup_and_delete_conflicts ()
254261 backup_pkgdir=${PKGREPOSITORY}
255262 fi
256263 mkdir -p "$backup_pkgdir"
257- if backup_pkg=`pkgsys_get_backup_pkg "$origin"`
264+ if backup_pkg=`pkgsys_get_backup_pkg "$origin"` || backup_pkg=`pkgsys_get_backup_pkg "$origin_equiv"`
258265 then
259266 message_echo "INFO: backup package already exists as $backup_pkg"
260267 elif ! backup_pkg=`pkgsys_create_backup_pkg "$pkg" "$backup_pkgdir"`
@@ -262,9 +269,16 @@ reinstall_backup_and_delete_conflicts ()
262269 message_echo "WARNING: Failed to create the backup package, the conflict is kept installed." >&2
263270 continue
264271 fi
265- grep -v -E "^${origin_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts" \
272+ env LANG=C grep -v -E "^${origin_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts" \
266273 > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || :
274+ if [ -n "$origin_equiv_regexp_esc" ]
275+ then
276+ env LANG=C grep -v -E "^${origin_equiv_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts.tmp" \
277+ > ${DBDIR}/deleted_conflicts.tmp2 2> /dev/null || :
278+ mv "${DBDIR}/deleted_conflicts.tmp2" "${DBDIR}/deleted_conflicts.tmp"
279+ fi
267280 printf '%s\t%s\n' "$origin" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp
281+ [ -n "$origin_equiv" ] && printf '%s\t%s\n' "$origin_equiv" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp
268282 mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
269283 pkg_delete_f "$pkg" || \
270284 {
@@ -294,13 +308,14 @@ reinstall_backup_and_delete_remaining_install_conflicts__by_pkg ()
294308 # ============= Back up and delete remaining actual install conflict (for installation by port) =============
295309 reinstall_backup_and_delete_remaining_install_conflicts ()
296310 {
297- local stagedir tmp_conflicts db_conflict
311+ local stagedir tmp_conflicts db_conflict REINSTALL_ORIGIN_equiv
298312 tmp_conflicts=${TMPDIR}/reinstall_backup_and_delete_remaining_install_conflicts
299313 db_conflict=$REINSTALL_DBNODE_DIR/possible_additional_conflict.csv
300314 message_echo "(Checking installation conflict...)"
301315 rm -rf "$db_conflict.tmp" "$tmp_conflicts".*
302316 stagedir=`database_query_get_makevar_val "$REINSTALL_ORIGIN" STAGEDIR`
303317 pkgsys_get_conflicting_installed_pkgs install "$REINSTALL_ORIGIN" > $tmp_conflicts.pkgs || :
318+ REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"`
304319 ( set -e
305320 cd "$stagedir"
306321 find . -not -type d
@@ -309,9 +324,12 @@ reinstall_backup_and_delete_remaining_install_conflicts ()
309324 [ ! -e "$filepath" ] && continue
310325 pkg=`pkg_which "$filepath" || :`
311326 [ -z "$pkg" ] && continue
312- grep -qFx "$pkg" "$tmp_conflicts.pkgs" && continue
327+ env LANG=C grep -qFx "$pkg" "$tmp_conflicts.pkgs" && continue
313328 origin=`pkg_info_flavored_origin "$pkg"`
314329 [ x"$origin" = x"$REINSTALL_ORIGIN" ] && continue
330+ [ x"$origin" = x"$REINSTALL_ORIGIN_equiv" ] && continue
331+ origin_equiv=`database_query_get_equivalent_orgin "$origin"`
332+ [ x"$origin_equiv" = x"$REINSTALL_ORIGIN" ] && continue
315333 printf '%s\t%s\n' "$pkg" "$filepath" >> $db_conflict.tmp
316334 done
317335 if [ -e "$db_conflict.tmp" ]
@@ -363,9 +381,9 @@ reinstall_remove_needless_possible_conflict ()
363381 cut -f 1 "$db_conflict" | sort -u > $tmp_db.conflict_pkg.old
364382 cut -f 1 "$db_conflict.tmp" | sort -u > $tmp_db.conflict_pkg.new
365383 suffix=`echo ":$REINSTALL_ORIGIN:$REINSTALL_NEWPKGNAME" | str_escape_replaceval_filter`
366- grep -vFx -f "$tmp_db.conflict_pkg.new" "$tmp_db.conflict_pkg.old" | \
384+ env LANG=C grep -vFx -f "$tmp_db.conflict_pkg.new" "$tmp_db.conflict_pkg.old" | \
367385 sed -E "s/$/$suffix/" > $tmp_db.conflict_pkg.needless.filter
368- grep -vFx -f "$tmp_db.conflict_pkg.needless.filter" "$db_forbidden" > $db_forbidden.tmp || :
386+ env LANG=C grep -vFx -f "$tmp_db.conflict_pkg.needless.filter" "$db_forbidden" > $db_forbidden.tmp || :
369387 mv "$db_forbidden.tmp" "$db_forbidden"
370388 mv "$db_conflict.tmp" "$db_conflict"
371389 [ `wc -l < $db_conflict` -gt 0 ] || rm "$db_conflict"
@@ -374,21 +392,24 @@ reinstall_remove_needless_possible_conflict ()
374392 # ============= Restoration of backed up conflict =============
375393 reinstall_restore_conflicts ()
376394 {
377- local origin_current tmpsrc
395+ local origin_current tmpsrc origin_current_equiv
378396 origin_current=$1
379397 [ $opt_fetch_only = no -a $opt_dry_run = no ] || return 0
380398 [ -e "${DBDIR}/deleted_conflicts" ] || return 0
381399 tmpsrc=${TMPDIR}/reinstall_restore_conflicts::deleted_conflicts
382400 cp "${DBDIR}/deleted_conflicts" "$tmpsrc"
401+ origin_current_equiv=`database_query_get_equivalent_orgin "$origin_current"`
383402 while read origin pkg
384403 do
385404 pkg_regexp_esc=`str_escape_regexp "$pkg"`
386- origins_init=`database_query_initial_orgins "$origin" | grep -vFx "$origin" || :`
405+ origins_init=`database_query_initial_orgins "$origin" | env LANG=C grep -vFx "$origin" || :`
387406 origin_replace=`echo "$origin" \
388407 | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"`
389408 [ "x$origin_replace" = "x$origin" ] && origin_replace=
390409 is_to_dereg_from_list=no
391- if [ -n "$origin_current" -a "x$origin" = "x$origin_current" ] || \
410+ origin_equiv=`database_query_get_equivalent_orgin "$origin"`
411+ if [ -n "$origin" -a \( "x$origin" = "x$origin_current" -o "x$origin" = "x$origin_current_equiv" \) ] || \
412+ [ -n "$origin_equiv" -a "x$origin_equiv" = "x$origin_current" ] || \
392413 pkg_info_e "$pkg" || pkgsys_exists_from_orig "$origin"
393414 then
394415 is_to_dereg_from_list=yes
@@ -420,7 +441,7 @@ reinstall_restore_conflicts ()
420441 then
421442 pkg_current=
422443 origin_current=
423- for origin_trial in $origin $origins_init $origin_replace
444+ for origin_trial in $origin $origin_equiv $origins_init $origin_replace
424445 do
425446 pkg_trial=`pkgsys_get_installed_pkg_from_origin "$origin_trial" || :`
426447 [ -z "$pkg_trial" ] && continue
@@ -432,33 +453,33 @@ reinstall_restore_conflicts ()
432453 pkgname_msg=$pkg
433454 origin_msg=$origin
434455 [ "x$pkg_current" = "x$pkg" ] || pkgname_msg="$pkg => $pkg_current"
435- [ "x$origin_current" = "x$origin" ] || origin_msg="$origin => $origin_current"
456+ [ "x$origin_current" = "x$origin" -o "x$origin_current" = "x$origin_equiv" ] || origin_msg="$origin => $origin_current"
436457 if [ $is_skipped = yes ]
437458 then
438459 message_echo "WARNING: Conflicting package is installed: $origin_msg ($pkgname_msg)"
439460 else
440461 message_echo "INFO: $origin_msg ($pkgname_msg) is already restored."
441- grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \
462+ env LANG=C grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \
442463 > ${DBDIR}/deleted_conflicts.tmp || :
443464 mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
444465 fi
445466 continue
446467 fi
447468 [ $is_skipped = yes ] && continue
448- if grep -q -Fx -e "$origin" -e "$origin_replace" "${DBDIR}/taboo.all.list" 2> /dev/null
469+ if env LANG=C grep -q -Fx -e "$origin" -e "$origin_equiv" -e "$origin_replace" "${DBDIR}/taboo.all.list" 2> /dev/null
449470 then
450471 message_echo "INFO: Restoration of a conflict, $origin ($pkg), is avoided because it is taboo."
451472 continue
452473 fi
453474 message_echo "INFO: Restoring a former conflict, $origin ($pkg)."
454- if ! backup_pkg=`pkgsys_get_backup_pkg "$origin"`
475+ if ! backup_pkg=`pkgsys_get_backup_pkg "$origin"` || ! backup_pkg=`pkgsys_get_backup_pkg "$origin_equiv"`
455476 then
456477 message_echo "WARNING: No backup exists, gave up." >&2
457478 continue
458479 fi
459480 if pkg_add_fF "$backup_pkg"
460481 then
461- grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \
482+ env LANG=C grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \
462483 > ${DBDIR}/deleted_conflicts.tmp || :
463484 mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
464485 else
@@ -473,7 +494,14 @@ reinstall_are_requirements_ready ()
473494 [ -e "$REINSTALL_DBNODE_DIR/requirements.all.direct" ] || return 0
474495 while read origin
475496 do
476- pkgsys_exists_from_orig "$origin" || return 1
497+ if ! pkgsys_exists_from_orig "$origin"
498+ then
499+ origin_equiv=`database_query_get_equivalent_orgin "$origin"`
500+ if [ -n "$origin_equiv" ] && ! pkgsys_exists_from_orig "$origin_equiv"
501+ then
502+ return 1
503+ fi
504+ fi
477505 done < $REINSTALL_DBNODE_DIR/requirements.all.direct
478506 }
479507
@@ -489,18 +517,30 @@ reinstall_chk_and_restore_requirements ()
489517 | while read origin
490518 do
491519 pkgsys_exists_from_orig "$origin" && continue
492- if grep -q -Fx "$origin" "${DBDIR}/taboo.all.list" 2> /dev/null
520+ origin_equiv=`database_query_get_equivalent_orgin "$origin"`
521+ pkgsys_exists_from_orig "$origin_equiv" && continue
522+ if env LANG=C grep -q -Fx "$origin" "${DBDIR}/taboo.all.list" 2> /dev/null \
523+ || { [ -n "$origin_equiv" ] && env LANG=C grep -q -Fx "$origin_equiv" "${DBDIR}/taboo.all.list" 2> /dev/null; }
493524 then
494525 message_echo "INFO: Restoration of a requirement [$origin] is avoided because it is set taboo."
495526 touch "$tmp_isfailed"
496527 break
497528 fi
498- origins_init=`database_query_initial_orgins "$origin" | grep -vFx "$origin" || :`
529+ if [ -n "$origin_equiv" ]
530+ then
531+ origins_init=`{ database_query_initial_orgins "$origin"; database_query_initial_orgins "$origin_equiv"; } | env LANG=C grep -vFx -e "$origin" -e "$origin_equiv" || :`
532+ else
533+ origins_init=`{ database_query_initial_orgins "$origin"; } | env LANG=C grep -vFx "$origin" || :`
534+ fi
499535 origin_replace=`echo "$origin" \
500536 | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"`
537+ origin_equiv_replace=`echo "$origin_equiv" \
538+ | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"`
501539 [ "x$origin_replace" = "x$origin" ] && origin_replace=
540+ [ "x$origin_equiv_replace" = "x$origin_equiv" ] && origin_equiv_replace=
541+ [ -n "$origin_replace" ] || origin_replace=$origin_equiv_replace
502542 is_installed=no
503- for origin_orig in $origins_init $origin_replace
543+ for origin_orig in $origins_init $origin_replace $origin_equiv_replace
504544 do
505545 [ "x$origin_orig" = "x$origin" ] && continue
506546 if pkgsys_exists_from_orig "$origin_orig"
@@ -508,7 +548,7 @@ reinstall_chk_and_restore_requirements ()
508548 is_installed=yes
509549 break
510550 fi
511- if grep -q -Fx "$origin_orig" "${DBDIR}/taboo.all.list" 2> /dev/null
551+ if env LANG=C grep -q -Fx "$origin_orig" "${DBDIR}/taboo.all.list" 2> /dev/null
512552 then
513553 message_echo "INFO: Restoration of a requirement [$origin_orig] is avoided because it is set taboo."
514554 touch "$tmp_isfailed"
@@ -518,13 +558,14 @@ reinstall_chk_and_restore_requirements ()
518558 done
519559 [ $is_installed = yes ] && continue
520560 [ $is_installed = taboo ] && break
521- for origin_orig in $origin $origins_init $origin_replace
561+ for origin_orig in $origin $origin_equiv $origins_init $origin_replace $origin_equiv_replace
522562 do
523563 pkgarc=`pkgsys_get_backup_pkg "$origin_orig"` && break
524564 done
525565 if [ -z "$pkgarc" ]
526566 then
527- if grep -q -Fx "$origin" "${DBDIR}/failed.list" 2> /dev/null
567+ if env LANG=C grep -q -Fx "$origin" "${DBDIR}/failed.list" 2> /dev/null || \
568+ { [ -n "$origin_equiv" ] && env LANG=C grep -q -Fx "$origin_equiv" "${DBDIR}/failed.list" 2> /dev/null; }
528569 then
529570 touch "$tmp_isfailed"
530571 break
@@ -546,7 +587,7 @@ reinstall_chk_and_restore_requirements ()
546587 message_echo "INFO: Restoring a backed-up requirement [$origin ($pkg)]."
547588 if pkg_add_fF "$pkgarc"
548589 then
549- grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \
590+ env LANG=C grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \
550591 > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || :
551592 mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
552593 else
@@ -562,7 +603,7 @@ reinstall_pkg_backup ()
562603 {
563604 local backup_pkg pkg
564605 reinstall_chk_stage_complete PKG_BACKUP && return
565- pkg=`echo "$REINSTALL_CURRENTPKG" | tr ' ' '\n' | grep -v '^$' | tail -n 1`
606+ pkg=`echo "$REINSTALL_CURRENTPKG" | tr ' ' '\n' | env LANG=C grep -v '^$' | tail -n 1`
566607 if [ -n "$pkg" ]
567608 then
568609 message_echo "-- (Creating temporary backup package for $REINSTALL_ORIGPKGTAG)"
@@ -581,7 +622,7 @@ reinstall_pkg_backup ()
581622 # ============= Deinstallation of the currently installed package =============
582623 reinstall_deinstall ()
583624 {
584- local tmp_installedpkg installed_pkgs dev_out dev_err
625+ local tmp_installedpkg REINSTALL_ORIGIN_equiv installed_pkgs dev_out dev_err
585626 dev_out=/dev/stdout
586627 dev_err=/dev/stderr
587628 if [ $opt_batch_mode = yes ]
@@ -593,7 +634,8 @@ reinstall_deinstall ()
593634 pkgsys_get_installed_pkg_from_origin "$REINSTALL_ORIGIN" > $tmp_installedpkg
594635 [ `wc -l < $tmp_installedpkg` -gt 0 ] || return 0
595636 installed_pkgs=`tr '\n' ' ' < $tmp_installedpkg | sed 's/ *$//'`
596- if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
637+ REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"`
638+ if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN" || pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN_equiv"
597639 then
598640 message_echo "INFO: Deinstalling $installed_pkgs by $PKGSYS_CMD_PKG_DELETE."
599641 pkg_delete_f $installed_pkgs || \
@@ -624,13 +666,15 @@ reinstall_deinstall_old_ports ()
624666 while read origin_old
625667 do
626668 pkgsys_get_installed_pkg_from_origin "$origin_old"
669+ origin_old_equiv=`database_query_get_equivalent_orgin "$origin_old"`
670+ pkgsys_get_installed_pkg_from_origin "$origin_old_equiv"
627671 done < $REINSTALL_FROMNODE_DIR/old_origs | reinstall_backup_and_delete_conflicts
628672 }
629673
630674 # ============= Recovery after failure of installation of the new package =============
631675 reinstall_failed_install_recover ()
632676 {
633- local backedup_version backup_pkg dev_out dev_err
677+ local backedup_version backup_pkg dev_out dev_err REINSTALL_ORIGIN_equiv
634678 dev_out=/dev/stdout
635679 dev_err=/dev/stderr
636680 if [ $opt_batch_mode = yes ]
@@ -647,7 +691,9 @@ reinstall_failed_install_recover ()
647691 message_echo "INFO: Trying to deinstall by ports to make sure (This may cause negligible warnings)."
648692 reinstall_make deinstall > $dev_out 2> $dev_err|| :
649693 backedup_version=`cat "$REINSTALL_FROMNODE_DIR/backedup_version" 2> /dev/null || :`
650- if grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/taboo.all.list" 2> /dev/null
694+ REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"`
695+ if env LANG=C grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/taboo.all.list" 2> /dev/null || \
696+ { [ -n "$REINSTALL_ORIGIN_equiv" ] && env LANG=C grep -q -Fx "$REINSTALL_ORIGIN_equiv" "${DBDIR}/taboo.all.list" 2> /dev/null; }
651697 then
652698 message_echo "INFO: Restoration of the backup of $backedup_version is avoided because it is taboo."
653699 elif [ -n "$backedup_version" ]
@@ -680,8 +726,10 @@ reinstall_failed_install_recover ()
680726 # ============= Report an installation success to the all dependents =============
681727 reinstall_tell_update_to_depandents ()
682728 {
683- local tag level dbsuffix
729+ local REINSTALL_ORIGIN_equiv tag level dbsuffix
684730 pkgsys_is_pkgtool "$REINSTALL_ORIGIN" && return
731+ REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"`
732+ pkgsys_is_pkgtool "$REINSTALL_ORIGIN_equiv" && return
685733 reinstall_chk_stage_complete TELL_UPDATE_TO_DEPANDENTSL && return
686734 for tag in all run build none
687735 do
@@ -695,6 +743,11 @@ reinstall_tell_update_to_depandents ()
695743 | sort -u \
696744 | while read origin_dependent
697745 do
746+ echo "$origin_dependent"
747+ origin_dependent_equiv=`database_query_get_equivalent_orgin "$origin_dependent"`
748+ [ -z "$origin_dependent_equiv" ] || echo "$origin_dependent_equiv"
749+ done | while read origin_dependent
750+ do
698751 [ -d "${DBDIR}/requires/$origin_dependent" ] || continue
699752 touch "${DBDIR}/requires/$origin_dependent/need_reinstall_due_to_upgraded_requirements.$dbsuffix"
700753 fileedit_rm_a_line "$origin_dependent" \
@@ -707,7 +760,7 @@ reinstall_tell_update_to_depandents ()
707760 reinstall_register_stage_complete TELL_UPDATE_TO_DEPANDENTS
708761 }
709762
710-# ============= Closing operations after an installation success =============
763+# ============= Closing operations after a successful installation =============
711764 reinstall_closing_operations_after_successful_install ()
712765 {
713766 local tag level
@@ -730,15 +783,17 @@ reinstall_closing_operations_after_successful_install ()
730783 } | sort -u | while read initial_orig
731784 do
732785 initial_orig_regexp=`str_escape_regexp "$initial_orig"`
733- grep -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" 2> /dev/null \
786+ initial_orig_equiv=`database_query_get_equivalent_orgin "$initial_orig"`
787+ initial_orig_equiv_regexp=`str_escape_regexp "$initial_orig_equiv"`
788+ env LANG=C grep -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" 2> /dev/null \
734789 | cut -f 2 | while read initial_pkg
735790 do
736791 pkg_regexp=`str_escape_regexp "$initial_pkg"`
737- grep -v -E "^${pkg_regexp}:" "${DBDIR}/forbidden_conflicts" \
792+ env LANG=C grep -v -E "^${pkg_regexp}:" "${DBDIR}/forbidden_conflicts" \
738793 > ${DBDIR}/forbidden_conflicts.tmp 2> /dev/null || :
739794 mv "${DBDIR}/forbidden_conflicts.tmp" "${DBDIR}/forbidden_conflicts"
740795 done
741- grep -v -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" \
796+ env LANG=C grep -v -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" \
742797 > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || :
743798 mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
744799 pkgsys_delete_backup_pkg "$initial_orig"
@@ -758,21 +813,21 @@ reinstall_fetch_missing_distfiles ()
758813 tmp_missing_fetch=${TMPDIR}/reinstall_fetch_missing_distfiles:missing_fetch.sh
759814 rm -rf "$tmp_fetch.pre"
760815 reinstall_make_anymode fetch-list 2> /dev/null > $tmp_fetch.src || return
761- grep '^SHA256[[:space:]]' "$port_path/distinfo" | \
816+ env LANG=C grep '^SHA256[[:space:]]' "$port_path/distinfo" | \
762817 sed -E 's/^SHA256[[:space:]]+\(([^)]*)\).*/\1/' | \
763818 while read relative_distfile_path
764819 do
765820 if ! { testhash=`( cd "${DISTDIR}" && sha256 "$relative_distfile_path" ) 2> /dev/null` && \
766- grep -qxF "$testhash" "$port_path/distinfo"; }
821+ env LANG=C grep -qxF "$testhash" "$port_path/distinfo"; }
767822 then
768823 relative_distfile_path_ptn=`str_escape_regexp "|| echo \"$relative_distfile_path\" not fetched; }"`
769- if grep -E "$relative_distfile_path_ptn$" "$tmp_fetch.src"
824+ if env LANG=C grep -E "$relative_distfile_path_ptn$" "$tmp_fetch.src"
770825 then
771826 subdir_distfile=`dirname "$relative_distfile_path"`
772827 [ "x$subdir_distfile" = x. ] || echo "mkdir -p \"${DISTDIR}/$subdir_distfile\"" >> $tmp_fetch.pre
773828 fi
774829 fi
775- done | grep -v '^[[:space:]]*$' > $tmp_fetch.main || :
830+ done | env LANG=C grep -v '^[[:space:]]*$' > $tmp_fetch.main || :
776831 [ -e "$tmp_fetch.pre" ] && sort -u "$tmp_fetch.pre"
777832 cat "$tmp_fetch.main"
778833 }
@@ -817,18 +872,23 @@ reinstall_execcmd_getstdout_errlog ()
817872 # Return status 0 for no problem about missing ports
818873 reinstall_chk_missing_requirement ()
819874 {
820- local tmp_filter tmp_miising
875+ local tmp_filter tmp_missing
821876 tmp_filter=${TMPDIR}/reinstall_chk_missing_requirement::requirements.all_but_test.unflavored
822- tmp_miising=${TMPDIR}/reinstall_chk_missing_requirement::missing_requirements
877+ tmp_missing=${TMPDIR}/reinstall_chk_missing_requirement::missing_requirements
823878 message_echo "Checking whether any required package is missing or too old..."
824879 sed 's/@.*//' "$REINSTALL_DBNODE_DIR/requirements.all.full" > $tmp_filter || :
825- if reinstall_make missing 2> /dev/null | grep -Fx -f "$tmp_filter" > $tmp_miising
880+ reinstall_make missing 2> /dev/null | env LANG=C grep -Fx -f "$tmp_filter" | while read missing_orig
881+ do
882+ missing_equiv=`database_query_get_equivalent_orgin "$missing_orig"`
883+ [ -n "$missing_equiv" ] && ! pkg_info_eO "$missing_equiv" && echo "$missing_orig"
884+ done > $tmp_missing
885+ if [ `wc -l < $tmp_missing` -gt 0 ]
826886 then
827887 message_echo "Found missing/too old requirements:"
828- message_cat < $tmp_miising
888+ message_cat < $tmp_missing
829889 {
830890 echo "Found missing/too old requirements:"
831- cat "$tmp_miising"
891+ cat "$tmp_missing"
832892 } > "$REINSTALL_DBNODE_DIR/error.log"
833893 reinstall_restore_conflicts "$REINSTALL_ORIGIN"
834894 reinstall_restore_if_temporarily_deinstalled
@@ -867,7 +927,7 @@ reinstall_exec_chk_skip ()
867927 if expr "$REINSTALL_CURRENTPKG" : '.* .*' > /dev/null
868928 then
869929 message_echo "WARNING: Multiple packages are registered for this port. Reinstallation is needed to fix it." >&2
870- elif grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/damaged_package" 2> /dev/null
930+ elif env LANG=C grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/damaged_package" 2> /dev/null
871931 then
872932 message_echo "WARNING: Installed files have invalid checksums for this port. Reinstallation is needed to fix it." >&2
873933 else
@@ -1201,7 +1261,7 @@ reinstall_exec_reinstall_freeze_if_necessary ()
12011261 # Return status 0 for no concern about freezing requirements
12021262 reinstall_exec_reinstall_avoid_if_any_unfrozen_requirements_exists ()
12031263 {
1204- if grep -qFx "$REINSTALL_DBNODE_DIR/requirements.all.full" "${DBDIR}/freeze.all.list" 2> /dev/null
1264+ if env LANG=C grep -qFx "$REINSTALL_DBNODE_DIR/requirements.all.full" "${DBDIR}/freeze.all.list" 2> /dev/null
12051265 then
12061266 reinstall_restore_conflicts
12071267 {
@@ -1354,9 +1414,10 @@ reinstall_exec_reinstall_chk_interactive_mode ()
13541414 # Return status 1 for error end
13551415 reinstall_exec_reinstall_build ()
13561416 {
1357- local flag_restarted_build build_args is_build_env_modified conflicts_install dev_out dev_err
1417+ local flag_restarted_build build_args is_build_env_modified conflicts_install dev_out dev_err REINSTALL_ORIGIN_equiv
13581418 dev_out=/dev/stdout
13591419 dev_err=/dev/stderr
1420+ REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"`
13601421 if [ $opt_batch_mode = yes ]
13611422 then
13621423 dev_out=/dev/null
@@ -1393,7 +1454,7 @@ reinstall_exec_reinstall_build ()
13931454 echo "$conflicts_install" | reinstall_backup_and_delete_conflicts
13941455 is_build_env_modified=yes
13951456 fi
1396- if pkgsys_exists_from_orig "$REINSTALL_ORIGIN"
1457+ if pkgsys_exists_from_orig "$REINSTALL_ORIGIN" "$REINSTALL_ORIGIN_equiv"
13971458 then
13981459 message_echo "INFO: The currently installed package for this port is deinstalled for retrial because it may have effects on build."
13991460 reinstall_pkg_backup || :
@@ -1472,13 +1533,14 @@ reinstall_exec_reinstall_stage ()
14721533 reinstall_deregister_stage in_stage
14731534 }
14741535
1475-# ============= Reinstallation of the current origin: Install process=============
1536+# ============= Reinstallation of the current origin: Install process =============
14761537 # Return status 1 for error end
14771538 reinstall_exec_reinstall_install ()
14781539 {
1479- local insttarget dev_out dev_err
1540+ local insttarget dev_out dev_err REINSTALL_ORIGIN_equiv
14801541 dev_out=/dev/stdout
14811542 dev_err=/dev/stderr
1543+ REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"`
14821544 if [ $opt_batch_mode = yes ]
14831545 then
14841546 dev_out=/dev/null
@@ -1579,9 +1641,10 @@ reinstall_exec_reinstall_install ()
15791641 | while read origin_bak pkgpath_bak
15801642 do
15811643 pkg_bak=`pkgsys_pkgarc_to_pkgname "$pkgpath_bak"`
1582- if [ "$origin_bak" = "$REINSTALL_ORIGIN" ]
1644+ origin_bak_equiv=`database_query_get_equivalent_orgin "$origin_bak"`
1645+ if [ "x$origin_bak" = "x$REINSTALL_ORIGIN" -o "x$origin_bak_equiv" = "x$REINSTALL_ORIGIN" -o "x$origin_bak" = "x$REINSTALL_ORIGIN_equiv" ]
15831646 then
1584- [ "$pkg_bak" = "$REINSTALL_NEWPKGNAME" ] && continue
1647+ [ "x$pkg_bak" = "x$REINSTALL_NEWPKGNAME" ] && continue
15851648 elif reinstall_quick_chk_forbidden_conflicts "$pkg_bak"
15861649 then
15871650 continue
@@ -1703,7 +1766,7 @@ reinstall_exec ()
17031766 REINSTALL_DBSUFFIX=`options_get_dependency_type`.`options_get_dependency_level`
17041767 REINSTALL_NEWPKGNAME=`database_build_get_new_pkgname "$REINSTALL_ORIGIN"`
17051768 REINSTALL_IS_FROZEN=no
1706- grep -qFx "$REINSTALL_ORIGIN" "${DBDIR}/freeze.all.list" 2> /dev/null && REINSTALL_IS_FROZEN=yes
1769+ env LANG=C grep -qFx "$REINSTALL_ORIGIN" "${DBDIR}/freeze.all.list" 2> /dev/null && REINSTALL_IS_FROZEN=yes
17071770 message_stage_title "$PROGRAM_STEP_COUNTER $REINSTALL_ORIGPKGTAG"
17081771 reinstall_exec_chk_skip && reinstall_exec_reinstall || :
17091772 message_echo
--- a/lib/main/liboptions.sh
+++ b/lib/main/liboptions.sh
@@ -9,7 +9,7 @@
99
1010 # ============= Database of options which are given at each run and not saved =============
1111 # [Syntax of option databases]
12-# short_name, long_name, variable, defult_vaule, set_value
12+# short_name, long_name, variable, default_value, set_value
1313 # Columns are delimited by tab characters.
1414 options_db_onetime ()
1515 {
--- a/lib/upgrade/libcommand_do.sh
+++ b/lib/upgrade/libcommand_do.sh
@@ -71,8 +71,8 @@ command_do_reinst_ports ()
7171 if [ -n "$target_pkg" ]
7272 then
7373 target_regexp=`str_escape_regexp "$target_pkg"`
74- timestamp_init=`grep -E "^${target_regexp}[[:space:]]" "${DBDIR}/initial_pkgs_snapshot.csv" | cut -f 2`
75- timestamp_fin=`grep -E "^${target_regexp}[[:space:]]" "${ETCDIR}/final_pkgs_snapshot.csv" | cut -f 2`
74+ timestamp_init=`env LANG=C grep -E "^${target_regexp}[[:space:]]" "${DBDIR}/initial_pkgs_snapshot.csv" | cut -f 2`
75+ timestamp_fin=`env LANG=C grep -E "^${target_regexp}[[:space:]]" "${ETCDIR}/final_pkgs_snapshot.csv" | cut -f 2`
7676 if [ -n "$timestamp_init" -a -n "$timestamp_fin" ]
7777 then
7878 pkgtype_init=`expr "$timestamp_init" : '\([^:]*\):' || :`
@@ -182,8 +182,8 @@ command_do_deinst_remining_olg_pkgs ()
182182 {
183183 message_section_title "Deinstalling remaining old packages if any..."
184184 pkg_get_pkgs_timestamps | \
185- grep -vE "`pkgsys_pkgtools_pkgs_filter_regexp`"> ${TMPDIR}/current_pkgs_snapshot.csv
186- grep -Fxv -f "${ETCDIR}/final_pkgs_snapshot.csv" "${TMPDIR}/current_pkgs_snapshot.csv" | \
185+ env LANG=C grep -vE "`pkgsys_pkgtools_pkgs_filter_regexp`"> ${TMPDIR}/current_pkgs_snapshot.csv
186+ env LANG=C grep -Fxv -f "${ETCDIR}/final_pkgs_snapshot.csv" "${TMPDIR}/current_pkgs_snapshot.csv" | \
187187 cut -f 1 | while read pkg_old
188188 do
189189 pkg_delete_f "$pkg_old"
--- a/lib/upgrade/liboptions.sh
+++ b/lib/upgrade/liboptions.sh
@@ -9,7 +9,7 @@
99
1010 # ============= Database of options which are given at each run and not saved =============
1111 # [Syntax of option databases]
12-# short_name, long_name, variable, defult_vaule, set_value
12+# short_name, long_name, variable, default_value, set_value
1313 # Columns are delimited by tab characters.
1414 options_db_onetime ()
1515 {
--- a/man/portsreinstall-chroot.8
+++ b/man/portsreinstall-chroot.8
@@ -195,7 +195,7 @@ The delimiter is comma (",") by default and changeable by \fB\-E\fR option.
195195 .PD 0
196196 .TP
197197 \fB\-\-fullcourse\fR
198-Carry out the \fBdo\fR process as the "full course" automatic mode where update of the ports tree and package repository are done first at the target host environment and thhen operation in the builder \fBchroot\fR(8) environment is started by cleaning of the temporary database and execution of \fBportsreinstall\fR(8) initiated with option \fB\-CGSjqx\fR (\fB\-CGSYajqx\fR if \fB\-a\fR option is set).
198+Carry out the \fBdo\fR process as the "full course" automatic mode where update of the ports tree and package repository are done first at the target host environment and then operation in the builder \fBchroot\fR(8) environment is started by cleaning of the temporary database and execution of \fBportsreinstall\fR(8) initiated with option \fB\-CGSjqx\fR (\fB\-CGSYajqx\fR if \fB\-a\fR option is set).
199199 Resuming \fBdo\fR command automatically executes \fBportsreinstall\fR(8) in the builder \fBchroot\fR(8) environment.
200200 With \fB\-a\fR option, the all detected leaf and obsolete packages will be deleted.
201201 .PD
@@ -337,6 +337,9 @@ See also the corresponding section of \fBportsreinstall\fR(8).
337337 The variables are conveyed to the forked environment from the target host.
338338 .SH HISTORY
339339 This utility first appeared as a part of \fBportsreinstall\fR(8) version 4.0.0 released on June 29, 2018.
340+.SH BUGS
341+This tool is still experimental and may not work in typical environments.
342+It has been observed that \fBpkg\-add\fR(8) command froze at the preparation stage in a ZFS-mounted environment with 12.2-RELEASE.
340343 .SH "SEE ALSO"
341344 \fBchroot\fR(8)
342345 \fBportsreinstall\fR(8),
Show on old repository browser