在 Linux 建立 RPM 包需要 shell 腳本與 readme 檔,後者作為前者的註解與說明。

目錄通常以「套件名-版本」命名,並把需要的檔案放進去。以 test-1.0 為例:
$ cd /usr/src/redhat
$ mkdir test-1.0
$ cd test-1.0
$ echo echo this is a test > test.sh
$ chmod +x test.sh
$ echo just launch the script > README
接著建立 .tar.gz,它需要放在 rpmbuild/SOURCES 下;另外還要一份 .specs 檔,裡面寫明所有安裝規範,是 RPM 的核心。spec 檔放在 SPECS 目錄。以下指令以一般使用者身分執行,確保 rpmbuild 位於家目錄:
$ cd
$ mkdir -p rpmbuild/SOURCES
$ mkdir -p rpmbuild/SPECS
$ tar -cvzf rpmbuild/SOURCES/test-1.0.tar.gz test-1.0