Version: @VERSION@
Release: @RELEASE@%{dist}
Summary: YAMU ymdial
Group: Applications/Internet
License: GPL
URL: http://www.yamutech.com
Source0: ymdial-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
%description
YAMU ymdial
%prep
%setup -q -n ymdial-%{version}
%build
#make %{?_smp_mflags}
make
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/%{_bindir}
mkdir -p %{buildroot}/etc/
mkdir -p %{buildroot}/etc/init.d
mkdir -p %{buildroot}/var/log/ymdial
install -m 755 ymdial %{buildroot}/%{_bindir}/ymdial
install -m 755 config/ymdial.ini %{buildroot}/etc/
install -m 755 config/ymdiald %{buildroot}/etc/init.d/
%clean
rm -rf %{buildroot}
%post
if [ "$1" = "1" ]
then
chkconfig --add ymdiald
fi
%files
%defattr(-,root,root,-)
%{_bindir}/ymdial
/etc/ymdial.ini
%config/etc/ymdial.ini
/var/log/ymdial/
/etc/init.d/ymdiald
%preun
if [ "$1" = "0" ]
then
chkconfig --del ymdiald
fi
%changelog
参考:
https://www.cnblogs.com/xinyuyuanm/p/3212477.html
%define os .centos
Summary: YAMU high performance dns resolver
Name: yrdns
Version: @VERSION@
Release: @RELEASE@%{dist}
License: GPL
Packager: yamu <yamu@yamutech.com>
Vendor: yamutech dist-repo <www.yamutech.com/repo>
Url: http://www.yamutech.com
Source: yrdns-%{version}.tar.gz
Group: Applications/Internet
#BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
#Source1:yrdns.sysconfig
Source2:yrdnsd.service
Source3:yrdnsd.systemd
%description
YAMU high performance dns resolver
%prep
%setup -q -n yrdns-%{version}
# %%configure
%build
# %%{__make} CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
%{__make} all
%define yrdns_conf %{_sysconfdir}/yrdns.conf
%pre
if [ -f %{yrdns_conf} ]then mv %{yrdns_conf} %{yrdns_conf}.oldfi
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
mkdir -p ${RPM_BUILD_ROOT}/run/yrdns
mkdir -p ${RPM_BUILD_ROOT}/var/yrdns/{log,data}
mkdir -p ${RPM_BUILD_ROOT}/var/run/yrdns
mkdir -p %{buildroot}%{_libdir}/yrdns/gen-py/yrdns
mkdir -p ${RPM_BUILD_ROOT}/var/named/seckeys
mkdir -p ${RPM_BUILD_ROOT}/var/named/dsset
%{__make} BUILD_PATH=%{buildroot} install
%if "%{?dist}" == ".el6"
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d/
install -m 644 %{SOURCE2} ${RPM_BUILD_ROOT}/etc/init.d/yrdnsd
%endif
%if "%{?dist}" == ".el7.centos"
mkdir -p ${RPM_BUILD_ROOT}%{_unitdir}
install -m 644 %{SOURCE3} ${RPM_BUILD_ROOT}%{_unitdir}/yrdnsd.service
%endif
install -m 644 app/gen-py/*.py %{buildroot}%{_libdir}/yrdns/gen-py/
install -m 644 app/gen-py/yrdns/*.py %{buildroot}%{_libdir}/yrdns/gen-py/yrdns/
%clean
rm -rf ${RPM_BUILD_ROOT}
%post
%if "%{?dist}" == ".el7.centos"
%systemd_post yrdnsd.service
%endif
%if "%{?dist}" == ".el6"
if [ "$1" = "1" ]
then
chkconfig --add yrdnsd
fi
%endif
mv %{yrdns_conf} %{yrdns_conf}.new
if [ -f %{yrdns_conf}.old ]then mv %{yrdns_conf}.old %{yrdns_conf}else mv %{yrdns_conf}.new %{yrdns_conf}fi
%files
%defattr(-,root,root,-)
%{_bindir}/yrdns
%{_bindir}/yrdns_stat
%{_bindir}/yrdnscli.py
%{_bindir}/zoneal
%{_bindir}/zonexfr
%defattr(664,root,root,-)
%{_libdir}/yrdns/
%{_sysconfdir}/yrdns.conf
%{_var}/yrdns/root.ca
%{_var}/yrdns/dnssec.key
%{_var}/yrdns/dnstunnelDetect.ini
%{_var}/yrdns/log
%{_var}/yrdns/data
%{_var}/run/yrdns
%dir /var/named/seckeys
%defattr(755,root,root,-)
%dir /var/named/dsset
%defattr(755,root,root,-)
%dir /run/yrdns
%defattr(755,root,root,-)
%if "%{?dist}" == ".el6"
%{_sysconfdir}/init.d/yrdnsd
%endif
%if "%{?dist}" == ".el7.centos"
%{_unitdir}/yrdnsd.service
%endif
%postun
%if "%{?dist}" == ".el7.centos"
%systemd_postun_with_restart yrdnsd.service
%endif
%preun
%if "%{?dist}" == ".el6"
if [ "$1" = "0" ]
then
chkconfig --del yrdnsd
fi
%endif
%if "%{?dist}" == ".el7.centos"
%systemd_preun yrdnsd.service
%endif
*** ERROR: No build ID note found in /home/wuyang/rpmbuild/BUILDROOT/******
error: Bad exit status from /var/tmp/rpm-tmp.BPd1OI (%install)
解决方法是在.spec文件中任意位置添加如下参数:
%define __debug_install_post \
%{_rpmconfigdir}/find-debuginfo.sh %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
重新打包,即可。
TGT=ymdial
SRCS=$(wildcard ./src/*.cpp)
LIBRAYS= -lrt -lpthread -ldl -lz -lresolv -lcrypto -lssl -lnetsnmp ./lib/*.a
COMPILE_FLAGS= -g -W -O2 -DHAVE_NETINET_IN_H -I./include -I./clib/include -I/usr/include/openssl
CC=g++
all:$(TGT)
@echo Generation target!
$(TGT):$(SRCS:.cpp=.o)
$(CC) -o $@ $^ $(LIBRAYS) $(COMPILE_FLAGS)
%.o : %.cpp
$(CC) -c $(COMPILE_FLAGS) $<-o $@
.PHONY: clean rpmclean
clean:
rm -rf $(TGT) $(SRCS:.cpp=.o)
RPM_VERSION = $(shell sed -ne 's/\#define\(\ \)\{1,\}VERSION\(\ \)\{1,\}\"\(.*\)\"/\3/p' ./include/version.h)
COMMIT = $(shell git rev-list HEAD |head -1|cut -c 1-6)
RPM_RELEASE = edns_dial
RPM_TOP_DIR = $(shell rpm -E %{_topdir})
PRJHOME = $(shell pwd)
rpm:
@echo [RPM] \
sed -e "s/@VERSION@/$(RPM_VERSION)/g" -e "s/@RELEASE@/$(RPM_RELEASE)/g" $(TGT).spec.tmp >${RPM_TOP_DIR}/SPECS/$(TGT).spec \
cp -a -r ${PRJHOME} /tmp/$(TGT)-$(RPM_VERSION) \
cd /tmp \
tar zcvf $(RPM_TOP_DIR)/SOURCES/$(TGT)-$(RPM_VERSION).tar.gz $(TGT)-$(RPM_VERSION) \
rm -rf $(TGT)-$(RPM_VERSION) \
rpmbuild -bb $(RPM_TOP_DIR)/SPECS/$(TGT).spec \
rpmclean:
cp -r ~/rpmbuild/RPMS/x86_64/$(TGT)*$(RPM_VERSION)* ./
rm -rf ~/rpmbuild/SOURCES/$(TGT)* \
~/rpmbuild/BUILD/$(TGT)* \
~/rpmbuild/RPMS/x86_64/$(TGT)* \
~/rpmbuild/SPEC/$(TGT)*
rpm -qa | grep drmsd | xargs rpm -e --nodeps
rpm2cpio xxx.rpm | cpio -div
mspaint,control。spec文件是配置规范文件,是RPM软件包编译过程的核心,配合rpmbuild命令使用,mspaint,control不是针对spec文件的 *** 作命令。spec文件说明了软件包如何被配置、打那些补丁、安装哪些文件、安装到哪里、安装过程需要哪些系统级别活动。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)