From c44b6eebb4d7e8313872ecda58a1166379203901 Mon Sep 17 00:00:00 2001 From: forget-the-bright Date: Tue, 28 Mar 2023 17:28:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9windows=20=E4=B8=8B=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=8C=85sha256=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli/install.go | 18 ++++++++++++------ go.mod | 11 +---------- go.sum | 24 ------------------------ internal/pkg/check/sha256sum.go | 24 ++++++++++++++++++++++++ internal/pkg/config/linux_url.go | 12 ++++++++++++ internal/pkg/config/urls.go | 1 + internal/pkg/config/windows_url.go | 11 +++++++++++ main.go | 10 +++++----- 8 files changed, 66 insertions(+), 45 deletions(-) create mode 100644 internal/pkg/check/sha256sum.go diff --git a/cli/install.go b/cli/install.go index 4be0904..d99f772 100644 --- a/cli/install.go +++ b/cli/install.go @@ -7,6 +7,7 @@ import ( "path/filepath" "github.com/forget-the-bright/j/internal/pkg/archiver" + "github.com/forget-the-bright/j/internal/pkg/check" "github.com/forget-the-bright/j/internal/pkg/config" "github.com/forget-the-bright/j/internal/pkg/download" @@ -33,17 +34,22 @@ func downloadAndInstall(version string) (err error) { //判断本地有没有安装包 没有就进入下载 if _, err := os.Stat(filename); err != nil { DownloadWithProgress(ui.In.URL, filename) + } else { + if ui.In.Sha256 != check.PrintSha256(filename) { + DownloadWithProgress(ui.In.URL, filename) + } } //获取解压目标目录 targetV := filepath.Join(versionsDir, ui.SimpleName) - //判断判断解压目录是否存在,不存在就解压 - if _, err := os.Stat(targetV); err != nil { - // 解压安装包 - if err = archiver.Unarchive(filename, targetV, true); err != nil { - return cli.Exit(errstring(err), 1) - } + // 检查版本是否已经安装 + if finfo, err := os.Stat(targetV); err == nil && finfo.IsDir() { + return cli.Exit(fmt.Sprintf("[g] %q version has been installed.", version), 1) + } + // 解压安装包 + if err = archiver.Unarchive(filename, targetV, true); err != nil { + return cli.Exit(errstring(err), 1) } /* // 解压安装包 if err = archiver.Unarchive(filename, versionsDir); err != nil { diff --git a/go.mod b/go.mod index 055de46..208a203 100644 --- a/go.mod +++ b/go.mod @@ -6,29 +6,20 @@ require ( github.com/Masterminds/semver v1.5.0 github.com/fatih/color v1.15.0 github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 - github.com/mholt/archiver/v3 v3.5.1 github.com/schollz/progressbar/v3 v3.13.1 github.com/urfave/cli/v2 v2.25.0 + github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 ) require ( - github.com/andybalholm/brotli v1.0.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect - github.com/golang/snappy v0.0.2 // indirect - github.com/klauspost/compress v1.11.4 // indirect - github.com/klauspost/pgzip v1.2.5 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect - github.com/nwaples/rardecode v1.1.0 // indirect - github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/rivo/uniseg v0.4.3 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/stretchr/testify v1.8.0 // indirect - github.com/ulikunitz/xz v0.5.9 // indirect - github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/term v0.6.0 // indirect diff --git a/go.sum b/go.sum index 881a248..6e7b0c6 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,14 @@ github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= -github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY= -github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s= -github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw= -github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 h1:qGQQKEcAR99REcMpsXCp3lJ03zYT1PkRd3kQGPn9GVg= github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= -github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.11.4 h1:kz40R/YWls3iqT9zX9AHN3WoVsrAWVyui5sxuLqiXqU= -github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= -github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -30,14 +16,8 @@ github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPn github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= -github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= -github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ= -github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= -github.com/pierrec/lz4/v4 v4.1.2 h1:qvY3YFXRQE/XB8MlLzJH7mSzBs74eA2gg52YTk6jUPM= -github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -53,9 +33,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= -github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli/v2 v2.25.0 h1:ykdZKuQey2zq0yin/l7JOm9Mh+pg72ngYMeB0ABn6q8= github.com/urfave/cli/v2 v2.25.0/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= @@ -67,7 +44,6 @@ golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/internal/pkg/check/sha256sum.go b/internal/pkg/check/sha256sum.go new file mode 100644 index 0000000..957b860 --- /dev/null +++ b/internal/pkg/check/sha256sum.go @@ -0,0 +1,24 @@ +package check + +import ( + "crypto/sha256" + "encoding/hex" + "fmt" + "io/ioutil" +) + +func PrintSha256(path string) string { + strContent := readFileToStr(path) + sum := sha256.Sum256([]byte(strContent)) + //fmt.Printf("sha256: %x\n", sum) + return hex.EncodeToString(sum[:]) +} + +func readFileToStr(path string) string { + content, err := ioutil.ReadFile(path) + if err != nil { + fmt.Println("read file failed, err:", err) + return "" + } + return string(content) +} diff --git a/internal/pkg/config/linux_url.go b/internal/pkg/config/linux_url.go index 55c3ee5..e581c60 100644 --- a/internal/pkg/config/linux_url.go +++ b/internal/pkg/config/linux_url.go @@ -5,6 +5,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-19+36_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk19/ri/openjdk-19+36_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-19", SimpleName: "19", @@ -13,6 +14,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-18+36_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk18/ri/openjdk-18+36_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-18", SimpleName: "18", @@ -21,6 +23,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-17+35_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk17/ri/openjdk-17+35_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-17", SimpleName: "17", @@ -29,6 +32,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-16+36_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk16/ri/openjdk-16+36_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-16", SimpleName: "16", @@ -37,6 +41,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-15+36_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk15/ri/openjdk-15+36_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-15", SimpleName: "15", @@ -45,6 +50,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-14+36_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk14/ri/openjdk-14+36_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-14", SimpleName: "14", @@ -53,6 +59,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-13+33_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk13/ri/openjdk-13+33_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-13", SimpleName: "13", @@ -61,6 +68,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-12+32_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk12/ri/openjdk-12+32_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-12", SimpleName: "12", @@ -69,6 +77,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-11+28_linux-x64_bin.tar.gz", URL: "https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz", + Sha256: "", }, Expected: "jdk-11", SimpleName: "11", @@ -77,6 +86,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-10+44_linux-x64_bin_ri.tar.gz", URL: "https://download.java.net/openjdk/jdk10/ri/openjdk-10+44_linux-x64_bin_ri.tar.gz", + Sha256: "", }, Expected: "jdk-10", SimpleName: "10", @@ -85,6 +95,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-9+181_linux-x64_ri.zip", URL: "https://download.java.net/openjdk/jdk9/ri/openjdk-9+181_linux-x64_ri.zip", + Sha256: "", }, Expected: "jdk-9", SimpleName: "9", @@ -93,6 +104,7 @@ var linux_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-8u42-b03-linux-x64-14_jul_2022.tar.gz", URL: "https://download.java.net/openjdk/jdk8u42/ri/openjdk-8u42-b03-linux-x64-14_jul_2022.tar.gz", + Sha256: "", }, Expected: "jdk-8", SimpleName: "8", diff --git a/internal/pkg/config/urls.go b/internal/pkg/config/urls.go index b32bce5..764f614 100644 --- a/internal/pkg/config/urls.go +++ b/internal/pkg/config/urls.go @@ -10,6 +10,7 @@ import ( type JavaFileItem struct { FileName string URL string + Sha256 string } type UrlItem struct { In *JavaFileItem diff --git a/internal/pkg/config/windows_url.go b/internal/pkg/config/windows_url.go index c3918e3..e7e5baf 100644 --- a/internal/pkg/config/windows_url.go +++ b/internal/pkg/config/windows_url.go @@ -5,6 +5,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-19+36_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk19/ri/openjdk-19+36_windows-x64_bin.zip", + Sha256: "8fabcee7c4e8d3b53486777ecd27bb906d67d7c1efd1bf22a8290cf659afa487", }, Expected: "jdk-19", SimpleName: "19", @@ -13,6 +14,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-18+36_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk18/ri/openjdk-18+36_windows-x64_bin.zip", + Sha256: "a5b91d4c12752d44aa75df70ae3e2311287b3e60c288b07dade106376c688277", }, Expected: "jdk-18", SimpleName: "18", @@ -21,6 +23,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-17+35_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk17/ri/openjdk-17+35_windows-x64_bin.zip", + Sha256: "e88b0df00021c9d266bb435c9a95fdc67d1948cce4518daf85c234907bd393c5", }, Expected: "jdk-17", SimpleName: "17", @@ -29,6 +32,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-16+36_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk16/ri/openjdk-16+36_windows-x64_bin.zip", + Sha256: "a78bdeaad186297601edac6772d931224d7af6f682a43372e693c37020bd37d6", }, Expected: "jdk-16", SimpleName: "16", @@ -37,6 +41,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-15+36_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk15/ri/openjdk-15+36_windows-x64_bin.zip", + Sha256: "764e39a71252a9791118a31ae56a4247c049463bda5eb72497122ec50b1d07f8", }, Expected: "jdk-15", SimpleName: "15", @@ -45,6 +50,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-14+36_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk14/ri/openjdk-14+36_windows-x64_bin.zip", + Sha256: "6b56c65c2ebb89eb361f47370359f88c4b87234dc073988a2c33e7d75c01e488", }, Expected: "jdk-14", SimpleName: "14", @@ -53,6 +59,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-13+33_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk13/ri/openjdk-13+33_windows-x64_bin.zip", + Sha256: "053d8c87bb34347478512911a6218a389720bffcde4e496be5a54d51ad7c9c2f", }, Expected: "jdk-13", SimpleName: "13", @@ -61,6 +68,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-12+32_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk12/ri/openjdk-12+32_windows-x64_bin.zip", + Sha256: "d6a550477754289e5bc0a635974b40bf5bc0515db441381414303ae954d8d6b8", }, Expected: "jdk-12", SimpleName: "12", @@ -69,6 +77,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-11+28_windows-x64_bin.zip", URL: "https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_windows-x64_bin.zip", + Sha256: "fde3b28ca31b86a889c37528f17411cd0b9651beb6fa76cac89a223417910f4b", }, Expected: "jdk-11", SimpleName: "11", @@ -77,6 +86,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "jdk-9+181_windows-x64_ri.zip", URL: "https://download.java.net/openjdk/jdk9/ri/jdk-9+181_windows-x64_ri.zip", + Sha256: "51948d69c7b770b376162ec5b88f6ec8a266bd3c9e6da21c4e834b6d0d661897", }, Expected: "jdk-9", SimpleName: "9", @@ -85,6 +95,7 @@ var windows_Url_Items = []*UrlItem{ In: &JavaFileItem{ FileName: "openjdk-8u42-b03-windows-i586-14_jul_2022.zip", URL: "https://download.java.net/openjdk/jdk8u42/ri/openjdk-8u42-b03-windows-i586-14_jul_2022.zip", + Sha256: "0314134bd981db63c7ca68d262ef896383b5694307a14bac81af88b5ad926279", }, Expected: "java-se-8u42-ri", SimpleName: "8", diff --git a/main.go b/main.go index a008983..c636d28 100644 --- a/main.go +++ b/main.go @@ -15,9 +15,9 @@ func main() { cli.Install(os.Args[1]) } */ - /* ghomeDir, _ := os.Getwd() - fmt.Println(ghomeDir) - downloadsDir := filepath.Join(ghomeDir, "downloads") - versionsDir := filepath.Join(ghomeDir, "versions") - archiver.Run_unzip(downloadsDir+"\\openjdk-19+36_windows-x64_bin.zip", versionsDir+"\\20", true) */ + /* ghomeDir, _ := os.Getwd() + fmt.Println(ghomeDir) + downloadsDir := filepath.Join(ghomeDir, "downloads") + //versionsDir := filepath.Join(ghomeDir, "versions") + fmt.Println(check.PrintSha256(downloadsDir + "\\openjdk-19+36_windows-x64_bin.zip")) */ }