Packaging python into rpms (like a boss)
Fri, Dec 16, 2016
2-minute read
What do you do when you need to package an rpm on an Ubuntu box? You use Vagrant and FPM ofcourse!
Tools needed:
- vagrant
- virtualbox
- fpm
- a git repo with python waiting to be packaged into rpms
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/6"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", inline: <<-SHELL
# Clean up everything
yum clean all
# Install Software Collections
yum install centos-release-scl -y
# Install ruby193 + needed dependencies for fpm and some tooling
yum install ruby193 ruby193-ruby-devel python-setuptools git -y
yum groupinstall 'Development tools' -y
# Set ruby193 to be default one
echo "source /opt/rh/ruby193/enable" | sudo tee -a /etc/profile.d/ruby193.sh
source /opt/rh/ruby193/enable
# Install fpm (finally)
gem install fpm
# now it's up to you to git clone and package stuff!
SHELL
end
Getting the environment up and packaging the file:
$ vagrant up
... output removed because it's a long one!
$ vagrant ssh
[vagrant@localhost ~]$ sudo su -
[root@localhost ~]# git clone https://github.com/rfarley3/Kibana
Initialized empty Git repository in /root/Kibana/.git/
remote: Counting objects: 171, done.
remote: Total 171 (delta 0), reused 0 (delta 0), pack-reused 171
Receiving objects: 100% (171/171), 40.53 KiB, done.
Resolving deltas: 100% (100/100), done.
[root@localhost ~]# fpm -s python -t rpm Kibana/setup.py
Created package {:path=>"python-kibana-0.7-1.noarch.rpm"}
[root@localhost ~]# rpm -qip python-kibana-0.7-1.noarch.rpm
Name : python-kibana Relocations: /
Version : 0.7 Vendor: none
Release : 1 Build Date: Thu 22 Dec 2016 03:03:55 PM UTC
Install Date: (not installed) Build Host: localhost
Group : default Source RPM: python-kibana-0.7-1.src.rpm
Size : 70802 License: UNKNOWN
Signature : (none)
Packager : <root@localhost.localdomain>
URL : https://github.com/rfarley3/Kibana
Summary : Kibana configuration index (.kibana) command line interface and python API (visualization import/export and mappings refresh)
Description :
Kibana configuration index (.kibana) command line interface and python API (visualization import/export and mappings refresh)
Have fun packaging with your new reusable packaging environment!