summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-11 16:00:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-11 16:00:58 -0400
commit66864d5d99e595e56ed77bd89312abc43d593c83 (patch)
tree47bb74bc92145c51faf76632785500e1bad3a30e
parent4b5aa38d39f4bef06bcbface980584d2654bcd28 (diff)
parente658dc378eaa14607278cddd30f965ffcff89426 (diff)
Merge branch 'android'
-rw-r--r--Annex/UUID.hs15
-rw-r--r--Assistant/Pairing.hs9
-rw-r--r--Build/Configure.hs1
-rw-r--r--Build/Standalone.hs1
-rw-r--r--Command/Add.hs6
-rw-r--r--Limit.hs16
-rw-r--r--Makefile27
-rw-r--r--Utility/ThreadScheduler.hs8
-rw-r--r--Utility/libdiskfree.c5
-rw-r--r--Utility/libmounts.h5
-rw-r--r--debian/changelog9
-rw-r--r--debian/control1
-rw-r--r--doc/design/assistant/android.mdwn11
-rw-r--r--doc/install/Fedora.mdwn2
-rw-r--r--doc/install/OSX.mdwn7
-rw-r--r--doc/install/ScientificLinux5.mdwn12
-rw-r--r--doc/install/fromscratch.mdwn5
-rw-r--r--git-annex.cabal14
18 files changed, 108 insertions, 46 deletions
diff --git a/Annex/UUID.hs b/Annex/UUID.hs
index b20d94125..c36861bbe 100644
--- a/Annex/UUID.hs
+++ b/Annex/UUID.hs
@@ -6,7 +6,7 @@
- UUIDs of remotes are cached in git config, using keys named
- remote.<name>.annex-uuid
-
- - Copyright 2010-2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2013 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -24,20 +24,17 @@ module Annex.UUID (
import Common.Annex
import qualified Git
import qualified Git.Config
-import qualified Build.SysConfig as SysConfig
import Config
+import qualified Data.UUID as U
+import System.Random
+
configkey :: ConfigKey
configkey = annexConfig "uuid"
-{- Generates a UUID. There is a library for this, but it's not packaged,
- - so use the command line tool. -}
+{- Generates a random UUID, that does not include the MAC address. -}
genUUID :: IO UUID
-genUUID = gen . lines <$> readProcess command params
- where
- gen [] = error $ "no output from " ++ command
- gen (l:_) = toUUID l
- (command:params) = words SysConfig.uuid
+genUUID = UUID . show <$> (randomIO :: IO U.UUID)
{- Get current repository's UUID. -}
getUUID :: Annex UUID
diff --git a/Assistant/Pairing.hs b/Assistant/Pairing.hs
index 6df54873a..2c1fcf0d0 100644
--- a/Assistant/Pairing.hs
+++ b/Assistant/Pairing.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Assistant.Pairing where
import Common.Annex
@@ -70,7 +72,12 @@ data PairingInProgress = PairingInProgress
}
deriving (Show)
-data SomeAddr = IPv4Addr HostAddress | IPv6Addr HostAddress6
+data SomeAddr = IPv4Addr HostAddress
+{- My Android build of the Network library does not currently have IPV6
+ - support. -}
+#ifndef WITH_ANDROID
+ | IPv6Addr HostAddress6
+#endif
deriving (Ord, Eq, Read, Show)
{- This contains the whole secret, just lightly obfuscated to make it not
diff --git a/Build/Configure.hs b/Build/Configure.hs
index 491a74461..6e12d19af 100644
--- a/Build/Configure.hs
+++ b/Build/Configure.hs
@@ -19,7 +19,6 @@ tests =
, testCp "cp_a" "-a"
, testCp "cp_p" "-p"
, testCp "cp_reflink_auto" "--reflink=auto"
- , TestCase "uuid generator" $ selectCmd "uuid" [("uuid -m", ""), ("uuid", ""), ("uuidgen", "")]
, TestCase "xargs -0" $ requireCmd "xargs_0" "xargs -0 </dev/null"
, TestCase "rsync" $ requireCmd "rsync" "rsync --version >/dev/null"
, TestCase "curl" $ testCmd "curl" "curl --version >/dev/null"
diff --git a/Build/Standalone.hs b/Build/Standalone.hs
index cf0abbc13..76ff7b25c 100644
--- a/Build/Standalone.hs
+++ b/Build/Standalone.hs
@@ -39,7 +39,6 @@ thirdpartyProgs = catMaybes
, Just "rsync"
, Just "ssh"
, Just "sh"
- , headMaybe $ words SysConfig.uuid -- may include parameters
, ifset SysConfig.curl "curl"
, ifset SysConfig.wget "wget"
, ifset SysConfig.bup "bup"
diff --git a/Command/Add.hs b/Command/Add.hs
index a68b190de..bfab33099 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Command.Add where
import Common.Annex
@@ -18,7 +20,9 @@ import Logs.Location
import Annex.Content
import Annex.Content.Direct
import Annex.Perms
+#ifndef WITH_ANDROID
import Utility.Touch
+#endif
import Utility.FileMode
import Config
import qualified Git.HashObject
@@ -141,12 +145,14 @@ link file key hascontent = handle (undo file key) $ do
l <- calcGitLink file key
liftIO $ createSymbolicLink l file
+#ifndef WITH_ANDROID
when hascontent $ do
-- touch the symlink to have the same mtime as the
-- file it points to
liftIO $ do
mtime <- modificationTime <$> getFileStatus file
touch file (TimeSpec mtime) False
+#endif
return l
diff --git a/Limit.hs b/Limit.hs
index 80608bcc6..16e555bed 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -5,13 +5,19 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Limit where
-import Text.Regex.PCRE.Light.Char8
-import System.Path.WildMatch
import Data.Time.Clock.POSIX
import qualified Data.Set as S
import qualified Data.Map as M
+#ifdef WITH_GLOB
+import System.FilePath.Glob (simplify, compile, match)
+#else
+import Text.Regex.PCRE.Light.Char8
+import System.Path.WildMatch
+#endif
import Common.Annex
import qualified Annex
@@ -82,10 +88,16 @@ limitExclude glob = Right $ const $ return . not . matchglob glob
matchglob :: String -> Annex.FileInfo -> Bool
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
+#ifdef WITH_GLOB
+ match pattern f
+ where
+ pattern = simplify $ compile glob
+#else
isJust $ match cregex f []
where
cregex = compile regex []
regex = '^':wildToRegex glob
+#endif
{- Adds a limit to skip files not believed to be present
- in a specfied repository. -}
diff --git a/Makefile b/Makefile
index 83fa33d47..04eea2e28 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ BASEFLAGS=-Wall -outputdir $(GIT_ANNEX_TMP_BUILD_DIR) -IUtility
# you can turn off some of these features.
#
# If you're using an old version of yesod, enable -DWITH_OLD_YESOD
-FEATURES?=$(GIT_ANNEX_LOCAL_FEATURES) -DWITH_ASSISTANT -DWITH_S3 -DWITH_WEBDAV -DWITH_WEBAPP -DWITH_PAIRING -DWITH_XMPP -DWITH_DNS
+FEATURES?=$(GIT_ANNEX_LOCAL_FEATURES) -DWITH_ASSISTANT -DWITH_S3 -DWITH_WEBDAV -DWITH_WEBAPP -DWITH_PAIRING -DWITH_XMPP -DWITH_DNS -DWITH_GLOB
bins=git-annex
mans=git-annex.1 git-annex-shell.1
@@ -14,6 +14,12 @@ sources=Build/SysConfig.hs Utility/Touch.hs Utility/Mounts.hs
all=$(bins) $(mans) docs
OS:=$(shell uname | sed 's/[-_].*//')
+ifeq ($(ANDROID),1)
+OPTFLAGS?=-DWITH_INOTIFY -DWITH_ANDROID
+clibs=Utility/libdiskfree.o Utility/libmounts.o
+CFLAGS:=-Wall -DWITH_ANDROID
+THREADFLAGS=-threaded
+else
ifeq ($(OS),Linux)
OPTFLAGS?=-DWITH_INOTIFY -DWITH_DBUS
clibs=Utility/libdiskfree.o Utility/libmounts.o
@@ -41,6 +47,7 @@ clibs=Utility/libdiskfree.o Utility/libmounts.o Utility/libkqueue.o
endif
endif
endif
+endif
ALLFLAGS = $(BASEFLAGS) $(FEATURES) $(OPTFLAGS) $(THREADFLAGS)
@@ -51,7 +58,8 @@ ifdef PROFILE
GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(ALLFLAGS)
endif
-GHCMAKE=ghc $(GHCFLAGS) --make
+GHC?=ghc
+GHCMAKE=$(GHC) $(GHCFLAGS) --make
# Am I typing :make in vim? Do a fast build.
ifdef VIM
@@ -113,7 +121,7 @@ test: $(sources) $(clibs)
testcoverage:
rm -f test.tix test
- ghc $(GHCFLAGS) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR)/testcoverage --make -fhpc test
+ $(GHC) $(GHCFLAGS) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR)/testcoverage --make -fhpc test
./test
@echo ""
@hpc report test --exclude=Main --exclude=QC
@@ -216,6 +224,19 @@ osxapp:
rm -f tmp/git-annex.dmg.bz2
bzip2 --fast tmp/git-annex.dmg
+# Cross compile for Android binary.
+# Uses https://github.com/neurocyte/ghc-android
+#
+# configure is run, probing the local system.
+# So the Android should have all the same stuff that configure probes for,
+# including the same version of git.
+android:
+ $(MAKE) Build/SysConfig.hs
+ GHC=$$HOME/.ghc/android-14/arm-linux-androideabi-4.7/bin/arm-unknown-linux-androideabi-ghc \
+ CC=$$HOME/.ghc/android-14/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc \
+ FEATURES="-DWITH_ANDROID -DWITH_ASSISTANT -DWITH_GLOB -DWITH_DNS" \
+ ANDROID=1 $(MAKE) fast
+
# used by ./ghci
getflags:
@echo $(ALLFLAGS) $(clibs)
diff --git a/Utility/ThreadScheduler.hs b/Utility/ThreadScheduler.hs
index 96bccbe70..fdf40ab6d 100644
--- a/Utility/ThreadScheduler.hs
+++ b/Utility/ThreadScheduler.hs
@@ -6,13 +6,17 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Utility.ThreadScheduler where
import Common
import Control.Concurrent
-import System.Posix.Terminal
import System.Posix.Signals
+#ifndef WITH_ANDROID
+import System.Posix.Terminal
+#endif
newtype Seconds = Seconds { fromSeconds :: Int }
deriving (Eq, Ord, Show)
@@ -49,8 +53,10 @@ waitForTermination :: IO ()
waitForTermination = do
lock <- newEmptyMVar
check softwareTermination lock
+#ifndef WITH_ANDROID
whenM (queryTerminal stdInput) $
check keyboardSignal lock
+#endif
takeMVar lock
where
check sig lock = void $
diff --git a/Utility/libdiskfree.c b/Utility/libdiskfree.c
index 5e84d4bde..a9ca90b41 100644
--- a/Utility/libdiskfree.c
+++ b/Utility/libdiskfree.c
@@ -22,6 +22,10 @@
# define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */
# define STATSTRUCT statfs
#else
+#if defined WITH_ANDROID
+# warning free space checking code not available for Android
+# define UNKNOWN
+#else
#if defined (__linux__) || defined (__FreeBSD_kernel__)
/* Linux or Debian kFreeBSD */
/* This is a POSIX standard, so might also work elsewhere too. */
@@ -34,6 +38,7 @@
#endif
#endif
#endif
+#endif
#include <errno.h>
#include <stdio.h>
diff --git a/Utility/libmounts.h b/Utility/libmounts.h
index b65978629..76b2484d3 100644
--- a/Utility/libmounts.h
+++ b/Utility/libmounts.h
@@ -5,6 +5,10 @@
# include <sys/mount.h>
# define GETMNTINFO
#else
+#if defined WITH_ANDROID
+# warning mounts listing code not available for Android
+# define UNKNOWN
+#else
#if defined (__linux__) || defined (__FreeBSD_kernel__)
/* Linux or Debian kFreeBSD */
#include <mntent.h>
@@ -14,6 +18,7 @@
# define UNKNOWN
#endif
#endif
+#endif
#include <stdio.h>
diff --git a/debian/changelog b/debian/changelog
index 4422ea8bc..e2c0dcb4a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+git-annex (3.20130208) UNRELEASED; urgency=low
+
+ * Now uses the Haskell uuid library, rather than needing a uuid program.
+ * Now uses the Haskell Glob library, rather than pcre-light, avoiding
+ the need to install libpcre. Currently done only for Cabal or when
+ the Makefile is made to use -DWITH_GLOB
+
+ -- Joey Hess <joeyh@debian.org> Sun, 10 Feb 2013 14:52:01 -0400
+
git-annex (3.20130207) unstable; urgency=low
* webapp: Now allows restarting any threads that crash.
diff --git a/debian/control b/debian/control
index 2610ca53b..cdfbd06c1 100644
--- a/debian/control
+++ b/debian/control
@@ -17,6 +17,7 @@ Build-Depends:
libghc-quickcheck2-dev,
libghc-monad-control-dev (>= 0.3),
libghc-lifted-base-dev,
+ libghc-uuid-dev,
libghc-json-dev,
libghc-ifelse-dev,
libghc-bloomfilter-dev,
diff --git a/doc/design/assistant/android.mdwn b/doc/design/assistant/android.mdwn
index 1a2ba8dd8..d050619c7 100644
--- a/doc/design/assistant/android.mdwn
+++ b/doc/design/assistant/android.mdwn
@@ -32,3 +32,14 @@ transfers when not on wifi. This may need to be configurable.
Due to use of the FAT filesystem, which doesn't do symlinks, [[desymlink]]
is probably needed for at least older Android devices that have SD cards.
+
+## Porting notes
+
+To build git, you can use the C cross compiler installed by ghc-android.
+I did so like this:
+
+ PATH=~/.ghc/android-14/arm-linux-androideabi-4.7/arm-linux-androideabi/bin:$PATH NO_OPENSSL=1 NO_GETTEXT=1 NO_GECOS_IN_PWENT=1 NO_GETPASS=1 NO_NSEC=1 NO_MKDTEMP=1 NO_PTHREADS=1 NO_PERL=1 NO_CURL=1 NO_EXPAT=1 NO_TCLTK=1 NO_ICONV=1 make
+
+This required coping various directories from
+~/.ghc/android-14/arm-linux-androideabi-4.7/ into
+~/.ghc/android-14/arm-linux-androideabi-4.7/arm-linux-androideabi/
diff --git a/doc/install/Fedora.mdwn b/doc/install/Fedora.mdwn
index a150dbc38..d7d07715c 100644
--- a/doc/install/Fedora.mdwn
+++ b/doc/install/Fedora.mdwn
@@ -9,7 +9,7 @@ Should be as simple as: `yum install git-annex`
Older version? Here's an installation recipe for Fedora 14 through 15.
<pre>
-sudo yum install ghc cabal-install pcre-devel
+sudo yum install ghc cabal-install
git clone git://git-annex.branchable.com/ git-annex
cd git-annex
git checkout ghc7.0
diff --git a/doc/install/OSX.mdwn b/doc/install/OSX.mdwn
index e9e2a044b..10735a7d0 100644
--- a/doc/install/OSX.mdwn
+++ b/doc/install/OSX.mdwn
@@ -24,7 +24,7 @@ the app for OSX Lion.
<pre>
brew update
-brew install haskell-platform git ossp-uuid md5sha1sum coreutils pcre libgsasl gnutls libidn libgsasl pkg-config libxml2
+brew install haskell-platform git ossp-uuid md5sha1sum coreutils libgsasl gnutls libidn libgsasl pkg-config libxml2
brew link libxml2
cabal update
PATH=$HOME/bin:$PATH
@@ -38,10 +38,7 @@ The version provided by Macports is too old to work with current versions of git
Then execute
<pre>
-sudo port install git-core ossp-uuid md5sha1sum coreutils pcre gnutls libxml2 libgsasl pkgconfig
-
-sudo ln -s /opt/local/include/pcre.h /usr/include/pcre.h # This is hack that allows pcre-light to find pcre
-
+sudo port install git-core ossp-uuid md5sha1sum coreutils gnutls libxml2 libgsasl pkgconfig
sudo cabal update
PATH=$HOME/bin:$PATH
cabal install c2hs git-annex --bindir=$HOME/bin
diff --git a/doc/install/ScientificLinux5.mdwn b/doc/install/ScientificLinux5.mdwn
index 15ffb928b..23dca311c 100644
--- a/doc/install/ScientificLinux5.mdwn
+++ b/doc/install/ScientificLinux5.mdwn
@@ -29,23 +29,11 @@ don't want things to be system wide)
$ export PATH=/usr/hs/bin:$PATH
-On SL5 pcre is at version 6.6 which is far too old for one of the
-dependancies that git-annex requires. Therefore the user must install
-an updated version of _pcre_ either from source or another method, I
-chose to install it from source and by hand into /usr/local
-
- $ wget http://sourceforge.net/projects/pcre/files/pcre/8.30/pcre-8.30.tar.gz/download
- $ tar zxvf pcre-8.30.tar.gz
- $ cd pcre-8.30
- $ ./configure
- $ make && make install
-
Once the packages are installed and are in your execution path, using
cabal to configure and build git-annex just makes life easier, it
should install all the needed dependancies.
$ cabal update
- $ cabal install pcre-light --extra-include-dirs=/usr/local/include
$ git clone git://git.kitenet.net/git-annex
$ cd git-annex
$ make git-annex.1
diff --git a/doc/install/fromscratch.mdwn b/doc/install/fromscratch.mdwn
index 8fdb8dcda..386776f6b 100644
--- a/doc/install/fromscratch.mdwn
+++ b/doc/install/fromscratch.mdwn
@@ -5,7 +5,6 @@ quite a lot.
* [The Haskell Platform](http://haskell.org/platform/) (GHC 7.4 or newer)
* [mtl](http://hackage.haskell.org.package/mtl) (2.1.1 or newer)
* [MissingH](http://github.com/jgoerzen/missingh/wiki)
- * [pcre-light](http://hackage.haskell.org/package/pcre-light)
* [utf8-string](http://hackage.haskell.org/package/utf8-string)
* [SHA](http://hackage.haskell.org/package/SHA)
* [dataenc](http://hackage.haskell.org/package/dataenc)
@@ -20,6 +19,8 @@ quite a lot.
* [hS3](http://hackage.haskell.org/package/hS3) (optional)
* [DAV](http://hackage.haskell.org/package/DAV) (optional)
* [SafeSemaphore](http://hackage.haskell.org/package/SafeSemaphore)
+ * [UUID](http://hackage.haskell.org/package/uuid)
+ * [Glob](http://hackage.haskell.org/package/Glob)
* Optional haskell stuff, used by the [[assistant]] and its webapp (edit Makefile to disable)
* [stm](http://hackage.haskell.org/package/stm)
(version 2.3 or newer)
@@ -48,8 +49,6 @@ quite a lot.
* [async](http://hackage.haskell.org/package/async)
* Shell commands
* [git](http://git-scm.com/)
- * [uuid](http://www.ossp.org/pkg/lib/uuid/)
- (or `uuidgen` from util-linux)
* [xargs](http://savannah.gnu.org/projects/findutils/)
* [rsync](http://rsync.samba.org/)
* [curl](http://http://curl.haxx.se/) (optional, but recommended)
diff --git a/git-annex.cabal b/git-annex.cabal
index 24fc251ee..1b06564e5 100644
--- a/git-annex.cabal
+++ b/git-annex.cabal
@@ -57,16 +57,16 @@ Executable git-annex
Build-Depends: MissingH, hslogger, directory, filepath,
unix, containers, utf8-string, network (>= 2.0), mtl (>= 2.1.1),
bytestring, old-locale, time,
- pcre-light, extensible-exceptions, dataenc, SHA, process, json,
+ extensible-exceptions, dataenc, SHA, process, json,
base (>= 4.5 && < 4.8), monad-control, transformers-base, lifted-base,
IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process,
- SafeSemaphore
+ SafeSemaphore, uuid, Glob
-- Need to list these because they're generated from .hsc files.
Other-Modules: Utility.Touch Utility.Mounts
Include-Dirs: Utility
C-Sources: Utility/libdiskfree.c Utility/libmounts.c
Extensions: CPP
- GHC-Options: -threaded
+ GHC-Options: -threaded -DWITH_GLOB
if flag(S3)
Build-Depends: hS3
@@ -123,15 +123,15 @@ Test-Suite test
Main-Is: test.hs
Build-Depends: testpack, HUnit, MissingH, hslogger, directory, filepath,
unix, containers, utf8-string, network, mtl (>= 2.1.1), bytestring,
- old-locale, time, pcre-light, extensible-exceptions, dataenc, SHA,
- process, json, HTTP, base (>= 4.5 && < 4.7), monad-control,
+ old-locale, time, extensible-exceptions, dataenc, SHA,
+ process, json, base (>= 4.5 && < 4.7), monad-control,
transformers-base, lifted-base, IfElse, text, QuickCheck >= 2.1,
- bloomfilter, edit-distance, process, SafeSemaphore
+ bloomfilter, edit-distance, process, SafeSemaphore, Glob
Other-Modules: Utility.Touch
Include-Dirs: Utility
C-Sources: Utility/libdiskfree.c
Extensions: CPP
- GHC-Options: -threaded
+ GHC-Options: -threaded -DWITH_GLOB
source-repository head
type: git