RPM + rpm安装(根据SPEC不创建目录)

时间:2011-04-17 16:24:08

标签: linux rpm rpm-spec

我需要有关以下内容的建议

我构建简单的spec文件并构建rpm

我将新rpm转移到其他Linux机器以安装新的rpm

根据spec文件新rpm - > test.sh-6.2-2.i386.rpm应该创建 / tmp / MY_RPM_TESTS目录,但此rpm不会创建MY_RPM_TESTS和子目录 请告诉我为什么,我需要在spec文件中修复什么?

RPM安装:

   [root@linux1 rpm -Uvh  /root/rpmbuild/RPMS/i386/test.sh-6.2-2.i386.rpm
   Preparing...                ########################################### [100%]
   This is preinstall script
   Linux linux 2.6.18-164.2.1.el5PAE #1 SMP Mon Sep 21 04:45:05 EDT 2009 i686 i686 i386 GNU/Linux
   1:test.sh                ########################################### [100%]
   Linux linux 2.6.18-164.2.1.el5PAE #1 SMP Mon Sep 21 04:45:05 EDT 2009 i686 i686 i386 GNU/Linux
   Now we wait for sleep
   100

   [root@linux1 ls /tmp

   preinstall_dir

我的SPEC文件:

  root@linux /usr/src/redhat/SPECS]# more my_spec.spec
  Summary: An example tool. To show a simple rpm build of the tool.
  Name: test.sh
  Version: 6.2
  Release: 2
  Source0: /root/test.sh 
  Source1: /root/urim.sh
  Group: Development/Debuggers
  BuildRoot:/tmp/MY_RPM_TESTS
  License: OtherLicense
  %description


  %pre -p /bin/ksh
  print "This is preinstall script"
  uname -a
  rm -rf /tmp/preinstall_dir
  mkdir /tmp/preinstall_dir

  %install
  rm -rf %{buildroot}

  mkdir -p %{buildroot}
  mkdir -p %{buildroot}/home
  mkdir -p %{buildroot}/home/home1

  cp %SOURCE0 %{buildroot}/home
  cp %SOURCE0 %{buildroot}/home/home1

  cp %SOURCE1  %{buildroot}/home

  %files
  /home/test.sh
  /home/home1/test.sh
  /home/urim.sh



  %post -p /bin/ksh

  uname -a
  print "Now we wait for sleep" ; sleep  1
  NUM=100
  print $NUM

构建rpm:

  [root@linux /usr/src/redhat/SPECS]# rpm -ba   /usr/src/redhat/SPECS/my_spec.spec
  Executing(%install): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.83360
  + umask 022
  + cd /root/rpmbuild/BUILD
  + rm -rf /tmp/MY_RPM_TESTS
  + mkdir -p /tmp/MY_RPM_TESTS
  + mkdir -p /tmp/MY_RPM_TESTS/home
  + mkdir -p /tmp/MY_RPM_TESTS/home/home1
  + cp /root/rpmbuild/SOURCES/test.sh /tmp/MY_RPM_TESTS/home
  + cp /root/rpmbuild/SOURCES/test.sh /tmp/MY_RPM_TESTS/home/home1
  + cp /root/rpmbuild/SOURCES/urim.sh /tmp/MY_RPM_TESTS/home
  + /usr/lib/rpm/brp-compress
  + /usr/lib/rpm/brp-strip
  + /usr/lib/rpm/brp-strip-static-archive
  + /usr/lib/rpm/brp-strip-comment-note
  Processing files: test.sh-6.2-2
  Requires(interp): /bin/ksh /bin/ksh
  Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib    (PayloadFilesHavePrefix) <= 4.0-1
  Requires(pre): /bin/ksh
  Requires(post): /bin/ksh
  Checking for unpackaged file(s): /usr/lib/rpm/check-files /tmp/MY_RPM_TESTS
  Wrote: /root/rpmbuild/SRPMS/test.sh-6.2-2.src.rpm
  Wrote: /root/rpmbuild/RPMS/i386/test.sh-6.2-2.i386.rpm

1 个答案:

答案 0 :(得分:3)

你误解了。 /tmp/MY_RPM_TESTS是构建根,创建的,但仅由rpmbuild临时和内部使用。它不应该是rpm文件的一部分,你绝不应该尝试在/tmp中安装任何东西! / tmp仅用于临时文件。