N00b rpmbuild错误

时间:2013-11-12 22:29:33

标签: linux redhat rpm rpmbuild

我一直试图弄清楚如何在过去的6个月内建立一个rpm,我仍然在努力去理解我的构建中缺少的东西。我的目标是让我的rpm安装一个tar.gz文件。

这是我的.rpmmacros文件

%_topdir      %(echo $HOME)/rpmbuild
%_smp_mflags  -j3
%__arch_install_post   /usr/lib/rpm/check-rpaths   /usr/lib/rpm/check-buildroot
%_tmppath  %{_topdir}/tmp

这是我的spec文件

Summary: Appadm Monitoring
Name: AppadmQ
Version: 1
Release: 1
Source0: AppadmQ-1-1.tar.gz
License: GPL
Group: 
BuildArch: noarch
BuildRoot: %{_builddir}/%{name}_%{version}.%{release}-root/
%description
%prep
%setup -n AppadmQ-1
%build
%install
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
mkdir $RPM_BUILD_ROOT
if [ -d $RPM_BUILD_ROOT ]; then
   mkdir $RPM_BUILD_ROOT/tmp
   cp -af AppadmQ-1-1.tar.gz $RPM_BUILD_ROOT/tmp
   tar -xvzf $RPM_BUILD_ROOT/tmp/AppadmQ-1-1.tar.gz
else
   echo "NO BUILD ROOT... nothing built."
   exit 1
fi;

%clean
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}

%post
echo " "
echo "SUCCESS!"
%files

以下是我尝试构建rpm时发生的事情

 Executing(%prep): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.sC0xn6
 + umask 022
 + cd /root/rpmbuild/BUILD
 + LANG=C
 + export LANG
 + unset DISPLAY
 + cd /root/rpmbuild/BUILD
 + rm -rf AppadmQ-1
 + /usr/bin/gzip -dc /root/rpmbuild/SOURCES/AppadmQ-1-1.tar.gz
 + /bin/tar -xvvf -
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:35 home/appadm/
 -rw-r--r-- appadm/users    121 2011-10-11 03:25 home/appadm/.kshrc
 drwxr-xr-x appadm/appadm     0 2013-07-17 18:07 home/appadm/orwell/
 -r--r--r-- appadm/users   1837 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20004.stub
 -r--r--r-- appadm/users   1892 2010-10-22 15:07 home/appadm/orwell/irco_orwell_20052.stub
 -r--r--r-- appadm/users   1841 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20003.stub
 -r--r--r-- appadm/users   1975 2010-11-04 22:52 home/appadm/orwell/irco_orwell_20053.stub
 -rw-r--r-- appadm/users    996 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00409.stub
 -r--r--r-- appadm/users   3087 2011-12-30 14:06 home/appadm/orwell/irco_orwell_20032.stub
 -rw-r--r-- appadm/users   1098 2011-06-02 12:52 home/appadm/orwell/sys_orwell_00413.stub
 -rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00410.stub
 -r--r--r-- appadm/users   1159 2013-07-17 18:07 home/appadm/orwell/irco_orwell_20037.stub
 -rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00411.stub
 -r--r--r-- appadm/users   1535 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20002.stub
 -r--r--r-- appadm/users     11 2013-07-02 18:31 home/appadm/lanetypeCksum_baseline
 drwxrwxr-x appadm/appadm     0 2013-11-11 15:19 home/appadm/rat/
 -rwxr-xr-x appadm/users    406 2008-08-24 21:00 home/appadm/j7.sh
 -rw------- appadm/users     51 2013-01-30 17:24 home/appadm/.lesshst
 -rw-r----- appadm/users    276 2011-10-11 03:25 home/appadm/.profile
 -rwxr-xr-x appadm/users     53 2008-10-06 22:28 home/appadm/to2.sh
 -rwxr-xr-x appadm/users    229 2008-11-03 17:27 home/appadm/ipl.sh
 -rwxr-xr-x appadm/users    263 2008-10-16 16:26 home/appadm/longsql.sh
 -rwxr-xr-x appadm/users    162 2008-10-06 21:51 home/appadm/to.sh
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:10 home/appadm/logs/
 -rwxr-xr-x appadm/users    160 2012-01-21 13:55 home/appadm/j.sh
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:09 home/appadm/copient/
 -rwxr-xr-x appadm/users    514 2013-10-30 18:45 home/appadm/copient/ops_coptidy.pl
 -rw-r--r-- appadm/users     20 2011-12-22 09:50 home/appadm/copient/co_monitor2.txt
 -rwxr-xr-x appadm/users    170 2005-09-28 10:53 home/appadm/copient/ops_chklog.sh
 -rwxr-xr-x appadm/users  23290 2013-10-30 18:45 home/appadm/copient/ops_copiphourly.pl
 -rwxr-xr-x appadm/users    610 2009-08-19 17:42 home/appadm/copient/ops_coptidy.sh
 -rwxr-xr-x appadm/users     65 2013-11-11 15:08 home/appadm/copient/copient_phpver.php
 -rwxr-xr-x appadm/users    538 2008-12-10 17:00 home/appadm/copient/ops_appadm.exp
 -rwxr-xr-x appadm/users    866 2010-01-21 14:17 home/appadm/copient/copIP.sh
 -rwxr-xr-x appadm/users    706 2010-06-04 17:18 home/appadm/copient/ops_coproid.sh
 -rwxr-xr-x appadm/users   6413 2013-10-30 18:45 home/appadm/copient/ops_copdiscount.pl
 -rwxr-xr-x appadm/users    642 2009-06-09 11:09 home/appadm/copient/ops_copiphourly.sh
 -rwxr-xr-x appadm/users    293 2008-11-18 17:16 home/appadm/copient/ops_cksum.sh
 -rwxr-xr-- appadm/users    688 2012-08-19 19:12 home/appadm/copient/dbCurebkup.sh
 -rwxr-xr-x appadm/users  21993 2013-10-30 18:45 home/appadm/copient/ops_copresponse.pl
 -rwxr-xr-x appadm/users    259 2006-01-09 19:58 home/appadm/copient/ops_appadm_survey.sh
 -rwxr-xr-x appadm/users   3553 2013-10-30 18:45 home/appadm/copient/ops_copcard.pl
 -rwxr-xr-x appadm/users    704 2010-02-12 09:46 home/appadm/copient/ops_copresponse.sh
 -rwxr-xr-x appadm/users    670 2011-04-17 23:19 home/appadm/copient/ops_corpBrand.sh
 -rwxr--r-- appadm/users    111 2013-06-11 21:59 home/appadm/copient/c96766_EOC_fix.sh
 -rwxr--r-- appadm/users     73 2013-06-18 18:14 home/appadm/copient/IncentiveFetch_fix.sh
 -rwxr-xr-x appadm/users   2486 2012-10-08 14:21 home/appadm/copient/cop_cksum.sh
 -rwxr-xr-x appadm/users    681 2010-08-13 14:35 home/appadm/copient/cop_incentiveFetch.sh
 -rwxr-xr-x appadm/users  13119 2012-10-08 14:21 home/appadm/copient/cksumList
 -rwxr-xr-x appadm/users   2571 2012-02-21 16:13 home/appadm/copient/toastClipStore.pl
 -rwxr-xr-x appadm/users    357 2008-11-12 14:36 home/appadm/copient/ops_conf1.sh
 -rwxr-xr-x appadm/users   3865 2013-10-30 18:45 home/appadm/copient/ops_cop_avg_roids_per_cust.pl
 -rwxr-xr-x appadm/users    109 2006-04-17 11:40 home/appadm/copient/copient_ver.php
 -rwxr-xr-x appadm/users    323 2008-11-11 16:28 home/appadm/copient/ops_pgsql_cksum.sh
 -rwxr-xr-x appadm/users  39326 2013-10-30 18:45 home/appadm/copient/ops_corpBrands.pl
 -rwxr-xr-x appadm/users    647 2010-08-19 16:18 home/appadm/copient/ops_copcard.sh
 -rwxr-xr-x appadm/users    663 2005-05-31 15:53 home/appadm/copient/ops_copient.exp
 -rwxr-x--- appadm/users    691 2006-03-24 12:40 home/appadm/copient/terminals.pl
 -rwxr-xr-x appadm/users   6847 2013-08-23 15:42 home/appadm/copient/co_monitor2.sh
 -rw-r--r-- appadm/users   1310 2008-09-21 13:45 home/appadm/tidy.pl
 drwx------ appadm/appadm     0 2013-11-11 15:19 home/appadm/.ssh/
 drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/
 drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/nssdb/
 -rw------- appadm/users   9703 2013-10-21 14:29 home/appadm/.viminfo
 -rwxr-xr-x appadm/users   1955 2008-10-06 21:51 home/appadm/to.pl
 -rw------- appadm/users     30 2012-10-19 17:16 home/appadm/.php_history
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:05 home/appadm/bin/
 -rwxr-xr-x appadm/users    172 2007-07-16 18:30 home/appadm/bin/ops_chklog.sh
 -rwxr-xr-x appadm/users    190 2013-10-30 18:45 home/appadm/bin/ops_copPhonehome.sh
 -rwxr-xr-x appadm/users    229 2013-10-30 18:45 home/appadm/bin/ops_Q_coproid.sh
 -rwxr-xr-x appadm/users    362 2013-10-30 18:45 home/appadm/bin/ops_Q_copOld_customer_data.sh
 -rwxr-xr-x appadm/users    292 2011-07-26 09:14 home/appadm/bin/ops_appadm.exp
 -rwxr-xr-x appadm/users    167 2013-10-30 18:45 home/appadm/bin/ops_copSanity.sh
 -rwxr-xr-x appadm/users   4483 2013-10-30 18:45 home/appadm/bin/qtySCO.pl
 -rwxr-xr-x appadm/users    607 2013-10-30 18:45 home/appadm/bin/ops_Q_copLook_for_coupon_time_outs.sh
 -rwxr-xr-x appadm/users    426 2011-08-12 18:20 home/appadm/bin/ops_appadm_ssh.exp
 -rwxr-xr-x appadm/users    261 2007-07-16 18:30 home/appadm/bin/ops_appadm_survey.sh
 -rwxr-xr-x appadm/users    215 2013-10-30 18:45 home/appadm/bin/ops_Q_copBrand.sh
 -rwxr-xr-x appadm/users   1811 2013-10-30 18:45 home/appadm/bin/ops_copCksum.sh
 -rwxr-xr-x appadm/users    237 2013-10-30 18:45 home/appadm/bin/ops_Q_coptidy.sh
 -rwxr-xr-x appadm/users  39646 2013-10-30 18:45 home/appadm/bin/ops_Q.sh
 -rwxr-xr-x appadm/users   1238 2007-12-20 09:27 home/appadm/bin/ops_remote.pl
 -rwxr-xr-x appadm/users    222 2013-10-30 18:45 home/appadm/bin/ops_Q_copresponse.sh
 -rwxr-xr-x appadm/users   1297 2012-02-17 18:44 home/appadm/bin/cop_daily_IPL_time.sh
 -rwxr-xr-x appadm/users    602 2011-07-27 18:09 home/appadm/bin/ops_appadm_scp.exp
 -rwxr-xr-x appadm/users    206 2013-10-30 18:45 home/appadm/bin/ops_Q_copcard.sh
 -rwxr-xr-x appadm/users    665 2007-07-16 18:30 home/appadm/bin/ops_copient.exp
 -rwxr-xr-x appadm/users    694 2007-07-16 18:30 home/appadm/bin/terminals.pl
 -rwxr-xr-x appadm/users   2736 2007-07-16 18:30 home/appadm/bin/co_monitor2.sh
 -rwxr-xr-x appadm/users   6305 2006-06-02 14:21 home/appadm/bin/ccp
 -rwxr-xr-x appadm/users    217 2013-10-30 18:45 home/appadm/bin/ops_Q_copiphourly.sh
 -rwxr-xr-x appadm/users    501 2012-06-06 15:25 home/appadm/bin/ops_appadm_bb.exp
 -rwxr-xr-x appadm/users    785 2009-01-16 15:53 home/appadm/ops_emer.sh
 -rw-r----- appadm/users    281 2011-10-11 03:25 home/appadm/.bashrc
 -rw-r--r-- appadm/users   2535 2008-10-06 22:28 home/appadm/to2.pl
 -rw-r--r-- appadm/users    176 2011-10-11 03:25 home/appadm/.bash_profile
 -rw-r--r-- appadm/users   3205 2012-02-01 11:25 home/appadm/ipsort.pl
 + STATUS=0
 + '[' 0 -ne 0 ']'
 + cd AppadmQ-1
 /root/rpmbuild/tmp/rpm-tmp.sC0xn6: line 38: cd: AppadmQ-1: No such file or directory
 error: Bad exit status from /root/rpmbuild/tmp/rpm-tmp.sC0xn6 (%prep)


 RPM build errors:
 Bad exit status from /root/rpmbuild/tmp/rpm-tmp.sC0xn6 (%prep)

以下是tmp文件的内容

 #!/bin/sh

  RPM_SOURCE_DIR="/root/rpmbuild/SOURCES"
  RPM_BUILD_DIR="/root/rpmbuild/BUILD"
  RPM_OPT_FLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
  RPM_ARCH="x86_64"
  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="AppadmQ"
  RPM_PACKAGE_VERSION="1"
  RPM_PACKAGE_RELEASE="1"
  export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
  LANG=C
  export LANG
  unset CDPATH DISPLAY ||:
  RPM_BUILD_ROOT="/root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64"
  export RPM_BUILD_ROOT

  PKG_CONFIG_PATH="/usr/lib64/pkgconfig:/usr/share/pkgconfig"
  export PKG_CONFIG_PATH

  set -x
  umask 022
  cd "/root/rpmbuild/BUILD"
LANG=C
export LANG
unset DISPLAY

cd '/root/rpmbuild/BUILD'
rm -rf 'AppadmQ-1'
/usr/bin/gzip -dc '/root/rpmbuild/SOURCES/AppadmQ-1-1.tar.gz' | /bin/tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
  exit $STATUS
fi
cd 'AppadmQ-1'

命令失败,因为它无法进入AppadmQ-1。我很困惑,如果这是我需要手动构建的东西,当我tarball我想要安装的目录。我认为它是基于spec文件中的Name,version和release构建的。我在另一个线程上读到你需要在设置中创建它。我尝试过,但它仍然失败。我的tar.gz文件源是从/ home / appadm目录的所有内容创建的。当我安装rpm时,我希望rpm解压缩源代码并将其覆盖到我的desitation servers / home / appadm目录中,这样我就可以维护该目录中所有文件和文件夹的版本控制。任何帮助是极大的赞赏。如果这个问题已经在另一个帖子中得到了解答,那么非常感谢重定向到该主题,或者甚至是我能阅读的一本书,以便更好地理解这一切是如何起作用的。

@ glglgl 感谢您的反馈,我真的很感激。我在下面做了你建议的修改。 我修改了我的spec文件,现在该行显示为

%setup -c -n AppadmQ-1

这是我运行命令后的输出

Executing(%prep): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.Hl0evU
+ umask 022
+ cd /root/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /root/rpmbuild/BUILD
+ rm -rf AppadmQ-1
+ /bin/mkdir -p AppadmQ-1
+ cd AppadmQ-1
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/AppadmQ-1-1.tar.gz
+ /bin/tar -xvvf -
drwxr-xr-x appadm/appadm     0 2013-11-11 15:35 home/appadm/
drwxr-xr-x                  Creating directory: home
-rw-r--r-- appadm/users    121 2011-10-11 03:25 home/appadm/.kshrc
drwxr-xr-x appadm/appadm     0 2013-07-17 18:07 home/appadm/orwell/
-r--r--r-- appadm/users   1837 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20004.stub
-r--r--r-- appadm/users   1892 2010-10-22 15:07 home/appadm/orwell/irco_orwell_20052.stub
-r--r--r-- appadm/users   1841 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20003.stub
-r--r--r-- appadm/users   1975 2010-11-04 22:52 home/appadm/orwell/irco_orwell_20053.stub
-rw-r--r-- appadm/users    996 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00409.stub
-r--r--r-- appadm/users   3087 2011-12-30 14:06 home/appadm/orwell/irco_orwell_20032.stub
-rw-r--r-- appadm/users   1098 2011-06-02 12:52 home/appadm/orwell/sys_orwell_00413.stub
-rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00410.stub
-r--r--r-- appadm/users   1159 2013-07-17 18:07 home/appadm/orwell/irco_orwell_20037.stub
-rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00411.stub
-r--r--r-- appadm/users   1535 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20002.stub
-r--r--r-- appadm/users     11 2013-07-02 18:31 home/appadm/lanetypeCksum_baseline
drwxrwxr-x appadm/appadm     0 2013-11-11 15:19 home/appadm/rat/
-rwxr-xr-x appadm/users    406 2008-08-24 21:00 home/appadm/j7.sh
-rw------- appadm/users     51 2013-01-30 17:24 home/appadm/.lesshst
-rw-r----- appadm/users    276 2011-10-11 03:25 home/appadm/.profile
-rwxr-xr-x appadm/users     53 2008-10-06 22:28 home/appadm/to2.sh
-rwxr-xr-x appadm/users    229 2008-11-03 17:27 home/appadm/ipl.sh
-rwxr-xr-x appadm/users    263 2008-10-16 16:26 home/appadm/longsql.sh
-rwxr-xr-x appadm/users    162 2008-10-06 21:51 home/appadm/to.sh
drwxr-xr-x appadm/appadm     0 2013-11-11 15:10 home/appadm/logs/
-rwxr-xr-x appadm/users    160 2012-01-21 13:55 home/appadm/j.sh
drwxr-xr-x appadm/appadm     0 2013-11-11 15:09 home/appadm/copient/
-rwxr-xr-x appadm/users    514 2013-10-30 18:45 home/appadm/copient/ops_coptidy.pl
-rw-r--r-- appadm/users     20 2011-12-22 09:50 home/appadm/copient/co_monitor2.txt
-rwxr-xr-x appadm/users    170 2005-09-28 10:53 home/appadm/copient/ops_chklog.sh
-rwxr-xr-x appadm/users  23290 2013-10-30 18:45 home/appadm/copient/ops_copiphourly.pl
-rwxr-xr-x appadm/users    610 2009-08-19 17:42 home/appadm/copient/ops_coptidy.sh
-rwxr-xr-x appadm/users     65 2013-11-11 15:08 home/appadm/copient/copient_phpver.php
-rwxr-xr-x appadm/users    538 2008-12-10 17:00 home/appadm/copient/ops_appadm.exp
-rwxr-xr-x appadm/users    866 2010-01-21 14:17 home/appadm/copient/copIP.sh
-rwxr-xr-x appadm/users    706 2010-06-04 17:18 home/appadm/copient/ops_coproid.sh
-rwxr-xr-x appadm/users   6413 2013-10-30 18:45 home/appadm/copient/ops_copdiscount.pl
-rwxr-xr-x appadm/users    642 2009-06-09 11:09 home/appadm/copient/ops_copiphourly.sh
-rwxr-xr-x appadm/users    293 2008-11-18 17:16 home/appadm/copient/ops_cksum.sh
-rwxr-xr-- appadm/users    688 2012-08-19 19:12 home/appadm/copient/dbCurebkup.sh
-rwxr-xr-x appadm/users  21993 2013-10-30 18:45 home/appadm/copient/ops_copresponse.pl
-rwxr-xr-x appadm/users    259 2006-01-09 19:58 home/appadm/copient/ops_appadm_survey.sh
-rwxr-xr-x appadm/users   3553 2013-10-30 18:45 home/appadm/copient/ops_copcard.pl
-rwxr-xr-x appadm/users    704 2010-02-12 09:46 home/appadm/copient/ops_copresponse.sh
-rwxr-xr-x appadm/users    670 2011-04-17 23:19 home/appadm/copient/ops_corpBrand.sh
-rwxr--r-- appadm/users    111 2013-06-11 21:59 home/appadm/copient/c96766_EOC_fix.sh
-rwxr--r-- appadm/users     73 2013-06-18 18:14 home/appadm/copient/IncentiveFetch_fix.sh
-rwxr-xr-x appadm/users   2486 2012-10-08 14:21 home/appadm/copient/cop_cksum.sh
-rwxr-xr-x appadm/users    681 2010-08-13 14:35 home/appadm/copient/cop_incentiveFetch.sh
-rwxr-xr-x appadm/users  13119 2012-10-08 14:21 home/appadm/copient/cksumList
-rwxr-xr-x appadm/users   2571 2012-02-21 16:13 home/appadm/copient/toastClipStore.pl
-rwxr-xr-x appadm/users    357 2008-11-12 14:36 home/appadm/copient/ops_conf1.sh
-rwxr-xr-x appadm/users   3865 2013-10-30 18:45 home/appadm/copient/ops_cop_avg_roids_per_cust.pl
-rwxr-xr-x appadm/users    109 2006-04-17 11:40 home/appadm/copient/copient_ver.php
-rwxr-xr-x appadm/users    323 2008-11-11 16:28 home/appadm/copient/ops_pgsql_cksum.sh
-rwxr-xr-x appadm/users  39326 2013-10-30 18:45 home/appadm/copient/ops_corpBrands.pl
-rwxr-xr-x appadm/users    647 2010-08-19 16:18 home/appadm/copient/ops_copcard.sh
-rwxr-xr-x appadm/users    663 2005-05-31 15:53 home/appadm/copient/ops_copient.exp
-rwxr-x--- appadm/users    691 2006-03-24 12:40 home/appadm/copient/terminals.pl
-rwxr-xr-x appadm/users   6847 2013-08-23 15:42 home/appadm/copient/co_monitor2.sh
-rw-r--r-- appadm/users   1310 2008-09-21 13:45 home/appadm/tidy.pl
drwx------ appadm/appadm     0 2013-11-11 15:19 home/appadm/.ssh/
drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/
drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/nssdb/
-rw------- appadm/users   9703 2013-10-21 14:29 home/appadm/.viminfo
-rwxr-xr-x appadm/users   1955 2008-10-06 21:51 home/appadm/to.pl
-rw------- appadm/users     30 2012-10-19 17:16 home/appadm/.php_history
drwxr-xr-x appadm/appadm     0 2013-11-11 15:05 home/appadm/bin/
-rwxr-xr-x appadm/users    172 2007-07-16 18:30 home/appadm/bin/ops_chklog.sh
-rwxr-xr-x appadm/users    190 2013-10-30 18:45 home/appadm/bin/ops_copPhonehome.sh
-rwxr-xr-x appadm/users    229 2013-10-30 18:45 home/appadm/bin/ops_Q_coproid.sh
-rwxr-xr-x appadm/users    362 2013-10-30 18:45 home/appadm/bin/ops_Q_copOld_customer_data.sh
-rwxr-xr-x appadm/users    292 2011-07-26 09:14 home/appadm/bin/ops_appadm.exp
-rwxr-xr-x appadm/users    167 2013-10-30 18:45 home/appadm/bin/ops_copSanity.sh
-rwxr-xr-x appadm/users   4483 2013-10-30 18:45 home/appadm/bin/qtySCO.pl
-rwxr-xr-x appadm/users    607 2013-10-30 18:45 home/appadm/bin/ops_Q_copLook_for_coupon_time_outs.sh
-rwxr-xr-x appadm/users    426 2011-08-12 18:20 home/appadm/bin/ops_appadm_ssh.exp
-rwxr-xr-x appadm/users    261 2007-07-16 18:30 home/appadm/bin/ops_appadm_survey.sh
-rwxr-xr-x appadm/users    215 2013-10-30 18:45 home/appadm/bin/ops_Q_copBrand.sh
-rwxr-xr-x appadm/users   1811 2013-10-30 18:45 home/appadm/bin/ops_copCksum.sh
-rwxr-xr-x appadm/users    237 2013-10-30 18:45 home/appadm/bin/ops_Q_coptidy.sh
-rwxr-xr-x appadm/users  39646 2013-10-30 18:45 home/appadm/bin/ops_Q.sh
-rwxr-xr-x appadm/users   1238 2007-12-20 09:27 home/appadm/bin/ops_remote.pl
-rwxr-xr-x appadm/users    222 2013-10-30 18:45 home/appadm/bin/ops_Q_copresponse.sh
-rwxr-xr-x appadm/users   1297 2012-02-17 18:44 home/appadm/bin/cop_daily_IPL_time.sh
-rwxr-xr-x appadm/users    602 2011-07-27 18:09 home/appadm/bin/ops_appadm_scp.exp
-rwxr-xr-x appadm/users    206 2013-10-30 18:45 home/appadm/bin/ops_Q_copcard.sh
-rwxr-xr-x appadm/users    665 2007-07-16 18:30 home/appadm/bin/ops_copient.exp
-rwxr-xr-x appadm/users    694 2007-07-16 18:30 home/appadm/bin/terminals.pl
-rwxr-xr-x appadm/users   2736 2007-07-16 18:30 home/appadm/bin/co_monitor2.sh
-rwxr-xr-x appadm/users   6305 2006-06-02 14:21 home/appadm/bin/ccp
-rwxr-xr-x appadm/users    217 2013-10-30 18:45 home/appadm/bin/ops_Q_copiphourly.sh
-rwxr-xr-x appadm/users    501 2012-06-06 15:25 home/appadm/bin/ops_appadm_bb.exp
-rwxr-xr-x appadm/users    785 2009-01-16 15:53 home/appadm/ops_emer.sh
-rw-r----- appadm/users    281 2011-10-11 03:25 home/appadm/.bashrc
-rw-r--r-- appadm/users   2535 2008-10-06 22:28 home/appadm/to2.pl
-rw-r--r-- appadm/users    176 2011-10-11 03:25 home/appadm/.bash_profile
-rw-r--r-- appadm/users   3205 2012-02-01 11:25 home/appadm/ipsort.pl
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.5UPBZD
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd AppadmQ-1
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.7AYovn
+ umask 022
+ cd /root/rpmbuild/BUILD
+ '[' /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
++ dirname /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT
+ mkdir /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ cd AppadmQ-1
+ LANG=C
+ export LANG
+ unset DISPLAY
+ '[' /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ mkdir /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ '[' -d /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64 ']'
+ mkdir /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64/tmp
+ cp -af AppadmQ-1-1.tar.gz /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64/tmp
cp: cannot stat `AppadmQ-1-1.tar.gz': No such file or directory
error: Bad exit status from /root/rpmbuild/tmp/rpm-tmp.7AYovn (%install)


RPM build errors:
    Bad exit status from /root/rpmbuild/tmp/rpm-tmp.7AYovn (%install)

我可以看到该目录是在我的服务器上创建的

[root@ tmp]#pwd
/root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64/tmp
[root@ tmp]#ls

源文件位于SOURCES目录中。我假设rpmbuild命令会将该文件从SOURCES目录复制到其临时工作目录中。

[root@j299848 SOURCES]#ls -la Ap*
-rw-r----- 1 root root 51158 Nov 11 15:54 AppadmQ-1-1.tar.gz

我想让我感到困惑的是如何在构建过程中创建和使用临时目录,这样我就会弄清楚我的tar.gz应该去哪里,以及我在我的规范中用宏来命名的内容

1 个答案:

答案 0 :(得分:2)

  

该命令失败,因为它无法进入AppadmQ-1。

右。那是因为你指定了

%setup -n AppadmQ-1

告诉%setup script,它应该是cd AppadmQ-1

如果您不想这样做,请不要告诉它。

如果您想在开箱前设置mkdir AppadmQ-1,请执行

    %setup -c -n AppadmQ-1

并且.tar.gz中的目录树会进入指定的子目录 - 这也是您的工作目录。

因此,如您所见,.tar.gz文件在%prep阶段通过%setup脚本解压缩。

通常情况下,接下来会有一些构建过程,但似乎并非如此。

相反,现在接下来是%install进程。它包括将应该在目标系统上的所有文件放入构建根目录。

可以使用cp命令完成。但是,当然不是.tar.gz文件,而是解压缩的目录树:

cp -af . "$RPM_BUILD_ROOT" # I omit the tmp/ part because I think it is not the ight way to go.

现在您有一个结构$RPM_BUILD_ROOT/home/...,在安装该RPM时会将其放到/home/...

请注意,您必须提及%files指令下的文件才能包含它们。在这里,您有机会为文件提供一些用户,组甚至模式。

但请注意,在/home/...下安装文件肯定不是最佳选择。

通常情况下,我们会将包含/opt/myapp/下完全拥有的目录的包放在/usr//var//srv或适合的任何地方。

并进一步建议:绝对不建议以root身份运行rpmbuild。这是整个问题的一部分:您准备文件的目的地,并将它们打包在一起。只有安装.rpm文件的过程才需要root权限。