rpm 安装后+解压文件怎么办?

rpm 安装后+解压文件怎么办?

我根据 spec 文件构建了一个简单的 rpm,但我的目标是在通过 rpm -Uvh 安装 rpm 后,将 test.sh 文件放在 /home 目录下,请建议我需要在 spec 文件中进行哪些更改才能在安装 rpm 后放置 test.sh?

备注:test.sh 在 /usr/src/redhat/SOURCES 下定义

 [root@linux /usr/src/redhat]# ls
   BUILD  RPMS  SOURCES  SPECS  SRPMS
 [root@linux /usr/src/redhat]# ls SOURCES 
   test.sh

 [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
  Source: /root/test.sh 
  URL: http://www.gnomovision.com/cdplayer/cdplayer.html
  Group: Development/Debuggers
  BuildRoot:/var/test.sh
  License: OtherLicense
  %description
  %files

  [root@linux /usr/src/redhat/SPECS]# rpm -ba   /usr/src/redhat/SPECS/my_spec.spec 

  Processing files: test.sh-6.2-2
  Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/test.sh
  Wrote: /root/rpmbuild/SRPMS/test.sh-6.2-2.src.rpm
  Wrote: /root/rpmbuild/RPMS/i386/test.sh-6.2-2.i386.rpm

  [root@linux /usr/src/redhat/SPECS]# rpm -Uvh  /root/rpmbuild/RPMS/i386/test.sh-6.2- 2.i386.rpm
  Preparing...                ########################################### [100%]
  1:test.sh                ########################################### [100%]



      [root@linux /usr/src/redhat]# rpm2cpio  /root/rpmbuild/RPMS/i386/test.sh-6.2-2.i386.rpm | cpio -idmv
      1 block    ( I dont get the test.sh file?)

答案1

嗯,你需要一个安装步骤,将脚本复制到主目录之类的,没有经过测试!

%install
rm -rf %{buildroot}

mkdir -p %{buildroot}/home

cp %SOURCE0 %{buildroot}/home

%file
/home/test.sh

相关内容