File: bakefile

package info (click to toggle)
bake 1.0-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 188 kB
  • ctags: 151
  • sloc: python: 895; ansic: 50; makefile: 42
file content (124 lines) | stat: -rw-r--r-- 2,382 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
#  bakefile  --  install `bake'; serves as a demo as well
#

targets = []


#
# Determine release date
#

def release( name, macros):
    relstr = 'Release date: '
    readmefile = 'README'

    def ftime( t = None):
        import time
        fmt = '%c'
        if t is None:
            return time.strftime( '%c', time.localtime())
        else:
            return time.strftime( '%c', time.localtime( t))

    new = ftime( max( [ os.lstat( x).st_mtime
                        for x in os.listdir( os.curdir)]))
    readme = open( readmefile).read().splitlines()
    for x in readme:
        if x.startswith( relstr):
            old = x[ len( relstr):]
            break
    if new != old:
        f = open( readmefile, 'w')
        for x in readme:
            print >>f, x.startswith( relstr) and (relstr + ftime()) or x


Rule( Phony, 'release', '', release)


#
# Installation targets
#


def makeprg( name, macros):
    bout, bin = open( name, 'w'), open( macros( '&')[ 0])
    print >>bout, '#!%s' % Command( 'which python').popen().strip()
    print >>bout
    for l in bin:
        bout.write( l)
    os.chmod( name, os.stat( name).st_mode | 0111)

Rule( File, 'bake', 'bake.py', makeprg)

Suffix( File, '.gz', '', 'gzip -c -9 $& >$@')



Var( 'PREFIX',  '/usr/local')
Var( 'EPREFIX', '${PREFIX}')

Var( 'BINDIR', '${EPREFIX}/bin')
Var( 'MANDIR', '${PREFIX}/man')



class BakeInst( Installer):

    bakebins = [ 'bake']
    bakemans = [ 'bake.1.gz', 'bakefile.5.gz']

    targets = bakebins + bakemans

    def execfiles( self):
        d = { '${BINDIR}' : BakeInst.bakebins}
        for m in BakeInst.bakemans:
            section = Ext.split( Ext.split( m)[ -2])[ -1]
            mansect = '${MANDIR}/man%s' % section
            d.setdefault( mansect, [])
            d[ mansect] += [ m]
        return d

    def conffiles( self):
        return {}


bi = BakeInst()

bi.stdrules()

targets += BakeInst.targets


#
# Cleanup targets
#

Rule( Phony, 'clear', '', [
    'rm -f ' + ' '.join( targets)])

Rule( Phony, 'clean', '', [
    'rm -f *~ \\#*#',
    'rm -f *.pyc *.pyo',
    'rm -f typescript'])

Rule( Phony, 'wipe', 'clear clean', '')


#
# Archiving target
#

def tar( name, macros):
    a = Archive( fakeroot = True)
    a.bothall( 'download')


Rule( Phony, 'tar', 'wipe release', tar)


# vim: syntax=python
# Local Variables:
#   mode: Python
# End: