Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/scripts/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/scripts/tap2rpm.pyc


oUNc@sddlZddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZdZdZ
de
jfdYZidd	6d
d
6dd6dd6Zd
ZdZddZdS(iN(tStringIO(tusagetlogs#!/bin/sh
#
#  Startup script for a Twisted service.
#
#  chkconfig: - 85 15
#  description: Start-up script for the Twisted service "%(tap_file)s".

PATH=/usr/bin:/bin:/usr/sbin:/sbin

pidfile=/var/run/%(rpm_file)s.pid
rundir=/var/lib/twisted-taps/%(rpm_file)s/
file=/etc/twisted-taps/%(tap_file)s
logfile=/var/log/%(rpm_file)s.log

#  load init function library
. /etc/init.d/functions

[ -r /etc/default/%(rpm_file)s ] && . /etc/default/%(rpm_file)s

#  check for required files
if [ ! -x /usr/bin/twistd ]
then
	echo "$0: Aborting, no /usr/bin/twistd found"
	exit 0
fi
if [ ! -r "$file" ]
then
	echo "$0: Aborting, no file $file found."
	exit 0
fi

#  set up run directory if necessary
if [ ! -d "${rundir}" ]
then
	mkdir -p "${rundir}"
fi


case "$1" in
	start)
		echo -n "Starting %(rpm_file)s: twistd"
		daemon twistd  \
				--pidfile=$pidfile \
				--rundir=$rundir \
				--%(twistd_option)s=$file \
				--logfile=$logfile
		status %(rpm_file)s
		;;

	stop)
		echo -n "Stopping %(rpm_file)s: twistd"
		kill `cat "${pidfile}"`
		status %(rpm_file)s
		;;

	restart)
		"${0}" stop
		"${0}" start
		;;

    *)
		echo "Usage: ${0} {start|stop|restart|}" >&2
		exit 1
		;;
esac

exit 0
sSummary:    %(description)s
Name:       %(rpm_file)s
Version:    %(version)s
Release:    1
License:    Unknown
Group:      Networking/Daemons
Source:     %(tarfile_basename)s
BuildRoot:  %%{_tmppath}/%%{name}-%%{version}-root
Requires:   /usr/bin/twistd
BuildArch:  noarch

%%description
%(long_description)s

%%prep
%%setup
%%build

%%install
[ ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != '/' ] 		&& rm -rf "$RPM_BUILD_ROOT"
mkdir -p "$RPM_BUILD_ROOT"/etc/twisted-taps
mkdir -p "$RPM_BUILD_ROOT"/etc/init.d
mkdir -p "$RPM_BUILD_ROOT"/var/lib/twisted-taps
cp "%(tap_file)s" "$RPM_BUILD_ROOT"/etc/twisted-taps/
cp "%(rpm_file)s.init" "$RPM_BUILD_ROOT"/etc/init.d/"%(rpm_file)s"

%%clean
[ ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != '/' ] 		&& rm -rf "$RPM_BUILD_ROOT"

%%post
/sbin/chkconfig --add %(rpm_file)s
/sbin/chkconfig --level 35 %(rpm_file)s
/etc/init.d/%(rpm_file)s start

%%preun
/etc/init.d/%(rpm_file)s stop
/sbin/chkconfig --del %(rpm_file)s

%%files
%%defattr(-,root,root)
%%attr(0755,root,root) /etc/init.d/%(rpm_file)s
%%attr(0660,root,root) /etc/twisted-taps/%(tap_file)s

%%changelog
* %(date)s %(maintainer)s
- Created by tap2rpm: %(rpm_file)s (%(version)s)
t	MyOptionscBseZddgddggZdddgddd	gd
dd gdd
d gdddgdddgddd gddddggZejdiejddddgd6ejdd6Z	dZ
RS(!tunsignedtutquiettqttapfiletts
twistd.tapt
maintainertmttap2rpmtprotocoltptdescriptiontetlong_descriptiontls Automatically created by tap2rpmsset-versiontVs1.0trpmfiletrttypetyttaps8type of configuration: 'tap', 'xml, 'source' or 'python't
optActionstxmltsourcetpythons*.rpmcCs|dd
krCtjj|d}tjj|d|d<n|dd
krkd|df|d<n|dd
krd|df|d<nt|d|d	<d
|d|df|d<d
S(sP
        Calculate the default values for certain command-line options.
        R
RiRsA TCP server for %sRs
twisted-%sRt
twistd_options%s-%ssset-versionsrelease-nameN(tNonetostpathtbasenametsplitextt	type_dict(tselftbase_tapfile((s;/usr/lib/python2.7/dist-packages/twisted/scripts/tap2rpm.pytpostOptionssN(t__name__t
__module__toptFlagsRt
optParametersRtCompletionstCompleteListt
CompleteFilestcompDataR&(((s;/usr/lib/python2.7/dist-packages/twisted/scripts/tap2rpm.pyRs	
tfileRRRRcCstj}tjtjj|ddtjtjj|dtjtjj|dtjtjj|dtjtjj|dtjddd	||S(
s}
    Set up the temporary directory for building RPMs.

    Returns: buildDir, a randomly-named subdirectory of baseDir.
    tRPMStnoarchtSPECStBUILDtSOURCEStSRPMStformats'Created RPM build structure in %(path)rR (ttempfiletmkdtempRtmakedirsR tjoinRtmsg(ttmpDir((s;/usr/lib/python2.7/dist-packages/twisted/scripts/tap2rpm.pytmakeBuildDirscCsbd|df}tjj|d|}tj|d}tj|d}tj|_d|_|j	|tjj
|d}tjtjj|dd|d}tj|_d|_ti|d	6|dd
6|dd6}t
||_|j	|t|t|dd}	|jd
tjj|d|d|	}
d|
_|j	|
|	|jtjddd|d|df}tjj|d|}t|d}
ti|dd6|dd
6|dd6|d6|d	6tjdtjtjd6|dd6|dd6}|
j||
jtjddd||S(sG
    Create files required to build an RPM in the build directory.
    s%s.tarsrelease-nameR4twiRs%s.initRttap_filetrpm_fileRtrbtarcnametfileobjiR6s,Created dummy source tarball %(tarballPath)rttarballPaths%s.specR2Rsset-versiontversionttarfile_basenames%a %b %d %YtdateR
Rs"Created RPM spec file %(specPath)rtspecPath(RR R:ttarfiletopentTarInfotDIRTYPERtmodetaddfileR!tREGTYPEtinitFileDatatlentsizeRt
gettarinfotcloseRR;tspecFileDatattimetstrftimet	localtimetwrite(tbuildDirtconfigttarballNameRDt
tarballHandlet
sourceDirInfottapFileBasetinitFileInfotinitFileRealDatat
tapFileHandlettapFileInfotspecNameRHt
specHandletspecFileRealData((s;/usr/lib/python2.7/dist-packages/twisted/scripts/tap2rpm.pytsetupBuildFiless\	
					
"

c
Csyt}|j|Wn4tjk
rP}tjdtjd|fnXt}t||}t	j
dddd|fd|gdt	jd	t	j}|j
\}}|jdkr|GHntjtjj|d
ddd}tjtjj|d
dd}	|ds;dtjj|GHntj|d|dsmdtjj|	GHntj|	dtj|tjj|tjj|	gS(Ns%s: %sitrpmbuilds-vvs--defines
_topdir %ss-batstdouttstderrR0R1t*R5RsWriting "%s"...t.(RtparseOptionsRterrortsystexittargvR=Rgt
subprocesstPopentPIPEtSTDOUTtcommunicatet
returncodetglobRR R:R!tshutiltcopytrmtree(
toptionsR[tueR<RHtjobRit_trpmPathtsrpmPath((s;/usr/lib/python2.7/dist-packages/twisted/scripts/tap2rpm.pytruns4	"	
(%


(RoRRyRVRxRrR7RIRttwisted.pythonRRRPRUtOptionsRR#R=RgRR(((s;/usr/lib/python2.7/dist-packages/twisted/scripts/tap2rpm.pyt<module>s <I5)
		E