Apt-bundle: apt 的 brew bundle
Apt-bundle: brew bundle for apt

原始链接: https://github.com/apt-bundle/apt-bundle

## apt-bundle:Debian 系统的声明式包管理 apt-bundle 是一个用于在基于 Debian 的系统上管理 apt 包的工具,灵感来自 Brewfile 和 Brew Bundle。它允许您在简单的 `Aptfile` 中定义系统依赖项,并使用单个命令安装它们,从而确保可重复且可共享的配置。 主要功能包括:声明式包定义、幂等操作(可安全重复运行)、仓库和密钥管理(PPAs、自定义仓库、GPG 密钥)以及版本锁定。它提供了一个简单的 CLI,用于安装、检查和从现有系统生成 `Aptfile`。 安装可以通过提供的脚本或手动下载 `.deb` 包快速完成。`Aptfile` 使用简单的格式来指定包、PPAs、仓库和密钥。 apt-bundle 使用 Go 构建,静态链接以实现可移植性,并设计为小尺寸。它非常适合自动化系统设置、管理 Dockerfile 依赖项以及确保一致的环境。完整的文档和示例可在项目网站上找到。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 工作 | 提交 登录 Apt-bundle: apt 的 brew bundle (github.com/apt-bundle) 4 分,作者 sadeshmukh,2 小时前 | 隐藏 | 过去 | 收藏 | 3 条评论 pamcake 17 分钟前 | 下一个 [–] 非常喜欢!起初感觉像魔法,但现在我需要处理一大堆 Aptfile… 目前正在使用下一代工具 apt-bundle-bunch 来解决这个问题,它具有简单的声明式格式来管理你的 apt-bundle 项目,使用 Aptbundlefile。它已经非常适合代理,并且我正在与 Claude 合作,创建一个 curl|sh 安装程序用于 v1. replylifetimerubyist 18 分钟前 | 上一个 [–] 人们为了避免编写 bash 脚本想出各种办法。 migmaldo 7 分钟前 | 父评论 [–] 我希望我能点更多赞。 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

A declarative, Brewfile-like wrapper for apt, inspired by brew bundle — not a full config management system.

📚 Full Documentation | Installation | Usage

apt-bundle provides a simple, declarative, and shareable way to manage apt packages and repositories on Debian-based systems. Define your system dependencies in an Aptfile and install them with a single command.

  • 📦 Declarative Package Management: Define packages in a simple text file
  • 🔄 Idempotent Operations: Safe to run multiple times
  • 🔑 Repository & Key Management: Add PPAs, custom repositories, and GPG keys
  • 📝 Version Pinning: Install specific package versions
  • 🚀 Simple CLI: Easy-to-use command-line interface

Quick Install (Recommended)

Install the latest release using the install script:

curl -fsSL https://raw.githubusercontent.com/apt-bundle/apt-bundle/main/install.sh | sudo bash

Manual Installation from .deb Package

Download and install the appropriate .deb package for your architecture:

# Detect your architecture
ARCH=$(dpkg --print-architecture)

# Download latest release (replace v1.0.0 with actual version)
VERSION=$(curl -s https://api.github.com/repos/apt-bundle/apt-bundle/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -LO https://github.com/apt-bundle/apt-bundle/releases/download/${VERSION}/apt-bundle_${VERSION#v}_linux_${ARCH}.deb

# Install
sudo dpkg -i apt-bundle_${VERSION#v}_linux_${ARCH}.deb
sudo apt-get install -f  # Install dependencies if needed
# Clone the repository
git clone https://github.com/apt-bundle/apt-bundle.git
cd apt-bundle

# Build and install
make build
sudo make install

The binary will be installed to /usr/local/bin/apt-bundle.

# Build the binary
make build

# The binary will be in build/apt-bundle
./build/apt-bundle --help
# Install packages from Aptfile (default: ./Aptfile)
sudo apt-bundle

# or explicitly
sudo apt-bundle install

# Use a different Aptfile
sudo apt-bundle --file /path/to/Aptfile

# Skip updating package lists (useful in CI/CD)
sudo apt-bundle --no-update

# Check if packages are installed (no root required)
apt-bundle check

# Generate an Aptfile from current system
apt-bundle dump > Aptfile

The Aptfile is a simple line-oriented text file with the following directives:

# Install latest version
apt vim
apt curl
apt git

# Install specific version
apt "nano=2.9.3-2"
ppa ppa:ondrej/php
apt php8.1
# Add GPG key
key https://download.docker.com/linux/ubuntu/gpg

# Add repository
deb "[arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

# Install packages from the repository
apt docker-ce
apt docker-ce-cli
# Core development tools
apt build-essential
apt curl
apt git
apt vim
apt htop

# Specific version
apt "nano=2.9.3-2"

# PHP from PPA
ppa ppa:ondrej/php
apt php8.1
apt php8.1-cli
apt php8.1-fpm

# Docker
key https://download.docker.com/linux/ubuntu/gpg
deb "[arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt docker-ce
apt docker-ce-cli
apt containerd.io
# Clone project
git clone https://github.com/myorg/myproject.git
cd myproject

# Install all system dependencies
sudo apt-bundle

Use apt-bundle in your Dockerfiles to manage system dependencies declaratively. See the examples directory for complete working examples:

# On primary workstation
apt-bundle dump > Aptfile

# On new laptop
sudo apt-bundle
apt-bundle/
├── cmd/
│   └── apt-bundle/       # Main entry point
├── internal/
│   ├── apt/              # APT interactions (packages, repos, keys)
│   ├── aptfile/          # Aptfile parsing
│   └── commands/         # CLI commands (install, dump, check)
├── examples/             # Docker examples by installation method
├── docs/                 # Documentation site and APT repository
├── specs/                # Requirements and technical specifications
├── Makefile              # Build automation
└── go.mod                # Go module definition
# Format code
make fmt

# Run static analysis
make vet

# Run tests
make test

# Build
make build

# Install locally for testing
sudo make install
  • Go 1.21 or later
  • Debian/Ubuntu-based system (for running the tool)

The project uses a VERSION file for version management:

  • The VERSION file contains the major.minor version (e.g., 1.0)
  • Patch versions are automatically incremented on each release
  • To update the major or minor version, edit the VERSION file
  • Releases are automatically created when code is merged to the main branch
  • Self-contained: The Go binary is statically linked and doesn't require external .so or .dll files
  • CGO_ENABLED=0: Ensures pure Go compilation without C dependencies
  • Small size: Compiled with -ldflags="-s -w" to strip debug symbols

📚 Full Documentation Site - Complete user guide, developer documentation, and API reference

For internal specifications:

Contributions are welcome! Please feel free to submit a Pull Request.

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

联系我们 contact @ memedata.com