Class PackageManager
java.lang.Object
com.aoindustries.aoserv.daemon.posix.linux.PackageManager
Manages the set of packages on a server.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic interfaceCalled when the package list is updated or first loaded.static enumThe set of all managed package names.static classstatic class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a new package listener to be notified when the package list is updated or first loaded.static SortedSet<PackageManager.Rpm> Gets the set of all packages installed on the server.static PackageManager.RpmGets the highest version of an installed package ornullif not installed.static PackageManager.RpmInstalls a package if it is not currently installed.static PackageManager.RpminstallPackage(PackageManager.PackageName name, IORunnable onInstall) Installs a package if it is not currently installed.static voidinstallPackages(PackageManager.PackageName... packageNames) Installs all of the packages that are not currently installed.static voidinstallPackages(Iterable<PackageManager.PackageName> packageNames) Installs all of the packages that are not currently installed.static booleanRemoves the package with the provided name.static booleanRemoves a package listener.
-
Field Details
-
APACHE_TOMCAT_PREFIX
The name prefix used to match any Apache Tomcat package installations after the move to AORepo.org.- See Also:
-
OLD_APACHE_TOMCAT_PREFIX
The name prefix used to match any Apache Tomcat package installations before the move to AORepo.org.- See Also:
-
-
Method Details
-
getAllRpms
Gets the set of all packages installed on the server. Becauserpm -aqcan take several seconds to run, the results are cached and only updated when a file in/var/lib/rpmhas been modified.- Throws:
IOException
-
getInstalledPackage
public static PackageManager.Rpm getInstalledPackage(PackageManager.PackageName name) throws IOException Gets the highest version of an installed package ornullif not installed.- Throws:
IOException
-
installPackage
Installs a package if it is not currently installed. If the package is already installed, no action is taken. The package is installed with "yum -q -y install $NAME". If multiple packages are already installed, the highest version is returned.- Returns:
- the highest version of RPM that is installed
- Throws:
IOException
-
installPackage
public static PackageManager.Rpm installPackage(PackageManager.PackageName name, IORunnable onInstall) throws IOException Installs a package if it is not currently installed. If the package is already installed, no action is taken. The package is installed with "yum -q -y install $NAME". If multiple packages are already installed, the highest version is returned.- Parameters:
onInstall- Called when the RPM is actually installed. Not called if already installed.- Returns:
- the highest version of RPM that is installed
- Throws:
IOException
-
installPackages
public static void installPackages(Iterable<PackageManager.PackageName> packageNames) throws IOException Installs all of the packages that are not currently installed. If a package is already installed, no action is taken for that package.- Throws:
IOException- See Also:
-
installPackages
Installs all of the packages that are not currently installed. If a package is already installed, no action is taken for that package.- Throws:
IOException- See Also:
-
removePackage
Removes the package with the provided name. There must be only one match for the provided name. If the RPM is not installed, no action is taken. If more than one version is installed, an exception is thrown.- Returns:
truewhen a package was removed- Throws:
IOException- See Also:
-
addPackageListener
Adds a new package listener to be notified when the package list is updated or first loaded.- See Also:
-
removePackageListener
Removes a package listener.- Returns:
trueif the listener was removed,falsewhen not found- See Also:
-
