Skip to content

Commit

Permalink
Add Chocolatey package. (#402)
Browse files Browse the repository at this point in the history
* Add files for Chocolatey package for #370.
  • Loading branch information
Donald Morton authored Mar 3, 2021
1 parent ffee4cb commit a7323b7
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ package-linux32: ## Create Linux i386 system package
package-windows: ## Create Windows installer
@mkdir -p dist/pkg
makensis -DVERSION=$(COLLECTOR_VERSION) -DVERSION_SUFFIX=$(COLLECTOR_VERSION_SUFFIX) -DREVISION=$(COLLECTOR_REVISION) dist/recipe.nsi
dist/chocolatey/gensha.sh $(COLLECTOR_VERSION) $(COLLECTOR_REVISION) $(COLLECTOR_VERSION_SUFFIX)

package-tar: ## Create tar archive for all platforms
@mkdir -p dist/pkg
Expand Down
17 changes: 17 additions & 0 deletions dist/chocolatey/gensha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# gensha.sh - Generate sha256 file for Chocolatey package and update chocolateyinstall.ps1 with the correct version and checksum.

COLLECTOR_VERSION=$1
COLLECTOR_REVISION=$2
COLLECTOR_VERSION_SUFFIX=$3

if [[ ${COLLECTOR_VERSION_SUFFIX} == "-SNAPSHOT" ]]; then
COLLECTOR_CHECKSUM=$(sha256sum dist/pkg/graylog_sidecar_installer_${COLLECTOR_VERSION}-${COLLECTOR_REVISION}.SNAPSHOT.exe | cut -d" " -f1)
else
COLLECTOR_CHECKSUM=$(sha256sum dist/pkg/graylog_sidecar_installer_${COLLECTOR_VERSION}-${COLLECTOR_REVISION}.exe | cut -d" " -f1)
fi

sed -i "s/checksum = '.*'/checksum = '$COLLECTOR_CHECKSUM'/" dist/chocolatey/tools/chocolateyinstall.ps1
sed -i "s/url = '.*'/url = 'https:\/\/downloads.graylog.org\/releases\/graylog-collector-sidecar\/${COLLECTOR_VERSION}\/graylog_sidecar_installer_${COLLECTOR_VERSION}-${COLLECTOR_REVISION}.exe'/" dist/chocolatey/tools/chocolateyinstall.ps1

find dist/pkg -name "graylog_sidecar_installer*.exe" -exec /bin/bash -c "sha256sum {} | cut -d' ' -f1 > {}.sha256.txt" \;
29 changes: 29 additions & 0 deletions dist/chocolatey/graylog-sidecar.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>graylog-sidecar</id>
<version>$version$</version>
<packageSourceUrl>https://github.com/Graylog2/collector-sidecar</packageSourceUrl>
<title>Graylog Sidecar</title>
<authors>Donald Morton</authors>
<projectUrl>https://github.com/Graylog2/collector-sidecar</projectUrl>
<iconUrl>http://cdn.rawgit.com/collector-sidecar/master/images/graylog-icon.svg</iconUrl>
<licenseUrl>https://github.com/Graylog2/collector-sidecar/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/Graylog2/collector-sidecar</projectSourceUrl>
<docsUrl>https://docs.graylog.org/en/latest/pages/sidecar.html</docsUrl>
<bugTrackerUrl>https://github.com/Graylog2/collector-sidecar/issues</bugTrackerUrl>
<tags>graylog graylog-sidecar log</tags>
<summary>Manage log collectors through Graylog</summary>
<description>The Graylog Sidecar is a supervisor process for 3rd party log collectors like NXLog and filebeat. The Sidecar program is able to fetch and validate configuration files from a Graylog server for various log collectors. You can think of it like a centralized configuration and process management system for your log collectors.
## Install Arguments
To properly configure the sidecar, you'll need to pass in your **server url** and your **api token**.

choco install graylog-sidecar --install-arguments="'-SERVERURL=http://10.0.2.2:9000/api -APITOKEN=yourapitoken'"
</description>
<releaseNotes></releaseNotes>
</metadata>
<files>
<file src="tools/**" target="tools" />
</files>
</package>
11 changes: 11 additions & 0 deletions dist/chocolatey/tools/VERIFICATION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

This package is published by Graylog, Inc.

The sha256 checksum for any release can be found at the url below. Simply replace "VERSION" and "REVISION" with the appropriate parameters:
https://downloads.graylog.org/releases/graylog-collector-sidecar/VERSION/graylog_sidecar_installer_VERSION-REVISION.exe.sha256.txt

Example:
https://downloads.graylog.org/releases/graylog-collector-sidecar/1.0.3/graylog_sidecar_installer_1.0.3-1.exe.sha256.txt
20 changes: 20 additions & 0 deletions dist/chocolatey/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $toolsDir
fileType = 'EXE'
url = 'https://downloads.graylog.org/releases/graylog-collector-sidecar/1.0.2/graylog_sidecar_installer_1.0.2-1.exe'
softwareName = 'graylog-sidecar*'

# Checksums are now required as of 0.10.0.
# To determine checksums, you can get that from the original site if provided.
# You can also use checksum.exe (choco install checksum) and use it
# e.g. checksum -t sha256 -f path\to\file
checksum = 'e6eac94e512599ffb5860d29782d619c8a78fd5fd3b39f8023049cace0f7868a'
checksumType = 'sha256'
silentArgs = '/S'
}

Install-ChocolateyPackage @packageArgs
1 change: 1 addition & 0 deletions images/graylog-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions jenkins.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ pipeline
'''

s3Upload(workingDir:'dist/pkg', bucket:'graylog2-releases', path:"graylog2-releases/graylog-collector-sidecar/${TAG_NAME}", includePathPattern:'graylog*')

sh "docker run --rm -v $PWD:$PWD -w $PWD/dist/chocolatey torch/jenkins-mono-choco:latest pack --version ${TAG_NAME}"
}
}
post
Expand All @@ -126,6 +128,7 @@ pipeline
{
script
{
archiveArtifacts 'dist/pkg/*.nupkg'
cleanWs()
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
COLLECTOR_VERSION = 1.1.0
COLLECTOR_VERSION_SUFFIX = -SNAPSHOT
COLLECTOR_REVISION = 0
COLLECTOR_REVISION = 1

0 comments on commit a7323b7

Please sign in to comment.