Subject: pkg/26235: pkgsrc makes use of test -e (or [ -e), which does not work on some platforms
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <geos@epost.de>
List: pkgsrc-bugs
Date: 07/10/2004 19:50:43
>Number:         26235
>Category:       pkg
>Synopsis:       pkgsrc makes use of test -e (or [ -e), which does not work on some platforms
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 10 19:51:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Georg Schwarz
>Release:        current pkgsrc
>Organization:
>Environment:
IRIX lorenz 5.3 08031225 IP20 mips
>Description:
Pkgsrc makes use of TEST -e in various files. Some shells´ test on certain platforms does not understand -e. The following files are affected:

pkgsrc/mk/install/install
pkgsrc/mk/install/deinstall

as well as

pkgsrc/audio/rio/files/find-lpt-port
pkgsrc/comms/conserver/files/conserver.sh
pkgsrc/comms/minicom/scripts/create-dev-link
pkgsrc/emulators/*/INSTALL
pkgsrc/graphics/fxtv/Makefile
pkgsrc/net/ja-samba/INSTALL
pkgsrc/net/samba/INSTALL
pkgsrc/net/samba2/INSTALL
pkgsrc/pkgtools/pkg_install/files/view/linkfarm.sh.in
pkgsrc/www/opera6/files/opera.sh
pkgsrc/www/wwwoffle/INSTALL
pkgsrc/www/opera7/files/opera.sh
pkgsrc/textproc/nbsed/files/TEST/sed.test

furthermore, some of the following patchsets also contain TEST -e:

pkgsrc/audio/abcde
pkgsrc/audio/cdparanoia
pkgsrc/audio/kdemultimedia2
pkgsrc/ham/dpbox
pkgsrc/lang/sather
pkgsrc/misc/heyu
pkgsrc/misc/pdmenu
pkgsrc/misc/vfu
pkgsrc/sysutils/xentools12
pkgsrc/www/asp2php
pkgsrc/www/gtkasp2php
pkgsrc/www/ap-jserv

(some of them are most likely for NetBSD only, so it does not matter there)


Similarly, some pkgsrc scripts use -ef to check for hardlinks. This suffers from similar portability problems. (here however I unfortunately do not know how to overcome this)
>How-To-Repeat:

>Fix:
Replace -e by -f, -d, -b, or -c, as appropriate. -r or -s might also be an option.
The following two patches should do that for the mk files affected:

--- pkgsrc/mk/install/install.orig      2004-07-10 15:34:52.000000000 +0200
+++ pkgsrc/mk/install/install   2004-07-10 15:46:07.000000000 +0200
@@ -117,7 +117,7 @@
                                print;                                  \
                        }'                                              \
                `
-               if [ -d $sysconfdir -a ! -e ${PKG_SYSCONFDIR} ]; then
+               if [ -d $sysconfdir -a ! -d ${PKG_SYSCONFDIR} ]; then
                        ${MKDIR} -p `${DIRNAME} ${PKG_SYSCONFDIR}`
                        ${LN} -sf $sysconfdir ${PKG_SYSCONFDIR}
                fi
@@ -241,13 +241,13 @@
                                msgadd ""
                        fi
                        msgadd "#${file} (m=@CONF_FILES_MODE@)"
-               elif [ -e "${file}" ]; then
+               elif [ -f "${file}" ]; then
                        if [ ! "${file}" -ef "${samplefile}" ]; then
                                ${ECHO} "       ${file} already exists, example file is"
                                ${ECHO} "           ${samplefile}"
                        fi
                else
-                       if [ -e "${samplefile}" ]; then
+                       if [ -f "${samplefile}" ]; then
                                ${ECHO} "       ${file}"
                                ${CP} "${samplefile}" "${file}"
                                ${CHMOD} @CONF_FILES_MODE@ "${file}"
@@ -267,13 +267,13 @@
                                msgadd ""
                        fi
                        msgadd "#${file} (m=@SUPPORT_FILES_MODE@)"
-               elif [ -e "${file}" ]; then
+               elif [ -f "${file}" ]; then
                        if [ ! "${file}" -ef "${samplefile}" ]; then
                                ${ECHO} "       ${file} already exists, example file is"
                                ${ECHO} "           ${samplefile}"
                        fi
                else
-                       if [ -e "${samplefile}" ]; then
+                       if [ -f "${samplefile}" ]; then
                                ${ECHO} "       ${file}"
                                ${CP} "${samplefile}" "${file}"
                                ${CHMOD} @SUPPORT_FILES_MODE@ "${file}"
@@ -294,13 +294,13 @@
                                msgadd ""
                        fi
                        msgadd "#${file} (o=${owner}, g=${group}, m=${mode})"
-               elif [ -e ${file} ]; then
+               elif [ -f ${file} ]; then
                        if [ ! "${file}" -ef "${samplefile}" ]; then
                                ${ECHO} "       ${file} already exists, example file is"
                                ${ECHO} "           ${samplefile}"
                        fi
                else
-                       if [ -e "${samplefile}" ]; then
+                       if [ -f "${samplefile}" ]; then
                                ${ECHO} "       ${file}"
                                ${CP} "${samplefile}" "${file}"
                                ${CHOWN} "${owner}" "${file}"
@@ -323,13 +323,13 @@
                                msgadd ""
                        fi
                        msgadd "#${file} (m=@RCD_SCRIPTS_MODE@)"
-               elif [ -e "${file}" ]; then
+               elif [ -f "${file}" ]; then
                        if [ ! "${file}" -ef "${samplefile}" ]; then
                                ${ECHO} "       ${file} already exists, example file is"
                                ${ECHO} "           ${samplefile}"
                        fi
                else
-                       if [ -e "${samplefile}" ]; then
+                       if [ -f "${samplefile}" ]; then
                                ${ECHO} "       ${file}"
                                ${CP} "${samplefile}" "${file}"
                                ${CHMOD} @RCD_SCRIPTS_MODE@ "${file}"



--- pkgsrc/mk/install/deinstall.orig    2004-07-10 15:35:00.000000000 +0200
+++ pkgsrc/mk/install/deinstall 2004-07-10 15:46:55.000000000 +0200
@@ -111,7 +111,7 @@
                        shift; shift
 
                        if [ ! "${file}" -ef "${samplefile}" -a         \
-                            -e "${file}" -a -e "${samplefile}" ]; then
+                            -f "${file}" -a -f "${samplefile}" ]; then
                                if ${CMP} -s "${file}" "${samplefile}"; then
                                        ${RM} -f "${file}"
                                fi
@@ -127,7 +127,7 @@
                samplefile="$1"; file="$2"
                shift; shift
 
-               if [ -e "${file}" ]; then
+               if [ -f "${file}" ]; then
                        modified_files="${modified_files} \"${file}\""
                fi
        done


(sorry for the lost tabs; nevertheless the above changes should be easy to read)




>Release-Note:
>Audit-Trail:
>Unformatted: