add lsof build deps
Check for it in configure; and add a --force option for people without it who want to live dangerously.
This commit is contained in:
parent
5d63c2a4bb
commit
0052cec2b7
5 changed files with 32 additions and 3 deletions
21
Assistant.hs
21
Assistant.hs
|
@ -49,8 +49,10 @@ import Assistant.DaemonStatus
|
||||||
import Assistant.Watcher
|
import Assistant.Watcher
|
||||||
import Assistant.Committer
|
import Assistant.Committer
|
||||||
import Assistant.SanityChecker
|
import Assistant.SanityChecker
|
||||||
|
import qualified Annex
|
||||||
import qualified Utility.Daemon
|
import qualified Utility.Daemon
|
||||||
import Utility.LogFile
|
import Utility.LogFile
|
||||||
|
import qualified Build.SysConfig as SysConfig
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
|
||||||
|
@ -64,7 +66,12 @@ startDaemon foreground
|
||||||
pidfile <- fromRepo gitAnnexPidFile
|
pidfile <- fromRepo gitAnnexPidFile
|
||||||
go $ Utility.Daemon.daemonize logfd (Just pidfile) False
|
go $ Utility.Daemon.daemonize logfd (Just pidfile) False
|
||||||
where
|
where
|
||||||
go a = withThreadState $ \st -> do
|
go a
|
||||||
|
| SysConfig.lsof = start a
|
||||||
|
| otherwise =
|
||||||
|
ifM (Annex.getState Annex.force)
|
||||||
|
(start a, needlsof)
|
||||||
|
start a = withThreadState $ \st -> do
|
||||||
dstatus <- startDaemonStatus
|
dstatus <- startDaemonStatus
|
||||||
liftIO $ a $ do
|
liftIO $ a $ do
|
||||||
changechan <- newChangeChan
|
changechan <- newChangeChan
|
||||||
|
@ -78,5 +85,17 @@ startDaemon foreground
|
||||||
_ <- forkIO $ sanityCheckerThread st dstatus changechan
|
_ <- forkIO $ sanityCheckerThread st dstatus changechan
|
||||||
watchThread st dstatus changechan
|
watchThread st dstatus changechan
|
||||||
|
|
||||||
|
-- this message is optimised away when lsof is available
|
||||||
|
needlsof = error $ unlines
|
||||||
|
[ "The lsof command is needed for watch mode to be safe."
|
||||||
|
, "But this build of git-annex was made without lsof available. Giving up..."
|
||||||
|
, ""
|
||||||
|
, "You can use --force if lsof is available now. Please make very sure it is."
|
||||||
|
, "If run with --force and without lsof available, files can be added to the"
|
||||||
|
, "annex while a process still has them opened for writing. This can"
|
||||||
|
, "corrupt data in the annex, and make fsck complain."
|
||||||
|
, "Use the --force with caution, Luke!"
|
||||||
|
]
|
||||||
|
|
||||||
stopDaemon :: Annex ()
|
stopDaemon :: Annex ()
|
||||||
stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile
|
stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile
|
||||||
|
|
|
@ -26,6 +26,7 @@ tests =
|
||||||
, TestCase "wget" $ testCmd "wget" "wget --version >/dev/null"
|
, TestCase "wget" $ testCmd "wget" "wget --version >/dev/null"
|
||||||
, TestCase "bup" $ testCmd "bup" "bup --version >/dev/null"
|
, TestCase "bup" $ testCmd "bup" "bup --version >/dev/null"
|
||||||
, TestCase "gpg" $ testCmd "gpg" "gpg --version >/dev/null"
|
, TestCase "gpg" $ testCmd "gpg" "gpg --version >/dev/null"
|
||||||
|
, TestCase "lsof" $ testCmd "lsof" "lsof -v >/dev/null 2>&1"
|
||||||
, TestCase "ssh connection caching" getSshConnectionCaching
|
, TestCase "ssh connection caching" getSshConnectionCaching
|
||||||
] ++ shaTestCases False [1, 512, 224, 384] ++ shaTestCases True [256]
|
] ++ shaTestCases False [1, 512, 224, 384] ++ shaTestCases True [256]
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,16 @@ data ProcessInfo = ProcessInfo ProcessID CmdLine
|
||||||
queryDir :: FilePath -> IO [(FilePath, LsofOpenMode, ProcessInfo)]
|
queryDir :: FilePath -> IO [(FilePath, LsofOpenMode, ProcessInfo)]
|
||||||
queryDir path = query ["+d", path]
|
queryDir path = query ["+d", path]
|
||||||
|
|
||||||
|
{- Runs lsof with some parameters.
|
||||||
|
-
|
||||||
|
- Ignores nonzero exit code; lsof returns that when no files are open.
|
||||||
|
-
|
||||||
|
- Note: If lsof is not available, this always returns [] !
|
||||||
|
-}
|
||||||
query :: [String] -> IO [(FilePath, LsofOpenMode, ProcessInfo)]
|
query :: [String] -> IO [(FilePath, LsofOpenMode, ProcessInfo)]
|
||||||
query opts = do
|
query opts = do
|
||||||
(pid, s) <- pipeFrom "lsof" ("-F0can" : opts)
|
(pid, s) <- pipeFrom "lsof" ("-F0can" : opts)
|
||||||
let !r = parse s
|
let !r = parse s
|
||||||
-- ignore nonzero exit code; lsof returns that when no files are open
|
|
||||||
void $ getProcessStatus True False $ processID pid
|
void $ getProcessStatus True False $ processID pid
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
4
debian/control
vendored
4
debian/control
vendored
|
@ -28,6 +28,7 @@ Build-Depends:
|
||||||
uuid,
|
uuid,
|
||||||
rsync,
|
rsync,
|
||||||
openssh-client,
|
openssh-client,
|
||||||
|
lsof,
|
||||||
Maintainer: Joey Hess <joeyh@debian.org>
|
Maintainer: Joey Hess <joeyh@debian.org>
|
||||||
Standards-Version: 3.9.3
|
Standards-Version: 3.9.3
|
||||||
Vcs-Git: git://git.kitenet.net/git-annex
|
Vcs-Git: git://git.kitenet.net/git-annex
|
||||||
|
@ -41,7 +42,8 @@ Depends: ${misc:Depends}, ${shlibs:Depends},
|
||||||
uuid,
|
uuid,
|
||||||
rsync,
|
rsync,
|
||||||
wget | curl,
|
wget | curl,
|
||||||
openssh-client (>= 1:5.6p1)
|
openssh-client (>= 1:5.6p1),
|
||||||
|
lsof
|
||||||
Suggests: graphviz, bup, gnupg
|
Suggests: graphviz, bup, gnupg
|
||||||
Description: manage files with git, without checking their contents into git
|
Description: manage files with git, without checking their contents into git
|
||||||
git-annex allows managing files with git, without checking the file
|
git-annex allows managing files with git, without checking the file
|
||||||
|
|
|
@ -54,6 +54,8 @@ To build and use git-annex, you will need:
|
||||||
* [sha1sum](ftp://ftp.gnu.org/gnu/coreutils/) (optional, but recommended;
|
* [sha1sum](ftp://ftp.gnu.org/gnu/coreutils/) (optional, but recommended;
|
||||||
a sha1 command will also do)
|
a sha1 command will also do)
|
||||||
* [gpg](http://gnupg.org/) (optional; needed for encryption)
|
* [gpg](http://gnupg.org/) (optional; needed for encryption)
|
||||||
|
* [lsof](ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/)
|
||||||
|
(needed for watch mode)
|
||||||
* [ikiwiki](http://ikiwiki.info) (optional; used to build the docs)
|
* [ikiwiki](http://ikiwiki.info) (optional; used to build the docs)
|
||||||
|
|
||||||
Then just [[download]] git-annex and run: `make; make install`
|
Then just [[download]] git-annex and run: `make; make install`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue