git-annex/Utility/Android.hs
Joey Hess 2948f6d916
avoid uname -o on !linux and catch any exception from it
Fix bug in last release that prevented the webapp opening on non-Linux systems.

This commit was sponsored by Jake Vosloo on Patreon.
2018-05-08 14:06:19 -04:00

24 lines
548 B
Haskell

{-# LANGUAGE CPP #-}
{- Android stuff
-
- Copyright 2018 Joey Hess <id@joeyh.name>
-
- License: BSD-2-clause
-}
module Utility.Android where
import Common
-- Detect when the Linux build is running on Android, eg in termux.
--
-- Note that this relies on termux's uname having been built with "Android"
-- as the os name. Often on Android, uname will report "Linux".
osAndroid :: IO Bool
#ifdef linux_HOST_OS
osAndroid = catchDefaultIO False $
("Android" `isPrefixOf` ) <$> readProcess "uname" ["-o"]
#else
osAndroid = return False
#endif