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
Modifier and TypeClassDescriptionstatic enum
static interface
Called when the package list is updated or first loaded.static enum
The set of all managed package names.static class
static class
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Adds 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.Rpm
Gets the highest version of an installed package ornull
if not installed.static PackageManager.Rpm
Installs a package if it is not currently installed.static PackageManager.Rpm
installPackage
(PackageManager.PackageName name, IORunnable onInstall) Installs a package if it is not currently installed.static void
installPackages
(PackageManager.PackageName... packageNames) Installs all of the packages that are not currently installed.static void
installPackages
(Iterable<PackageManager.PackageName> packageNames) Installs all of the packages that are not currently installed.static boolean
Removes the package with the provided name.static boolean
Removes 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 -aq
can take several seconds to run, the results are cached and only updated when a file in/var/lib/rpm
has been modified.- Throws:
IOException
-
getInstalledPackage
public static PackageManager.Rpm getInstalledPackage(PackageManager.PackageName name) throws IOException Gets the highest version of an installed package ornull
if 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:
true
when 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:
true
if the listener was removed,false
when not found- See Also:
-