Automating Installation of Many Packages
Introduction
Pkgadd isn't particularly user-friendly; it has plenty of options but they're a bit too hidden for my taste. For work, I needed to deploy approximately 1000 packages on several machines. However, with each package installation, I had to enter 'y' and press enter, which quickly becomes tedious.
To solve this problem, I looked at the man page and found the -n
argument, which is useful since it lets you bypass interactive mode. The drawback is that it doesn't work perfectly. So I searched a bit on the internet and found the response file. This is a file where we pass options. These options are tested during a package installation, and here we force them by default to avoid being bothered.
Note: there's also the pkgask command that allows you to create a response file, but it seems to have some limitations compared to this method.
IMPORTANT: This doesn't work for .pkg files! Convert them beforehand.
Configuration
Response File
A response file can be generated using the pkgask command:
This will generate a response file called "answer". This file contains options specific to the package and cannot be used by any other package.
When trying to generate a response file, the command might return this:
This indicates that the package doesn't contain any customization information, and in this case, using an admin file is necessary.
Admin File
Not all packages allow the use of a response file, which is why we can also use an admin file. The admin file works the same way as the response file but uses standard options for a package installation rather than custom options specific to the package.
A template admin file can be found in the directory /var/sadm/install/admin/default. Copy it, then modify it to meet your needs.
Here's what an admin file looks like:
WARNING: If you want to use this method to install packages in the "Finish" script of a jumpstart, don't forget to modify the parameter "basedir=default" to "basedir=/a/" which corresponds to the mount point of the partition during installation.
Installation Script
You can simply navigate to the folder in question and execute pkgadd:
- With a response file
- With an admin file
You must specify the full paths when using the response file!
Alternatively, you can use this script (I prefer it, but it's up to you):
- With a response file
- With an admin file
Run this and you'll be set!