-
Notifications
You must be signed in to change notification settings - Fork 1
/
PackageROOTForNuget.ps1
138 lines (117 loc) · 4.65 KB
/
PackageROOTForNuget.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#
# Given a version of ROOT, and a package version, go ahead and create a set of C++ nuget packages for it.
#
[CmdletBinding()]
param (
[Parameter(mandatory=$true)]
[string] $ROOTUrl,
[Parameter(mandatory=$true)]
[string] $bundleVersion,
[Parameter(mandatory=$true)]
[string] $scratchDir
)
Import-Module -Force -DisableNameChecking .\ROOTRepositoryAccess
#
# Download the root package from the web.
#
function DownloadFromWeb($url, $local)
{
if (-not (test-path $local))
{
if (-not $url.Contains("//"))
{
copy-item $url $local
}
else
{
Write-Host "Downloading $url"
$client = new-object System.Net.WebClient
$client.DownloadFile( $url, $local )
}
}
}
#
# Uncompress a file
#
$SevenZipExe = "C:\Program Files\7-Zip\7z.exe"
function Uncompress($path, $logDir)
{
if (-not $path.EndsWith(".tar.gz"))
{
throw "Only know how to uncompress .tar.gz files - $path"
}
$logFile = "$logDir/uncompress.log"
$uncompressFlag = "$path-uncompressed"
if (-not (test-path $uncompressFlag)) {
Write-Host "Uncompressing $path"
"Uncompressing $path" | out-file -filepath $logFile -append
$tarfileName = join-path $(split-path $path) $(split-path -leaf ($path.SubString(0, $path.Length-3)))
$outputDirectory = split-path $path
$switch = "-o" + $outputDirectory
if (-not (test-path $tarfileName)) {
& "$SevenZipExe" $switch x -y $path | out-file -filepath $logFile -append
}
if (-not (test-path $tarfileName)) {
throw "Could not find the tar file $tarfileName after uncompressoing $path"
}
& "$SevenZipExe" $switch x -y $tarfileName | out-file -filepath $logfile -append
$bogus = new-item $uncompressFlag -type file
}
}
#
# Get the root release, if we haven't already. If the download was interrupted, then
# the below code will likely fail.
#
$versionInfo = $ROOTUrl | parse-root-filename
$baseDirectoryName = join-path $scratchDir (($ROOTUrl -split ".win32")[0] -split "/")[-1]
$localFileName = join-path $baseDirectoryName ($ROOTUrl -split "/")[-1]
if (-not (test-path $baseDirectoryName)) {
mkdir $baseDirectoryName
}
#set-location $baseDirectoryName
DownloadFromWeb $ROOTUrl $localFileName
#
# Next, unzip it.
#
$rootInstallDir = $baseDirectoryName + "/root";
Uncompress $localFileName $baseDirectoryName
#
# Now, write out the nuget package file.
#
$version = $versionInfo.VersionMajor + "." + $versionInfo.VersionMinor + "." + $versionInfo.VersionSubMinor
$class = $versionInfo.DownloadType
$nugetFile = join-path $baseDirectoryName "ROOT.autopkg"
"nuget {" | out-file $nugetFile
" nuspec {" | out-file -append $nugetFile
" id = ROOT-$version-$class;" | out-file -append $nugetFile
" version = $version.$bundleVersion;" | out-file -append $nugetFile
" title = ROOT $version ""($class)"";" | out-file -append $nugetFile
" authors = {CERN};" | out-file -append $nugetFile
" owners = {G. Watts};" | out-file -append $nugetFile
" licenseUrl: ""http://root.cern.ch/drupal/content/license"";" | out-file -append $nugetFile
" projectUrl: ""http://root.cern.ch"";" | out-file -append $nugetFile
" iconUrl: ""http://root.cern.ch/drupal/sites/default/files/rootdrawing-logo.png"";" | out-file -append $nugetFile
" requireLicenseAcceptance: false;" | out-file -append $nugetFile
" summary: ""The complete ROOT data analysis toolkit for C++, for ROOT $version and compiled for $class"";" | out-file -append $nugetFile
" description: Contains all libraries needed for the full set of ROOT utilities;" | out-file -append $nugetFile
" releaseNotes: Release $version of ROOT;" | out-file -append $nugetFile
" tags: data;" | out-file -append $nugetFile
" };" | out-file -append $nugetFile
" " | out-file -append $nugetFile
" files {" | out-file -append $nugetFile
" include: { ""root\include\*""};" | out-file -append $nugetFile
" [x86,dynamic] {" | out-file -append $nugetFile
" lib: { ""root\lib\*.lib"" };" | out-file -append $nugetFile
" bin: { ""root\bin\*.dll"" };" | out-file -append $nugetFile
" };" | out-file -append $nugetFile
" }" | out-file -append $nugetFile
" " | out-file -append $nugetFile
" props {" | out-file -append $nugetFile
" ItemDefinitionGroup.ClCompile.ForcedIncludeFiles += ""w32pragma.h"";" | out-file -append $nugetFile
" }" | out-file -append $nugetFile
" " | out-file -append $nugetFile
"}" | out-file -append $nugetFile
#
# And generate the packages!
#
Write-NuGetPackage $nugetFile -PackageDirectory $baseDirectoryName