Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i would like to create a rpm . But it should have sysV init script to start and stop service which has to be installed into /etc/init.d....
I'm using a tarball as a source which has one excutable file,conf file.. that conf file should go to /etc/, executable file should go to /usr/sbin
so in the spec file i've given like (spec file for daemonsas)
---------------------------------------
%prep
%setup -q
%build
%configure
make
%install
install -s -m 755 daemonsas /usr/sbin/
install -m 644 daemonsas.conf /etc
install -s -m daemonsasservice.sh /etc/init.d
%files
%defattr(-,root,root)
/usr/sbin/daemonsas
/etc/daemonsas.conf
/etc/init.d/daemonsasservice
---------------------------------------
the error i'm getting in both build and install section... Don't know y?
The error is: ./configure no such file or directory
so i removed the build section then executed the rpmbuild to create rpm but in install section also throws some error like
daemonsasservice.sh --- file format not found..
Y such errors are coming?.. Please help me out in the spec file...
Let me know how to create a service in linux
should i give sh for the sevice...
just creating the script file in /etc/init.d/ ll make the script as a service?
Creating packages using prefab binaries results in packages that should not be publicly distributed because nobody will be able to determine source origin, changes et cetera. Commonly RPM packages are created by using the original source archive, maybe patch the source or inject files, and the './configure, make, make install' mantra.
Quote:
Originally Posted by umaparvahty
daemonsasservice.sh --- file format not found..
Y such errors are coming?..
Because in "-m filename" you forgot to put in the permission like "-m 0640 filename". You should read at least the http://www.rpm.org/max-rpm/ and http://docs.fedoraproject.org/en-US/...ide/index.html because your .spec file (if you posted the complete one) does not conform to any standards. If you build this as root account user, which you should not need to do ever, then you compromise system integrity because you overwrite system files instead of using a $RPM_BUILD_ROOT.
Quote:
Originally Posted by umaparvahty
Let me know how to create a service in linux
should i give sh for the sevice...
just creating the script file in /etc/init.d/ ll make the script as a service?
Copy one of the SysV init scripts in /etc/rc.d/init.d/ to your package building area and use it as template to create the init script for your service. Test the script works then %install the script and in the %post section (add a user account if required and) use the available tools like 'chkconfig' to add the service:
Code:
%post
if [ "$1" = "1" ]; then
#This package is being installed for the first time
#SysV init script /etc/rc.d/init.d/daemonsas
chkconfig --add daemonsas
fi
* Finally please mind how you write things as writing "Y such errors" makes no sense if you are going to write out the rest of the words and the whole IM / texting style isn't appreciated here anyway.
here is my complete 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 have 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
The "\r" may be due to transferring files between systems with different line endings, you propose to use paths that do not conform to the FSSTND or FHS, you use application versions in path names other than /usr/share/doc/%{name}, there is no "GNU daemonsas", you haven't used the right Group: tag, you have a malformed %files section, and there is no documentation and manual. What's more you haven't acknowledged you're building packages the bad way so you probably do not understand any of the dangers. This is also shown by you building somewhere in the root-owned "/usr/local" path so I wouldn't be surprised if you actually do run your build process as root user and have read none of the docs linked to.
Here is a .spec file that should build OK as unprivileged user and having a tarball with contents that mimic a tree populated the way 'make install' would (%{name}-%{ver}/{etc,usr}/path/item):
Code:
%define debug_packages %{nil}
%define debug_package %{nil}
%define name daemonsas
%define ver 1.2
%define rel 1
Name: %{name}
Summary: %{name}, listens and prints messages sent over TCP to syslog
Version: %{ver}
Release: %{rel}
License: GPL
# (See /usr/share/doc/rpm-.*/GROUPS)
Group: Utilities/System
Source: %{name}-%{ver}.tar.gz
Provides: %{name}
BuildRoot: %{_tmppath}/%{name}-%{ver}
%description
%{name} listens and prints messages sent over TCP to syslog.
%prep
%setup -n %{name}-%{ver}
DUMB=`id -g`
[ $DUMB -eq 0 ] && exit 127
DUMB=`rpm --eval '%{_sourcedir}'`
[ "${DUMB:1:4}" = "root" ] && exit 127
[ "${DUMB:1:3}" = "usr" ] && exit 127
%install
if [ "$RPM_BUILD_ROOT" = "%{_tmppath}/%{name}-%{version}" ]; then
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/sbin
mkdir -p $RPM_BUILD_ROOT/etc
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
install -m 755 usr/local/sbin/%{name} $RPM_BUILD_ROOT/usr/local/sbin
install -m 644 etc/%{name}.conf $RPM_BUILD_ROOT/etc
install -m 755 etc/rc.d/init.d/%{name}d $RPM_BUILD_ROOT/etc/rc.d/init.d
fi
%clean
if [ "$RPM_BUILD_ROOT" = "%{_tmppath}/%{name}-%{version}" ]; then
rm -rf $RPM_BUILD_ROOT
else
echo "Invalid Build root "${RPM_BUILD_ROOT}"."
exit 1
fi
%post
if [ "$1" = "1" ]; then
chkconfig --add %{name}d
fi
%preun
if [ "$1" = "0" ]; then
service %{name}d stop >/dev/null 2>&1
chkconfig --del %{name}d
fi
%files
%defattr(-,root,root)
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/%{name}.conf
%attr(755,root,root) /etc/rc.d/init.d/%{name}d
%attr(755,root,root) /usr/local/sbin/%{name}
%changelog
* Mon Aug 16 2010 %{packager} - init
- Initialize %{name}-%{ver}.%{rel}.
But while installing rpm i'm getting the following error
Code:
[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
the content of the daemond is
Code:
#!/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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.