centos 查看命令源码

【附送福利】阿里云1888元优惠券红包免费领取https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=t9686fzw
html

# yum install yum-utilscentos


设置源:
[base-src]
name=CentOS-5.4 - Base src -
baseurl=http://vault.centos.org/5.4/os/SRPMS/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=SRPMS&repo=os
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5ui


[updates-src]
name=CentOS-5.4 - Updates src-centos
baseurl=http://vault.centos.org/5.4/updates/SRPMS/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=SRPMS&repo=updates
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
阿里云


#packages used/produced in the build but not released
[addons-src]
name=CentOS-5.4 - Addons src -
baseurl=http://vault.centos.org/5.4/addons/SRPMS/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=SRPMS&repo=addons
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
url


#additional packages that may be useful
[extras-src]
name=CentOS-5.4 - Extras src-centos
baseurl=http://vault.centos.org/5.4/extras/SRPMS/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=SRPMS&repo=extras
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
htm


#additional packages that extend functionality of existing packages
[centosplus-src]
name=CentOS-5.4 - Plus src-centos
baseurl=http://vault.centos.org/5.4/centosplus/SRPMS/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=SRPMS&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
get


#contrib - packages by Centos Users
[contrib-src]
name=CentOS-5.4 - Contrib src-centos
baseurl=http://vault.centos.org/5.4/contrib/SRPMS/
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=SRPMS&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
源码


怎么查看某个命令的源代码pm2

好比想查看uname这个命令的源代码it

[root@localhost usr]# whereis uname

uname: /bin/uname /usr/share/man/man1/uname.1.gz /usr/share/man/man2/uname.2.gz /usr/share/man/man1p/uname.1p.gz /usr/share/man/man3p/uname.3p.gz

[root@localhost usr]# rpm -qf /bin/uname

coreutils-8.5-7.fc14.i686

##没有yumdownloader 的话能够这样子安装#yum install yum-utils

[workhard@localhost tmp]$ yumdownloader --source coreutils-8.5-7.fc14.i686 ##source下载源码包

到这一步后有两种方法能够查看到源码包,第一种方法

[workhard@localhost tmp]$ rpm -qpl coreutils-8.5-7.fc14.src.rpm | grep tar ##查询rpm中的tar文件,源码通常放在这里

coreutils-8.5.tar.xz

##从rpm包中提取指定的文件

[workhard@localhost tmp]$ rpm2cpio coreutils-8.5-7.fc14.src.rpm | cpio -idv coreutils-8.5.tar.xz

coreutils-8.5.tar.xz

9446 blocks

[workhard@localhost coreutils-8.5]$ tar xjvf coreutils-8.5.tar.xz

##到解压出来的coreutils-8.5/src/中就能找到相关的源码了

第二种方法:安装源码包

[workhard@localhost tmp]$ rpm -i coreutils-8.5-7.fc14.src.rpm ##安装源码包

warning: user mockbuild does not exist - using root

warning: group mockbuild does not exist - using root

##centos和rhel通常安装后的源码在/usr/src/redhat下的各个目录下,但fedora是在~/rpmbuild/SOURCES/

##能够经过locate命令查询代码包被安装到哪里了

[workhard@localhost tmp]$ locate *coreutils*tar*

/home/workhard/tmp/coreutils-8.5.tar.xz

/home/workhard/rpmbuild/SOURCES/coreutils-8.5.tar.xz

[workhard@localhost tmp]$ cd /home/workhard/rpmbuild/SOURCES/c

[workhard@localhost SOURCES]$ tar Jxvf coreutils-8.5.tar.xz

[workhard@localhost src]$ cd coreutils-8.5/src/

[workhard@localhost src]$ ll uname*

-rw-r--r--. 1 workhard workhard 48 Jan 1 2010 uname-arch.c

-rw-r--r--. 1 workhard workhard 10024 Jan 1 2010 uname.c

-rw-r--r--. 1 workhard workhard 146 Jan 1 2010 uname.h

-rw-r--r--. 1 workhard workhard 49 Jan 1 2010 uname-uname.c

安装*.src.rpm后怎么卸载

[workhard@localhost SOURCES]$ cd /home/workhard/rpmbuild/SOURCES

[workhard@localhost SPECS]$ rpmbuild --rmsource --rmspec coreutils.spec

**相关说明

1、yumdownloader comes from the yum-utils package, if you don't have that installed already.

#yum install yum-utils

2、RPM用法

rpm {-i|--install} [install-options] PACKAGE_FILE ...

-f, --file FILE

Query package owning FILE.

-p, --package PACKAGE_FILE

Query an (uninstalled) package PACKAGE_FILE.

-l, --list

List files in package.

-qf:查找指定文件属于哪一个RPM软件包

-qpl:列出RPM软件包内的文件信息;

3、rpm2cpio - Extract cpio archive from RPM Package Manager (RPM) package.

顾名思义,rpm2cpio是将rpm包文件转换成cpio归档文件

4、CPIO用法

cpio - copy files to and from archives

-i 抽取的意思,和"--extract"等同

-d 创建目录,和"--make-directories"等同

-v 冗余信息输出,和"--verbose"等同

5、rpmbuild用法

--rmsource

Remove the sources after the build

--rmspec

Remove the spec file after the build

【附送福利】阿里云1888元优惠券红包免费领取https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=t9686fzw

拿走不谢~

相关文章
相关标签/搜索