Skip to content

Commit 5df2112

Browse files
committed
docs: Add claude.md
1 parent 8154747 commit 5df2112

File tree

5 files changed

+202
-54
lines changed

5 files changed

+202
-54
lines changed

CLAUDE.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# CLAUDE.md
2+
3+
<!-- LLM Generated: This file was created by Claude (claude.ai/code) -->
4+
5+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
6+
7+
## Project Overview
8+
9+
**AlterLinux** is an Arch Linux-derived OS optimized for Japanese users. **AlterISO 6.0** (in the `dev` branch) is the build system that generates ISO images using a profile generation approach. It creates archiso-compatible profiles from AlterISO configuration files and uses an "Injectable" mechanism to hook into archiso functions without modifying upstream code.
10+
11+
## Build Commands
12+
13+
```bash
14+
# Generate archiso profile from AlterISO config
15+
./alteriso/gen.sh configs/<profile_name>
16+
17+
# Build ISO image (generates profile + runs mkarchiso)
18+
cd alteriso && ./build.sh
19+
20+
# Or directly with Go
21+
go run ./src profile build configs/<profile_name>
22+
23+
# Clean generated profiles
24+
./alteriso/clean.sh
25+
26+
# Lint shell scripts
27+
make check
28+
```
29+
30+
Build requires root privileges. Output goes to `alteriso/out/`, work directory is `alteriso/work/`.
31+
32+
## Architecture
33+
34+
### Core Components
35+
36+
- **Go Application** (`alteriso/src/`): Profile generation using Cobra CLI
37+
- `internal/cmd/` - CLI commands (root, profile generate, profile build)
38+
- `internal/archiso/` - Profile parsing, generation, and Injectable handling
39+
- **Modules** (`alteriso/modules/`): Pluggable units providing packages, files, scripts, and injection hooks
40+
- **Bootloaders** (`alteriso/bootloaders/`): BIOS/UEFI boot configuration templates
41+
- **archiso** (`archiso/`): Forked upstream archiso with Injectable support
42+
43+
### Data Flow
44+
45+
1. User provides `configs/<profile>/profiledef.json` + `profiledef.sh`
46+
2. Go tool reads JSON, loads referenced modules from `modules/` directory
47+
3. Modules provide: packages, files, scripts, injection hooks
48+
4. AlterISO merges everything → generates archiso-compatible profile in `out/`
49+
5. mkarchiso builds ISO with injected hooks
50+
51+
### Injectable Mechanism
52+
53+
AlterISO leverages archiso's `_run_once()` function which sources `profiledef.sh`. Generated `profiledef.sh` includes:
54+
- Pre/post hooks: `pre_<function>()`, `post_<function>()`
55+
- Override hooks: `override_<function>()`
56+
- Example: `post__make_packages()`, `pre__make_customize_airootfs()`
57+
58+
### Module Structure
59+
60+
```
61+
modules/<name>/
62+
├── alteriso.json # Module manifest (required)
63+
├── module.sh # Shell script with hook functions
64+
├── packages.x86_64.d/ # Package lists
65+
├── airootfs.any/ # Files for all architectures
66+
└── airootfs.x86_64/ # Architecture-specific files
67+
```
68+
69+
### Profile Configuration
70+
71+
`profiledef.json` fields:
72+
- `arch` (required): Target architecture (currently "x86_64")
73+
- `modules` (required): List of modules to load in order
74+
- `os_name`, `kernel_name`, `username`, `cow_spacesize`: Optional config
75+
- `injects`: Profile-level injection hooks
76+
- `require_injectable`: Whether profile needs Injectable archiso support
77+
78+
Placeholders in bootloader configs: `%ALTERISO_OS_NAME%`, `%ALTERISO_KERNEL_NAME%`, `%ALTERISO_COW_SPACESIZE%`, `%ALTERISO_KERNEL_PARAM%`
79+
80+
## Key Files
81+
82+
- `alteriso/src/internal/archiso/profile_gen.go` - Main profile generation logic
83+
- `alteriso/src/internal/archiso/injects/profiledef.sh.in` - Template for generated profiledef.sh
84+
- `alteriso/src/internal/archiso/injects/injecter.sh` - Hook injection mechanism
85+
- `alteriso/configs/xfce/profiledef.json` - Example profile configuration
86+
87+
## Important Notes
88+
89+
- Module load order matters: determines precedence for injections and file overwrites
90+
- Scripts rebuild Go binary each time; binaries are cleaned up after
91+
- Documentation is primarily in Japanese (see `alteriso/docs/`)
92+
- Testing is done by building ISO and running with qemu (`scripts/run_archiso.sh`)
93+
- Changes to archiso upstream may require updates to injection templates
94+
95+
## LLM-Generated Content Rules
96+
97+
This project distinguishes between LLM-generated and human-written code. When creating new files or making substantial changes, follow these rules:
98+
99+
### Marking New Files
100+
101+
Add an LLM marker comment at the top of new files:
102+
103+
- **Markdown files**: `<!-- LLM Generated: Created by Claude -->`
104+
- **Go files**: `// LLM Generated: Created by Claude`
105+
- **Shell scripts**: `# LLM Generated: Created by Claude`
106+
- **JSON files**: Add `"_llm_generated": "Created by Claude"` field
107+
108+
### Marking Existing File Changes
109+
110+
When making substantial changes to existing files, add a comment near the modified code:
111+
112+
```go
113+
// LLM Modified: Added error handling - Claude
114+
```
115+
116+
```bash
117+
# LLM Modified: Refactored validation logic - Claude
118+
```
119+
120+
### Git Commit Messages
121+
122+
Include the Co-Authored-By trailer in commit messages:
123+
124+
```
125+
Co-Authored-By: Claude <noreply@anthropic.com>
126+
```

alteriso/docs/config.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- LLM Generated: This document was created by Claude -->
2+
13
# コンフィグの仕様
24

35
本ドキュメントでは、alteriso の設定ファイル `profiledef.json` の仕様について説明します。
@@ -18,6 +20,7 @@
1820
- ****: `"x86_64"`
1921

2022
現在サポートされているアーキテクチャ:
23+
2124
- `x86_64`
2225

2326
#### modules
@@ -73,10 +76,11 @@
7376

7477
#### injects
7578

76-
- ****: object (map[string][]string)
79+
- ****: object (`map[string][]string`)
7780
- **説明**: プロファイルレベルのインジェクション定義
7881
- **デフォルト値**: `{}`
7982
- ****:
83+
8084
```json
8185
{
8286
"injects": {
@@ -148,18 +152,18 @@
148152

149153
### 利用可能なプレースホルダー
150154

151-
| プレースホルダー | 対応する設定 | デフォルト値 |
152-
|---|---|---|
153-
| `%ALTERISO_OS_NAME%` | `os_name` | `""` |
154-
| `%ALTERISO_KERNEL_NAME%` | `kernel_name` | `"linux"` |
155-
| `%ALTERISO_COW_SPACESIZE%` | `cow_spacesize` | `"256M"` |
156-
| `%ALTERISO_KERNEL_PARAM%` | モジュールの `append_kernel_param` | `""` |
155+
| プレースホルダー | 対応する設定 | デフォルト値 |
156+
| --- | --- | --- |
157+
| `%ALTERISO_OS_NAME%` | `os_name` | `""` |
158+
| `%ALTERISO_KERNEL_NAME%` | `kernel_name` | `"linux"` |
159+
| `%ALTERISO_COW_SPACESIZE%` | `cow_spacesize` | `"256M"` |
160+
| `%ALTERISO_KERNEL_PARAM%` | モジュールの `append_kernel_param` | `""` |
157161

158162
### 展開の例
159163

160164
#### ブートローダー設定テンプレート
161165

162-
```
166+
```text
163167
LABEL %ALTERISO_OS_NAME%
164168
LINUX /boot/vmlinuz-%ALTERISO_KERNEL_NAME%
165169
APPEND cow_spacesize=%ALTERISO_COW_SPACESIZE% %ALTERISO_KERNEL_PARAM%
@@ -177,7 +181,7 @@ APPEND cow_spacesize=%ALTERISO_COW_SPACESIZE% %ALTERISO_KERNEL_PARAM%
177181

178182
#### 展開結果
179183

180-
```
184+
```text
181185
LABEL Custom Linux
182186
LINUX /boot/vmlinuz-linux-lts
183187
APPEND cow_spacesize=2G quiet splash
@@ -206,6 +210,7 @@ APPEND cow_spacesize=2G quiet splash
206210
```
207211

208212
この場合:
213+
209214
1. `base` モジュールがロード
210215
2. `user` モジュールがロード
211216
3. `network-manager` モジュールがロード
@@ -237,6 +242,7 @@ __alteriso_profiledef
237242
```
238243

239244
出力例:
245+
240246
```json
241247
{"os_name":"Alter Linux","arch":"x86_64","modules":["base","user"],...}
242248
```
@@ -284,13 +290,15 @@ echo "COW space size: ${cow_size}"
284290
### 2. 適切な COW サイズ
285291

286292
用途に応じて `cow_spacesize` を設定します:
293+
287294
- ミニマル環境: `"512M"`
288295
- 標準環境: `"1G"`
289296
- デスクトップ環境: `"2G"` 以上
290297

291298
### 3. カーネルの選択
292299

293300
用途に応じたカーネルを選択します:
301+
294302
- 標準: `"linux"`
295303
- 長期サポート: `"linux-lts"`
296304
- 低レイテンシ: `"linux-zen"`
@@ -310,31 +318,34 @@ echo "COW space size: ${cow_size}"
310318

311319
### JSON パースエラー
312320

313-
```
321+
```text
314322
Error: failed to parse profile config: invalid character...
315323
```
316324

317325
解決方法:
326+
318327
- JSON の形式を確認 (カンマ、括弧、引用符など)
319328
- JSON バリデータでチェック
320329

321330
### モジュールロードエラー
322331

323-
```
332+
```text
324333
Error: failed to load module <name>: module directory does not exist
325334
```
326335

327336
解決方法:
337+
328338
- `modules/` ディレクトリに該当モジュールが存在するか確認
329339
- モジュール名のスペルを確認
330340

331341
### フィールド型エラー
332342

333-
```
343+
```text
334344
Error: json: cannot unmarshal...
335345
```
336346

337347
解決方法:
348+
338349
- フィールドの型を確認 (string, array, object)
339350
- 配列は `[]`、文字列は `""` で囲む
340351

alteriso/docs/module.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- LLM Generated: This document was created by Claude -->
2+
13
# モジュールの仕組みと仕様
24

35
本ドキュメントでは、alteriso のモジュールシステムの仕組みと仕様について説明します。
@@ -11,7 +13,7 @@
1113

1214
### ディレクトリ構成
1315

14-
```
16+
```text
1517
modules/<module_name>/
1618
├── alteriso.json # モジュール設定ファイル (必須)
1719
├── module.sh # シェルスクリプト (オプション)
@@ -98,6 +100,7 @@ modules/<module_name>/
98100
複数のモジュールが同じフックに関数を登録した場合、モジュールのロード順序で実行されます。
99101

100102
例:
103+
101104
- モジュール A: `post__make_packages``[function_a]`
102105
- モジュール B: `post__make_packages``[function_b]`
103106

@@ -119,9 +122,9 @@ modules/<module_name>/
119122
- `#` で始まる行はコメント
120123
- 空行は無視される
121124

122-
####
125+
#### packages.x86_64.d の例
123126

124-
```
127+
```text
125128
# ネットワーク管理
126129
networkmanager
127130
nm-connection-editor
@@ -167,7 +170,7 @@ bootstrap ビルドモード用のパッケージリストです。
167170

168171
### ファイル構造の例
169172

170-
```
173+
```text
171174
airootfs.any/
172175
├── etc/
173176
│ ├── systemd/
@@ -218,14 +221,15 @@ airootfs.any/
218221

219222
### パッケージのみを提供するモジュール例
220223

221-
```
224+
```text
222225
modules/example/
223226
├── alteriso.json
224227
└── packages.x86_64.d/
225228
└── example.x86_64
226229
```
227230

228231
`alteriso.json`:
232+
229233
```json
230234
{
231235
"manifest_version": 1,
@@ -234,21 +238,23 @@ modules/example/
234238
```
235239

236240
`packages.x86_64.d/example.x86_64`:
237-
```
241+
242+
```text
238243
vim
239244
tmux
240245
git
241246
```
242247

243248
### インジェクション付きモジュール例
244249

245-
```
250+
```text
246251
modules/custom/
247252
├── alteriso.json
248253
└── module.sh
249254
```
250255

251256
`alteriso.json`:
257+
252258
```json
253259
{
254260
"manifest_version": 1,
@@ -261,6 +267,7 @@ modules/custom/
261267
```
262268

263269
`module.sh`:
270+
264271
```bash
265272
custom_post_install() {
266273
_msg_info "Running custom post-install tasks..."

0 commit comments

Comments
 (0)