Skip to content

Commit 1ee1481

Browse files
committed
Add files and script to produce chocolatey install package
1 parent 931defe commit 1ee1481

File tree

6 files changed

+114
-0
lines changed

6 files changed

+114
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,7 @@ Generated_Code #added for RIA/Silverlight projects
107107
_UpgradeReport_Files/
108108
Backup*/
109109
UpgradeLog*.XML
110+
111+
#Chocolatey Build Output
112+
ChocolateyPackage/PSReadLine/
113+
*.nupkg

ChocolateyPackage/PSReadline.nuspec

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<metadata>
4+
<id>PSReadline</id>
5+
<version></version>
6+
<authors>Jason Shirk</authors>
7+
<owners>Jason Shirk</owners>
8+
<projectUrl>https://github.com/lzybkr/PSReadLine</projectUrl>
9+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
10+
<licenseUrl>https://raw.github.com/lzybkr/PSReadLine/master/License.txt</licenseUrl>
11+
<summary>A bash inspired readline implementation for PowerShell</summary>
12+
<description>Once installed you will likely want to change your profile.ps1 to automatically load the PSReadLine module. Please refer to the project website for instructions. Note that to upgrade or uninstall you will likely need to close all instances of PowerShell and uninstall from cmd.exe.</description>
13+
<releaseNotes>https://raw.github.com/lzybkr/PSReadLine/master/Changes.txt</releaseNotes>
14+
<copyright></copyright>
15+
<tags>Powershell PS Script</tags>
16+
<dependencies>
17+
</dependencies>
18+
</metadata>
19+
<files>
20+
<file src="tools\**" target="tools" />
21+
<file src="PSReadline\**" target="PSReadline" />
22+
</files>
23+
</package>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
$packageName = "PSReadLine"
2+
3+
try {
4+
$source = Resolve-Path ($PSScriptRoot + "\..\$packageName\")
5+
$dest64 = "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\"
6+
$dest32 = "C:\Windows\sysWOW64\WindowsPowerShell\v1.0\Modules\"
7+
8+
$command = ""
9+
10+
if (Test-Path -PathType Container $dest64) {
11+
$command = $command + "Copy-Item -Force -Recurse `'$source`' `'$dest64`';"
12+
}
13+
14+
if (Test-Path -PathType Container $dest32) {
15+
$command = $command + "Copy-Item -Force -Recurse `'$source`' `'$dest32`'"
16+
}
17+
18+
Start-ChocolateyProcessAsAdmin $command
19+
20+
Write-ChocolateySuccess $packageName
21+
} catch {
22+
Write-ChocolateyFailure $packageName $($_.Exception.Message)
23+
throw
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$packageName = "PSReadLine"
2+
3+
try {
4+
$dir64 = "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\$packageName\"
5+
$dir32 = "C:\Windows\sysWOW64\WindowsPowerShell\v1.0\Modules\$packageName\"
6+
7+
$command = ""
8+
9+
if (Test-Path -PathType Container $dir64) {
10+
$command = $command + "Remove-Item -Recurse -Force `'$dir64`';"
11+
}
12+
13+
if (Test-Path -PathType Container $dir32) {
14+
$command = $command + "Remove-Item -Recurse -Force `'$dir32`'"
15+
}
16+
17+
Start-ChocolateyProcessAsAdmin $command
18+
19+
Write-ChocolateySuccess $packageName
20+
} catch {
21+
Write-ChocolateyFailure $packageName $($_.Exception.Message)
22+
throw
23+
}

MakeRelease.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ $version = (Get-ChildItem $targetDir\PSReadline.dll).VersionInfo.FileVersion
4444

4545
& $PSScriptRoot\Update-ModuleManifest.ps1 $targetDir\PSReadline.psd1 $version
4646

47+
#make sure chocolatey is installed and in the path
48+
if (gcm cpack -ea Ignore)
49+
{
50+
$chocolateyDir = "$PSScriptRoot\ChocolateyPackage"
51+
52+
if (Test-Path $chocolateyDir\PSReadline)
53+
{
54+
rm -re $chocolateyDir\PSReadline
55+
}
56+
57+
& $PSScriptRoot\Update-NuspecVersion.ps1 "$chocolateyDir\PSReadline.nuspec" $version
58+
59+
cp -r $targetDir $chocolateyDir\PSReadline
60+
61+
cpack "$chocolateyDir\PSReadline.nuspec"
62+
}
4763

4864
del $PSScriptRoot\PSReadline.zip -ea Ignore
4965
[System.IO.Compression.ZipFile]::CreateFromDirectory($targetDir, "$PSScriptRoot\PSReadline.zip")

Update-NuspecVersion.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
param (
2+
[Parameter(Mandatory=$TRUE)]
3+
[String] $FilePath,
4+
[Parameter(Mandatory=$TRUE)]
5+
[String] $Version
6+
)
7+
8+
if ((Test-Path $FilePath -PathType Leaf) -ne $TRUE) {
9+
Write-Error -Message ($FilePath + ' not found.') -Category InvalidArgument;
10+
exit 1;
11+
}
12+
13+
#normalize path
14+
$FilePath = (Resolve-Path $FilePath).Path;
15+
16+
$nuspecConfig = [xml] (Get-Content $FilePath);
17+
$nuspecConfig.DocumentElement.metadata.version = $Version;
18+
19+
if (!$?) {
20+
Write-Error -Message "Unable to perform update.";
21+
exit 1;
22+
}
23+
24+
$nuspecConfig.Save($FilePath);

0 commit comments

Comments
 (0)