Refactor build process to use TypeScript with Deno, replacing Bash script and updating CI workflow; enhance README with usage instructions and prerequisites
···2233[](https://github.com/tsirysndr/vmlinux-builder/actions/workflows/ci.yml)
4455-📦 **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.
55+📦 **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.
6677## ✨ Features
8899- Builds any stable Linux kernel version (e.g., `6.1`, `6.1.12`, `6.1.y`)
1010- Uses a custom `.config` for reproducible builds
1111- Outputs a ready-to-use `vmlinux-X.Y` file
1212+- Written in TypeScript with Deno for better type safety and cross-platform compatibility
1313+- Colored output using Chalk for improved readability
1214- Easily integrated into CI pipelines (e.g., GitHub Actions)
13151416## 🛠 Prerequisites
15171818+### System Dependencies
1919+1620Ensure you have the following dependencies installed:
1717-1821```bash
1922sudo apt-get install -y git build-essential flex bison libncurses5-dev \
2023libssl-dev gcc bc libelf-dev pahole
2124```
22252626+### Deno Runtime
2727+2828+Install Deno if you haven't already:
2929+```bash
3030+curl -fsSL https://deno.land/install.sh | sh
3131+```
3232+3333+Or follow the [official Deno installation guide](https://deno.land/#installation).
3434+2335## 🚀 Usage
3636+2437Clone the repo and provide a kernel version:
3838+```bash
3939+# Make the script executable
4040+chmod +x build.ts
25412626-```bash
2727-./build.sh 6.16.y
4242+# Run with a kernel version
4343+./build.ts 6.16.y
4444+4545+# Or run directly with Deno
4646+deno run --allow-run --allow-read --allow-write --allow-env --allow-net build.ts 6.16.y
2847```
29483049**Note:** Ensure a valid `.config` file is present in the root directory before running.
31505151+### Supported Version Formats
5252+5353+- `6.1` - Major.Minor version
5454+- `6.1.12` - Specific patch version
5555+- `6.1.y` - Latest from maintenance branch
5656+- `v6.1.12` - Version with 'v' prefix (automatically normalized)
32573358### Example output
3434-3559```
6060+Building vmlinux for Linux kernel 6.16
3661vmlinux built successfully!
3737-You can find the vmlinux file in linux-stable/vmlinux-6.16
6262+You can find the vmlinux file in /path/to/linux-stable/vmlinux-6.16.x86_64
3863```
39644065## 📦 GitHub Actions
41664267This repo includes a GitHub Actions workflow (`.github/workflows/ci.yml`) that:
43684444-- Triggers on tag push (e.g. git tag 6.16.y && git push origin 6.16.y)
6969+- Triggers on tag push (e.g. `git tag 6.16.y && git push origin 6.16.y`)
4570- Builds the vmlinux for that version
4646-- Publishes the resulting vmlinux-X.Y as a GitHub Release asset
7171+- Publishes the resulting `vmlinux-X.Y` as a GitHub Release asset
7272+7373+## 🔧 Development
7474+7575+The script is written in TypeScript and runs on Deno. Key features:
7676+7777+- **Type-safe**: Full TypeScript support with type checking
7878+- **Cross-platform**: Works on Linux, macOS, and Windows (WSL)
7979+- **Modern**: Uses Deno's native APIs for file operations and process management
8080+- **Colored output**: Enhanced user experience with Chalk
47814882## 📄 License
49835050-This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.8484+This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
-65
build.sh
···11-#!/usr/bin/env bash
22-set -e
33-44-readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')"
55-readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')"
66-readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')"
77-readonly ORANGE="$(tput setaf 3 2>/dev/null || echo '')"
88-readonly NO_COLOR="$(tput sgr0 2>/dev/null || echo '')"
99-1010-if [[ $# -lt 1 ]]; then
1111- echo "${ORANGE}Usage: $0 <kernel-version>{.y|.Z}${NO_COLOR}"
1212- echo "Example: ./build.sh 6.1 | 6.1.12 | 6.1.y | v6.1.12"
1313- exit 1
1414-fi
1515-1616-INPUT="$1"
1717-NUM="${INPUT#v}" # normalize by stripping optional leading 'v'
1818-1919-# Validate: X.Y, X.Y.Z, or X.Y.y
2020-if [[ ! "$NUM" =~ ^[0-9]+\.[0-9]+(\.(y|[0-9]+))?$ ]]; then
2121- echo "${ORANGE}Error: Invalid kernel version '${INPUT}'. Expected X.Y, X.Y.Z, or X.Y.y${NO_COLOR}"
2222- echo "Examples: 6.1 | 6.1.12 | 6.1.y | v6.1.12"
2323- exit 1
2424-fi
2525-2626-echo "Building vmlinux for Linux kernel ${CYAN}${NUM}${NO_COLOR}"
2727-2828-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
2929-3030-REPO_URL="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
3131-3232-# Decide ref: maintenance branch vs tag
3333-if [[ "$NUM" == *".y" ]]; then
3434- REF="linux-${NUM}" # e.g. linux-6.16.y
3535- VERSION="${NUM%.y}" # e.g. 6.16
3636-else
3737- REF="v${NUM}" # e.g. v6.16.2 (ensure leading v)
3838- VERSION="${NUM}" # e.g. 6.16.2 (no leading v)
3939-fi
4040-4141-if [[ ! -d linux-stable ]]; then
4242- # Clone directly at the desired ref (branch or tag)
4343- git clone --depth=1 --branch "$REF" "$REPO_URL" linux-stable
4444-else
4545- # Update existing checkout to the desired ref
4646- git -C linux-stable fetch --tags --force origin
4747- # Shallow-fetch the specific ref (works for both branches and tags)
4848- git -C linux-stable fetch --depth=1 origin "$REF":"$REF" || git -C linux-stable fetch origin "$REF":"$REF"
4949- git -C linux-stable checkout -f "$REF"
5050-fi
5151-5252-cp .config linux-stable/.config
5353-5454-cd linux-stable
5555-5656-# Build
5757-yes '' | make vmlinux -j"$(nproc)" < /dev/null
5858-5959-VMLINUX="vmlinux-${VERSION}"
6060-mv vmlinux "${VMLINUX}.$(uname -m)"
6161-6262-echo "${GREEN}vmlinux built successfully!${NO_COLOR}"
6363-echo "You can find the vmlinux file in ${CYAN}$(pwd)/${VMLINUX}.$(uname -m)${NO_COLOR}"
6464-6565-exit 0