使用nfpm打包deb&&rpm


nfpm是受fpm啟發的一個deb以及rpm包制作工具,goreleaser中的rpm包制作就依賴此包(當然是同一個人開發的)
使用nfpm的好處是簡單,跨平台(基於golang同時包也小),以下是一個簡單的使用

安裝nfpm

比較簡單,從github下載即可,https://github.com/goreleaser/nfpm/releases

使用

  • init
    使用init 可以幫助我們生成一個配置模版,命令nfpm init
    nfpm init 內容如下(主要是關於deb以及rpm依賴的資源以及配置還有安裝中的一些腳本)
 
# nfpm example config file
name: "foo"
arch: "amd64"
platform: "linux"
version: "v${MY_APP_VERSION}"
section: "default"
priority: "extra"
replaces:
- foobar
provides:
- bar
depends:
- foo
- bar
# recommends on rpm packages requires rpmbuild >= 4.13
recommends:
- whatever
# suggests on rpm packages requires rpmbuild >= 4.13
suggests:
- something-else
conflicts:
- not-foo
- not-bar
maintainer: "John Doe <john@example.com>"
description: |
  FooBar is the great foo and bar software.
    And this can be in multiple lines!
vendor: "FooBarCorp"
homepage: "http://example.com"
license: "MIT"
bindir: "/usr/local/bin"
files:
  ./foo: "/usr/local/bin/foo"
  ./bar: "/usr/local/bin/bar"
config_files:
  ./foobar.conf: "/etc/foobar.conf"
overrides:
  rpm:
    scripts:
      preinstall: ./scripts/preinstall.sh
      postremove: ./scripts/postremove.sh
  deb:
    scripts:
      postinstall: ./scripts/postinstall.sh
      preremove: ./scripts/preremove.sh
  • 創建demo資源
    因為是測試,我們需要參考上邊的yaml,創建需要的文件,比如shell 腳本依賴的部署文件,內容可以為空
    主要是測試
 
├── bar
├── foo
├── foobar.conf
├── nfpm.yaml
└── scripts
    ├── postinstall.sh
    ├── postremove.sh
    ├── preinstall.sh
    └── preremove.sh
  • 打包
nfpm pkg -t /tmp/foo.deb
nfpm pkg -t /tmp/foo.rpm

效果

 

 

說明

nfpm 是一個不錯的deb以及rpm打包工具,相對比fpm 弱了點,但是安裝以及使用簡單,是一個不錯的工具

參考資料

https://github.com/goreleaser/nfpm


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM