Skip to content

Commit d2de05b

Browse files
committed
(#230) Add ChocolateyCore Repo source
Add ChocolateyCore repo as main repo for core packages Also add change to name main packages folder Change license package creation script to point to packages folder for output Signed-off-by: Ryan Richter <[email protected]>
1 parent 19bf837 commit d2de05b

12 files changed

+81
-39
lines changed

OfflineInstallPreparation.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ if (-not $Licensed) {
9090
}
9191
Copy-Item $LicensePath $InstalledLicensePath -Force
9292
}
93-
$ExtensionSource = if (Test-Path $PSScriptRoot\files\chocolatey.extension.*.nupkg) {
94-
Convert-Path $PSScriptRoot\files\
93+
$ExtensionSource = if (Test-Path $PSScriptRoot\packages\chocolatey.extension.*.nupkg) {
94+
Convert-Path $PSScriptRoot\packages\
9595
} else {
9696
'https://licensedpackages.chocolatey.org/api/v2/'
9797
}
@@ -103,7 +103,7 @@ $PackageWorkingDirectory = Join-Path $WorkingDirectory "Packages"
103103
if (-not (Test-Path $PackageWorkingDirectory)) {
104104
$null = New-Item -Path $PackageWorkingDirectory -ItemType Directory -Force
105105
}
106-
foreach ($Package in (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertFrom-Json).packages) {
106+
foreach ($Package in (Get-Content $PSScriptRoot\packages\chocolatey.json | ConvertFrom-Json).packages) {
107107
$ChocoArgs = @(
108108
"download", "$($Package.Name)"
109109
"--output-directory", $PackageWorkingDirectory
@@ -118,7 +118,7 @@ foreach ($Package in (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertF
118118
}
119119

120120
try {
121-
if (-not (Get-ChocolateyPackageMetadata -Path $PackageWorkingDirectory -Id $Package.Name) -and -not (Get-ChocolateyPackageMetadata -Path "$PSScriptRoot\files\" -Id $Package.Name)) {
121+
if (-not (Get-ChocolateyPackageMetadata -Path $PackageWorkingDirectory -Id $Package.Name) -and -not (Get-ChocolateyPackageMetadata -Path "$PSScriptRoot\packages\" -Id $Package.Name)) {
122122
Write-Host "Downloading '$($Package.Name)'"
123123

124124
while ((Get-ChildItem $PackageWorkingDirectory -Filter *.nupkg).Where{$_.CreationTime -gt (Get-Date).AddMinutes(-1)}.Count -gt 5) {
@@ -132,18 +132,18 @@ foreach ($Package in (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertF
132132
throw $_
133133
}
134134
}
135-
Move-Item -Path $PackageWorkingDirectory\*.nupkg -Destination $PSScriptRoot\files\
135+
Move-Item -Path $PackageWorkingDirectory\*.nupkg -Destination $PSScriptRoot\packages\
136136

137137
# Jenkins Plugins
138138
$PluginsWorkingDirectory = Join-Path $WorkingDirectory "JenkinsPlugins"
139139
if (-not (Test-Path $PluginsWorkingDirectory)) {
140140
$null = New-Item -Path $PluginsWorkingDirectory -ItemType Directory -Force
141141
}
142-
if (Test-Path $PSScriptRoot\files\JenkinsPlugins.zip) {
143-
Expand-Archive -Path $PSScriptRoot\files\JenkinsPlugins.zip -DestinationPath $PluginsWorkingDirectory -Force
142+
if (Test-Path $PSScriptRoot\packages\JenkinsPlugins.zip) {
143+
Expand-Archive -Path $PSScriptRoot\packages\JenkinsPlugins.zip -DestinationPath $PluginsWorkingDirectory -Force
144144
}
145145
$ProgressPreference = "Ignore"
146-
foreach ($Plugin in (Get-Content $PSScriptRoot\files\jenkins.json | ConvertFrom-Json).plugins) {
146+
foreach ($Plugin in (Get-Content $PSScriptRoot\packages\jenkins.json | ConvertFrom-Json).plugins) {
147147
$RestArgs = @{
148148
Uri = "https://updates.jenkins-ci.org/latest/$($Plugin.Name).hpi"
149149
OutFile = Join-Path $PluginsWorkingDirectory "$($Plugin.Name).hpi"
@@ -155,12 +155,12 @@ foreach ($Plugin in (Get-Content $PSScriptRoot\files\jenkins.json | ConvertFrom-
155155
Invoke-WebRequest @RestArgs -UseBasicParsing
156156
}
157157
}
158-
Compress-Archive -Path $PluginsWorkingDirectory\* -Destination $PSScriptRoot\files\JenkinsPlugins.zip -Force
158+
Compress-Archive -Path $PluginsWorkingDirectory\* -Destination $PSScriptRoot\packages\JenkinsPlugins.zip -Force
159159

160160
# BCryptDll
161161
$null = Get-BcryptDll
162162

163163
# License
164-
if ($LicensePath -ne "$PSScriptRoot\files\chocolatey.license.xml") {
165-
Copy-Item -Path (Convert-Path $LicensePath) -Destination $PSScriptRoot\files\chocolatey.license.xml
164+
if ($LicensePath -ne "$PSScriptRoot\packages\chocolatey.license.xml") {
165+
Copy-Item -Path (Convert-Path $LicensePath) -Destination $PSScriptRoot\packages\chocolatey.license.xml
166166
}

Set-SslSecurity.ps1

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ process {
139139
Write-Host "Nexus is ready!"
140140

141141
choco source remove --name="'ChocolateyInternal'"
142-
$RepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"
142+
$InternalRepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyInternal/index.json"
143+
144+
choco source remove --name="'ChocolateyCore'"
145+
$CoreRepositoryUrl = "https://${SubjectWithoutCn}:8443/repository/ChocolateyCore/index.json"
143146

144147
# Build Credential Object, Connect to Nexus
145148
$securePw = (Get-Content 'C:\programdata\sonatype-work\nexus3\admin.password') | ConvertTo-SecureString -AsPlainText -Force
@@ -187,12 +190,23 @@ process {
187190
'source',
188191
'add',
189192
"--name='ChocolateyInternal'",
190-
"--source='$RepositoryUrl'",
193+
"--source='$InternalRepositoryUrl'",
191194
'--priority=1',
192195
"--user='chocouser'",
193196
"--password='$NexusPw'"
194197
)
195198
& choco @ChocoArgs
199+
200+
$ChocoArgs = @(
201+
'source',
202+
'add',
203+
"--name='ChocolateyCore'",
204+
"--source='$CoreRepositoryUrl'",
205+
'--priority=0',
206+
"--user='chocouser'",
207+
"--password='$NexusPw'"
208+
)
209+
& choco @ChocoArgs
196210

197211
}
198212

@@ -201,22 +215,34 @@ process {
201215
'source',
202216
'add',
203217
"--name='ChocolateyInternal'",
204-
"--source='$RepositoryUrl'",
218+
"--source='$InternalRepositoryUrl'",
205219
'--priority=1'
206220
)
207221
& choco @ChocoArgs
222+
223+
$ChocoArgs = @(
224+
'source',
225+
'add',
226+
"--name='ChocolateyCore'",
227+
"--source='$CoreRepositoryUrl'",
228+
'--priority=0'
229+
)
230+
& choco @ChocoArgs
208231
}
209232

210233
# Update Repository API key
211-
$chocoArgs = @('apikey', "--source='$RepositoryUrl'", "--api-key='$NuGetApiKey'")
234+
$chocoArgs = @('apikey', "--source='$InternalRepositoryUrl'", "--api-key='$NuGetApiKey'")
235+
& choco @chocoArgs
236+
237+
$chocoArgs = @('apikey', "--source='$CoreRepositoryUrl'", "--api-key='$NuGetApiKey'")
212238
& choco @chocoArgs
213239

214240
# Reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
215241
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
216242

217243
Update-JsonFile -Path "$env:SystemDrive\choco-setup\logs\nexus.json" -Properties @{
218244
NexusUri = "https://$($SubjectWithoutCn):8443"
219-
NexusRepo = $RepositoryUrl
245+
NexusRepo = $CoreRepositoryUrl
220246
ChocoUserPassword = $NexusPw
221247
}
222248

@@ -271,7 +297,7 @@ process {
271297
# Touch NOTHING below this line
272298
`$User = 'chocouser'
273299
`$SecurePassword = `$NexusUserPW | ConvertTo-SecureString -AsPlainText -Force
274-
`$RepositoryUrl = "https://`$(`$fqdn):8443/repository/ChocolateyInternal/index.json"
300+
`$RepositoryUrl = "https://`$(`$fqdn):8443/repository/ChocolateyCore/index.json"
275301
276302
`$credential = [pscredential]::new(`$user, `$securePassword)
277303

Start-C4bCcmSetup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ process {
3939
# Dot-source helper functions
4040
. .\scripts\Get-Helpers.ps1
4141

42-
$Packages = (Get-Content $PSScriptRoot\files\chocolatey.json | ConvertFrom-Json).packages
42+
$Packages = (Get-Content $PSScriptRoot\packages\chocolatey.json | ConvertFrom-Json).packages
4343

4444
# DB Setup
4545
Write-Host "Installing SQL Server Express"

Start-C4bJenkinsSetup.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ process {
7777
Stop-Service -Name Jenkins
7878

7979
#region Jenkins Plugin Install & Update
80-
$JenkinsPlugins = (Get-Content $PSScriptRoot\files\jenkins.json | ConvertFrom-Json).plugins
80+
$JenkinsPlugins = (Get-Content $PSScriptRoot\packages\jenkins.json | ConvertFrom-Json).plugins
8181

82-
if (Test-Path $PSScriptRoot\files\JenkinsPlugins.zip) {
83-
Expand-Archive -Path $PSScriptRoot\files\JenkinsPlugins.zip -DestinationPath $jenkinsHome\plugins\ -Force
82+
if (Test-Path $PSScriptRoot\packages\JenkinsPlugins.zip) {
83+
Expand-Archive -Path $PSScriptRoot\packages\JenkinsPlugins.zip -DestinationPath $jenkinsHome\plugins\ -Force
8484
}
8585

8686
# Performance is killed by Invoke-WebRequest's progress bars, turning them off to speed this up

Start-C4bNexusSetup.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ process {
5757
Enable-NexusRealm -Realm 'NuGet API-Key Realm'
5858

5959
#Create Chocolatey repositories
60+
New-NexusNugetHostedRepository -Name ChocolateyCore -DeploymentPolicy Allow
6061
New-NexusNugetHostedRepository -Name ChocolateyInternal -DeploymentPolicy Allow
6162
New-NexusNugetHostedRepository -Name ChocolateyTest -DeploymentPolicy Allow
6263
New-NexusRawHostedRepository -Name choco-install -DeploymentPolicy Allow -ContentDisposition Attachment
@@ -65,12 +66,12 @@ process {
6566
$NuGetApiKey = (Get-NexusNuGetApiKey -Credential $Credential).apikey
6667

6768
# Push all packages from previous steps to NuGet repo
68-
Get-ChildItem -Path "$env:SystemDrive\choco-setup\files\files" -Filter *.nupkg | ForEach-Object {
69-
choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --apikey $NugetApiKey --force
69+
Get-ChildItem -Path "$env:SystemDrive\choco-setup\files\packages" -Filter *.nupkg | ForEach-Object {
70+
choco push $_.FullName --source "$((Get-NexusRepository -Name 'ChocolateyCore').url)/index.json" --apikey $NugetApiKey --force
7071
}
7172

7273
# Temporary workaround to reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
73-
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
74+
Remove-NexusRepositoryFolder -RepositoryName ChocolateyCore -Name v3
7475

7576
# Push latest ChocolateyInstall.ps1 to raw repo
7677
$ScriptDir = "$env:SystemDrive\choco-setup\files\scripts"
@@ -91,6 +92,9 @@ process {
9192
# Add ChocolateyInternal as a source repository
9293
choco source add -n 'ChocolateyInternal' -s "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --priority 1
9394

95+
# Add ChocolateyCore as a source repository
96+
choco source add -n 'ChocolateyCore' -s "$((Get-NexusRepository -Name 'ChocolateyCore').url)/index.json" --priority 0 --admin-only
97+
9498
# Install a non-IE browser for browsing the Nexus web portal.
9599
if (-not (Test-Path 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe')) {
96100
Write-Host "Installing Microsoft Edge, to allow viewing the Nexus site"

Start-C4bSetup.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ param(
2121
[Parameter(ParameterSetName='Attended')]
2222
[string]
2323
$LicenseFile = $(
24-
if (Test-Path $PSScriptRoot\files\chocolatey.license.xml) {
24+
if (Test-Path $PSScriptRoot\packages\chocolatey.license.xml) {
2525
# Offline setup has been run, we should use that license.
26-
Join-Path $PSScriptRoot "files\chocolatey.license.xml"
26+
Join-Path $PSScriptRoot "packages\chocolatey.license.xml"
2727
} elseif (Test-Path $env:ChocolateyInstall\license\chocolatey.license.xml) {
2828
# Chocolatey is already installed, we can use that license.
2929
Join-Path $env:ChocolateyInstall "license\chocolatey.license.xml"
@@ -106,7 +106,7 @@ try {
106106
Write-Host "Setting up initial directories in"$env:SystemDrive\choco-setup"" -ForegroundColor Green
107107
$ChocoPath = "$env:SystemDrive\choco-setup"
108108
$FilesDir = Join-Path $ChocoPath "files"
109-
$PkgsDir = Join-Path $FilesDir "files"
109+
$PkgsDir = Join-Path $FilesDir "packages"
110110
$TempDir = Join-Path $ChocoPath "temp"
111111
$TestDir = Join-Path $ChocoPath "tests"
112112
@($ChocoPath, $FilesDir, $PkgsDir, $TempDir, $TestDir) | ForEach-Object {
@@ -133,8 +133,8 @@ try {
133133

134134
& $FilesDir\OfflineInstallPreparation.ps1 -LicensePath $LicenseFile
135135

136-
if (Test-Path $FilesDir\files\*.nupkg) {
137-
choco source add --name LocalChocolateySetup --source $FilesDir\files\ --Priority 1
136+
if (Test-Path $FilesDir\packages\*.nupkg) {
137+
choco source add --name LocalChocolateySetup --source $FilesDir\packages\ --Priority 1
138138
}
139139

140140
# Set Choco Server Chocolatey Configuration
File renamed without changes.
File renamed without changes.

scripts/ClientSetup.ps1

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ if ($Credential) {
8686
$NupkgUrl = if (-not $ChocolateyVersion) {
8787
$QueryString = "((Id eq 'chocolatey') and (not IsPrerelease)) and IsLatestVersion"
8888
$Query = 'Packages()?$filter={0}' -f [uri]::EscapeUriString($queryString)
89-
$QueryUrl = ($RepositoryUrl.TrimEnd('/index.json'), $Query) -join '/'
89+
$QueryUrl = ($RepositoryUrl.Replace('/index.json',''), $Query) -join '/'
9090

9191
[xml]$result = $webClient.DownloadString($QueryUrl)
9292
$result.feed.entry.content.src
9393
} else {
9494
# Otherwise, assume the URL
95-
"$($RepositoryUrl.TrimEnd('/index.json'))/chocolatey/$($ChocolateyVersion)"
95+
"$($RepositoryUrl.Replace('/index.json',''))/chocolatey/$($ChocolateyVersion)"
9696
}
9797

9898
# Download the NUPKG
@@ -111,6 +111,13 @@ $script = $webClient.DownloadString("https://${hostAddress}/repository/choco-ins
111111
choco config set cacheLocation $env:ChocolateyInstall\choco-cache
112112
choco config set commandExecutionTimeoutSeconds 14400
113113

114+
if ($InternetEnabled) {
115+
choco source add --name="'ChocolateyCore'" --source="'$RepositoryUrl'" --allow-self-service --admin-only --user="'$($Credential.UserName)'" --password="'$($Credential.GetNetworkCredential().Password)'" --priority=0
116+
}
117+
else {
118+
choco source add --name="'ChocolateyCore'" --source="'$RepositoryUrl'" --allow-self-service --admin-only --priority=0
119+
}
120+
114121
if ($InternetEnabled) {
115122
choco source add --name="'ChocolateyInternal'" --source="'$RepositoryUrl'" --allow-self-service --user="'$($Credential.UserName)'" --password="'$($Credential.GetNetworkCredential().Password)'" --priority=1
116123
}
@@ -121,12 +128,12 @@ else {
121128
choco source disable --name="'Chocolatey'"
122129
choco source disable --name="'chocolatey.licensed'"
123130

124-
choco upgrade chocolatey-license -y --source="'ChocolateyInternal'"
125-
choco upgrade chocolatey.extension -y --params="'/NoContextMenu'" --source="'ChocolateyInternal'" --no-progress
126-
choco upgrade chocolateygui -y --source="'ChocolateyInternal'" --no-progress
127-
choco upgrade chocolateygui.extension -y --source="'ChocolateyInternal'" --no-progress
131+
choco upgrade chocolatey-license -y --source="'ChocolateyCore'"
132+
choco upgrade chocolatey.extension -y --params="'/NoContextMenu'" --source="'ChocolateyCore'" --no-progress
133+
choco upgrade chocolateygui -y --source="'ChocolateyCore'" --no-progress
134+
choco upgrade chocolateygui.extension -y --source="'ChocolateyCore'" --no-progress
128135

129-
choco upgrade chocolatey-agent -y --source="'ChocolateyInternal'"
136+
choco upgrade chocolatey-agent -y --source="'ChocolateyCore'"
130137

131138
# Chocolatey Package Upgrade Resilience
132139
choco feature enable --name="'excludeChocolateyPackagesDuringUpgradeAll'"

scripts/Create-ChocoLicensePkg.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ param(
1313
# Local path used to build the license package.
1414
[Parameter()]
1515
[string]
16-
$PackagesPath = "$env:SystemDrive\choco-setup\files\files",
16+
$PackagesPath = "$env:SystemDrive\choco-setup\files\packages",
1717

1818
# Path to the license file.
1919
[Parameter()]

0 commit comments

Comments
 (0)