make_distr.py :  » Web-Server » SkunkWEB » skunkweb-3.4.4 » util » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Server » SkunkWEB 
SkunkWEB » skunkweb 3.4.4 » util » make_distr.py
#! /usr/bin/env python
#  
#  Copyright (C) 2001 Andrew T. Csillag <drew_csillag@geocities.com>
#  
#      You may distribute under the terms of either the GNU General
#      Public License or the SkunkWeb License, as specified in the
#      README file.
#   
#
# This is a script which facilitates creation of versioned releases
#

import commands
import re
import sys
import os

EXCLUDE='pylibs/string8859.py pylibs/pargen pylibs/skunkdoc'

try:
    from prompt import *
except ImportError:
    sys.path.append('../pylibs')
    from prompt import *

CVSROOT=open('CVS/Root').read().strip()

# Ask the questions

vers_q = StringQuestion('Please enter the version for this release')
src_q = StringQuestion('Please enter the directory where source code is checked out in', os.getcwd())
dist_dir = StringQuestion('Where do you wish the distribution to be created',
                            '/tmp')
vers_tag = StringQuestion('Please enter the tag for this release')

print 'Welcome to Skunk distribution creation'
print 'Please answer the following questions'

vers = vers_q.ask()

def_tag = 'SKUNK_RELEASE_' + re.sub('\.', '_', vers)
vers_tag.setDefault(def_tag)
tag = vers_tag.ask()

_dir = dist_dir.ask()
src_dir = src_q.ask()

conf_q = BoolQuestion('Are you sure you want to tag current code %s (version %s), and create a distribution in %s' % (tag, vers, _dir), 1)

if not conf_q.ask():
    sys.exit(0)
#
# Update the version
#
for d, f, var, real_f in(('.', 'configure.in', 'SW_VERSION', 'configure'),
                         ('SkunkWeb', 'SkunkWeb/configure.in', 'SW_VERSION', 'configure'),):
   full_f = os.path.join(src_dir, f)
   lines = open(full_f).read()
   pat = re.compile('^%s=.*' % var, re.MULTILINE)

   print 'Changing version in %s' % full_f

   new_lines = pat.sub('%s=%s' % (var, vers), lines)

   try:
       f = open(full_f, 'w')
       f.write(new_lines)
       f.close()
   except IOError, val:
       raise 'Cannot write %s : %s' % (full_f, val)

   # Run autoconf
   os.chdir(os.path.join(src_dir, d))

   ret, out = commands.getstatusoutput('autoconf')

   if ret:
       print 'Autoconf failed: returned %d: %s' % (ret, out)
       sys.exit(1)

   # Check the file back in
   print 'Checking in %s, %s' % (full_f, real_f)
   _d, _f = os.path.split(full_f)
   
   os.chdir(_d)
   cmd =("cvs ci -m 'upped version to %s' %s %s" % (vers, _f, real_f))

   ret, out = commands.getstatusoutput(cmd)
   if ret:
       print 'Checkin failed: returned %d: %s' % (ret, out)
       sys.exit(1)

   # All done


#
# Ok, do the work
#
#for d, local in ( ('.', 1), ('AED', 0), ('SDS', 0), ('pylibs', 0), ('misc', 0),
#                  ('schemas', 0)):
for d, local in(('.', 1), ('SkunkWeb', 0), ('pylibs', 0), ('docs', 0)):

    # Tag the stuff 
    if local:
       opt = '-l -F '
    else:
       opt = '-F '

    print 'Tagging in %s' % (os.path.join(src_dir, d))

    cmd = 'cvs tag %s %s .' % (opt, tag)

    os.chdir(os.path.join(src_dir, d))

    ret, out = commands.getstatusoutput(cmd)
    if ret:
        print 'Tag failed in %s: returned %d: %s' % (d, ret, out)
        sys.exit(1)

# untag the excluded files
os.chdir(src_dir)
cmd="cvs tag -d %s %s" % (tag, EXCLUDE)
ret, out=commands.getstatusoutput(cmd)
if ret:
    print "untagging excludes failed: returned %d: %s" % (ret, out)
    sys.exit(1)
#
# Ok, all tagged - create the distribution 
#
os.chdir(_dir)
d_file = os.path.join(_dir, 'skunkweb-%s.tar.gz' % vers) 

doc_cmds=[]
for i in ['stmlrefer', 'PyDO', 'devel', 'opman']:
    doc_cmds.append('cd skunkweb/docs/html; make %s/%s.html' % (i, i))
    doc_cmds.append('cd skunkweb/docs/paper-letter; make %s.ps %s.pdf %s.dvi' % (i,i,i))

cmds = (('cvs -d %s export -r %s -d skunkweb skunkweb' % (CVSROOT, tag,),)
        + tuple(doc_cmds) +
        ('mv skunkweb skunkweb-%s' % (vers,),
         'tar czf %s skunkweb-%s' % (d_file, vers),
         'rm -rf skunkweb-%s' % vers))

print 'Creating distribution'

for c in cmds:
    ret, out = commands.getstatusoutput(c)
    if ret:
        print '"%s" failed: returned %d: %s' % (c, ret, out)
        sys.exit(1)

print 'The new skunk distribution is now in %s' % d_file 
sys.exit(0)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.