adjust webapp paths when run in termux on Android
And display the special case Android UI
This commit is contained in:
parent
aa652a4933
commit
b0df331b4a
3 changed files with 49 additions and 9 deletions
|
@ -98,6 +98,9 @@ checkRepositoryPath p = do
|
||||||
{- On first run, if run in the home directory, default to putting it in
|
{- On first run, if run in the home directory, default to putting it in
|
||||||
- ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.
|
- ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.
|
||||||
-
|
-
|
||||||
|
- When on Android, default to ~/storage/shared/annex, which termux sets up
|
||||||
|
- as a link to the sdcard.
|
||||||
|
-
|
||||||
- If run in another directory, that the user can write to,
|
- If run in another directory, that the user can write to,
|
||||||
- the user probably wants to put it there. Unless that directory
|
- the user probably wants to put it there. Unless that directory
|
||||||
- contains a git-annex file, in which case the user has probably
|
- contains a git-annex file, in which case the user has probably
|
||||||
|
@ -120,18 +123,31 @@ defaultRepositoryPath firstrun = do
|
||||||
if firstrun then inhome else inhome
|
if firstrun then inhome else inhome
|
||||||
#endif
|
#endif
|
||||||
where
|
where
|
||||||
inhome = do
|
inhome = ifM osAndroid
|
||||||
|
( do
|
||||||
|
home <- myHomeDir
|
||||||
|
let storageshared = home </> "storage" </> "shared"
|
||||||
|
ifM (doesDirectoryExist storageshared)
|
||||||
|
( relHome $ storageshared </> gitAnnexAssistantDefaultDir
|
||||||
|
, return $ "~" </> gitAnnexAssistantDefaultDir
|
||||||
|
)
|
||||||
|
, do
|
||||||
desktop <- userDesktopDir
|
desktop <- userDesktopDir
|
||||||
ifM (doesDirectoryExist desktop <&&> canWrite desktop)
|
ifM (doesDirectoryExist desktop <&&> canWrite desktop)
|
||||||
( relHome $ desktop </> gitAnnexAssistantDefaultDir
|
( relHome $ desktop </> gitAnnexAssistantDefaultDir
|
||||||
, return $ "~" </> gitAnnexAssistantDefaultDir
|
, return $ "~" </> gitAnnexAssistantDefaultDir
|
||||||
)
|
)
|
||||||
|
)
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
-- Avoid using eg, standalone build's git-annex.linux/ directory
|
-- Avoid using eg, standalone build's git-annex.linux/ directory
|
||||||
-- when run from there.
|
-- when run from there.
|
||||||
legit d = not <$> doesFileExist (d </> "git-annex")
|
legit d = not <$> doesFileExist (d </> "git-annex")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
-- Detect when the Linux build is running on Android, eg in termux.
|
||||||
|
osAndroid :: IO Bool
|
||||||
|
osAndroid = ("Android" == ) <$> readProcess "uname" ["-o"]
|
||||||
|
|
||||||
newRepositoryForm :: FilePath -> Hamlet.Html -> MkMForm RepositoryPath
|
newRepositoryForm :: FilePath -> Hamlet.Html -> MkMForm RepositoryPath
|
||||||
newRepositoryForm defpath msg = do
|
newRepositoryForm defpath msg = do
|
||||||
(pathRes, pathView) <- mreq (repositoryPathField True) (bfs "")
|
(pathRes, pathView) <- mreq (repositoryPathField True) (bfs "")
|
||||||
|
@ -156,7 +172,7 @@ postFirstRepositoryR = page "Getting started" (Just Configuration) $ do
|
||||||
androidspecial <- liftIO $ doesDirectoryExist "/sdcard/DCIM"
|
androidspecial <- liftIO $ doesDirectoryExist "/sdcard/DCIM"
|
||||||
let path = "/sdcard/annex"
|
let path = "/sdcard/annex"
|
||||||
#else
|
#else
|
||||||
let androidspecial = False
|
androidspecial <- liftIO osAndroid
|
||||||
path <- liftIO . defaultRepositoryPath =<< liftH inFirstRun
|
path <- liftIO . defaultRepositoryPath =<< liftH inFirstRun
|
||||||
#endif
|
#endif
|
||||||
((res, form), enctype) <- liftH $ runFormPostNoToken $ newRepositoryForm path
|
((res, form), enctype) <- liftH $ runFormPostNoToken $ newRepositoryForm path
|
||||||
|
@ -166,8 +182,14 @@ postFirstRepositoryR = page "Getting started" (Just Configuration) $ do
|
||||||
_ -> $(widgetFile "configurators/newrepository/first")
|
_ -> $(widgetFile "configurators/newrepository/first")
|
||||||
|
|
||||||
getAndroidCameraRepositoryR :: Handler ()
|
getAndroidCameraRepositoryR :: Handler ()
|
||||||
getAndroidCameraRepositoryR =
|
getAndroidCameraRepositoryR = do
|
||||||
startFullAssistant "/sdcard/DCIM" SourceGroup $ Just addignore
|
#ifdef __ANDROID__
|
||||||
|
let dcim = "/sdcard/DCIM"
|
||||||
|
#else
|
||||||
|
home <- liftIO myHomeDir
|
||||||
|
let dcim = home </> "storage" </> "dcim"
|
||||||
|
#endif
|
||||||
|
startFullAssistant dcim SourceGroup $ Just addignore
|
||||||
where
|
where
|
||||||
addignore = do
|
addignore = do
|
||||||
liftIO $ unlessM (doesFileExist ".gitignore") $
|
liftIO $ unlessM (doesFileExist ".gitignore") $
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 8"""
|
||||||
|
date="2018-04-25T17:49:30Z"
|
||||||
|
content="""
|
||||||
|
We may be moving away from the git-annex Android app, and to running
|
||||||
|
git-annex in Termux on Android.
|
||||||
|
|
||||||
|
I think that will avoid this particular problem, since it uses the linux
|
||||||
|
build of git-annex which bundles the linux linker, so the behavior of the
|
||||||
|
android linker is no longer an issue.
|
||||||
|
|
||||||
|
If the people who have been bitten by this bug want to give it a try,
|
||||||
|
see <http://git-annex.branchable.com/tips/install_on_Android_in_Termux/>
|
||||||
|
"""]]
|
|
@ -20,3 +20,6 @@ tor package. And would avoid needing to bundle other
|
||||||
often out of date stuff with git-annex.apk.
|
often out of date stuff with git-annex.apk.
|
||||||
|
|
||||||
--[[Joey]]
|
--[[Joey]]
|
||||||
|
|
||||||
|
> Retargeting this todo to be about making the git-annex linux standalone
|
||||||
|
> build work well when unpacked in termux. --[[Joey]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue