powershellでoneget & chocolateyパッケージを作るときに気を付ける10のこと

Download PowerShellでOneGet & Chocolateyパッケージを作るときに気を付ける10のこと

Post on 15-Jan-2015

1.097 views

Category:

Technology

3 download

Embed Size (px)

DESCRIPTION

 

TRANSCRIPT

  • 1. PowerShellOne-Get & Chocolatey 10 3 PowerShell 2014/07/12 @oota_ken

2. OneGetChocolatey Chocolatey Chocolatey10 3. OneGetChocolatey OneGet Windows Management Framework 5.0(Preview)Microsoft apt-getyum, Homebrew Store Chocolatey Chocolatey OneGet Chocolatey inst chrome firefox jdk8 git poshgit gradle intellijidea-community jenkins vim nodejs ruby 4. OneGetChocolatey OneGet Windows Management Framework 5.0 Preview May 2014 http://www.microsoft.com/en-us/download/details.aspx?id=42936 "English" Chocolatey Windows PowerShell Set-ExecutionPolicy Unrestricted iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) 5. Chocolatey 6. Chocolatey https://chocolatey.org/account/Register API https://chocolatey.org/account API nuget.exe setApiKey URLAPI -Source http://chocolatey.org/ 7. cinst warmup git nuget.commandline cd %ChocolateyInstall% git clone [[https://github.com/chocolatey/chocolateytemplates.git]] cd chocolateytemplates_templates warmup addTemplateFolder chocolatey "%CD%chocolatey" warmup chocolatey jdk8 8. .nuspec tools/chocolateyInstall.ps1 tools/chocolateyUninstall.ps1 9. jdk8Java SE 8u5 8.0.5Sun Microsystems/Oracle Corporationoota_kenThe Java Development Kit (JDK) version 8.0.5The Java Development Kit (JDK) version 8.0.5http://www.oracle.com/technetwork/java/javase/downloads/index.htmljava jdkhttp://www.oracle.com/technetwork/java/javase/terms/license/index.htmlfalsehttps://raw.githubusercontent.com/carolynvs/chocolatey-packages/master/Java.JDK/java-logo.jpg 10. *.nuspecaptbrew 11. tools/chocolateyInstall.ps1 1 JetBrains IntelliJ IDEA - Community Edition $name = "intellijidea-community" $url = "http://download.jetbrains.com/idea/ideaIC-13.1.2.exe" $kind = "EXE" $silent = "/S" Install-ChocolateyPackage $name $kind $silent $url 12. tools/chocolateyUninstall.ps1 https://github.com/chocolatey/chocolatey/wiki/CommandsUninstall There are no functions defined in the chocolatey powershell module that would help with uninstall Chocolatey or jdk8 () $jdk = "/qn /x {64A3A4F4-B792-11D6-A78A-00B0D0" + $uninstall_id + "0}" Start-ChocolateyProcessAsAdmin $jdk 'msiexec' $java_bin = get-java-bin Uninstall-ChocolateyPath $java_bin 'Machine' 13. cpack cinst jdk8 -source '%cd%' () cuninst jdk8 cpush jdk8.1.8.0.05.nupkg 14. Chocolatey10 15. *.nuspecID jdk8Java SE 8u5 8.0.5 PowerShell id java.jdk, jdk7, jdk, jdk8 version JDK, JRE 8.0.501 16. [System.Net.ServicePointManager]::Server CertificateValidationCallback = { $true } $client = New-Object Net.WebClient $client.Headers.Add('Cookie', 'gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup- cookie') $client.DownloadFile($url, $output_filename) Web Web OK 17. >function add($a, $b) { return $a + $b; } > function call_add { add 1 2; add 2 3; return 6 } C:UsersKenichiroOta> call_add 3 5 6 $dummy = [System.Net.ServicePointManager]::ServerCertificateValid ationCallback = { $true } $client = New-Object Net.WebClient PowerShellreturn [void] $dummy [System.Net.ServicePointManager]::ServerCertificateValid ationCallback = { $true } $dummy = [System.Net.ServicePointManager]::ServerCertificateValid ationCallback = { $true } 18. $use64bit = use64bit if ($use64bit) { $jdk = "/qn /x {64A3A4F4-B792-11D6-A78A- 00B0D0" + $uninstall_id + "0}" $jre = "/qn /x {26A24AE4-039D-4CA4-87B4- 2F864" + $uninstall_id + "FF}" } else { $jdk = "/qn /x {32A3A4F4-B792-11D6-A78A- 00B0D0" + $uninstall_id + "0}" $jre = "/qn /x {26A24AE4-039D-4CA4-87B4- 2F832" + $uninstall_id + "FF}" } Start-ChocolateyProcessAsAdmin $jdk 'msiexec' Start-ChocolateyProcessAsAdmin $jre 'msiexec' https://github.com/chocolatey/chocolatey/wiki/Co mmandsUninstall Helper Uninstall-ChocolateyPackage UnInstall-ChocolateyZipPackage 19. Install-ChocolateyPath $java_bin 'Machine' [Environment]::SetEnvironmentVariable('Path', $actualPath, $pathType) Install-ChocolateyEnvironmentVariable 'JAVA_HOME' $java_home 'Machine' $env:Path = $actualPath ?? cinst ( PowerShell) cinstPowerShell SetEnvironmentVariable cinst GetEnvironmentVraible cinst, cuninst 20. Windows cinst cinstPowerShell cuninstPowerShell cinst cinst cinst key=value key=value key=value key=value cuninst key=value (cinst ) key=value cunsint key=value () cuninst cuninst 21. x64, x86 function use64bit() { $is64bitOS = (Get-WmiObject Class Win32_ComputerSystem).SystemType -match (x64) return $is64bitOS } if ($use64bit) { $jdk = "/qn /x {64A3A4F4-B792-11D6-A78A-00B0D0" + $uninstall_id + "0}" $jre = "/qn /x {26A24AE4-039D-4CA4-87B4-2F864" + $uninstall_id + "FF}" } else { # } x64x86 x64 OSx86x86 OS x86 OS x64 x64 C:Program Files x64 x86 C:Program Files (x86) x86 x86 C:Program Files 22. OneGet Chocolatey cinst jdk8 -source '%cd%' OneGet cpush jdk8.1.8.0.05.nupkg Install-Package jdk8 Uninstall-Package jdk8 OneGet Chocolatey OneGet (DLL) Chocolatey DLLPowerShell Chocolatey OneGet OneGet OneGet 23. x64, x86 * Chocolatey, OneGet Chocolatey * x64, x86 cinst jdk8 source '%cd%' cunint jdk8 OneGet cpush jdk8.1.8.0.05.nupkg Install-Package jdk8 Uninstall-Package jdk8 OS Chocolatey OneGet x64 Chocolatey x64 x86 OneGet x64 x86 x86 Chocolatey x86 OneGet x86 24. function Start-ChocolateyProcessAsAdmin { # $psi = new-object System.Diagnostics.ProcessStartInfo; $psi.FileName = $exeToRun; if ([Environment]::OSVersion.Version -ge (new-object 'Version' 6,0)){ $psi.Verb = "runas"; } # } Start-ChocolateyProcessAsAdmin runas Start-ChocolateyProcessAsAdmin function "OK" PowerShell 25. function Start-ChocolateyProcessAsAdmin { param( [string] $statements, [string] $exeToRun = 'powershell', [switch] $minimized, [switch] $noSleep, $validExitCodes = @(0) ) # if ($minimized) { $psi.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized; } # } Start-ChocolateyProcessAsAdmin not $minimized = $true Exit $minimized = $true function Install-ChocolateyPath { # Start-ChocolateyProcessAsAdmin "$psArgs" # Chocolateyminimzed = $true 26. OneGet & Chocolatey OneGet OneGet & Chocolatey OS x x (OneGet | Chocolatey) API ()

Recommended

View more >