include libmagic in windows installer
authorJoey Hess <joeyh@joeyh.name>
Mon, 26 Oct 2020 17:24:37 +0000 (13:24 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 26 Oct 2020 17:24:37 +0000 (13:24 -0400)
This is from https://raw.githubusercontent.com/datalad/datalad-extensions/master/resources/git-annex-magicBundle.patch
which was written by John Thorvald Wodder II.

I have converted line endings from windows, and fixed indentation to use
tabs.

Build/BundledPrograms.hs
Build/NullSoftInstaller.hs

index 096eeee29f5006d31d37f2a37e0c4a0175ab5a45..4440cc980e03cef96d1978a4138782de3291c58d 100644 (file)
@@ -87,3 +87,17 @@ preferredBundledPrograms = catMaybes
        ifset True s = Just s
        ifset False _ = Nothing
 #endif
+
+magicDLLs :: [FilePath]
+#ifdef mingw32_HOST_OS
+magicDLLs = ["libmagic-1.dll", "libgnurx-0.dll"]
+#else
+magicDLLs = []
+#endif
+
+magicShare :: [FilePath]
+#ifdef mingw32_HOST_OS
+magicShare = ["magic.mgc"]
+#else
+magicShare = []
+#endif
index 6d8ca3a29baf210b8680326b8a53ec7ebde8baab..d3d1a2243289b8d9e7a240ff6d3dd648ce22b617 100644 (file)
@@ -42,6 +42,7 @@ main = do
        withTmpDir "nsis-build" $ \tmpdir -> do\r
                let gitannex = tmpdir </> gitannexprogram\r
                mustSucceed "ln" [File "git-annex.exe", File gitannex]\r
+               mapM_ (\f -> mustSucceed "ln" [File f, File (tmpdir </> f)]) (magicDLLs ++ magicShare)\r
                let license = tmpdir </> licensefile\r
                mustSucceed "sh" [Param "-c", Param $ "zcat standalone/licences.gz > '" ++ license ++ "'"]\r
                webappscript <- vbsLauncher tmpdir "git-annex-webapp" "git annex webapp"\r
@@ -51,7 +52,7 @@ main = do
                let gitannexcmd = tmpdir </> "git-annex.cmd"\r
                writeFile gitannexcmd "git annex %*"\r
                writeFile nsifile $ makeInstaller\r
-                       gitannex gitannexcmd license htmlhelp winPrograms\r
+                       gitannex gitannexcmd license htmlhelp (winPrograms ++ magicDLLs) magicShare\r
                        [ webappscript, autostartscript ]\r
                mustSucceed "makensis" [File nsifile]\r
        removeFile nsifile -- left behind if makensis fails\r
@@ -117,8 +118,8 @@ needGit = strConcat
        , fromString "You can install git from http:////git-scm.com//"\r
        ]\r
 \r
-makeInstaller :: FilePath -> FilePath -> FilePath -> FilePath -> [FilePath] -> [FilePath] -> String\r
-makeInstaller gitannex gitannexcmd license htmlhelp extrabins launchers = nsis $ do\r
+makeInstaller :: FilePath -> FilePath -> FilePath -> FilePath -> [FilePath] -> [FilePath] -> [FilePath] -> String\r
+makeInstaller gitannex gitannexcmd license htmlhelp extrabins sharefiles launchers = nsis $ do\r
        name "git-annex"\r
        outFile $ str installer\r
        {- Installing into the same directory as git avoids needing to modify\r
@@ -163,6 +164,8 @@ makeInstaller gitannex gitannexcmd license htmlhelp extrabins launchers = nsis $
                -- there.\r
                setOutPath "$INSTDIR\\usr\\bin"\r
                mapM_ addfile (gitannex:extrabins)\r
+               setOutPath "$INSTDIR\\usr\\share\\misc"\r
+               mapM_ addfile sharefiles\r
                -- This little wrapper is installed in the cmd directory,\r
                -- so that "git-annex" works (as well as "git annex"),\r
                -- when only that directory is in PATH (ie, in a ms-dos\r