11using Compat
2- import BinDeps: download_cmd, unpack_cmd, splittarpath
3- if is_apple ()
2+ using Compat: @info
3+ using Compat. Sys: isapple, islinux, iswindows
4+
5+ using BinDeps
6+ using BinDeps: download_cmd, unpack_cmd, splittarpath
7+
8+ if isapple ()
49 using Homebrew
510end
611
712function download_and_unpack (baseurl, filename)
813 downloadurl = baseurl * filename
9- info ( " Downloading $filename from $downloadurl \n To avoid this " *
10- " download, install git manually and add it to your path " *
11- " before\n running Pkg.add(\" Git\" ) or Pkg.build(\" Git\" )" )
14+ @ info " Downloading $filename from $downloadurl \n To avoid this " *
15+ " download, install git manually and add it to your path " *
16+ " before\n running Pkg.add(\" Git\" ) or Pkg.build(\" Git\" )"
1217 dest = joinpath (" usr" , string (Sys. MACHINE))
1318 for dir in (" downloads" , " usr" , dest)
1419 isdir (dir) || mkdir (dir)
@@ -17,23 +22,24 @@ function download_and_unpack(baseurl, filename)
1722 isfile (filename) || run (download_cmd (downloadurl, filename))
1823 # TODO : checksum validation
1924 (b, ext, sec_ext) = splittarpath (filename)
20- run (unpack_cmd (filename, dest, is_windows () ? " .7z" : ext, sec_ext))
25+ run (unpack_cmd (filename, dest, iswindows () ? " .7z" : ext, sec_ext))
2126 # TODO : make this less noisy on windows, see how WinRPM does it
2227end
2328
2429gitcmd = ` git`
2530gitver = " notfound"
2631try
27- gitver = readchomp (` $gitcmd --version` )
32+ global gitver = readchomp (` $gitcmd --version` )
33+ catch
2834end
2935if gitver == " notfound"
30- if is_apple ()
36+ if isapple ()
3137 # we could allow other options, but lots of other packages already
3238 # depend on Homebrew.jl on mac and it needs a working git to function
3339 error (" Working git not found on path, try running\n Pkg.build(\" Homebrew\" )" )
3440 end
3541 baseurl = " "
36- if is_linux () && (Sys. ARCH in (:x86_64 , :i686 , :i586 , :i486 , :i386 ))
42+ if islinux () && (Sys. ARCH in (:x86_64 , :i686 , :i586 , :i486 , :i386 ))
3743 # use conda for a non-root option on x86/amd64 linux
3844 # TODO ? use conda-forge when we no longer build julia on centos 5
3945 gitver = " 2.6.4"
@@ -47,7 +53,7 @@ if gitver == "notfound"
4753 zlibver = " 1.2.8"
4854 zlibbase = " http://anaconda.org/anaconda/zlib/$zlibver /$plat "
4955 download_and_unpack (zlibbase, " zlib-$zlibver -3.tar.bz2" )
50- elseif is_windows ()
56+ elseif iswindows ()
5157 # download and extract portablegit
5258 gitver = " 2.9.0"
5359 baseurl = " https://github.com/git-for-windows/git/releases/download/"
@@ -59,24 +65,27 @@ if gitver == "notfound"
5965 gitcmd = ` $gitpath `
6066 end
6167 try
62- gitver = readchomp (` $gitcmd --version` )
63- info ( " Successfully installed $gitver to $gitcmd " )
68+ global gitver = readchomp (` $gitcmd --version` )
69+ @ info " Successfully installed $gitver to $gitcmd "
6470 # TODO : fix a warning about missing /templates here on linux
6571 # by setting an environment variable in deps.jl
6672 catch err
67- error (" Could not automatically install git, error was: $err \n " *
68- (is_windows () ? " Report an issue at https://github.com/JuliaPackaging/Git.jl/issues/new" :
69- " Try installing git via your system package manager then running\n Pkg.build(\" Git\" )" ))
73+ s = if iswindows ()
74+ " Report an issue at https://github.com/JuliaPackaging/Git.jl/issues/new"
75+ else
76+ " Try installing git via your system package manager then running\n Pkg.build(\" Git\" )"
77+ end
78+ error (" Could not automatically install git, error was: $err \n " * s)
7079 end
7180else
7281 try
7382 # this is in a try because some environments like centos 7
7483 # docker containers don't have `which` installed by default
75- gitpath = chomp (readlines (is_windows () ? ` where git` : ` which git` )[1 ])
76- gitcmd = ` $gitpath `
84+ global gitpath = chomp (readlines (iswindows () ? ` where git` : ` which git` )[1 ])
85+ global gitcmd = ` $gitpath `
86+ catch
7787 end
78- info (" Using $gitver found on path" * (gitcmd == ` git` ?
79- " " : " at $gitcmd " ))
88+ @info " Using $gitver found on path" * (gitcmd == ` git` ? " " : " at $gitcmd " )
8089end
8190open (" deps.jl" , " w" ) do f
8291 println (f, " gitcmd = $gitcmd " )
0 commit comments