Always do a system wide installation when DESTDIR is set. Closes: #689052

This commit is contained in:
Joey Hess 2012-09-28 15:48:00 -04:00
parent 1087fac544
commit 087781fb05
2 changed files with 15 additions and 10 deletions

View file

@ -24,6 +24,7 @@ import System.Environment
import System.Posix.User import System.Posix.User
import System.Posix.Files import System.Posix.Files
import System.FilePath import System.FilePath
import Data.Maybe
{- The command can be either just "git-annex", or the full path to use {- The command can be either just "git-annex", or the full path to use
- to run it. -} - to run it. -}
@ -43,29 +44,32 @@ autostart command = genDesktopEntry
(command ++ " assistant --autostart") (command ++ " assistant --autostart")
[] []
isRoot :: IO Bool systemwideInstall :: IO Bool
isRoot = do systemwideInstall = isroot <||> destdirset
uid <- fromIntegral <$> getRealUserID where
return $ uid == (0 :: Int) isroot = do
uid <- fromIntegral <$> getRealUserID
return $ uid == (0 :: Int)
destdirset = isJust <$> catchMaybeIO (getEnv "DESTDIR")
inDestDir :: FilePath -> IO FilePath inDestDir :: FilePath -> IO FilePath
inDestDir f = do inDestDir f = do
destdir <- catchDefaultIO "" (getEnv "DESTDIR") destdir <- catchDefaultIO "" (getEnv "DESTDIR")
return $ destdir </> f return $ destdir ++ "/" ++ f
writeFDODesktop :: FilePath -> IO () writeFDODesktop :: FilePath -> IO ()
writeFDODesktop command = do writeFDODesktop command = do
datadir <- ifM isRoot ( return systemDataDir, userDataDir ) datadir <- ifM systemwideInstall ( return systemDataDir, userDataDir )
writeDesktopMenuFile (desktop command) writeDesktopMenuFile (desktop command)
=<< inDestDir (desktopMenuFilePath "git-annex" datadir) =<< inDestDir (desktopMenuFilePath "git-annex" datadir)
configdir <- ifM isRoot ( return systemConfigDir, userConfigDir ) configdir <- ifM systemwideInstall ( return systemConfigDir, userConfigDir )
writeDesktopMenuFile (autostart command) writeDesktopMenuFile (autostart command)
=<< inDestDir (autoStartPath "git-annex" configdir) =<< inDestDir (autoStartPath "git-annex" configdir)
writeOSXDesktop :: FilePath -> IO () writeOSXDesktop :: FilePath -> IO ()
writeOSXDesktop command = do writeOSXDesktop command = do
installAutoStart command =<< inDestDir =<< ifM isRoot installAutoStart command =<< inDestDir =<< ifM systemwideInstall
( return $ systemAutoStart autoStartLabel ( return $ systemAutoStart autoStartLabel
, userAutoStart autoStartLabel , userAutoStart autoStartLabel
) )
@ -85,7 +89,7 @@ installOSXAppFile :: FilePath -> FilePath -> Maybe String -> IO ()
installOSXAppFile appdir appfile mcontent = do installOSXAppFile appdir appfile mcontent = do
let src = "ui-macos" </> appdir </> appfile let src = "ui-macos" </> appdir </> appfile
home <- myHomeDir home <- myHomeDir
dest <- ifM isRoot dest <- ifM systemwideInstall
( return $ "/Applications" </> appdir </> appfile ( return $ "/Applications" </> appdir </> appfile
, return $ home </> "Desktop" </> appdir </> appfile , return $ home </> "Desktop" </> appdir </> appfile
) )
@ -103,7 +107,7 @@ install command = do
#else #else
writeFDODesktop command writeFDODesktop command
#endif #endif
ifM isRoot ifM systemwideInstall
( return () ( return ()
, do , do
programfile <- inDestDir =<< programFile programfile <- inDestDir =<< programFile

1
debian/changelog vendored
View file

@ -18,6 +18,7 @@ git-annex (3.20120925) UNRELEASED; urgency=low
in a 600 mode file in the local git repo. in a 600 mode file in the local git repo.
* webapp: Avoid crashing when ssh-keygen -F chokes on an invalid known_hosts * webapp: Avoid crashing when ssh-keygen -F chokes on an invalid known_hosts
file. file.
* Always do a system wide installation when DESTDIR is set. Closes: #689052
-- Joey Hess <joeyh@debian.org> Mon, 24 Sep 2012 19:58:07 -0400 -- Joey Hess <joeyh@debian.org> Mon, 24 Sep 2012 19:58:07 -0400