diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b74a631..cc72330 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,10 @@ on: push: paths: - '**/*.sh' + - '.github/workflows/**' - 'bootstrap' - 'arch/**' + - 'debian/**' - 'ubuntu/**' - 'pop_os/**' - 'fedora/**' @@ -13,8 +15,10 @@ on: pull_request: paths: - '**/*.sh' + - '.github/workflows/**' - 'bootstrap' - 'arch/**' + - 'debian/**' - 'ubuntu/**' - 'pop_os/**' - 'fedora/**' diff --git a/.github/workflows/test-debian.yml b/.github/workflows/test-debian.yml new file mode 100644 index 0000000..68447df --- /dev/null +++ b/.github/workflows/test-debian.yml @@ -0,0 +1,64 @@ +name: Test Debian Bootstrap + +on: + push: + branches: [ main ] + paths: + - 'debian/**' + - 'generic/**' + - 'bootstrap' + - 'test/**' + - '.github/workflows/test-debian.yml' + pull_request: + branches: [ main ] + paths: + - 'debian/**' + - 'generic/**' + - 'bootstrap' + - 'test/**' + workflow_dispatch: + +jobs: + shellcheck: + name: ShellCheck Linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Run ShellCheck + run: | + sudo apt-get update && sudo apt-get install -y shellcheck + find debian/ generic/ -type f ! -name "*.md" -exec shellcheck -x --severity=error {} \; + shellcheck -x --severity=error bootstrap + + docker-test: + name: Docker Test (Debian ${{ matrix.debian-version }}) + runs-on: ubuntu-latest + strategy: + matrix: + debian-version: ['bookworm', 'trixie'] + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: Build test image + run: | + docker build \ + --build-arg DEBIAN_VERSION=${{ matrix.debian-version }} \ + -f test/docker/Dockerfile.debian-noninteractive \ + -t debian-bootstrap-test:${{ matrix.debian-version }} \ + . + + - name: Run installer tests + run: | + docker run --rm debian-bootstrap-test:${{ matrix.debian-version }} + + - name: Test syntax + run: | + docker run --rm debian-bootstrap-test:${{ matrix.debian-version }} bash -c " + cd /home/testuser/linux-bootstrap && \ + bash -n debian/bootstrap && \ + bash -n debian/install-packages && \ + echo 'All Debian syntax checks passed' + " \ No newline at end of file diff --git a/Makefile b/Makefile index 665827c..ac933aa 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ -.PHONY: help test test-auto test-interactive test-all test-syntax lint clean build-test-images docker-clean shellcheck +.PHONY: help test test-auto test-interactive test-all test-debian test-debian-all test-syntax lint clean build-test-images build-test-images-debian docker-clean shellcheck # Default target .DEFAULT_GOAL := help # Ubuntu versions to test UBUNTU_VERSIONS := 24.04 25.10 +DEBIAN_VERSIONS := bookworm trixie help: ## Show this help message @echo "Linux Bootstrap Testing Makefile" @@ -25,6 +26,12 @@ test-interactive: ## Start interactive Docker container for manual testing test-all: ## Run tests on all Ubuntu versions (24.04, 25.10) @./test/run-tests.sh all +test-debian: ## Run automated tests on Debian bookworm + @./test/run-tests.sh debian + +test-debian-all: ## Run tests on all Debian versions (bookworm, trixie) + @./test/run-tests.sh debian-all + test-syntax: ## Run syntax checks on all bash scripts @./test/run-tests.sh syntax @@ -34,6 +41,7 @@ shellcheck: ## Run shellcheck on all scripts @echo "Running shellcheck..." @if command -v shellcheck >/dev/null 2>&1; then \ shellcheck -x --severity=error bootstrap; \ + find debian/ -type f -exec shellcheck -x --severity=error {} \+; \ shellcheck -x --severity=error ubuntu/bootstrap; \ find ubuntu/ -type f -name 'install-*' -exec shellcheck -x --severity=error {} \+; \ find generic/ -type f -exec shellcheck -x --severity=error {} \+; \ @@ -53,13 +61,24 @@ build-test-images: ## Build Docker test images for all Ubuntu versions .; \ done +build-test-images-debian: ## Build Docker test images for all Debian versions + @echo "Building test images for Debian versions: $(DEBIAN_VERSIONS)" + @for version in $(DEBIAN_VERSIONS); do \ + echo "Building Debian $$version..."; \ + docker build \ + --build-arg DEBIAN_VERSION=$$version \ + -f test/docker/Dockerfile.debian-noninteractive \ + -t debian-bootstrap-test:$$version \ + .; \ + done + clean: docker-clean ## Clean up all test artifacts docker-clean: ## Remove all test Docker images @echo "Cleaning up Docker test images..." - @docker images | grep ubuntu-bootstrap-test | awk '{print $$3}' | xargs -r docker rmi || true + @docker images | grep -E 'ubuntu-bootstrap-test|debian-bootstrap-test' | awk '{print $$3}' | xargs -r docker rmi || true @echo "Cleanup complete" -ci: test-syntax test-all ## Run full CI test suite (syntax + all versions) +ci: test-syntax test-all test-debian-all ## Run full CI test suite (syntax + all versions) -quick: test-syntax test-auto ## Quick check: syntax + single version test +quick: test-syntax test-auto test-debian ## Quick check: syntax + single-version Ubuntu and Debian tests diff --git a/README.md b/README.md index f7aa939..953f75d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ detects the distribution and runs the appropriate set of scripts. ## Supported Distributions - Arch +- Debian - Fedora - Pop!_OS - Ubuntu @@ -30,9 +31,19 @@ sudo dnf install curl && \ source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/bootstrap) ``` -## Ubuntu or Pop!_OS +## Debian, Ubuntu, or Pop!_OS -To perform a full bootstrap from a clean Ubuntu or Pop!_OS install do: +On Debian, add your current user to the `sudo` group first, since Debian does not do this by default for all installs: + +```sh +su - +/usr/sbin/usermod -aG sudo "$USER" +exit +``` + +Then log out and log back in before running the bootstrap command. + +To perform a full bootstrap from a clean Debian, Ubuntu, or Pop!_OS install do: ```sh sudo apt-get update && sudo apt-get install -y curl git && \ diff --git a/bootstrap b/bootstrap index fc9d57b..24abc87 100755 --- a/bootstrap +++ b/bootstrap @@ -18,6 +18,9 @@ then elif [[ "$ID" == "arch" ]] then source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/arch/bootstrap) +elif [[ "$ID" == "debian" ]] +then + source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/debian/bootstrap) else echo "Unsupported Linux distribution." fi \ No newline at end of file diff --git a/debian/bootstrap b/debian/bootstrap new file mode 100755 index 0000000..f708f24 --- /dev/null +++ b/debian/bootstrap @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Performs a full bootstrap of Debian, running all of the other scripts +# in this directory. +# Usage: +# source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/debian/bootstrap) + +# Check if we're running on Debian +source /etc/os-release +if [[ "$ID" != "debian" ]] +then + echo "Not running Debian, exiting." + exit 1 +fi + +# Create an ssh key +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/generic/create-ssh-key) + +# Install packages +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/debian/install-packages) + +# Desktop packages +read -p "Install desktop apps? " -n 1 -r +echo +if [[ $REPLY =~ ^[Yy]$ ]] +then + source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/debian/install-desktop-packages) + + read -p "Install makemkv? " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]] + then + source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/debian/install-makemkv) + fi +fi + +# Zsh customizations +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/generic/install-zsh-customizations) + +# Create directories +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/generic/create-directories) + +# Install JetBrains Toolbox +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/generic/install-jetbrains-tools) + +# Authenticate to GitHub +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/generic/github-auth-login) + +# Add user to groups +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/generic/add-user-to-groups) diff --git a/debian/install-desktop-packages b/debian/install-desktop-packages new file mode 100755 index 0000000..ecfab28 --- /dev/null +++ b/debian/install-desktop-packages @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/debian/install-desktop-packages) + +# Install Microsoft repo for VS Code +curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg +sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/ +rm -f microsoft.gpg + +sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list' + +# Install Griffo repo for various packages +curl -sS https://debian.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/debian.griffo.io.gpg + +echo "deb https://debian.griffo.io/apt $(lsb_release -sc 2>/dev/null) main" | sudo tee /etc/apt/sources.list.d/debian.griffo.io.list + +# Update package repos +sudo apt-get update + +# Install graphical desktop packages +sudo apt-get install -y \ +audacity \ +code \ +darktable \ +evolution \ +evolution-ews \ +fonts-cascadia-code \ +fonts-firacode \ +ghostty \ +gimp \ +gnome-browser-connector \ +gnome-shell-extension-caffeine \ +gnome-shell-extension-dashtodock \ +gnome-shell-extension-freon \ +gnome-tweaks \ +handbrake \ +kdiff3 \ +libavcodec-extra \ +libfontconfig1 \ +mesa-utils \ +obs-studio \ +pipx \ +xclip + +# Install Gnome extension tooling and selected extensions +pipx install gnome-extensions-cli --system-site-packages +"$HOME"/.local/bin/gext install clipboard-history@alexsaveau.dev +"$HOME"/.local/bin/gext enable clipboard-history@alexsaveau.dev + +# Move window buttons to the left +if command -v gsettings >/dev/null 2>&1; then + gsettings get org.gnome.desktop.wm.preferences button-layout || true + gsettings set org.gnome.desktop.wm.preferences button-layout close,minimize,maximize: || true +fi diff --git a/debian/install-makemkv b/debian/install-makemkv new file mode 100755 index 0000000..7d8cd63 --- /dev/null +++ b/debian/install-makemkv @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/ubuntu/install-makemkv) + +# Install makemkv +if ! type makemkv +then + MAKEMKV_VERSION="1.18.2" + mkdir -p /tmp/makemkv-build + pushd /tmp/makemkv-build || exit + + curl -O "https://www.makemkv.com/download/makemkv-bin-$MAKEMKV_VERSION.tar.gz" + curl -O "https://www.makemkv.com/download/makemkv-oss-$MAKEMKV_VERSION.tar.gz" + curl -O https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 + + tar xzvf "makemkv-bin-$MAKEMKV_VERSION.tar.gz" + tar xzvf "makemkv-oss-$MAKEMKV_VERSION.tar.gz" + tar xjvf ffmpeg-snapshot.tar.bz2 + + popd || exit + + sudo apt-get install -y \ + build-essential \ + pkg-config \ + libc6-dev \ + libssl-dev \ + libexpat1-dev \ + libavcodec-dev \ + libgl1-mesa-dev \ + qtbase5-dev \ + zlib1g-dev \ + yasm \ + libfdk-aac-dev \ + nasm + + pushd /tmp/makemkv-build/ffmpeg || exit + ./configure --prefix=/tmp/ffmpeg --enable-static --disable-shared --enable-pic --enable-libfdk-aac + make install + popd || exit + + pushd "/tmp/makemkv-build/makemkv-oss-$MAKEMKV_VERSION" || exit + PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ./configure + make + sudo make install + popd || exit + + pushd "/tmp/makemkv-build/makemkv-bin-$MAKEMKV_VERSION" || exit + make + sudo make install + popd || exit +fi diff --git a/debian/install-packages b/debian/install-packages new file mode 100755 index 0000000..06d653a --- /dev/null +++ b/debian/install-packages @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/debian/install-packages) + +# Update package repos +sudo apt-get update + +# Update packages +sudo apt-get upgrade -y + +# Install essential packages +sudo apt-get install -y \ +apt-transport-https \ +bat \ +btop \ +curl \ +detox \ +docker.io \ +eza \ +ffmpeg \ +fzf \ +gh \ +git \ +gpg \ +lazygit \ +libfuse2 \ +lm-sensors \ +lsb-release \ +ncat \ +neovim \ +nmap \ +pipx \ +pv \ +pwgen \ +ranger \ +rclone \ +renameutils \ +tmux \ +wget \ +yadm \ +zoxide \ +zsh \ +zsh-doc + +pipx install mnamer + +# Install latest mdview .deb from the GitHub API (amd64) +MDVIEW_DEB_URL=$(curl -fsSL "https://api.github.com/repos/mapitman/mdview/releases/latest" | grep '"browser_download_url"' | grep 'amd64.*\.deb' | head -1 | cut -d'"' -f4) +if [ -n "$MDVIEW_DEB_URL" ]; then + MDVIEW_TMP_DEB="$(mktemp --suffix=.deb)" + wget -q "$MDVIEW_DEB_URL" -O "$MDVIEW_TMP_DEB" + sudo apt-get install -y "$MDVIEW_TMP_DEB" + rm -f "$MDVIEW_TMP_DEB" +else + echo "mdview: unable to determine latest .deb URL" >&2 +fi + +# Install Catppuccin theme for tmux +source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/generic/install-tmux-catppuccin-theme) diff --git a/test/README.md b/test/README.md index 3082c4b..047e2d8 100644 --- a/test/README.md +++ b/test/README.md @@ -1,195 +1,107 @@ -# Testing Strategy for Ubuntu Bootstrap Scripts +# Testing Strategy for Bootstrap Scripts -This directory contains automated testing infrastructure for the Ubuntu bootstrap scripts using Docker and QEMU. +This directory contains automated testing infrastructure for the Ubuntu and Debian bootstrap scripts using Docker and QEMU. ## Quick Start -### Option 1: Docker (Recommended for Quick Testing) +### Option 1: Docker -Docker provides fast, lightweight testing ideal for package installation validation. +Docker provides fast, lightweight testing for package installation validation. + +### Ubuntu interactive testing -**Interactive Testing:** ```bash -# Build the test image docker build -f test/docker/Dockerfile.ubuntu -t ubuntu-bootstrap-test . - -# Run interactively to manually test scripts docker run -it --rm ubuntu-bootstrap-test +``` -# Inside the container, test individual scripts: +Inside the container: + +```bash cd linux-bootstrap bash ubuntu/install-essential-packages ``` -**Automated Testing:** -```bash -# Build and run non-interactive tests -docker build -f test/docker/Dockerfile.ubuntu-noninteractive -t ubuntu-bootstrap-test-auto . -docker run --rm ubuntu-bootstrap-test-auto -``` +### Ubuntu automated testing -**Test Different Ubuntu Versions:** ```bash -# Ubuntu 22.04 LTS -docker build --build-arg UBUNTU_VERSION=22.04 -f test/docker/Dockerfile.ubuntu -t ubuntu-bootstrap-test:22.04 . - -# Ubuntu 24.04 LTS -docker build --build-arg UBUNTU_VERSION=24.04 -f test/docker/Dockerfile.ubuntu -t ubuntu-bootstrap-test:24.04 . +docker build -f test/docker/Dockerfile.ubuntu-noninteractive -t ubuntu-bootstrap-test:auto . +docker run --rm ubuntu-bootstrap-test:auto ``` -### Option 2: QEMU (For Full System Testing) - -QEMU provides a complete VM environment for testing system-level changes that Docker can't replicate (systemd, kernel modules, etc.). +### Debian automated testing ```bash -# See test/qemu/README.md for QEMU setup instructions +docker build -f test/docker/Dockerfile.debian-noninteractive -t debian-bootstrap-test:auto . +docker run --rm debian-bootstrap-test:auto ``` -## Testing Approaches - -### 1. Unit Testing (Individual Scripts) - -Test each script independently: +### Versioned test images ```bash -docker run -it --rm ubuntu-bootstrap-test bash -c " - cd linux-bootstrap && \ - bash ubuntu/install-essential-packages && \ - echo 'Essential packages installed successfully' -" +# Ubuntu +docker build --build-arg UBUNTU_VERSION=24.04 -f test/docker/Dockerfile.ubuntu-noninteractive -t ubuntu-bootstrap-test:24.04 . +docker build --build-arg UBUNTU_VERSION=25.10 -f test/docker/Dockerfile.ubuntu-noninteractive -t ubuntu-bootstrap-test:25.10 . + +# Debian +docker build --build-arg DEBIAN_VERSION=bookworm -f test/docker/Dockerfile.debian-noninteractive -t debian-bootstrap-test:bookworm . +docker build --build-arg DEBIAN_VERSION=trixie -f test/docker/Dockerfile.debian-noninteractive -t debian-bootstrap-test:trixie . ``` -### 2. Integration Testing (Full Bootstrap) +### Option 2: QEMU -Test the complete bootstrap flow (requires handling interactive prompts): +QEMU provides a full VM environment for testing system-level changes that Docker cannot replicate. ```bash -# Create a script with automated responses -cat > test-full-bootstrap.sh << 'EOF' -#!/bin/bash -# Simulate user responses: n for dev, n for desktop, n for media, n for optical -echo -e "n\nn\nn\nn" | bash ubuntu/bootstrap -EOF - -docker run -it --rm -v $(pwd)/test-full-bootstrap.sh:/tmp/test.sh ubuntu-bootstrap-test bash /tmp/test.sh +# See test/qemu/README.md for setup instructions ``` -### 3. GitHub Actions CI/CD - -Add `.github/workflows/test-ubuntu.yml` to automatically test on every push: - -```yaml -name: Test Ubuntu Bootstrap - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - ubuntu-version: ['20.04', '22.04', '24.04'] - - steps: - - uses: actions/checkout@v3 - - - name: Build test image - run: | - docker build \ - --build-arg UBUNTU_VERSION=${{ matrix.ubuntu-version }} \ - -f test/docker/Dockerfile.ubuntu-noninteractive \ - -t ubuntu-bootstrap-test . - - - name: Run tests - run: docker run --rm ubuntu-bootstrap-test -``` +## Local Commands -## Docker vs QEMU: When to Use Each +Use the wrapper script: -| Feature | Docker | QEMU | -|---------|--------|------| -| **Speed** | Fast (seconds) | Slow (minutes) | -| **Isolation** | Process-level | Full VM | -| **Systemd** | Limited support | Full support | -| **Kernel Modules** | Host kernel only | Full kernel | -| **Use Case** | Package installation testing | Full system configuration | -| **CI/CD** | ✅ Ideal | ❌ Too slow | +```bash +./test/run-tests.sh auto +./test/run-tests.sh all +./test/run-tests.sh debian +./test/run-tests.sh debian-all +./test/run-tests.sh syntax +``` -**Recommendation:** -- Use **Docker** for 95% of testing (package installs, script syntax, basic functionality) -- Use **QEMU** only when testing systemd services, kernel modules, or boot configuration +Or use the Makefile: -## Limitations and Workarounds +```bash +make test +make test-all +make test-debian +make test-debian-all +make test-syntax +``` -### Docker Limitations +## CI Workflows -1. **Interactive Prompts**: Scripts with `read -p` need automation or modification - - **Workaround**: Use `echo` piping or create non-interactive variants - -2. **Systemd**: Some systemd operations won't work in Docker - - **Workaround**: Mock systemd commands or skip in tests - -3. **Privileged Operations**: Some hardware/kernel operations unavailable - - **Workaround**: Use `--privileged` flag or test in QEMU +The repository includes dedicated distro test workflows: -### Testing Interactive Scripts +- `.github/workflows/test-ubuntu.yml` +- `.github/workflows/test-debian.yml` -For scripts with prompts, create test wrappers: +They build Docker images and run the non-interactive installer tests for supported Ubuntu and Debian versions. -```bash -# Automatically answer "yes" to all prompts -yes | bash ubuntu/bootstrap +## Limitations -# Provide specific answers -echo -e "y\nn\ny" | bash ubuntu/bootstrap -``` +Docker is suitable for package-installation validation and syntax checks, but not for full workstation bootstrap behavior that depends on interactive auth flows or full init/system services. -Or modify scripts to support environment variables: +For example, Debian CI tests target `debian/install-packages` rather than `debian/bootstrap`, because the full bootstrap sources interactive helpers such as SSH key generation and GitHub auth. -```bash -# In the script: -if [[ -n "$CI" ]]; then - # Non-interactive mode - REPLY="n" -else - read -p "Install development tools? " -n 1 -r - echo -fi -``` +## Recommended Workflow -## Recommended Testing Workflow - -1. **Local Development**: - ```bash - # Quick syntax check - bash -n ubuntu/bootstrap - shellcheck ubuntu/bootstrap - - # Test in Docker - docker build -f test/docker/Dockerfile.ubuntu -t ubuntu-bootstrap-test . - docker run -it --rm ubuntu-bootstrap-test - ``` - -2. **Before Commit**: - ```bash - # Run automated tests - docker build -f test/docker/Dockerfile.ubuntu-noninteractive -t test . - docker run --rm test - ``` - -3. **CI Pipeline**: - - Automated Docker tests on every push - - Test multiple Ubuntu versions (20.04, 22.04, 24.04) - -4. **Major Changes**: - - Full QEMU VM test with clean Ubuntu ISO - - Manual verification on physical hardware +1. Run `bash scripts/check.sh` for repo-wide syntax validation. +2. Run `make test-debian` for a quick Debian smoke test. +3. Run `make test-debian-all` before merging Debian-specific changes. +4. Use QEMU only if you need to validate behavior Docker cannot represent. ## Future Enhancements -- [ ] Add GitHub Actions CI workflow -- [ ] Create QEMU automated testing with cloud-init -- [ ] Add test coverage for all distros (Fedora, Arch, Pop!_OS) -- [ ] Create non-interactive mode for all bootstrap scripts -- [ ] Add smoke tests to verify installed packages work -- [ ] Create test fixtures for different user scenarios +- Add Fedora, Arch, and Pop!_OS Docker test coverage. +- Add smoke tests that verify key installed tools are actually runnable. +- Add non-interactive bootstrap modes for currently interactive distro flows. diff --git a/test/docker/Dockerfile.debian-noninteractive b/test/docker/Dockerfile.debian-noninteractive new file mode 100644 index 0000000..7a78ec7 --- /dev/null +++ b/test/docker/Dockerfile.debian-noninteractive @@ -0,0 +1,48 @@ +# Non-interactive testing Dockerfile for Debian bootstrap scripts +# This version runs the Debian package installer in a clean container +# Usage: +# docker build -f test/docker/Dockerfile.debian-noninteractive -t debian-bootstrap-test-auto . +# docker run --rm debian-bootstrap-test-auto + +ARG DEBIAN_VERSION=bookworm +FROM debian:${DEBIAN_VERSION} + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=UTC + +# Install minimal dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + sudo \ + openssh-client \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Create a test user with sudo privileges. +# This bypasses Debian's default lack of sudo group membership so tests can run unattended. +RUN useradd -m -s /bin/bash testuser && \ + echo "testuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +USER testuser +WORKDIR /home/testuser + +# Copy bootstrap scripts +COPY --chown=testuser:testuser . /home/testuser/linux-bootstrap + +# Create a non-interactive test runner +RUN echo '#!/bin/bash' > /home/testuser/run-tests.sh && \ + echo 'set -e' >> /home/testuser/run-tests.sh && \ + echo 'cd /home/testuser/linux-bootstrap' >> /home/testuser/run-tests.sh && \ + echo '' >> /home/testuser/run-tests.sh && \ + echo 'echo "Testing Debian package installation..."' >> /home/testuser/run-tests.sh && \ + echo 'bash debian/install-packages' >> /home/testuser/run-tests.sh && \ + echo '' >> /home/testuser/run-tests.sh && \ + echo 'echo ""' >> /home/testuser/run-tests.sh && \ + echo 'echo "================================="' >> /home/testuser/run-tests.sh && \ + echo 'echo "Debian package test completed"' >> /home/testuser/run-tests.sh && \ + echo 'echo "================================="' >> /home/testuser/run-tests.sh && \ + chmod +x /home/testuser/run-tests.sh + +CMD ["/home/testuser/run-tests.sh"] \ No newline at end of file diff --git a/test/run-tests.sh b/test/run-tests.sh index 1715aee..cb84d6e 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Quick test runner for Ubuntu bootstrap scripts -# Usage: ./test/run-tests.sh [interactive|auto|all|syntax|clean] +# Quick test runner for Ubuntu and Debian bootstrap scripts +# Usage: ./test/run-tests.sh [interactive|auto|all|debian|debian-all|syntax|clean] set -e @@ -64,6 +64,20 @@ case "$MODE" in echo -e "\n${GREEN}✓ Ubuntu 24.04 tests passed${NC}\n" ;; + + debian|d) + print_header "Running Debian Automated Tests" + + print_header "Testing Debian bookworm" + docker build \ + --build-arg DEBIAN_VERSION=bookworm \ + -f test/docker/Dockerfile.debian-noninteractive \ + -t debian-bootstrap-test:bookworm \ + . + docker run --rm debian-bootstrap-test:bookworm + + echo -e "\n${GREEN}✓ Debian bookworm tests passed${NC}\n" + ;; all) print_header "Running Comprehensive Tests" @@ -96,6 +110,37 @@ case "$MODE" in exit 1 fi ;; + + debian-all) + print_header "Running Comprehensive Debian Tests" + + VERSIONS=("bookworm" "trixie") + FAILED=() + + for VERSION in "${VERSIONS[@]}"; do + print_header "Testing Debian $VERSION" + + if docker build \ + --build-arg DEBIAN_VERSION="$VERSION" \ + -f test/docker/Dockerfile.debian-noninteractive \ + -t debian-bootstrap-test:"$VERSION" \ + . && \ + docker run --rm debian-bootstrap-test:"$VERSION"; then + echo -e "\n${GREEN}✓ Debian $VERSION tests passed${NC}\n" + else + print_error "Debian $VERSION tests failed" + FAILED+=("$VERSION") + fi + done + + print_header "Test Summary" + if [ ${#FAILED[@]} -eq 0 ]; then + echo -e "${GREEN}All Debian tests passed!${NC}" + else + echo -e "${RED}Failed versions: ${FAILED[*]}${NC}" + exit 1 + fi + ;; syntax) print_header "Running Syntax Checks" @@ -103,12 +148,19 @@ case "$MODE" in echo "Checking bootstrap scripts..." bash -n bootstrap bash -n ubuntu/bootstrap + bash -n debian/bootstrap echo "Checking ubuntu scripts..." for script in ubuntu/install-*; do echo " Checking $script" bash -n "$script" done + + echo "Checking debian scripts..." + for script in debian/*; do + echo " Checking $script" + bash -n "$script" + done echo "Checking generic scripts..." for script in generic/*; do @@ -121,7 +173,7 @@ case "$MODE" in if command -v shellcheck &> /dev/null; then print_header "Running ShellCheck" # ShellCheck is treated as advisory linting here; syntax errors still fail via set -e - shellcheck bootstrap ubuntu/bootstrap || print_warning "ShellCheck found issues" + shellcheck bootstrap ubuntu/bootstrap debian/bootstrap debian/install-packages || print_warning "ShellCheck found issues" else print_warning "shellcheck not installed, skipping advanced linting" echo "Install with: sudo apt-get install shellcheck" @@ -130,22 +182,25 @@ case "$MODE" in clean) print_header "Cleaning Up Test Images" - docker images | grep ubuntu-bootstrap-test | awk '{print $3}' | xargs -r docker rmi + docker images | grep -E 'ubuntu-bootstrap-test|debian-bootstrap-test' | awk '{print $3}' | xargs -r docker rmi echo -e "${GREEN}Cleanup complete${NC}" ;; *) - echo "Usage: ./test/run-tests.sh [interactive|auto|all|syntax|clean]" + echo "Usage: ./test/run-tests.sh [interactive|auto|all|debian|debian-all|syntax|clean]" echo "" echo "Modes:" echo " interactive (i) - Start interactive Docker container for manual testing" echo " auto (a) - Run automated tests on Ubuntu 24.04 (default)" echo " all - Run tests on Ubuntu 24.04 and 25.10" + echo " debian (d) - Run automated tests on Debian bookworm" + echo " debian-all - Run tests on Debian bookworm and trixie" echo " syntax - Run syntax checks and linting only" echo " clean - Remove all test Docker images" echo "" echo "Examples:" echo " ./test/run-tests.sh auto # Quick automated test" + echo " ./test/run-tests.sh debian # Quick Debian test" echo " ./test/run-tests.sh interactive # Manual testing" echo " ./test/run-tests.sh all # Full test suite" exit 1 diff --git a/ubuntu/install-makemkv b/ubuntu/install-makemkv deleted file mode 100755 index 7d8cd63..0000000 --- a/ubuntu/install-makemkv +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -# source <(curl -fsSL https://raw.githubusercontent.com/mapitman/linux-bootstrap/main/ubuntu/install-makemkv) - -# Install makemkv -if ! type makemkv -then - MAKEMKV_VERSION="1.18.2" - mkdir -p /tmp/makemkv-build - pushd /tmp/makemkv-build || exit - - curl -O "https://www.makemkv.com/download/makemkv-bin-$MAKEMKV_VERSION.tar.gz" - curl -O "https://www.makemkv.com/download/makemkv-oss-$MAKEMKV_VERSION.tar.gz" - curl -O https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 - - tar xzvf "makemkv-bin-$MAKEMKV_VERSION.tar.gz" - tar xzvf "makemkv-oss-$MAKEMKV_VERSION.tar.gz" - tar xjvf ffmpeg-snapshot.tar.bz2 - - popd || exit - - sudo apt-get install -y \ - build-essential \ - pkg-config \ - libc6-dev \ - libssl-dev \ - libexpat1-dev \ - libavcodec-dev \ - libgl1-mesa-dev \ - qtbase5-dev \ - zlib1g-dev \ - yasm \ - libfdk-aac-dev \ - nasm - - pushd /tmp/makemkv-build/ffmpeg || exit - ./configure --prefix=/tmp/ffmpeg --enable-static --disable-shared --enable-pic --enable-libfdk-aac - make install - popd || exit - - pushd "/tmp/makemkv-build/makemkv-oss-$MAKEMKV_VERSION" || exit - PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ./configure - make - sudo make install - popd || exit - - pushd "/tmp/makemkv-build/makemkv-bin-$MAKEMKV_VERSION" || exit - make - sudo make install - popd || exit -fi diff --git a/ubuntu/install-makemkv b/ubuntu/install-makemkv new file mode 120000 index 0000000..2ab1037 --- /dev/null +++ b/ubuntu/install-makemkv @@ -0,0 +1 @@ +../debian/install-makemkv \ No newline at end of file