Jin Mengfei
Jin Mengfei

Reputation: 333

Where can I find the souce code of a RPM package?

I'm using centos7, the version of the docker rpms are

[root@node-6 ~]# rpm -qa | grep docker

docker-common-1.13.1-63.git94f4240.el7.centos.x86_64

docker-client-1.13.1-63.git94f4240.el7.centos.x86_64

docker-1.13.1-63.git94f4240.el7.centos.x86_64

I downloaded the source code of docker 1.13 from github, found that it doesn't match with the log printed on the server. It seems that RHEL/CENT OS made a lot of modifications to the docker they provide. I searched a lot on google and centos rpm git, but no luck.

Is "centos edition" docker open souce? If so, where can I find the source code?

Upvotes: 0

Views: 865

Answers (1)

OldFart
OldFart

Reputation: 1721

By default, Docker is provided by the CentOS-extras repository. Here are some commands you might want to consider getting familiar with:

# To search everything 'docker' related
yum search docker

# Once found interesting package...
yum info docker

On a normal instance (that is without any extraneous/third-party repositories imported), the output should be similar to the following

Available Packages
Name        : docker
Arch        : x86_64
Epoch       : 2
Version     : 1.13.1
Release     : 96.gitb2f74b2.el7.centos
Size        : 18 M
Repo        : extras/7/x86_64
Summary     : Automates deployment of containerized applications
URL         : https://github.com/docker/docker
License     : ASL 2.0
Description : Docker is an open-source engine that automates the deployment of any
            : application as a lightweight, portable, self-sufficient container that will
            : run virtually anywhere.
            : 
            : Docker containers can encapsulate any payload, and will run consistently on
            : and between virtually any server. The same container that a developer builds
            : and tests on a laptop will run at scale, in production*, on VMs, bare-metal
            : servers, OpenStack clusters, public instances, or combinations of the above.

Then, in order to get (most of the time) the source package for a specific rpm, try the following command (assuming you have previously installed yum-utils

# Disable all repos, enable the one we have eyes on, set 'source only' and download
yumdownloader --disablerepo=\* --enablerepo=extras --source docker

Here is the output of the command

Initializing download: http://vault.centos.org/centos/7/extras/Source/SPackages/docker-1.13.1-96.gitb2f74b2.el7.centos.src.rpm
File size: 14604391 bytes
Opening output file ./docker-1.13.1-96.gitb2f74b2.el7.centos.src.rpm
Starting download

Connection 2 finished                                                          ] 41% [============================-                                         ]  0.0 B/s | 5.8 MB  --:--:-- ETA 
Connection 4 finished                                                          ]
Connection 0 finished                                                          ]
Connection 1 finished                                                          ]
[100%] [..................................................] [  14.6MB/s] [00:00]100% [======================================================================] 8.1 MB/s |  14 MB  00:00:00 ETA 

Downloaded 13.9 megabytes in 0 seconds. (14921.07 KB/s)
docker-1.13.1-96.gitb2f74b2.el7.centos.src.rpm                                                                                                                         |  14 MB  00:00:01     

Once the file is downloaded, you can either extract it or install it with rpm to access the content. Midnight Commander can also list/view/copy/extract most rpm archives to a directory of your choice.

rpm -Uvh docker-1.13.1-96.gitb2f74b2.el7.centos.src.rpm
Updating / installing...
   1:docker-2:1.13.1-96.gitb2f74b2.el7################################# [100%]

The files should have been installed in $HOME/rpmbuild SPECS folder will contain specfiles and SOURCES will contain the source code that has been compiled in order to create the said package.

In this instance, the source code file was located in $HOME/rpmbuild/SOURCES/b2f74b220126bddbae585cfe2406498ced3ae065.tar.gz

The specfile used for creating the rpm package is something of interest, also. Within the file, you will pick up on special things/modifications prior/post compiling that are 'exclusive' to the package maintainer or release.

Upvotes: 1

Related Questions