2011-03-16 19:48:26 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2020-03-09 20:47:57 +00:00
|
|
|
- Copyright 2011-2020 Joey Hess <id@joeyh.name>
|
2011-03-16 19:48:26 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2011-03-16 19:48:26 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Upgrade where
|
|
|
|
|
|
|
|
import Command
|
2011-03-19 22:58:10 +00:00
|
|
|
import Upgrade
|
2016-03-31 21:20:43 +00:00
|
|
|
import Annex.Version
|
|
|
|
import Annex.Init
|
2011-03-16 19:48:26 +00:00
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2020-05-11 06:40:13 +00:00
|
|
|
cmd = dontCheck
|
|
|
|
-- because an old version may not seem to exist
|
2019-09-01 17:29:55 +00:00
|
|
|
-- and also, this avoids automatic silent upgrades before
|
|
|
|
-- this command can start up.
|
2020-05-11 06:40:13 +00:00
|
|
|
repoExists $
|
|
|
|
-- avoid upgrading repo out from under daemon
|
2019-09-01 17:29:55 +00:00
|
|
|
noDaemonRunning $
|
|
|
|
command "upgrade" SectionMaintenance "upgrade repository"
|
2020-03-09 20:47:57 +00:00
|
|
|
paramNothing (seek <$$> optParser)
|
2011-03-16 19:48:26 +00:00
|
|
|
|
2020-03-09 20:47:57 +00:00
|
|
|
data UpgradeOptions = UpgradeOptions
|
|
|
|
{ autoOnly :: Bool
|
|
|
|
}
|
2011-03-16 19:48:26 +00:00
|
|
|
|
2020-03-09 20:47:57 +00:00
|
|
|
optParser :: CmdParamsDesc -> Parser UpgradeOptions
|
|
|
|
optParser _ = UpgradeOptions
|
|
|
|
<$> switch
|
|
|
|
( long "autoonly"
|
|
|
|
<> help "only do automatic upgrades"
|
|
|
|
)
|
|
|
|
|
|
|
|
seek :: UpgradeOptions -> CommandSeek
|
|
|
|
seek o = commandAction (start o)
|
|
|
|
|
|
|
|
start :: UpgradeOptions -> CommandStart
|
2020-10-19 15:14:01 +00:00
|
|
|
start (UpgradeOptions { autoOnly = True }) =
|
2020-09-14 20:49:33 +00:00
|
|
|
starting "upgrade" (ActionItemOther Nothing) (SeekInput []) $ do
|
2020-10-19 15:14:01 +00:00
|
|
|
getVersion >>= maybe noop checkUpgrade
|
|
|
|
next $ return True
|
|
|
|
start _ =
|
|
|
|
starting "upgrade" (ActionItemOther Nothing) (SeekInput []) $ do
|
|
|
|
whenM (isNothing <$> getVersion) $ do
|
|
|
|
initialize Nothing Nothing
|
|
|
|
r <- upgrade False latestVersion
|
|
|
|
next $ return r
|