Skip to content

Commit

Permalink
Update AU Install via Chocolatey
Browse files Browse the repository at this point in the history
  • Loading branch information
strausmann committed Jun 10, 2024
1 parent 78164ae commit a5659a3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
7 changes: 4 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ install:
'autohotkey.portable' = '2.0.17'
'vt-cli' = '0.14.0'
'git' = '2.45.2'
'chocolatey-au' = '1.0.0'
}.GetEnumerator() | % {
if (!(Test-Path "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg")) { rm "${env:nupkg_cache_path}\$($_.Key).*.nupkg" ; Invoke-WebRequest "https://chocolatey.org/api/v2/package/$($_.Key)/$($_.Value)" -OutFile "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg" }
if ($_.Key -eq 'chocolatey') { cup $_.Key --version $_.Value --source "'${env:nupkg_cache_path};http://chocolatey.org/api/v2/'" --allow-downgrade }
Expand All @@ -82,9 +83,9 @@ install:
rm "$env:ChocolateyInstall\logs\*.log"
- git --version
- choco --version
- ps: |
git clone -q https://github.com/chocolatey-community/chocolatey-au.git $Env:TEMP/au
. "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
#- ps: |
# git clone -q https://github.com/chocolatey-community/chocolatey-au.git $Env:TEMP/au
# . "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
- ps: |
"Build info"
' {0,-20} {1}' -f 'SCHEDULED BUILD:', ($Env:APPVEYOR_SCHEDULED_BUILD -eq 'true')
Expand Down
18 changes: 9 additions & 9 deletions New-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ function New-Package{
if ($Name -eq $null) { throw "Name can't be empty" }
if (Test-Path $Name) { throw "Package with that name already exists" }
if (!(Test-Path _template)) { throw "Template for the packages not found" }
cp _template automatic\$Name -Recurse
Copy-Item _template automatic\$Name -Recurse

$nuspec = gc "automatic\$Name\template.nuspec"
rm "automatic\$Name\template.nuspec"
$nuspec = Get-Content "automatic\$Name\template.nuspec"
Remove-Item "automatic\$Name\template.nuspec"

Write-Verbose 'Fixing nuspec'
$nuspec = $nuspec -replace '<id>.+', "<id>$Name</id>"
Expand All @@ -39,27 +39,27 @@ function New-Package{
{
'Installer' {
Write-Verbose 'Using installer template'
mv "automatic\$Name\tools\chocolateyInstallExe.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
Move-Item "automatic\$Name\tools\chocolateyInstallExe.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
}
'Portable' {
Write-Verbose 'Using portable template'
mv "automatic\$Name\tools\chocolateyInstallZip.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
Move-Item "automatic\$Name\tools\chocolateyInstallZip.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
}
'EInstaller' {
Write-Verbose 'Using embedded installer template'
mv "automatic\$Name\tools\chocolateyInstallEmbeddedExe.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
Move-Item "automatic\$Name\tools\chocolateyInstallEmbeddedExe.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
}
'EPortable' {
Write-Verbose 'Using embedded portable template'
mv "automatic\$Name\tools\chocolateyInstallEmbeddedZip.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
Move-Item "automatic\$Name\tools\chocolateyInstallEmbeddedZip.ps1" "automatic\$Name\tools\chocolateyInstall.ps1"
}

default { throw 'No template given' }
}
rm "automatic\$Name\tools\*.ps1" -Exclude chocolateyInstall.ps1, chocolateyUninstall.ps1
Remove-Item "automatic\$Name\tools\*.ps1" -Exclude chocolateyInstall.ps1, chocolateyUninstall.ps1

Write-Verbose 'Fixing chocolateyInstall.ps1'
$installer = gc "automatic\$Name\tools\chocolateyInstall.ps1"
$installer = Get-Content "automatic\$Name\tools\chocolateyInstall.ps1"
$installer -replace "(^[$]packageName\s*=\s*)('.*')", "`$1'$($Name)'" | Set-Content "automatic\$Name\tools\chocolateyInstall.ps1"
}

Expand Down
12 changes: 6 additions & 6 deletions cinst-gh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ function cinst-gh {
$Repo = "https://github.com/strausmann/ChocolateyPackages/tree/master"

$name = $args[0]
$download_page = iwr $Repo/$name -UseBasicParsing
$download_page = Invoke-WebRequest $Repo/$name -UseBasicParsing
$url = $download_page.Links.href -like '*.nupkg'
$p = $url -split '/' | select -last 1
$p = $url -split '/' | Select-Object -last 1

$raw = $Repo -replace 'github.com', 'rawgit.com' -replace 'tree/'
iwr "$raw/$(($p -split '\.')[0])/$p" -Out $p
$a = $args | select -Skip 1
Invoke-WebRequest "$raw/$(($p -split '\.')[0])/$p" -Out $p
$a = $args | Select-Object -Skip 1
$cmd = "cinst $p $a"
Write-Host $cmd; iex $cmd
rm $p
Write-Host $cmd; Invoke-Expression $cmd
Remove-Item $p
}
6 changes: 3 additions & 3 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#requires -version 2
#Requires -Version 2

<#
.SYNOPSIS
Expand All @@ -19,7 +19,7 @@ param(

$ErrorActionPreference = 'Stop'

$module_name = 'AU'
$module_name = 'Chocolatey-AU'

if ($PSVersionTable.PSEdition -ne "Core") {
$module_dst = "$Env:ProgramFiles\WindowsPowerShell\Modules"
Expand Down Expand Up @@ -68,6 +68,6 @@ $functions | ForEach-Object {
}
}

remove-module $module_name
Remove-Module $module_name
Write-Host "`nTo learn more about ${module_name}: man about_${module_name}"
Write-Host "See help for any function: man updateall`n"
1 change: 0 additions & 1 deletion test.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
param(
[switch]$Chocolatey,

[switch]$Pester,
[string]$Tag,
[switch]$CodeCoverage
Expand Down
4 changes: 2 additions & 2 deletions test_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (($Name.Length -gt 0) -and ($Name[0] -match '^random (.+)')) {
Write-Host "TESTING GROUP $($n+1) of $group"

$group_size = [int]($lsau.Count / $group) + 1
$Name = $lsau | select -First $group_size -Skip ($group_size*$n) | % { $_.Name }
$Name = $lsau | Select-Object -First $group_size -Skip ($group_size*$n) | ForEach-Object { $_.Name }

Write-Host ($Name -join ' ')
Write-Host ('-'*80)
Expand Down Expand Up @@ -82,7 +82,7 @@ $options = [ordered]@{

$global:info = updateall -Name $Name -Options $Options

$au_errors = $global:info | ? { $_.Error } | select -ExpandProperty Error
$au_errors = $global:info | Where-Object { $_.Error } | Select-Object -ExpandProperty Error

if ($ThrowOnErrors -and $au_errors.Count -gt 0) {
throw 'Errors during update'
Expand Down

0 comments on commit a5659a3

Please sign in to comment.