I wrote a SPEC file to build RPM package. I need to let end user to determine the value of an variable in the %pre
section. So I use "read < my_variable >" command in the %pre
section. But, when installing, the "read" command seems ignored by system, because the system didn't wait for me to enter the value. Why? and Is there any good method to do the above thing?

- 51,086
- 7
- 70
- 105
-
1No. Don't do this. RPMs really need to be installable in an unattended fashion (or you will greatly annoy many sysadmins). Find some other way to do what you want. (Even requiring a file to exist on disk with the correct configuration before installation would work though it is a bit ugly.) – Etan Reisner Nov 09 '15 at 13:24
1 Answers
Rather than embed the read
within your package, RPM has a conditional mechanism which can be used via command-line parameters. Most usage of conditionals in RPMs tests constants defined in the system's RPM macros or making simple filesystem checks. You should investigate those first, because it allows your package to install without help from the person doing the install.
Here are some useful pages discussing RPM conditionals:
- Passing conditional parameters into a rpm build (rpm.org)
- PackagerDocs/ConditionalBuilds (rpm.org)
- Conditionals (Maximum RPM: Taking the Red Hat Package Manager to the Limit)
- openSUSE:RPM conditional builds
As one can see from the suggested reading, these are build-time rather than install-time features. You cannot make an "interactive" RPM install. To read more about that, see these pages:
The latter is clear that this is intentional on the part of the developers. As an aside, one response mentions the --relocate
option, implying that this solves the problem. However, it is actually different. Read more about that here:
- Relocatable packages
- Chapter 15. Making a Relocatable Package (Maximum RPM)

- 1
- 1

- 51,086
- 7
- 70
- 105