Skip to content

Commit 98db219

Browse files
committed
WIP
1 parent e76ed6e commit 98db219

File tree

3 files changed

+93
-18
lines changed

3 files changed

+93
-18
lines changed

CLAUDE.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This repository contains devcontainer features for use with @devcontainers. It currently includes a `delta` feature that installs the delta pager for git.
8+
9+
## Repository Structure
10+
11+
- `src/` - Contains devcontainer features, each in its own subdirectory
12+
- `src/delta/` - The delta pager feature
13+
- `devcontainer-feature.json` - Feature configuration and metadata
14+
- `install.sh` - Installation script for the delta pager
15+
- `test/` - Test files for each feature
16+
- `test/delta/test.sh` - Test script for the delta feature
17+
18+
## Development Commands
19+
20+
### Testing Features
21+
22+
To test the delta feature:
23+
```bash
24+
devcontainer features test \
25+
--features delta \
26+
--remote-user root \
27+
--skip-scenarios \
28+
--base-image mcr.microsoft.com/devcontainers/base:ubuntu \
29+
/path/to/this/repo
30+
```
31+
32+
### Publishing Features
33+
34+
Features are published via GitHub Actions workflow (`.github/workflows/release.yaml`) that:
35+
- Publishes features using the devcontainers/action
36+
- Generates documentation automatically
37+
- Creates PRs for documentation updates
38+
39+
## Architecture
40+
41+
### Feature Structure
42+
43+
Each devcontainer feature follows this pattern:
44+
- `devcontainer-feature.json` - Defines the feature metadata, options, and environment variables
45+
- `install.sh` - Installation script that handles cross-platform installation
46+
- Tests in corresponding `test/` directory
47+
48+
### Installation Script Architecture
49+
50+
The `install.sh` script uses a modular approach:
51+
- OS detection (`detect_os()`) - Identifies RedHat, Alpine, or Debian-based systems
52+
- Architecture detection (`detect_architecture()`) - Handles amd64, arm64, armhf
53+
- Package manager abstraction (`install_package()`) - Unified interface for different package managers
54+
- Error handling with `run()` function for privilege escalation
55+
56+
### Cross-Platform Support
57+
58+
The delta feature supports:
59+
- Debian/Ubuntu: Downloads .deb from GitHub releases
60+
- RedHat/CentOS/Fedora: Uses dnf package manager
61+
- Alpine: Uses pacman package manager
62+
63+
## Key Files
64+
65+
- `src/delta/devcontainer-feature.json:21` - Sets GIT_PAGER environment variable
66+
- `src/delta/install.sh:115` - Contains a typo in the .deb URL construction (`.derb` instead of `.deb`)
67+
- `test/delta/test.sh:43` - Tests delta installation and GIT_PAGER configuration

src/delta/install.sh

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,36 @@ install_delta_for_debian() {
136136

137137
# Install delta based on OS (fallback to package manager)
138138
install_package() {
139-
OS_TYPE=$(detect_os)
139+
local OS_TYPE=$(detect_os)
140+
local version="${VERSION:-latest}"
140141
local package_name=$1
141-
echo "Detected OS type: $OS_TYPE"
142+
143+
echo "Installing ${package_name}; version: ${version}; on OS: ${OS_TYPE}"
142144

143145
case "$OS_TYPE" in
144146
redhat)
145147
echo "Installing delta using dnf..."
146-
run dnf install -y ${package_name}
148+
local pkg=${package_name}
149+
if [[ -z ${version} ]]; then
150+
pkg="${package_name}-${version}"
151+
fi
152+
run dnf install -y ${pkg}
147153
;;
148154
alpine)
149155
echo "Installing delta using pacman..."
150-
run pacman -S --noconfirm ${package_name}
156+
local pkg=${package_name}
157+
if [[ -z ${version} ]]; then
158+
pkg="${package_name}=${version}"
159+
fi
160+
run apk add --no-interactiv ${pkg}
151161
;;
152162
debian)
153163
echo "Installing delta using apt..."
154-
run apt update -y
155-
run apt install -y ${package_name}
164+
run apt-get update -y
165+
if [[ -z ${version} ]]; then
166+
pkg="${package_name}=${version}"
167+
fi
168+
run apt-get install -y ${pkg}
156169
;;
157170
*)
158171
echo "Unsupported OS or package manager not detected"
@@ -166,8 +179,8 @@ install_package() {
166179

167180
# Install delta based on OS (fallback to package manager)
168181
install_delta() {
182+
echo "Installing delta"
169183
OS_TYPE=$(detect_os)
170-
echo "Detected OS type: $OS_TYPE"
171184

172185
case "$OS_TYPE" in
173186
redhat)
@@ -181,7 +194,7 @@ install_delta() {
181194
install_delta_for_debian
182195
;;
183196
*)
184-
echo "Unsupported OS or package manager not detected"
197+
echo "Unsupported OS or package manager not detected: ${OS_TYPE}"
185198
echo "Please file an issue with the container OS information at:"
186199
echo "https://github.com/rcleveng/devcontainer-features/issues/new"
187200

@@ -190,14 +203,4 @@ install_delta() {
190203
esac
191204
}
192205

193-
echo "Activating feature 'delta'"
194-
195-
# Install delta
196206
install_delta
197-
198-
echo "The effective dev container remoteUser is '$_REMOTE_USER'"
199-
echo "The effective dev container remoteUser's home directory is '$_REMOTE_USER_HOME'"
200-
201-
echo "The effective dev container containerUser is '$_CONTAINER_USER'"
202-
echo "The effective dev container containerUser's home directory is '$_CONTAINER_USER_HOME'"
203-

test_all.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
devcontainer features test --base-image mcr.microsoft.com/devcontainers/base:alpine
4+
devcontainer features test --base-image mcr.microsoft.com/devcontainers/base:ubuntu
5+
devcontainer features test --base-image mcr.microsoft.com/devcontainers/base:debian

0 commit comments

Comments
 (0)