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

拿走不謝~

相關文章
相關標籤/搜索