1
1
using 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 ()
4
9
using Homebrew
5
10
end
6
11
7
12
function download_and_unpack (baseurl, filename)
8
13
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\" )"
12
17
dest = joinpath (" usr" , string (Sys. MACHINE))
13
18
for dir in (" downloads" , " usr" , dest)
14
19
isdir (dir) || mkdir (dir)
@@ -17,23 +22,24 @@ function download_and_unpack(baseurl, filename)
17
22
isfile (filename) || run (download_cmd (downloadurl, filename))
18
23
# TODO : checksum validation
19
24
(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))
21
26
# TODO : make this less noisy on windows, see how WinRPM does it
22
27
end
23
28
24
29
gitcmd = ` git`
25
30
gitver = " notfound"
26
31
try
27
- gitver = readchomp (` $gitcmd --version` )
32
+ global gitver = readchomp (` $gitcmd --version` )
33
+ catch
28
34
end
29
35
if gitver == " notfound"
30
- if is_apple ()
36
+ if isapple ()
31
37
# we could allow other options, but lots of other packages already
32
38
# depend on Homebrew.jl on mac and it needs a working git to function
33
39
error (" Working git not found on path, try running\n Pkg.build(\" Homebrew\" )" )
34
40
end
35
41
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 ))
37
43
# use conda for a non-root option on x86/amd64 linux
38
44
# TODO ? use conda-forge when we no longer build julia on centos 5
39
45
gitver = " 2.6.4"
@@ -47,7 +53,7 @@ if gitver == "notfound"
47
53
zlibver = " 1.2.8"
48
54
zlibbase = " http://anaconda.org/anaconda/zlib/$zlibver /$plat "
49
55
download_and_unpack (zlibbase, " zlib-$zlibver -3.tar.bz2" )
50
- elseif is_windows ()
56
+ elseif iswindows ()
51
57
# download and extract portablegit
52
58
gitver = " 2.9.0"
53
59
baseurl = " https://github.com/git-for-windows/git/releases/download/"
@@ -59,24 +65,27 @@ if gitver == "notfound"
59
65
gitcmd = ` $gitpath `
60
66
end
61
67
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 "
64
70
# TODO : fix a warning about missing /templates here on linux
65
71
# by setting an environment variable in deps.jl
66
72
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)
70
79
end
71
80
else
72
81
try
73
82
# this is in a try because some environments like centos 7
74
83
# 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
77
87
end
78
- info (" Using $gitver found on path" * (gitcmd == ` git` ?
79
- " " : " at $gitcmd " ))
88
+ @info " Using $gitver found on path" * (gitcmd == ` git` ? " " : " at $gitcmd " )
80
89
end
81
90
open (" deps.jl" , " w" ) do f
82
91
println (f, " gitcmd = $gitcmd " )
0 commit comments