Rpm - Install Time Parameters

RPM - Install time parameters

In general, RPM packages should not require user interaction. Time and time again, the RPM folks have stated that it is an explicit design goal of RPM to not have interactive installs. For packages that need some sort of input before first use, you typically ask for this information on first use, our you put it all in config files with macros or something and tell your users that they will have to configure the application before it is usable.

Even passing a parameter of some sort counts as end-user interaction. I think what you want is to have your pre or install scripts auto detect the environment somehow, maybe by having a file somewhere they can examine. I'll also point out that from an RPM user's perspective, having a package named *-qa.rpm is a lot more intuitive than passing some random parameter.

For your exact problem, if you are installing different content, you should create different packages. If you try to do things differently, you're going to end up fighting the RPM system more and more.

It isn't hard to create a build system that can spit out 20+ packages that are all mostly similar. I've done it with a template-ish spec file and some scripts run by make that will create the various spec files and build the RPMs. Without knowing the specifics, it sounds like you might even have a core package that all 20+ environment packages depend on, then the environment specific packages install whatever is specific to their target environment.

Passing user defined argument to RPM is possible while installing?

RPMs aren't meant to take user defined arguments.

See RPM - Install time parameters

Another similar question is at https://superuser.com/questions/408852/is-it-possible-to-get-users-input-during-installation-of-rpm

One workaround is to have the rpm's postinstall script ask for input from stdin, in which case you can pass in the answers by redirecting stdio from a file or here document.

>rpm -i sample.rpm <<__NOT_RECOMMENDED__
somearg
__NOT_RECOMMENDED__

How to make rpm auto install dependencies

Create a (local) repository and use yum to have it resolve the dependencies for you.

The CentOS wiki has a nice page providing a how-to on this. CentOS wiki HowTos/CreateLocalRepos.


Summarized and further minimized (not ideal, but quickest):

  1. Create a directory for you local repository, e.g. /home/user/repo.
  2. Move the RPMs into that directory.
  3. Fix some ownership and filesystem permissions:

    # chown -R root.root /home/user/repo
  4. Install the createrepo package if not installed yet, and run

    # createrepo /home/user/repo
    # chmod -R o-w+r /home/user/repo
  5. Create a repository configuration file, e.g. /etc/yum.repos.d/myrepo.repo containing

    [local]
    name=My Awesome Repo
    baseurl=file:///home/user/repo
    enabled=1
    gpgcheck=0
  6. Install your package using

    # yum install packagename

standardized conclusion required for rpm upgrade process

Assuming you only every want one version of an RPM installed at once, then yes use "rpm -U".

Creating an RPM that can have multiple versions installed requires that all common files between the versions are identical. This frequently happens, so you may get this behaviour "by default".

You can also prevent multiple versions with the following in you spec:

Conflicts : %{name} < %{version}

How to install a rpm package and its dependencies offline

In CentOS/RedHat you can use yumdownloader for specific packages, this downloads all RPMs required, then, compress the directory, upload it to the server without Internet access and install RPMs.

Here you can find and example, installing Kubernetes without Internet access.

yumdownloader --assumeyes --destdir=/var/rpm_dir/docker-ce --resolve docker-ce
tar -czvf d4r-k8s.tar.gz /var/rpm_dir
# Upload files
scp d4r-k8s.tar.gz root@YOUR-IP:/root
# Connect to your server
ssh root@YOUR-IP
tar -xzvf /root/d4r-k8s.tar.gz -C /
# install Docker:
yum install -y --cacheonly --disablerepo=* /var/rpm_dir/docker-ce/*.rpm

How would I make read command work in RPM spec file?

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:

  • Is it possible to get user's input during installation of rpm?
  • RPM - Install time parameters

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)


Related Topics



Leave a reply



Submit