Skip to content

Commit b8d5295

Browse files
author
Dhaivat Pandit
committed
Packaging: first cut of working deb and rpm build
* to build deb & rpm simply run ``` version=<se.mv.er> vagrant provision ``` vagrant shell provisioner will run the inline script and generate a deb and an rpm file in the local directory. This is achieved by multivm Vagrantfile one for centos and one for debian * To install the generated deb - run sudo dpkg -i * /pgcli/pgcli_<se.mv.er>.deb (then sudo apt-get install -f if deps are missing on a clean debian install) * To install generated rpm - sudo yum install path-to-rpm * package will be installed under /usr/share/pgcli * script pgcli will be a symlink in /usr/local/bin/pgcli -> /usr/share/pgcli/bin/pgcli (with right shebang line #!/usr/share/pgcli/bin/python)
1 parent 4161f66 commit b8d5295

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,11 @@ target/
5656

5757
# PyCharm
5858
.idea/
59-
*.iml
59+
*.iml
60+
61+
# Vagrant
62+
.vagrant/
63+
64+
# Generated Packages
65+
*.deb
66+
*.rpm

Vagrantfile

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure(2) do |config|
5+
6+
config.vm.synced_folder ".", "/pgcli"
7+
8+
pgcli_version = ENV['version']
9+
pgcli_description = "Postgres CLI with autocompletion and syntax highlighting"
10+
11+
config.vm.define "debian" do |debian|
12+
debian.vm.box = "chef/debian-7.8"
13+
debian.vm.provision "shell", inline: <<-SHELL
14+
echo "-> Building DEB on `lsb_release -s`"
15+
sudo apt-get update
16+
sudo apt-get install -y libpq-dev python-dev python-setuptools rubygems
17+
sudo easy_install pip
18+
sudo pip install virtualenv virtualenv-tools
19+
sudo gem install fpm
20+
echo "-> Cleaning up old workspace"
21+
rm -rf build
22+
mkdir -p build/usr/share
23+
virtualenv build/usr/share/pgcli
24+
build/usr/share/pgcli/bin/pip install -U pip distribute
25+
build/usr/share/pgcli/bin/pip uninstall -y distribute
26+
build/usr/share/pgcli/bin/pip install /pgcli
27+
28+
echo "-> Cleaning Virtualenv"
29+
cd build/usr/share/pgcli
30+
virtualenv-tools --update-path /usr/share/pgcli > /dev/null
31+
cd /home/vagrant/
32+
33+
echo "-> Removing compiled files"
34+
find build -iname '*.pyc' -delete
35+
find build -iname '*.pyo' -delete
36+
37+
echo "-> Creating PgCLI deb"
38+
sudo fpm -t deb -s dir -C build -n pgcli -v #{pgcli_version} \
39+
-a all \
40+
-d libpq-dev \
41+
-d python-dev \
42+
-p /pgcli/ \
43+
--after-install /pgcli/post-install \
44+
--after-remove /pgcli/post-remove \
45+
--url https://github.com/amjith/pgcli \
46+
--description "#{pgcli_description}" \
47+
--license '??? #TODO(amjith)'
48+
SHELL
49+
end
50+
51+
config.vm.define "centos" do |centos|
52+
centos.vm.box = "chef/centos-7.0"
53+
centos.vm.provision "shell", inline: <<-SHELL
54+
#!/bin/bash
55+
echo "-> Building RPM on `lsb_release -s`"
56+
sudo yum install -y rpm-build gcc ruby-devel postgresql-devel python-devel rubygems
57+
sudo easy_install pip
58+
sudo pip install virtualenv virtualenv-tools
59+
sudo gem install fpm
60+
echo "-> Cleaning up old workspace"
61+
rm -rf build
62+
mkdir -p build/usr/share
63+
virtualenv build/usr/share/pgcli
64+
build/usr/share/pgcli/bin/pip install -U pip distribute
65+
build/usr/share/pgcli/bin/pip uninstall -y distribute
66+
build/usr/share/pgcli/bin/pip install /pgcli
67+
68+
echo "-> Cleaning Virtualenv"
69+
cd build/usr/share/pgcli
70+
virtualenv-tools --update-path /usr/share/pgcli > /dev/null
71+
cd /home/vagrant/
72+
73+
echo "-> Removing compiled files"
74+
find build -iname '*.pyc' -delete
75+
find build -iname '*.pyo' -delete
76+
77+
echo "-> Creating PgCLI RPM"
78+
echo $PATH
79+
sudo /usr/local/bin/fpm -t rpm -s dir -C build -n pgcli -v #{pgcli_version} \
80+
-a all \
81+
-d postgresql-devel \
82+
-d python-devel \
83+
-p /pgcli/ \
84+
--after-install /pgcli/post-install \
85+
--after-remove /pgcli/post-remove \
86+
--url https://github.com/amjith/pgcli \
87+
--description "#{pgcli_description}" \
88+
--license '??? #TODO(amjith)'
89+
SHELL
90+
end
91+
92+
end
93+

post-install

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
echo "Setting up symlink to pgcli"
4+
ln -sf /usr/share/pgcli/bin/pgcli /usr/local/bin/pgcli

post-remove

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
echo "Removing symlink to pgcli"
4+
rm /usr/local/bin/pgcli

0 commit comments

Comments
 (0)