Back to home

How to build up a rpm package and use to private repository

We often use the package management tool for our convenient, with their repository. But the public repository did not already catch our require. In this case we need to build up a private repository and deploy ourself package to it.

Build a rpm package

Before you setup a whole clean system to do this, I recommend using docker container as your environment.

docker run -it centos:centos5 /bin/bash

Here is a example of python instance:

# prepare fpm
yum install -y ruby.x86_64
wget http://production.cf.rubygems.org/rubygems/rubygems-2.4.4.tgz -O /tmp/rubygems-2.4.4.tgz
tar -xf /tmp/rubygems-2.4.4.tgz -C /tmp
ruby /tmp/rubygems-2.4.4/setup.rb
gem install fpm

# Build the package
yum install -y curl tar gcc make xz zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel gdbm-devel db4-devel libpcap-devel xz-devel

curl -Sl "https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz" > Python-2.7.8.tar.xz
xz -dc < Python-2.7.8.tar.xz > Python-2.7.8.tar
tar -xvf Python-2.7.8.tar -C /tmp/
cd /tmp/Python-2.7.8
./configure --prefix=/usr/local && make -j 8
make install DESTDIR=/tmp/python
cd /tmp/python
fpm -s dir -t rpm -n python27 -v 2.7.8 -C /tmp/python -d zlib-devel -d bzip2-devel -d openssl-devel -d ncurses-devel -d sqlite-devel -d readline-devel -d gdbm-devel -d db4-devel -d libpcap-devel -d xz-devel --url http://huangx.in --description "Python 2.7.8" -m MAINTAINOR@gmail.com usr/

# output : python27-2.7.8-1.x86_64.rpm

Now, you could put the package into the private yum repository.

Setup the yum repository

http://www.harker.com/virtual/yumrepo.html

Update your package

mv SOME_WHERE/Python-2.7.8.x86_64-2.7.8-1.x86_64.rpm YUM_REPOSITORY/
sudo createrepo --update YUM_REPOSITORY/

And search it from yum if u already configurated the repository.

$ sudo repoquery python27
python27-0:2.7.8-1.x86_64