commit:     4e5b7557ea50bc7e6b037e67ac222fb65766646d
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Fri Sep  6 00:59:02 2019 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri Sep  6 06:53:10 2019 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=4e5b7557

gcc-config: Use findmnt for mountpoint check when available.

Closes: https://bugs.gentoo.org/693588
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 gcc-config | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/gcc-config b/gcc-config
index 9e5abf8..169f8bc 100755
--- a/gcc-config
+++ b/gcc-config
@@ -145,6 +145,37 @@ is_cross_compiler() {
        [[ ${CC_COMP/${CHOST}} == ${CC_COMP} ]]
 }
 
+is_same_mountpoint() {
+       local file1=$1 file2=$2
+
+       if type -P findmnt > /dev/null ; then
+               local file1_mountpoint=$(findmnt -n -o TARGET -T "${file1}")
+               local file2_mountpoint=$(findmnt -n -o TARGET -T "${file2}")
+
+               [[ ${file1_mountpoint} == ${file2_mountpoint} ]]
+               return
+       else
+               local file1_check_file file2_check_file result
+               if [[ -d ${file1} ]] ; then
+                       
file1_check_file=${file1}/.gcc.config.mountpoint_check_file1.$$
+               else
+                       
file1_check_file=${file1%/*}/.gcc.config.mountpoint_check_file1.$$
+               fi
+               if [[ -d ${file2} ]] ; then
+                       
file2_check_file=${file2}/.gcc.config.mountpoint_check_file2.$$
+               else
+                       
file2_check_file=${file2%/*}/.gcc.config.mountpoint_check_file2.$$
+               fi
+
+               rm -f "${file1_check_file}" "${file2_check_file}"
+               touch "${file1_check_file}"
+               ln "${file1_check_file}" "${file2_check_file}" 2> /dev/null
+               result=$?
+               rm -f "${file1_check_file}" "${file2_check_file}"
+               return ${result}
+       fi
+}
+
 # Usage: atomic_ln <source file> <destination dir> <destination file name>
 atomic_ln() {
        local src=$1 dst=$2 dstfile=$3 tmp
@@ -277,13 +308,11 @@ handle_split_usr() {
        # We use the same ordering logic as mentioned in the MY_LDPATH setup.
        # We get the libs from the latest version available.
        local LDPATH
-
        eval $(grep -h '^LDPATH=' "${GCC_ENV_D}"/${CHOST}-* | tail -1)
        LDPATH=${LDPATH%%:*}
 
-       # If /usr isn't a sep mount, then don't bother with linking stuff.
-       if ln "${ROOT}/${LDPATH}/libgcc.a" "${EROOT}"/lib/.gcc.config.$$ 
2>/dev/null ; then
-               rm -f "${EROOT}"/lib/.gcc.config.$$
+       # If GCC directory is not in separate mountpoint than /lib, then do not 
bother with copying libraries to /lib.
+       if is_same_mountpoint "${EROOT}/lib" "${ROOT}/${LDPATH}" ; then
                local lib old_libs=0 saved_nullglob=$(shopt -p nullglob)
                shopt -s nullglob
                for lib in "${EROOT}"/lib*/libgcc_s{.so*,*dylib} 
"${EROOT}"/lib*/libunwind.so.7* ; do

Reply via email to