From: gobo72 Date: Sun, 13 Mar 2011 21:57:31 +0000 (+0000) Subject: Remplacement "grep 1> /dev/null 2>&1" par "grep -q" X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=564ec1bbb321286571c30da20b81620c33b18e6f;p=hvlinux.git Remplacement "grep 1> /dev/null 2>&1" par "grep -q" --- diff --git a/config/packages-list b/config/packages-list index fcc0617..c89539e 100644 --- a/config/packages-list +++ b/config/packages-list @@ -272,7 +272,7 @@ LIBNOTIFY="libnotify-0.4.4" LIBOGG="libogg-1.1.4" LIBOIL="liboil-0.3.17" LIBOPENJPEG="libopenjpeg-1.2" -LIBPCAP="libpcap-1.0.0" +LIBPCAP="libpcap-1.1.1" LIBPNG="libpng-1.2.44" LIBPROXY="libproxy-0.2.3" LIBPTHREAD_STUBS="libpthread-stubs-0.3" @@ -321,7 +321,7 @@ NSS="nss-3.12-with-nspr-4.7" OPENJADE="openjade-1.3.2" OPENLDAP="openldap-2.3.38" OPENSP="OpenSP-1.5.2" -OPENSSH="openssh-5.6p1" +OPENSSH="openssh-5.8p1" OPENSSL="openssl-1.0.0b" OPENSSL_ROOT_CERTS="BLFS-ca-bundle-3.12.8.0" diff --git a/functions/fpkg b/functions/fpkg index c420d7b..2d3b474 100644 --- a/functions/fpkg +++ b/functions/fpkg @@ -165,8 +165,8 @@ detect_file_not_found() { # HTTP: will return "ERROR 404: Not Found" # FTP: will say "File not found" or "No such file" - if grep --ignore-case -e "not found" -e "no such file" ${WGET_LOG_FILE} \ - 1> /dev/null 2>&1; then + if grep -q --ignore-case -e "not found" -e "no such file" ${WGET_LOG_FILE}; \ + then #echo "404 NOTFOUND" return 0 fi @@ -215,8 +215,7 @@ static_getpkg() # Failure: if it was a connection timeout, don't try for other file # extensions. - if grep "failed: Connection timed out" ${WGET_LOG_FILE} \ - 1> /dev/null 2>&1; then + if grep -q "failed: Connection timed out" ${WGET_LOG_FILE}; then echo "Error, wget reported: Connection timed out" return 1 fi @@ -550,9 +549,10 @@ fpkg() # Rename any patch fetched (in fpkg call) and replace SOURCE by TARGET # in patch name. - if ls ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch 1> /dev/null 2>&1; then - echo "CMD=${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch" - rename ${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch + local PATCHES_LIST="${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch" + if ls ${PATCHES_LIST} 1> /dev/null 2>&1; then + echo "CMD=${SRC_FILENAME} ${PACK} ${PATCHES_LIST}" + rename ${SRC_FILENAME} ${PACK} ${PATCHES_LIST} fi fi } diff --git a/functions/ipkg b/functions/ipkg index 177f52c..9d3ea3e 100644 --- a/functions/ipkg +++ b/functions/ipkg @@ -154,7 +154,7 @@ ipkg_script() if [ "x${IPKG_MODE}" != "xnoac" ]; then # Add option --disable-dependency-tracking if supported if cat ${LFS_TMP}/${PACKAGE}/configure | \ - grep "disable-dependency-tracking" 1> /dev/null 2>&1; then + grep -q "disable-dependency-tracking"; then CONFIGURE_OPTS="\ ${CONFIGURE_OPTS} \ --disable-dependency-tracking" diff --git a/functions/main b/functions/main index e0bd99e..7207157 100644 --- a/functions/main +++ b/functions/main @@ -372,20 +372,20 @@ var_export() fi # Checking if variable exists - if ! grep "${VARIABLE}=" ${FILE} 1> /dev/null 2>&1; then + if ! grep -q "${VARIABLE}=" ${FILE}; then echo "${FUNCNAME}(), variable not found: ${VARIABLE}" return 1 fi # Checking if variable is already exported when it is defined - if grep "${VARIABLE}=" ${FILE} | grep "export " 1> /dev/null 2>&1; then + if grep "${VARIABLE}=" ${FILE} | grep -q "export "; then echo "${FUNCNAME}(), variable already exported in definition: ${VARIABLE}" return 0 fi # Checking if variable is already exported, in # a "export VARIABLE1 VARIABLE2..." statement - if grep "export " ${FILE} | grep " ${VARIABLE}" 1> /dev/null 2>&1; then + if grep "export " ${FILE} | grep -q " ${VARIABLE}"; then echo "${FUNCNAME}(), variable already exported in export list: ${VARIABLE}" return 0 fi @@ -419,13 +419,13 @@ var_add() fi # Checking if variable exists - if ! grep "${VARIABLE}=" ${FILE} 1> /dev/null 2>&1; then + if ! grep -q "${VARIABLE}=" ${FILE}; then echo "${VARIABLE}=\"${VALUE}\"" >> ${FILE} return $? fi # Checking if variable contains the new value - if grep "${VARIABLE}=" ${FILE} | grep "${VALUE}" 1> /dev/null 2>&1; then + if grep "${VARIABLE}=" ${FILE} | grep -q "${VALUE}"; then echo "${FUNCNAME}(), variable ${VARIABLE} already contains value: ${VALUE}" return 0 fi @@ -434,7 +434,7 @@ var_add() # We search for the variable name starting at the beginning of the line # For example, this ensures that if the variable name is PATH, then # PATH=... matches but not MANPATH=... - if grep "^${VARIABLE}=\"" ${FILE} 1> /dev/null 2>&1; then + if grep -q "^${VARIABLE}=\"" ${FILE}; then # Variable value is enclosed by double-quotes sed -i "s!\(^${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE} else @@ -447,7 +447,7 @@ var_add() # at the beginning of a line. # For example, this ensures that if the variable name is PATH, then # PATH=... matches but not MANPATH=... - if grep "^export ${VARIABLE}=\"" ${FILE} 1> /dev/null 2>&1; then + if grep -q "^export ${VARIABLE}=\"" ${FILE}; then # Variable value is enclosed by double-quotes sed -i "s!\(^export ${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE} else @@ -500,7 +500,7 @@ string_add() fi # Checking if string exists - if grep "${STRING}" ${FILE} 1> /dev/null 2>&1; then + if grep -q "${STRING}" ${FILE}; then echo "${FUNCNAME}(), string already defined: ${STRING}" return 0 fi @@ -532,7 +532,7 @@ var_add_shadow() fi # Checking if variable contains the new value - if egrep "^${VARIABLE}" ${FILE} | grep "${VALUE}" 1> /dev/null 2>&1; then + if egrep "^${VARIABLE}" ${FILE} | grep -q "${VALUE}"; then echo "${FUNCNAME}(), variable ${VARIABLE} already contains value: ${VALUE}" return 0 fi @@ -556,7 +556,7 @@ hv_groupadd() shift done - if ! cat /etc/group | egrep "^${groupname}:" 1> /dev/null 2>&1; then + if ! cat /etc/group | egrep -q "^${groupname}:"; then groupadd ${arguments} fi } @@ -573,7 +573,7 @@ hv_useradd() shift done - if ! cat /etc/passwd | egrep "^${username}:" 1> /dev/null 2>&1; then + if ! cat /etc/passwd | egrep -q "^${username}:"; then useradd ${arguments} fi } @@ -860,8 +860,7 @@ ipkg() PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log # Checking if package was previously successfully installed - if grep "^${HVLABEL} successfully installed" ${LFS_LOG_FILE} \ - 1> /dev/null 2>&1; then + if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then return $EXIT_SUCCESS fi @@ -957,7 +956,7 @@ rscr() if [ "x${SCRMODE}" = "xonce" ]; then # Checking if package was previously successfully installed - if grep "^${HVLABEL} successfully installed" ${LFS_LOG_FILE} 1> /dev/null 2>&1; then + if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then return $EXIT_SUCCESS fi fi diff --git a/stage0/pre-install b/stage0/pre-install index c07c163..15c38a8 100755 --- a/stage0/pre-install +++ b/stage0/pre-install @@ -19,7 +19,7 @@ fi # We cannot always automatically create the user 'lfs' because the installation # media can be a CD-ROM (read-only) If installing from some kind of live-CD, # simply install as root without the LFS user :) -if ! grep "lfs" /etc/passwd 1> /dev/null 2>&1; then +if ! grep -q "lfs" /etc/passwd; then groupadd -f lfs # The option '-k /dev/null' prevents possible copying of files from a # skeleton directory (default is /etc/skel). diff --git a/stage1/bootscripts/functions b/stage1/bootscripts/functions index 3d8ffb5..4056f1a 100644 --- a/stage1/bootscripts/functions +++ b/stage1/bootscripts/functions @@ -449,7 +449,7 @@ reloadproc() if [ ${?} -ne 0 ]; then sleep 2 - if statusproc ${base} | grep "not running" 1> /dev/null 2>&1; then + if statusproc ${base} | grep -q "not running"; then return ${EXIT_CODE_FAILURE} fi fi diff --git a/stage2/hv-utilities/camera-download b/stage2/hv-utilities/camera-download index 7271f49..5734b67 100755 --- a/stage2/hv-utilities/camera-download +++ b/stage2/hv-utilities/camera-download @@ -39,7 +39,7 @@ if [ $# -ne 0 ]; then fi -if ! mount | grep ${MOUNTPOINT} 1> /dev/null 2>&1; then +if ! mount | grep -q ${MOUNTPOINT}; then mount ${MOUNTPOINT} || exit 1 fi diff --git a/stage2/hv-utilities/media-write b/stage2/hv-utilities/media-write index 1f83ab9..e66dba6 100755 --- a/stage2/hv-utilities/media-write +++ b/stage2/hv-utilities/media-write @@ -14,15 +14,15 @@ GROWISOFS_OPTS="-dvd-compat" # Try to read ATIP infos for CD disks to estimate capacity... MEDIA_ATIP_INFOS=$(cdrecord dev=${MEDIA_DEV} -atip 2>&1) -if echo ${MEDIA_ATIP_INFOS} | grep "ATIP info from disk" 1> /dev/null 2>&1; then +if echo ${MEDIA_ATIP_INFOS} | grep -q "ATIP info from disk"; then MEDIA_SIZE=${CD_MEDIA_SIZE} MEDIA_TYPE="CD" echo "CD disk detected" -elif echo ${MEDIA_ATIP_INFOS} | grep "Found DVD media but" 1> /dev/null 2>&1; then +elif echo ${MEDIA_ATIP_INFOS} | grep -q "Found DVD media but"; then MEDIA_SIZE=${DVD_MEDIA_SIZE} MEDIA_TYPE="DVD" echo "DVD disk detected" -elif echo ${MEDIA_ATIP_INFOS} | grep "cdrecord: No disk / Wrong disk" 1> /dev/null 2>&1; then +elif echo ${MEDIA_ATIP_INFOS} | grep -q "cdrecord: No disk / Wrong disk"; then echo "No disk inserted, aborting" exit 1 else @@ -142,7 +142,7 @@ case "${MEDIA_TYPE}" in esac # Mounting the media to verify burned capacity -if ! grep ${MEDIA_DEV} /etc/mtab 1> /dev/null 2>&1; then +if ! grep -q ${MEDIA_DEV} /etc/mtab; then mount ${MEDIA_DEV} ${MEDIA_DIR} || exit 1 fi diff --git a/stage2/toolchain-test b/stage2/toolchain-test index 588ec94..cf8fa58 100755 --- a/stage2/toolchain-test +++ b/stage2/toolchain-test @@ -7,7 +7,8 @@ cd /tmp echo 'main(){}' > dummy.c gcc dummy.c -Wl,--verbose &> dummy.log -if ! readelf -l a.out | grep 'Requesting program interpreter: /lib/ld-linux.*.so.2' 1> /dev/null 2>&1 ; then +if ! readelf -l a.out | \ + grep -q 'Requesting program interpreter: /lib/ld-linux.*.so.2'; then echo "String 'Requesting program interpreter: /lib/ld-linux.*.so.2' not found" exit 1 fi diff --git a/stage4/bootscripts/dbus b/stage4/bootscripts/dbus index 4c21ac8..fe6987f 100755 --- a/stage4/bootscripts/dbus +++ b/stage4/bootscripts/dbus @@ -8,7 +8,7 @@ source /etc/rc.d/init.d/functions log_script_name "$0 $*" dbus_start() { - if statusproc dbus-daemon | grep "not running" 1> /dev/null 2>&1; then + if statusproc dbus-daemon | grep -q "not running"; then if [ -f /var/run/dbus/pid ]; then rm /var/run/dbus/pid fi diff --git a/stage4/configure-fonts b/stage4/configure-fonts index cfc35b3..7673a20 100755 --- a/stage4/configure-fonts +++ b/stage4/configure-fonts @@ -11,9 +11,10 @@ ln -svfT /usr/lib/X11/fonts/TTF /usr/share/fonts/X11-TTF X11_FONTS_DIR="/usr/share/fonts/X11" -if ! grep "${X11_FONTS_DIR}" /etc/fonts/local.conf 1> /dev/null 2>&1; then +if ! grep -q "${X11_FONTS_DIR}" /etc/fonts/local.conf; then # Adding X fonts directory to local configuration file - sed -i -e "s!\(\)! ${X11_FONTS_DIR}\n\1!" /etc/fonts/local.conf + sed -i -e "s!\(\)! ${X11_FONTS_DIR}\n\1!" \ + /etc/fonts/local.conf fi # Updating cache database. diff --git a/stage4/packages-update b/stage4/packages-update index f8da0ae..c636557 100755 --- a/stage4/packages-update +++ b/stage4/packages-update @@ -50,7 +50,7 @@ for module in ${XORG_MODULES_LIST}; do pushd ${DEST_DIR} >> ${LFS_LOG_FILE} # The "driver" md5 file maybe empty if the nouveau driver was selected - if cat ${LFS_PKG_DIR}/${MOD_NAME}/${module}.md5 | grep "[0-9]" 1> /dev/null 2>&1; then + if cat ${LFS_PKG_DIR}/${MOD_NAME}/${module}.md5 | grep -q "[0-9]"; then md5sum -c ${LFS_PKG_DIR}/${MOD_NAME}/${module}.md5 >> ${LFS_LOG_FILE} if [ $? -ne 0 ]; then echo " md5sum error for ${module}" diff --git a/stage5/bootscripts/clamav b/stage5/bootscripts/clamav index 5ffe846..32f32a0 100755 --- a/stage5/bootscripts/clamav +++ b/stage5/bootscripts/clamav @@ -9,7 +9,7 @@ SOCKET_DIR="/var/run/clamav" start() { - if statusproc clamd | grep "not running" 1> /dev/null 2>&1; then + if statusproc clamd | grep -q "not running"; then # Not taking any chances, removing left-over files rm -f ${SOCKET_DIR}/clamd.{sock,pid} || return 1 fi @@ -17,12 +17,13 @@ start() sleep 1 - if statusproc clamav-milter | grep "not running" 1> /dev/null 2>&1; then + if statusproc clamav-milter | grep -q "not running"; then # Not taking any chances, removing left-over files rm -f ${SOCKET_DIR}/clmilter.sock || return 1 fi # Option "--postmaster-only" is to send warnings only to postmaster. - loadproc /usr/sbin/clamav-milter --local --outgoing --headers --postmaster-only ${SOCKET_DIR}/clmilter.sock + loadproc /usr/sbin/clamav-milter --local --outgoing --headers \ + --postmaster-only ${SOCKET_DIR}/clmilter.sock return $? } diff --git a/stage5/pkg/apache b/stage5/pkg/apache index ab03860..37559e3 100644 --- a/stage5/pkg/apache +++ b/stage5/pkg/apache @@ -22,15 +22,13 @@ hvbuild_post() # There's a problem with the ISAPI DSO module caused from compiling with # GCC-4.1.2. # Commenting out the module from the configuration: - if grep "LoadModule isapi_module" /etc/apache/httpd.conf \ - 1> /dev/null 2>&1; then + if grep -q "LoadModule isapi_module" /etc/apache/httpd.conf; then sed -i -e "s/^LoadModule isapi_module/# &/" /etc/apache/httpd.conf fi # Modifying the listening port if an alternate one is specified. if [ -n "${HTTPD_PORT}" ]; then - if ! grep "Listen ${HTTPD_PORT}" /etc/apache/httpd.conf \ - 1> /dev/null 2>&1; then + if ! grep -q "Listen ${HTTPD_PORT}" /etc/apache/httpd.conf; then # Adding alternate port to default port of 80 sed -i -e "s%\(Listen 80\)%\1\nListen ${HTTPD_PORT}%" \ /etc/apache/httpd.conf diff --git a/stage5/pkg/ghostscript b/stage5/pkg/ghostscript index 242d9a3..5ff4e24 100644 --- a/stage5/pkg/ghostscript +++ b/stage5/pkg/ghostscript @@ -45,7 +45,7 @@ hvbuil_post() rmdir ${LFS_TMP}/fonts chown -v -R root:root ${GS_FONTS_PATH} - if ! grep "${GS_FONTS_PATH}" /etc/fonts/local.conf 1> /dev/null 2>&1; then + if ! grep -q "${GS_FONTS_PATH}" /etc/fonts/local.conf; then # Adding Ghostscript fonts directory to local configuration file sed -i -e "s!\(\)! ${GS_FONTS_PATH}\n\1!" \ /etc/fonts/local.conf diff --git a/stage5/pkg/php b/stage5/pkg/php index ad91548..87f343b 100644 --- a/stage5/pkg/php +++ b/stage5/pkg/php @@ -48,13 +48,11 @@ hvbuild_post() # To enable PHP support in the Apache web server, a new AddType directive # must be added to the httpd.conf file. - if ! grep "application/x-httpd-php" /etc/apache/httpd.conf \ - 1> /dev/null 2>&1; then + if ! grep -q "application/x-httpd-php" /etc/apache/httpd.conf; then echo "AddType application/x-httpd-php .php" >> /etc/apache/httpd.conf fi - if ! grep "DirectoryIndex" /etc/apache/httpd.conf | grep "index.php" \ - 1> /dev/null 2>&1; then + if ! grep -q "DirectoryIndex" /etc/apache/httpd.conf | grep "index.php"; then sed -i -e "s!\(^DirectoryIndex index.html.*\)!\1 index.php!g" \ /etc/apache/httpd.conf fi