1- using Compat
2- import BinDeps: download_cmd, unpack_cmd, splittarpath
3- if is_apple ()
1+ using Base. Sys: isapple, islinux, iswindows
2+ using BinDeps
3+ using BinDeps: download_cmd, unpack_cmd, splittarpath
4+
5+ if isapple ()
46 using Homebrew
57end
68
79function download_and_unpack (baseurl, filename)
810 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\" )" )
11+ @ info " Downloading $filename from $downloadurl \n To avoid this " *
12+ " download, install git manually and add it to your path " *
13+ " before\n running Pkg.add(\" Git\" ) or Pkg.build(\" Git\" )"
1214 dest = joinpath (" usr" , string (Sys. MACHINE))
1315 for dir in (" downloads" , " usr" , dest)
1416 isdir (dir) || mkdir (dir)
@@ -17,23 +19,24 @@ function download_and_unpack(baseurl, filename)
1719 isfile (filename) || run (download_cmd (downloadurl, filename))
1820 # TODO : checksum validation
1921 (b, ext, sec_ext) = splittarpath (filename)
20- run (unpack_cmd (filename, dest, is_windows () ? " .7z" : ext, sec_ext))
22+ run (unpack_cmd (filename, dest, iswindows () ? " .7z" : ext, sec_ext))
2123 # TODO : make this less noisy on windows, see how WinRPM does it
2224end
2325
2426gitcmd = ` git`
2527gitver = " notfound"
2628try
27- gitver = readchomp (` $gitcmd --version` )
29+ global gitver = readchomp (` $gitcmd --version` )
30+ catch
2831end
2932if gitver == " notfound"
30- if is_apple ()
33+ if isapple ()
3134 # we could allow other options, but lots of other packages already
3235 # depend on Homebrew.jl on mac and it needs a working git to function
3336 error (" Working git not found on path, try running\n Pkg.build(\" Homebrew\" )" )
3437 end
3538 baseurl = " "
36- if is_linux () && (Sys. ARCH in (:x86_64 , :i686 , :i586 , :i486 , :i386 ))
39+ if islinux () && (Sys. ARCH in (:x86_64 , :i686 , :i586 , :i486 , :i386 ))
3740 # use conda for a non-root option on x86/amd64 linux
3841 # TODO ? use conda-forge when we no longer build julia on centos 5
3942 gitver = " 2.6.4"
@@ -47,7 +50,7 @@ if gitver == "notfound"
4750 zlibver = " 1.2.8"
4851 zlibbase = " http://anaconda.org/anaconda/zlib/$zlibver /$plat "
4952 download_and_unpack (zlibbase, " zlib-$zlibver -3.tar.bz2" )
50- elseif is_windows ()
53+ elseif iswindows ()
5154 # download and extract portablegit
5255 gitver = " 2.9.0"
5356 baseurl = " https://github.com/git-for-windows/git/releases/download/"
@@ -59,24 +62,27 @@ if gitver == "notfound"
5962 gitcmd = ` $gitpath `
6063 end
6164 try
62- gitver = readchomp (` $gitcmd --version` )
63- info ( " Successfully installed $gitver to $gitcmd " )
65+ global gitver = readchomp (` $gitcmd --version` )
66+ @ info " Successfully installed $gitver to $gitcmd "
6467 # TODO : fix a warning about missing /templates here on linux
6568 # by setting an environment variable in deps.jl
6669 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\" )" ))
70+ s = if iswindows ()
71+ " Report an issue at https://github.com/JuliaPackaging/Git.jl/issues/new"
72+ else
73+ " Try installing git via your system package manager then running\n Pkg.build(\" Git\" )"
74+ end
75+ error (" Could not automatically install git, error was: $err \n " * s)
7076 end
7177else
7278 try
7379 # this is in a try because some environments like centos 7
7480 # docker containers don't have `which` installed by default
75- gitpath = chomp (readlines (is_windows () ? ` where git` : ` which git` )[1 ])
76- gitcmd = ` $gitpath `
81+ global gitpath = chomp (readlines (iswindows () ? ` where git` : ` which git` )[1 ])
82+ global gitcmd = ` $gitpath `
83+ catch
7784 end
78- info (" Using $gitver found on path" * (gitcmd == ` git` ?
79- " " : " at $gitcmd " ))
85+ @info " Using $gitver found on path" * (gitcmd == ` git` ? " " : " at $gitcmd " )
8086end
8187open (" deps.jl" , " w" ) do f
8288 println (f, " gitcmd = $gitcmd " )
0 commit comments