使用--quiet选项标志运行rpmbuild命令会产生大量调试信息

时间:2009-05-28 07:01:06

标签: linux debugging shell rpm sh

我希望最小化rpm构建过程的输出。

我运行以下命令:rpmbuild -ba --quiet "/tmp/yaneeve/kit/linux/rpm_spec"

我的系统是:Linux yaneeve-lnx-82-5 2.4.21-47.ELsmp #1 SMP Wed Jul 5 20:38:41 EDT 2006 i686 i686 i386 GNU/Linux

rpmbuild版本为:RPM version 4.2.3

我的rpm规范文件的%prep部分是:

%prep

. $LOGGER_FUNC_FILE_LOCATION/logger.sh

SCRIPT_NAME='rpm_spec-prep'
SOURCE_DIR=`readlink -f -n %{_sourcedir}`
PACKAGE_DIR=`readlink -f -n %{_pkg_script_dir}`
BUILD_PRODUCT_DIR=`readlink -f -n %{_build_product_dir}`
RESOURCE_DIR=`readlink -f -n %{_resource_dir}`

log $SCRIPT_NAME INFO "In the prep stage of the rpm spec file..."

if [[ -d $SOURCE_DIR && `ls -a $SOURCE_DIR | wc -w` -gt 2 ]] ; then
    log $SCRIPT_NAME INFO "Source directory exists and is not empty - deleting content."
    rm -rf $SOURCE_DIR//*
    if [ $? -ne 0 ]; then
        log $SCRIPT_NAME ERROR "Unable to remove $SOURCE_DIR/* - exiting."
        exit 1
    fi
fi

if [ ! -f $PACKAGE_DIR/include_src_files.sh ]; then
    log $SCRIPT_NAME ERROR "File list does not exist - aborting."
    exit 1
else
    $PACKAGE_DIR/include_src_files.sh $BUILD_PRODUCT_DIR $RESOURCE_DIR $SOURCE_DIR
    if [ $? -ne 0 ]; then
        log $SCRIPT_NAME ERROR "Unable to run include_src_files.sh script - exiting."
        exit 1
    fi
fi

rpmbuild创建了以下脚本(注意set -x):

#!/bin/sh

  RPM_SOURCE_DIR="/tmp/yaneeve/output/kit/SOURCES"
  RPM_BUILD_DIR="/tmp/yaneeve/output/kit/BUILD"
  RPM_OPT_FLAGS="-O2 -g -pipe -march=i386 -mcpu=i686"
  RPM_ARCH="i386"
  RPM_OS="linux"
  export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
  RPM_DOC_DIR="/usr/share/doc"
  export RPM_DOC_DIR
  RPM_PACKAGE_NAME="YANEEVE-APP"
  RPM_PACKAGE_VERSION="4.2.2.0"
  RPM_PACKAGE_RELEASE="01.0"
  export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
  RPM_BUILD_ROOT="/tmp/yaneeve/output/kit/SOURCES"
  export RPM_BUILD_ROOT


  set -x
  umask 022
  cd /tmp/yaneeve/output/kit/BUILD
LANG=C
export LANG
unset DISPLAY


. $LOGGER_FUNC_FILE_LOCATION/logger.sh

SCRIPT_NAME='rpm_spec-prep'
SOURCE_DIR=`readlink -f -n /tmp/yaneeve/output/kit/SOURCES`
PACKAGE_DIR=`readlink -f -n /tmp/yaneeve/output/kit/../../kit/linux`
BUILD_PRODUCT_DIR=`readlink -f -n /tmp/yaneeve/output/kit/..`
RESOURCE_DIR=`readlink -f -n /tmp/yaneeve/output/kit/../../conf`

log $SCRIPT_NAME INFO "In the prep stage of the rpm spec file..."

if [[ -d $SOURCE_DIR && `ls -a $SOURCE_DIR | wc -w` -gt 2 ]] ; then
    log $SCRIPT_NAME INFO "Source directory exists and is not empty - deleting content."
        rm -rf $SOURCE_DIR//*
        if [ $? -ne 0 ]; then
        log $SCRIPT_NAME ERROR "Unable to remove $SOURCE_DIR/* - exiting."
        exit 1
    fi
fi

if [ ! -f $PACKAGE_DIR/include_src_files.sh ]; then
        log $SCRIPT_NAME ERROR "File list does not exist - aborting."
        exit 1
else
    $PACKAGE_DIR/include_src_files.sh $BUILD_PRODUCT_DIR $RESOURCE_DIR $SOURCE_DIR
        if [ $? -ne 0 ]; then
        log $SCRIPT_NAME ERROR "Unable to run include_src_files.sh script - exiting."
        exit 1
    fi
fi

为什么set -x会被插入? 我相信这就是打印大量调试信息的原因? 我究竟做错了什么? 或者,我的rpmbuild程序有错误吗?

(对不起,如果我的问题有点过于描述......)

1 个答案:

答案 0 :(得分:2)

您的发行版上的%prep宏已展开,并包含-x设置 在我的发行版/ usr / lib / rpm / macros中,我发现了以下内容:

  
    

导出CLASSPATH} \
     %{verbose:set -x}%{!verbose:exec>的/ dev / null的} \
     umask 022 \
     cd \“%{u2p:%{_ builddir}} \”\

  

您需要取消设置详细变量才能删除'set -x'。