make inotify a build flag etc

This commit is contained in:
Joey Hess 2012-06-17 17:15:56 -04:00
parent bf3339e5b7
commit 91567ab8f6
5 changed files with 21 additions and 12 deletions

View file

@ -29,7 +29,7 @@ import Control.Concurrent.STM
import Data.Bits.Utils import Data.Bits.Utils
import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy as L
#if defined linux_HOST_OS #ifdef WITH_INOTIFY
import Utility.Inotify import Utility.Inotify
import System.INotify import System.INotify
#endif #endif
@ -38,11 +38,14 @@ type Handler = FilePath -> Maybe FileStatus -> DaemonStatusHandle -> Annex (Mayb
checkCanWatch :: Annex () checkCanWatch :: Annex ()
checkCanWatch = do checkCanWatch = do
#if defined linux_HOST_OS #ifdef WITH_INOTIFY
unlessM (liftIO (inPath "lsof") <||> Annex.getState Annex.force) $ unlessM (liftIO (inPath "lsof") <||> Annex.getState Annex.force) $
needLsof needLsof
#else #else
error "watch mode is currently only available in Linux" #if defined linux_HOST_OS
#warning "Building without inotify support; watch mode will be disabled."
#endif
error "watch mode is not available on this system"
#endif #endif
needLsof :: Annex () needLsof :: Annex ()
@ -54,7 +57,7 @@ needLsof = error $ unlines
] ]
watchThread :: ThreadState -> DaemonStatusHandle -> ChangeChan -> IO () watchThread :: ThreadState -> DaemonStatusHandle -> ChangeChan -> IO ()
#if defined linux_HOST_OS #ifdef WITH_INOTIFY
watchThread st dstatus changechan = withINotify $ \i -> do watchThread st dstatus changechan = withINotify $ \i -> do
runThreadState st $ runThreadState st $
showAction "scanning" showAction "scanning"

View file

@ -1,6 +1,6 @@
PREFIX=/usr PREFIX=/usr
IGNORE=-ignore-package monads-fd -ignore-package monads-tf IGNORE=-ignore-package monads-fd -ignore-package monads-tf
BASEFLAGS=-Wall $(IGNORE) -outputdir tmp -IUtility -DWITH_S3 BASEFLAGS=-Wall $(IGNORE) -outputdir tmp -IUtility -DWITH_S3 -DWITH_INOTIFY
GHCFLAGS=-O2 $(BASEFLAGS) GHCFLAGS=-O2 $(BASEFLAGS)
ifdef PROFILE ifdef PROFILE

2
debian/control vendored
View file

@ -20,7 +20,7 @@ Build-Depends:
libghc-ifelse-dev, libghc-ifelse-dev,
libghc-bloomfilter-dev, libghc-bloomfilter-dev,
libghc-edit-distance-dev, libghc-edit-distance-dev,
libghc-hinotify-dev, libghc-hinotify-dev [linux-any],
libghc-stm-dev, libghc-stm-dev,
ikiwiki, ikiwiki,
perlmagick, perlmagick,

View file

@ -43,7 +43,8 @@ To build and use git-annex, you will need:
* [bloomfilter](http://hackage.haskell.org/package/bloomfilter) * [bloomfilter](http://hackage.haskell.org/package/bloomfilter)
* [edit-distance](http://hackage.haskell.org/package/edit-distance) * [edit-distance](http://hackage.haskell.org/package/edit-distance)
* [stm](http://hackage.haskell.org/package/stm) * [stm](http://hackage.haskell.org/package/stm)
* [hinotify](http://hackage.haskell.org/package/hinotify) (on Linux only) * [hinotify](http://hackage.haskell.org/package/hinotify)
(optional; Linux only)
* Shell commands * Shell commands
* [git](http://git-scm.com/) * [git](http://git-scm.com/)
* [uuid](http://www.ossp.org/pkg/lib/uuid/) * [uuid](http://www.ossp.org/pkg/lib/uuid/)

View file

@ -1,5 +1,5 @@
Name: git-annex Name: git-annex
Version: 3.20120614 Version: 3.20120616
Cabal-Version: >= 1.8 Cabal-Version: >= 1.8
License: GPL License: GPL
Maintainer: Joey Hess <joey@kitenet.net> Maintainer: Joey Hess <joey@kitenet.net>
@ -28,14 +28,16 @@ Description:
Flag S3 Flag S3
Description: Enable S3 support Description: Enable S3 support
Flag Inotify
Description: Enable inotify support
Executable git-annex Executable git-annex
Main-Is: git-annex.hs Main-Is: git-annex.hs
Build-Depends: MissingH, hslogger, directory, filepath, Build-Depends: MissingH, hslogger, directory, filepath,
unix, containers, utf8-string, network, mtl, bytestring, old-locale, time, unix, containers, utf8-string, network, mtl, bytestring, old-locale, time,
pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP, pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP,
base == 4.5.*, monad-control, transformers-base, lifted-base, base == 4.5.*, monad-control, transformers-base, lifted-base,
IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, stm
hinotify, stm
-- Need to list this because it's generated from a .hsc file. -- Need to list this because it's generated from a .hsc file.
Other-Modules: Utility.Touch Other-Modules: Utility.Touch
C-Sources: Utility/libdiskfree.c C-Sources: Utility/libdiskfree.c
@ -45,6 +47,10 @@ Executable git-annex
Build-Depends: hS3 Build-Depends: hS3
CPP-Options: -DWITH_S3 CPP-Options: -DWITH_S3
if flag(Inotify)
Build-Depends: hinotify
CPP-Options: -DWITH_INOTIFY
Test-Suite test Test-Suite test
Type: exitcode-stdio-1.0 Type: exitcode-stdio-1.0
Main-Is: test.hs Main-Is: test.hs
@ -52,8 +58,7 @@ Test-Suite test
unix, containers, utf8-string, network, mtl, bytestring, old-locale, time, unix, containers, utf8-string, network, mtl, bytestring, old-locale, time,
pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP, pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP,
base == 4.5.*, monad-control, transformers-base, lifted-base, base == 4.5.*, monad-control, transformers-base, lifted-base,
IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, stm
hinotify, stm
Other-Modules: Utility.Touch Other-Modules: Utility.Touch
C-Sources: Utility/libdiskfree.c C-Sources: Utility/libdiskfree.c
Extensions: CPP Extensions: CPP