From e78b13c42807f598d9dd7e449a5980c26f731f72 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 1 Aug 2012 21:04:25 -0400 Subject: [PATCH] hook desktop menu file installation into makefile and cabal --- Build/{Desktop.hs => InstallDesktopFile.hs} | 7 ++++++- Makefile | 1 + Setup.hs | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) rename Build/{Desktop.hs => InstallDesktopFile.hs} (84%) diff --git a/Build/Desktop.hs b/Build/InstallDesktopFile.hs similarity index 84% rename from Build/Desktop.hs rename to Build/InstallDesktopFile.hs index b35b0c0104..b4a56a2cbd 100644 --- a/Build/Desktop.hs +++ b/Build/InstallDesktopFile.hs @@ -5,7 +5,7 @@ - Licensed under the GNU GPL version 3 or higher. -} -module Build.Desktop where +module Build.InstallDesktopFile where import Utility.Exception import Utility.FreeDesktop @@ -32,3 +32,8 @@ writeDesktop d = do then userDesktopMenuFilePath "git-annex" else return $ systemDesktopMenuFilePath "git-annex" writeDesktopMenuFile d dest + +main = getArgs >>= go + where + go [] = error "specify git-annex command" + go (command:_) = writeDesktop $ desktop command diff --git a/Makefile b/Makefile index 8eef53f30e..bd8aa4f3f6 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,7 @@ install: all install-docs install -d $(DESTDIR)$(PREFIX)/bin install $(bins) $(DESTDIR)$(PREFIX)/bin ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell + runghc Build/InstallDesktopFile.hs $(PREFIX)/bin/git-annex || true test: $(sources) $(clibs) @if ! $(GHCMAKE) -O0 test $(clibs); then \ diff --git a/Setup.hs b/Setup.hs index 80d23cc878..4451e86455 100644 --- a/Setup.hs +++ b/Setup.hs @@ -10,6 +10,7 @@ import Distribution.PackageDescription (PackageDescription(..)) import Distribution.Verbosity (Verbosity) import System.FilePath +import qualified Build.InstallDesktopFile as InstallDesktopFile import qualified Build.Configure as Configure main = defaultMainWithHooks simpleUserHooks @@ -25,6 +26,7 @@ myPostInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO myPostInst _ (InstallFlags { installVerbosity }) pkg lbi = do installGitAnnexShell dest verbosity pkg lbi installManpages dest verbosity pkg lbi + installDesktopFile dest verbosity pkg lbi where dest = NoCopyDest verbosity = fromFlag installVerbosity @@ -47,3 +49,9 @@ installManpages copyDest verbosity pkg lbi = srcManpages = zip (repeat srcManDir) manpages srcManDir = "" manpages = ["git-annex.1", "git-annex-shell.1"] + +installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO () +installDesktopFile copyDest verbosity pkg lbi = + InstallDesktopFile.writeDesktop $ InstallDesktopFile.desktop $ dstBinDir "git-annex" + where + dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest