参考资源
http://vbird.dic.ksu.edu.tw/linux_basic/0520rpm_and_srpm_3.php
http://linux.vbird.org/linux_basic/0520source/main.tgz
第一 源码,并加上Makefile
wget http://linux.vbird.org/linux_basic/0520source/main.tgz
mkdir -p /usr/local/src/main-0.1
tar -zxvf main.tgz -C /usr/local/src/main-0.1
cd /usr/local/src/main-0.1/
tar -czvf main-0.1.tar.gz main-0.1
## add Makefile 要记得下载回来的main.tgz不包括这个文件哦 要加才行
vim Makefile
LIBS = -lm
OBJS = main.o haha.o sin_value.o cos_value.o
main: ${OBJS}
gcc -o main ${OBJS} ${LIBS}
clean:
rm -f main ${OBJS}
install:
install -m 755 main $(RPM_INSTALL_ROOT)/usr/local/bin/main
# 记得 gcc 与 rm 之前是使用
第二 源码放到 /usr/src/redhat/SOURCES 底下,并创建 *.spec 的配置
[root@c main-0.1]# cd ..
[root@c src]# tar -zcvf main-0.1.tar.gz main-0.1
# 此时会产生 main-0.1.tar.gz ,将他挪到 /usr/src/redhat/SOURCES 底下:
[root@c src]# cp main-0.1.tar.gz /usr/src/redhat/SOURCES
创建 *.spec 的配置档
[root@c ~]# cd /usr/src/redhat/SPECS
[root@c SPECS]# vim main.spec
Summary: calculate sin and cos value.
Name: main
Version: 0.1
Release: 1
License: GPL
Group: VBird's Home
#<==记得要写正确的 Tarball 档名喔!
Source: main-0.1.tar.gz
Url: http://linux.vbird.org
Packager: VBird
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
This package will let you input your name and calculate sin cos value.
%prep
%setup -q
%build
make
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/usr/local/bin
make install RPM_INSTALL_ROOT=%{buildroot}
%files
/usr/local/bin/main
%changelog
* Wed Jul 01 2009 VBird Tsai
- build the program
第三编译成RPM AND SRPM
[root@c SPECS]# rpmbuild -ba main.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.3469
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
….(前面省略)….
Processing files: main-debuginfo-0.1-1
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/main-0.1-1-root
Wrote: /usr/src/redhat/SRPMS/main-0.1-1.src.rpm
Wrote: /usr/src/redhat/RPMS/x86_64/main-0.1-1.x86_64.rpm
Wrote: /usr/src/redhat/RPMS/x86_64/main-debuginfo-0.1-1.x86_64.rpm
[root@c SPECS]# rpm -ivh /usr/src/redhat/RPMS/x86_64/main-0.1-1.x86_64.rpm
[root@c SPECS]# rpm -ql main
/usr/local/bin/main
[root@c SPECS]# rpm -qi main
Name : main Relocations: (not relocatable)
Version : 0.1 Vendor: (none)
Release : 1 Build Date: Wed 14 Aug 2013 09:10:47 AM CST
Install Date: Wed 14 Aug 2013 09:11:32 AM CST Build Host: c.com
Group : VBird's Home Source RPM: main-0.1-1.src.rpm
Size : 5088 License: GPL
Signature : (none)
Packager : VBird
URL : http://linux.vbird.org
Summary : calculate sin and cos value.
Description :
This package will let you input your name and calculate sin cos value.
SRPM 的编译命令 -ba/-bb
rpmbuild -ba rp-pppoe.spec