OSDN Git Service

[IMPROVED] The behavior with union file systems is stabilized.
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Tue, 10 Jul 2018 03:44:24 +0000 (11:44 +0800)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Tue, 10 Jul 2018 03:44:24 +0000 (11:44 +0800)
modified:   Makefile
modified:   bin/portsreinstall
modified:   bin/portsreinstall-chroot
modified:   lib/chroot-mount/libmain.sh
modified:   lib/chroot/libfs.sh
modified:   lib/chroot/libmain.sh
modified:   lib/chroot/liboptions.sh
modified:   lib/libconf.sh
modified:   lib/libdatabase_build.sh
modified:   lib/libdatabase_record.sh
modified:   lib/libdeinstall.sh
new file:   lib/libfs.sh
modified:   lib/libmain.sh
modified:   lib/libmisc.sh
modified:   lib/libpkgsys.sh
modified:   lib/libreinstall.sh
modified:   lib/upgrade/liboptions.sh
modified:   man/portsreinstall.8
modified:   share/bin/portsreinstall-chroot-mount
modified:   share/bin/portsreinstall-upgrade

20 files changed:
Makefile
bin/portsreinstall
bin/portsreinstall-chroot
lib/chroot-mount/libmain.sh
lib/chroot/libfs.sh
lib/chroot/libmain.sh
lib/chroot/liboptions.sh
lib/libconf.sh
lib/libdatabase_build.sh
lib/libdatabase_record.sh
lib/libdeinstall.sh
lib/libfs.sh [new file with mode: 0644]
lib/libmain.sh
lib/libmisc.sh
lib/libpkgsys.sh
lib/libreinstall.sh
lib/upgrade/liboptions.sh
man/portsreinstall.8
share/bin/portsreinstall-chroot-mount
share/bin/portsreinstall-upgrade

index eef3c29..cc5fda7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ LIBS=\
        lib/libdatabase_record.sh \
        lib/libdeinstall.sh \
        lib/libfileedit.sh \
+       lib/libfs.sh \
        lib/libmain.sh \
        lib/libmessage.sh \
        lib/libmisc.sh \
index bbcb57a..0f9bcc1 100755 (executable)
@@ -32,6 +32,7 @@ ETCDIR=${MYPREFIX}/etc
 . ${LIBDIR}/libdatabase_record.sh
 . ${LIBDIR}/libdeinstall.sh
 . ${LIBDIR}/libfileedit.sh
+. ${LIBDIR}/libfs.sh
 . ${LIBDIR}/libmain.sh
 . ${LIBDIR}/libmessage.sh
 . ${LIBDIR}/libmisc.sh
index 02f8117..7655c85 100755 (executable)
@@ -32,6 +32,7 @@ ETCDIR=${MYPREFIX}/etc
 . ${LIBDIR}/libdatabase_record.sh
 . ${LIBDIR}/libdeinstall.sh
 . ${LIBDIR}/libfileedit.sh
+. ${LIBDIR}/libfs.sh
 . ${LIBDIR}/libmain.sh
 . ${LIBDIR}/libmessage.sh
 . ${LIBDIR}/libmisc.sh
@@ -74,7 +75,7 @@ fs_safeguard_basedir "$opt_basedir"
 # ========================================================
 main_setup_parameters "$@"
 
-misc_inspect_fs_privilege
+fs_inspect_fs_privilege
 
 main_operation_without_pkg_management_tools "$@"
 
index 926b3ca..3192605 100644 (file)
@@ -37,7 +37,7 @@ main_parse_conf ()
 # ============= Check of the mounting/unmounting privilege of the environment =============
 main_check_of_mounting_unmounting_privilege ()
 {
-       if ! misc_chk_mount_privilege || ! misc_chk_unmount_privilege
+       if ! fs_chk_mount_privilege || ! fs_chk_unmount_privilege
        then
                temp_terminate_process () { :; }
                message_echo "ERROR: The current environment does not have the full privilege to mount and unmount file systems." >&2
index eb47095..7e6c3ed 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/sh -e
 # ==============================================================================
-# portsreinstall-chroot library script for portsreinstall-chroot
+# portsreinstall-chroot library script
+# Overlay onto lib/libfs.sh for portsreinstall-chroot
 # - File system operations -
 # Copyright (C) 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 # This software is distributed under the 2-Clause BSD License.
@@ -68,14 +69,14 @@ fs_build_chroot ()
                                        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"
-                                       misc_get_descendant_mount_info "$systembase/$src_mountpoint_real" > $tmpdir_descendant/list
+                                       fs_get_descendant_mount_info "$systembase/$src_mountpoint_real" > $tmpdir_descendant/list
                                fi
                        elif [ -d "$systembase"/$directory ]
                        then
                                printf '%s\t%s\n' real $directory >> ${TMPDIR}/fs_build_chroot:directories
                                tmpdir_descendant=${TMPDIR}/fs_build_chroot:descendant/$directory
                                mkdir -p "$tmpdir_descendant"
-                               misc_get_descendant_mount_info "$systembase/$directory" > $tmpdir_descendant/list
+                               fs_get_descendant_mount_info "$systembase/$directory" > $tmpdir_descendant/list
                        fi
                done < ${TMPDIR}/fs_build_chroot:sys_dirs
        )
@@ -185,7 +186,7 @@ fs_chk_mount ()
                [ "x$type" = xnullfs -o "x$type" = xunionfs ] && target=$systembase/$target
                directory=`echo "$srcline" | cut -f 3`
                opt=`echo "$srcline" | cut -f 4`
-               if ! misc_chk_mounted "$type" "$target" "$systembase/$opt_basedir/builder/$directory"
+               if ! fs_chk_mounted "$type" "$target" "$systembase/$opt_basedir/builder/$directory"
                then
                        touch "${TMPDIR}"/fs_chk_mount:remains
                        break
@@ -200,7 +201,7 @@ fs_terminate_if_mount_unavailable ()
        local systembase
        systembase=$1
        fs_chk_mount "$systembase" && return
-       misc_chk_mount_privilege && return
+       fs_chk_mount_privilege && return
        temp_terminate_process ()
        {
                local errno basedir
@@ -214,7 +215,7 @@ fs_terminate_if_mount_unavailable ()
                message_echo
                message_echo "INFO: Terminated for mounting file systems because this utility was executed at a virtual (chroot or jail) environment."
                message_echo "Execute"
-               basedir=`misc_get_system_basedir`
+               basedir=`fs_get_system_basedir`
                if [ -n "$basedir" ]
                then
                        message_echo "  $basedir${SHAREDIR}/bin/portsreinstall-chroot-mount"
@@ -249,7 +250,7 @@ fs_mount ()
                directory=`echo "$srcline" | cut -f 3`
                opt=`echo "$srcline" | cut -f 4`
                mp=$systembase/$opt_basedir/builder/$directory
-               if ! misc_chk_mounted "$type" "$target" "$mp"
+               if ! fs_chk_mounted "$type" "$target" "$mp"
                then
                        mount -t "$type" -o "$opt" "$target" "$mp"
                fi
@@ -276,7 +277,7 @@ fs_chk_unmount ()
                [ "x$type" = xnullfs -o "x$type" = xunionfs ] && target=$systembase/$target
                directory=`echo "$srcline" | cut -f 3`
                opt=`echo "$srcline" | cut -f 4`
-               if misc_chk_mounted "$type" "$target" "$systembase/$opt_basedir/builder/$directory"
+               if fs_chk_mounted "$type" "$target" "$systembase/$opt_basedir/builder/$directory"
                then
                        touch "${TMPDIR}"/fs_chk_unmount:remains
                        break
@@ -291,7 +292,7 @@ fs_terminate_if_unmount_unavailable ()
        local systembase
        systembase=$1
        fs_chk_unmount "$systembase" && return
-       misc_chk_unmount_privilege && return
+       fs_chk_unmount_privilege && return
        temp_terminate_process ()
        {
                local errno basedir
@@ -305,7 +306,7 @@ fs_terminate_if_unmount_unavailable ()
                message_echo
                message_echo "INFO: Terminated for unmounting file systems because this utility was executed at a virtual (chroot or jail) environment."
                message_echo "Execute"
-               basedir=`misc_get_system_basedir`
+               basedir=`fs_get_system_basedir`
                if [ -n "$basedir" ]
                then
                        message_echo "  $basedir${SHAREDIR}/bin/portsreinstall-chroot-mount unmount"
@@ -342,7 +343,7 @@ fs_unmount ()
                directory=`echo "$srcline" | cut -f 3`
                opt=`echo "$srcline" | cut -f 4`
                mp=$systembase/$opt_basedir/builder/$directory
-               if misc_chk_mounted "$type" "$target" "$mp"
+               if fs_chk_mounted "$type" "$target" "$mp"
                then
                        umount -f "$mp"
                fi
index 21601cd..beb8383 100644 (file)
@@ -14,7 +14,7 @@ main_set_termination_messages_special ()
        {
                local errno
                errno=${1:-0}
-               ! fs_chk_unmount && misc_chk_mount_privilege && fs_unmount
+               ! fs_chk_unmount && fs_chk_mount_privilege && fs_unmount
                temp_terminate_process_common "$errno"
        }
 }
index 3283717..8b0aae8 100644 (file)
@@ -42,5 +42,5 @@ eof
 # ============= Regularize the option value =============
 options_regularize ()
 {
-       opt_basedir=`misc_global_path "$opt_basedir"`
+       opt_basedir=`fs_global_path "$opt_basedir"`
 }
index 133efb2..235c7d6 100644 (file)
@@ -13,6 +13,7 @@ conf_setup_ports_envs ()
        tmp_work=${TMPDIR}/conf_setup_ports_envs:work
        rm -rf "$tmp_work"
        mkdir "$tmp_work"
+       fs_fix_unionfs_image_if_hidden "${PORTSDIR}"
        PORTSDIR=${PORTSDIR:-`[ -e /etc/make.conf ] && make -C "$tmp_work" -f /etc/make.conf -V PORTSDIR 2> /dev/null`} || :
        PORTSDIR=${PORTSDIR:-/usr/ports}
        pkgsys_chk_ports_tree_implementation
index 7fbda24..cc8bade 100644 (file)
@@ -136,6 +136,7 @@ database_build_make ()
        MAKE_ARGS=`database_build_setup_make_args "$origin"`
        MAKE_ENVS=`database_build_setup_make_envs "$origin"`
        port_path=`pkgsys_get_portpath_from_origin "$origin"`
+       fs_fix_unionfs_image_if_hidden "$port_path"
        env $MAKE_ENVS make -C "$port_path" "$@" $MAKE_ARGS
 }
 
index 6364b66..2cac1ac 100644 (file)
@@ -83,7 +83,7 @@ database_record_failure ()
        if [ -z "$clean" -o "@$clean" = @clean ]
        then
                message_echo "*** Trying to clean the failed build... (Ignore failures)"
-               env ${MAKE_ENVS} make clean ${MAKE_ARGS} || :
+               database_build_make "$origin" clean || :
        fi
        message_echo "*** Skipping this port and proceeding to next forcibly..."
        message_echo
index 67c4f94..92ea92f 100644 (file)
@@ -220,7 +220,7 @@ deinstall_exec ()
                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" ] || return 0
+               [ -n "$currentpkg" ] || continue
                temp_set_msg_current_stage "a ${_MSG_CURRENT_STAGE_general} process for $origin ($currentpkg) $PROGRAM_STEP_COUNTER"
                database_query_get_target_attributes currentorigin "$origin"
                if [ -z "${currentorigin_is_relevant}" ]
diff --git a/lib/libfs.sh b/lib/libfs.sh
new file mode 100644 (file)
index 0000000..e22aa77
--- /dev/null
@@ -0,0 +1,200 @@
+#!/bin/sh -e
+# ==============================================================================
+# portsreinstall library script
+# - File system operations -
+# Copyright (C) 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
+# This software is distributed under the 2-Clause BSD License.
+# ==============================================================================
+
+# ============= Get the global path of a possibly not yet created file/directory =============
+fs_global_path ()
+{
+       local $path_src
+       path_src=$1
+       if [ -e "$path_src" ]
+       then
+               realpath "$path_src"
+       else
+               expr "$path_src" : '^/' > /dev/null || echo -n `realpath .`
+               echo "$path_src"
+       fi
+}
+
+# ============= Inspect the privilege of the current environment on file system operation =============
+fs_inspect_fs_privilege ()
+{
+       local tgv mp mp_regexp mount_privilege basedir
+       [ -d "${TMPDIR}"/fs_privilege ] && return
+       tgv=${TMPDIR}/fs_privilege/test_tg
+       mkdir -p "$tgv" "${TMPDIR}"/fs_privilege/test_mp
+       mp=`realpath "${TMPDIR}"/fs_privilege/test_mp`
+       mp_regexp=`str_escape_regexp "$mp"`
+       echo yes > ${TMPDIR}/fs_privilege/fs_privilege
+       cat > ${TMPDIR}/fs_privilege/fslist << eof
+devfs  devfs
+fdescfs        null
+procfs proc
+tmpfs  tmpfs
+nullfs "$tgv"
+unionfs        "$tgv"
+eof
+       while read fs tg
+       do
+               if mount -t $fs "$tgv" "$mp" 2> /dev/null && umount "$mp"
+               then
+                       echo yes
+               else
+                       echo no
+                       echo no > ${TMPDIR}/fs_privilege/fs_privilege
+               fi > ${TMPDIR}/fs_privilege/fs_privilege:$fs 2> /dev/null
+               umount -f "$mp" 2> /dev/null || :
+               [ -e "${TMPDIR}"/fs_privilege/basedir ] && continue
+               mount -t $fs "$tgv" "$mp" 2> /dev/null && \
+                       df "$mp" > ${TMPDIR}/fs_privilege/df:$fs && \
+                       umount "$mp"
+               real_mp=`sed 1d "${TMPDIR}"/fs_privilege/df:$fs | tail -n 1 | \
+                       sed -E 's/^.*[[:space:]][0-9]+%[[:space:]]+//'`
+               echo "$real_mp" | sed -E "s/$mp_regexp$//" > ${TMPDIR}/fs_privilege/basedir
+       done < ${TMPDIR}/fs_privilege/fslist
+       mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege`
+       if [ "x$mount_privilege" = xyes ]
+       then
+               mount -t nullfs /bin "$mp" 2> /dev/null
+               if [ `ls "$mp" 2> /dev/null | wc -l` -gt 0 ]
+               then
+                       echo yes
+               else
+                       echo no
+               fi > ${TMPDIR}/fs_privilege/nullfs_target_recognition
+               umount -f "$mp" 2> /dev/null || :
+               nullfs_target_recognition=`cat "${TMPDIR}"/fs_privilege/nullfs_target_recognition`
+               if [ "x$nullfs_target_recognition" = xyes ]
+               then
+                       message_echo "INFO: The current environment has the full required privilege of mounting/unmounting file systems."
+               else
+                       message_echo "INFO: The current environment formally has the full required privilege of mounting/unmounting file systems but the recognition of nullfs/unionfs targets is incorrect."
+               fi
+       else
+               echo no > ${TMPDIR}/fs_privilege/nullfs_target_recognition
+               message_echo "INFO: The current environment does not have the privilege of mounting/unmounting for the following file system(s)."
+               while read fs tg
+               do
+                        mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege:$fs`
+                        [ "x$mount_privilege" = xyes ] || echo '  '$fs
+               done < ${TMPDIR}/fs_privilege/fslist | message_cat
+       fi
+       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
+       if [ -n "$basedir" ]
+       then
+               message_echo "INFO: The current environment will be a chroot/jail guest whose base directory is \"$basedir\"."
+       fi
+       if [ "x$opt_invalidate_mount_privilege" = xyes ]
+       then
+               message_echo "INFO: The privilege of mounting/unmounting in this environment is forcibly invalidated."
+       fi
+}
+
+# ============= Check whether mounting file systems are available at the current environment =============
+fs_chk_mount_privilege ()
+{
+       local mount_privilege
+       fs_inspect_fs_privilege
+       [ "x$opt_invalidate_mount_privilege" = xno ] || return
+       mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege`
+       nullfs_target_recognition=`cat "${TMPDIR}"/fs_privilege/nullfs_target_recognition`
+       [ "x$nullfs_target_recognition" = xyes -a "x$mount_privilege" = xyes ]
+}
+
+# ============= Check whether mounting file systems are available at the current environment =============
+fs_chk_unmount_privilege ()
+{
+       local mount_privilege
+       fs_inspect_fs_privilege
+       [ "x$opt_invalidate_mount_privilege" = xno ] || return
+       mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege`
+       [ "x$mount_privilege" = xyes ]
+}
+
+# ============= Get the base directory the current environment (applicable in case of a chroot guest) =============
+fs_get_system_basedir ()
+{
+       fs_inspect_fs_privilege
+       cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :
+}
+
+# ============= Get the regular expression pattern of the actual mount point =============
+fs_get_actual_mount_point_pattern ()
+{
+       local mountpoint basedir mountpoint_real
+       mountpoint=$1
+       [ -e  "$mountpoint" ] || return
+       fs_inspect_fs_privilege
+       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
+       mountpoint_real=`realpath "$mountpoint"`
+       mountpoint_real_full=`echo "$basedir$mountpoint_real" | sed 's|//*|/|'`
+       str_escape_regexp "$mountpoint_real_full"
+}
+
+# ============= Get mount info at the descendant directory levels required for builder chroot environment =============
+fs_get_descendant_mount_info ()
+{
+       local mountpoint mountpoint_real_regexp basedir
+       mountpoint=$1
+       mountpoint_real_regexp=`fs_get_actual_mount_point_pattern "$mountpoint"` || return
+       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
+       basedir_ptn=`str_escape_regexp "$basedir"`
+       df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp\/" | while read fs data
+       do
+               echo "$fs" | grep -q -e '^/' -e '^<above>:' && 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||"`
+               printf '%s\t%s\t%s\n' "$fs" "$mp" "$relative"
+       done
+}
+
+# ============= Repair the unionfs image if applicable and hidden =============
+# Use the side effect of find(1).
+fs_fix_unionfs_image_if_hidden ()
+{
+       local needlepath needlepath_next
+       needlepath=`realpath "$1"`
+       while :
+       do
+               find -dx "$needlepath" -maxdepth 0 echo "$needlepath"
+               needlepath_next=`dirname "$needlepath"`
+               [ "x$needlepath" = "x$needlepath_next" ] && break
+               needlepath=$needlepath_next
+       done
+}
+
+# ============= Check whether a directory is mounted properly =============
+fs_chk_mounted ()
+{
+       local type target mountpoint target_ptn mountpoint_real_regexp tmpsrc
+       type=$1
+       target=$2
+       mountpoint=$3ileedit
+       target_ptn=`echo "$target" | sed 's|//*|/|g' | str_escape_regexp_filter`
+       mountpoint_real_regexp=`fs_get_actual_mount_point_pattern "$mountpoint"` || return
+       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
+       basedir_target_ptn=`echo "$basedir/$target" | sed 's|//*|/|g' | str_escape_regexp_filter`
+       tmpsrc=${TMPDIR}/fs_chk_mounted:src
+       df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp$" > $tmpsrc
+       case $type in
+               nullfs )
+                       grep -qE "^${target_ptn}[[:space:]]" "$tmpsrc" || grep -qE "^${basedir_target_ptn}[[:space:]]" "$tmpsrc"
+                       ;;
+               unionfs )
+                       grep -qE "^<above>:${target_ptn}[[:space:]]" "$tmpsrc" || grep -qE "^<above>:${basedir_target_ptn}[[:space:]]" "$tmpsrc"
+                       ;;
+               devfs | fdescfs | procfs | linprocfs | tmpfs )
+                       grep -q "^$type" "$tmpsrc"
+                       ;;
+               *)
+                       message_echo "ERROR: Unsupported fyle system [$type]" >&2
+                       exit 1
+                       ;;
+       esac
+}
+
index e1ebd4c..c5c0e60 100644 (file)
@@ -12,7 +12,7 @@ main_set_version ()
        MYVERSION=4.0.0
        COMPATIBLE_VERSIONS='^(4\.[0]\.[0])$'
        # Template for development versions
-       MYVERSION=4.0.0+toward_4.0.1_20180709164228
+       MYVERSION=4.0.0+toward_4.0.1_20180710114409
        COMPATIBLE_VERSIONS='^(4\.[0]\.[0]|4\.[0]\.[0]+(|\+toward_4\.[0]\.[1]+_[0-9]+))$'
 }
 
index f5570e7..e00a6e2 100644 (file)
@@ -91,122 +91,6 @@ misc_get_console_row_size ()
        misc_get_console_size | sed -E 's/^([^ ]+) +[^ ]+/\1/'
 }
 
-# ============= Get the global path of a possibly not yet created file/directory =============
-misc_global_path ()
-{
-       local $path_src
-       path_src=$1
-       if [ -e "$path_src" ]
-       then
-               realpath "$path_src"
-       else
-               expr "$path_src" : '^/' > /dev/null || echo -n `realpath .`
-               echo "$path_src"
-       fi
-}
-
-# ============= Inspect the privilege of the current environment on file system operation =============
-misc_inspect_fs_privilege ()
-{
-       local tgv mp mp_regexp mount_privilege basedir
-       [ -d "${TMPDIR}"/fs_privilege ] && return
-       tgv=${TMPDIR}/fs_privilege/test_tg
-       mkdir -p "$tgv" "${TMPDIR}"/fs_privilege/test_mp
-       mp=`realpath "${TMPDIR}"/fs_privilege/test_mp`
-       mp_regexp=`str_escape_regexp "$mp"`
-       echo yes > ${TMPDIR}/fs_privilege/fs_privilege
-       cat > ${TMPDIR}/fs_privilege/fslist << eof
-devfs  devfs
-fdescfs        null
-procfs proc
-tmpfs  tmpfs
-nullfs "$tgv"
-unionfs        "$tgv"
-eof
-       while read fs tg
-       do
-               if mount -t $fs "$tgv" "$mp" 2> /dev/null && umount "$mp"
-               then
-                       echo yes
-               else
-                       echo no
-                       echo no > ${TMPDIR}/fs_privilege/fs_privilege
-               fi > ${TMPDIR}/fs_privilege/fs_privilege:$fs 2> /dev/null
-               umount -f "$mp" 2> /dev/null || :
-               [ -e "${TMPDIR}"/fs_privilege/basedir ] && continue
-               mount -t $fs "$tgv" "$mp" 2> /dev/null && \
-                       df "$mp" > ${TMPDIR}/fs_privilege/df:$fs && \
-                       umount "$mp"
-               real_mp=`sed 1d "${TMPDIR}"/fs_privilege/df:$fs | tail -n 1 | \
-                       sed -E 's/^.*[[:space:]][0-9]+%[[:space:]]+//'`
-               echo "$real_mp" | sed -E "s/$mp_regexp$//" > ${TMPDIR}/fs_privilege/basedir
-       done < ${TMPDIR}/fs_privilege/fslist
-       mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege`
-       if [ "x$mount_privilege" = xyes ]
-       then
-               mount -t nullfs /bin "$mp" 2> /dev/null
-               if [ `ls "$mp" 2> /dev/null | wc -l` -gt 0 ]
-               then
-                       echo yes
-               else
-                       echo no
-               fi > ${TMPDIR}/fs_privilege/nullfs_target_recognition
-               umount -f "$mp" 2> /dev/null || :
-               nullfs_target_recognition=`cat "${TMPDIR}"/fs_privilege/nullfs_target_recognition`
-               if [ "x$nullfs_target_recognition" = xyes ]
-               then
-                       message_echo "INFO: The current environment has the full required privilege of mounting/unmounting file systems."
-               else
-                       message_echo "INFO: The current environment formally has the full required privilege of mounting/unmounting file systems but the recognition of nullfs/unionfs targets is incorrect."
-               fi
-       else
-               echo no > ${TMPDIR}/fs_privilege/nullfs_target_recognition
-               message_echo "INFO: The current environment does not have the privilege of mounting/unmounting for the following file system(s)."
-               while read fs tg
-               do
-                        mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege:$fs`
-                        [ "x$mount_privilege" = xyes ] || echo '  '$fs
-               done < ${TMPDIR}/fs_privilege/fslist | message_cat
-       fi
-       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
-       if [ -n "$basedir" ]
-       then
-               message_echo "INFO: The current environment will be a chroot/jail guest whose base directory is \"$basedir\"."
-       fi
-       if [ "x$opt_invalidate_mount_privilege" = xyes ]
-       then
-               message_echo "INFO: The privilege of mounting/unmounting in this environment is forcibly invalidated."
-       fi
-}
-
-# ============= Check whether mounting file systems are available at the current environment =============
-misc_chk_mount_privilege ()
-{
-       local mount_privilege
-       misc_inspect_fs_privilege
-       [ "x$opt_invalidate_mount_privilege" = xno ] || return
-       mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege`
-       nullfs_target_recognition=`cat "${TMPDIR}"/fs_privilege/nullfs_target_recognition`
-       [ "x$nullfs_target_recognition" = xyes -a "x$mount_privilege" = xyes ]
-}
-
-# ============= Check whether mounting file systems are available at the current environment =============
-misc_chk_unmount_privilege ()
-{
-       local mount_privilege
-       misc_inspect_fs_privilege
-       [ "x$opt_invalidate_mount_privilege" = xno ] || return
-       mount_privilege=`cat "${TMPDIR}"/fs_privilege/fs_privilege`
-       [ "x$mount_privilege" = xyes ]
-}
-
-# ============= Get the base directory the current environment (applicable in case of a chroot guest) =============
-misc_get_system_basedir ()
-{
-       misc_inspect_fs_privilege
-       cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :
-}
-
 # ============= Check whether the current environment is in a jail =============
 misc_chk_in_jail ()
 {
@@ -215,67 +99,6 @@ misc_chk_in_jail ()
        [ x"$status" != x0 ]
 }
 
-# ============= Get the regular expression pattern of the actual mount point =============
-misc_get_actual_mount_point_pattern ()
-{
-       local mountpoint basedir mountpoint_real
-       mountpoint=$1
-       [ -e  "$mountpoint" ] || return
-       misc_inspect_fs_privilege
-       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
-       mountpoint_real=`realpath "$mountpoint"`
-       mountpoint_real_full=`echo "$basedir$mountpoint_real" | sed 's|//*|/|'`
-       str_escape_regexp "$mountpoint_real_full"
-}
-
-# ============= Get mount info at the descendant directory levels required for builder chroot environment =============
-misc_get_descendant_mount_info ()
-{
-       local mountpoint mountpoint_real_regexp basedir
-       mountpoint=$1
-       mountpoint_real_regexp=`misc_get_actual_mount_point_pattern "$mountpoint"` || return
-       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
-       basedir_ptn=`str_escape_regexp "$basedir"`
-       df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp\/" | while read fs data
-       do
-               echo "$fs" | grep -q -e '^/' -e '^<above>:' && 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||"`
-               printf '%s\t%s\t%s\n' "$fs" "$mp" "$relative"
-       done
-}
-
-# ============= Check whether a directory is mounted properly =============
-misc_chk_mounted ()
-{
-       local type target mountpoint target_ptn mountpoint_real_regexp tmpsrc
-       type=$1
-       target=$2
-       mountpoint=$3
-       target_ptn=`echo "$target" | sed 's|//*|/|g' | str_escape_regexp_filter`
-       mountpoint_real_regexp=`misc_get_actual_mount_point_pattern "$mountpoint"` || return
-       basedir=`cat "${TMPDIR}"/fs_privilege/basedir 2> /dev/null || :`
-       basedir_target_ptn=`echo "$basedir/$target" | sed 's|//*|/|g' | str_escape_regexp_filter`
-       tmpsrc=${TMPDIR}/misc_chk_mounted:src
-       df | sed 1d | grep -E "%[[:space:]]+$mountpoint_real_regexp$" > $tmpsrc
-       case $type in
-               nullfs )
-                       grep -qE "^${target_ptn}[[:space:]]" "$tmpsrc" || grep -qE "^${basedir_target_ptn}[[:space:]]" "$tmpsrc"
-                       ;;
-               unionfs )
-                       grep -qE "^<above>:${target_ptn}[[:space:]]" "$tmpsrc" || grep -qE "^<above>:${basedir_target_ptn}[[:space:]]" "$tmpsrc"
-                       ;;
-               devfs | fdescfs | procfs | linprocfs | tmpfs )
-                       grep -q "^$type" "$tmpsrc"
-                       ;;
-               *)
-                       message_echo "ERROR: Unsupported fyle system [$type]" >&2
-                       exit 1
-                       ;;
-       esac
-}
-
 # ============= Selection of removing leaf ports =============
 # Box options for dialog(1) are given via stdin.
 misc_dialog_checklist ()
index 10fd38a..43d82f7 100644 (file)
@@ -36,6 +36,7 @@ pkgsys_sysvar ()
        tmp_work=${TMPDIR}/pkgsys_sysvar:work
        rm -rf "$tmp_work"
        mkdir "$tmp_work"
+       fs_fix_unionfs_image_if_hidden "${PORTSDIR}/Mk/bsd.port.mk"
        make -C "$tmp_work" -f "${PORTSDIR}/Mk/bsd.port.mk" -V "$var" 2> /dev/null
 }
 
@@ -655,6 +656,7 @@ pkgsys_def_pkgtools ()
                                unset WITHOUT_PKGNG
                                message_echo "INFO: Attempting deinstallation of pkg(8) to make sure."
                                portsmgmt_port_path=`pkgsys_get_portpath_from_origin "$origin_portsmgmt"`
+                               fs_fix_unionfs_image_if_hidden "${TMPDIR}/make.conf"
                                env __MAKE_CONF="${TMPDIR}/make.conf" make -C "$portsmgmt_port_path" deinstall || :
                                message_echo "INFO: Attempting (re)installation by pkg(8)."
                                env __MAKE_CONF="${TMPDIR}/make.conf" make -C "$portsmgmt_port_path" reinstall clean
@@ -1112,6 +1114,7 @@ pkgsys_eval_ports_glob ()
                                        
                                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@|"
                                done
@@ -1123,6 +1126,7 @@ pkgsys_eval_ports_glob ()
                                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 || :
                                        if [ `wc -l < $tmp_flavors` -gt 0 ]
@@ -1153,6 +1157,7 @@ pkgsys_eval_ports_glob ()
                        done | 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 || :
                                [ `wc -l < $tmp_flavors` -gt 0 ] || echo > $tmp_flavors
index 51183d5..dff581b 100644 (file)
@@ -148,6 +148,7 @@ _reinstall_make_common ()
        MAKE_ARGS=`reinstall_setup_make_args $mode`
        MAKE_ENVS=`reinstall_setup_make_envs`
        port_path=`pkgsys_get_portpath_from_origin "$REINSTALL_ORIGIN"`
+       fs_fix_unionfs_image_if_hidden "$port_path"
        env $MAKE_ENVS make -C "$port_path" "$@" $MAKE_ARGS
 }
 
index a831ecf..93f699c 100644 (file)
@@ -44,5 +44,5 @@ eof
 # ============= Regularize the option value =============
 options_regularize ()
 {
-       opt_packages_dir=`misc_global_path "$opt_packages_dir"`
+       opt_packages_dir=`fs_global_path "$opt_packages_dir"`
 }
index abfb478..ea223eb 100644 (file)
@@ -1081,6 +1081,8 @@ Configuration file of \fBportupgrade\fR(1).
 .PP
 [IMPROVED] It is changed to detect unflavored ports or ports with old flavor names of flavored ports as obsolete.
 .PP
+[IMPROVED] The behavior with union file systems is stabilized.
+.PP
 [IMPROVED] It is changed to show messages of reset ports at the stage of reloading ${LOCALBASE}/etc/portsreinstall.conf.
 .PP
 [BUG FIX] Changes made by commands or in ${LOCALBASE}/etc/portsreinstall.conf were not reflected to dependents of the specified ports in the redo runs with incorrect messages notifying as already inspected merged ports.
index 72f7c42..90f4bc2 100755 (executable)
@@ -32,6 +32,7 @@ ETCDIR=${MYPREFIX}/etc
 . ${LIBDIR}/libdatabase_record.sh
 . ${LIBDIR}/libdeinstall.sh
 . ${LIBDIR}/libfileedit.sh
+. ${LIBDIR}/libfs.sh
 . ${LIBDIR}/libmain.sh
 . ${LIBDIR}/libmessage.sh
 . ${LIBDIR}/libmisc.sh
index 7c4735f..533152a 100644 (file)
@@ -31,6 +31,7 @@ ETCDIR=${MYPREFIX}/etc
 . ${LIBDIR}/libdatabase_record.sh
 . ${LIBDIR}/libdeinstall.sh
 . ${LIBDIR}/libfileedit.sh
+. ${LIBDIR}/libfs.sh
 . ${LIBDIR}/libmain.sh
 . ${LIBDIR}/libmessage.sh
 . ${LIBDIR}/libmisc.sh