-1

I would like to create a rpm package that does the following:

When setup:

  1. copies a script across into the rpm

  2. untars a file into the rpm

When run:

  1. runs script.sh

  2. runs install file that is extracted into the rpm

When the user runs the rpm it should execute 2 and 3 because the files already exist in the rpm.

I know how to do the setup stuff, the *.spec file is:

%description
# lets skip this for now

%prep
# lets skip this for now

%build
# lets skip this for now

%install
cd ${RPM_BUILD_ROOT}
cp -v /home/methuselah/script.sh ${RPM_BUILD_ROOT}
tar xvpf /home/methuselah/bin.tar
chmod 775 -R ${RPM_BUILD_ROOT}/*

%files
/*

%changelog
* Tue Jan 28 2014 Pavel Šimerda  - 3.0.9-14
- Resolves: #1052814 - rsync command is terminated with SIGSEGV
- Resolves: #1052814 - add missing patch file

I'm not sure where to put the actual installation steps that run when the rpm is executed.

halfer
  • 19,824
  • 17
  • 99
  • 186
methuselah
  • 12,766
  • 47
  • 165
  • 315
  • I think you should present your actual use case, because what you're asking to do is **generally a bad idea** and goes against what RPM is there for. Once you untar a file, let's say `/etc/randomfile`, how is the user supposed to know where it came from? SAs are trained to check the RPM database - it's not in there, because you randomly dropped it in. Now the admin needs to track it down and make sure there hasn't been some kind of breach, etc. – Aaron D. Marasco Sep 30 '19 at 20:30

2 Answers2

3

the %install section is there to install the files during the rpm build process in the rpm build root. This part is not run during installation on the target machine. That is the confusing part of spec files.

During the building of the rpm (in this order):

  • %prep
  • %build
  • %install
  • %check

during the installation of the rpm (in this order):

  • %pre
  • (real installation: files from %files section are installed)
  • %post

NOTE: this page on the full rpm scripts order

some more remarks:

  • two rpms cannot own the same file/folder, so make sure you don't package /home, /usr or something like that (when specifying /* under %files you are packaging the whole tree)
  • don't package files in the /home directory of a user. Packages are installed system-wide, so package only files in generic directories like /etc , /usr, ...
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
1

Maybe you want to put your files (script.sh and bin.tar) under the "%files" section and leave all installation with %install.

Take a look here and maybe here for more information.

I'm not sure where to put the actual installation steps that run when the rpm is executed.

I think this link can help you.

halfer
  • 19,824
  • 17
  • 99
  • 186
luizinho
  • 126
  • 1
  • 5
  • while helpfull, if possible at least describe what each link is supposed to help the user with, so he doesn't need to open them all to see what they are about. – Chris Maes Sep 30 '19 at 10:12
  • @ChrisMaes Yes, you're right! I wanted to give a quick answer before editing my own answer with more info. But your answer nails it. :-) – luizinho Sep 30 '19 at 10:48