Spec file

From Null-pointer

Jump to: navigation, search
%define _svn_revision %(echo '$Rev: 42849 $' | sed -r 's/[^0-9]+//g' )
%define _version_tag %(echo '$Version: 0.0.1 $' | sed -r 's/[^0-9\.]+//g' )


Name				: MyProduct
Version			: %{_version_tag}
Release			: %{_svn_revision}
Summary			: My Product summary
Group				: Applications/Internet
License			: creative commons
Source				: %{name}-%{version}.tar.gz
BuildArch			: noarch
BuildRoot			: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
Prereq				: /usr/sbin/useradd
Requires			: daemontools
Requires			: ruby >= 1.8.6
Requires			: rubygems
Requires			: spread

%description
Installs my profile.

%clean
%{__rm} -rf %{buildroot}


%pre
/usr/sbin/useradd -M myproductuser > /dev/null 2>&1 || :

%prep
%setup

%build

%install
%{__rm} -rf %{buildroot}
%{__mkdir} -p %{buildroot}/usr/lib/myproductroot
%{__cp} -ra * %{buildroot}/usr/lib/myproductroot 

%post
%{__cp} %{buildroot}/usr/lib/livetext-tweets/config/livetext-tweets.conf /etc/httpd/conf.d/

restart_service()
{
	# If the service is already running, restart it.
	local DIR NAME
	DIR="$1"
	NAME="${2:-`basename $1`}"
	if svok "$DIR"
	then
		svc -t "$DIR"
	else
		ln -nsf "$DIR" /service/"$NAME"
	fi
}

SERVICE_DIR="/usr/lib/myproduct/services"

restart_service $SERVICE_DIR/myproduct-service myproduct-service

%preun

stop_service()
{
    local DIR
    DIR="$1"
    svc -dx "$DIR"
    for ((i=0;i<5;i+=1)); do svok "$DIR" && sleep 1 ; done
    svok "$DIR" ; [ $? = 100 ] && rm -rf "$DIR"/supervise
}

if [ "$1" = 0 ]
then
  # Remove any symlinks
	rm -f /service/myproduct

  # Stop the process and log services
  cd /usr/lib/myproduct/services
	stop_service ./myproduct-service
	stop_service ./myproduct-service/log
fi


%files
%defattr(0744, myproductuser, myproductuser, 0775)
/usr/lib/myproduct/
%defattr(0644, myproductuser, myproductuser, 0775)
Personal tools