Skip to content

Commit

Permalink
Revert r28357. Reopens twisted#3292.
Browse files Browse the repository at this point in the history
The RPM tests fail on Fedora buildbot.



git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@28364 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information
jml committed Feb 22, 2010
1 parent 01fcb1e commit 8fabb6e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 361 deletions.
47 changes: 24 additions & 23 deletions doc/core/howto/basics.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,35 @@ pid (usually you would do <code class="shell">kill `cat twistd.pid`</code>).

<p>As always, the gory details are in the manual page.</p>

<h2>OS Integration</h2>
<h2>tap2deb</h2>

<p>
If you have an Application that runs with <code class="shell">twistd</code>,
you can easily deploy it on RedHat Linux or Debian GNU/Linux based systems
using the <code class="shell">tap2deb</code> or <code
class="shell">tap2rpm</code> tools. These take a Twisted Application file (of
any of the supported formats — Python source, XML or pickle), and build a
Debian or RPM package (respectively) that installs the Application as a system
service. The package includes the Application file, a default
<code>/etc/init.d/</code> script that starts and stops the process with twistd,
and post-installation scripts that configure the Application to be run in the
appropriate init levels.
For Twisted-based server application developers who want to deploy on
Debian, Twisted supplies the <code class="shell">tap2deb</code> program. This program
wraps a Twisted Application file (of any of the supported formats -- Python,
source, xml or pickle)
in a Debian package, including correct installation and removal scripts
and <code>init.d</code> scripts. This frees the installer from manually
stopping or starting the service, and will make sure it goes properly up
on startup and down on shutdown and that it obeys the init levels.
</p>

<!-- Is "note" really the right class to be using here? -->
<div class="note">
<code class="shell">tap2rpm</code> and <code class="shell">tap2deb</code> do
not package your entire application and dependent code, just the Twisted
Application file. You will need to find some other way to package your Python
code, such as <code class="API">distutils</code>' <code>bdist_rpm</code>
command.
</div>

<p>
For more savvy users, these tools also generate the source package, allowing
you to modify and polish things which automated software cannot detect (such as
dependencies or relationships to virtual packages).
For the more savvy Debian users, the
<code class="shell">tap2deb</code> also generates the source package, allowing her
to modify and polish things which automated software cannot detect
(such as dependencies or relationships to virtual packages). In addition,
the Twisted team itself intends to produce Debian packages for some common
services, such as web servers and an inetd replacement. Those packages
will enjoy the best of all worlds -- both the consistency which comes
from being based on the <code class="shell">tap2deb</code> and the delicate manual
tweaking of a Debian maintainer, insuring perfect integration with
Debian.
</p>

<h2>tap2rpm</h2>

<p><code class="shell">tap2rpm</code> is similar to <code class="shell">tap2deb</code>, except that
it generates RPMs for Redhat and other related platforms.</p>

</body></html>
7 changes: 3 additions & 4 deletions doc/core/howto/tutorial/configuration.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ integration:</p>
<h3>Red Hat / Mandrake</h3>

<pre class="shell">
% tap2rpm --type=python finger.tac
% sudo rpm -i *.rpm
% tap2rpm --type=python finger.tac #[maybe other options needed]
% sudo rpm -i .build/*.rpm
</pre>

<p>These packages will properly install and register init.d scripts, etc. for
the given file.</p>
<p>Will properly register the tap/tac, init.d scripts, etc. for the given file.</p>

<p>If it doesn't work on your favorite OS: patches accepted!</p>
</body>
Expand Down
11 changes: 6 additions & 5 deletions doc/core/man/tap2rpm.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ tap2rpm \- create RPM packages which wrap .tap files
.SH DESCRIPTION
Create a set of RPM/SRPM packages in the current directory
.TP
\fB\-u\fR, \fB\--unsigned\fR
do not sign the RPM package
.TP
\fB\-t\fR, \fB\--tapfile\fR \fI<tapfile>\fR
Build the application around the given .tap (default twistd.tap)
.TP
Expand Down Expand Up @@ -37,19 +40,17 @@ this being an automatic package created from tap2rpm.
.TP
\fB\-m\fR, \fB\--maintainer\fR \fI<maintainer>\fR
The maintainer, as "Name Lastname <email address>". This will
go in the meta-files.
go in the meta-files, as well as be used as the id to sign the package.
.TP
\fB\--version\fR
Output version information and exit.
.SH AUTHOR
tap2rpm was written by Sean Reifschneider based on tap2deb by Moshe Zadka.
This man page is heavily based on the tap2deb man page by Moshe Zadka.
.SH "REPORTING BUGS"
To report a bug, visit
\fIhttp://twistedmatrix.com/trac/wiki/TwistedDevelopment#FilingTickets\fR for more
information.
To report a bug, visit \fIhttp://twistedmatrix.com/bugs/\fR
.SH COPYRIGHT
Copyright \(co 2000-2009 Twisted Matrix Laboratories.
Copyright \(co 2000-2008 Twisted Matrix Laboratories.
.br
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Expand Down
66 changes: 33 additions & 33 deletions twisted/scripts/tap2rpm.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- test-case-name: twisted.scripts.test.test_tap2rpm -*-
# based off the tap2deb.py file
# tap2rpm.py built by Sean Reifschneider, <jafo@tummy.com>

# Copyright (c) 2003-2010 Twisted Matrix Laboratories.
# See LICENSE for details.
# TODO: need to implement log-file rotation

import sys, os, shutil, time, glob
import subprocess

from twisted.python import usage
from twisted.scripts import tap2deb
Expand Down Expand Up @@ -89,7 +88,7 @@
Name: %(rpm_file)s
Version: %(version)s
Release: 1
License: Unknown
Copyright: Unknown
Group: Networking/Daemons
Source: %(tarfile_basename)s
BuildRoot: /var/tmp/%%{name}-%%{version}-root
Expand Down Expand Up @@ -137,7 +136,7 @@

###############################
class MyOptions(usage.Options):
optFlags = [["unsigned", "u"], ['quiet', 'q']]
optFlags = [["unsigned", "u"]]
optParameters = [
["tapfile", "t", "twistd.tap"],
["maintainer", "m", ""],
Expand Down Expand Up @@ -168,10 +167,8 @@ class MyOptions(usage.Options):

##########################
def makeBuildDir(baseDir):
'''
Set up the temporary directory for building RPMs.
Returns: buildDir, a randomly-named subdirectory of baseDir.
'''Set up the temporary directory for building RPMs.
Returns: Tuple: ( buildDir, rpmrcFile )
'''
import random, string

Expand All @@ -192,15 +189,29 @@ def makeBuildDir(baseDir):
os.makedirs(os.path.join(tmpDir, 'SOURCES'))
os.makedirs(os.path.join(tmpDir, 'SRPMS'))

return tmpDir
# set up rpmmacros file
macroFile = os.path.join(tmpDir, 'rpmmacros')
rcFile = os.path.join(tmpDir, 'rpmrc')
rpmrcData = open('/usr/lib/rpm/rpmrc', 'r').read()
rpmrcData = string.replace(rpmrcData, '~/.rpmmacros', macroFile)
fp = open(macroFile, 'w')
fp.write('%%_topdir %s\n' % tmpDir)
fp.close()

# set up the rpmrc file
fp = open(rcFile, 'w')
fp.write(rpmrcData)
fp.close()

return(( tmpDir, rcFile ))


##########
def run(options=None):
def run():
# parse options
try:
config = MyOptions()
config.parseOptions(options)
config.parseOptions()
except usage.error, ue:
sys.exit("%s: %s" % (sys.argv[0], ue))

Expand All @@ -225,7 +236,7 @@ def run(options=None):
maintainer = 'tap2rpm'

# create source archive directory
tmp_dir = makeBuildDir('/var/tmp')
tmp_dir, rpmrc_file = makeBuildDir('/var/tmp')
source_dir = os.path.join(tmp_dir, directory)
os.makedirs(source_dir)

Expand All @@ -243,31 +254,20 @@ def run(options=None):
% vars())

# build rpm
job = subprocess.Popen([
"rpmbuild",
"--define", "_topdir %s" % (tmp_dir,),
"-ta", tarfile_name,
], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, _ = job.communicate()

# If there was a problem, show people what it was.
if job.returncode != 0:
print stdout
print 'Starting build...'
print '=' * 70
sys.stdout.flush()
os.system('rpmbuild -ta --rcfile "%s" %s' % ( rpmrc_file, tarfile_name ))
print 'Done with build...'
print '=' * 70

# copy the RPMs to the local directory
rpm_path = glob.glob(os.path.join(tmp_dir, 'RPMS', 'noarch', '*'))[0]
srpm_path = glob.glob(os.path.join(tmp_dir, 'SRPMS', '*'))[0]
if not config['quiet']:
print 'Writing "%s"...' % os.path.basename(rpm_path)
print 'Writing "%s"...' % os.path.basename(rpm_path)
shutil.copy(rpm_path, '.')
if not config['quiet']:
print 'Writing "%s"...' % os.path.basename(srpm_path)
print 'Writing "%s"...' % os.path.basename(srpm_path)
shutil.copy(srpm_path, '.')

# remove the build directory
shutil.rmtree(tmp_dir)

return [
os.path.basename(rpm_path),
os.path.basename(srpm_path),
]
Loading

0 comments on commit 8fabb6e

Please sign in to comment.