From c7a6296ef30e4dbcf70b52677e222bbce23f2a7c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Sep 2015 12:32:00 -0400 Subject: [PATCH] get git-annex working even if user doesn't add git to path This is pretty complicated, but I have both "git-annex" and "git annex" working both in the git bash shell even with git not added to path. And, when git's added to path, both work from MS-DOS prompt window too. I think that the webapp startup does still need git in path, so instructions will keep saying to do that. But, users often disregard them, and hopefully this will reduce support traffic. Also, switched the wget from the cygwin one to the msys2 one, avoiding the complication of needing to bundle any cygwin dlls. --- Build/NullSoftInstaller.hs | 65 +++++++++++++++--------------- debian/changelog | 2 + standalone/windows/build-simple.sh | 5 +-- standalone/windows/build.sh | 23 ++++++----- 4 files changed, 49 insertions(+), 46 deletions(-) diff --git a/Build/NullSoftInstaller.hs b/Build/NullSoftInstaller.hs index 7726fdcbce..c7cd44ea78 100644 --- a/Build/NullSoftInstaller.hs +++ b/Build/NullSoftInstaller.hs @@ -1,8 +1,4 @@ {- Generates a NullSoft installer program for git-annex on Windows. - - - - To build the installer, git-annex should already be built by cabal, - - and the necessary utility programs already installed - - from cygwin. - - This uses the Haskell nsis package (cabal install nsis) - to generate a .nsi file, which is then used to produce @@ -12,6 +8,10 @@ - exception of git and some utilities that are bundled with git. - The user needs to install git separately, and the installer checks - for that. + - + - To build the installer, git-annex should already be built by cabal, + - and the necessary utility programs (rsync and wget) already installed + - in PATH from msys32. - - Copyright 2013-2015 Joey Hess - @@ -44,19 +44,14 @@ main = do mustSucceed "ln" [File "dist/build/git-annex/git-annex.exe", File gitannex] let license = tmpdir licensefile mustSucceed "sh" [Param "-c", Param $ "zcat standalone/licences.gz > '" ++ license ++ "'"] - extrabins <- forM (winPrograms) $ \f -> do - p <- searchPath f - when (isNothing p) $ - print ("unable to find in PATH", f) - return p - dlls <- forM (catMaybes extrabins) findCygLibs - dllpaths <- mapM searchPath (nub (concat dlls)) - webappscript <- vbsLauncher tmpdir "git-annex-webapp" "git-annex webapp" + webappscript <- vbsLauncher tmpdir "git-annex-webapp" "git annex webapp" autostartscript <- vbsLauncher tmpdir "git-annex-autostart" "git annex assistant --autostart" let htmlhelp = tmpdir "git-annex.html" writeFile htmlhelp htmlHelpText - writeFile nsifile $ makeInstaller gitannex license htmlhelp - (catMaybes (extrabins ++ dllpaths)) + let gitannexcmd = tmpdir "git-annex.cmd" + writeFile gitannexcmd "git annex %*" + writeFile nsifile $ makeInstaller + gitannex gitannexcmd license htmlhelp winPrograms [ webappscript, autostartscript ] mustSucceed "makensis" [File nsifile] removeFile nsifile -- left behind if makensis fails @@ -115,8 +110,8 @@ needGit = strConcat , fromString "You can install git from http:////git-scm.com//" ] -makeInstaller :: FilePath -> FilePath -> FilePath -> [FilePath] -> [FilePath] -> String -makeInstaller gitannex license htmlhelp extrabins launchers = nsis $ do +makeInstaller :: FilePath -> FilePath -> FilePath -> FilePath -> [FilePath] -> [FilePath] -> String +makeInstaller gitannex gitannexcmd license htmlhelp extrabins launchers = nsis $ do name "git-annex" outFile $ str installer {- Installing into the same directory as git avoids needing to modify @@ -138,7 +133,7 @@ makeInstaller gitannex license htmlhelp extrabins launchers = nsis $ do [ Target "wscript.exe" , Parameters "\"$INSTDIR/git-annex-webapp.vbs\"" , StartOptions "SW_SHOWNORMAL" - , IconFile "$INSTDIR/cmd/git-annex.exe" + , IconFile "$INSTDIR/usr/bin/git-annex.exe" , IconIndex 2 , Description "Git Annex (Webapp)" ] @@ -147,15 +142,30 @@ makeInstaller gitannex license htmlhelp extrabins launchers = nsis $ do [ Target "wscript.exe" , Parameters "\"$INSTDIR/git-annex-autostart.vbs\"" , StartOptions "SW_SHOWNORMAL" - , IconFile "$INSTDIR/cmd/git-annex.exe" + , IconFile "$INSTDIR/usr/bin/git-annex.exe" , IconIndex 2 , Description "git-annex autostart" ] section "cmd" [] $ do - setOutPath "$INSTDIR\\cmd" + -- Remove old files no longer installed in the cmd + -- directory. + removefilesFrom "$INSTDIR/cmd" (gitannex:extrabins) + -- Install everything to the same location git puts its + -- bins. This makes "git annex" work in the git bash + -- shell, since git expects to find the git-annex binary + -- there. + setOutPath "$INSTDIR\\usr\\bin" mapM_ addfile (gitannex:extrabins) + -- This little wrapper is installed in the cmd directory, + -- so that "git-annex" works (as well as "git annex"), + -- when only that directory is in PATH (ie, in a ms-dos + -- prompt window). + setOutPath "$INSTDIR\\cmd" + addfile gitannexcmd section "meta" [] $ do - setOutPath "$INSTDIR\\doc\\git\\html" + -- git opens this file when git annex --help is run. + -- (Program Files/Git/mingw32/share/doc/git-doc/git-annex.html) + setOutPath "$INSTDIR\\mingw32\\share\\doc\\git-doc" addfile htmlhelp setOutPath "$INSTDIR" addfile license @@ -164,7 +174,8 @@ makeInstaller gitannex license htmlhelp extrabins launchers = nsis $ do uninstall $ do delete [RebootOK] $ startMenuItem delete [RebootOK] $ autoStartItem - removefilesFrom "$INSTDIR/cmd" (gitannex:extrabins) + removefilesFrom "$INSTDIR/usr/bin" (gitannex:extrabins) + removefilesFrom "$INSTDIR/cmd" gitannexcmd removefilesFrom "$INSTDIR\\doc\\git\\html" [htmlhelp] removefilesFrom "$INSTDIR" $ launchers ++ @@ -178,8 +189,6 @@ makeInstaller gitannex license htmlhelp extrabins launchers = nsis $ do winPrograms :: [FilePath] winPrograms = map (\p -> p ++ ".exe") bundledPrograms --- git opens Program Files/Git/doc/git/html/git-annex.html --- when git annex --help is run. htmlHelpText :: String htmlHelpText = unlines [ "" @@ -190,13 +199,3 @@ htmlHelpText = unlines , "" , " IO [FilePath] -findCygLibs p = filter iscyg . mapMaybe parse . lines - <$> catchDefaultIO "" (readProcess "ldd" [p]) - where - parse l = case words (dropWhile isSpace l) of - (dll:"=>":_dllpath:_offset:[]) -> Just dll - _ -> Nothing - iscyg f = "cyg" `isPrefixOf` f || "lib" `isPrefixOf` f diff --git a/debian/changelog b/debian/changelog index 2cb63ed972..a1a392ba43 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ git-annex (5.20150825) UNRELEASED; urgency=medium use it instead of the gpg command. * Windows: Switched to using git for Windows, rather than msysgit. Using msysgit with git-annex is no longer supported. + * Windows: When the user neglects to tell the git installer to add git to + PATH, git-annex will now work from within the git bash shell. -- Joey Hess Tue, 01 Sep 2015 14:46:18 -0700 diff --git a/standalone/windows/build-simple.sh b/standalone/windows/build-simple.sh index 7e0f40bab5..65be712718 100755 --- a/standalone/windows/build-simple.sh +++ b/standalone/windows/build-simple.sh @@ -35,7 +35,4 @@ fi # Build the installer cabal install nsis ghc --make Build/NullSoftInstaller.hs -fno-warn-tabs -PATH="$PATH:/cygdrive/c/Program Files/NSIS" -# Want to include cygwin programs in bundle, not others, since -# it includes the cygwin libs that go with them. -withcygpreferred Build/NullSoftInstaller.exe +PATH="$PATH:/cygdrive/c/Program Files/NSIS" Build/NullSoftInstaller.exe diff --git a/standalone/windows/build.sh b/standalone/windows/build.sh index 86b28847ce..91037eec33 100755 --- a/standalone/windows/build.sh +++ b/standalone/windows/build.sh @@ -58,20 +58,25 @@ if ! withcyg cabal build; then Build/EvilLinker fi -# Build the installer -cabal install nsis -ghc -fforce-recomp --make Build/NullSoftInstaller.hs -fno-warn-tabs -# Want to include cygwin programs in bundle, not others, since -# it includes the cygwin libs that go with them. -# Currently need an different version of rsync than the one from cygwin. -# This rsync build originally comes from https://msys2.github.io/, -# and it works with the ssh bundled with git for windows. +# Get extra programs to bundle with git-annex. +# These are msys2 programs, from https://msys2.github.io/. +# Since git for windows uses msys2, and includes its libraries, +# these programs will work well with it. if [ ! -e rsync.exe ] || [ "$(sha1sum rsync.exe)" != "85cb7a4d16d274fcf8069b39042965ad26abd6aa" ]; then rm -f rsync.exe || true withcyg wget https://downloads.kitenet.net/git-annex/windows/assets/rsync.exe withcyg chmod +x rsync.exe fi -PATH=".:/c/cygwin/bin:$PATH" Build/NullSoftInstaller.exe +if [ ! -e wget.exe ] || [ "$(sha1sum wget.exe)" != "044380729200d5762965b10123a4f134806b01cf" ]; then + rm -f wget.exe || true + withcyg wget https://downloads.kitenet.net/git-annex/windows/assets/wget.exe + withcyg chmod +x wget.exe +fi + +# Build the installer +cabal install nsis +ghc -fforce-recomp --make Build/NullSoftInstaller.hs -fno-warn-tabs +Build/NullSoftInstaller.exe rm -f last-incremental-failed