# kdev (linux kernel development tools)
```
Something I hope you know before go into the coding~
First, please watch or star this repo, I'll be more happy if you follow me.
Bug report, questions and discussion are welcome, you can post an issue or pull a request.
```
## 项目描述
本仓库提供kdev工具,用于快速构建内核编译环境、测试环境(QEMU/KVM)。
## 使用方式
假设,内核源代码目录位于```/data/linux-4.git```目录,
工作目录位于```/data/linux-4.git-build-x86_64```,
配置文件```linux4.kdev```位于工作目录中。
```shell
sourcedir = /kernel/linux-4.git
arch = x86_64
debug = True
nodocker = True
````
```shell
cd /data/linux-4.git-build-x86_64
```
切换到工作目录,执行如下命令:
```shell
kdev init
```
init 子命令用于安装内核构建依赖(执行apt-get install命令)
```shell
kdev kernel
```
kernel 子命令用于编译内核
```shell
kdev rootfs
```
rootfs 子命令用于构建根文件系统
```shell
kdev run
```
run 子命令运行虚拟机
```shell
kdev clean
```
clean 子命令用于清空编译
## 子命令详解
### kernel子命令
```shell
optional arguments:
-h, --help show this help message and exit
-V, --verbose show verbose output
-s SOURCEDIR, --sourcedir SOURCEDIR
set kernel source dir
-a ARCH, --arch ARCH set arch, default is x86_64
-w WORKDIR, --workdir WORKDIR
setup workdir
--debug enable debug
--nodocker, --host build kernel without docker environment
-j JOB, --job JOB setup compile job number
-c CLEAN, --clean CLEAN
clean docker when exit
--config CONFIG setup kernel build config
--bash break before build(just for docker build)
--mrproper make mrproper before build
```
* --mrproper 将清空工作目录进行完整编译,默认不清空,支持二次编译。经测试完整编译耗时6.36min,二次编译耗时0.63min
* --nodocker 不使用docker编译,使用host编译环境
* --bash 登陆 docker bash 终端
* --config 指定config配置
### rootfs子命令
```shell
usage: kdev rootfs [-h] [-V] [-s SOURCEDIR] [-a ARCH] [-w WORKDIR] [--debug] [-r]
optional arguments:
-h, --help show this help message and exit
-V, --verbose show verbose output
-s SOURCEDIR, --sourcedir SOURCEDIR
set kernel source dir
-a ARCH, --arch ARCH set arch, default is x86_64
-w WORKDIR, --workdir WORKDIR
setup workdir
--debug enable debug
-r, --release
```
## Debian Distribution Release
| 版本及代号 | 内核版本 | 稳定性 | 可用仓库 |
| ------------------------------ | ------------------------ | ------------------------------------------------ | ---------------------------------------------------------------------------------- |
| **Debian 12 (bookworm)** | 6.1/5.10(LTS)/5.15 | 当前的稳定(stable)版 | [链接](http://mirrors.tencent.com/debian/dists/bookworm/) |
| **Debian 11 (bullseye)** | 5.10(LTS) | 当前的旧的稳定(oldstable)版 | [链接](http://mirrors.tencent.com/debian/dists/bullseye/) |
| **Debian 10(buster)** | 4.19/4.20 | 当前的更旧的稳定(oldoldstable)版,现有长期支持 | [链接](http://mirrors.tencent.com/debian/dists/buster/) |
| Debian 9(stretch) | 4.9/4.10 | 已存档版本,现有扩展长期支持 | [链接](https://snapshot.debian.org/archive/debian/20220101T024315Z/dists/stretch/) |
| **Debian 8(jessie)** | 3.16/3.18 | 已存档版本,现有扩展长期支持 | [链接](http://snapshot.debian.org/archive/debian/20210326T030000Z/dists/jessie) |
| Debian 7(wheezy) | 3.2/3.4 | 被淘汰的稳定版 | [链接](http://snapshot.debian.org/archive/debian/20210326T030000Z/dists/wheezy) |
| **Debian 6.0(squeeze)** | 2.6.32/2.6.36/2.6.38/3.2 | 被淘汰的稳定版 | [链接](https://snapshot.debian.org/archive/debian/20160301T103342Z/dists/squeeze/) |
| Debian GNU/Linux 5.0(lenny) | 2.6.26 | 被淘汰的稳定版 | |
| Debian GNU/Linux 4.0(etch) | 2.6.18 | 被淘汰的稳定版 | |
| Debian GNU/Linux 3.1(sarge) | 2.4.27/2.6.8 | 被淘汰的稳定版 | |
| Debian GNU/Linux 3.0(woody) | 2.4.18/2.6.8 | 被淘汰的稳定版 | |
| Debian GNU/Linux 2.2(potato) | 2.2.10/2.4.18 | 被淘汰的稳定版 | |
| Debian GNU/Linux 2.1(slink) | 2.0.34/2.2.10 | 被淘汰的稳定版 | |
| Debian GNU/Linux 2.0(hamm) | 2.0.30/2.0.36 | 被淘汰的稳定版 | |
* 存档镜像: <https://snapshot.debian.org/>
## Ubuntu Distribution Release
| 版本及代号 | 内核版本 | 稳定性 | 可用仓库 |
| ----------------------------------------- | -------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ubuntu 22.04.X **LTS** (Jammy Jellyfish) | 5.15 | | [QCOW2](http://cloud-images.ubuntu.com/releases/jammy/) / [APT源](http://archive.ubuntu.com/ubuntu/dists/jammy/) / [ISO](https://old-releases.ubuntu.com/releases/jammy/) |
| Ubuntu 21.10 (Impish Indri) | 5.14 | | |
| Ubuntu 21.04 (Hirsute Hippo) | 5.11 | | |
| Ubuntu 20.10 (Groovy Gorilla) | 5.8 | | |
| Ubuntu 20.04.X **LTS** (Focal Fossa) | 5.4 | | [QCOW2](http://cloud-images.ubuntu.com/releases/focal/) / [APT源](http://archive.ubuntu.com/ubuntu/dists/focal/) / [ISO](https://old-releases.ubun