Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need advice about the following

I build simple spec file and build rpm

I transfer the new rpm to other Linux machine in order to install the new rpm

according to the spec file the new rpm -> test.sh-6.2-2.i386.rpm should create the /tmp/MY_RPM_TESTS directory , but this rpm not create the MY_RPM_TESTS and sub directories please advice why , what I need to fix in the spec file?

RPM installation:

   [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

my SPEC file:

  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

Build the 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
share|improve this question
add comment

1 Answer

The problem is you've mixed up the two parts of rpm's world - 1) making the package and 2) installing the package.

Simply put, when you make the package on one computer rpm takes the raw source code and runs the scripts defined in the %build and %install sections. It then bundles up any files you specify in the %files section and puts them in the package.

Then, when you install the rpm on another computer it runs %pre, unpacks the files it made earlier from %files and puts them in the relevant places in the filesystem, and then runs %post.

Have a look at Mandriva's Wiki on the topic of RPM HOW TO.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.