summaryrefslogtreecommitdiff
path: root/Build/InstallDesktopFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-28 15:48:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-28 15:48:00 -0400
commit818f4ab95e588f6cb7c7e21943c9000dbd3c9ac5 (patch)
treeea728bfec6cd58b27595b15e6e9525217fa03926 /Build/InstallDesktopFile.hs
parent3e2b87fb28116f3e6fa856335fec3da9fb336695 (diff)
Always do a system wide installation when DESTDIR is set. Closes: #689052
Diffstat (limited to 'Build/InstallDesktopFile.hs')
-rw-r--r--Build/InstallDesktopFile.hs24
1 files changed, 14 insertions, 10 deletions
diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs
index bf1211bf4..b4d9251e6 100644
--- a/Build/InstallDesktopFile.hs
+++ b/Build/InstallDesktopFile.hs
@@ -24,6 +24,7 @@ import System.Environment
import System.Posix.User
import System.Posix.Files
import System.FilePath
+import Data.Maybe
{- The command can be either just "git-annex", or the full path to use
- to run it. -}
@@ -43,29 +44,32 @@ autostart command = genDesktopEntry
(command ++ " assistant --autostart")
[]
-isRoot :: IO Bool
-isRoot = do
- uid <- fromIntegral <$> getRealUserID
- return $ uid == (0 :: Int)
+systemwideInstall :: IO Bool
+systemwideInstall = isroot <||> destdirset
+ where
+ isroot = do
+ uid <- fromIntegral <$> getRealUserID
+ return $ uid == (0 :: Int)
+ destdirset = isJust <$> catchMaybeIO (getEnv "DESTDIR")
inDestDir :: FilePath -> IO FilePath
inDestDir f = do
destdir <- catchDefaultIO "" (getEnv "DESTDIR")
- return $ destdir </> f
+ return $ destdir ++ "/" ++ f
writeFDODesktop :: FilePath -> IO ()
writeFDODesktop command = do
- datadir <- ifM isRoot ( return systemDataDir, userDataDir )
+ datadir <- ifM systemwideInstall ( return systemDataDir, userDataDir )
writeDesktopMenuFile (desktop command)
=<< inDestDir (desktopMenuFilePath "git-annex" datadir)
- configdir <- ifM isRoot ( return systemConfigDir, userConfigDir )
+ configdir <- ifM systemwideInstall ( return systemConfigDir, userConfigDir )
writeDesktopMenuFile (autostart command)
=<< inDestDir (autoStartPath "git-annex" configdir)
writeOSXDesktop :: FilePath -> IO ()
writeOSXDesktop command = do
- installAutoStart command =<< inDestDir =<< ifM isRoot
+ installAutoStart command =<< inDestDir =<< ifM systemwideInstall
( return $ systemAutoStart autoStartLabel
, userAutoStart autoStartLabel
)
@@ -85,7 +89,7 @@ installOSXAppFile :: FilePath -> FilePath -> Maybe String -> IO ()
installOSXAppFile appdir appfile mcontent = do
let src = "ui-macos" </> appdir </> appfile
home <- myHomeDir
- dest <- ifM isRoot
+ dest <- ifM systemwideInstall
( return $ "/Applications" </> appdir </> appfile
, return $ home </> "Desktop" </> appdir </> appfile
)
@@ -103,7 +107,7 @@ install command = do
#else
writeFDODesktop command
#endif
- ifM isRoot
+ ifM systemwideInstall
( return ()
, do
programfile <- inDestDir =<< programFile