Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openxt
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
msc
openxt
Commits
ff1e65ed
There was an error fetching the commit references. Please try again later.
Commit
ff1e65ed
authored
3 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
parallel download almost done. still has strange bug
parent
24460a4e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packageManager.go
+18
-8
18 additions, 8 deletions
packageManager.go
tools/nuget-download-package/main.go
+21
-9
21 additions, 9 deletions
tools/nuget-download-package/main.go
tools/nuget-download-package/unzip.go
+2
-1
2 additions, 1 deletion
tools/nuget-download-package/unzip.go
with
41 additions
and
18 deletions
packageManager.go
+
18
−
8
View file @
ff1e65ed
...
...
@@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"strings"
"sync"
)
// Scan a directory recursively, and parse `**/*.csproj`, to list all referenced nuget packages. (in CoreXT reference format)
...
...
@@ -31,16 +32,25 @@ func SyncPackages(nugetConfigPath, localRepoPath string, allDeps []dependencyIte
// Prepare nuget local repo
depsToSync
:=
depsDeduplicate
(
allDeps
)
for
index
,
dep
:=
range
depsToSync
{
// TODO: parallelize me!
log
.
Printf
(
"[%v/%v] Downloading pkg: %v:%v as var %v"
,
index
,
len
(
depsToSync
),
dep
.
pkgName
,
dep
.
targetNetVer
,
dep
.
envName
)
cmd
:=
exec
.
Command
(
"nuget-download-package"
,
dep
.
pkgName
,
dep
.
targetNetVer
,
localRepoPath
,
nugetConfigPath
)
stdout
,
err
:=
cmd
.
CombinedOutput
()
log
.
Println
(
string
(
stdout
))
// We can do nothing on failure. usually, if envName is NULL, we need not install it at all.
logErrorIfAny
(
err
,
"EXEC command"
)
var
wg
sync
.
WaitGroup
for
index_
,
dep_
:=
range
depsToSync
{
wg
.
Add
(
1
)
go
func
(
index
int
,
dep
dependencyItem
)
{
defer
wg
.
Done
()
log
.
Printf
(
"[%v/%v] Begin downloading: %v:%v as var %v"
,
index
,
len
(
depsToSync
),
dep
.
pkgName
,
dep
.
targetNetVer
,
dep
.
envName
)
log
.
Println
(
"nuget-download-package"
,
dep
.
pkgName
,
dep
.
targetNetVer
,
localRepoPath
,
nugetConfigPath
)
cmd
:=
exec
.
Command
(
"nuget-download-package"
,
dep
.
pkgName
,
dep
.
targetNetVer
,
localRepoPath
,
nugetConfigPath
)
stdout
,
err
:=
cmd
.
CombinedOutput
()
log
.
Println
(
string
(
stdout
))
// We can do nothing on failure. usually, if envName is NULL, we need not install it at all.
logErrorIfAny
(
err
,
"EXEC command"
)
log
.
Printf
(
"[%v/%v] End downloading: %v:%v as var %v"
,
index
,
len
(
depsToSync
),
dep
.
pkgName
,
dep
.
targetNetVer
,
dep
.
envName
)
}(
index_
,
dep_
)
}
wg
.
Wait
()
}
// Given package name, this function lookup the localRepoPath, and returns path to a good package version.
...
...
This diff is collapsed.
Click to expand it.
tools/nuget-download-package/main.go
+
21
−
9
View file @
ff1e65ed
...
...
@@ -197,22 +197,29 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
defer
func
()
{
recover
()}
()
// try parse, skip this entry on error
jPkgVersionItem
:=
jPkgVersionItem_
.
(
map
[
string
]
interface
{})
jCatalogEntry
:=
jPkgVersionItem
[
"catalogEntry"
]
.
(
map
[
string
]
interface
{})
j5
:=
jCatalogEntry
[
"dependencyGroups"
]
.
([]
interface
{})
myVersionText
:=
jCatalogEntry
[
"version"
]
.
(
string
)
// log.Println("DEBUG: reaching " + myVersionText)
// Let's check if this version is ok
thisPkgVersionIsOk
:=
false
if
frameworkVersion
!=
""
{
for
_
,
j6
:=
range
j5
{
j7
:=
j6
.
(
map
[
string
]
interface
{})
if
j8
,
ok
:=
j7
[
"targetFramework"
];
ok
{
thisPkgVersionIsOk
=
frameworkVersion
==
netVersionNugetFormatToStandardFormat
(
j8
.
(
string
))
break
}
else
{
// if not ok, then this pkgVersion has no targetFramework limitation.
thisPkgVersionIsOk
=
true
if
j5
,
ok
:=
jCatalogEntry
[
"dependencyGroups"
];
ok
{
for
_
,
j6
:=
range
j5
.
([]
interface
{})
{
j7
:=
j6
.
(
map
[
string
]
interface
{})
if
j8
,
ok
:=
j7
[
"targetFramework"
];
ok
{
if
frameworkVersion
==
netVersionNugetFormatToStandardFormat
(
j8
.
(
string
))
{
thisPkgVersionIsOk
=
true
break
}
}
else
{
// this pkgVersion has no targetFramework limitation.
thisPkgVersionIsOk
=
true
}
}
}
else
{
// no dependencyGroups at all
thisPkgVersionIsOk
=
true
}
}
...
...
@@ -221,6 +228,7 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
}
if
thisPkgVersionIsOk
{
// log.Println("DEBUG: good " + myVersionText)
// This version is ok! Log it.
myVersionUrl
:=
jPkgVersionItem
[
"packageContent"
]
.
(
string
)
if
version
.
CompareSimple
(
myVersionText
,
maxAvailableVersion
)
==
1
{
...
...
@@ -263,6 +271,10 @@ func main() {
pkgVer
,
targetUrl
,
targetUrlLogin
=
decidePackageVersion
(
""
,
pkgVerOrNetVer
,
indexJsons
,
indexJsons_Login
)
}
if
pkgVer
==
""
{
log
.
Println
(
"Error: can not find a valid pkgVer for "
+
pkgName
+
":"
+
pkgVerOrNetVer
)
os
.
Exit
(
2
)
}
log
.
Println
(
"Using pkgVer "
+
pkgVer
+
" from "
+
targetUrl
)
pkgBaseDir
:=
filepath
.
Join
(
localRepoDir
,
pkgName
,
pkgVer
)
...
...
This diff is collapsed.
Click to expand it.
tools/nuget-download-package/unzip.go
+
2
−
1
View file @
ff1e65ed
...
...
@@ -4,6 +4,7 @@ import (
"archive/zip"
"fmt"
"io"
"log"
"os"
"path/filepath"
"strings"
...
...
@@ -11,7 +12,7 @@ import (
func
Extract
(
src
,
dest
string
)
error
{
fmt
.
Println
(
"Extracting "
+
src
+
"..."
)
log
.
Println
(
"Extracting "
+
src
+
"..."
)
r
,
err
:=
zip
.
OpenReader
(
src
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment