PDA

View Full Version : Rpm build error: file must begin with /


umaparvathy
15th August 2010, 05:49 PM
Hi All,

I'm trying to create own rpm. with system V init script .. but i'm getting stuck in %files section...





Please help me out...


Here my spec file

# This is the spec file for daemonsas
%define _topdir /usr/local/up/rpm
%define name daemonsas
%define release 1
%define version 1.2
%define buildroot %{_topdir}/%{name}-%{version}-root
BuildRoot:%{_topdir}
Summary:GNU daemonsas
License:GPL
Name:%{name}
Version:%{version}
Release:%{release}
Source:%{name}-%{version}.tgz
Group:Development tools
%description
Listen the tcp port and prints the received messages from the port to syslog
%prep
%setup -q
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/sbin/daemonsas-1.2
mkdir -p $RPM_BUILD_ROOT/etc/daemonsas-1.2
mkdir -p $RPM_BUILD_ROOT/etc/init.d/daemonsas-1.2
# install -m 755 -d %{buildroot}/usr/sbin/daemonsas-1.2
# install -m 755 -d %{buildroot}/etc/daemonsas-1.2
install -m 755 daemonsas $RPM_BUILD_ROOT/usr/sbin/daemonsas-1.2
install -m 644 daemonsas.conf $RPM_BUILD_ROOT/etc/daemonsas-1.2
install -m 755 daemond $RPM_BUILD_ROOT/etc/init.d/daemonsas-1.2
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
%post
# cp daemond /etc/init.d
# chmod +x /etc/init.d/daemond
if [ -x /sbin/chkconfig ]; then
/sbin/chkconfig -add daemond
else
for i in 2 3 5 ; do
ln -sf /etc/init.d/daemond /etc/rc.d/rc${i}.d/S91daemond
done
for i 1 4 6 ; do
ln -sf /etc/init.d/daemond /etc/rc.d/rc${i}.d/K30daemond
done
fi
%preun
if [ $1 = 0 ] ; then
/sbin/chkconfig --del daemond
/sbin/service daemond stop &>/dev/null
fi
exit 0
%files
%defattr(-, root, root)
/usr/sbin/daemonsas-1.2/daemonsas
/etc/daemonsas-1.2/daemonsas.conf
/etc/init.d/daemond
-------------------

The error is

+ install -m 755 daemonsas $'/usr/local/up/rpm/daemonsas-1.2-root/usr/sbin/daemonsas-1.2\r'
+ install -m 644 daemonsas.conf $'/usr/local/up/rpm/daemonsas-1.2-root/etc/daemonsas-1.2\r'
+ install -m 755 daemond $'/usr/local/up/rpm/daemonsas-1.2-root/etc/init.d/daemonsas-1.2\r'
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: daemonsas-1.2-1
error: File must begin with "/":
error: File not found: /usr/local/up/rpm/daemonsas-1.2-root/usr/sbin/daemonsas-1.2/daemonsas
error: File not found: /usr/local/up/rpm/daemonsas-1.2-root/etc/daemonsas-1.2/daemonsas.conf
error: File not found: /usr/local/up/rpm/daemonsas-1.2-root/etc/init.d/daemond


RPM build errors:
File must begin with "/":
File not found: /usr/local/up/rpm/daemonsas-1.2-root/usr/sbin/daemonsas-1.2/daemonsas
File not found: /usr/local/up/rpm/daemonsas-1.2-root/etc/daemonsas-1.2/daemonsas.conf
File not found: /usr/local/up/rpm/daemonsas-1.2-root/etc/init.d/daemond


--------------------------

if i look in daemonsas-1.2-root dir i've etc,sbin dir
but in etc, sbin directories has a sub dir as daemonsas-1.2?
why such character is added with the dir?

if i add the '?' character in the files section such as

%files
%defattr(-,root,root)
/usr/sbin/daemonsas-1.2?/daemonsas
/etc/daemonsas-1.2?/daemonsas
/etc/init.d/daemonsas-1.2?/daemond

the error as "RPM build errors: file must begin with /"

Please help me out how to resolve it..



Thanks in advance,

regards,
umaparvathy

leigh123linux
15th August 2010, 06:16 PM
Remove this crap from the spec file

# This is the spec file for daemonsas
%define _topdir /usr/local/up/rpm


%define buildroot %{_topdir}/%{name}-%{version}-root
BuildRoot:%{_topdir}


Replace the buildroot bit with

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

umaparvathy
16th August 2010, 05:21 PM

Hi,

I resolved the rpm build error, it's becoz of i've transfered files from windows desktop to redhat using winscp ...
i've used the following code

:set fileformat=unix
:wq


But now problem in installing the rpm :rolleyes:
When i install the rpm i'm getting the following error


[root@localhost i686]# rpm -ivh daemonsas-1.2-1.i686.rpm
Preparing... ########################################### [100%]
1:daemonsas ########################################### [100%]
error reading information on service daemond: No such file or directory
error: %post(daemonsas-1.2-1.i686) scriptlet failed, exit status 1





Here is my System V init script (daemond)

#!/bin/sh
# chkconfig: 235 91 30
# processname:daemond
# pidfile: /var/run/daemond.pid
# config /etc/daemonsas-1.2/daemonsas.conf
#source function library
. /etc/rc.d/init.d/functions

RET=0
daemonsas="/usr/sbin/daemonsas-1.2/daemonsas"
lockfile="/var/run/subsys/daemonsas"

case "$1" in
start)
echo "***starting the service***"
if [ -f $daemonsas ] ; then
daemon $daemonsas
RET=$?
echo
[ $RET = 0 ] && touch ${lockfile}
fi
;;
stop)
echo "***stoping the service***"
killproc -d 10 $daemonsas
RET=$?
echo
[ $RET -eq 0 ] && rm -f ${lockfile}
;;
status)
echo "***status the service***"
status daemond
RET=$?
;;
restart)
echo "***restarting the service***"
$0 stop
sleep 3
$0 start
;;
reload)
echo "***Reloading the service***"
killproc $daemonsas -HUP
;;
*)
echo "usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit $RET


Please help me out...

Thanks in advance..
Regards,
Umaparvathy

leigh123linux
16th August 2010, 05:46 PM
Does this help?

https://fedoraproject.org/wiki/Packaging/SysVInitScript