Avoiding Installing Some Packages in a Group Package

Use the pkg avoid command to avoid installing specified packages if they are the target of a group dependency. You can always explicitly install a package that is compatible with the image even if that package is on the avoid list. Explicitly installing a package that is on the avoid list removes that package from the avoid list. The pkg avoid command enables you to avoid installing specified packages that are part of a group package when you install that group package.

With no arguments, the pkg avoid command displays each avoided package along with any packages that have a group dependency on that package.

With packages specified, the pkg avoid command places the package names that currently match the specified patterns on the avoid list. Only packages that are not currently installed can be avoided. If a package is currently the target of a group dependency, uninstalling the package places it on the avoid list.

Packages that are on the avoid list are installed if needed to satisfy a require dependency and thus are removed from the avoid list. If that require dependency is removed, the package is uninstalled and placed back on the avoid list.

Use the pkg unavoid command to explicitly remove the specified packages from the avoid list.

Packages on the avoid list that are the target of a group dependency of an installed package cannot be removed from the avoid list by using the pkg unavoid command. To remove such a package from the avoid list, install the package.

Example 5-5 Add Packages To and Remove Packages From the Avoid List

The following command output shows that the group/feature/amp group package is not installed. Some of the packages that are part of that group package are installed because they were installed explicitly or as require dependencies of other packages. Use the -r option with the pkg contents command because the specified package is not installed.

$ pkg list -a group/feature/amp
NAME (PUBLISHER)                                  VERSION                    IFO
group/feature/amp                                 5.12-5.12.0.0.0.110.0      ---
$ pkg list -a `pkg contents -o fmri -Hrt depend -a type=group group/feature/amp`
NAME (PUBLISHER)                                  VERSION                    IFO
database/mysql-56                                 5.6.29-5.12.0.0.0.110.0    ---
web/php-56                                        5.6.22-5.12.0.0.0.110.0    ---
web/server/apache-24                              2.4.23-5.12.0.0.0.110.0    i--
web/server/apache-24/module/apache-dbd            2.4.23-5.12.0.0.0.110.0    ---
web/server/apache-24/module/apache-fcgid          2.3.9-5.12.0.0.0.110.0     ---
web/server/apache-24/module/apache-ldap           2.4.23-5.12.0.0.0.110.0    ---
web/server/apache-24/module/apache-ssl            2.4.23-5.12.0.0.0.110.0    i--

The following command places one of the packages that is not installed and that belongs to this group package on the avoid list. The group package is not noted on the avoid list because the group package is not installed.

$ pkg avoid mysql-56
$ pkg avoid
    database/mysql-56

The following commands show that the avoided package is not installed when the group package is installed. The -r option is not used with the pkg contents command because the specified package is installed.

$ pkg install group/feature/amp
$ pkg list -a `pkg contents -o fmri -Ht depend -a type=group group/feature/amp`
NAME (PUBLISHER)                                  VERSION                    IFO
database/mysql-56                                 5.6.29-5.12.0.0.0.110.0    ---
web/php-56                                        5.6.22-5.12.0.0.0.110.0    i--
web/server/apache-24                              2.4.23-5.12.0.0.0.110.0    i--
web/server/apache-24/module/apache-dbd            2.4.23-5.12.0.0.0.110.0    i--
web/server/apache-24/module/apache-fcgid          2.3.9-5.12.0.0.0.110.0     i--
web/server/apache-24/module/apache-ldap           2.4.23-5.12.0.0.0.110.0    i--
web/server/apache-24/module/apache-ssl            2.4.23-5.12.0.0.0.110.0    i--

After the group package is installed, the group package is noted on the avoid list.

$ pkg avoid
    database/mysql-56 (group dependency of 'group/feature/amp')

The pkg unavoid command does not remove a package from the avoid list if that package is part of an installed group package. To remove such a package from the avoid list, install the package.

$ pkg unavoid mysql-56
pkg unavoid: The following packages are a target of group dependencies; use install to unavoid these:
    database/mysql-56
$ pkg install mysql-56
$ pkg avoid
$

You cannot place a package on the avoid list if that package is already installed. The package is placed on the avoid list if you uninstall the package.

$ pkg avoid mysql-56
pkg avoid: The following packages are already installed in this image; use uninstall to avoid these:
    database/mysql-56
$ pkg uninstall mysql-56
$ pkg avoid
    database/mysql-56 (group dependency of 'group/feature/amp')

If the group package is uninstalled, the avoided packages remain on the avoid list, but the avoid list no longer notes their association with the group package.

$ pkg uninstall group/feature/amp
$ pkg avoid
    database/mysql-56
$ pkg unavoid mysql-56
$ pkg avoid
$