1

在过去的 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

这是我的规格文件

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'

该命令失败,因为它无法 cd 进入 AppadmQ-1。我很困惑,当我压缩我想要安装的目录时,我是否需要手动构建。我认为它是基于规范文件中的名称、版本和版本构建的。我在另一个线程上读到您需要在设置中创建它。我试过了,但它仍然失败。我的 tar.gz 文件源是从 /home/appadm 目录的所有内容创建的。当我安装 rpm 时,我希望该 rpm 解压缩该源代码并将其覆盖到我的目标服务器 /home/appadm 目录中,以便我可以维护该目录中所有文件和文件夹的版本控制。任何帮助是极大的赞赏。如果这个问题已经在另一个线程中得到回答,

#

@glglgl谢谢你的反馈,我真的很感激。我在下面进行了您建议的更改。我修改了我的规范文件,所以该行现在读取

%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 应该去哪里以及我应该在我的规范中用宏命名的东西。

4

1 回答 1

2

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

正确的。那是因为你指定

%setup -n AppadmQ-1

它告诉%setup脚本,它应该是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/...,将/home/...在安装该 RPM 时使用。

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

但请进一步注意,安装文件/home/...肯定不会是要走的路。

通常,将具有完全自己的目录的软件包放在/opt/myapp//usr/或任何适合的地方/var//srv

而且,还有一个建议:绝对不建议以rpmbuildroot 身份运行。这是整个要点的一部分:您准备好文件,然后将它们打包在一起。只有安装.rpm文件的过程需要 root 权限。

于 2013-11-12T23:43:15.777 回答