diff options
author | joewilliams <[email protected]> | 2011-10-18 10:30:56 -0700 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2011-10-20 09:50:15 +0200 |
commit | 66be346a3b0f04bb010608ad6125ecec501384c2 (patch) | |
tree | 1dd3cb18a81fd5fa106e007fba0a951c55bb85ab /lib/sasl/src/release_handler.erl | |
parent | 02ec67177b2f5d2de371362e5bb3c9b9771fb0b8 (diff) | |
download | otp-66be346a3b0f04bb010608ad6125ecec501384c2.tar.gz otp-66be346a3b0f04bb010608ad6125ecec501384c2.tar.bz2 otp-66be346a3b0f04bb010608ad6125ecec501384c2.zip |
Add release_handler:which_releases/1
This is an extension to which_releases that allows a user to specify the
status of the releases they wish to be returned. For instance it allows
for quickly determining which release is 'permanent' without the need of
parsing the entire release list.
Diffstat (limited to 'lib/sasl/src/release_handler.erl')
-rw-r--r-- | lib/sasl/src/release_handler.erl | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/sasl/src/release_handler.erl b/lib/sasl/src/release_handler.erl index bc08f94dff..5650f1433d 100644 --- a/lib/sasl/src/release_handler.erl +++ b/lib/sasl/src/release_handler.erl @@ -27,7 +27,8 @@ unpack_release/1, check_install_release/1, check_install_release/2, install_release/1, install_release/2, remove_release/1, - which_releases/0, make_permanent/1, reboot_old_release/1, + which_releases/0, which_releases/1, make_permanent/1, + reboot_old_release/1, set_unpacked/2, set_removed/1, install_file/2]). -export([upgrade_app/2, downgrade_app/2, downgrade_app/3, upgrade_script/2, downgrade_script/3, @@ -305,6 +306,14 @@ which_releases() -> call(which_releases). %%----------------------------------------------------------------- +%% Returns: [{Name, Vsn, [LibName], Status}] +%% Status = unpacked | current | permanent | old +%%----------------------------------------------------------------- +which_releases(Status) -> + Releases = which_releases(), + get_releases_with_status(Releases, Status, []). + +%%----------------------------------------------------------------- %% check_script(Script, LibDirs) -> ok | {error, Reason} %%----------------------------------------------------------------- check_script(Script, LibDirs) -> @@ -2010,3 +2019,14 @@ get_new_libs([{App,Vsn,_LibDir}|CurrentLibs], NewLibs) -> end; get_new_libs([],_) -> []. + +%%----------------------------------------------------------------- +%% Return a list of releases witch a specific status +%%----------------------------------------------------------------- +get_releases_with_status([], _, Acc) -> + Acc; +get_releases_with_status([ {_, _, _, ReleaseStatus } = Head | Tail], + Status, Acc) when ReleaseStatus == Status -> + get_releases_with_status(Tail, Status, [Head | Acc]); +get_releases_with_status([_ | Tail], Status, Acc) -> + get_releases_with_status(Tail, Status, Acc). |