使用fpm 方便快速生成postgresql extension分发包
fpm 是一个不错,而且强大的rpm、deb,系统启动服务工具包,我们可以用来快速的生成专业的软件分发包
演示一个pg 扩展包分发包的生成(rpm 以及deb)
安装fpm
sudo gem install --no-ri --no-rdoc fpm
clone pg 扩展项目
代码已经写好了,使用plgo 参考https://www.cnblogs.com/rongfengliang/p/10672695.html
git clone https://github.com/rongfengliang/fpm-pg-extension-package-generate-demo
生成rpm 包
- 生成
fpm -s dir -t rpm -n myplgo-extension ./example--0.1.sql=/usr/pgsql-10/share/extension/ ./example.control=/usr/pgsql-10/share/extension/ ./example.so=/usr/pgsql-10/lib/
- 查看内容
rpm2cpio myplgo-extension-1.0-1.x86_64.rpm | cpio -t
效果
./usr/pgsql-10/lib/example.so
./usr/pgsql-10/share/extension/example--0.1.sql
./usr/pgsql-10/share/extension/example.control
生成deb 包
- 生成
fpm -s dir -t deb -n myplgo-extension ./example--0.1.sql=/usr/pgsql-10/share/extension/ ./example.control=/usr/pgsql-10/share/extension/ ./example.so=/usr/pgsql-10/lib/
- 查看内容
dpkg -c myplgo-extension_1.0_amd64.deb
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/pgsql-10/
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/pgsql-10/lib/
-rw-r--r-- 0/0 3316752 2019-04-09 11:39 ./usr/pgsql-10/lib/example.so
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/pgsql-10/share/
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/pgsql-10/share/extension/
-rw-r--r-- 0/0 1005 2019-04-09 11:39 ./usr/pgsql-10/share/extension/example--0.1.sql
-rw-r--r-- 0/0 92 2019-04-09 11:39 ./usr/pgsql-10/share/extension/example.control
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/share/
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/share/doc/
drwxr-xr-x 0/0 0 2019-04-09 13:08 ./usr/share/doc/myplgo-extension/
-rw-r--r-- 0/0 142 2019-04-09 13:08 ./usr/share/doc/myplgo-extension/changelog.gz
说明
演示的比较简单,主要是使用fpm 也很简单,我们不需要关注太多的包代码细节,直接使用就可以了,主要是进行配置而已
对于需要添加系统服务的也很简单,参考如下:
% fpm -s pleaserun -t rpm -n example /usr/bin/example
% rpm -qlp example-1.0-1.x86_64.rpm
/usr/share/pleaserun/example/generate-cleanup.sh
/usr/share/pleaserun/example/install-path.sh
/usr/share/pleaserun/example/install.sh
/usr/share/pleaserun/example/launchd/10.9/files/Library/LaunchDaemons/example.plist
/usr/share/pleaserun/example/launchd/10.9/install_actions.sh
/usr/share/pleaserun/example/systemd/default/files/etc/default/example
/usr/share/pleaserun/example/systemd/default/files/etc/systemd/system/example.service
/usr/share/pleaserun/example/systemd/default/install_actions.sh
/usr/share/pleaserun/example/sysv/lsb-3.1/files/etc/default/example
/usr/share/pleaserun/example/sysv/lsb-3.1/files/etc/init.d/example
/usr/share/pleaserun/example/upstart/0.6.5/files/etc/default/example
/usr/share/pleaserun/example/upstart/0.6.5/files/etc/init/example.conf
/usr/share/pleaserun/example/upstart/1.5/files/etc/default/example
/usr/share/pleaserun/example/upstart/1.5/files/etc/init/example.conf
参考资料
https://github.com/rongfengliang/fpm-pg-extension-package-generate-demo
https://www.cnblogs.com/rongfengliang/p/10674023.html
https://www.cnblogs.com/rongfengliang/p/10672695.html
https://github.com/rongfengliang/plgo-rpm
https://github.com/rongfengliang/plgo
https://fpm.readthedocs.io/en/latest/intro.html