Skip to content

Commit

Permalink
Merge pull request #2543 from AdmiringWorm/1password [AU 1password\OPW4]
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm authored Sep 26, 2024
2 parents a2c371e + 01e39c4 commit 2cc2e18
Show file tree
Hide file tree
Showing 26 changed files with 428 additions and 105 deletions.
6 changes: 3 additions & 3 deletions automatic/1password/1password.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"OPW": "7.9.835",
"OPW4": "4.6.2.626"
{
"OPW4": "4.6.2.62600",
"OPW7": "7.9.835"
}
11 changes: 4 additions & 7 deletions automatic/1password/1password.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@
- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**
]]></description>
<summary>1Password - Have you ever forgotten a password?</summary>
<copyright2021 AgileBits, Inc. All rights reserved.</copyright>
<tags>1password password keystore keys saver admin trial cross-platform</tags>
<copyright 2024 1Password. All rights reserved.</copyright>
<tags>1password utility trial cross-platform password keystore keys</tags>
<packageSourceUrl>https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/1password</packageSourceUrl>
<dependencies>
<dependency id="dotnet4.7.2" version="4.7.2.20180712" />
<dependency id="chocolatey-core.extension" version="1.3.3" />
<dependency id="1password" version="0.0" />
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
<files />
</package>
39 changes: 0 additions & 39 deletions automatic/1password/tools/chocolateyInstall.ps1

This file was deleted.

93 changes: 44 additions & 49 deletions automatic/1password/update.ps1
Original file line number Diff line number Diff line change
@@ -1,70 +1,65 @@
Import-Module Chocolatey-AU
import-module $PSScriptRoot\..\..\extensions\chocolatey-core.extension\extensions\chocolatey-core.psm1
param($IncludeStream = $global:au_IncludeStream, $Force)

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(?i)^(\s*url\s*=\s*)'.*'" = "`${1}'$($Latest.URL32)'"
"(?i)^(\s*checksum\s*=\s*)'.*'" = "`${1}'$($Latest.Checksum32)'"
"(?i)^(\s*checksumType\s*=\s*)'.*'" = "`${1}'$($Latest.ChecksumType32)'"
"(?i)^(\s*silentArgs\s*=\s*)['`"].*['`"]" = "`${1}`"$($Latest.SilentArgs)`""
}
}
}
Import-Module Chocolatey-AU

function global:au_AfterUpdate {
. "$PSScriptRoot/update_helper.ps1"
if ($Latest.PackageName -eq '1password4') {
removeDependencies ".\*.nuspec"
addDependency ".\*.nuspec" "chocolatey-core.extension" "1.3.3"
if (($IncludeStream -match "^OPW(?<major>\d+)") -and (Test-Path "$PSScriptRoot\..\..\manual\1password$($Matches['major'])")) {
# Since this is a manual package, we will assume that the package itself needs to be updated.
Push-Location "$PSScriptRoot\..\..\manual\1password$($Matches['major'])"
try {
$oldVersion = $global:au_Version
. "./update.ps1" -NoUpdateCheck

if ($oldVersion) {
$global:au_Version = $oldVersion
} else {
$global:au_Version = $global:Latest.Version.ToString()
}
$global:au_Latest = $null
$global:Latest = $null
}
else {
addDependency ".\*.nuspec" 'dotnet4.7.2' '4.7.2.20180712'
finally {
Pop-Location
}
}

function global:au_BeforeUpdate {
if ($Latest.PackageName -eq '1password4') {
$Latest.SilentArgs = '/VERYSILENT /NORESTART /SUPPRESSMSGBOXES /SP- /LOG=`"$($env:TEMP)\$($env:chocolateyPackageName).$($env:chocolateyPackageVersion).InnoInstall.log`"'
}
else {
$Latest.SilentArgs = '--silent'
else {
Get-ChildItem "$PSScriptRoot\..\1password*" | Where-Object { $_.Name -ne '1password' } | ForEach-Object {
. "$_\update.ps1"
}
}

function Get-LatestOPW {
param (
[string]$url,
[string]$kind
function global:au_BeforeUpdate($Package) {
# This is done in the before update, otherwise the dependency is not updated.
$readmePath = $Latest.Readme

)

$url32 = Get-RedirectedUrl $url
$verRe = 'Setup-|word-|\.exe$'
$version = $url32 -split $verRe | Select-Object -last 1 -skip 1
$version = $version -replace ('\.BETA', ' beta')
$version = Get-Version $version
$major = $version.ToString(1)
if ($readmePath -and (Test-Path $readmePath)) {
Set-DescriptionFromReadme $Package -SkipFirst 2 -ReadmePath $readmePath
}
}

function global:au_SearchReplace {
@{
URL32 = $url32
Version = $version.ToString()
PackageName = $kind
"$($Latest.PackageName).nuspec" = @{
"(?i)(\<dependency .+?)`"1password\d*(`" version=)`"([^`"]+)`"" = "`$1`"$($Latest.DependencyName)`$2`"[$($Latest.Version)]`""
}
}
}

$releases_opw4 = 'https://app-updates.agilebits.com/download/OPW4'
$kind_opw4 = '1password4'
$releases_opw = 'https://app-updates.agilebits.com/download/OPW7/Y'
$kind_opw = '1password'
function global:au_AfterUpdate {
. "$PSScriptRoot\..\..\scripts\Update-IconUrl.ps1" -Name '1password' -IconName $Latest.DependencyName -ThrowErrorOnIconNotFound
}


function global:au_GetLatest {
$streams = [ordered] @{
OPW4 = Get-LatestOPW -url $releases_opw4 -kind $kind_opw4
OPW = Get-LatestOPW -url $releases_opw -kind $kind_opw
$commands = Get-Command "Find-1Password*"

$streams = @{}

$null = $commands | ForEach-Object {
$result = & $_
$streams.Add('OPW' + $result.VersionMajor, $result)
}

return @{ Streams = $streams }
}

update -ChecksumFor 32 -IncludeStream $IncludeStream -Force:$Force
update -ChecksumFor None -IncludeStream $IncludeStream -Force:$Force
26 changes: 25 additions & 1 deletion automatic/1password/update_helper.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
function LoadXml([string]$Path) {
function Get-LatestOPW {
param (
[Parameter(Mandatory)]
[string]$url

)

$url32 = Get-RedirectedUrl $url
$verRe = 'Setup-|word-|\.exe$'
$version = $url32 -split $verRe | Select-Object -last 1 -skip 1
$version = $version -replace ('\.BETA', ' beta')
$version = Get-Version $version
$major = $version.ToString(1)

$result = @{
URL32 = $url32
Version = $version
VersionMajor = $major
RemoteVersion = $version
}

$result
}

function LoadXml([string]$Path) {
$Path = Resolve-Path $Path
$nu = New-Object xml
$nu.PSBase.PreserveWhitespace = $true
Expand Down
28 changes: 28 additions & 0 deletions automatic/1password7/1password7.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>1password7</id>
<version>0.0</version>
<title>1Password</title>
<authors>AgileBits</authors>
<owners>chocolatey-community, AgileBits</owners>
<licenseUrl>https://1password.com/legal/terms-of-service</licenseUrl>
<projectUrl>https://1password.com/</projectUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/chocolatey-community/chocolatey-packages@09451a71b28e4ee0b3ea3841ab130b1bbf46f9b0/icons/1password7.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<mailingListUrl>https://discussions.agilebits.com/</mailingListUrl>
<!-- Do not touch the description here in the nuspec file. Description is imported during update from the Readme.md file -->
<description><![CDATA[]]></description>
<summary>1Password - Have you ever forgotten a password?</summary>
<copyright>© 2024 1Password. All rights reserved.</copyright>
<tags>1password7 utility trial cross-platform password keystore keys 1password</tags>
<packageSourceUrl>https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/1password</packageSourceUrl>
<dependencies>
<dependency id="dotnet4.7.2" version="4.7.2.20180712" />
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
11 changes: 11 additions & 0 deletions automatic/1password7/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# [<img src="https://cdn.jsdelivr.net/gh/chocolatey-community/chocolatey-packages@09451a71b28e4ee0b3ea3841ab130b1bbf46f9b0/icons/1password.png" height="48" width="48" /> 1Password](https://chocolatey.org/packages/1password)

1Password can create strong, unique passwords for you, remember them, and restore them, all directly in your web browser.

![screenshot](https://github.com/chocolatey-community/chocolatey-coreteampackages/blob/master/automatic/1password7/screenshot.png?raw=true)

## Notes

- This package version installs version 7.x of 1password, if you want 8.x use the package [1password8](https://chocolatey.org/packages/1password8) or [1password4](https://chocolatey.org/packages/1password4) for 4.x.

- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**
File renamed without changes
43 changes: 43 additions & 0 deletions automatic/1password7/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
$ErrorActionPreference = 'Stop'

$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'exe'
url = 'https://c.1password.com/dist/1P/win6/1PasswordSetup-7.9.835.exe'
softwareName = '1Password*'
checksum = '3d43ea28c46a1dac9cc645c5d9f4692cd1be009145ffe5260a910a2d9c89dd52'
checksumType = 'sha256'
silentArgs = "--silent"
validExitCodes = @(0)

BeforeInstall = {
$cache_dir = Join-Path -Path $env:LocalAppData -ChildPath "1password\logs\setup"

# Installer blocks at the end and never returns. Successfull installation is visible in the log file, but only if it is the first installation
$null = Start-Job -ScriptBlock { param($cache_dir)
Remove-Item $cache_dir\*.log -Recurse -ea 0
$seconds = 0; $max_seconds = 120

while ($seconds -lt $max_seconds) {
Start-Sleep 1; $seconds++

$logFilePath = Get-ChildItem $cache_dir\*.log -Recurse | Select-Object -First 1

# We will only wait up to a minute for a log file being available.
if (!$logFilePath ) { continue }

$log = Get-Content $logFilePath
if ($log -like '*Installation successful!' -or $log -like '*Installation completed successfully!*') {
break
}
}

# We will wait a couple of seconds to ensure as the installer haven't fully finished when this message
# is outputted. We also need to stop the executable no matter what for the package to finish.
Start-Sleep -Seconds 2
Get-Process '1password' -ea 0 | Stop-Process
} -ArgumentList ($cache_dir)
}
}

Install-ChocolateyPackage @packageArgs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$packageName = $env:ChocolateyPackageName

[array]$key = Get-UninstallRegistryKey -SoftwareName '1Password*'
[array]$key = Get-UninstallRegistryKey -SoftwareName '1Password*' | ? DisplayVersion -match "^7\."

if ($key.Count -eq 1) {
$key | ForEach-Object {
Expand Down
30 changes: 30 additions & 0 deletions automatic/1password7/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Import-Module Chocolatey-AU
. "$PSScriptRoot\..\1password\update_helper.ps1"

function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(?i)^(\s*url\s*=\s*)'.*'" = "`${1}'$($Latest.URL32)'"
"(?i)^(\s*checksum\s*=\s*)'.*'" = "`${1}'$($Latest.Checksum32)'"
"(?i)^(\s*checksumType\s*=\s*)'.*'" = "`${1}'$($Latest.ChecksumType32)'"
}
}
}

function Find-1Password7Stream {
$releaseUrl = 'https://app-updates.agilebits.com/download/OPW7/Y'

$result = Get-LatestOPW -url $releaseUrl
$result['Readme'] = "$PSScriptRoot\Readme.md"
$result['DependencyName'] = Split-Path -Leaf $PSScriptRoot

$result
}

function global:au_GetLatest {
Find-1Password7Stream
}

if ($MyInvocation.InvocationName -ne '.') {
update -ChecksumFor 32 -IncludeStream $IncludeStream -Force:$Force
}
25 changes: 25 additions & 0 deletions automatic/1password8/1password8.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>1password8</id>
<version>0.0</version>
<title>1Password</title>
<authors>AgileBits</authors>
<owners>chocolatey-community</owners>
<licenseUrl>https://1password.com/legal/terms-of-service</licenseUrl>
<projectUrl>https://1password.com/</projectUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/chocolatey-community/chocolatey-packages@09451a71b28e4ee0b3ea3841ab130b1bbf46f9b0/icons/1password8.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<mailingListUrl>https://discussions.agilebits.com/</mailingListUrl>
<!-- Do not touch the description here in the nuspec file. Description is imported during update from the Readme.md file -->
<description><![CDATA[]]></description>
<summary>1Password - Have you ever forgotten a password?</summary>
<copyright>© 2024 1Password. All rights reserved.</copyright>
<tags>1password8 utility trial cross-platform password keystore keys 1password</tags>
<packageSourceUrl>https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/1password8</packageSourceUrl>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
10 changes: 10 additions & 0 deletions automatic/1password8/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# [<img src="https://cdn.jsdelivr.net/gh/chocolatey-community/chocolatey-packages@09451a71b28e4ee0b3ea3841ab130b1bbf46f9b0/icons/1password.png" height="48" width="48" /> 1Password](https://chocolatey.org/packages/1password8)

1Password can create strong, unique passwords for you, remember them, and restore them, all directly in your web browser.

![screenshot](https://github.com/chocolatey-community/chocolatey-packages/blob/master/automatic/1password/screenshot.webp?raw=true)

## Notes

- This package version installs version 8.x of 1password, if you want 7.x use the package [1password7](https://chocolatey.org/packages/1password7) or [1password4](https://chocolatey.org/packages/1password4) for 4.x.
- **If the package is out of date please check [Version History](#versionhistory) for the latest submitted version. If you have a question, please ask it in [Chocolatey Community Package Discussions](https://github.com/chocolatey-community/chocolatey-packages/discussions) or raise an issue on the [Chocolatey Community Packages Repository](https://github.com/chocolatey-community/chocolatey-packages/issues) if you have problems with the package. Disqus comments will generally not be responded to.**
Binary file added automatic/1password8/screenshot.webp
Binary file not shown.
14 changes: 14 additions & 0 deletions automatic/1password8/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$ErrorActionPreference = 'Stop'

$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'msi'
url = ''
softwareName = '1Password*'
checksum = ''
checksumType = 'sha256'
silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($env:chocolateyPackageName).$($env:chocolateyPackageVersion).MsiInstall.log`""
validExitCodes = @(0, 1641, 3010)
}

Install-ChocolateyPackage @packageArgs
Loading

0 comments on commit 2cc2e18

Please sign in to comment.