From 12c96c00c54d1b56c2472457377339c11e0a00d9 Mon Sep 17 00:00:00 2001 From: Mamoru Sakaue Date: Thu, 24 Mar 2022 02:10:15 +0900 Subject: [PATCH] [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 --- HISTORY | 7 +- lib/chroot-mount/liboptions.sh | 2 +- lib/chroot/libfs.sh | 115 +++++++++++++++++++------- lib/chroot/liboptions.sh | 16 +++- lib/libcommand_do.sh | 46 +++++------ lib/libcommand_flexconf.sh | 4 +- lib/libcommand_forget.sh | 4 +- lib/libcommand_pkgs.sh | 22 ++--- lib/libconf.sh | 18 ++--- lib/libdatabase_build.sh | 58 +++++++------- lib/libdatabase_maintain.sh | 2 +- lib/libdatabase_query.sh | 42 +++++++--- lib/libdatabase_record.sh | 2 +- lib/libdeinstall.sh | 20 ++--- lib/libfileedit.sh | 16 ++-- lib/libfs.sh | 21 ++--- lib/libmain.sh | 4 +- lib/libmisc.sh | 2 +- lib/liboptions.sh | 67 ++++++++++++---- lib/libpkgsys.sh | 93 +++++++++++----------- lib/libprogram.sh | 2 +- lib/libreinstall.sh | 177 ++++++++++++++++++++++++++++------------- lib/main/liboptions.sh | 2 +- lib/upgrade/libcommand_do.sh | 8 +- lib/upgrade/liboptions.sh | 2 +- man/portsreinstall-chroot.8 | 5 +- 26 files changed, 479 insertions(+), 278 deletions(-) diff --git a/HISTORY b/HISTORY index 8e4f098..5100ec9 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,10 @@ -4.1.1 (?? October 2021) +4.1.1 (?? December 2021) [IMPROVED] Adapt to the specification change of pkg-create(8) that the default extension of the package files become "pkg". +[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. 4.1.0 (22 September 2018) [NEW] Options -j and -x are added. [NEW] Option -J is added to the all utilities. diff --git a/lib/chroot-mount/liboptions.sh b/lib/chroot-mount/liboptions.sh index 7e66db9..a106bfe 100644 --- a/lib/chroot-mount/liboptions.sh +++ b/lib/chroot-mount/liboptions.sh @@ -9,7 +9,7 @@ # ============= Database of options which are given at each run and not saved ============= # [Syntax of option databases] -# short_name, long_name, variable, defult_vaule, set_value +# short_name, long_name, variable, default_value, set_value # Columns are delimited by tab characters. options_db_onetime () { diff --git a/lib/chroot/libfs.sh b/lib/chroot/libfs.sh index 1165f3f..b549266 100644 --- a/lib/chroot/libfs.sh +++ b/lib/chroot/libfs.sh @@ -61,14 +61,18 @@ fs_save_mounttime_systembase () # ============= Get the system base observed currently ============= fs_get_current_systembase () { - cat "${TMPDIR}/fs_save_current_systembase" 2> /dev/null + local systembase + systembase=`cat "${TMPDIR}/fs_save_current_systembase" 2> /dev/null` + [ -z "$systembase" ] || realpath "$systembase" } # ============= Get the system base observed at the time of mounting ============= # Non-zero return means no file system was attempted to mount fs_get_mounttime_systembase () { - cat "${DBDIR}/fs_systembase" 2> /dev/null + local systembase + systembase=`cat "${DBDIR}/fs_systembase" 2> /dev/null` + [ -z "$systembase" ] || realpath "$systembase" } # ============= Get the system base in the scope of accessing ============= @@ -104,40 +108,89 @@ fs_build_chroot () fs_safeguard_basedir "$opt_basedir" fs_unmount || return mkdir -p "$opt_basedir" - # Prescan the f file system of the original environment + # Prescan the file system of the original environment cp /dev/null "${TMPDIR}/fs_build_chroot:directories" ( + real_basedir=`realpath "$opt_basedir"` { +# echo bin compat etc lib libexec root sbin sys usr | tr ' ' '\n' echo bin compat etc lib libexec root sbin sys usr var | tr ' ' '\n' echo "$opt_extra_dirs" | tr "$opt_extra_dirs_delim" '\n' - } | grep -v '^[[:space:]]*$' | sort -u > ${TMPDIR}/fs_build_chroot:sys_dirs - sysdirs_ptn="^/*(`str_escape_regexp_filter < ${TMPDIR}/fs_build_chroot:sys_dirs | tr '\n' '|' | sed 's/\|$//'`)/+" - while read directory + } | env LANG=C grep -v '^[[:space:]]*$' | sort -u | while read node do - [ -e "/$directory" ] || continue - if [ -L "/$directory" ] + [ -e "/$node" ] || continue + src_mountpoint_real=`realpath "/$node"` + ptn_src_mountpoint_real=`str_escape_regexp "$src_mountpoint_real/"` + if echo "$real_basedir" | grep -Eq "^$ptn_src_mountpoint_real" then - src_mountpoint_real=`realpath "/$directory"` - printf '%s\t%s\n' link "$directory" >> ${TMPDIR}/fs_build_chroot:directories - if ! echo "$src_mountpoint_real/" | grep -qE "$sysdirs_ptn" + ( + node_cur=$node + rm -f "${TMPDIR}/fs_build_chroot:hit_exact" + while [ ! -e "${TMPDIR}/fs_build_chroot:hit_exact" ] + do + rm -f "${TMPDIR}/fs_build_chroot:hit_subnode" + cd "/$node_cur" + ls -a | while read subnode + do + if [ "$subnode" = . -o "$subnode" = .. ] + then + continue + elif [ -L "$subnode" -o -f "$subnode" ] + then + echo "$node_cur/$subnode" + elif [ -d "$subnode" ] + then + node_cur_tmp_real=`realpath "/$node_cur/$subnode"` + ptn_node_cur_tmp_real=`str_escape_regexp "$node_cur_tmp_real/"` + if [ "$real_basedir" = "$node_cur_tmp_real" ] + then + touch "${TMPDIR}/fs_build_chroot:hit_exact" + elif echo "$real_basedir" | grep -Eq "^$ptn_node_cur_tmp_real" + then + echo "$subnode" > ${TMPDIR}/fs_build_chroot:hit_subnode + else + echo "$node_cur/$subnode" + fi + fi + done + [ -e "${TMPDIR}/fs_build_chroot:hit_subnode" ] || break + node_cur=$node_cur/`cat "${TMPDIR}/fs_build_chroot:hit_subnode"` + done + ) + else + echo "$node" + fi + done > ${TMPDIR}/fs_build_chroot:sys_nodes + sysdirs_ptn="^/*(`str_escape_regexp_filter < ${TMPDIR}/fs_build_chroot:sys_nodes | tr '\n' '|' | sed 's/\|$//'`)/+" + while read node + do + [ -e "/$node" ] || continue + if [ -L "/$node" -a -d "/$node" ] + then + src_mountpoint_real=`realpath "/$node"` + printf '%s\t%s\n' link "$node" >> ${TMPDIR}/fs_build_chroot:directories + if ! echo "$src_mountpoint_real/" | env LANG=C grep -qE "$sysdirs_ptn" then printf '%s\t%s\n' real "$src_mountpoint_real" >> ${TMPDIR}/fs_build_chroot:directories tmpdir_descendant=${TMPDIR}/fs_build_chroot:descendant/$src_mountpoint_real mkdir -p "$tmpdir_descendant" fs_get_descendant_mount_info "/$src_mountpoint_real" > $tmpdir_descendant/list fi - elif [ -d "/$directory" ] + elif [ -d "/$node" ] then - printf '%s\t%s\n' real $directory >> ${TMPDIR}/fs_build_chroot:directories - tmpdir_descendant=${TMPDIR}/fs_build_chroot:descendant/$directory + printf '%s\t%s\n' real $node >> ${TMPDIR}/fs_build_chroot:directories + tmpdir_descendant=${TMPDIR}/fs_build_chroot:descendant/$node mkdir -p "$tmpdir_descendant" - fs_get_descendant_mount_info "/$directory" > $tmpdir_descendant/list + fs_get_descendant_mount_info "/$node" > $tmpdir_descendant/list + elif [ -L "/$node" -o -f "/$node" ] + then + cp -p "/$node" "$node" fi - done < ${TMPDIR}/fs_build_chroot:sys_dirs + done < ${TMPDIR}/fs_build_chroot:sys_nodes ) # Prepare the grand base of the chroot environment ( - cd "/$opt_basedir" + cd "$opt_basedir" for directory in builder mask store do [ -d $directory ] || mkdir $directory @@ -149,14 +202,16 @@ fs_build_chroot () echo "$PORTSDIR" echo "$PORTSNAP_WORKDIR" echo "$PKGNG_PKG_CACHEDIR" - fi | str_regularize_df_path_filter | grep -v '^[[:space:]]*$' | sort -u > ${DBDIR}/shared_dirs.lst + fi | str_regularize_df_path_filter | env LANG=C grep -v '^[[:space:]]*$' | sort -u > ${DBDIR}/shared_dirs.lst str_escape_regexp_filter < ${DBDIR}/shared_dirs.lst | sed 's|^|^|;s|$|\/|' > ${TMPDIR}/fs_build_chroot:shared_dirs.regexp.tmp paste "${DBDIR}/shared_dirs.lst" "${TMPDIR}/fs_build_chroot:shared_dirs.regexp.tmp" > ${TMPDIR}/fs_build_chroot:shared_dirs.regexp cp /dev/null "${TMPDIR}/fs_build_chroot:shared_dirs:added" # Build target directories and the manifest for mounting + mkdir -p "$opt_basedir/mask" cp /dev/null "${DBDIR}/mount_manifest.tmp" ( - cd "/$opt_basedir"/builder + real_basedir=`realpath "$opt_basedir"` + cd "$real_basedir"/builder while read srcline do type=`echo "$srcline" | cut -f 1` @@ -167,7 +222,7 @@ fs_build_chroot () ;; real ) mkdir -p "./$directory" - masktarget=/$opt_basedir/mask/$directory + masktarget=$real_basedir/mask/$directory mkdir -p "$masktarget" printf '%s\t%s\t%s\t%s\n' nullfs "/$directory" "$directory" ro >> ${DBDIR}/mount_manifest.tmp 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 () rm -f "${TMPDIR}/fs_build_chroot:shared_dirs:is_itself" while read -r shared_path shared_path_regexp do - echo "$fullpath/" | grep -qE "$shared_path_regexp" || continue + echo "$fullpath/" | env LANG=C grep -qE "$shared_path_regexp" || continue echo "$shared_path"$'\n'"$fullpath" | while read mpath do - if ! grep -qFx "$mpath" "${TMPDIR}/fs_build_chroot:shared_dirs:added" + if ! env LANG=C grep -qFx "$mpath" "${TMPDIR}/fs_build_chroot:shared_dirs:added" then echo "$mpath" >> ${TMPDIR}/fs_build_chroot:shared_dirs:added mkdir -p "/$mpath" @@ -197,7 +252,7 @@ fs_build_chroot () [ -e "${TMPDIR}/fs_build_chroot:shared_dirs:is_under" ] && continue case $fs in normal ) - masktarget=`str_regularize_df_path "/$opt_basedir/mask/$fullpath"` + masktarget=`str_regularize_df_path "$real_basedir/mask/$fullpath"` mkdir -p "$masktarget" printf '%s\t%s\t%s\t%s\n' nullfs "$mp" "$fullpath" ro >> ${DBDIR}/mount_manifest.tmp 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 () ;; esac done < ${TMPDIR}/fs_build_chroot:directories - grep -Ev -f "${TMPDIR}/fs_build_chroot:shared_dirs:added" "${DBDIR}/shared_dirs.lst" | while read shared_dir + env LANG=C grep -Ev -f "${TMPDIR}/fs_build_chroot:shared_dirs:added" "${DBDIR}/shared_dirs.lst" | while read shared_dir do mkdir -p "$shared_dir" mp_share=`realpath "$shared_dir"` @@ -237,7 +292,7 @@ fs_build_chroot () printf '%s\t%s\t%s\t%s\n' procfs proc proc rw >> ${DBDIR}/mount_manifest.tmp printf '%s\t%s\t%s\t%s\n' tmpfs tmpfs tmp rw,mode=1777 >> ${DBDIR}/mount_manifest.tmp mkdir -p ."${PROGRAM}" - cd "/$opt_basedir/mask" + cd "$real_basedir/mask" if [ ! -e root/.cshrc ] then tmp_cshrc=${TMPDIR}/fs_build_chroot:.cshrc @@ -257,7 +312,7 @@ fs_build_chroot () echo 'set prompt="%N@[builder]%m:%~ %# "' >> $tmp_cshrc mv "$tmp_cshrc" root/.cshrc fi - printf '%s\t%s\t%s\t%s\n' nullfs "/$opt_basedir"/store ".${PROGRAM}" rw >> ${DBDIR}/mount_manifest.tmp + printf '%s\t%s\t%s\t%s\n' nullfs "$real_basedir"/store ".${PROGRAM}" rw >> ${DBDIR}/mount_manifest.tmp ) mv "${DBDIR}/mount_manifest.tmp" "${DBDIR}/mount_manifest" } @@ -279,7 +334,8 @@ fs_chk_mount () directory=`echo "$srcline" | cut -f 3` opt=`echo "$srcline" | cut -f 4` mp=`str_regularize_df_path "$systembase_mp/$opt_basedir/builder/$directory"` - if ! fs_chk_mounted "$type" "$target" "$mp" + expr "$target" : \\/ && target=`realpath "$target"` + if ! real_mp=`realpath "$mp" 2> /dev/null` || ! fs_chk_mounted "$type" "$target" "$real_mp" then printf '%s\t%s\t%s\n' "$type" "$target" "$mp" >> $tmp_remains fi @@ -412,8 +468,9 @@ fs_chk_unmount () [ "x$type" = xnullfs -o "x$type" = xunionfs ] && target=$systembase_target/$target directory=`echo "$srcline" | cut -f 3` opt=`echo "$srcline" | cut -f 4` - mp=$systembase_mp/$opt_basedir/builder/$directory - fs_chk_mounted "$type" "$target" "$mp" || continue + mp=`str_regularize_df_path "$systembase_mp/$opt_basedir/builder/$directory"` + real_mp=`realpath "$mp" 2> /dev/null` || continue + fs_chk_mounted "$type" "$target" "$real_mp" || continue str_regularize_df_path "$mp" >> $tmp_remains done ! cat "$tmp_remains" 2> /dev/null diff --git a/lib/chroot/liboptions.sh b/lib/chroot/liboptions.sh index 7c73343..fe42fb3 100644 --- a/lib/chroot/liboptions.sh +++ b/lib/chroot/liboptions.sh @@ -9,7 +9,7 @@ # ============= Database of options which are given at each run and not saved ============= # [Syntax of option databases] -# short_name, long_name, variable, defult_vaule, set_value +# short_name, long_name, variable, default_value, set_value # Columns are delimited by tab characters. options_db_onetime () { @@ -43,8 +43,16 @@ s share-port-pkgs-dirs opt_share_port_pkgs_dirs no yes eof } -# ============= Regularize the option value ============= -options_regularize () +# ============= Definitions of value regulator functions ============= +options_db_value_regulators () { - opt_basedir=`fs_global_path "$opt_basedir"` + cat << eof +opt_basedir options_regularize_to_global_path +eof +} + +# ============= Regularize a value of an option value: conversion of a oath into the global path ============= +options_regularize_to_global_path () +{ + fs_global_path "$1" } diff --git a/lib/libcommand_do.sh b/lib/libcommand_do.sh index 044750b..73bd344 100644 --- a/lib/libcommand_do.sh +++ b/lib/libcommand_do.sh @@ -274,10 +274,10 @@ command_do_reset_changed_portdb () str_escape_regexp_filter < $tmp_ls.uninspected.dbfile | sed 's/^/^/;s/$/[[:space:]]/' > $tmp_ls.uninspected.dbfile_ptn paste "$tmp_ls.uninspected.dbfile_ptn" "$tmp_ls.uninspected.logname" | while read -r dbfile_ptn logname do - grep -E "$dbfile_ptn" < $tmp_ls.log > ${DBDIR}/ls_dbdir/$logname.log 2> /dev/null || : + env LANG=C grep -E "$dbfile_ptn" < $tmp_ls.log > ${DBDIR}/ls_dbdir/$logname.log 2> /dev/null || : done str_escape_regexp_filter < $tmp_ls.nonexistent.db | sed 's/^/^/;s/$/[[:space:]]/' > $tmp_ls.nonexistent.db_ptn - grep -E -f "$tmp_ls.nonexistent.db_ptn" < $tmp_ls.log | pkgsys_register_list_nonexistent_portopriondb + env LANG=C grep -E -f "$tmp_ls.nonexistent.db_ptn" < $tmp_ls.log | pkgsys_register_list_nonexistent_portopriondb message_echo [ ! -e "$tmp_ls.updated" ] } @@ -329,7 +329,7 @@ command_do_convert_dependency_lists_to_actual_ones () if [ -e "$target.src" ] then sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "$target.src" \ - | grep -v '^$' | sort -u > $target.tmp + | env LANG=C grep -v '^$' | sort -u > $target.tmp [ -e "$target" ] && ! diff -q "$target.tmp" "$target" > /dev/null \ && echo "$origin" >> ${DBDIR}/update_dependencies mv "$target.tmp" "$target" @@ -354,13 +354,13 @@ command_do_convert_dependency_lists_to_actual_ones () find . -depth 3 -type f -name requirements.${tag}.full -or -name requirements.${tag}.full.orig ) \ | sort -u \ | sed 's|^./||;s|/[^/]*$||' \ - | grep -v -Fx -f "${DBDIR}/update_dependencies" \ + | env LANG=C grep -v -Fx -f "${DBDIR}/update_dependencies" \ > ${TMPDIR}/convert_requirements_list:full_complete.grep_pattern || : ( cd "${DBDIR}/requires" && \ find . -depth 3 -type f -name requirements.${tag}.direct -or -name requirements.${tag}.direct.orig ) \ | sort -u \ | sed 's|^./||;s|/[^/]*$||' \ - | grep -v -Fx -f "${TMPDIR}/convert_requirements_list:full_complete.grep_pattern" \ + | env LANG=C grep -v -Fx -f "${TMPDIR}/convert_requirements_list:full_complete.grep_pattern" \ > ${DBDIR}/stage.loop_list/complete_recursive_${tag}time_reqlists || : done for inspected_level_tmp in direct node @@ -423,7 +423,7 @@ command_do_trim_dependency_lists_by_removing_uninspected_ports () do srcdb=requirements.${tag}.${level} [ -e "$dbpath/$srcdb" ] || continue - grep -Fx -f "${DBDIR}/inspected_ports" "$dbpath/$srcdb" > $dbpath/$srcdb.tmp || : + env LANG=C grep -Fx -f "${DBDIR}/inspected_ports" "$dbpath/$srcdb" > $dbpath/$srcdb.tmp || : mv "$dbpath/$srcdb.tmp" "$dbpath/$srcdb" done done @@ -621,7 +621,7 @@ command_do_post_process_after_the_preparation_of_target_attribute_information () { message_section_title "Post-process after the preparation of target attribute information" sort -u "${DBDIR}/all_targets.lst" 2> /dev/null \ - | grep -Fx -f "${DBDIR}/inspected_ports" \ + | env LANG=C grep -Fx -f "${DBDIR}/inspected_ports" \ | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" 2> /dev/null \ > ${DBDIR}/all_targets.lst.tmp || : mv "${DBDIR}/all_targets.lst.tmp" "${DBDIR}/all_targets.lst" @@ -792,7 +792,7 @@ command_do_preparation_for_inspection_of_new_leaf_ports () fileedit_manipulate_new_lines \ "${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:nonleaf_ports" \ "${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:inspected_ports" \ - | grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null \ + | env LANG=C grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null \ > ${DBDIR}/stage.loop_list/leaf_ports_primary_candidates || : cp /dev/null "${DBDIR}/leaf_ports.filter" cp /dev/null "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" @@ -815,8 +815,8 @@ command_do_inspection_of_new_primary_leaf_ports () origin=$1 pkgsys_is_pkgtool "$origin" && return dbpath=${DBDIR}/requires/$origin - grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return - if ! grep -q -Fx "$origin" "${DBDIR}/noneed.list" 2> /dev/null + env LANG=C grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return + if ! env LANG=C grep -q -Fx "$origin" "${DBDIR}/noneed.list" 2> /dev/null then if [ -e "$dbpath/initial_orig" ] then @@ -832,7 +832,7 @@ command_do_inspection_of_new_primary_leaf_ports () if [ -e "$dbpath/requirements.all.full" -o -e "$dbpath/ignored_requirements.all" ] then cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null | \ - grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null| \ + env LANG=C grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null| \ fileedit_add_lines_if_new "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" || : fi fileedit_add_a_line_if_new "$origin" "${DBDIR}/leaf_ports.filter" @@ -871,9 +871,9 @@ command_do_inspection_of_requirements_of_new_leaf_ports () origin=$1 pkgsys_is_pkgtool "$origin" && return dbpath=${DBDIR}/requires/$origin - grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return + env LANG=C grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return cat "$dbpath/dependents.all.full" "$dbpath/ignored_dependents.all" 2> /dev/null \ - | grep -Fxq -v -f "${DBDIR}/leaf_ports.filter" 2> /dev/null && return + | env LANG=C grep -Fxq -v -f "${DBDIR}/leaf_ports.filter" 2> /dev/null && return cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null \ >> ${DBDIR}/leaf_ports_secondary_candidates.new_requirements || : fileedit_add_a_line_if_new "$origin" "${DBDIR}/leaf_ports.filter" @@ -889,10 +889,10 @@ command_do_inspection_of_requirements_of_new_leaf_ports () break fi { - grep -Fx -v -f "${DBDIR}/leaf_ports.filter" \ + env LANG=C grep -Fx -v -f "${DBDIR}/leaf_ports.filter" \ "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" || : cat "${DBDIR}/leaf_ports_secondary_candidates.new_requirements" || : - } 2> /dev/null | grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null | sort -u \ + } 2> /dev/null | env LANG=C grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null | sort -u \ > ${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates.tmp || : program_reset_loop_for_stage INSPECT_REQUIREMENTS_OF_LEAF_PORTS mv "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates.tmp" \ @@ -902,7 +902,7 @@ command_do_inspection_of_requirements_of_new_leaf_ports () num_inspect=`wc -l < ${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates | tr -d ' '` message_echo " $num_leaves_new leaf port(s) is/are newly found; continue for $num_inspect candidate(s)." done - grep -Fx -f "${DBDIR}/leaf_ports.filter" "${DBDIR}/inspected_ports" 2> /dev/null | sort -u > ${DBDIR}/leaf_ports || : + env LANG=C grep -Fx -f "${DBDIR}/leaf_ports.filter" "${DBDIR}/inspected_ports" 2> /dev/null | sort -u > ${DBDIR}/leaf_ports || : message_echo } program_exec_and_record_completion INSPECT_REQUIREMENTS_OF_LEAF_PORTS @@ -1008,7 +1008,7 @@ command_do_collection_of_obsolete_ports_to_delete () cat "${DBDIR}/initial/$origin/requirements.run.full" || : cat "${DBDIR}/obsolete/$origin/requirements.run.full" || : done | sort -u > $reqptn_file - grep -v -Fx -f "$reqptn_file" "$src_selected" > $dst_selected 2> /dev/null || : + env LANG=C grep -v -Fx -f "$reqptn_file" "$src_selected" > $dst_selected 2> /dev/null || : message_echo } 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 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ] then cat "$reqptn_leaf" "$reqptn_obs" 2> /dev/null | sort -u > $grepptn - grep -v -Fx -f "$grepptn" "$leaf_selected_src" 2> /dev/null \ + env LANG=C grep -v -Fx -f "$grepptn" "$leaf_selected_src" 2> /dev/null \ | database_query_add_initial_origins > $leaf_selected || : cat "$obs_selected" "$leaf_selected" 2> /dev/null || : else @@ -1059,11 +1059,11 @@ command_do_composition_of_a_list_for_deinstallation_of_obsolete_and_leaf_package str_escape_regexp_filter < ${DBDIR}/stage.loop_list/ports_to_delete \ | sed 's/^/^/;s/$/[[:space:]]/' > $grepptn_col1 cat "${DBDIR}/leaf_ports.with_ini" "${DBDIR}/obsolete_ports" 2> /dev/null \ - | grep -Fx -v -f "${DBDIR}/stage.loop_list/ports_to_delete" > ${DBDIR}/stage.loop_list/ports_to_restore 2> /dev/null || : + | env LANG=C grep -Fx -v -f "${DBDIR}/stage.loop_list/ports_to_delete" > ${DBDIR}/stage.loop_list/ports_to_restore 2> /dev/null || : if [ $opt_batch_mode = no ] then if [ ! -e "${DBDIR}/inspected_ports_only_partially" ] && \ - grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$leaf_selected_src" > $preserved 2> /dev/null + env LANG=C grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$leaf_selected_src" > $preserved 2> /dev/null then message_echo "INFO: Following leaf ports are preserved because required by other preserved leaf/obsolete ports." message_echo "----------------" @@ -1079,7 +1079,7 @@ command_do_composition_of_a_list_for_deinstallation_of_obsolete_and_leaf_package done < $preserved message_echo "----------------" fi - if grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$obs_selected_src" > $preserved 2> /dev/null + if env LANG=C grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$obs_selected_src" > $preserved 2> /dev/null then message_echo "INFO: Following obsolete ports are preserved because required by other obsolete ports." message_echo "----------------" @@ -1112,7 +1112,7 @@ command_do_collect_entire_distfiles_list () { message_section_title "Collecting entire distfiles list" find "${PORTSDIR}" -depth 3 -name distinfo -exec cat {} \; \ - | grep '^SHA256 ' | sed -E 's/^SHA256 \(([^)]*)\).*/\1/' \ + | env LANG=C grep '^SHA256 ' | sed -E 's/^SHA256 \(([^)]*)\).*/\1/' \ | sort -u > ${DBDIR}/distfiles.entire.tmp mv "${DBDIR}/distfiles.entire.tmp" "${DBDIR}/distfiles.entire" message_echo @@ -1292,7 +1292,7 @@ command_do_rebuild_of_package_database () { which -s pkgdb || return 0 message_section_title "Rebuilding package database for portupgrade" - if grep -q @ "${DBDIR}/stage.loop_list/reinst_todo" + if env LANG=C grep -q @ "${DBDIR}/stage.loop_list/reinst_todo" then message_echo "INFO: Skipped because of lacking flavor support." else diff --git a/lib/libcommand_flexconf.sh b/lib/libcommand_flexconf.sh index 4113667..0b9708c 100644 --- a/lib/libcommand_flexconf.sh +++ b/lib/libcommand_flexconf.sh @@ -100,8 +100,8 @@ command_flexconf_update_freeze () fileedit_combine_lists "${DBDIR}/conf/FREEZE:PORTS.parsed" "${DBDIR}/freeze.list" > ${DBDIR}/freeze.all.list rm -f "$tmp_list:exists_update" { - grep -vFx -f "$tmp_list:old" "${DBDIR}/freeze.all.list" - grep -vFx -f "${DBDIR}/freeze.all.list" "$tmp_list:old" + env LANG=C grep -vFx -f "$tmp_list:old" "${DBDIR}/freeze.all.list" + env LANG=C grep -vFx -f "${DBDIR}/freeze.all.list" "$tmp_list:old" } | while read origin do touch "$tmp_list:exists_update" diff --git a/lib/libcommand_forget.sh b/lib/libcommand_forget.sh index b25afe1..9ba6c5a 100644 --- a/lib/libcommand_forget.sh +++ b/lib/libcommand_forget.sh @@ -74,7 +74,7 @@ command_forget () origin=$1 origins_init=`database_query_initial_orgins "$origin"` if [ -z "$origins_init" ] \ - && ! grep -qv -Fx -f "${DBDIR}/forget/remove.scope.filter" \ + && ! env LANG=C grep -qv -Fx -f "${DBDIR}/forget/remove.scope.filter" \ "${DBDIR}/requires/$origin/dependents.all.full" \ 2> /dev/null then @@ -94,7 +94,7 @@ command_forget () cat "${DBDIR}/forget/remove" || : } 2> /dev/null | sort -u > ${DBDIR}/forget/remove.filter cat "${DBDIR}/inspected_ports.update" 2> /dev/null | sort -u \ - | grep -v -Fx -f "${DBDIR}/forget/remove.filter" \ + | env LANG=C grep -v -Fx -f "${DBDIR}/forget/remove.filter" \ > ${DBDIR}/inspected_ports.update.tmp 2> /dev/null || : mv "${DBDIR}/inspected_ports.update.tmp" "${DBDIR}/inspected_ports.update" message_echo diff --git a/lib/libcommand_pkgs.sh b/lib/libcommand_pkgs.sh index d134476..e0114fa 100644 --- a/lib/libcommand_pkgs.sh +++ b/lib/libcommand_pkgs.sh @@ -77,7 +77,7 @@ command_pkgs_restore () do pkgsys_register_evaluated_globs remove "${DBDIR}/taboo.list" "$origin" message_echo " Deregistered $origin from taboo." - grep -Fx -q "$origin" "$tmp_done_orig" 2> /dev/null || : + env LANG=C grep -Fx -q "$origin" "$tmp_done_orig" 2> /dev/null || : if pkgsys_exists_from_orig "$origin" then pkg=`pkgsys_get_installed_pkg_from_origin "$origin"` @@ -159,7 +159,7 @@ command_pkgs_pkgsanity () while read origin do pkgsys_get_installed_pkg_from_origin "$origin" - done < $tmp_list.orgs | grep -v '^[[:space:]]*$' > $tmp_list.pkgs || { + done < $tmp_list.orgs | env LANG=C grep -v '^[[:space:]]*$' > $tmp_list.pkgs || { message_echo "WARNING: No such globs match any installed package." >&2 temp_terminate_process () { :; } exit 1 @@ -212,7 +212,7 @@ command_pkgs_pkgsanity () iline=$((${iline}+1)) origin=`pkg_info_flavored_origin "$pkg"` [ -n "$origin" ] || continue - grep -q -Fx "$origin" "${DBDIR}/damaged_package" 2>/dev/null && continue + env LANG=C grep -q -Fx "$origin" "${DBDIR}/damaged_package" 2>/dev/null && continue pkgsys_sanitychk_pkgcontents "$pkg" is_reinstall_encouraged && continue port_path=`pkgsys_get_portpath_from_origin "$origin"` if [ ! -d "$port_path" ] @@ -312,7 +312,7 @@ command_pkgs_packupgrade_create__manifest_reinst () PROGRAM_DEPENDS=COMMAND_PACKUPGRADE_PREPARE _program_exec_restartable_loop_operation__routine () { - local origin dstdir tmp_manifest dbdir_new pkgname pkgarc timestamp_inst timestamp_arc origin_old + local origin dstdir tmp_manifest dbdir_new pkgname pkgarc timestamp_inst timestamp_arc origin_old origin_equiv origin=$1 dstdir=${DBDIR}/command_packupgrade tmp_manifest=${TMPDIR}/packupgrade::manifest @@ -320,14 +320,14 @@ command_pkgs_packupgrade_create__manifest_reinst () dbdir_new=${DBDIR}/requires/$origin pkgname=`pkgsys_get_installed_pkg_from_origin "$origin"` [ -n "$pkgname" ] || return 0 - if ! grep -Fxq "$pkgname" "$dstdir/etc/created_packages.lst" 2> /dev/null + if ! env LANG=C grep -Fxq "$pkgname" "$dstdir/etc/created_packages.lst" 2> /dev/null then if pkg_info_e "$pkgname" then if pkgarc=`pkgsys_pkgname_to_pkgarc "${PACKAGESDIR}" "$pkgname"` then timestamp_inst=`pkg_get_pkg_timestamp "$pkgname" 2> /dev/null` || : - timestamp_arc=`ls -lD %s "$pkgarc" 2> /dev/null | sed -E 's/[[:space:]]+/ /g' | cut -w -f 6 | grep -v '^$'` || : + timestamp_arc=`ls -lD %s "$pkgarc" 2> /dev/null | sed -E 's/[[:space:]]+/ /g' | cut -w -f 6 | env LANG=C grep -v '^$'` || : else timestamp_inst=1 timestamp_arc=0 @@ -340,10 +340,14 @@ command_pkgs_packupgrade_create__manifest_reinst () exit 1 fi fi - elif grep -Fxq "$origin" ${DBDIR}/success.run.full.list + elif env LANG=C grep -Fxq "$origin" ${DBDIR}/success.run.full.list then - message_echo "ERROR: Necessary package is missing [$origin]." >&2 - exit 1 + origin_equiv=`database_query_get_equivalent_orgin "$origin"` + if [ -z "$origin_equiv" ] || env LANG=C grep -Fxq "$origin_equiv" ${DBDIR}/success.run.full.list + then + message_echo "ERROR: Necessary package is missing [$origin]." >&2 + exit 1 + fi fi fileedit_add_a_line_if_new "$pkgname" "$dstdir/etc/created_packages.lst" fi diff --git a/lib/libconf.sh b/lib/libconf.sh index d16ceeb..6a22497 100644 --- a/lib/libconf.sh +++ b/lib/libconf.sh @@ -55,7 +55,7 @@ conf_parse_vars_for_each_port_glob () { local section section=$1 - misc_get_all_vardefs | grep -e "^_CONF_${section}_" | cut -d = -f 1 | while read var + misc_get_all_vardefs | env LANG=C grep -e "^_CONF_${section}_" | cut -d = -f 1 | while read var do eval glob_pattern=\${$var} pkgsys_eval_ports_glob "$glob_pattern" @@ -69,7 +69,7 @@ conf_parse_vars_for_each_port_glob_with_bound_val () section=$1 tag_target=$2 tag_val=$3 - misc_get_all_vardefs | grep -e "^_CONF_${section}_${tag_target}_" | cut -d = -f 1 | while read var + misc_get_all_vardefs | env LANG=C grep -e "^_CONF_${section}_${tag_target}_" | cut -d = -f 1 | while read var do eval glob_pattern=\${$var} eval val=\$\{`echo "$var" | sed "s/^_CONF_${section}_${tag_target}_/_CONF_${section}_${tag_val}_/"`\} @@ -210,13 +210,13 @@ conf_manipulate_available_var_defs () _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' for item in ${_CONFVARS} do - misc_get_all_vardefs | grep -e "^${item}_" | cut -d = -f 1 | sed 's/^/unset /' + misc_get_all_vardefs | env LANG=C grep -e "^${item}_" | cut -d = -f 1 | sed 's/^/unset /' done > $tmpfile_unsetvars . "$tmpfile_unsetvars" . "${DBDIR}/conf/complete_setup.sh" for item in ${_CONFVARS} do - misc_get_all_vardefs | grep -e "^${item}_" | sed 's/^/_CONF_/' + misc_get_all_vardefs | env LANG=C grep -e "^${item}_" | sed 's/^/_CONF_/' done | sort -u > ${DBDIR}/conf/manipulated_defs.sh ) || { message_echo "ERROR: Failed to manipulate available variable definitions from the configuration file." >&2; exit 1; } } @@ -224,12 +224,12 @@ conf_manipulate_available_var_defs () # ============= Build an effective MOVED database ============= conf_build_effective_MOVED () { - grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "${PORTS_MOVED_DB}" > ${DBDIR}/conf/MOVED.parsed - misc_get_all_vardefs | grep -e '^_CONF_ALT_MOVED_' | cut -d = -f 1 | while read var + env LANG=C grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "${PORTS_MOVED_DB}" > ${DBDIR}/conf/MOVED.parsed + misc_get_all_vardefs | env LANG=C grep -e '^_CONF_ALT_MOVED_' | cut -d = -f 1 | while read var do eval movedsb_path=\${$var} cat "$movedsb_path" - done | grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' > ${DBDIR}/conf/MOVED_ALT.parsed || : + done | env LANG=C grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' > ${DBDIR}/conf/MOVED_ALT.parsed || : cat "${DBDIR}/conf/MOVED_ALT.parsed" >> ${DBDIR}/conf/MOVED.parsed } @@ -241,7 +241,7 @@ conf_setup_effective_env () do eval $key=\$\{_CONF_ENV_$key:-\$\{$key\}\} done - 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=' + 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=' ) echo '[ -n "$PKG_PATH" ] && PKGREPOSITORY=$PKG_PATH' echo 'conf_setup_ports_envs' @@ -257,7 +257,7 @@ conf_build_replacement_patterns_from_REPLACE () cp /dev/null "${DBDIR}/conf/REPLACE.filter" cp /dev/null "${DBDIR}/conf/REPLACE.sed_pattern" cp /dev/null "${DBDIR}/conf/REPLACE.csv" - misc_get_all_vardefs | grep -e '^_CONF_REPLACE_FROM_' | cut -d = -f 1 | while read var + misc_get_all_vardefs | env LANG=C grep -e '^_CONF_REPLACE_FROM_' | cut -d = -f 1 | while read var do eval glob_pattern=\$\{$var\} eval to=\$\{`echo "$var" | sed 's/^_CONF_REPLACE_FROM_/_CONF_REPLACE_TO_/'`\} diff --git a/lib/libdatabase_build.sh b/lib/libdatabase_build.sh index e814790..b697cdf 100644 --- a/lib/libdatabase_build.sh +++ b/lib/libdatabase_build.sh @@ -41,7 +41,7 @@ database_build_convert_and_register_origin_if_obsolete () echo "$origin" > ${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origin pkgsys_exists_port "$origin" && return database_build_register_obsolete_port "$origin" - grep -n -m 1 -E "^`str_escape_regexp \"$origin\"`\|" "$recursedb" 2> /dev/null > ${TMPDIR}/moved.info || : + env LANG=C grep -n -m 1 -E "^`str_escape_regexp \"$origin\"`\|" "$recursedb" 2> /dev/null > ${TMPDIR}/moved.info || : if [ `wc -l < ${TMPDIR}/moved.info` -eq 0 ] then fileedit_add_a_line_if_new "$origin" "${DBDIR}/obsolete_ports" @@ -206,7 +206,7 @@ database_build_setup_replace_node () rm -rf "$dbpath" mkdir -p "$dbpath" origin_trial=$origin_orig - if echo "$origin_orig" | grep -q -Fx -f "${DBDIR}/conf/REPLACE.filter" 2> /dev/null + if echo "$origin_orig" | env LANG=C grep -q -Fx -f "${DBDIR}/conf/REPLACE.filter" 2> /dev/null then origin_trial=`echo "$origin_orig" | sed -E -f "${DBDIR}/conf/REPLACE.sed_pattern"` if [ "x$origin_orig" != "x$origin_trial" ] @@ -279,9 +279,9 @@ database_build_get_inspected_level () then echo full elif ! pkgsys_exists_or_existed_from_orig "$origin" \ - || grep -qFx "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null \ + || env LANG=C grep -qFx "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null \ || [ ! -e "${DBDIR}/moved_from/$origin_dependent/installed_version" ] \ - || grep -qFx "$origin_dependent" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null + || env LANG=C grep -qFx "$origin_dependent" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null then echo direct else @@ -302,7 +302,7 @@ database_build_is_port_already_inspected_in_required_level () cat "${DBDIR}/ports.inspected.${inspected_level}.list" || : cat "${DBDIR}/moved_ports" || : cat "${DBDIR}/obsolete_ports" || : - } 2> /dev/null | grep -q -Fx "$origin_actual" || return + } 2> /dev/null | env LANG=C grep -q -Fx "$origin_actual" || return fileedit_rm_a_line "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect.remain" [ "x$origin" = "$origin_actual" ] || \ 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 () while read origin do database_build_get_new_pkgname "$origin" - done < $srcfile | grep -v '^[[:space:]]*$' | sort -u > $savefile + done < $srcfile | env LANG=C grep -v '^[[:space:]]*$' | sort -u > $savefile fi cat "$savefile" 2> /dev/null || : } @@ -471,7 +471,7 @@ database_build_determine_flavored_origin () if [ -n "$flavor_trial" ] then flavors_ptn="^("`database_build_make "$origin" -V FLAVORS 2> /dev/null | sed -E 's/[[:space:]]+/|/g'`")$" - echo "$flavor_trial" | grep -qE "$flavors_ptn" || flavor_trial= + echo "$flavor_trial" | env LANG=C grep -qE "$flavors_ptn" || flavor_trial= fi origin_trial=`pkgsys_compose_flavored_origin "$origin_unflavored" "$flavor_trial"` flavor=`database_build_make "$origin_trial" -V FLAVOR 2> /dev/null || :` @@ -576,7 +576,7 @@ database_build_inspect_dependencies () [ "x$origin_orig" = "x$origin" ] || fileedit_add_a_line_if_new "$origin_orig" "$frompath/initial_orig" [ -e "${DBDIR}/initial/$origin_orig/SUPPRESSED_SELF" ] && touch "$frompath/SUPPRESSED_SELF" [ -e "${DBDIR}/initial/$origin_orig/SUPPRESSED_PKGNG" ] && touch "$frompath/SUPPRESSED_PKGNG" - if ! grep -qFx "$origin" "${DBDIR}/done_required_ports_to_inspect" 2> /dev/null + if ! env LANG=C grep -qFx "$origin" "${DBDIR}/done_required_ports_to_inspect" 2> /dev/null then fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports" fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports" @@ -588,7 +588,7 @@ database_build_inspect_dependencies () # Notify reconfiguration of the port option conf_updated= if [ -e "$dbpath/complete_as_node" ] || \ - grep -q -Fx -e "$origin_orig" -e "$origin" "${DBDIR}/to_be_reconf" 2> /dev/null + env LANG=C grep -q -Fx -e "$origin_orig" -e "$origin" "${DBDIR}/to_be_reconf" 2> /dev/null then message_echo "${DEPTH_INDEX} ===> Reconfigured" conf_updated=y @@ -647,7 +647,7 @@ database_build_inspect_dependencies () do tr ' ' '\n' < ${TMPDIR}/database_build_inspect_dependencies:${tag}_depends_list | \ sed -E 's#.*:([^:/]+/[^:/]+|[^:/]+/[^:/]+:[^:/]*)$#\1#' | cut -d : -f 1 | sort -u | \ - grep -Ev "`pkgsys_pkgtools_ports_filter_regexp`" \ + env LANG=C grep -Ev "`pkgsys_pkgtools_ports_filter_regexp`" \ | while read origin_flavor_incomplete do ( set -e @@ -655,9 +655,9 @@ database_build_inspect_dependencies () database_build_determine_port_option "$origin_flavor_incomplete" ) database_build_determine_flavored_origin "$origin_flavor_incomplete" - done | grep -v '^$' | sort -u > $dbpath/requirements.$tag.orig || : + done | env LANG=C grep -v '^$' | sort -u > $dbpath/requirements.$tag.orig || : sed -E -f "${DBDIR}/conf/REPLACE.sed_pattern" "$dbpath/requirements.$tag.orig" \ - | grep -v '^$' | sort -u > $dbpath/requirements.$tag.src || : + | env LANG=C grep -v '^$' | sort -u > $dbpath/requirements.$tag.src || : done for stage in orig src do @@ -695,12 +695,12 @@ database_build_inspect_dependencies () inspected_level=`database_build_get_inspected_level "$origin" "$origin_dependent"` case $inspected_level in full ) - grep -v -Fx -f "${DBDIR}/installed_ports" \ + env LANG=C grep -v -Fx -f "${DBDIR}/installed_ports" \ "$dbpath/requirements.all.direct.src" > ${TMPDIR}/missing.$origin_id || : inspected_levels_compatible='full direct node' ;; direct ) - grep -v -Fx -f "${DBDIR}/installed_ports" \ + env LANG=C grep -v -Fx -f "${DBDIR}/installed_ports" \ "$dbpath/requirements.all.direct.src" > ${TMPDIR}/missing.$origin_id || : inspected_levels_compatible='direct node' ;; @@ -716,7 +716,7 @@ database_build_inspect_dependencies () do origin_dependency=`sed -n ${iline}p "${TMPDIR}/missing.$origin_id"` iline=$(($iline+1)) - grep -q -Fx "$origin_dependency" "${DBDIR}/ports.inspected.list" 2> /dev/null && \ + env LANG=C grep -q -Fx "$origin_dependency" "${DBDIR}/ports.inspected.list" 2> /dev/null && \ continue database_build_inspect_dependencies "$origin_dependency" "$origin" done @@ -737,7 +737,7 @@ database_build_inspect_dependencies () # Transfer data from the previous database if existent, successful and no change pkg_new=`cat "$dbpath/new_version"` if [ ! -e "$dbpath/conf_updated" -a -d "$dbpath_prev" ] && pkg_info_e "$pkg_new" 2> /dev/null && \ - ! grep -qFx "$origin" "$dbpath_prev/to_be_reconf" 2> /dev/null + ! env LANG=C grep -qFx "$origin" "$dbpath_prev/to_be_reconf" 2> /dev/null then same_as_prevset=yes for dbfile in new_version CONFLICT.conf BUILDCONFLICT.conf MARG.conf MENV.conf \ @@ -772,7 +772,7 @@ database_build_inspect_dependencies () then for dbfile in failed.list damaged_package manually_done.list do - if grep -qFx "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null + if env LANG=C grep -qFx "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null then same_as_prevset=no break @@ -799,7 +799,7 @@ database_build_inspect_dependencies () done } | while read dbfile do - if grep -Fxq "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null + if env LANG=C grep -Fxq "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null then fileedit_add_a_line_if_new "$origin" "${DBDIR}/$dbfile" fi @@ -856,7 +856,7 @@ database_build_filter_ignored_requirements () pattern=${DBDIR}/requires/$origin/ignored_requirements.filter if [ -e "$pattern" ] then - grep -Fxvq -f "$pattern" + env LANG=C grep -Fxvq -f "$pattern" else cat fi 2> /dev/null || : @@ -882,9 +882,9 @@ database_build_get_complete_recursive_dependency () then touch "$tmppath.parents" num_parents=`wc -l < $tmppath.parents` - if grep -Fxq "$origin" "$tmppath.parents" + if env LANG=C grep -Fxq "$origin" "$tmppath.parents" then - loophead=`grep -Fxn "$origin" "$tmppath.parents" | tail -n 1 | cut -d : -f 1` + loophead=`env LANG=C grep -Fxn "$origin" "$tmppath.parents" | tail -n 1 | cut -d : -f 1` if [ "x$opt_force_continuation_for_looped_dependency" = xno ] then message_echo "ERROR: The following loop was found for requirements.${tag}${suffix}:" >&2 @@ -913,8 +913,8 @@ database_build_get_complete_recursive_dependency () origin_target=`sed -n ${index_loop}p "$tmppath.ports_in_loop"` origin_ref=`sed -n $((${index_loop}+1))p "$tmppath.ports_in_loop"` dbpath_target=${DBDIR}/requires/$origin_target - if ! grep -Fxq "$origin_ref" "$dbpath_target/requirements.run.direct${suffix}" 2> /dev/null || \ - ! grep -Fxq "$origin_ref" "$dbpath_target/requirements.build.direct${suffix}" 2> /dev/null + if ! env LANG=C grep -Fxq "$origin_ref" "$dbpath_target/requirements.run.direct${suffix}" 2> /dev/null || \ + ! env LANG=C grep -Fxq "$origin_ref" "$dbpath_target/requirements.build.direct${suffix}" 2> /dev/null then message_echo 'INFO: The dependency of '$origin_target' on '$origin_ref' is ignored to terminate the loop.' >&2 break @@ -929,7 +929,7 @@ database_build_get_complete_recursive_dependency () do for tag_tmp in run build do - grep -Fxq "$origin_ref" "$dbpath_target/requirements.${tag_tmp}.direct${suffix_tmp}" 2> /dev/null && \ + env LANG=C grep -Fxq "$origin_ref" "$dbpath_target/requirements.${tag_tmp}.direct${suffix_tmp}" 2> /dev/null && \ fileedit_add_a_line_if_new "$origin_ref" "$dbpath_target/ignored_requirements.${tag_tmp}${suffix_tmp}" done 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 () [ "x$tag" = xbuild ] && tag_dep=run recursive_dependency=`database_build_get_complete_recursive_dependency "$tag_dep" "$origin_requirement" "$suffix"` [ -e "$dbpath/ignored_requirements.filter" ] && \ - echo "$origin_requirement" | grep -Fxq -f "$dbpath/ignored_requirements.filter" 2> /dev/null && \ + echo "$origin_requirement" | env LANG=C grep -Fxq -f "$dbpath/ignored_requirements.filter" 2> /dev/null && \ continue echo "$origin_requirement" echo "$recursive_dependency" @@ -957,7 +957,7 @@ database_build_get_complete_recursive_dependency () mv "$tmppath.parents.tmp" "$tmppath.parents" if [ ! -e "$dstfile" ] then - sort -u "$dstfile_tmp" | grep -v '^$' > $dstfile || : + sort -u "$dstfile_tmp" | env LANG=C grep -v '^$' > $dstfile || : rm "$dstfile_tmp" fi fi @@ -1095,7 +1095,7 @@ database_build_order_ports_considering_dependencies () (cd "${DBDIR}/requires" && \ find . -depth 3 -name requirements.all.full -exec echo {} \; -exec cat {} \; -exec echo \;) | \ env "DBDIR=${DBDIR}" awk -f "${LIBEXECDIR}"/order_dependencies.awk || return - grep -v '^$' "${DBDIR}/reinst_order.list.tmp" > "${DBDIR}/reinst_order.list" || : + env LANG=C grep -v '^$' "${DBDIR}/reinst_order.list.tmp" > "${DBDIR}/reinst_order.list" || : } # ============= [Sub-function] Common operations for resetting configurations for a port ============= @@ -1187,7 +1187,7 @@ database_build_post_inspect_dependencies () cat "${DBDIR}/conf/HOLD:PORTS.parsed" || : cat "${DBDIR}/need.list" || : } 2> /dev/null | sort -u > $tmpfile.obsolete_ports.exclude - grep -v -Fx -f "$tmpfile.obsolete_ports.exclude" "${DBDIR}/obsolete_ports" > ${DBDIR}/obsolete_ports.can_be_deleted || : + env LANG=C grep -v -Fx -f "$tmpfile.obsolete_ports.exclude" "${DBDIR}/obsolete_ports" > ${DBDIR}/obsolete_ports.can_be_deleted || : cp /dev/null "${DBDIR}/REPLACE.complete_sed_pattern.tmp" find "${DBDIR}/replace" -depth 3 -type f -name origin | while read nodepath do @@ -1200,7 +1200,7 @@ database_build_post_inspect_dependencies () mv "${DBDIR}/REPLACE.complete_sed_pattern.tmp" "${DBDIR}/REPLACE.complete_sed_pattern" if [ `cat "${DBDIR}/inspected_ports.update" 2> /dev/null | wc -l` -gt 0 ] then - grep -Fx -f "${DBDIR}/inspected_ports.all" "${DBDIR}/inspected_ports.update" \ + env LANG=C grep -Fx -f "${DBDIR}/inspected_ports.all" "${DBDIR}/inspected_ports.update" \ > ${DBDIR}/inspected_ports.update.tmp 2> /dev/null || : mv "${DBDIR}/inspected_ports.update.tmp" "${DBDIR}/inspected_ports.update" if [ $opt_only_target_scope = yes ] diff --git a/lib/libdatabase_maintain.sh b/lib/libdatabase_maintain.sh index d4da230..3d55cd9 100644 --- a/lib/libdatabase_maintain.sh +++ b/lib/libdatabase_maintain.sh @@ -52,7 +52,7 @@ database_maintain_create () misc_lock_duplicated_executions "${DBDIR}/.lock" if [ -e "${DBDIR}/MYVERSION" ] then - if ! grep -q -E "$COMPATIBLE_VERSIONS" "${DBDIR}/MYVERSION" 2> /dev/null + if ! env LANG=C grep -q -E "$COMPATIBLE_VERSIONS" "${DBDIR}/MYVERSION" 2> /dev/null then message_echo "ERROR: The current temporary database is incompatible. You must delete it by" >&2 message_echo " ${APPNAME} clean force" >&2 diff --git a/lib/libdatabase_query.sh b/lib/libdatabase_query.sh index b62dbcd..03908b7 100644 --- a/lib/libdatabase_query.sh +++ b/lib/libdatabase_query.sh @@ -16,10 +16,10 @@ database_query_show_list_failure () message_echo "INFO: No item is registered in this list." return 1 fi - grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern" "${DBDIR}/failed.list" 2> /dev/null \ + env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern" "${DBDIR}/failed.list" 2> /dev/null \ | while read origin do - grep -q -Fx "$origin" "${DBDIR}/stage.loop_list/ports_to_delete" 2> /dev/null \ + env LANG=C grep -q -Fx "$origin" "${DBDIR}/stage.loop_list/ports_to_delete" 2> /dev/null \ || echo "$origin" done > $tmp_valid if [ `cat "$tmp_valid" 2> /dev/null | wc -l` -eq 0 ] @@ -31,7 +31,7 @@ database_query_show_list_failure () do note=`cat "${DBDIR}/notes/$origin/note_failtre" 2> /dev/null || :` resolved=no - grep -q -Fx "$origin" "${DBDIR}/manually_done.list" 2> /dev/null && resolved=yes + env LANG=C grep -q -Fx "$origin" "${DBDIR}/manually_done.list" 2> /dev/null && resolved=yes pkgtag=`cat "${DBDIR}/moved_from/$origin/pkgtag" 2> /dev/null || :` if [ $opt_batch_mode = no ] then @@ -66,11 +66,11 @@ database_query_show_list_failed_conflicts_restoration () message_echo "INFO: No item is registered in this list." return 1 fi - grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" \ + env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" \ | while read origin pkg do pkg_regexp=`str_escape_regexp "$pkg"` - against=`grep -E "^$pkg_regexp:" "${DBDIR}/forbidden_conflicts" 2> /dev/null | cut -d : -f 2,3 | sort -u` + against=`env LANG=C grep -E "^$pkg_regexp:" "${DBDIR}/forbidden_conflicts" 2> /dev/null | cut -d : -f 2,3 | sort -u` if [ $opt_batch_mode = no ] then if [ -n "$pkg" ] @@ -256,7 +256,7 @@ database_query_is_default_conf () echo "Non-default port options," >> $tmp_msg is_customized=yes fi - if grep -q -Fx "$origin" "${DBDIR}/conf/NOPKG:PORTS.parsed" 2> /dev/null + if env LANG=C grep -q -Fx "$origin" "${DBDIR}/conf/NOPKG:PORTS.parsed" 2> /dev/null then echo "Explicit specification as non-default in ${APPNAME}.conf," >> $tmp_msg is_customized=yes @@ -546,7 +546,7 @@ database_query_show_single_list () matches_negative=no for negative_listdb in $flag_negative_listdb do - if grep -qFx "$origin" "${DBDIR}/$negative_listdb" 2> /dev/null + if env LANG=C grep -qFx "$origin" "${DBDIR}/$negative_listdb" 2> /dev/null then matches_negative=yes break @@ -833,8 +833,8 @@ database_query_exists_in_list () list=`ls "${DBDIR}"/fossil_pkgs/fossil_since_* | head -n 1` ;; conflict ) - grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" 2> /dev/null \ - | grep -q -E "^${origin_esc}[[:space:]]" + env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" 2> /dev/null \ + | env LANG=C grep -q -E "^${origin_esc}[[:space:]]" return ;; taboo ) @@ -856,7 +856,7 @@ database_query_exists_in_list () list=stage.loop_list/ports_to_delete ;; esac - grep -q -Fx "$origin" "${DBDIR}/$list" 2> /dev/null + env LANG=C grep -q -Fx "$origin" "${DBDIR}/$list" 2> /dev/null } # ============= Check whether the requirements of installed packages match the port configuration ============= @@ -870,7 +870,7 @@ database_query_dependency_matching () pkg=`database_build_get_new_pkgname "$origin"` [ -n "$pkg" ] || return pkg_info_e "$pkg" || return - pkg_info_qr "$pkg" | grep -v '^[[:space:]]*$' | sort -u > $tmp_inst + pkg_info_qr "$pkg" | env LANG=C grep -v '^[[:space:]]*$' | sort -u > $tmp_inst database_build_get_full_run_requirement_pkgs "$origin" > $tmp_db diff "$tmp_inst" "$tmp_db" > /dev/null 2>/dev/null } @@ -883,7 +883,7 @@ database_query_are_requirements_not_locked () cat "${DBDIR}/requires/$origin/requirements.all.direct" 2> /dev/null | while read origin_requirement do pkg_requirement=`pkgsys_get_installed_pkg_from_origin "$origin_requirement"` || : - if grep -q -Fx "$origin_requirement" "${DBDIR}/freeze.all.list" 2> /dev/null + if env LANG=C grep -q -Fx "$origin_requirement" "${DBDIR}/freeze.all.list" 2> /dev/null then [ -n "$pkg_requirement" ] || return elif [ -z "$pkg_requirement" ] @@ -916,3 +916,21 @@ database_query_initial_orgins () fi : } + +# ============= Get an unflavored or flavored equivalence of an origin with the same package name, which is deemed the same version ============= +# If the input is unflavored and a flavored equivalence is inspected as a required port, the flavored origin is returned. +# If the input is flavored and an unflavored equivalence is inspected as a required port, the unflavored origin is returned. +# Otherwise, a blank value is returned. +database_query_get_equivalent_orgin () +{ + local origin origin_esc pkg_origin pkg_origin_esc flavor origin_unflavored_esc origin_search + origin=$1 + origin_esc=`str_escape_regexp "$origin"` + pkg_origin=`env LANG=C grep -E "[[:space:]]$origin_esc$" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" | cut -f 2 || :` + [ -n "$pkg_origin" ] || return 0 + pkg_origin_esc=`str_escape_regexp "$pkg_origin"` + flavor=`pkgsys_get_flavor_from_origin "$origin"` + origin_search=$origin_unflavored_esc$ + [ -n "$flavor" ] || origin_search=$origin_esc@ + env LANG=C grep -E "^$pkg_origin_esc[[:space:]]$origin_search" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" | cut -f 2 | head -n 1 || : +} diff --git a/lib/libdatabase_record.sh b/lib/libdatabase_record.sh index efef554..6117384 100644 --- a/lib/libdatabase_record.sh +++ b/lib/libdatabase_record.sh @@ -33,7 +33,7 @@ database_record_success () { cat "$nodedir/requirements.$dbsuffix" 2> /dev/null [ $level = full ] && cat "$nodedir/ignored_requirements.$tag" 2> /dev/null - } | grep -q -Fx -f "${DBDIR}/failed.list" 2> /dev/null + } | env LANG=C grep -q -Fx -f "${DBDIR}/failed.list" 2> /dev/null then fileedit_rm_a_line "$origin" "${DBDIR}/success.$dbsuffix.list" fileedit_add_a_line_if_new "$origin" "${DBDIR}/todo_after_requirements_succeed.$dbsuffix.list" diff --git a/lib/libdeinstall.sh b/lib/libdeinstall.sh index 096c7e2..db53f87 100644 --- a/lib/libdeinstall.sh +++ b/lib/libdeinstall.sh @@ -20,11 +20,11 @@ deinstall_select_leaf_ports_to_delete_dialog () do pkgtag=`cat "${DBDIR}/moved_from/$origin/pkgtag" 2> /dev/null` || : val=on - grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off + env LANG=C grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off printf '%s\t"(%s)"\t%s\n' "$origin" "$pkgtag" "$val" done < $src > $itemlist misc_dialog_checklist "$title" "$desc" "$dst_selected" "$itemlist" - grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || : + env LANG=C grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || : } # ============= Automatic selection of removing ports ============= @@ -41,11 +41,11 @@ deinstall_select_auto () cat "$dst_add" "$dst_rem" 2> /dev/null | sort -u > $tmp_srcprev cat "$src" 2> /dev/null | sort -u > $tmp_srcnew fileedit_manipulate_old_new_lines "$tmp_srcprev" "$tmp_srcnew" "$diff_removed" "$diff_added" || return 0 - grep -v -Fx -f "$diff_removed" "$dst_rem" 2> /dev/null | \ - grep -Fx -f "$src" > $dst_rem.tmp || : + env LANG=C grep -v -Fx -f "$diff_removed" "$dst_rem" 2> /dev/null | \ + env LANG=C grep -Fx -f "$src" > $dst_rem.tmp || : mv "$dst_rem.tmp" "$dst_rem" cat "$dst_add" "$diff_added" 2> /dev/null | sort -u | \ - grep -Fx -f "$src" > $dst_add.tmp || : + env LANG=C grep -Fx -f "$src" > $dst_add.tmp || : mv "$dst_add.tmp" "$dst_add" } @@ -109,11 +109,11 @@ deinstall_select_obsolete_ports_to_delete_dialog () do pkgtag=`cat "${DBDIR}/initial/$origin/installed_version"` val=on - grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off + env LANG=C grep -Fxq "$origin" "$dst_unselected" 2> /dev/null && val=off printf '%s\t"(%s)"\t%s\n' "$origin" "$pkgtag" "$val" done < $src > $itemlist misc_dialog_checklist "$title" "$desc" "$dst_selected" "$itemlist" - grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || : + env LANG=C grep -Fx -v -f "$dst_selected" "$src" > $dst_unselected || : } # ============= Selection of removing obsolete ports ============= @@ -217,7 +217,7 @@ deinstall_exec () for origin in `{ echo "$origin_master"; database_query_initial_orgins "$origin_master"; } | sort -u` do origin_regexp=`str_escape_regexp "$origin"` - grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || : + env LANG=C grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || : mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts" currentpkg=`pkgsys_get_installed_pkg_from_origin "$origin" | tr '\n' ' ' | sed 's/ *$//'` [ -n "$currentpkg" ] || continue @@ -248,7 +248,7 @@ deinstall_exec () backup_pkgdir=${PKGREPOSITORY} fi mkdir -p "$backup_pkgdir" - pkg=`echo "$currentpkg" | tr ' ' '\n' | grep -v '^$' | tail -n 1` + pkg=`echo "$currentpkg" | tr ' ' '\n' | env LANG=C grep -v '^$' | tail -n 1` backup_pkg=`pkgsys_create_backup_pkg "$pkg" "$backup_pkgdir"` || : if [ -n "$backup_pkg" ] then @@ -260,7 +260,7 @@ deinstall_exec () fi fi message_echo "-- (Deleting package for $origin as $currentpkg)" - echo "$currentpkg" | tr ' ' '\n' | grep -v '^$' | while read pkg + echo "$currentpkg" | tr ' ' '\n' | env LANG=C grep -v '^$' | while read pkg do if ! pkg_delete_f "$currentpkg" then diff --git a/lib/libfileedit.sh b/lib/libfileedit.sh index 6d8a8ef..007ca4e 100644 --- a/lib/libfileedit.sh +++ b/lib/libfileedit.sh @@ -15,7 +15,7 @@ fileedit_rm_a_line () [ -n "$item" ] || return 0 [ -e "$dstpath" ] || return 0 tmpfile=$dstpath.fileedit_rm_a_line.tmp - grep -v -Fx "$item" "$dstpath" 2> /dev/null > $tmpfile || : + env LANG=C grep -v -Fx "$item" "$dstpath" 2> /dev/null > $tmpfile || : mv "$tmpfile" "$dstpath" } @@ -31,7 +31,7 @@ fileedit_add_a_line_if_new () if [ -e "$dstpath" ] then cp "$dstpath" "$tmpfile" - grep -q -Fx "$item" "$dstpath" \ + env LANG=C grep -q -Fx "$item" "$dstpath" \ || echo "$item" >> $tmpfile else dstdir=`dirname "$dstpath"` @@ -77,7 +77,7 @@ fileedit_add_lines_if_new () then while read origin do - grep -q -Fx "$origin" "$dstpath" \ + env LANG=C grep -q -Fx "$origin" "$dstpath" \ || echo "$origin" done > $tmpclip if [ "@$advance" = @advance ] @@ -110,8 +110,8 @@ fileedit_manipulate_old_new_lines () newdiff=$4 [ -e "$oldsrc" ] || oldsrc=/dev/null [ -e "$newsrc" ] || newsrc=/dev/null - grep -vFx -f "$newsrc" "$oldsrc" > $olddiff 2> /dev/null || : - grep -vFx -f "$oldsrc" "$newsrc" > $newdiff 2> /dev/null || : + env LANG=C grep -vFx -f "$newsrc" "$oldsrc" > $olddiff 2> /dev/null || : + env LANG=C grep -vFx -f "$oldsrc" "$newsrc" > $newdiff 2> /dev/null || : [ `cat "$olddiff" "$newdiff" | wc -l` -gt 0 ] } @@ -123,7 +123,7 @@ fileedit_manipulate_old_lines () newsrc=$2 [ -e "$oldsrc" ] || oldsrc=/dev/null [ -e "$newsrc" ] || newsrc=/dev/null - grep -vFx -f "$newsrc" "$oldsrc" 2> /dev/null + env LANG=C grep -vFx -f "$newsrc" "$oldsrc" 2> /dev/null } # ============= Manipulate new lines from an old and a new versions of a file ============= @@ -134,7 +134,7 @@ fileedit_manipulate_new_lines () newsrc=$2 [ -e "$oldsrc" ] || oldsrc=/dev/null [ -e "$newsrc" ] || newsrc=/dev/null - grep -vFx -f "$oldsrc" "$newsrc" 2> /dev/null + env LANG=C grep -vFx -f "$oldsrc" "$newsrc" 2> /dev/null } # ============= 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 () newsrc=$2 [ -e "$oldsrc" ] || oldsrc=/dev/null [ -e "$newsrc" ] || newsrc=/dev/null - grep -qvFx -f "$newsrc" "$oldsrc" 2> /dev/null + env LANG=C grep -qvFx -f "$newsrc" "$oldsrc" 2> /dev/null } diff --git a/lib/libfs.sh b/lib/libfs.sh index 7bfeb0a..eedb7b3 100644 --- a/lib/libfs.sh +++ b/lib/libfs.sh @@ -152,14 +152,17 @@ fs_get_actual_mount_point_pattern () # ============= Get mount info at the descendant directory levels required for builder chroot environment ============= fs_get_descendant_mount_info () { - local mountpoint mountpoint_real_regexp basedir + local mountpoint mountpoint_real_regexp basedir basedir_ptn zpools_ptn ptns mountpoint=$1 mountpoint_real_regexp=`fs_get_actual_mount_point_pattern "$mountpoint"` || return basedir=`fs_get_system_basedir` basedir_ptn=`str_escape_regexp "$basedir"` - df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp\/" | while read fs data + zpools_ptn=`zpool list -H -o name | str_escape_regexp_filter | tr \\n '|' | sed 's/|$//'` + ptns='/|:' + [ -z "$zpools_ptn" ] || ptns="$ptns|$zpools_ptn" + df | sed 1d | env LANG=C grep -E "%[[:space:]]+$mountpoint_real_regexp\/" | while read fs data do - echo "$fs" | grep -q -e '^/' -e '^:' && fs=normal + echo "$fs" | env LANG=C grep -Eq "^$ptns" && fs=normal mp_abs=`echo "$data" | sed -E 's|.*%[[:space:]]+(/.+)$|\1|'` mp=`echo "$mp_abs" | sed -E "s|^$basedir_ptn||"` relative=`echo "$mp_abs" | sed -E "s|^$mountpoint_real_regexp||"` @@ -186,7 +189,7 @@ fs_fix_unionfs_image_if_hidden () needlepath_cur=$needlepath_next done [ -e "$needlepath" ] && return - if [ -n "$needlepath_lowest_exist" ] && df "$needlepath_lowest_exist" | sed 1d | grep -q '^:' + if [ -n "$needlepath_lowest_exist" ] && df "$needlepath_lowest_exist" | sed 1d | env LANG=C grep -q '^:' then message_echo "ERROR: Failed to recover a lost mandatory file, probably due to the bug of unionfs: $needlepath" >&2 mkdir -p "${DBDIR}/execflag" @@ -206,19 +209,19 @@ fs_chk_mounted () mountpoint=`str_regularize_df_path "$3"` target_ptn=`str_escape_regexp "$target"` mountpoint_real_regexp=`str_escape_regexp "$mountpoint"` - tmpsrc=`df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp$"` + tmpsrc=`df | sed 1d | env LANG=C grep -E "%[[:space:]]+$mountpoint_real_regexp$"` case $type in nullfs ) - echo "$tmpsrc" | grep -qE "^${target_ptn}[[:space:]]" && return + echo "$tmpsrc" | env LANG=C grep -qE "^${target_ptn}[[:space:]]" && return ;; unionfs ) - echo "$tmpsrc" | grep -qE "^:${target_ptn}[[:space:]]" && return + echo "$tmpsrc" | env LANG=C grep -qE "^:${target_ptn}[[:space:]]" && return ;; devfs | fdescfs | procfs | linprocfs | tmpfs ) - echo "$tmpsrc" | grep -q "^$type" && return + echo "$tmpsrc" | env LANG=C grep -q "^$type" && return ;; *) - message_echo "ERROR: Unsupported fyle system [$type]" >&2 + message_echo "ERROR: Unsupported file system [$type]" >&2 exit 1 ;; esac diff --git a/lib/libmain.sh b/lib/libmain.sh index 6018f2d..9a0f752 100644 --- a/lib/libmain.sh +++ b/lib/libmain.sh @@ -13,7 +13,7 @@ main_set_version () COMPATIBLE_VERSIONS='^(4\.[1]\.[0-9])$' # Template for development versions MYVERSION=4.1.0+toward_4.1.1_20211011024526 - COMPATIBLE_VERSIONS='^(4\.[0-1]\.[0-9]]|4\.[0]\.[0]+(|\+toward_4\.[0-1]\.[0-9]+_[0-9]+))$' + COMPATIBLE_VERSIONS='^(4\.[0-1]\.[0-9]]|4\.[0-1]\.[0]+(|\+toward_4\.[0-1]\.[0-9]+_[0-9]+))$' } # ============= Parse options, arguments and control parameters ============= @@ -523,7 +523,7 @@ main_reflect_conf_changes () if fileedit_manipulate_old_new_lines \ "${DBDIR}/conf.prev/setenv.sh" "${DBDIR}/conf/setenv.sh" "$tmpfile_old" "$tmpfile_new" then - if grep -q -e ^LOCALBASE= -e ^LINUXBASE= -e ^PORTSDIR= "$tmpfile_old" "$tmpfile_new" + if env LANG=C grep -q -e ^LOCALBASE= -e ^LINUXBASE= -e ^PORTSDIR= "$tmpfile_old" "$tmpfile_new" then message_echo "ERROR: Migration of the temporary database is unavailable because LOCALBASE, LINUXBASE or PORTSDIR was changed." >&2 message_echo " ${APPNAME} clean" >&2 diff --git a/lib/libmisc.sh b/lib/libmisc.sh index bf83892..44500d2 100644 --- a/lib/libmisc.sh +++ b/lib/libmisc.sh @@ -56,7 +56,7 @@ misc_get_all_vardefs () # ============= Initialize shell variable definitions ============= misc_init_vardefs () { - eval `misc_get_all_vardefs | grep -E '^[a-z_][a-zA-Z0-9_]+=' | sed 's/=.*//;s/^/unset /'` + eval `misc_get_all_vardefs | env LANG=C grep -E '^[a-z_][a-zA-Z0-9_]+=' | sed 's/=.*//;s/^/unset /'` } # ============= Get the size of the current console ============= diff --git a/lib/liboptions.sh b/lib/liboptions.sh index 83a1e4a..565d687 100644 --- a/lib/liboptions.sh +++ b/lib/liboptions.sh @@ -12,7 +12,7 @@ OPTIONS_SHIFT=0 # ============= Database of options which are given at each run and not saved ============= # [Syntax of option databases] -# short_name, long_name, variable, defult_vaule, set_value +# short_name, long_name, variable, default_value, set_value # Columns are delimited by tab characters. options_db_onetime () { @@ -48,9 +48,44 @@ options_db_saved_and_non_renewable () eof } + +# ============= Definitions of value regulator functions ============= +options_db_value_regulators () +{ + cat << eof +eof +} + # ============= Regularize the option value ============= options_regularize () { + local nlines iline srcline var fnc + options_db_value_regulators > ${TMPDIR}/options_regularize::db + nlines=`wc -l < ${TMPDIR}/options_regularize::db` + iline=1 + while [ $iline -le $nlines ] + do + srcline=`sed -n ${iline}p "${TMPDIR}/options_regularize::db"` + var=`echo "$srcline" | cut -f 1` + fnc=`echo "$srcline" | cut -f 2` + eval $var=\`$fnc \"\$$var\"\` + iline=$(($iline+1)) + done +} + +# ============= Regularize a value of an option value ============= +options_regularize_a_value () +{ + local variable value fnc + variable=$1 + value=$2 + fnc=`options_db_value_regulators | grep "^$variable[[:space:]]" | cut -f 2` + if [ -n "$fnc" ] + then + eval $fnc "$value" + else + echo "$value" + fi } # ============= Database of all options to be saved ============= @@ -114,7 +149,7 @@ options_convert_shortname_to_varname () { local shortname shortname=$1 - options_db_all | grep -m 1 "^${shortname}[[:space:]]" | cut -f 3 | sort -u + options_db_all | env LANG=C grep -m 1 "^${shortname}[[:space:]]" | cut -f 3 | sort -u } # ============= Dump all command line arguments and options ============= @@ -144,7 +179,7 @@ options_set_default () # ============= Get the argument for getopts ============= options_getopts_arg () { - options_db_all | cut -f 1,5 | grep -v '^[[:space:]]' | sort -u \ + options_db_all | cut -f 1,5 | env LANG=C grep -v '^[[:space:]]' | sort -u \ | sed -E 's/[[:space:]]:$/:/;s/[[:space:]].*$//' | tr -d '\n' } @@ -157,7 +192,7 @@ options_getopts_only_short () while getopts $getopts_option option > /dev/null do val=`str_escape_replaceval "$OPTARG"` - command=`options_db_all | grep -m 1 "^${option}[[:space:]]" \ + command=`options_db_all | env LANG=C grep -m 1 "^${option}[[:space:]]" \ | cut -f 3,5 | sed -E 's/[[:space:]]/=/;s/:$/'$val'/' || :` [ -n "$command" ] || return 1 echo -n "$command;OPTIND=$OPTIND;" @@ -182,7 +217,7 @@ options_getopts () [ $# -eq 0 ] && break erropt=$1 option=`expr "x$1" : '^x--\([a-zA-Z0-9][a-zA-Z0-9-]*\).*'` || break - command=`options_db_all | cut -f 2,3,5 | grep -m 1 "^${option}[[:space:]]" \ + command=`options_db_all | cut -f 2,3,5 | env LANG=C grep -m 1 "^${option}[[:space:]]" \ | cut -f 2,3 | sed -E 's/[[:space:]]/=/' || :` [ -n "$command" ] || break if expr "$command" : '^[^=]*=:$' > /dev/null @@ -208,21 +243,23 @@ options_getopts () # ============= Filter option value definitions to pick up selected groups ============= options_filter () { - grep `options_db "$@" | cut -f 3 | sed 's/^/-e ^/;s/$/=/'` + env LANG=C grep `options_db "$@" | cut -f 3 | sed 's/^/-e ^/;s/$/=/'` } # ============= Compose an option set in a command line form from the current settings ============= options_inverse_parse () { - options_db "$@" | while read short_name long_name variable defult_vaule set_value + options_db "$@" | while read short_name long_name variable default_value set_value do + eval default_value_eval=$default_value + default_value_regular=`options_regularize_a_value "$variable" "$default_value_eval"` eval val=\$$variable - eval val_def=$defult_vaule + eval val_def=\$default_value_regular eval val_set=$set_value if [ "x$set_value" = x: ] then [ "x$val" = "x$val_def" ] \ - || misc_get_all_vardefs | grep -m 1 "^$variable=" \ + || misc_get_all_vardefs | env LANG=C grep -m 1 "^$variable=" \ | sed "s/^[^=]*=/-$short_name /" elif [ "x$val" = "x$val_set" ] then @@ -237,13 +274,15 @@ options_filter_configured () { local tmpptn tmpptn=${TMPDIR}/options_filter_configured:ptn - options_db "$@" | while read short_name long_name variable defult_vaule set_value + options_db "$@" | while read short_name long_name variable default_value set_value do + eval default_value_eval=$default_value + default_value_regular=`options_regularize_a_value "$variable" "$default_value_eval"` eval val=\$$variable - eval val_def=$defult_vaule + eval val_def=\$default_value_regular [ "x$val" = "x$val_def" ] || echo "^$variable=" done > $tmpptn - grep -f "$tmpptn" + env LANG=C grep -f "$tmpptn" } # ============= Check inclusion of invalid options intending to be renewed ============= @@ -298,7 +337,7 @@ options_select_new_ports_if_duplicated () itemlist=${TMPDIR}/options_select_new_ports_if_duplicated::itemlist cp /dev/null "$dstfile.tmp" echo "$optargs" | sed -E 's/[ :]+/\ -/g' | grep -v '^$' | sort -u > $globs_list +/g' | env LANG=C grep -v '^$' | sort -u > $globs_list nlines=`wc -l < $globs_list` iline=1 while [ $iline -le $nlines ] @@ -318,7 +357,7 @@ options_select_new_ports_if_duplicated () do if pkgsys_exists_or_existed_from_orig "$origin" \ || cat "${DBDIR}/installed_ports" "${DBDIR}/targets_specified_so_far" 2> /dev/null \ - | grep -q -Fx "$origin" + | env LANG=C grep -q -Fx "$origin" then echo "$origin" >> $tmp_existing_ports else diff --git a/lib/libpkgsys.sh b/lib/libpkgsys.sh index 8568f0f..2135359 100644 --- a/lib/libpkgsys.sh +++ b/lib/libpkgsys.sh @@ -229,7 +229,7 @@ pkgsys_fetch_legacy_remote () pkg_regexp=`str_escape_regexp "$pkg"` pkgsys_ready_checksum_file || return checksumpath=`pkgsys_ready_checksum_file__fetched_file` - validMD5=`grep -m 1 -E -e "^MD5[[:space:]]*\($pkg_regexp\.tbz\)[[:space:]]*=" "$checksumpath" | sed -E "s/^[^=]*=[[:space:]]*(.*)/\1/"` + validMD5=`env LANG=C grep -m 1 -E -e "^MD5[[:space:]]*\($pkg_regexp\.tbz\)[[:space:]]*=" "$checksumpath" | sed -E "s/^[^=]*=[[:space:]]*(.*)/\1/"` if [ -z "$validMD5" ] then message_echo "WARNING: No check sum for $pkg.tbz." >&2 @@ -297,7 +297,7 @@ pkgsys_is_dependency_of_a_legacypkg_latest () rm -rf "$tmp_extract" mkdir "$tmp_extract" tar xf "$pkgarc" -C "$tmp_extract" +CONTENTS - grep -e '^@pkgdep[[:space:]]' -e '^@comment[[:space:]]*DEPORIGIN:' "$tmp_extract/+CONTENTS" \ + env LANG=C grep -e '^@pkgdep[[:space:]]' -e '^@comment[[:space:]]*DEPORIGIN:' "$tmp_extract/+CONTENTS" \ | sed 's/^@pkgdep[[:space:]]*//;s/^@comment[[:space:]]*DEPORIGIN://' > $tmp_contents nlines=`wc -l < $tmp_contents` iline=1 @@ -442,7 +442,7 @@ pkgsys_def_pkgtools () { local glob_unflavored glob_unflavored=$1 - pkg query -g '%At\t%Av' "$glob_unflavored" 2> /dev/null | grep -E '^flavor[[:space:]]' | cut -f 2 + pkg query -g '%At\t%Av' "$glob_unflavored" 2> /dev/null | env LANG=C grep -E '^flavor[[:space:]]' | cut -f 2 } pkg_info_flavored_origin () { @@ -457,9 +457,9 @@ pkgsys_def_pkgtools () { local tmp_flavored tmp_flavored_ptn tmp_flavored_ptn=${TMPDIR}/pkg_info_all_flavored_origins:flavored_ptn - pkg query '%o\t%At\t%Av' 2> /dev/null | grep -E '^[^[:space:]]+[[:space:]]flavor[[:space:]]' | cut -f 1,3 | tr '\t' @ | sed 's/@$//' - pkg query '%n\t%At' 2> /dev/null | grep -E '^[^[:space:]]+[[:space:]]flavor$' | cut -f 1 > $tmp_flavored_ptn - pkg query '%n\t%o' 2> /dev/null | grep -vFx -f "$tmp_flavored_ptn" | cut -f 2 + 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/@$//' + pkg query '%n\t%At' 2> /dev/null | env LANG=C grep -E '^[^[:space:]]+[[:space:]]flavor$' | cut -f 1 > $tmp_flavored_ptn + pkg query '%n\t%o' 2> /dev/null | env LANG=C grep -vFx -f "$tmp_flavored_ptn" | cut -f 2 } pkg_check_sanity () { @@ -469,9 +469,9 @@ pkgsys_def_pkgtools () tmp_stderr=${TMPDIR}/pkgng:pkg_check_sanity:stderr pkg check -s "$pkg" > $tmp_stdout 2> $tmp_stderr || : { - grep '^[^:]*: checksum mismatch for ' "$tmp_stderr" | sed 's/^[^:]*: checksum mismatch for //' || : - grep '^[^:]*: missing file ' "$tmp_stderr" | sed 's/^[^:]*: missing file //' || : - if grep -q '^pkg: .*: No such file or directory$' "$tmp_stderr" # For the old specification of pkg(8) + env LANG=C grep '^[^:]*: checksum mismatch for ' "$tmp_stderr" | sed 's/^[^:]*: checksum mismatch for //' || : + env LANG=C grep '^[^:]*: missing file ' "$tmp_stderr" | sed 's/^[^:]*: missing file //' || : + if env LANG=C grep -q '^pkg: .*: No such file or directory$' "$tmp_stderr" # For the old specification of pkg(8) then pkg info -ql "$pkg" 2> /dev/null | while read filepath do @@ -720,16 +720,16 @@ pkgsys_def_pkgtools () PKGNG_AUTODEPS=NO PKGNG_PORTAUDIT_SITE='http=//portaudit.FreeBSD.org/auditfile.tbz' # Load configuration for pkg(1) - pkg_conf=`pkg query %Fp pkg 2> /dev/null | grep '/etc/pkg\.conf\.sample$' | sed 's/\.sample$//'` || : + pkg_conf=`pkg query %Fp pkg 2> /dev/null | env LANG=C grep '/etc/pkg\.conf\.sample$' | sed 's/\.sample$//'` || : [ -n "$pkg_conf" ] || pkg_conf=${MYPREFIX}/etc/pkg.conf - grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "$pkg_conf" 2> /dev/null \ - | grep -e '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*.*' \ + env LANG=C grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "$pkg_conf" 2> /dev/null \ + | env LANG=C grep -e '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*.*' \ | while read srcline do var=`expr "$srcline" : '^[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*:.*'` || : val=`expr "$srcline" : '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*\(.*\)'` || : eval PKGNG_$var=\$val - misc_get_all_vardefs | grep "^PKGNG_$var=" + misc_get_all_vardefs | env LANG=C grep "^PKGNG_$var=" done > ${TMPDIR}/pkgsys_def_pkgtools:pkg.conf.sh . "${TMPDIR}/pkgsys_def_pkgtools:pkg.conf.sh" } @@ -746,10 +746,10 @@ pkgsys_def_pkgtools () message_echo "INFO: Installing pkgng by legacy package tool." checksumpath=`pkgsys_ready_checksum_file__fetched_file` pkgname=`sed 's/^MD5[[:space:]]*(//;s/\.tbz)[[:space:]]*=[^=]*$//' "$checksumpath" \ - | grep -m 1 '^pkg-[0-9]'` || : + | env LANG=C grep -m 1 '^pkg-[0-9]'` || : [ -n "$pkgname" ] && pkg_inst_remote_wild "$pkgname" && return message_echo "INFO: Failed by package, so installing pkgng by port." - grep -Ev '^[[:space:]]*WITH_PKG(|NG)=' /etc/make.conf > ${TMPDIR}/make.conf 2> /dev/null || : + env LANG=C grep -Ev '^[[:space:]]*WITH_PKG(|NG)=' /etc/make.conf > ${TMPDIR}/make.conf 2> /dev/null || : echo WITHOUT_PKG=yes >> ${TMPDIR}/make.conf echo WITHOUT_PKGNG=yes >> ${TMPDIR}/make.conf dev_out=/dev/stdout @@ -851,7 +851,7 @@ pkgsys_def_pkgtools () } pkg_info_qR () { - pkg_info -qR "$@" 2> /dev/null | grep -v '^$' + pkg_info -qR "$@" 2> /dev/null | env LANG=C grep -v '^$' } pkg_info_Ex () { @@ -1123,6 +1123,7 @@ pkgsys_get_installed_pkg_from_glob () local glob regexp for glob in "$@" do + [ -z "$glob" ] && continue if regexp=`expr "$glob" : ':\(.*\)'` then pkg_info_Ex "$regexp" @@ -1158,7 +1159,7 @@ pkgsys_exists_or_existed_from_orig () local origin origin=$1 cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \ - | grep -q -Fx "$origin" || pkgsys_exists_from_orig "$origin" + | env LANG=C grep -q -Fx "$origin" || pkgsys_exists_from_orig "$origin" } # ============= Get the name of an initially installed package for a flavored origin ============= @@ -1221,7 +1222,7 @@ pkgsys_init_pkg_orig_by_ambiguous_matching () while : do pkg_regexp=`str_escape_regexp "$pkg"`$ambsuffix - grep -E "^${pkg_regexp}[[:space:]]" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \ + env LANG=C grep -E "^${pkg_regexp}[[:space:]]" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \ | cut -f 2 > $tmporigin norigins=`wc -l < $tmporigin` [ $norigins -gt 0 ] && break @@ -1298,23 +1299,23 @@ pkgsys_eval_ports_glob () glob_regexp_unflavored=`expr "$glob_regexp" : '\([^@]*\)' || :`$ glob_regexp_flavor=^`expr "$glob_regexp" : '[^@]*@\([^@]*\)' || :` - grep -E "$glob_regexp_unflavored" "$unflavored_origlist" 2>&1 | while read origin_unflavored + env LANG=C grep -E "$glob_regexp_unflavored" "$unflavored_origlist" 2>&1 | while read origin_unflavored do fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored" make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \ - tr '[:space:]' '\n' | grep -v '^$' | grep -E "$glob_regexp_flavor" | sed -E "s|^|$origin_unflavored@|" + tr '[:space:]' '\n' | env LANG=C grep -v '^$' | env LANG=C grep -E "$glob_regexp_flavor" | sed -E "s|^|$origin_unflavored@|" done { pkg_info_all_flavored_origins cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null - } | grep -E "$glob_regexp" 2>&1 || : + } | env LANG=C grep -E "$glob_regexp" 2>&1 || : else - grep -E "$glob_regexp" "$unflavored_origlist" 2>&1 | while read origin_unflavored + env LANG=C grep -E "$glob_regexp" "$unflavored_origlist" 2>&1 | while read origin_unflavored do origin_unflavored_rpl=`str_escape_replaceval "$origin_unflavored"` fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored" make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \ - tr '[:space:]' '\n' | grep -v '^$' > $tmp_flavors || : + tr '[:space:]' '\n' | env LANG=C grep -v '^$' > $tmp_flavors || : if [ `wc -l < $tmp_flavors` -gt 0 ] then sed -E "s|^|$origin_unflavored_rpl@|" "$tmp_flavors" @@ -1327,7 +1328,7 @@ pkgsys_eval_ports_glob () { pkg_info_all_flavored_origins cut -f 2 "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null - } | grep -E "$glob_regexp_allflavors" 2>&1 || : + } | env LANG=C grep -E "$glob_regexp_allflavors" 2>&1 || : else if expr "$glob" : '[a-z][a-zA-Z0-9_.+-]*[a-zA-Z0-9_.+]$' > /dev/null 2>&1 && \ [ `expr "$glob" : '.*-[0-9]' 2>&1` -eq 0 ] @@ -1336,7 +1337,7 @@ pkgsys_eval_ports_glob () else glob_regexp2=$glob_regexp fi - grep -n -E "$glob_regexp2" "$pkglist" 2>&1 | cut -d : -f 1 \ + env LANG=C grep -n -E "$glob_regexp2" "$pkglist" 2>&1 | cut -d : -f 1 \ | while read index do sed -n ${index}p "$unflavored_origlist" @@ -1345,7 +1346,7 @@ pkgsys_eval_ports_glob () origin_unflavored_rpl=`str_escape_replaceval "$origin_unflavored"` fs_fix_unionfs_image_if_hidden "${PORTSDIR}/$origin_unflavored" make -C "${PORTSDIR}/$origin_unflavored" -V FLAVORS 2> /dev/null | \ - tr '[:space:]' '\n' | grep -v '^$' > $tmp_flavors || : + tr '[:space:]' '\n' | env LANG=C grep -v '^$' > $tmp_flavors || : [ `wc -l < $tmp_flavors` -gt 0 ] || echo > $tmp_flavors sed -E "s/^/$origin_unflavored_rpl /" "$tmp_flavors" done | while read origin_unflavored flavor @@ -1353,20 +1354,20 @@ pkgsys_eval_ports_glob () if [ -n "$flavor" ] then if make -C "${PORTSDIR}/$origin_unflavored" package-name FLAVOR=$flavor 2> /dev/null | \ - grep -qE "$glob_regexp2" + env LANG=C grep -qE "$glob_regexp2" then echo "$origin_unflavored@$flavor" fi else if make -C "${PORTSDIR}/$origin_unflavored" package-name 2> /dev/null | \ - grep -qE "$glob_regexp2" + env LANG=C grep -qE "$glob_regexp2" then echo "$origin_unflavored" fi fi done || : glob_regexp2=`echo "$glob_regexp" | sed -E 's/\$*$//' 2>&1 || :`'[[:space:]]' - grep -E "$glob_regexp2" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \ + env LANG=C grep -E "$glob_regexp2" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \ | cut -f 2 || : pkg_info_Ex "$glob_regexp" | while read pkgname do @@ -1396,7 +1397,7 @@ pkgsys_create_backup_pkg () then pkgname_ptn=`str_escape_regexp "$pkgname"` backup_pkg=`ls "${TMPDIR}"/package.tmp | \ - grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || : + env LANG=C grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || : fi if [ -z "$backup_pkg" ] then @@ -1431,12 +1432,12 @@ pkgsys_delete_backup_pkg () local origin origin_regexp origin=$1 origin_regexp=`str_escape_regexp "$origin"` - grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \ + env LANG=C grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \ | cut -f 2 | while read pkgpath_cur do rm -f "$pkgpath_cur" done - grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" \ + env LANG=C grep -v -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" \ 2> /dev/null > ${DBDIR}/backup_pkgarcs.lst.tmp || : mv "${DBDIR}/backup_pkgarcs.lst.tmp" "${DBDIR}/backup_pkgarcs.lst" } @@ -1449,7 +1450,7 @@ pkgsys_get_backup_pkg () tmpnewest=${TMPDIR}/pkgsys_get_backup_pkg::newest origin_regexp=`str_escape_regexp "$origin"` rm -f "$tmpnewest" - grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \ + env LANG=C grep -E "^${origin_regexp}[[:space:]]" "${DBDIR}/backup_pkgarcs.lst" 2> /dev/null \ | cut -f 2 | while read pkgpath do pkgpath_newest=`cat "$tmpnewest" 2> /dev/null` || : @@ -1475,7 +1476,7 @@ pkgsys_chk_match_to_restored_files_by_backup_pkg () origin=$1 filelist=$2 dbfile=${DBDIR}/backup/$origin/previously_installed_files - grep -qFx -f "$filelist" "$dbfile" 2> /dev/null + env LANG=C grep -qFx -f "$filelist" "$dbfile" 2> /dev/null } # ============= Get a package name from a package archive file name ============= @@ -1497,7 +1498,7 @@ pkgsys_pkgname_to_pkgarc () if [ "x$PKGSYS_USE_PKGNG" = xyes ] then pkgname_ptn=`str_escape_regexp "$pkgname"` - pkgnode=`ls "$pkgdir" 2> /dev/null | grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || : + pkgnode=`ls "$pkgdir" 2> /dev/null | env LANG=C grep -m 1 -E "^${pkgname_ptn}\.(txz|tbz|tgz|tar|pkg)$"` || : elif [ -e "$pkgdir/$pkgname.tbz" ] then pkgnode=$pkgname.tbz @@ -1513,8 +1514,8 @@ pkgsys_eval_ports_glob_even_if_nonexistent () glob_pattern=$1 { pkgsys_eval_ports_glob "$glob_pattern" 2> /dev/null || : - echo "$glob_pattern" | grep -E '^[a-z]+/[a-zA-Z0-9_.+-]+(|@[a-zA-Z0-9_.+-]+)$' || : - } | grep -v -e '^$' | sort -u + echo "$glob_pattern" | env LANG=C grep -E '^[a-z]+/[a-zA-Z0-9_.+-]+(|@[a-zA-Z0-9_.+-]+)$' || : + } | env LANG=C grep -v -e '^$' | sort -u } # ============= Evaluate glob patterns and add/remove non-existing/existing ones of them to/from a file ============= @@ -1527,7 +1528,7 @@ pkgsys_register_evaluated_globs () dirpath=`dirname "$listpath"` tmp_evaluated=${TMPDIR}/pkgsys_register_evaluated_globs:pkgsys_eval_ports_glob echo "$@" | sed -E 's/[ :]+/\ -/g' | grep -v '^$' | sort -u | while read -r glob +/g' | env LANG=C grep -v '^$' | sort -u | while read -r glob do pkgsys_eval_ports_glob "$glob" > $tmp_evaluated [ `wc -l < $tmp_evaluated` -ge 1 ] || \ @@ -1583,7 +1584,7 @@ pkgsys_get_conflicting_pkgs_patterns () conflicts_config= ;; esac - echo "$conflicts $conflicts_makevar $conflicts_config" | tr ' ' '\n' | grep -v '^$' | sort -u + echo "$conflicts $conflicts_makevar $conflicts_config" | tr ' ' '\n' | env LANG=C grep -v '^$' | sort -u } # ============= Get conflicting installed packages of a port ============= @@ -1611,7 +1612,7 @@ pkgsys_chk_conflict_by_a_pkg () tmp_conflicts_ptn=${TMPDIR}/pkgsys_chk_conflict_by_a_pkg::conflicts_ptn pkgsys_get_conflicting_pkgs_patterns "$mode" "$origin" \ | str_convert_glob_to_regexp_pattern > $tmp_conflicts_ptn - echo "$pkg" | grep -q -E -f "$tmp_conflicts_ptn" + echo "$pkg" | env LANG=C grep -q -E -f "$tmp_conflicts_ptn" } # ============= Check whether installed files are lost or broken for a package ============= @@ -1642,7 +1643,7 @@ pkgsys_sanitychk_pkgcontents () break fi filename_esc=`str_escape_regexp "$filename"` - if file "$filename" | sed -E "s/^$filename_esc:[[:space:]]//" | grep -q '^ELF ' + if file "$filename" | sed -E "s/^$filename_esc:[[:space:]]//" | env LANG=C grep -q '^ELF ' then _is_reinstall_encouraged=yes break @@ -1683,7 +1684,7 @@ pkgsys_get_current_port_oprions_timestamp () { ls -lD %Y%m%d:%H%M%S "${PORT_DBDIR}" | if [ -n "$portdb_needle_regexp" ] then - grep -E "[[:space:]]$portdb_needle_regexp$" || : + env LANG=C grep -E "[[:space:]]$portdb_needle_regexp$" || : else cat fi @@ -1743,12 +1744,12 @@ pkgsys_get_changed_port_oprions () current_log=$2 tmp_log=${TMPDIR}/pkgsys_get_changed_port_oprions.log { - grep -vxF -f "$current_log" "$saved_log" || : - grep -vxF -f "$saved_log" "$current_log" || : - } | cut -w -f 1 | grep -v '^$' | sort -u > $tmp_log + env LANG=C grep -vxF -f "$current_log" "$saved_log" || : + env LANG=C grep -vxF -f "$saved_log" "$current_log" || : + } | cut -w -f 1 | env LANG=C grep -v '^$' | sort -u > $tmp_log if pkgsys_is_dialog4ports_used then - grep '_' "$tmp_log" || : + env LANG=C grep '_' "$tmp_log" || : else cat "$tmp_log" fi diff --git a/lib/libprogram.sh b/lib/libprogram.sh index 31bdb27..313ce47 100644 --- a/lib/libprogram.sh +++ b/lib/libprogram.sh @@ -174,7 +174,7 @@ program_exec_restartable_loop_operation () iline=$(($iline+1)) PROGRAM_STEP_PROGRESS=$(($PROGRAM_STEP_PROGRESS+1)) PROGRAM_STEP_COUNTER="[$PROGRAM_STEP_PROGRESS/$PROGRAM_NUM_STEPS $(($PROGRAM_STEP_PROGRESS*100/$PROGRAM_NUM_STEPS))%]" - if ! grep -q -Fx "$item" "$looplist.remain" 2> /dev/null + if ! env LANG=C grep -q -Fx "$item" "$looplist.remain" 2> /dev/null then [ $iline -gt $nlines ] && PROGRAM_STEP_COUNTER_LAST_SKIPPED=yes continue diff --git a/lib/libreinstall.sh b/lib/libreinstall.sh index d24eca7..74731bc 100644 --- a/lib/libreinstall.sh +++ b/lib/libreinstall.sh @@ -25,23 +25,23 @@ reinstall_skip () message_target_relations "$REINSTALL_ORIGIN" } -# ============= Check whether a package is forbidden due to conflict ============= +# ============= Check whether a package is forbidden due to conflict (only by referring to the record) ============= reinstall_quick_chk_forbidden_conflicts () { local pkg pkg_regexp_esc pkg=$1 pkg_regexp_esc=`str_escape_regexp "$pkg"` - grep -qE "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" 2> /dev/null + env LANG=C grep -qE "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" 2> /dev/null } -# ============= Check whether a package is forbidden due to conflict ============= +# ============= Check whether a package is forbidden due to conflict (referring to both the record and the actual installation) ============= reinstall_chk_forbidden_conflicts () { local pkg tmp_forbidden pkg_regexp_esc pkg=$1 tmp_forbidden=${TMPDIR}/reinstall_chk_forbidden_conflicts:forbidden pkg_regexp_esc=`str_escape_regexp "$pkg"` - grep -E "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" > $tmp_forbidden 2> /dev/null || return + env LANG=C grep -E "^$pkg_regexp_esc:" "${DBDIR}/forbidden_conflicts" > $tmp_forbidden 2> /dev/null || return pkg_info_e `cut -d : -f 3 "$tmp_forbidden"` } @@ -97,7 +97,12 @@ reinstall_skip_if_in_a_list () message=$1 list=$2 mode=$3 - grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/$list" 2> /dev/null || return + env LANG=C grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/$list" 2> /dev/null || return + REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"` + if [ -n "$REINSTALL_ORIGIN_equiv" ] + then + env LANG=C grep -q -Fx "$REINSTALL_ORIGIN_equiv" "${DBDIR}/$list" 2> /dev/null || return + fi [ "x$mode" = xrestore ] && reinstall_restore_if_temporarily_deinstalled reinstall_skip "$message" || : } @@ -240,13 +245,15 @@ reinstall_deregister_stage_complete () # Package names of conflict are given via stdin. reinstall_backup_and_delete_conflicts () { - local pkg origin origin_regexp_esc backup_pkgdir backup_pkg + local pkg origin origin_equiv origin_regexp_esc origin_equiv_regexp_esc backup_pkgdir backup_pkg message_echo "INFO: Deinstalling conflicting packages for $REINSTALL_ORIGPKGTAG." while read pkg do origin=`pkg_info_flavored_origin "$pkg"` + origin_equiv=`database_query_get_equivalent_orgin "$origin"` message_echo "INFO: Backing up and deleting a conflict, $origin ($pkg)." origin_regexp_esc=`str_escape_regexp "$origin"` + origin_equiv_regexp_esc=`str_escape_regexp "$origin_equiv"` if [ -d "${DBDIR}/requires/$origin" ] then backup_pkgdir=${DBDIR}/backup_packages @@ -254,7 +261,7 @@ reinstall_backup_and_delete_conflicts () backup_pkgdir=${PKGREPOSITORY} fi mkdir -p "$backup_pkgdir" - if backup_pkg=`pkgsys_get_backup_pkg "$origin"` + if backup_pkg=`pkgsys_get_backup_pkg "$origin"` || backup_pkg=`pkgsys_get_backup_pkg "$origin_equiv"` then message_echo "INFO: backup package already exists as $backup_pkg" elif ! backup_pkg=`pkgsys_create_backup_pkg "$pkg" "$backup_pkgdir"` @@ -262,9 +269,16 @@ reinstall_backup_and_delete_conflicts () message_echo "WARNING: Failed to create the backup package, the conflict is kept installed." >&2 continue fi - grep -v -E "^${origin_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts" \ + env LANG=C grep -v -E "^${origin_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts" \ > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || : + if [ -n "$origin_equiv_regexp_esc" ] + then + env LANG=C grep -v -E "^${origin_equiv_regexp_esc}[[:space:]]" "${DBDIR}/deleted_conflicts.tmp" \ + > ${DBDIR}/deleted_conflicts.tmp2 2> /dev/null || : + mv "${DBDIR}/deleted_conflicts.tmp2" "${DBDIR}/deleted_conflicts.tmp" + fi printf '%s\t%s\n' "$origin" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp + [ -n "$origin_equiv" ] && printf '%s\t%s\n' "$origin_equiv" "$pkg" >> ${DBDIR}/deleted_conflicts.tmp mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts" pkg_delete_f "$pkg" || \ { @@ -294,13 +308,14 @@ reinstall_backup_and_delete_remaining_install_conflicts__by_pkg () # ============= Back up and delete remaining actual install conflict (for installation by port) ============= reinstall_backup_and_delete_remaining_install_conflicts () { - local stagedir tmp_conflicts db_conflict + local stagedir tmp_conflicts db_conflict REINSTALL_ORIGIN_equiv tmp_conflicts=${TMPDIR}/reinstall_backup_and_delete_remaining_install_conflicts db_conflict=$REINSTALL_DBNODE_DIR/possible_additional_conflict.csv message_echo "(Checking installation conflict...)" rm -rf "$db_conflict.tmp" "$tmp_conflicts".* stagedir=`database_query_get_makevar_val "$REINSTALL_ORIGIN" STAGEDIR` pkgsys_get_conflicting_installed_pkgs install "$REINSTALL_ORIGIN" > $tmp_conflicts.pkgs || : + REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"` ( set -e cd "$stagedir" find . -not -type d @@ -309,9 +324,12 @@ reinstall_backup_and_delete_remaining_install_conflicts () [ ! -e "$filepath" ] && continue pkg=`pkg_which "$filepath" || :` [ -z "$pkg" ] && continue - grep -qFx "$pkg" "$tmp_conflicts.pkgs" && continue + env LANG=C grep -qFx "$pkg" "$tmp_conflicts.pkgs" && continue origin=`pkg_info_flavored_origin "$pkg"` [ x"$origin" = x"$REINSTALL_ORIGIN" ] && continue + [ x"$origin" = x"$REINSTALL_ORIGIN_equiv" ] && continue + origin_equiv=`database_query_get_equivalent_orgin "$origin"` + [ x"$origin_equiv" = x"$REINSTALL_ORIGIN" ] && continue printf '%s\t%s\n' "$pkg" "$filepath" >> $db_conflict.tmp done if [ -e "$db_conflict.tmp" ] @@ -363,9 +381,9 @@ reinstall_remove_needless_possible_conflict () cut -f 1 "$db_conflict" | sort -u > $tmp_db.conflict_pkg.old cut -f 1 "$db_conflict.tmp" | sort -u > $tmp_db.conflict_pkg.new suffix=`echo ":$REINSTALL_ORIGIN:$REINSTALL_NEWPKGNAME" | str_escape_replaceval_filter` - grep -vFx -f "$tmp_db.conflict_pkg.new" "$tmp_db.conflict_pkg.old" | \ + env LANG=C grep -vFx -f "$tmp_db.conflict_pkg.new" "$tmp_db.conflict_pkg.old" | \ sed -E "s/$/$suffix/" > $tmp_db.conflict_pkg.needless.filter - grep -vFx -f "$tmp_db.conflict_pkg.needless.filter" "$db_forbidden" > $db_forbidden.tmp || : + env LANG=C grep -vFx -f "$tmp_db.conflict_pkg.needless.filter" "$db_forbidden" > $db_forbidden.tmp || : mv "$db_forbidden.tmp" "$db_forbidden" mv "$db_conflict.tmp" "$db_conflict" [ `wc -l < $db_conflict` -gt 0 ] || rm "$db_conflict" @@ -374,21 +392,24 @@ reinstall_remove_needless_possible_conflict () # ============= Restoration of backed up conflict ============= reinstall_restore_conflicts () { - local origin_current tmpsrc + local origin_current tmpsrc origin_current_equiv origin_current=$1 [ $opt_fetch_only = no -a $opt_dry_run = no ] || return 0 [ -e "${DBDIR}/deleted_conflicts" ] || return 0 tmpsrc=${TMPDIR}/reinstall_restore_conflicts::deleted_conflicts cp "${DBDIR}/deleted_conflicts" "$tmpsrc" + origin_current_equiv=`database_query_get_equivalent_orgin "$origin_current"` while read origin pkg do pkg_regexp_esc=`str_escape_regexp "$pkg"` - origins_init=`database_query_initial_orgins "$origin" | grep -vFx "$origin" || :` + origins_init=`database_query_initial_orgins "$origin" | env LANG=C grep -vFx "$origin" || :` origin_replace=`echo "$origin" \ | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"` [ "x$origin_replace" = "x$origin" ] && origin_replace= is_to_dereg_from_list=no - if [ -n "$origin_current" -a "x$origin" = "x$origin_current" ] || \ + origin_equiv=`database_query_get_equivalent_orgin "$origin"` + if [ -n "$origin" -a \( "x$origin" = "x$origin_current" -o "x$origin" = "x$origin_current_equiv" \) ] || \ + [ -n "$origin_equiv" -a "x$origin_equiv" = "x$origin_current" ] || \ pkg_info_e "$pkg" || pkgsys_exists_from_orig "$origin" then is_to_dereg_from_list=yes @@ -420,7 +441,7 @@ reinstall_restore_conflicts () then pkg_current= origin_current= - for origin_trial in $origin $origins_init $origin_replace + for origin_trial in $origin $origin_equiv $origins_init $origin_replace do pkg_trial=`pkgsys_get_installed_pkg_from_origin "$origin_trial" || :` [ -z "$pkg_trial" ] && continue @@ -432,33 +453,33 @@ reinstall_restore_conflicts () pkgname_msg=$pkg origin_msg=$origin [ "x$pkg_current" = "x$pkg" ] || pkgname_msg="$pkg => $pkg_current" - [ "x$origin_current" = "x$origin" ] || origin_msg="$origin => $origin_current" + [ "x$origin_current" = "x$origin" -o "x$origin_current" = "x$origin_equiv" ] || origin_msg="$origin => $origin_current" if [ $is_skipped = yes ] then message_echo "WARNING: Conflicting package is installed: $origin_msg ($pkgname_msg)" else message_echo "INFO: $origin_msg ($pkgname_msg) is already restored." - grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \ + env LANG=C grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \ > ${DBDIR}/deleted_conflicts.tmp || : mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts" fi continue fi [ $is_skipped = yes ] && continue - if grep -q -Fx -e "$origin" -e "$origin_replace" "${DBDIR}/taboo.all.list" 2> /dev/null + if env LANG=C grep -q -Fx -e "$origin" -e "$origin_equiv" -e "$origin_replace" "${DBDIR}/taboo.all.list" 2> /dev/null then message_echo "INFO: Restoration of a conflict, $origin ($pkg), is avoided because it is taboo." continue fi message_echo "INFO: Restoring a former conflict, $origin ($pkg)." - if ! backup_pkg=`pkgsys_get_backup_pkg "$origin"` + if ! backup_pkg=`pkgsys_get_backup_pkg "$origin"` || ! backup_pkg=`pkgsys_get_backup_pkg "$origin_equiv"` then message_echo "WARNING: No backup exists, gave up." >&2 continue fi if pkg_add_fF "$backup_pkg" then - grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \ + env LANG=C grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \ > ${DBDIR}/deleted_conflicts.tmp || : mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts" else @@ -473,7 +494,14 @@ reinstall_are_requirements_ready () [ -e "$REINSTALL_DBNODE_DIR/requirements.all.direct" ] || return 0 while read origin do - pkgsys_exists_from_orig "$origin" || return 1 + if ! pkgsys_exists_from_orig "$origin" + then + origin_equiv=`database_query_get_equivalent_orgin "$origin"` + if [ -n "$origin_equiv" ] && ! pkgsys_exists_from_orig "$origin_equiv" + then + return 1 + fi + fi done < $REINSTALL_DBNODE_DIR/requirements.all.direct } @@ -489,18 +517,30 @@ reinstall_chk_and_restore_requirements () | while read origin do pkgsys_exists_from_orig "$origin" && continue - if grep -q -Fx "$origin" "${DBDIR}/taboo.all.list" 2> /dev/null + origin_equiv=`database_query_get_equivalent_orgin "$origin"` + pkgsys_exists_from_orig "$origin_equiv" && continue + if env LANG=C grep -q -Fx "$origin" "${DBDIR}/taboo.all.list" 2> /dev/null \ + || { [ -n "$origin_equiv" ] && env LANG=C grep -q -Fx "$origin_equiv" "${DBDIR}/taboo.all.list" 2> /dev/null; } then message_echo "INFO: Restoration of a requirement [$origin] is avoided because it is set taboo." touch "$tmp_isfailed" break fi - origins_init=`database_query_initial_orgins "$origin" | grep -vFx "$origin" || :` + if [ -n "$origin_equiv" ] + then + origins_init=`{ database_query_initial_orgins "$origin"; database_query_initial_orgins "$origin_equiv"; } | env LANG=C grep -vFx -e "$origin" -e "$origin_equiv" || :` + else + origins_init=`{ database_query_initial_orgins "$origin"; } | env LANG=C grep -vFx "$origin" || :` + fi origin_replace=`echo "$origin" \ | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"` + origin_equiv_replace=`echo "$origin_equiv" \ + | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"` [ "x$origin_replace" = "x$origin" ] && origin_replace= + [ "x$origin_equiv_replace" = "x$origin_equiv" ] && origin_equiv_replace= + [ -n "$origin_replace" ] || origin_replace=$origin_equiv_replace is_installed=no - for origin_orig in $origins_init $origin_replace + for origin_orig in $origins_init $origin_replace $origin_equiv_replace do [ "x$origin_orig" = "x$origin" ] && continue if pkgsys_exists_from_orig "$origin_orig" @@ -508,7 +548,7 @@ reinstall_chk_and_restore_requirements () is_installed=yes break fi - if grep -q -Fx "$origin_orig" "${DBDIR}/taboo.all.list" 2> /dev/null + if env LANG=C grep -q -Fx "$origin_orig" "${DBDIR}/taboo.all.list" 2> /dev/null then message_echo "INFO: Restoration of a requirement [$origin_orig] is avoided because it is set taboo." touch "$tmp_isfailed" @@ -518,13 +558,14 @@ reinstall_chk_and_restore_requirements () done [ $is_installed = yes ] && continue [ $is_installed = taboo ] && break - for origin_orig in $origin $origins_init $origin_replace + for origin_orig in $origin $origin_equiv $origins_init $origin_replace $origin_equiv_replace do pkgarc=`pkgsys_get_backup_pkg "$origin_orig"` && break done if [ -z "$pkgarc" ] then - if grep -q -Fx "$origin" "${DBDIR}/failed.list" 2> /dev/null + if env LANG=C grep -q -Fx "$origin" "${DBDIR}/failed.list" 2> /dev/null || \ + { [ -n "$origin_equiv" ] && env LANG=C grep -q -Fx "$origin_equiv" "${DBDIR}/failed.list" 2> /dev/null; } then touch "$tmp_isfailed" break @@ -546,7 +587,7 @@ reinstall_chk_and_restore_requirements () message_echo "INFO: Restoring a backed-up requirement [$origin ($pkg)]." if pkg_add_fF "$pkgarc" then - grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \ + env LANG=C grep -v -E "[[:space:]]$pkg_regexp_esc$" "${DBDIR}/deleted_conflicts" \ > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || : mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts" else @@ -562,7 +603,7 @@ reinstall_pkg_backup () { local backup_pkg pkg reinstall_chk_stage_complete PKG_BACKUP && return - pkg=`echo "$REINSTALL_CURRENTPKG" | tr ' ' '\n' | grep -v '^$' | tail -n 1` + pkg=`echo "$REINSTALL_CURRENTPKG" | tr ' ' '\n' | env LANG=C grep -v '^$' | tail -n 1` if [ -n "$pkg" ] then message_echo "-- (Creating temporary backup package for $REINSTALL_ORIGPKGTAG)" @@ -581,7 +622,7 @@ reinstall_pkg_backup () # ============= Deinstallation of the currently installed package ============= reinstall_deinstall () { - local tmp_installedpkg installed_pkgs dev_out dev_err + local tmp_installedpkg REINSTALL_ORIGIN_equiv installed_pkgs dev_out dev_err dev_out=/dev/stdout dev_err=/dev/stderr if [ $opt_batch_mode = yes ] @@ -593,7 +634,8 @@ reinstall_deinstall () pkgsys_get_installed_pkg_from_origin "$REINSTALL_ORIGIN" > $tmp_installedpkg [ `wc -l < $tmp_installedpkg` -gt 0 ] || return 0 installed_pkgs=`tr '\n' ' ' < $tmp_installedpkg | sed 's/ *$//'` - if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN" + REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"` + if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN" || pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN_equiv" then message_echo "INFO: Deinstalling $installed_pkgs by $PKGSYS_CMD_PKG_DELETE." pkg_delete_f $installed_pkgs || \ @@ -624,13 +666,15 @@ reinstall_deinstall_old_ports () while read origin_old do pkgsys_get_installed_pkg_from_origin "$origin_old" + origin_old_equiv=`database_query_get_equivalent_orgin "$origin_old"` + pkgsys_get_installed_pkg_from_origin "$origin_old_equiv" done < $REINSTALL_FROMNODE_DIR/old_origs | reinstall_backup_and_delete_conflicts } # ============= Recovery after failure of installation of the new package ============= reinstall_failed_install_recover () { - local backedup_version backup_pkg dev_out dev_err + local backedup_version backup_pkg dev_out dev_err REINSTALL_ORIGIN_equiv dev_out=/dev/stdout dev_err=/dev/stderr if [ $opt_batch_mode = yes ] @@ -647,7 +691,9 @@ reinstall_failed_install_recover () message_echo "INFO: Trying to deinstall by ports to make sure (This may cause negligible warnings)." reinstall_make deinstall > $dev_out 2> $dev_err|| : backedup_version=`cat "$REINSTALL_FROMNODE_DIR/backedup_version" 2> /dev/null || :` - if grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/taboo.all.list" 2> /dev/null + REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"` + if env LANG=C grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/taboo.all.list" 2> /dev/null || \ + { [ -n "$REINSTALL_ORIGIN_equiv" ] && env LANG=C grep -q -Fx "$REINSTALL_ORIGIN_equiv" "${DBDIR}/taboo.all.list" 2> /dev/null; } then message_echo "INFO: Restoration of the backup of $backedup_version is avoided because it is taboo." elif [ -n "$backedup_version" ] @@ -680,8 +726,10 @@ reinstall_failed_install_recover () # ============= Report an installation success to the all dependents ============= reinstall_tell_update_to_depandents () { - local tag level dbsuffix + local REINSTALL_ORIGIN_equiv tag level dbsuffix pkgsys_is_pkgtool "$REINSTALL_ORIGIN" && return + REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"` + pkgsys_is_pkgtool "$REINSTALL_ORIGIN_equiv" && return reinstall_chk_stage_complete TELL_UPDATE_TO_DEPANDENTSL && return for tag in all run build none do @@ -695,6 +743,11 @@ reinstall_tell_update_to_depandents () | sort -u \ | while read origin_dependent do + echo "$origin_dependent" + origin_dependent_equiv=`database_query_get_equivalent_orgin "$origin_dependent"` + [ -z "$origin_dependent_equiv" ] || echo "$origin_dependent_equiv" + done | while read origin_dependent + do [ -d "${DBDIR}/requires/$origin_dependent" ] || continue touch "${DBDIR}/requires/$origin_dependent/need_reinstall_due_to_upgraded_requirements.$dbsuffix" fileedit_rm_a_line "$origin_dependent" \ @@ -707,7 +760,7 @@ reinstall_tell_update_to_depandents () reinstall_register_stage_complete TELL_UPDATE_TO_DEPANDENTS } -# ============= Closing operations after an installation success ============= +# ============= Closing operations after a successful installation ============= reinstall_closing_operations_after_successful_install () { local tag level @@ -730,15 +783,17 @@ reinstall_closing_operations_after_successful_install () } | sort -u | while read initial_orig do initial_orig_regexp=`str_escape_regexp "$initial_orig"` - grep -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" 2> /dev/null \ + initial_orig_equiv=`database_query_get_equivalent_orgin "$initial_orig"` + initial_orig_equiv_regexp=`str_escape_regexp "$initial_orig_equiv"` + env LANG=C grep -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" 2> /dev/null \ | cut -f 2 | while read initial_pkg do pkg_regexp=`str_escape_regexp "$initial_pkg"` - grep -v -E "^${pkg_regexp}:" "${DBDIR}/forbidden_conflicts" \ + env LANG=C grep -v -E "^${pkg_regexp}:" "${DBDIR}/forbidden_conflicts" \ > ${DBDIR}/forbidden_conflicts.tmp 2> /dev/null || : mv "${DBDIR}/forbidden_conflicts.tmp" "${DBDIR}/forbidden_conflicts" done - grep -v -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" \ + env LANG=C grep -v -E "^${initial_orig_regexp}[[:space:]]" "${DBDIR}/deleted_conflicts" \ > ${DBDIR}/deleted_conflicts.tmp 2> /dev/null || : mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts" pkgsys_delete_backup_pkg "$initial_orig" @@ -758,21 +813,21 @@ reinstall_fetch_missing_distfiles () tmp_missing_fetch=${TMPDIR}/reinstall_fetch_missing_distfiles:missing_fetch.sh rm -rf "$tmp_fetch.pre" reinstall_make_anymode fetch-list 2> /dev/null > $tmp_fetch.src || return - grep '^SHA256[[:space:]]' "$port_path/distinfo" | \ + env LANG=C grep '^SHA256[[:space:]]' "$port_path/distinfo" | \ sed -E 's/^SHA256[[:space:]]+\(([^)]*)\).*/\1/' | \ while read relative_distfile_path do if ! { testhash=`( cd "${DISTDIR}" && sha256 "$relative_distfile_path" ) 2> /dev/null` && \ - grep -qxF "$testhash" "$port_path/distinfo"; } + env LANG=C grep -qxF "$testhash" "$port_path/distinfo"; } then relative_distfile_path_ptn=`str_escape_regexp "|| echo \"$relative_distfile_path\" not fetched; }"` - if grep -E "$relative_distfile_path_ptn$" "$tmp_fetch.src" + if env LANG=C grep -E "$relative_distfile_path_ptn$" "$tmp_fetch.src" then subdir_distfile=`dirname "$relative_distfile_path"` [ "x$subdir_distfile" = x. ] || echo "mkdir -p \"${DISTDIR}/$subdir_distfile\"" >> $tmp_fetch.pre fi fi - done | grep -v '^[[:space:]]*$' > $tmp_fetch.main || : + done | env LANG=C grep -v '^[[:space:]]*$' > $tmp_fetch.main || : [ -e "$tmp_fetch.pre" ] && sort -u "$tmp_fetch.pre" cat "$tmp_fetch.main" } @@ -817,18 +872,23 @@ reinstall_execcmd_getstdout_errlog () # Return status 0 for no problem about missing ports reinstall_chk_missing_requirement () { - local tmp_filter tmp_miising + local tmp_filter tmp_missing tmp_filter=${TMPDIR}/reinstall_chk_missing_requirement::requirements.all_but_test.unflavored - tmp_miising=${TMPDIR}/reinstall_chk_missing_requirement::missing_requirements + tmp_missing=${TMPDIR}/reinstall_chk_missing_requirement::missing_requirements message_echo "Checking whether any required package is missing or too old..." sed 's/@.*//' "$REINSTALL_DBNODE_DIR/requirements.all.full" > $tmp_filter || : - if reinstall_make missing 2> /dev/null | grep -Fx -f "$tmp_filter" > $tmp_miising + reinstall_make missing 2> /dev/null | env LANG=C grep -Fx -f "$tmp_filter" | while read missing_orig + do + missing_equiv=`database_query_get_equivalent_orgin "$missing_orig"` + [ -n "$missing_equiv" ] && ! pkg_info_eO "$missing_equiv" && echo "$missing_orig" + done > $tmp_missing + if [ `wc -l < $tmp_missing` -gt 0 ] then message_echo "Found missing/too old requirements:" - message_cat < $tmp_miising + message_cat < $tmp_missing { echo "Found missing/too old requirements:" - cat "$tmp_miising" + cat "$tmp_missing" } > "$REINSTALL_DBNODE_DIR/error.log" reinstall_restore_conflicts "$REINSTALL_ORIGIN" reinstall_restore_if_temporarily_deinstalled @@ -867,7 +927,7 @@ reinstall_exec_chk_skip () if expr "$REINSTALL_CURRENTPKG" : '.* .*' > /dev/null then message_echo "WARNING: Multiple packages are registered for this port. Reinstallation is needed to fix it." >&2 - elif grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/damaged_package" 2> /dev/null + elif env LANG=C grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/damaged_package" 2> /dev/null then message_echo "WARNING: Installed files have invalid checksums for this port. Reinstallation is needed to fix it." >&2 else @@ -1201,7 +1261,7 @@ reinstall_exec_reinstall_freeze_if_necessary () # Return status 0 for no concern about freezing requirements reinstall_exec_reinstall_avoid_if_any_unfrozen_requirements_exists () { - if grep -qFx "$REINSTALL_DBNODE_DIR/requirements.all.full" "${DBDIR}/freeze.all.list" 2> /dev/null + if env LANG=C grep -qFx "$REINSTALL_DBNODE_DIR/requirements.all.full" "${DBDIR}/freeze.all.list" 2> /dev/null then reinstall_restore_conflicts { @@ -1354,9 +1414,10 @@ reinstall_exec_reinstall_chk_interactive_mode () # Return status 1 for error end reinstall_exec_reinstall_build () { - local flag_restarted_build build_args is_build_env_modified conflicts_install dev_out dev_err + local flag_restarted_build build_args is_build_env_modified conflicts_install dev_out dev_err REINSTALL_ORIGIN_equiv dev_out=/dev/stdout dev_err=/dev/stderr + REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"` if [ $opt_batch_mode = yes ] then dev_out=/dev/null @@ -1393,7 +1454,7 @@ reinstall_exec_reinstall_build () echo "$conflicts_install" | reinstall_backup_and_delete_conflicts is_build_env_modified=yes fi - if pkgsys_exists_from_orig "$REINSTALL_ORIGIN" + if pkgsys_exists_from_orig "$REINSTALL_ORIGIN" "$REINSTALL_ORIGIN_equiv" then message_echo "INFO: The currently installed package for this port is deinstalled for retrial because it may have effects on build." reinstall_pkg_backup || : @@ -1472,13 +1533,14 @@ reinstall_exec_reinstall_stage () reinstall_deregister_stage in_stage } -# ============= Reinstallation of the current origin: Install process============= +# ============= Reinstallation of the current origin: Install process ============= # Return status 1 for error end reinstall_exec_reinstall_install () { - local insttarget dev_out dev_err + local insttarget dev_out dev_err REINSTALL_ORIGIN_equiv dev_out=/dev/stdout dev_err=/dev/stderr + REINSTALL_ORIGIN_equiv=`database_query_get_equivalent_orgin "$REINSTALL_ORIGIN"` if [ $opt_batch_mode = yes ] then dev_out=/dev/null @@ -1579,9 +1641,10 @@ reinstall_exec_reinstall_install () | while read origin_bak pkgpath_bak do pkg_bak=`pkgsys_pkgarc_to_pkgname "$pkgpath_bak"` - if [ "$origin_bak" = "$REINSTALL_ORIGIN" ] + origin_bak_equiv=`database_query_get_equivalent_orgin "$origin_bak"` + if [ "x$origin_bak" = "x$REINSTALL_ORIGIN" -o "x$origin_bak_equiv" = "x$REINSTALL_ORIGIN" -o "x$origin_bak" = "x$REINSTALL_ORIGIN_equiv" ] then - [ "$pkg_bak" = "$REINSTALL_NEWPKGNAME" ] && continue + [ "x$pkg_bak" = "x$REINSTALL_NEWPKGNAME" ] && continue elif reinstall_quick_chk_forbidden_conflicts "$pkg_bak" then continue @@ -1703,7 +1766,7 @@ reinstall_exec () REINSTALL_DBSUFFIX=`options_get_dependency_type`.`options_get_dependency_level` REINSTALL_NEWPKGNAME=`database_build_get_new_pkgname "$REINSTALL_ORIGIN"` REINSTALL_IS_FROZEN=no - grep -qFx "$REINSTALL_ORIGIN" "${DBDIR}/freeze.all.list" 2> /dev/null && REINSTALL_IS_FROZEN=yes + env LANG=C grep -qFx "$REINSTALL_ORIGIN" "${DBDIR}/freeze.all.list" 2> /dev/null && REINSTALL_IS_FROZEN=yes message_stage_title "$PROGRAM_STEP_COUNTER $REINSTALL_ORIGPKGTAG" reinstall_exec_chk_skip && reinstall_exec_reinstall || : message_echo diff --git a/lib/main/liboptions.sh b/lib/main/liboptions.sh index f52172b..fec7aa8 100644 --- a/lib/main/liboptions.sh +++ b/lib/main/liboptions.sh @@ -9,7 +9,7 @@ # ============= Database of options which are given at each run and not saved ============= # [Syntax of option databases] -# short_name, long_name, variable, defult_vaule, set_value +# short_name, long_name, variable, default_value, set_value # Columns are delimited by tab characters. options_db_onetime () { diff --git a/lib/upgrade/libcommand_do.sh b/lib/upgrade/libcommand_do.sh index 49f7845..5e9fced 100644 --- a/lib/upgrade/libcommand_do.sh +++ b/lib/upgrade/libcommand_do.sh @@ -71,8 +71,8 @@ command_do_reinst_ports () if [ -n "$target_pkg" ] then target_regexp=`str_escape_regexp "$target_pkg"` - timestamp_init=`grep -E "^${target_regexp}[[:space:]]" "${DBDIR}/initial_pkgs_snapshot.csv" | cut -f 2` - timestamp_fin=`grep -E "^${target_regexp}[[:space:]]" "${ETCDIR}/final_pkgs_snapshot.csv" | cut -f 2` + timestamp_init=`env LANG=C grep -E "^${target_regexp}[[:space:]]" "${DBDIR}/initial_pkgs_snapshot.csv" | cut -f 2` + timestamp_fin=`env LANG=C grep -E "^${target_regexp}[[:space:]]" "${ETCDIR}/final_pkgs_snapshot.csv" | cut -f 2` if [ -n "$timestamp_init" -a -n "$timestamp_fin" ] then pkgtype_init=`expr "$timestamp_init" : '\([^:]*\):' || :` @@ -182,8 +182,8 @@ command_do_deinst_remining_olg_pkgs () { message_section_title "Deinstalling remaining old packages if any..." pkg_get_pkgs_timestamps | \ - grep -vE "`pkgsys_pkgtools_pkgs_filter_regexp`"> ${TMPDIR}/current_pkgs_snapshot.csv - grep -Fxv -f "${ETCDIR}/final_pkgs_snapshot.csv" "${TMPDIR}/current_pkgs_snapshot.csv" | \ + env LANG=C grep -vE "`pkgsys_pkgtools_pkgs_filter_regexp`"> ${TMPDIR}/current_pkgs_snapshot.csv + env LANG=C grep -Fxv -f "${ETCDIR}/final_pkgs_snapshot.csv" "${TMPDIR}/current_pkgs_snapshot.csv" | \ cut -f 1 | while read pkg_old do pkg_delete_f "$pkg_old" diff --git a/lib/upgrade/liboptions.sh b/lib/upgrade/liboptions.sh index a59909c..665dc4d 100644 --- a/lib/upgrade/liboptions.sh +++ b/lib/upgrade/liboptions.sh @@ -9,7 +9,7 @@ # ============= Database of options which are given at each run and not saved ============= # [Syntax of option databases] -# short_name, long_name, variable, defult_vaule, set_value +# short_name, long_name, variable, default_value, set_value # Columns are delimited by tab characters. options_db_onetime () { diff --git a/man/portsreinstall-chroot.8 b/man/portsreinstall-chroot.8 index 652f59e..06b728b 100644 --- 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. .PD 0 .TP \fB\-\-fullcourse\fR -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). +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). Resuming \fBdo\fR command automatically executes \fBportsreinstall\fR(8) in the builder \fBchroot\fR(8) environment. With \fB\-a\fR option, the all detected leaf and obsolete packages will be deleted. .PD @@ -337,6 +337,9 @@ See also the corresponding section of \fBportsreinstall\fR(8). The variables are conveyed to the forked environment from the target host. .SH HISTORY This utility first appeared as a part of \fBportsreinstall\fR(8) version 4.0.0 released on June 29, 2018. +.SH BUGS +This tool is still experimental and may not work in typical environments. +It has been observed that \fBpkg\-add\fR(8) command froze at the preparation stage in a ZFS-mounted environment with 12.2-RELEASE. .SH "SEE ALSO" \fBchroot\fR(8) \fBportsreinstall\fR(8), -- 2.11.0