bindown

package module
v2.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2020 License: MIT Imports: 19 Imported by: 0

README

bindown

godoc Go Report Card ci Coverage Status

bindown is a command-line utility to download, verify and install binary files. It is intended to be used in development and ci environments where it is important to guarantee the same version of the same binary is downloaded every time.

Installation

Using bootstrap-bindown.sh

This is the preferred method for ci or development environments. Each release contains a shell script bootstrap-bindown.sh that will download bindown for the current os. Place bootstrap-bindown.sh from the latest release in your project's repository. Don't forget to make it executable first (chmod +x bootstrap-bindown.sh on most systems). Then you can call bootstrap-bindown.sh before bindown in the projects bootstrap script or Makefile.

Usage
./bootstrap-bindown.sh -h
./bootstrap-bindown.sh: download the bindown binary

Usage: ./bootstrap-bindown.sh [-b bindir] [-d]
  -b sets bindir or installation directory, Defaults to ./bin
  -d turns on debug logging
Go get

If you happen to already have go installed on your system, you can install bindown with:

GO111MODULE=on go get -u github.com/willabides/bindown/v2/cmd/bindown 

Note the lowercase willabides. Pro tip: Your life will be easier with a lowercase GitHub username.

Config

bindown is configured with a yaml file. By default it uses a file named bindown.yml in the current directory.

Downloader values
os

required

The operating system this binary is built for. Common values are windows, darwin and linux. macos and osx are aliases for darwin.

arch

required

The system architecture this binary is build for. Common values are amd64, 386 and arm.

url

required

The url to download from. The url can point to either the binary itself or an archive containing the binary.

checksum

required

The sha256 hash of the download. Often projects will publish this in a checksums.txt file along with the downloads. You can get the value from there or run bindown config update-checksums <bin-name> to have bindown populate this automatically.

archive path

The path to the binary once the downloaded archive has been extracted. If the download is just the unarchived binary, this should just be the downloaded file name.

default: the binary name

Whether bindown should create a symlink instead of moving the binary to its final destination.

default: false

bin

What you want the final binary to be called if different from the downloader name.

default: the downloader name

Example
downloaders:
  golangci-lint:
  - os: darwin
    arch: amd64
    url: https://github.com/golangci/golangci-lint/releases/download/v1.21.0/golangci-lint-1.21.0-darwin-amd64.tar.gz
    checksum: 2b2713ec5007e67883aa501eebb81f22abfab0cf0909134ba90f60a066db3760
    archive_path: golangci-lint-1.21.0-darwin-amd64/golangci-lint
    link: true
  - os: linux
    arch: amd64
    url: https://github.com/golangci/golangci-lint/releases/download/v1.21.0/golangci-lint-1.21.0-linux-amd64.tar.gz
    checksum: 2c861f8dc56b560474aa27cab0c075991628cc01af3451e27ac82f5d10d5106b
    archive_path: golangci-lint-1.21.0-linux-amd64/golangci-lint
    link: true
  - os: windows
    arch: amd64
    url: https://github.com/golangci/golangci-lint/releases/download/v1.21.0/golangci-lint-1.21.0-windows-amd64.zip
    checksum: 2e40ded7adcf11e59013cb15c24438b15a86526ca241edfcfdf1abd73a5280a8
    archive_path: golangci-lint-1.21.0-windows-amd64/golangci-lint.exe
    link: true

Usage

Usage: bindown <command>

Flags:
  --help                                     Show context-sensitive help.
  --configfile="bindown.yml|bindown.json"    file with bindown config
  --cellar-dir=STRING                        directory where downloads will be cached

Commands:
  version

  download <target-file>
    download a bin

  config format
    formats the config file

  config update-checksums <target-file>
    name of the binary to update

  config validate <bin>
    validate that downloads work

  config install-completions
    install shell completions

Run "bindown <command> --help" for more information on a command.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Downloaders map[string][]*Downloader `json:"downloaders,omitempty" yaml:"downloaders"`
}

Config is downloaders configuration

func (*Config) Downloader

func (c *Config) Downloader(binary, os, arch string) *Downloader

Downloader returns a Downloader for the given binary, os and arch.

type ConfigFile added in v2.2.0

type ConfigFile struct {
	Config
	// contains filtered or unexported fields
}

ConfigFile represents a config file

func LoadConfigFile

func LoadConfigFile(file string) (*ConfigFile, error)

LoadConfigFile loads a config file

func (*ConfigFile) Write added in v2.2.0

func (c *ConfigFile) Write() error

type Downloader

type Downloader struct {
	OS          string `json:"os"`
	Arch        string `json:"arch"`
	URL         string `json:"url"`
	Checksum    string `json:"checksum,omitempty" yaml:",omitempty"`
	ArchivePath string `json:"archive_path,omitempty" yaml:"archive_path,omitempty"`
	Link        bool   `json:"link,omitempty" yaml:",omitempty"`
	BinName     string `json:"bin,omitempty" yaml:"bin,omitempty"`

	// Deprecated: use ArchivePath
	MoveFrom string `json:"move-from,omitempty" yaml:"move-from,omitempty"`

	// Deprecated: use ArchivePath and Link
	LinkSource string `json:"symlink,omitempty" yaml:"symlink,omitempty"`
}

Downloader downloads a binary

func (*Downloader) Install

func (d *Downloader) Install(opts InstallOpts) error

Install downloads and installs a bin

func (*Downloader) UpdateChecksum

func (d *Downloader) UpdateChecksum(opts UpdateChecksumOpts) error

UpdateChecksum updates the checksum based on a fresh download

type InstallOpts

type InstallOpts struct {
	// DownloaderName is the downloader's key from the config file
	DownloaderName string
	// CellarDir is the directory where downloads and extractions will be placed.  Default is a <TargetDir>/.bindown
	CellarDir string
	// TargetDir is the directory where the executable should end up
	TargetDir string
	// Force - whether to force the install even if it already exists
	Force bool
}

InstallOpts options for Install

type UpdateChecksumOpts

type UpdateChecksumOpts struct {
	// DownloaderName is the downloader's key from the config file
	DownloaderName string
	// CellarDir is the directory where downloads and extractions will be placed.  Default is a <TargetDir>/.bindown
	CellarDir string
	// TargetDir is the directory where the executable should end up
	TargetDir string
}

UpdateChecksumOpts options for UpdateChecksum

Directories

Path Synopsis
cmd
internal
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL