eget

repository·master·Indexed 21 days ago

https://github.com/zyedidia/eget

A tool for downloading and extracting pre-built binaries from GitHub releases. It automates asset selection based on the user's system, handles extraction from formats like .tar.gz and .zip, and performs checksum verification. Eget supports configuration via TOML, GitHub API authentication to avoid rate limiting, and an --upgrade-only mode to update binaries if a newer release is available.

Tokens
9.9K
Snippets
23
Records
56
Agent score
83%

What's inside eget

  1. Configure GitHub API Authentication

    master

    To avoid GitHub API rate limiting (60 requests/hour for unauthenticated users), you can provide a personal access token. This increases your limit to 5,000 requests per hour.

    Methods to provide a token:

    1. Environment Variable: Set GITHUB_TOKEN or EGET_GITHUB_TOKEN. If both are set, EGET_GITHUB_TOKEN takes precedence.
    2. Config File: Use the github_token key in the [global] section of your ~/.eget.toml.
    3. File Reference: Use the @/path/to/file syntax as the token value.

    Example via Environment Variable

    export EGET_GITHUB_TOKEN=ghp_1234567890
    eget zyedidia/micro
  2. How Eget handles checksum verification

    master

    Eget attempts to verify the integrity of downloaded assets using SHA-256.

    • Automatic Verification: If an asset named xxx is downloaded and a file named xxx.sha256 or xxx.sha256sum is present in the same location, Eget will automatically verify the asset against that checksum.
    • Manual Control: Verification occurs if the user provides a checksum or explicitly asks Eget to print the checksum.
  3. Supported sources for Eget

    master

    Eget can retrieve binaries from the following sources:

    • GitHub Releases: Searching for assets within a repository's releases.
    • Direct URLs: If a direct URL is provided, Eget skips detection and downloads directly from that URL.
    • Local Files: If a local file path is provided, Eget skips detection and performs extraction directly from the local file.
  4. How Eget selects files during extraction

    master

    When extracting an asset, Eget follows these rules to determine which file to use:

    1. Requested File: If a specific file is requested by the user, that file is extracted.
    2. Executable Priority: If no file is requested, Eget looks for files with executable permissions. It prioritizes files that share the same name as the repository.
    3. User Prompt: If multiple executable files exist and none match the repository name, Eget will prompt the user to choose.
    4. Windows Compatibility: Files ending in .exe are always treated as executables, regardless of their internal permission settings within the archive.
    5. Single Files: If the asset is not an archive, it is treated as a single file and marked as executable automatically.
  5. Verifying SHA-256 checksums in Eget

    master

    Eget provides several ways to ensure the integrity of downloaded binaries:

    1. Automatic Verification: If Eget finds a matching asset in the GitHub release ending in .sha256 or .sha256sum, it will automatically verify the SHA-256 checksum of your download.
    2. Manual Verification: You can manually provide a checksum using the --sha256 or --verify-sha256 options.
  6. How Eget handles binary upgrades

    master

    Eget is generally stateless across invocations. However, it can perform upgrades using the --upgrade-only option.

    When using --upgrade-only, Eget checks the EGET_BIN environment variable to locate the existing binary on your file system. It will then compare the version on your system with the latest GitHub release and only download the new version if the GitHub release is newer.

  7. How Eget works: The four phases of installation

    master

    Eget operates through a four-phase lifecycle to install pre-built binaries:

    1. Find: Determines a list of potential assets. If a GitHub repository identifier is provided, it queries api.github.com. If a direct URL is provided, it uses that URL.
    2. Detect: Identifies the correct asset for the target system by matching the asset's filename against known OS and architecture regular expressions (case-insensitive).
    3. Verify: Verifies the asset's checksum. If a checksum file like xxx.sha256 or xxx.sha256sum exists alongside the asset, Eget automatically performs SHA-256 verification.
    4. Extract: Detects the archive type and extracts the relevant file. If no specific file is requested, Eget looks for executable files, prioritizing those matching the repository name.
  8. How Eget differs from a package manager

    master

    Eget is not a full-featured package manager. It is a tool designed specifically to download pre-built binaries uploaded to GitHub releases.

    Key differences include:

    • No Central Registry: It does not maintain a central list of packages.
    • No Dependency Management: It does not resolve or install dependencies.
    • No State/Manifest: It does not maintain a manifest of installed binaries or a registry for uninstallation.
    • No Automatic System Installation: It does not place executables in system-wide directories (like /usr/local/bin) unless explicitly instructed to do so.

    Eget is best suited for software that is distributed as a single binary (e.g., tools written in Go, Rust, or Haskell).

  9. Installing specific projects from monorepos using --tag

    master

    If a GitHub repository contains releases for multiple different projects (a monorepo), you can use the --tag TAG option to target a specific project.

    Eget will look for the latest release with a tag that contains the provided TAG. For this to work effectively, ensure that releases for each project are given tags that include that project's name.

  10. Use Eget to install binaries

    master

    Eget downloads and extracts pre-built binaries from GitHub releases. The TARGET argument can be:

    • A GitHub repository (user/repo).
    • A direct URL.
    • A local file.

    Common Usage Patterns

    Basic installation:

    eget junegunn/fzf

    Install to a specific directory:

    eget jgm/pandoc --to /usr/local/bin

    Target a specific tag or pre-release:

    eget zyedidia/micro --tag nightly
    eget <repo> --pre-release

    Filter assets using globs or strings:

    eget ogham/exa --asset ^musl
    eget --all --file '*' ActivityWatch/activitywatch

    Specify target system:

    eget --system darwin/amd64 sharkdp/fd
    eget junegunn/fzf
  11. Install prebuilt binaries with eget

    master

    Eget downloads and extracts prebuilt binaries from GitHub releases, direct URLs, or local files. By default, it searches for a suitable binary for your current system and extracts it to the current directory. If the environment variable EGET_BIN is set, it uses that directory instead.

    Target Formats:

    • GitHub Repository: user/repo (searches release assets).
    • Direct URL: Downloads and extracts directly from the URL.
    • Local File: Extracts directly from the local file.

    Checksum Verification: If an asset named xxx has a corresponding xxx.sha256 or xxx.sha256sum file in the release, Eget automatically verifies the SHA-256 checksum and aborts if they do not match.

    eget zyedidia/micro
  12. Install Eget

    master

    You can install Eget using several methods depending on your operating system and preference:

    Quick-install script

    Run the following commands to download and execute the installer. It is recommended to verify the checksum of the script before running it.

    curl -o eget.sh https://zyedidia.github.io/eget.sh
    shasum -a 256 eget.sh # verify with hash below
    bash eget.sh

    Note: The sha256 checksum for the script is 0e64b8a3c13f531da005096cc364ac77835bda54276fedef6c62f3dbdc1ee919.

    Package Managers

    • Homebrew (macOS/Linux): brew install eget
    • Chocolatey (Windows): choco install eget

    From Source

    • Go: go install github.com/zyedidia/eget@latest
    • Manual Build:
      git clone https://github.com/zyedidia/eget
      cd eget
      make build
    curl -o eget.sh https://zyedidia.github.io/eget.sh
    shasum -a 256 eget.sh
    bash eget.sh