Refactor build process to use TypeScript with Deno, replacing Bash script and updating CI workflow; enhance README with usage instructions and prerequisites
···23[](https://github.com/tsirysndr/vmlinux-builder/actions/workflows/ci.yml)
45-📦 **vmlinux-builder** is a lightweight Bash-based tool to fetch, configure, and build the Linux kernel `vmlinux` image for a given version — ideal for use with Firecracker microVMs or other kernel-related debugging/testing tasks.
67## ✨ Features
89- Builds any stable Linux kernel version (e.g., `6.1`, `6.1.12`, `6.1.y`)
10- Uses a custom `.config` for reproducible builds
11- Outputs a ready-to-use `vmlinux-X.Y` file
0012- Easily integrated into CI pipelines (e.g., GitHub Actions)
1314## 🛠 Prerequisites
150016Ensure you have the following dependencies installed:
17-18```bash
19sudo apt-get install -y git build-essential flex bison libncurses5-dev \
20libssl-dev gcc bc libelf-dev pahole
21```
2200000000023## 🚀 Usage
024Clone the repo and provide a kernel version:
0002526-```bash
27-./build.sh 6.16.y
00028```
2930**Note:** Ensure a valid `.config` file is present in the root directory before running.
310000003233### Example output
34-35```
036vmlinux built successfully!
37-You can find the vmlinux file in linux-stable/vmlinux-6.16
38```
3940## 📦 GitHub Actions
4142This repo includes a GitHub Actions workflow (`.github/workflows/ci.yml`) that:
4344-- Triggers on tag push (e.g. git tag 6.16.y && git push origin 6.16.y)
45- Builds the vmlinux for that version
46-- Publishes the resulting vmlinux-X.Y as a GitHub Release asset
0000000004748## 📄 License
4950-This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
···23[](https://github.com/tsirysndr/vmlinux-builder/actions/workflows/ci.yml)
45+📦 **vmlinux-builder** is a lightweight TypeScript/Deno-based tool to fetch, configure, and build the Linux kernel `vmlinux` image for a given version — ideal for use with Firecracker microVMs or other kernel-related debugging/testing tasks.
67## ✨ Features
89- Builds any stable Linux kernel version (e.g., `6.1`, `6.1.12`, `6.1.y`)
10- Uses a custom `.config` for reproducible builds
11- Outputs a ready-to-use `vmlinux-X.Y` file
12+- Written in TypeScript with Deno for better type safety and cross-platform compatibility
13+- Colored output using Chalk for improved readability
14- Easily integrated into CI pipelines (e.g., GitHub Actions)
1516## 🛠 Prerequisites
1718+### System Dependencies
19+20Ensure you have the following dependencies installed:
021```bash
22sudo apt-get install -y git build-essential flex bison libncurses5-dev \
23libssl-dev gcc bc libelf-dev pahole
24```
2526+### Deno Runtime
27+28+Install Deno if you haven't already:
29+```bash
30+curl -fsSL https://deno.land/install.sh | sh
31+```
32+33+Or follow the [official Deno installation guide](https://deno.land/#installation).
34+35## 🚀 Usage
36+37Clone the repo and provide a kernel version:
38+```bash
39+# Make the script executable
40+chmod +x build.ts
4142+# Run with a kernel version
43+./build.ts 6.16.y
44+45+# Or run directly with Deno
46+deno run --allow-run --allow-read --allow-write --allow-env --allow-net build.ts 6.16.y
47```
4849**Note:** Ensure a valid `.config` file is present in the root directory before running.
5051+### Supported Version Formats
52+53+- `6.1` - Major.Minor version
54+- `6.1.12` - Specific patch version
55+- `6.1.y` - Latest from maintenance branch
56+- `v6.1.12` - Version with 'v' prefix (automatically normalized)
5758### Example output
059```
60+Building vmlinux for Linux kernel 6.16
61vmlinux built successfully!
62+You can find the vmlinux file in /path/to/linux-stable/vmlinux-6.16.x86_64
63```
6465## 📦 GitHub Actions
6667This repo includes a GitHub Actions workflow (`.github/workflows/ci.yml`) that:
6869+- Triggers on tag push (e.g. `git tag 6.16.y && git push origin 6.16.y`)
70- Builds the vmlinux for that version
71+- Publishes the resulting `vmlinux-X.Y` as a GitHub Release asset
72+73+## 🔧 Development
74+75+The script is written in TypeScript and runs on Deno. Key features:
76+77+- **Type-safe**: Full TypeScript support with type checking
78+- **Cross-platform**: Works on Linux, macOS, and Windows (WSL)
79+- **Modern**: Uses Deno's native APIs for file operations and process management
80+- **Colored output**: Enhanced user experience with Chalk
8182## 📄 License
8384+This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
-65
build.sh
···1-#!/usr/bin/env bash
2-set -e
3-4-readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')"
5-readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')"
6-readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')"
7-readonly ORANGE="$(tput setaf 3 2>/dev/null || echo '')"
8-readonly NO_COLOR="$(tput sgr0 2>/dev/null || echo '')"
9-10-if [[ $# -lt 1 ]]; then
11- echo "${ORANGE}Usage: $0 <kernel-version>{.y|.Z}${NO_COLOR}"
12- echo "Example: ./build.sh 6.1 | 6.1.12 | 6.1.y | v6.1.12"
13- exit 1
14-fi
15-16-INPUT="$1"
17-NUM="${INPUT#v}" # normalize by stripping optional leading 'v'
18-19-# Validate: X.Y, X.Y.Z, or X.Y.y
20-if [[ ! "$NUM" =~ ^[0-9]+\.[0-9]+(\.(y|[0-9]+))?$ ]]; then
21- echo "${ORANGE}Error: Invalid kernel version '${INPUT}'. Expected X.Y, X.Y.Z, or X.Y.y${NO_COLOR}"
22- echo "Examples: 6.1 | 6.1.12 | 6.1.y | v6.1.12"
23- exit 1
24-fi
25-26-echo "Building vmlinux for Linux kernel ${CYAN}${NUM}${NO_COLOR}"
27-28-type apt-get >/dev/null 2>&1 && sudo apt-get install -y git build-essential flex bison libncurses5-dev libssl-dev gcc bc libelf-dev pahole || true
29-30-REPO_URL="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
31-32-# Decide ref: maintenance branch vs tag
33-if [[ "$NUM" == *".y" ]]; then
34- REF="linux-${NUM}" # e.g. linux-6.16.y
35- VERSION="${NUM%.y}" # e.g. 6.16
36-else
37- REF="v${NUM}" # e.g. v6.16.2 (ensure leading v)
38- VERSION="${NUM}" # e.g. 6.16.2 (no leading v)
39-fi
40-41-if [[ ! -d linux-stable ]]; then
42- # Clone directly at the desired ref (branch or tag)
43- git clone --depth=1 --branch "$REF" "$REPO_URL" linux-stable
44-else
45- # Update existing checkout to the desired ref
46- git -C linux-stable fetch --tags --force origin
47- # Shallow-fetch the specific ref (works for both branches and tags)
48- git -C linux-stable fetch --depth=1 origin "$REF":"$REF" || git -C linux-stable fetch origin "$REF":"$REF"
49- git -C linux-stable checkout -f "$REF"
50-fi
51-52-cp .config linux-stable/.config
53-54-cd linux-stable
55-56-# Build
57-yes '' | make vmlinux -j"$(nproc)" < /dev/null
58-59-VMLINUX="vmlinux-${VERSION}"
60-mv vmlinux "${VMLINUX}.$(uname -m)"
61-62-echo "${GREEN}vmlinux built successfully!${NO_COLOR}"
63-echo "You can find the vmlinux file in ${CYAN}$(pwd)/${VMLINUX}.$(uname -m)${NO_COLOR}"
64-65-exit 0