From ddfbd65ae0b6aed3886b1b0071bb31bd13d8c359 Mon Sep 17 00:00:00 2001 From: Thomas Clark Date: Sun, 5 May 2024 07:30:49 +0100 Subject: [PATCH] refactor: migrate from au to chocolatey-au https://github.com/chocolatey-community/chocolatey-packages-template/pull/47 --- .appveyor.yml | 36 +- README.md | 54 +- automatic/README.md | 26 +- automatic/_output/README.md | 7 - ketarin/README.md | 7 - ketarin/_KetarinChocolateyTemplate.xml | 108 - ops/README.md | 9 - ops/ketarinupdate.cmd | 29 - setup/KetarinSettings.xml | 2646 ------------------------ setup/README.md | 26 +- setup/au_setup.ps1 | 22 +- setup/ketarin_setup.ps1 | 11 - test_all.ps1 | 54 +- update_all.ps1 | 130 +- 14 files changed, 182 insertions(+), 2983 deletions(-) delete mode 100644 automatic/_output/README.md delete mode 100644 ketarin/README.md delete mode 100644 ketarin/_KetarinChocolateyTemplate.xml delete mode 100644 ops/README.md delete mode 100644 ops/ketarinupdate.cmd delete mode 100644 setup/KetarinSettings.xml delete mode 100644 setup/ketarin_setup.ps1 diff --git a/.appveyor.yml b/.appveyor.yml index bb5547ccc8..2baff3b673 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,13 +1,11 @@ -# AU template: https://github.com/majkinetor/au-packages-template - version: '{build}' max_jobs: 1 -image: WMF 5 +image: Visual Studio 2022 # History plugin requires complete log clone_depth: 5 branches: only: - - master + - master # build: # verbosity: minimal @@ -44,16 +42,32 @@ environment: secure: U6n1Xfo0lhitmK8PZNHK3q3Dxhz/akc1Im1iotq0JUHgRQ6vao19btvE+lAz3Mmi # https://ci.appveyor.com/tools/encrypt init: -- git config --global user.email "tnc1997@virginmedia.com" -- git config --global user.name "tnc1997" +- git config --global user.email "chocolatey@realdimensions.net" +- git config --global user.name "Chocolatey-AU" - git config --global core.safecrlf false install: +- ps: | + $chocoVersion = $Env:choco_version + if (!(Test-Path "$env:nupkg_cache_path")) { mkdir -Force "$env:nupkg_cache_path" } + @{ + 'chocolatey' = $chocoVersion +# Uncomment and input the version if you are using any of these in AU scripts +# 'wormies-au-helpers' = 'VERSION_HERE' +# 'chocolatey-core.extension' = 'VERSION_HERE' +# 'autohotkey.install' = 'VERSION_HERE' + }.GetEnumerator() | % { + if (!(Test-Path "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg")) { rm "${env:nupkg_cache_path}\$($_.Key).*.nupkg" ; iwr "https://chocolatey.org/api/v2/package/$($_.Key)/$($_.Value)" -OutFile "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg" } + if ($_.Key -eq 'chocolatey') { choco upgrade $_.Key --version $_.Value --source ${env:nupkg_cache_path} --allow-downgrade --pre } + else { choco install $_.Key --version $_.Value --source ${env:nupkg_cache_path} --ignore-dependencies } + } + rm "$env:ChocolateyInstall\logs\*.log" - ps: 'Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version' - ps: $PSVersionTable - git --version +- choco --version - ps: | - git clone -q https://github.com/majkinetor/au.git $Env:TEMP/au + 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: | @@ -80,7 +94,10 @@ build_script: Write-Host ("{0}`n{1}`n" -f ('-'*60), "PACKAGE: $package") $package_dir = ls -recurse | ? { $_.Name -eq "$package.nuspec"} | select -First 1 | % Directory if (!$package_dir) { Write-Warning "Can't find package '$package'"; continue } - pushd $package_dir; choco pack; Push-Package; popd + pushd $package_dir + if (Test-Path update.ps1 -ea 0) { ./update.ps1 } + choco pack; Push-Package; + popd } return } @@ -102,5 +119,8 @@ notifications: on_build_failure: true on_build_status_changed: true +cache: +- '%nupkg_cache_path% -> .appveyor.yml' + # on_finish: # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/README.md b/README.md index 999483aba5..54a731a5aa 100644 --- a/README.md +++ b/README.md @@ -7,51 +7,28 @@ This contains Chocolatey packages, both manually and automatically maintained. -You can choose to use one or both of the different methods currently supported in the Chocolatey community for automatic packaging. They are AU (Automatic Updater) and Ketarin/ChocolateyPackageUpdater. - ### Folder Structure -* automatic - where automatic packaging and packages are kept. These are packages that are automatically maintained using either [AU](https://chocolatey.org/packages/au) or [Ketarin](https://chocolatey.org/packages/ketarin)/[ChocolateyPackageUpdater](https://chocolatey.org/packages/chocolateypackageupdater) combo. +* automatic - where automatic packaging and packages are kept. These are packages that are automatically maintained using [chocolatey-au](https://github.com/chocolatey-community/chocolatey-au). * icons - Where you keep icon files for the packages. This is done to reduce issues when packages themselves move around. -* ketarin - where ketarin jobs (aka applications or searches) exported as XML are kept. This is done to allow ease of contribution. * manual - where packages that are not automatic are kept. -* ops - scripts, jobs, and other items for ensuring automatic packaging. -* setup - items for prepping the system to ensure for auto packaging. - -For setting up your own automatic package repository, please see [Automatic Packaging](https://chocolatey.org/docs/automatic-packages) ### Requirements * Chocolatey (choco.exe) -#### Ketarin / ChocolateyPackageUpdater - -* PowerShell v2+ -* [Ketarin](https://chocolatey.org/packages/ketarin) -* [Chocolatey Package Updater](https://chocolatey.org/packages/chocolateypackageupdater) -* A Windows box somewhere - to run the updater on - appveyor can't work until the import of the settings can be automated - #### AU * PowerShell v5+. -* The [AU module](https://chocolatey.org/packages/au). - -For daily operations check out the AU packages [template README](https://github.com/majkinetor/au-packages-template/blob/master/README.md). +* The [chocolatey-au module](https://github.com/chocolatey-community/chocolatey-au). ### Getting started -1. Fork this repository and rename it to `chocolatey-packages` (on GitHub - go into Settings, Repository name and rename). +1. Click "Use this template" then "Create a new repository". Name it `chocolatey-packages` 1. Clone the repository locally. -1. Head into the `setup` folder and perform the proper steps for your choice of setup (or both if you plan to use both methods). +1. Head into the `setup` folder and perform the steps in the README there. 1. Edit this README. Update the badges at the top. - -### Recommendation on Auto Packaging - -AU provides more in the process of being completely automated, sending emails when things go wrong, and providing a nice report at the end. It doesn't have a bolt-on feeling to it that you see with Ketarin / ChocolateyPackageUdater, however the one thing it does lack in comparison is no visual feedback to seeing how searches for installers may be found. Other than that, it provides errors when things go wrong, where Ketarin doesn't consider anything that happens during "before run"/"post run updates" (where chocopkgup and checksumming occur) to be an error, even if those scripts error. - -So for best visibility, enjoying the ease of using AppVeyor, and for a nice report of results, we recommend AU over Ketarin. You also don't need to deal with templates as AU works directly with the xml/ps1 files to do replacement. - ### Adapting your current source repository to this source repository template You want to bring in all of your packages into the proper folders. We suggest using some sort of diffing tool to look at the differences between your current solution and this solution and then making adjustments to it. Pay special attention to the setup folder. @@ -59,31 +36,8 @@ You want to bring in all of your packages into the proper folders. We suggest us 1. Bring over the following files to your package source repository: * `automatic\README.md` * `icons\README.md` - * `ketarin\README.md` - * `ketarin\_KetarinChocolateyTemplate.xml` * `manual\README.md` - * `ops\*.*` * `setup\*.*` * `.appveyor.yml` 1. Inspect the following file and add the differences: * `.gitignore` - -### Use Both Methodologies - -The way this source repository is designed, you can use both AU and Ketarin/ChocolateyPackageUpdater together. This is especially helpful when migrating existing packages from one methodology to the other. - -### Migrating existing Ketarin packages to AU - -1. Add an update.ps1 to the package folder and determine how to update the package using [AU's instructions](https://github.com/majkinetor/au#creating-the-package-updater-script). -1. Remove the ketarin.xml file from the ketarin folder. -1. Ensure you also remove the package job from Ketarin itself as it doesn't automatically remove. - -### Special Notes - -#### Ketarin - -* In `Settings -> Global variables` the variable `autoPackagesFolder` is used to determine where your automatic packages are. It doesn't matter what `chocopkgup` is using, this folder is passed through. Ensure this is set appropriately. -* In `Settings -> Global variables` the variable `saveDir` is used to determine where to save the downloaded files from Ketarin. Please ensure the folder exists. -* In `Settings -> Global variables` the variable `nopush` is set to `--nopush`, which allows checksum calculations to occur and then a custom script will push the files. -* In `Settings -> Global variables` the variable `cscript` is set to `2`, which means calculate checksums, rebuild, and push the packages. If you set this to `1` it will do everything except push the packages. Setting this to `1` is how you disable package pushing. -* In `Settings -> Global variables` the variable `checksum` is set to `{checksum}`. Do not change this, this is how the post update script replaces the literal value `{checksum}`. The same goes for `checksumx64`, `packageGuid`, and `url64`. diff --git a/automatic/README.md b/automatic/README.md index 0facd1c147..a32c046579 100644 --- a/automatic/README.md +++ b/automatic/README.md @@ -1,27 +1,11 @@ ## Automatic Folder -This is where you put your Chocolatey packages that are automatically packaged up by either [AU](https://chocolatey.org/packages/au) or [Ketarin](https://chocolatey.org/packages/ketarin)/[ChocolateyPackageUpdater](https://chocolatey.org/packages/chocolateypackageupdater). +This is where you put your Chocolatey packages that are automatically packaged up by [chocolatey-au](https://github.com/chocolatey-community/chocolatey-au). -### Ketarin / ChocolateyPackageUpdater (chocopkgup) +Execute `update_all.ps1` in the repository root to run [chocolatey-au](https://github.com/chocolatey-community/chocolatey-au) updater with default options. -You want to drop the actual Ketarin files (job file exports) in the top-level ketarin folder to keep them separate from the packages themselves. +To fully setup all the features ensure you perform the steps in the [setup/README.md](https://github.com/chocolatey/chocolatey-packages-template/blob/master/setup/README.md) -The following packages implement this strategy of auto updates: - -* 1password -* git.install - -There is also an _output folder where the automatic packaging files with tokens to do token replacment and output package files with actual values in this folder. This folder is necessary for chocopkgup to do its work. You can decide whether to commit this set of folders or not. We recommend committing it as it makes it easier to do one off fixes and contributors to submit fixes for a package. - -### Automatic Updater (AU) - -AU works with packages without automatic package tokens necessary. So you can treat the packages as normal. - -Execute `update_all.ps1` in the repository root to run [AU](https://chocolatey.org/packages/au) updater with default options. - -To fully setup all the features ensure you perform the steps in the [setup/README.md](https://github.com/chocolatey/chocolatey-packages-template/blob/master/setup/README.md#automatic-updater-au) - -To get the packages that implement AU updater run `Get-AUPackages` or `lsau` in this directory. - -**NOTE:** Ensure when you are creating packages for AU, you don't use `--auto` as the packaging files should be normal packages. AU doesn't need the tokens to do replacement. +To get the packages that implement chocolatey-au updater run `Get-AUPackages` or `lsau` in this directory. +**NOTE:** Ensure when you are creating packages for chocolatey-au, you don't use `--auto` as the packaging files should be normal packages. chocolatey-au doesn't need the tokens to do replacement. diff --git a/automatic/_output/README.md b/automatic/_output/README.md deleted file mode 100644 index f38018c5fc..0000000000 --- a/automatic/_output/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Output Folder - -When using Ketarin / Chocolatey Package Updater (chocopkgup) combo for keeping packages up to date, this folder will contain the output of generating those packages. - -This is the folder where chocopkgup will point to when configured to use the automatic folder (the parent folder of this) as the PackagesFolder. - -You will want to configure chocopkgup (chocopkgup.exe.config file in the package folder) to point to this directory. diff --git a/ketarin/README.md b/ketarin/README.md deleted file mode 100644 index aa9f69eeb7..0000000000 --- a/ketarin/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Ketarin Jobs - -* Ensure you perform the steps in `setup/README.md`. - -This is where the ketarin xml job exports go. This allows it to be easier to contribute when Ketarin jobs are available for exporting. - -This is also the folder that ops/ketarinupdate.cmd is using to import all of the jobs into Ketarin silently, so that things stay updated on a server running this. diff --git a/ketarin/_KetarinChocolateyTemplate.xml b/ketarin/_KetarinChocolateyTemplate.xml deleted file mode 100644 index c0929e2a5a..0000000000 --- a/ketarin/_KetarinChocolateyTemplate.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - chocolatey command line - - 0 - - false - Default - - false - - - None - true - false - false - - - - - - version - - - - false - RegularExpression - Last program version.*?([\d\.]+) - - version - - - - - - url - - - - false - Textual - - {getUrl} - url - - - - - - getUrl - - - - false - RegularExpression - [^ "'<>\*]+\.exe - - getUrl - - - - - - url64 - - - - false - Textual - - {getUrl64} - url64 - - - - - - getUrl64 - - - - false - RegularExpression - [^ "'<>\*]+\.exe - - getUrl64 - - - - - - - Batch - Batch - - FixedUrl - - true - true - - - {saveDir}\{appname}_{version}.{url:ext} - {url} - - - diff --git a/ops/README.md b/ops/README.md deleted file mode 100644 index e4f4149af2..0000000000 --- a/ops/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## Operations - -### Ketarin/ChocolateyPackageUpdater Ops - -* Use ketarinupdate.cmd or another file to set up a scheduled task for daily, hourly, or whatever schedule you best feel will work appropriately. - -### AutomaticUpdater - -Nothing to do here, jobs run automatically by AppVeyor on commit and on a schedule that you've set up in AppVeyor. diff --git a/ops/ketarinupdate.cmd b/ops/ketarinupdate.cmd deleted file mode 100644 index a9e168ff90..0000000000 --- a/ops/ketarinupdate.cmd +++ /dev/null @@ -1,29 +0,0 @@ -@echo off - -SET DIR=%~dp0% - -For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b) -For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b) - -echo Updating the github repo first -pushd %DIR% -call git add --all :/ -call git commit -m "updates prior to automatic run for %mydate%_%mytime%" -::call git reset --hard HEAD -call git fetch && git rebase origin/master -call git push origin master -popd - -:: /database="%DIR%\jobs.db" - -::import all the files -FOR /f "tokens=*" %%F IN ('dir %DIR%..\ /b *.ketarin.xml') DO ( - call ketarin.exe /import="%DIR%..\%%F" - TIMEOUT /T 2 -) - -Echo Wait for all of those to finish importing... -TIMEOUT /T 15 - -echo Calling ketarin now the the repo has been updated -call "Ketarin.exe" /silent /notify /log=C:\ProgramData\chocolateypackageupdater\ketarin.%mydate%_%mytime%.log diff --git a/setup/KetarinSettings.xml b/setup/KetarinSettings.xml deleted file mode 100644 index 4424a3c32c..0000000000 --- a/setup/KetarinSettings.xml +++ /dev/null @@ -1,2646 +0,0 @@ - - - - - - - AuthorGuid - - - System.String:{75a093b7-da5f-493a-b8f0-22c278f874c1} - - - - - LastUpdateCheck - - - AAEAAAD/////AQAAAAAAAAAEAQAAAA9TeXN0ZW0uRGF0ZVRpbWUCAAAABXRpY2tzCGRhdGVEYXRhAAAJEOGhVC47mtII4aFULjua0ogL - - - - - MainForm/Size - - - System.Drawing.Size:1046,476 - - - - - MainForm/Location - - - System.Drawing.Point:203,77 - - - - - MainForm/WindowState - - - System.Int32:0 - - - - - olvJobs/Application:Visibility - - - System.Boolean:True - - - - - olvJobs/Application:Width - - - System.Int32:126 - - - - - olvJobs/Application:LastDisplayIndex - - - System.Int32:0 - - - - - olvJobs/Last updated:Visibility - - - System.Boolean:True - - - - - olvJobs/Last updated:Width - - - System.Int32:96 - - - - - olvJobs/Last updated:LastDisplayIndex - - - System.Int32:2 - - - - - olvJobs/Progress:Visibility - - - System.Boolean:True - - - - - olvJobs/Progress:Width - - - System.Int32:100 - - - - - olvJobs/Progress:LastDisplayIndex - - - System.Int32:4 - - - - - olvJobs/Target:Visibility - - - System.Boolean:True - - - - - olvJobs/Target:Width - - - System.Int32:0 - - - - - olvJobs/Target:LastDisplayIndex - - - System.Int32:5 - - - - - olvJobs/Category:Visibility - - - System.Boolean:True - - - - - olvJobs/Category:Width - - - System.Int32:80 - - - - - olvJobs/Category:LastDisplayIndex - - - System.Int32:15 - - - - - olvJobs/Status:Visibility - - - System.Boolean:True - - - - - olvJobs/Status:Width - - - System.Int32:79 - - - - - olvJobs/Status:LastDisplayIndex - - - System.Int32:6 - - - - - olvJobs/LastSortColumn - - - System.String:Application - - - - - olvJobs/LastSortOrder - - - System.Int32:1 - - - - - Ketarin/ShowGroups - - - System.Boolean:True - - - - - Ketarin/ShowStatusBar - - - System.Boolean:False - - - - - Ketarin/ShowLog - - - System.Boolean:True - - - - - Ketarin/AutoScroll - - - System.Boolean:True - - - - - PreUpdateCommand - - - System.String:REM https://chocolatey.org/packages/chocolateypackageupdater -chocopkgup {nopush} {force} --pf="{autoPackagesFolder}" --packagename="{appname}" --version="{version}" --url="{preupdate-url}" --urlx64="{url64}" --checksum="{checksum}" --c64="{checksumx64}" --debug - - - - - PreUpdateCommandType - - - System.String:Batch - - - - - CustomColumns - - - System.String:<?xml version="1.0" encoding="utf-16"?> -<dictionary> - <item> - <key> - <string>version</string> - </key> - <value> - <string>{version}</string> - </value> - </item> - <item> - <key> - <string>filesize</string> - </key> - <value> - <string>{filesize:formatfilesize}</string> - </value> - </item> - <item> - <key> - <string>host</string> - </key> - <value> - <string>{url:regex:(?&lt;=//)([\w-]+\.)*(?=[\w-]+\.[\w-]+(?=/))}</string> - </value> - </item> - <item> - <key> - <string>fileDate</string> - </key> - <value> - <string>{f:yyyy}-{f:MM}-{f:dd} {f:HH}:{f:mm}</string> - </value> - </item> - <item> - <key> - <string>fixedUrl</string> - </key> - <value> - <string>{property:FixedDownloadUrl:regex:(?&lt;=//).*}</string> - </value> - </item> - <item> - <key> - <string>referer</string> - </key> - <value> - <string>{property:HttpReferer}</string> - </value> - </item> - <item> - <key> - <string>user-agent</string> - </key> - <value> - <string>{property:UserAgent}</string> - </value> - </item> - <item> - <key> - <string>delPrevFile</string> - </key> - <value> - <string>{property:DeletePreviousFile:multireplace:,:True,False:X,}</string> - </value> - </item> - <item> - <key> - <string>varChgInd</string> - </key> - <value> - <string>{property:VariableChangeIndicator}</string> - </value> - </item> - <item> - <key> - <string>cscript</string> - </key> - <value> - <string>{cscript}</string> - </value> - </item> - <item> - <key> - <string>enabled</string> - </key> - <value> - <string>{property:Enabled}</string> - </value> - </item> - <item> - <key> - <string>nopush</string> - </key> - <value> - <string>{nopush}</string> - </value> - </item> - <item> - <key> - <string>domain</string> - </key> - <value> - <string>{url:regex:(?&lt;=//[\w-]+\.)*[\w-]+\.[\w-]+(?=/)}</string> - </value> - </item> - <item> - <key> - <string>url64</string> - </key> - <value> - <string>{url64}</string> - </value> - </item> - <item> - <key> - <string>hashInternal</string> - </key> - <value> - <string>{hash}</string> - </value> - </item> - <item> - <key> - <string>hashType</string> - </key> - <value> - <string>{property:HashType:replace:None:}</string> - </value> - </item> - <item> - <key> - <string>proto</string> - </key> - <value> - <string>{url:regex:.*?(?=.//)}</string> - </value> - </item> - <item> - <key> - <string>bytes</string> - </key> - <value> - <string>{filesize}</string> - </value> - </item> - <item> - <key> - <string>hashExternal</string> - </key> - <value> - <string>{checksum}</string> - </value> - </item> - <item> - <key> - <string>checksum64</string> - </key> - <value> - <string>{checksumx64}</string> - </value> - </item> -</dictionary> - - - - - CustomColumn - - - - - - - - CustomColumn2 - - - - - - - - UpdateAtStartup - - - System.Boolean:False - - - - - AvoidFileHippoBeta - - - System.Boolean:True - - - - - ConnectionTimeout - - - AAEAAAD/////AQAAAAAAAAAEAQAAAA5TeXN0ZW0uRGVjaW1hbAQAAAAFZmxhZ3MCaGkCbG8DbWlkAAAAAAgICAgAAAAAAAAAADwAAAAAAAAACw== - - - - - ThreadCount - - - System.Int32:4 - - - - - RetryCount - - - System.Int32:2 - - - - - UpdateOnlineDatabase - - - System.Boolean:False - - - - - MinimizeToTray - - - System.Boolean:True - - - - - CreateDatabaseBackups - - - System.Boolean:True - - - - - OpenWebsiteOnDoubleClick - - - System.Boolean:False - - - - - ProxyPort - - - AAEAAAD/////AQAAAAAAAAAEAQAAAA5TeXN0ZW0uRGVjaW1hbAQAAAAFZmxhZ3MCaGkCbG8DbWlkAAAAAAgICAgAAAAAAAAAALgiAAAAAAAACw== - - - - - ProxyServer - - - System.String: - - - - - ProxyUser - - - System.String: - - - - - ProxyPassword - - - System.String: - - - - - olvJobs/Version:Visibility - - - System.Boolean:True - - - - - olvJobs/Version:Width - - - System.Int32:99 - - - - - olvJobs/Version:LastDisplayIndex - - - System.Int32:1 - - - - - SetPlaceholderDialog/Size - - - System.Drawing.Size:699,157 - - - - - SetPlaceholderDialog/Location - - - System.Drawing.Point:0,0 - - - - - SetPlaceholderDialog/WindowState - - - System.Int32:0 - - - - - EditVariablesDialog/Size - - - System.Drawing.Size:1004,492 - - - - - EditVariablesDialog/Location - - - System.Drawing.Point:66,65 - - - - - EditVariablesDialog/WindowState - - - System.Int32:0 - - - - - ApplicationJobDialog/Size - - - System.Drawing.Size:507,507 - - - - - ApplicationJobDialog/Location - - - System.Drawing.Point:173,12 - - - - - ApplicationJobDialog/WindowState - - - System.Int32:0 - - - - - LogDialog/Size - - - System.Drawing.Size:1143,423 - - - - - LogDialog/Location - - - System.Drawing.Point:116,360 - - - - - LogDialog/WindowState - - - System.Int32:0 - - - - - ErrorsDialog/Size - - - System.Drawing.Size:1096,965 - - - - - olvErrors/Application:Visibility - - - System.Boolean:True - - - - - olvErrors/Application:Width - - - System.Int32:98 - - - - - olvErrors/Application:LastDisplayIndex - - - System.Int32:-1 - - - - - olvErrors/Error:Visibility - - - System.Boolean:True - - - - - olvErrors/Error:Width - - - System.Int32:952 - - - - - olvErrors/Error:LastDisplayIndex - - - System.Int32:-1 - - - - - olvErrors/LastSortColumn - - - System.String:Application - - - - - olvErrors/LastSortOrder - - - System.Int32:1 - - - - - ProgressDialog/Size - - - System.Drawing.Size:302,112 - - - - - Hotkey: OpenWebsite - - - System.String: - - - - - Hotkey: Edit - - - System.String: - - - - - Hotkey: Update - - - System.String: - - - - - Hotkey: ForceDownload - - - System.String: - - - - - Hotkey: InstallSelected - - - System.String: - - - - - Hotkey: OpenFile - - - System.String: - - - - - Hotkey: OpenFolder - - - System.String: - - - - - Hotkey: CheckUpdate - - - System.String: - - - - - Hotkey: UpdateAndInstall - - - System.String: - - - - - InstallingApplicationsDialog/Size - - - System.Drawing.Size:406,250 - - - - - InstallingApplicationsDialog/Location - - - System.Drawing.Point:164,724 - - - - - InstallingApplicationsDialog/WindowState - - - System.Int32:0 - - - - - olvLog/Time:Visibility - - - System.Boolean:True - - - - - olvLog/Time:Width - - - System.Int32:55 - - - - - olvLog/Time:LastDisplayIndex - - - System.Int32:-1 - - - - - olvLog/Message:Visibility - - - System.Boolean:True - - - - - olvLog/Message:Width - - - System.Int32:310 - - - - - olvLog/Message:LastDisplayIndex - - - System.Int32:-1 - - - - - olvLog/LastSortColumn - - - System.String:Time - - - - - olvLog/LastSortOrder - - - System.Int32:0 - - - - - InstallingApplicationsDialog/Expanded - - - System.Boolean:True - - - - - DefaultCommand - - - System.String://////////////////////////////////////////////////////////////////////////////////////// -/// version ? Lots of changes -/// -/// Changelog: -/// - Allow for non-versioned output folder paths -/// - Logging! -/// - Call choco directly, expected to be at the default location. -/// -// REQUIRES: -// global vars: saveDir=corresponds to download location of installer file -// app vars: nopush, checksum64file=corresponds to 64 bit install file -// file vars: same as specified by chocopkgup - -// get package variable 'cscript' -string varCScript = ""; -varCScript = app.Variables.ReplaceAllInString("{cscript}").Trim(); - -Ketarin.Forms.LogDialog.Log(app,"cscript='" + varCScript + "'"); -Ketarin.Forms.LogDialog.Log(app,"If cscript is set to 1, checksums will be calculated but the package won't be pushed."); -Ketarin.Forms.LogDialog.Log(app,"If cscript is set to 2, checksums will be calculated AND the package will be pushed."); - -// determine whether we run this by checking cscript exists AND is 1 or 2 -if ((varCScript == "1") || (varCScript == "2")) -{ - // ketarin variables we pass for this script to use - string varAppname = app.Variables.ReplaceAllInString("{appname}"); - string varVersion = app.Variables.ReplaceAllInString("{version}"); - string varChocoPkgOutput = System.IO.Path.Combine(app.Variables.ReplaceAllInString("{autoPackagesFolder}"), "_output"); - string varChecksum = app.Variables.ReplaceAllInString("{checksum}"); - string varChecksumx64 = app.Variables.ReplaceAllInString("{checksumx64}"); - string varChecksum64File = app.Variables.ReplaceAllInString("{url64}"); - string varSaveDir = app.Variables.ReplaceAllInString("{saveDir}"); - - // custom variables used in this script - // equivalent to ketarin variable "{file}" - string savePath = app.PreviousLocation; - string pkgPath = System.IO.Path.Combine(varChocoPkgOutput, varAppname, varVersion); - if (!System.IO.Directory.Exists(pkgPath)) - { - pkgPath = System.IO.Path.Combine(varChocoPkgOutput, varAppname); - Ketarin.Forms.LogDialog.Log(app,"Using the output folder without a version"); - } - - Ketarin.Forms.LogDialog.Log(app, "Using package file at " + pkgPath); - - string fileNameNuspec = System.String.Concat(varAppname, ".nuspec"); - string fileUriNuspec = System.IO.Path.Combine(pkgPath, fileNameNuspec); - string fileNameNupkg = System.String.Concat(varAppname, ".", varVersion, ".nupkg"); - string fileUriNupkg = System.IO.Path.Combine(pkgPath, fileNameNupkg); - - //MessageBox.Show("pkgPath=" + pkgPath + System.Environment.NewLine - // + "savePath=" + savePath); - - // do not re-push package if package already created - System.DateTime today = System.DateTime.Today; - System.DateTime pkgCreateDate = System.IO.File.GetCreationTime(pkgPath); - if (today > pkgCreateDate) - { - return; - } - - // calculate SHA256 from {url} Note we are leveraging ketarin's downloaded copy - System.IO.FileStream fileSha = new System.IO.FileStream(savePath, System.IO.FileMode.Open); - System.Security.Cryptography.SHA256 sha256 = new System.Security.Cryptography.SHA256Managed(); - byte[] retValSha = sha256.ComputeHash(fileSha); - fileSha.Close(); - - // build string from byte value - System.Text.StringBuilder sbSha = new System.Text.StringBuilder(); - for (int i = 0; i < retValSha.Length; i++) - { - sbSha.Append(retValSha[i].ToString("x2")); - } - - // find $pkgPath -iname "*.nuspec" -o -iname "*.ps1" -exec sed -i 's/'$sbSha'/{checksum}/g' '{}' \; - string replaceChecksum = sbSha.ToString(); - Ketarin.Forms.LogDialog.Log(app, "Checksum for url is " + replaceChecksum); - //MessageBox.Show(replaceChecksum); - System.Collections.Generic.List<string> pkgFileList = new System.Collections.Generic.List<string>(System.IO.Directory.GetFiles(pkgPath, "*.ps1", System.IO.SearchOption.AllDirectories)); - string[] filesNuspec = System.IO.Directory.GetFiles(pkgPath, "*.nuspec", System.IO.SearchOption.AllDirectories); - pkgFileList.AddRange(filesNuspec); - string[] files = pkgFileList.ToArray(); - foreach (string file in files) - { - try - { - string contents = System.IO.File.ReadAllText(file); - //MessageBox.Show(contents); - contents = contents.Replace("{checksum}", replaceChecksum); - //MessageBox.Show(contents); - // Make files writable - // File.SetAttributes(file, FileAttributes.Normal); - System.IO.File.WriteAllText(file, contents); - } - catch (System.Exception ex) - { - System.Console.WriteLine(ex.Message); - } - } - - // Get Checksum for 64bit file if url64 exists - if (varChecksum64File != "{url64}" && varChecksum64File != "\"\"" && !System.String.IsNullOrEmpty(varChecksum64File)) - { - // TODO: verify and validate URI checksum64file points to a downloadable file - - // string varChecksum64basefile = app.Variables.ReplaceAllInString("{url64:basefile}"); - string varChecksum64ext = app.Variables.ReplaceAllInString("{url64:ext}"); - string saveFileName64 = System.String.Concat(varAppname, "_64_", varVersion, ".", varChecksum64ext); - string savePath64 = System.IO.Path.Combine(varSaveDir, saveFileName64); - // we must download the file to calculate checksum ... may as well save it - Ketarin.Forms.LogDialog.Log(app, "Downloading '" + varChecksum64File + "' to '" + savePath64 + "'."); - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.DownloadFile(varChecksum64File, savePath64); - - // calculate SHA256 from file of url pointed to by 'checksum64file' - System.IO.FileStream file64Sha = new System.IO.FileStream(savePath64, System.IO.FileMode.Open); - System.Security.Cryptography.SHA256 sha256_64 = new System.Security.Cryptography.SHA256Managed(); - byte[] retVal64Sha = sha256_64.ComputeHash(file64Sha); - file64Sha.Close(); - - // build string from byte value - System.Text.StringBuilder sb64Sha = new System.Text.StringBuilder(); - for (int i = 0; i < retVal64Sha.Length; i++) - { - sb64Sha.Append(retVal64Sha[i].ToString("x2")); - } - - // find $pkgPath -iname "*.nuspec" -o -iname "*.ps1" -exec sed -i 's/'$sb64Sha'/{checksumx64}/g' '{}' \; - // Note chocopkgup will strip 1 set of curly braces so {{checksum}} becomes {checksum} - string replace64Checksum = sb64Sha.ToString(); - Ketarin.Forms.LogDialog.Log(app, "Checksum for url64 is " + replace64Checksum); - foreach (string file in files) - { - try - { - string contents = System.IO.File.ReadAllText(file); - //MessageBox.Show(contents); - contents = contents.Replace("{checksumx64}", replace64Checksum); - //MessageBox.Show(contents); - System.IO.File.WriteAllText(file, contents); - } - catch (System.Exception ex) - { - System.Console.WriteLine(ex.Message); - } - } - } - - // delete existing nupkg made by chocopkgup; we leverage chocopkgup to create the structure/files in destination - Ketarin.Forms.LogDialog.Log(app, "Deleting the existing nupkg before repacking at " + fileUriNupkg); - System.Diagnostics.Process process1 = new System.Diagnostics.Process(); - System.Diagnostics.ProcessStartInfo proc1 = new System.Diagnostics.ProcessStartInfo(); - proc1.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - proc1.UseShellExecute = true; - proc1.WorkingDirectory = pkgPath; - proc1.FileName = "cmd.exe"; - proc1.Arguments = "/c " + "del /f " + fileUriNupkg; - process1.StartInfo = proc1; - process1.Start(); - process1.WaitForExit(30000); - - // create a new nupkg - Ketarin.Forms.LogDialog.Log(app, "Packing up the package, this time with checksums"); - System.Diagnostics.Process process2 = new System.Diagnostics.Process(); - System.Diagnostics.ProcessStartInfo proc2 = new System.Diagnostics.ProcessStartInfo(); - proc2.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized; - proc2.UseShellExecute = false; - proc2.WorkingDirectory = pkgPath; - proc2.FileName = "C:\\ProgramData\\Chocolatey\\bin\\choco.exe"; - proc2.Arguments = "pack " + fileUriNuspec; - proc2.RedirectStandardOutput = true; - proc2.RedirectStandardError = true; - proc2.CreateNoWindow = true; - process2.StartInfo = proc2; - process2.OutputDataReceived += (s, e) => { if (e != null) Ketarin.Forms.LogDialog.Log(app, e.Data); }; - process2.ErrorDataReceived += (s, e) => { if (e != null) Ketarin.Forms.LogDialog.Log(app, e.Data); }; - process2.EnableRaisingEvents = true; - process2.Start(); - process2.BeginErrorReadLine(); - process2.BeginOutputReadLine(); - process2.WaitForExit(30000); - - process2.StartInfo = proc2; - process2.Start(); - - // push the nupkg - if (varCScript == "2") - { - System.Threading.Thread.Sleep(2000); - System.Int32 exitCode = -1; - Ketarin.Forms.LogDialog.Log(app, "Pushing the package"); - System.Diagnostics.Process process3 = new System.Diagnostics.Process(); - System.Diagnostics.ProcessStartInfo proc3 = new System.Diagnostics.ProcessStartInfo(); - proc3.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized; - proc3.UseShellExecute = false; - proc3.WorkingDirectory = pkgPath; - proc3.FileName = "C:\\ProgramData\\Chocolatey\\bin\\choco.exe"; - // find nupkg in pkgPath - string[] pushPkg = System.IO.Directory.GetFiles(pkgPath, "*.nupkg", System.IO.SearchOption.TopDirectoryOnly); - - foreach (System.String file in pushPkg) - { - Ketarin.Forms.LogDialog.Log(app, "Pushing " + file + " to dot org"); - proc3.Arguments = "push " + file; - } - proc3.RedirectStandardOutput = true; - proc3.RedirectStandardError = true; - proc3.CreateNoWindow = true; - process3.StartInfo = proc3; - process3.OutputDataReceived += (s, e) => { if (e != null) Ketarin.Forms.LogDialog.Log(app, e.Data); }; - process3.ErrorDataReceived += (s, e) => { if (e != null) Ketarin.Forms.LogDialog.Log(app, e.Data); }; - process3.EnableRaisingEvents = true; - process3.Start(); - process3.BeginErrorReadLine(); - process3.BeginOutputReadLine(); - System.Boolean exited = process3.WaitForExit(120000); - if (exited) - { - exitCode = process3.ExitCode; - } - if (exitCode != 0) - { - throw new System.Exception("Push did not finish successfully. See the log for details."); - Ketarin.Forms.LogDialog.Log(app, "This is a failure. However Ketarin doesn't error on post updates."); - } - } -} - - - - - DefaultCommandType - - - System.String:CS - - - - - PostUpdateCommand - - - System.String: - - - - - PostUpdateCommandType - - - System.String:Batch - - - - - DefaultApplication - - - System.String:<?xml version="1.0" encoding="utf-8"?> -<Jobs> - <ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <WebsiteUrl /> - <UserAgent /> - <UserNotes /> - <LastFileSize>0</LastFileSize> - <LastFileDate xsi:nil="true" /> - <IgnoreFileInformation>false</IgnoreFileInformation> - <DownloadBeta>Default</DownloadBeta> - - <CheckForUpdatesOnly>false</CheckForUpdatesOnly> - <VariableChangeIndicator /> - <HashVariable /> - <HashType>None</HashType> - <CanBeShared>true</CanBeShared> - <ShareApplication>false</ShareApplication> - <ExclusiveDownload>false</ExclusiveDownload> - <HttpReferer /> - <SetupInstructions /> - <Variables> - <item> - <key> - <string>nopush</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>Textual</VariableType> - <Regex /> - <TextualContent>--nopush</TextualContent> - <Name>nopush</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>version</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>RegularExpression</VariableType> - <Regex>Last program version.*?([\d\.]+)</Regex> - <Url>x</Url> - <Name>version</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>url</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>Textual</VariableType> - <Regex /> - <TextualContent>{getUrl}</TextualContent> - <Name>url</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>url64</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>Textual</VariableType> - <Regex /> - <TextualContent>{getUrl64}</TextualContent> - <Name>url64</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>getUrl</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>RegularExpression</VariableType> - <Regex>[^ "'&lt;&gt;\*]+\.exe</Regex> - <Url>x</Url> - <Name>getUrl</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>getUrl64</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>RegularExpression</VariableType> - <Regex>[^ "'&lt;&gt;\*]+\.exe</Regex> - <Url>x</Url> - <Name>getUrl64</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>checksum</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>RegularExpression</VariableType> - <Regex>[A-Fa-f0-9]{32}</Regex> - <Url>md5</Url> - <TextualContent>{checksum}</TextualContent> - <Name>checksum</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>checksumx64</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>RegularExpression</VariableType> - <Regex>(?&lt;=ResponseUri: )[^\r\n]+</Regex> - <Url>{url64}</Url> - <TextualContent>{checksum}</TextualContent> - <Name>checksumx64</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>checksum64file</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>Textual</VariableType> - <Regex /> - <TextualContent>{url64}</TextualContent> - <Name>checksum64file</Name> - </UrlVariable> - </value> - </item> - <item> - <key> - <string>cscript</string> - </key> - <value> - <UrlVariable> - <RegexRightToLeft>false</RegexRightToLeft> - <VariableType>Textual</VariableType> - <Regex /> - <TextualContent>0</TextualContent> - <Name>cscript</Name> - </UrlVariable> - </value> - </item> - </Variables> - <ExecuteCommand /> - <ExecutePreCommand /> - <ExecuteCommandType>Batch</ExecuteCommandType> - <ExecutePreCommandType>Batch</ExecutePreCommandType> - <Category /> - <SourceType>FixedUrl</SourceType> - - <DeletePreviousFile>false</DeletePreviousFile> - <Enabled>true</Enabled> - <FileHippoId /> - - <TargetPath>{saveDir}\{appname}_{version}.{url:ext}</TargetPath> - <FixedDownloadUrl>{url}</FixedDownloadUrl> - <Name>x </Name> - </ApplicationJob> -</Jobs> - - - - - olvJobs/x:Visibility - - - System.Boolean:True - - - - - olvJobs/x:Width - - - System.Int32:89 - - - - - olvJobs/x:LastDisplayIndex - - - System.Int32:-1 - - - - - olvJobs/Filesize:Visibility - - - System.Boolean:True - - - - - olvJobs/Filesize:Width - - - System.Int32:68 - - - - - olvJobs/Filesize:LastDisplayIndex - - - System.Int32:5 - - - - - olvJobs/url:Visibility - - - System.Boolean:True - - - - - olvJobs/url:Width - - - System.Int32:147 - - - - - olvJobs/url:LastDisplayIndex - - - System.Int32:-1 - - - - - olvJobs/host:Visibility - - - System.Boolean:True - - - - - olvJobs/host:Width - - - System.Int32:120 - - - - - olvJobs/host:LastDisplayIndex - - - System.Int32:10 - - - - - olvJobs/packageGuid:Visibility - - - System.Boolean:True - - - - - olvJobs/packageGuid:Width - - - System.Int32:77 - - - - - olvJobs/packageGuid:LastDisplayIndex - - - System.Int32:14 - - - - - olvJobs/fileDate:Visibility - - - System.Boolean:True - - - - - olvJobs/fileDate:Width - - - System.Int32:97 - - - - - olvJobs/fileDate:LastDisplayIndex - - - System.Int32:3 - - - - - olvJobs/fixedUrl:Visibility - - - System.Boolean:True - - - - - olvJobs/fixedUrl:Width - - - System.Int32:96 - - - - - olvJobs/fixedUrl:LastDisplayIndex - - - System.Int32:9 - - - - - olvJobs/referer:Visibility - - - System.Boolean:True - - - - - olvJobs/referer:Width - - - System.Int32:65 - - - - - olvJobs/referer:LastDisplayIndex - - - System.Int32:13 - - - - - olvJobs/User-Agent:Visibility - - - System.Boolean:True - - - - - olvJobs/User-Agent:Width - - - System.Int32:80 - - - - - olvJobs/User-Agent:LastDisplayIndex - - - System.Int32:8 - - - - - olvJobs/DeletePreviousFile:Visibility - - - System.Boolean:True - - - - - olvJobs/DeletePreviousFile:Width - - - System.Int32:41 - - - - - olvJobs/DeletePreviousFile:LastDisplayIndex - - - System.Int32:20 - - - - - olvJobs/VariableChangeIndicator:Visibility - - - System.Boolean:True - - - - - olvJobs/VariableChangeIndicator:Width - - - System.Int32:55 - - - - - olvJobs/VariableChangeIndicator:LastDisplayIndex - - - System.Int32:15 - - - - - olvJobs/github:Visibility - - - System.Boolean:True - - - - - olvJobs/github:Width - - - System.Int32:64 - - - - - olvJobs/github:LastDisplayIndex - - - System.Int32:16 - - - - - olvJobs/kde:Visibility - - - System.Boolean:True - - - - - olvJobs/kde:Width - - - System.Int32:49 - - - - - olvJobs/kde:LastDisplayIndex - - - System.Int32:17 - - - - - olvJobs/cscript:Visibility - - - System.Boolean:True - - - - - olvJobs/cscript:Width - - - System.Int32:32 - - - - - olvJobs/cscript:LastDisplayIndex - - - System.Int32:22 - - - - - olvJobs/enabled:Visibility - - - System.Boolean:True - - - - - olvJobs/enabled:Width - - - System.Int32:60 - - - - - olvJobs/enabled:LastDisplayIndex - - - System.Int32:26 - - - - - olvJobs/nopush:Visibility - - - System.Boolean:True - - - - - olvJobs/nopush:Width - - - System.Int32:60 - - - - - olvJobs/nopush:LastDisplayIndex - - - System.Int32:23 - - - - - olvJobs/domainname:Visibility - - - System.Boolean:True - - - - - olvJobs/domainname:Width - - - System.Int32:166 - - - - - olvJobs/domainname:LastDisplayIndex - - - System.Int32:10 - - - - - olvJobs/domain:Visibility - - - System.Boolean:True - - - - - olvJobs/domain:Width - - - System.Int32:141 - - - - - olvJobs/domain:LastDisplayIndex - - - System.Int32:17 - - - - - olvJobs/checksum64file:Visibility - - - System.Boolean:True - - - - - olvJobs/checksum64file:Width - - - System.Int32:91 - - - - - olvJobs/checksum64file:LastDisplayIndex - - - System.Int32:25 - - - - - olvJobs/Target2:Visibility - - - System.Boolean:True - - - - - olvJobs/Target2:Width - - - System.Int32:60 - - - - - olvJobs/Target2:LastDisplayIndex - - - System.Int32:-1 - - - - - olvJobs/AppName:Visibility - - - System.Boolean:True - - - - - olvJobs/AppName:Width - - - System.Int32:164 - - - - - olvJobs/AppName:LastDisplayIndex - - - System.Int32:-1 - - - - - olvJobs/version:Visibility - - - System.Boolean:True - - - - - olvJobs/version:Width - - - System.Int32:120 - - - - - olvJobs/version:LastDisplayIndex - - - System.Int32:1 - - - - - olvJobs/filesize:Visibility - - - System.Boolean:True - - - - - olvJobs/filesize:Width - - - System.Int32:68 - - - - - olvJobs/filesize:LastDisplayIndex - - - System.Int32:8 - - - - - olvJobs/user-agent:Visibility - - - System.Boolean:True - - - - - olvJobs/user-agent:Width - - - System.Int32:60 - - - - - olvJobs/user-agent:LastDisplayIndex - - - System.Int32:12 - - - - - olvJobs/delPrevFile:Visibility - - - System.Boolean:True - - - - - olvJobs/delPrevFile:Width - - - System.Int32:60 - - - - - olvJobs/delPrevFile:LastDisplayIndex - - - System.Int32:27 - - - - - olvJobs/varChangeIndicator:Visibility - - - System.Boolean:True - - - - - olvJobs/varChangeIndicator:Width - - - System.Int32:60 - - - - - olvJobs/varChangeIndicator:LastDisplayIndex - - - System.Int32:20 - - - - - olvJobs/varChgInd:Visibility - - - System.Boolean:True - - - - - olvJobs/varChgInd:Width - - - System.Int32:82 - - - - - olvJobs/varChgInd:LastDisplayIndex - - - System.Int32:16 - - - - - olvJobs/url64:Visibility - - - System.Boolean:True - - - - - olvJobs/url64:Width - - - System.Int32:60 - - - - - olvJobs/url64:LastDisplayIndex - - - System.Int32:24 - - - - - olvJobs/hash:Visibility - - - System.Boolean:True - - - - - olvJobs/hash:Width - - - System.Int32:60 - - - - - olvJobs/hash:LastDisplayIndex - - - System.Int32:24 - - - - - olvJobs/hashType:Visibility - - - System.Boolean:True - - - - - olvJobs/hashType:Width - - - System.Int32:60 - - - - - olvJobs/hashType:LastDisplayIndex - - - System.Int32:18 - - - - - ImportFromDatabaseDialog/Size - - - System.Drawing.Size:524,1596 - - - - - olvApplications/Application name:Visibility - - - System.Boolean:True - - - - - olvApplications/Application name:Width - - - System.Int32:291 - - - - - olvApplications/Application name:LastDisplayIndex - - - System.Int32:-1 - - - - - olvApplications/Last updated:Visibility - - - System.Boolean:True - - - - - olvApplications/Last updated:Width - - - System.Int32:130 - - - - - olvApplications/Last updated:LastDisplayIndex - - - System.Int32:-1 - - - - - olvApplications/Uses:Visibility - - - System.Boolean:True - - - - - olvApplications/Uses:Width - - - System.Int32:40 - - - - - olvApplications/Uses:LastDisplayIndex - - - System.Int32:-1 - - - - - olvApplications/LastSortColumn - - - System.String:Application name - - - - - olvApplications/LastSortOrder - - - System.Int32:1 - - - - - ChooseAppsToInstallDialog/Size - - - System.Drawing.Size:618,433 - - - - - ChooseAppsToInstallDialog/Location - - - System.Drawing.Point:675,637 - - - - - ChooseAppsToInstallDialog/WindowState - - - System.Int32:0 - - - - - olvApps/Name:Visibility - - - System.Boolean:True - - - - - olvApps/Name:Width - - - System.Int32:263 - - - - - olvApps/Name:LastDisplayIndex - - - System.Int32:-1 - - - - - olvApps/LastSortColumn - - - System.String:Name - - - - - olvApps/LastSortOrder - - - System.Int32:1 - - - - - olvLists/Name:Visibility - - - System.Boolean:True - - - - - olvLists/Name:Width - - - System.Int32:80 - - - - - olvLists/Name:LastDisplayIndex - - - System.Int32:-1 - - - - - olvLists/Applications:Visibility - - - System.Boolean:True - - - - - olvLists/Applications:Width - - - System.Int32:80 - - - - - olvLists/Applications:LastDisplayIndex - - - System.Int32:-1 - - - - - olvLists/LastSortColumn - - - System.String:Name - - - - - olvLists/LastSortOrder - - - System.Int32:0 - - - - - ChooseAppsToInstallDialog/ListsView - - - System.Int32:4 - - - - - olvJobs/proto:Visibility - - - System.Boolean:True - - - - - olvJobs/proto:Width - - - System.Int32:60 - - - - - olvJobs/proto:LastDisplayIndex - - - System.Int32:11 - - - - - CopyFileInstructionDialog/Size - - - System.Drawing.Size:402,163 - - - - - olvJobs/bytes:Visibility - - - System.Boolean:True - - - - - olvJobs/bytes:Width - - - System.Int32:71 - - - - - olvJobs/bytes:LastDisplayIndex - - - System.Int32:7 - - - - - olvJobs/hashExtVar:Visibility - - - System.Boolean:True - - - - - olvJobs/hashExtVar:Width - - - System.Int32:60 - - - - - olvJobs/hashExtVar:LastDisplayIndex - - - System.Int32:23 - - - - - olvJobs/hashInternal:Visibility - - - System.Boolean:True - - - - - olvJobs/hashInternal:Width - - - System.Int32:60 - - - - - olvJobs/hashInternal:LastDisplayIndex - - - System.Int32:19 - - - - - olvJobs/hashExternal:Visibility - - - System.Boolean:True - - - - - olvJobs/hashExternal:Width - - - System.Int32:60 - - - - - olvJobs/hashExternal:LastDisplayIndex - - - System.Int32:20 - - - - - olvJobs/checksum64:Visibility - - - System.Boolean:True - - - - - olvJobs/checksum64:Width - - - System.Int32:33 - - - - - olvJobs/checksum64:LastDisplayIndex - - - System.Int32:21 - - - - - - - - - - - - - - - - - - - - - - - - - - chocopkgup {nopush} --packagename={appname} --version={version} --pg="{packageGuid}" --url="{preupdate-url}" --urlx64="{url64}" --packagepath="{file}" --checksum="{checksum}" --c64="{checksumx64}" --debug - //////////////////////////////////////////////////////////////////////////////////////// -/// version 6.5 -/// -/// FIX: do not re-push package if package already created -/// - -// REQUIRES: -// global vars: workdir=corresponds to download location of installer file -// app vars: nopush, checksum64file=corresponds to 64 bit install file -// file vars: same as specified by chocopkgup -string varCScript = app.Variables.ReplaceAllInString("{cscript}"); -if ((varCScript == "1") || (varCScript == "2")) { -string varAppname = app.Variables.ReplaceAllInString("{appname}"); -string varVersion = app.Variables.ReplaceAllInString("{version}"); -string varChocoPkgOutput = System.IO.Path.Combine(app.Variables.ReplaceAllInString("{autoPackagesFolder}"), "_output"); -string varChecksum = app.Variables.ReplaceAllInString("{checksum}"); -string varChecksumx64 = app.Variables.ReplaceAllInString("{checksumx64}"); -string varChecksum64File = app.Variables.ReplaceAllInString("{checksum64file}"); -string varChecksum64basefile = app.Variables.ReplaceAllInString("{checksum64file:basefile}"); -string varChecksum64ext = app.Variables.ReplaceAllInString("{checksum64file:ext}"); -string varWorkdir = app.Variables.ReplaceAllInString("{workdir}"); -string saveFileName64 = String.Concat(varChecksum64basefile, ".", varChecksum64ext); -// equivalent to ketarin variable "{file}" -//string savePath = app.PreviousLocation; -string savePath = app.PreviousLocation; -string pkgPath = Path.Combine(varChocoPkgOutput, varAppname, varVersion); -if (!System.IO.Directory.Exists(pkgPath)) { - pkgPath = Path.Combine(varChocoPkgOutput, varAppname); -} -string fileNameNuspec = String.Concat(varAppname, ".nuspec"); -string fileUriNuspec = Path.Combine(pkgPath, fileNameNuspec); -string fileNameNupkg = String.Concat(varAppname, ".", varVersion, ".nupkg"); -string fileUriNupkg = Path.Combine(pkgPath, fileNameNupkg); - -// do not re-push package if package already created -DateTime today = DateTime.Today; -DateTime pkgCreateDate = File.GetCreationTime(pkgPath); -if (today > pkgCreateDate) { - return; -} - -if (varChecksum == "{checksum}") { - // calculate SHA1 - System.IO.FileStream fileSha1 = new System.IO.FileStream(savePath, System.IO.FileMode.Open); - System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider(); - byte[] retValSha1 = sha1.ComputeHash(fileSha1); - fileSha1.Close(); - - // create a string - System.Text.StringBuilder sbSha1 = new System.Text.StringBuilder(); - for (int i = 0; i < retValSha1.Length; i++) { - sbSha1.Append(retValSha1[i].ToString("x2")); - } - - string replaceChecksum = sbSha1.ToString(); - List<string> fileList = new List<string>(Directory.GetFiles(pkgPath, "*.ps1", SearchOption.AllDirectories)); - string[] filesNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); - fileList.AddRange(filesNuspec); - string[] files = fileList.ToArray(); - foreach (string file in files) { - try { - string contents = File.ReadAllText(file); - contents = contents.Replace("{checksum}", replaceChecksum); - // Make files writable - // File.SetAttributes(file, FileAttributes.Normal); - File.WriteAllText(file, contents); - } catch (Exception ex) { - Console.WriteLine(ex.Message); - } - } -} - -// only get checksum if {checksum64file} exists and points to a downloadable file -if (varChecksumx64 == "{checksumx64}" && varChecksum64File != "{checksum64file}") { - string savePath64 = Path.Combine(varWorkdir, saveFileName64); - System.Net.WebClient webClient = new System.Net.WebClient(); - webClient.DownloadFile(varChecksum64File, savePath64); - - // calculate SHA1 - System.IO.FileStream file64Sha1 = new System.IO.FileStream(savePath64, System.IO.FileMode.Open); - System.Security.Cryptography.SHA1 sha164 = new System.Security.Cryptography.SHA1CryptoServiceProvider(); - byte[] retVal64Sha1 = sha164.ComputeHash(file64Sha1); - file64Sha1.Close(); - - // create a string - System.Text.StringBuilder sb64Sha1 = new System.Text.StringBuilder(); - for (int i = 0; i < retVal64Sha1.Length; i++) { - sb64Sha1.Append(retVal64Sha1[i].ToString("x2")); - } - - string replace64Checksum = sb64Sha1.ToString(); - List<string> fileList = new List<string>(Directory.GetFiles(pkgPath, "*.ps1", SearchOption.AllDirectories)); - string[] filesNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); - fileList.AddRange(filesNuspec); - string[] files = fileList.ToArray(); - foreach (string file in files) { - try { - string contents = File.ReadAllText(file); - contents = contents.Replace("{checksumx64}", replace64Checksum); - File.WriteAllText(file, contents); - } catch (Exception ex) { - Console.WriteLine(ex.Message); - } - } -} - -int checkBeta = varVersion.Split('-').Length; -if ( checkBeta == 2) { - string strPre = varVersion.Split('-')[1]; - string strReplace = String.Concat(strPre, "</version>"); - string strCheck = String.Concat(".", DateTime.Now.ToString("yyyyMMdd"), "</version>"); - string[] fileNuspec = Directory.GetFiles(pkgPath, "*.nuspec", SearchOption.AllDirectories); - foreach (string file in fileNuspec) { - string contents = File.ReadAllText(file); - contents = contents.Replace(strCheck, strReplace); - File.WriteAllText(file, contents); - } -} - -// delete existing nupkg made by chocopkgup; we leverage chocopkgup to create the structure/files in destination -System.Diagnostics.Process process1 = new System.Diagnostics.Process(); -System.Diagnostics.ProcessStartInfo proc1 = new System.Diagnostics.ProcessStartInfo(); -proc1.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; -proc1.UseShellExecute = true; -proc1.WorkingDirectory = pkgPath; -proc1.FileName = "cmd.exe"; -proc1.Arguments = "/c "+"del /f " + fileUriNupkg; -process1.StartInfo = proc1; -process1.Start(); - -// create a new nupkg -System.Diagnostics.Process process2 = new System.Diagnostics.Process(); -System.Diagnostics.ProcessStartInfo proc2 = new System.Diagnostics.ProcessStartInfo(); -proc2.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; -proc2.UseShellExecute = true; -proc2.WorkingDirectory = pkgPath; -proc2.FileName = "cmd.exe"; -proc2.Arguments = "/c "+"choco pack "+fileUriNuspec+" -d"; -process2.StartInfo = proc2; -process2.Start(); - -// push the nupkg -if (varCScript == "2") { - System.Diagnostics.Process process3 = new System.Diagnostics.Process(); - System.Diagnostics.ProcessStartInfo proc3 = new System.Diagnostics.ProcessStartInfo(); - proc3.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - proc3.UseShellExecute = true; - proc3.WorkingDirectory = pkgPath; - proc3.FileName = "cmd.exe"; - // find nupkg in pkgPath - string[] pushPkg = Directory.GetFiles(pkgPath, "*.nupkg", SearchOption.TopDirectoryOnly); - foreach (String file in pushPkg) { - proc3.Arguments = "/c "+"cpush " + file + " -d"; - } - process3.StartInfo = proc3; - System.Threading.Thread.Sleep(2000); - process3.Start(); -} -} - - - diff --git a/setup/README.md b/setup/README.md index 8498e456e0..cd6bec430c 100644 --- a/setup/README.md +++ b/setup/README.md @@ -1,22 +1,10 @@ -# Setup +# Setup Automatic Updater (chocolatey-au) -## Ketarin / ChocolateyPackageUpdater Automatic Packaging - -* Review `ketarin_setup.ps1` to ensure all items are set appropriately. Uncomment/change anything you need to now. -* Run `ketarin_setup.ps1` -* Open ketarin after installing it, open the settings and import `KetarinSettings.xml`. -* Set up push for Chocolatey community feed with your API key. -* Ensure `git push` doesn't require credentials. -* Review `ops/ketarinupdate.cmd` to ensure it is good to go. - -**Note**: Use `ops/ketarinupdate.cmd` or similar to schedule updates. - -## Automatic Updater (AU) - -* Ensure you have the [Chocolatey PowerShell profile](https://chocolatey.org/docs/troubleshooting#why-does-choco-intab-not-work-for-me) installed. +* Ensure you have the [Chocolatey PowerShell profile](https://docs.chocolatey.org/en-us/troubleshooting#why-does-choco-tab-not-work-for-me) installed. * Open `au_setup.ps1` in an editor and review it. -* Run PowerShell `5.x` as Administrator (AU framework supports PowerShell 6+ but this setup does not) +* Run PowerShell `5.x` as Administrator (chocolatey-au framework supports PowerShell 6+ but this setup does not). * Run `au_setup.ps1`. -* Configure AU [plugins](https://github.com/majkinetor/au/blob/master/Plugins.md). -* Configure [AppVeyor](https://github.com/majkinetor/au/wiki/AppVeyor). -* Configure [local run](https://github.com/majkinetor/au/wiki#local-run). +* For local automatic packaging, copy `update_vars_default.ps1` to `update_default.ps1` and fill it in. +* Configure chocolatey-au [plugins](https://github.com/chocolatey-community/chocolatey-au/blob/master/Plugins.md). +* Configure [AppVeyor](https://github.com/chocolatey-community/chocolatey-au/wiki/AppVeyor). +* Configure [local run](https://github.com/chocolatey-community/chocolatey-au/wiki#local-run). diff --git a/setup/au_setup.ps1 b/setup/au_setup.ps1 index 1725e6a68a..c39a664185 100644 --- a/setup/au_setup.ps1 +++ b/setup/au_setup.ps1 @@ -1,17 +1,17 @@ -# WMF 3/4 only +# upgrade powershell if ($PSVersionTable.PSVersion -lt $(New-Object System.Version("5.0.0.0"))) { - choco install dotnet4.5.1 -y - choco upgrade powershell-packagemanagement --ignore-dependencies -y + choco install powershell -y } -$refreshenv = Get-Command refreshenv -ea SilentlyContinue -if ($refreshenv -ne $null -and $refreshenv.CommandType -ne 'Application') { - refreshenv # You need the Chocolatey profile installed for this to work properly (Choco v0.9.10.0+). +$UpdateSessionEnvironment = Get-Command Update-SessionEnvironment -ea SilentlyContinue +if ($UpdateSessionEnvironment -ne $null -and $UpdateSessionEnvironment.CommandType -ne 'Application') { + Update-SessionEnvironment # You need the Chocolatey profile installed for this to work properly (Choco v0.9.10.0+). } else { - Write-Warning "We detected that you do not have the Chocolatey PowerShell profile installed, which is necessary for 'refreshenv' to work in PowerShell." + Write-Warning "We detected that you do not have the Chocolatey PowerShell profile installed, which is necessary for 'Update-SessionEnvironment' to work in PowerShell." } -Install-PackageProvider -Name NuGet -Force -Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Install-Module au -Scope AllUsers -Get-Module au -ListAvailable | select Name, Version +choco install git.portable -y +# Required as git is installed to Get-ToolsLocation and is added to the PATH +Update-SessionEnvironment +git clone -q https://github.com/chocolatey-community/chocolatey-au.git $Env:TEMP/chocolatey-au +. "$Env:TEMP/chocolatey-au/scripts/Install-AU.ps1" "master" diff --git a/setup/ketarin_setup.ps1 b/setup/ketarin_setup.ps1 deleted file mode 100644 index b9139faf0e..0000000000 --- a/setup/ketarin_setup.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -# If you change this value, also change it in the global settings -# The name will also be saveDir -$saveDir = "c:\chocolatey-auto-save" - -Write-Host "Ensuring that the Ketarin auto save folder is set appropriately." -if (!(Test-Path($saveDir))) { - mkdir $saveDir -} - -choco upgrade chocolateypackageupdater -y -choco upgrade ketarin -y diff --git a/test_all.ps1 b/test_all.ps1 index faa4904896..4decb6ee2e 100644 --- a/test_all.ps1 +++ b/test_all.ps1 @@ -20,27 +20,57 @@ if (($Name.Length -gt 0) -and ($Name[0] -match '^random (.+)')) { } $options = [ordered]@{ - Force = $true - Push = $false + Force = $true + Push = $false + Threads = 10 + + IgnoreOn = @( #Error message parts to set the package ignore status + 'Could not create SSL/TLS secure channel' + 'Could not establish trust relationship' + 'The operation has timed out' + 'Internal Server Error' + 'Service Temporarily Unavailable' + 'Choco pack failed with exit code 1' + ) + + RepeatOn = @( #Error message parts on which to repeat package updater + 'Could not create SSL/TLS secure channel' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/718 + 'Could not establish trust relationship' # -||- + 'Unable to connect' + 'The remote name could not be resolved' + 'Choco pack failed with exit code 1' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/721 + 'The operation has timed out' + 'Internal Server Error' + 'An exception occurred during a WebClient request' + 'Job returned no object, Vector smash ?' + ) + RepeatSleep = 60 #How much to sleep between repeats in seconds, by default 0 + RepeatCount = 2 #How many times to repeat on errors, by default 1 Report = @{ - Type = 'markdown' # Report type: markdown or text - Path = "$PSScriptRoot\Update-Force-Test-${n}.md" # Path where to save the report - Params = @{ # Report parameters: - Github_UserRepo = $Env:github_user_repo # Markdown: shows user info in upper right corner - NoAppVeyor = $false # Markdown: do not show AppVeyor build shield - Title = "Update Force Test - Group ${n}" - UserMessage = "[Update report](https://gist.github.com/$Env:gist_id) | **USING AU NEXT VERSION**" + Type = 'markdown' #Report type: markdown or text + Path = "$PSScriptRoot\Update-Force-Test-${n}.md" #Path where to save the report + Params= @{ #Report parameters: + Github_UserRepo = $Env:github_user_repo # Markdown: shows user info in upper right corner + NoAppVeyor = $true # Markdown: do not show AppVeyor build shield + Title = "Update Force Test - Group ${n}" + UserMessage = "[Ignored](#ignored) | [Update report](https://gist.github.com/$Env:gist_id)" # Markdown, Text: Custom user message to show } } Gist = @{ - Id = $Env:gist_id_test # Your gist id; leave empty for new private or anonymous gist - ApiKey = $Env:github_api_key # Your github api key - if empty anoymous gist is created - Path = "$PSScriptRoot\Update-Force-Test-${n}.md" # List of files to add to the gist + Id = $Env:gist_id_test #Your gist id; leave empty for new private or anonymous gist + ApiKey = $Env:github_api_key #Your github api key - if empty anoymous gist is created + Path = "$PSScriptRoot\Update-Force-Test-${n}.md" #List of files to add to the gist Description = "Update Force Test Report #powershell #chocolatey" } } $global:info = updateall -Name $Name -Options $Options + +$au_errors = $global:info | ? { $_.Error } | select -ExpandProperty Error + +if ($ThrowOnErrors -and $au_errors.Count -gt 0) { + throw 'Errors during update' +} diff --git a/update_all.ps1 b/update_all.ps1 index bf3ed9df23..2c67200acc 100644 --- a/update_all.ps1 +++ b/update_all.ps1 @@ -1,80 +1,120 @@ -# AU Packages Template: https://github.com/majkinetor/au-packages-template - -param([string] $Name, [string] $ForcedPackages, [string] $Root = "$PSScriptRoot\automatic") +param([string[]] $Name, [string] $ForcedPackages, $Root = "$PSScriptRoot\automatic") if (Test-Path $PSScriptRoot/update_vars.ps1) { . $PSScriptRoot/update_vars.ps1 } $Options = [ordered]@{ - Timeout = 100 # Connection timeout in seconds - UpdateTimeout = 1200 # Update timeout in seconds - Threads = 10 # Number of background jobs to use - Push = $Env:au_Push -eq 'true' # Push to chocolatey - PluginPath = '' # Path to user plugins + WhatIf = $au_WhatIf #Whatif all packages + Force = $false #Force all packages + Timeout = 100 #Connection timeout in seconds + UpdateTimeout = 1200 #Update timeout in seconds + Threads = 10 #Number of background jobs to use + Push = $Env:au_Push -eq 'true' #Push to chocolatey + PushAll = $true #Allow to push multiple packages at once + PluginPath = '' #Path to user plugins + IgnoreOn = @( #Error message parts to set the package ignore status + 'Could not create SSL/TLS secure channel' + 'Could not establish trust relationship' + 'The operation has timed out' + 'Internal Server Error' + 'Service Temporarily Unavailable' + 'The connection was closed unexpectedly.' + 'package version already exists' + 'already exists on a Simple OData Server' # https://github.com/chocolatey/chocolatey.org/issues/613 + 'Conflict' + 'A system shutdown has already been scheduled' # https://gist.github.com/choco-bot/a14b1e5bfaf70839b338eb1ab7f8226f#wps-office-free + ) + RepeatOn = @( #Error message parts on which to repeat package updater + 'Could not create SSL/TLS secure channel' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/718 + 'Could not establish trust relationship' # -||- + 'Unable to connect' + 'The remote name could not be resolved' + 'Choco pack failed with exit code 1' # https://github.com/chocolatey/chocolatey-coreteampackages/issues/721 + 'The operation has timed out' + 'Internal Server Error' + 'An exception occurred during a WebClient request' + 'remote session failed with an unexpected state' + 'The connection was closed unexpectedly.' + ) + #RepeatSleep = 250 #How much to sleep between repeats in seconds, by default 0 + #RepeatCount = 2 #How many times to repeat on errors, by default 1 + + #NoCheckChocoVersion = $true #Turn on this switch for all packages + Report = @{ - Type = 'markdown' # Report type: markdown or text - Path = "$PSScriptRoot\Update-AUPackages.md" # Path where to save the report - Params= @{ # Report parameters: - Github_UserRepo = $Env:github_user_repo # Markdown: shows user info in upper right corner - NoAppVeyor = $false # Markdown: do not show AppVeyor build shield - UserMessage = "[History](#update-history)" # Markdown, Text: Custom user message to show - NoIcons = $false # Markdown: don't show icon - IconSize = 32 # Markdown: icon size - Title = '' # Markdown, Text: Title of the report, by default 'Update-AUPackages' + Type = 'markdown' #Report type: markdown or text + Path = "$PSScriptRoot\Update-AUPackages.md" #Path where to save the report + Params= @{ #Report parameters: + Github_UserRepo = $Env:github_user_repo # Markdown: shows user info in upper right corner + NoAppVeyor = $false # Markdown: do not show AppVeyor build shield + UserMessage = "[Ignored](#ignored) | [History](#update-history) | [Force Test](https://gist.github.com/$Env:gist_id_test) | [Releases](https://github.com/$Env:github_user_repo/tags)" # Markdown, Text: Custom user message to show + NoIcons = $false # Markdown: don't show icon + IconSize = 32 # Markdown: icon size + Title = '' # Markdown, Text: TItle of the report, by default 'Update-AUPackages' } } History = @{ - Lines = 30 # Number of lines to show - Github_UserRepo = $Env:github_user_repo # User repo to be link to commits - Path = "$PSScriptRoot\Update-History.md" # Path where to save history + Lines = 120 #Number of lines to show + Github_UserRepo = $Env:github_user_repo #User repo to be link to commits + Path = "$PSScriptRoot\Update-History.md" #Path where to save history } Gist = @{ - Id = $Env:gist_id # Your gist id; leave empty for new private or anonymous gist - ApiKey = $Env:github_api_key # Your github api key - if empty anoymous gist is created + Id = $Env:gist_id #Your gist id; leave empty for new private or anonymous gist + ApiKey = $Env:github_api_key #Your github api key - if empty anoymous gist is created Path = "$PSScriptRoot\Update-AUPackages.md", "$PSScriptRoot\Update-History.md" Description = "Update-AUPackages Report #powershell #chocolatey" } Git = @{ - User = '' # Git username, leave empty if github api key is used - Password = $Env:github_api_key # Password if username is not empty, otherwise api key + User = '' #Git username, leave empty if github api key is used + Password = $Env:github_api_key #Password if username is not empty, otherwise api key + } + + GitReleases = @{ + ApiToken = $Env:github_api_key #Your github api key + ReleaseType = 'package' #Either 1 release per date, or 1 release per package } RunInfo = @{ - Exclude = 'password', 'apikey' # Option keys which contain those words will be removed - Path = "$PSScriptRoot\update_info.xml" # Path where to save the run info + Exclude = 'password', 'apikey', 'apitoken' #Option keys which contain those words will be removed + Path = "$PSScriptRoot\update_info.xml" #Path where to save the run info } - # Mail = if ($Env:mail_user) { - # @{ - # To = $Env:mail_user - # Server = $Env:mail_server - # UserName = $Env:mail_user - # Password = $Env:mail_pass - # Port = $Env:mail_port - # EnableSsl = $Env:mail_enablessl -eq 'true' - # Attachment = "$PSScriptRoot\update_info.xml" - # UserMessage = '' - # SendAlways = $false - # } - # } else {} + #Mail = if ($Env:mail_user) { + #@{ + #To = $Env:mail_user + #From = $Env:mail_from + #Server = $Env:mail_server + #UserName = $Env:mail_user + #Password = $Env:mail_pass + #Port = $Env:mail_port + #EnableSsl = $Env:mail_enablessl -eq 'true' + #Attachment = "$PSScriptRoot\update_info.xml" + #UserMessage = '' + #SendAlways = $false #Send notifications every time + #} + #} else {} ForcedPackages = $ForcedPackages -split ' ' BeforeEach = { param($PackageName, $Options ) - $p = $Options.ForcedPackages | ? { $_ -match "^${PackageName}(?:\:(.+))*$" } + + $pattern = "^${PackageName}(?:\\(?[^:]+))?(?:\:(?.+))?$" + $p = $Options.ForcedPackages | ? { $_ -match $pattern } if (!$p) { return } - $global:au_Force = $true - $global:au_Version = ($p -split ':')[1] + $global:au_Force = $true + $global:au_IncludeStream = $Matches['stream'] + $global:au_Version = $Matches['version'] } } if ($ForcedPackages) { Write-Host "FORCED PACKAGES: $ForcedPackages" } -$global:au_Root = $Root # Path to the AU packages +$global:au_Root = $Root #Path to the AU packages +$global:au_GalleryUrl = '' #URL to package gallery, leave empty for Chocolatey Gallery $global:info = updateall -Name $Name -Options $Options -# Uncomment to fail the build on AppVeyor on any package error -# if ($global:info.error_count.total) { throw 'Errors during update' } +#Uncomment to fail the build on AppVeyor on any package error +#if ($global:info.error_count.total) { throw 'Errors during update' }