当前位置: 首页 > news >正文

Ubuntu 22.04 源码下载的几种方法

1、查询当前系统内核版本

root@ubuntu22:~# uname -r
5.15.0-118-generic

2、查询本地软件包数据库中的内核源码信息

root@ubuntu22:~# apt search linux-source
Sorting... Done
Full Text Search... Done
linux-source/jammy-updates,jammy-security,now 5.15.0.119.119 all [installed]Linux kernel source with Ubuntu patcheslinux-source-5.15.0/jammy-updates,jammy-security,now 5.15.0-119.129 all [installed,automatic]Linux kernel source for version 5.15.0 with Ubuntu patcheslinux-source-5.19.0/jammy-updates,jammy-security 5.19.0-50.50 allLinux kernel source for version 5.19.0 with Ubuntu patcheslinux-source-6.2.0/jammy-updates,jammy-security 6.2.0-39.40~22.04.1 allLinux kernel source for version 6.2.0 with Ubuntu patcheslinux-source-6.5.0/jammy-updates 6.5.0-45.45~22.04.1 allLinux kernel source for version 6.5.0 with Ubuntu patches

3、apt source 与 apt install

3.1 apt source

将内核源码下载到当前目录并自动解压,提供了更完整的源代码包,包括 Ubuntu 特定的修改。
(1)apt source linux
安装仓库中最新可用的内核源代码版本
linux总是可用的,指向最新通用版本
(2)apt source linux-image-$(uname -r)
获取与当前运行的内核版本完全匹配的源代码
并非所有版本在仓库中都有对应的 linux-image-$(uname -r)包

3.2 apt install

将内核源码下载到/usr/src目录,安装的是一个"原始"的源代码包,可能需要额外的步骤来应用 Ubuntu 特定的补丁。
(1)apt install linux-source
安装仓库中最新可用的内核源代码版本
linux-source 包总是可用的,指向最新版本
(2)apt install linux-source-<version>
安装指定版本的内核源代码
并非所有版本都有对应的 linux-source-<version> 包
5.15.0-118-generic,version=5.15.0,将下载 5.15 系列的通用源码。
如要精确匹配 5.15.0-118-generic 版本,需要额外下载 Ubuntu 特定的补丁。

4、apt下载源码

(1)apt source linux

root@ubuntu22:~# apt source linux
Reading package lists... Done
NOTICE: 'linux' packaging is maintained in the 'Git' version control system at:
git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
Please use:
git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
to retrieve the latest (possibly unreleased) updates to the package.
eed to get 206 MB of source archives.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux 5.15.0-121.131 (dsc) [7,799 B]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux 5.15.0-121.131 (tar) [195 MB]
Get:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux 5.15.0-121.131 (diff) [10.5 MB]                    
Fetched 206 MB in 49s (4,168 kB/s)                                                                                           
dpkg-source: info: extracting linux in linux-5.15.0
dpkg-source: info: unpacking linux_5.15.0.orig.tar.gz
dpkg-source: info: applying linux_5.15.0-121.131.diff.gzroot@ubuntu22:~# ll
total 200708
drwxr-xr-x  3 root root      4096 Sep 13 06:32 ./
drwx------  6 root root      4096 Sep 13 06:23 ../
drwxr-xr-x 28 root root      4096 Sep 13 06:32 linux-5.15.0/
-rw-r--r--  1 root root  10533549 Aug 12 13:17 linux_5.15.0-121.131.diff.gz
-rw-r--r--  1 root root      7799 Aug 12 13:17 linux_5.15.0-121.131.dsc
-rw-r--r--  1 root root 194969557 Nov 18  2021 linux_5.15.0.orig.tar.gzroot@ubuntu22:~# cat linux-5.15.0/Makefile
...
VERSION = 5
PATCHLEVEL = 15
SUBLEVEL = 163
EXTRAVERSION =
NAME = Trick or Treat
...

(2)apt source linux-image-$(uname -r)

root@ubuntu22:~# apt source linux-image-$(uname -r)
Reading package lists... Done
Picking 'linux-signed' as source package instead of 'linux-image-5.15.0-118-generic'
Need to get 26.4 kB of source archives.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux-signed 5.15.0-121.131 (dsc) [2,370 B]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux-signed 5.15.0-121.131 (tar) [24.1 kB]
Fetched 26.4 kB in 1s (51.3 kB/s)       
dpkg-source: info: extracting linux-signed in linux-signed-5.15.0
dpkg-source: info: unpacking linux-signed_5.15.0-121.131.tar.xzroot@ubuntu22:~# ll
total 40
drwxr-xr-x 3 root root  4096 Sep 13 06:49 ./
drwx------ 6 root root  4096 Sep 13 06:44 ../
drwxr-xr-x 3 root root  4096 May 27 13:50 linux-signed-5.15.0/
-rw-r--r-- 1 root root  2370 Aug 12 13:17 linux-signed_5.15.0-121.131.dsc
-rw-r--r-- 1 root root 24076 Aug 12 13:17 linux-signed_5.15.0-121.131.tar.xzroot@ubuntu22:~# ll linux-signed-5.15.0/
total 24
drwxr-xr-x 3 root root 4096 May 27 13:50 ./
drwxr-xr-x 3 root root 4096 Sep 13 06:49 ../
drwxr-xr-x 6 root root 4096 Aug  9 08:16 debian/
-rwxr-xr-x 1 root root 6988 May 23 15:13 download-signed*
-rwxr-xr-x 1 root root  450 May 23 15:13 download-unsigned*root@ubuntu22:~# ll linux-signed-5.15.0/debian/
total 180
drwxr-xr-x 6 root root   4096 Aug  9 08:16 ./
drwxr-xr-x 3 root root   4096 May 27 13:50 ../
drwxr-xr-x 3 root root   4096 Aug  1 13:01 ancillary/
-rw-r--r-- 1 root root 121300 Aug  9 08:16 changelog
-rw-r--r-- 1 root root      2 Apr 25 14:35 compat
-rw-r--r-- 1 root root   1949 Aug  9 08:16 control
-rw-r--r-- 1 root root    277 Aug  6 13:11 control.stub
-rw-r--r-- 1 root root   1456 Nov 14  2023 copyright
-rw-r--r-- 1 root root    163 Aug  6 13:11 package.config
-rwxr-xr-x 1 root root   5693 Aug  6 13:11 rules*
drwxr-xr-x 3 root root   4096 Aug  6 13:11 scripts/
-rw-r--r-- 1 root root     12 Aug  6 13:11 signed-version
drwxr-xr-x 2 root root   4096 Nov 14  2023 source/
drwxr-xr-x 2 root root   4096 Aug  6 13:11 templates/
-rw-r--r-- 1 root root     21 Aug  9 07:41 tracking-bug

(3)apt source linux-image-unsigned-$(uname -r)

root@ubuntu22:~# apt source linux-image-unsigned-$(uname -r)
Reading package lists... Done
Picking 'linux' as source package instead of 'linux-image-unsigned-5.15.0-118-generic'
NOTICE: 'linux' packaging is maintained in the 'Git' version control system at:
git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
Please use:
git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 206 MB of source archives.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux 5.15.0-121.131 (dsc) [7,799 B]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux 5.15.0-121.131 (tar) [195 MB]
Get:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main linux 5.15.0-121.131 (diff) [10.5 MB]
Fetched 206 MB in 2min 21s (1,455 kB/s)                                                                                      
dpkg-source: info: extracting linux in linux-5.15.0
dpkg-source: info: unpacking linux_5.15.0.orig.tar.gz
dpkg-source: info: applying linux_5.15.0-121.131.diff.gz

(4)apt install linux-source

# cd /usr/src# ll
total 16
drwxr-xr-x  4 root root 4096 Aug 20 08:12 ./
drwxr-xr-x 14 root root 4096 Aug  9  2022 ../
drwxr-xr-x 25 root root 4096 Aug 20 08:12 linux-headers-5.15.0-118/
drwxr-xr-x  7 root root 4096 Aug 20 08:12 linux-headers-5.15.0-118-generic/# apt install linux-source
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:linux-source-5.15.0
Suggested packages:libncurses-dev | ncurses-dev kernel-package libqt3-dev
The following NEW packages will be installed:linux-source linux-source-5.15.0
0 upgraded, 2 newly installed, 0 to remove and 112 not upgraded.
Need to get 153 MB of archives.
After this operation, 161 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main amd64 linux-source-5.15.0 all 5.15.0-121.131 [153 MB]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main amd64 linux-source all 5.15.0.121.121 [2,310 B]          
Fetched 153 MB in 1min 23s (1,834 kB/s)# ll
total 20
drwxr-xr-x  5 root root 4096 Sep 13 03:45 ./
drwxr-xr-x 14 root root 4096 Aug  9  2022 ../
drwxr-xr-x 25 root root 4096 Aug 20 08:12 linux-headers-5.15.0-118/
drwxr-xr-x  7 root root 4096 Aug 20 08:12 linux-headers-5.15.0-118-generic/
drwxr-xr-x  4 root root 4096 Sep 13 03:45 linux-source-5.15.0/
lrwxrwxrwx  1 root root   47 Aug  9 08:15 linux-source-5.15.0.tar.bz2 -> linux-source-5.15.0/linux-source-5.15.0.tar.bz2# ll linux-source-5.15.0
total 149944
drwxr-xr-x  4 root root      4096 Sep 13 03:45 ./
drwxr-xr-x  5 root root      4096 Sep 13 03:45 ../
drwxr-xr-x 15 root root      4096 Sep 13 03:45 debian/
drwxr-xr-x  7 root root      4096 Sep 13 03:45 debian.master/
-rw-r--r--  1 root root 153523863 Aug  9 08:15 linux-source-5.15.0.tar.bz2

(5)apt install linux-source-5.15.0

# apt install linux-source-5.15.0
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:libncurses-dev | ncurses-dev kernel-package libqt3-dev
The following NEW packages will be installed:linux-source-5.15.0
0 upgraded, 1 newly installed, 0 to remove and 112 not upgraded.
Need to get 153 MB of archives.
After this operation, 161 MB of additional disk space will be used.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/main amd64 linux-source-5.15.0 all 5.15.0-121.131 [153 MB]
Fetched 153 MB in 1min 4s (2,401 kB/s) # ll
total 20
drwxr-xr-x  5 root root 4096 Sep 13 07:29 ./
drwxr-xr-x 14 root root 4096 Aug  9  2022 ../
drwxr-xr-x 25 root root 4096 Aug 20 08:12 linux-headers-5.15.0-118/
drwxr-xr-x  7 root root 4096 Aug 20 08:12 linux-headers-5.15.0-118-generic/
drwxr-xr-x  4 root root 4096 Sep 13 07:29 linux-source-5.15.0/
lrwxrwxrwx  1 root root   47 Aug  9 08:15 linux-source-5.15.0.tar.bz2 -> linux-source-5.15.0/linux-source-5.15.0.tar.bz2c# ll linux-source-5.15.0
total 149944
drwxr-xr-x  4 root root      4096 Sep 13 07:29 ./
drwxr-xr-x  5 root root      4096 Sep 13 07:29 ../
drwxr-xr-x 15 root root      4096 Sep 13 07:29 debian/
drwxr-xr-x  7 root root      4096 Sep 13 07:29 debian.master/
-rw-r--r--  1 root root 153523863 Aug  9 08:15 linux-source-5.15.0.tar.bz2

5、launchpad

Ubuntu 官方使用的代码托管和协作平台,可以浏览下载 Ubuntu 内核源码
https://code.launchpad.net/ubuntu/+source/linux

ubuntu22.04

git clone https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy

git tag
最接近5.15.0-118-generic的版本为 Ubuntu-5.15.0-118.128

git checkout Ubuntu-5.15.0-118.128

只clone指定标签的最新代码(无其它标签)(有没有single-branch参数结果都一样)

git clone --branch Ubuntu-5.15.0-118.128 --depth 1 --single-branch https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy

6、https://kernel.ubuntu.com/git/

版本列表链接到code.launchpad.net

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 项目中遇到的问题
  • 【论文阅读】Face2Diffusion for Fast and Editable Face Personalization
  • 搜索引擎onesearch3实现解释和升级到Elasticsearch v8系列(五)-聚合
  • GitHub每日最火火火项目(9.20)
  • 【简单点】docker如何部署tomcat
  • 线程池的类型
  • 掌握顶会流量密码!“Mamba+CNN”双热点组合!轻松找到创新点!
  • EP21 Promise封装request请求
  • Java企业面试题3
  • 数据结构—单链表
  • 让医院更智慧,让决策更容易
  • LeetCode_sql_day30(1264.页面推荐)
  • ROS学习笔记13——rosbag功能包的简单使用
  • 【自动化测试】常见的自动化遍历工具以及如何选择合适的自动化遍历工具
  • 1、vectorCast单元测试常用操作
  • 实现windows 窗体的自己画,网上摘抄的,学习了
  • [ JavaScript ] 数据结构与算法 —— 链表
  • 【翻译】Mashape是如何管理15000个API和微服务的(三)
  • 【附node操作实例】redis简明入门系列—字符串类型
  • 10个最佳ES6特性 ES7与ES8的特性
  • C++类中的特殊成员函数
  • CSS相对定位
  • IIS 10 PHP CGI 设置 PHP_INI_SCAN_DIR
  • Laravel Telescope:优雅的应用调试工具
  • leetcode46 Permutation 排列组合
  • Linux编程学习笔记 | Linux多线程学习[2] - 线程的同步
  • 第13期 DApp 榜单 :来,吃我这波安利
  • 聊聊flink的TableFactory
  • 前端攻城师
  • ​字​节​一​面​
  • # Redis 入门到精通(八)-- 服务器配置-redis.conf配置与高级数据类型
  • # windows 安装 mysql 显示 no packages found 解决方法
  • #QT 笔记一
  • #window11设置系统变量#
  • ( 10 )MySQL中的外键
  • (6)【Python/机器学习/深度学习】Machine-Learning模型与算法应用—使用Adaboost建模及工作环境下的数据分析整理
  • (7)svelte 教程: Props(属性)
  • (delphi11最新学习资料) Object Pascal 学习笔记---第14章泛型第2节(泛型类的类构造函数)
  • (zt)最盛行的警世狂言(爆笑)
  • (二) 初入MySQL 【数据库管理】
  • (附源码)spring boot校园拼车微信小程序 毕业设计 091617
  • (附源码)计算机毕业设计SSM基于健身房管理系统
  • (佳作)两轮平衡小车(原理图、PCB、程序源码、BOM等)
  • (接口封装)
  • (九)信息融合方式简介
  • (亲测有效)解决windows11无法使用1500000波特率的问题
  • (十二)devops持续集成开发——jenkins的全局工具配置之sonar qube环境安装及配置
  • (一)SvelteKit教程:hello world
  • (译)计算距离、方位和更多经纬度之间的点
  • (原創) 人會胖會瘦,都是自我要求的結果 (日記)
  • (转)Linq学习笔记
  • (转载)PyTorch代码规范最佳实践和样式指南
  • .Mobi域名介绍
  • .NET 3.0 Framework已经被添加到WindowUpdate
  • .NET Micro Framework初体验(二)