启用源代码存储库
编辑/etc/apt/sources.list文件:
$ sudo vi /etc/apt/sources.list
deb-src指定Ubuntu发行版源代码地址:
# Sources specification for the Ubuntu 20.04 LTS distro # deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
其中
deb-src
:指明我们需要.DEB文件的源代码。http://archive.ubuntu.com/ubuntu
:获取.deb文件索引和源代码的URL。focal
:Ubuntu Linux 20.04 LTS代号mainstrict Universe multiverse
:存储库的状态组件名称,例如main,restricted,universe 和multiverse
如何下载Debian软件包源代码
该过程与Ubuntu相同,但是URL稍有不同:
$ sudo vi /etc/apt/sources.list
添加源码存储库地址:
# source repo for Debian 10 buster # deb-src deb http://deb.debian.org/debian buster main
然后运行下面命令更新索引:
$ sudo apt-get update
下载软件包的源代码:
$ apt-get source apache2
更新索引
更新刚设置的deb-src定义的索引文件:
$ sudo apt-get update # 或者 $ sudo apt update
下载Ubuntu软件包源代码
使用下面语法下载软件包的源代码
$ sudo apt-get source {pkg1} $ sudo apt-get source bash
如果没有设置deb-src,将会报错:E: You must put some source URIs in your sources.list
如果我们不想解压下载的源码包:
将--download-only
选项传递给apt-get
命令:
$ sudo apt-get --download-only source source bash
如何提取deb源码包中的文件:
$ dpkg-source -x /path/to/pkg.dsc $ dpkg-source -x bash_5.0-6ubuntu1.1.dsc
还可以直接构建软件包:
$ sudo apt-get --build source {pkg} $ sudo apt-get --build source bash
如何使用apt-get命令或apt命令获取已安装软件的源代码?
在Debian或Ubuntu系统上如何下载软件包的源代码?
日期:2020-03-23 08:03:53 来源:oir作者:oir