summaryrefslogtreecommitdiffstats
path: root/encap/bcfg2-0.8.2.ep
blob: 09208eccf0cebd9974d1501f0bf14ab16603c076 (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?xml version="1.0"?>

<!-- $Id$ -->

<encap_profile
	profile_ver="1.0"
	pkgspec="bcfg2-0.8.2"
>

<environment
        variable="CC"
        value="gcc"
        type="set"
/>

<environment
        variable="PATH"
PLATFORM_IF_MATCH(solaris)
        value="/usr/local/lib/bcfg2/bin:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin:"
PLATFORM_ELSE
        value="/usr/local/lib/bcfg2/bin:/usr/local/bin:"
PLATFORM_ENDIF
        type="prepend"
/>

PLATFORM_IF_MATCH(linux)
PLATFORM_ELSE
<environment
        variable="MAKE"
        value="gmake"
        type="set"
/>
PLATFORM_ENDIF

<environment
        variable="LDFLAGS"
PLATFORM_IF_MATCH(linux)
        value="-L/usr/local/lib/bcfg2/lib -Wl,-rpath,/usr/local/lib/bcfg2/lib"
PLATFORM_ELSE_IF_MATCH(aix)
	value="-L/usr/local/lib/bcfg2/lib -Wl,-blibpath:/usr/local/lib/bcfg2/lib:/usr/lib"
PLATFORM_ELSE_IF_MATCH(solaris)
        value="-L/usr/local/lib/bcfg2/lib -R/usr/local/lib/bcfg2/lib:/usr/lib -YP,/usr/local/lib/bcfg2/lib:/usr/lib"
PLATFORM_ELSE
PLATFORM_ENDIF
        type="set"
/>

<environment
        variable="CPPFLAGS"
        value="-I/usr/local/lib/bcfg2/include"
        type="set"
/>

<source
url="http://www.pobox.com/users/dclark/mirror/bcfg/bcfg2-0.8.2.tar.gz
     ftp://ftp.mcs.anl.gov/pub/bcfg/bcfg2-0.8.2.tar.gz"
>

<configure>
:
</configure>

<build>
/usr/local/lib/bcfg2/bin/python setup.py build \
--build-base=${builddir}/build
</build>

<install>
/usr/local/lib/bcfg2/bin/python setup.py install \
--prefix=${ENCAP_SOURCE}/${ENCAP_PKGNAME}/lib/bcfg2
</install>

<clean>
/usr/local/lib/bcfg2/bin/python setup.py clean
</clean>

</source>

<prepackage type="set"><![CDATA[
mkdir bin 2>/dev/null || exit 0
ln -sf ../lib/bcfg2/bin/GenerateHostInfo bin/GenerateHostInfo
ln -sf ../lib/bcfg2/bin/GenerateHostInfo bin/b2GenerateHostInfo
ln -sf ../lib/bcfg2/bin/StatReports bin/StatReports
ln -sf ../lib/bcfg2/bin/StatReports bin/b2StatReports
ln -sf ../lib/bcfg2/bin/bcfg2 bin/
ln -sf ../lib/bcfg2/bin/bcfg2-info bin/
ln -sf ../lib/bcfg2/bin/bcfg2-repo-validate bin/
ln -sf ../lib/bcfg2/bin/bcfg2-server bin/
mkdir share 2>/dev/null || exit 0
mkdir share/bcfg2  2>/dev/null || exit 0
(cp ${builddir}/doc/manual.pdf share/bcfg2/ || true)
cp -r ${builddir}/examples share/bcfg2/
mkdir var 2>/dev/null || exit 0
mkdir var/encap 2>/dev/null || exit 0
touch var/encap/${ENCAP_PKGNAME}
]]></prepackage>

<include_file name="b2regexplace.py" mode="0755"><![CDATA[
#!/usr/local/lib/bcfg2/bin/python

# regexplace: regular expression search and replace
# Stefano Spinucci
# 2006-02-07 (rev 4)
# Daniel Clark
# 2006-08-03 (modified for bcfg2 encap use)
# thanks to roadrunner.py
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52553
# for some ideas and some code
# tested with python 2.4.3

import sys, os, re, string

# pupulate and return 'fileslist[]' with all files inside 'dir' matching 'regx'
def make_files_list(dir, regx):

    # if dir is not a directory, exit with error
    if not os.path.isdir(dir):
        sys.exit(dir + ' is not a valid dir to walk !!!')

    # compile the search regexp
    cregex=re.compile(regx)

    # initialize the file list
    fileslist = []

    # loop on all files and select files matching 'regx'
    # don't include symbolic links
    for root, dirs, files in os.walk(dir):
        for name in files:
            if cregex.search(name) and name not in ("b2regexplace.sh", "b2regexplace.py", "postinstall", "postinstall.log", "bcfg2-0.8.2.ep"):
                path = os.path.join(root, name)
                if not os.path.islink(path):
                    fileslist.append(path)

    # return the file list
    return fileslist[:]

# in all files in 'fileslist' search the regexp 'searchregx' and replace
# with 'replacestring'; real substitution in files only if 'simulation' = 0
def replace_in_files(fileslist, searchregx, replacestring, simulation):

    # compile regexp
    cregex=re.compile(searchregx)
    
    # loop on all files
    for xfile in fileslist:

        # initialize the replace flag
        replaceflag=0

        # open file for read  
        readlines=open(xfile,'r').readlines()
        # intialize the list counter
        listindex = -1

        # search and replace in current file printing to the user changed lines
        for currentline in readlines:

            # increment the list counter
            listindex = listindex + 1

            # if the regexp is found
            if cregex.search(currentline):

                # make the substitution
                f=re.sub(searchregx,replacestring,currentline)

                # print the current filename, the old string and the new string
                print '\n' + xfile
                print '- ' + currentline ,
                if currentline[-1:]!='\n': print '\n' ,
                print '+ ' + f ,
                if f[-1:]!='\n': print '\n' ,

                # if substitution is real
                if simulation == 0:

                    # update the whole file variable ('readlines')
                    readlines[listindex] = f
                    replaceflag=1
                            
        # if some text was replaced
        # overwrite the original file
        if replaceflag==1:

            # open the file for writting  
            write_file=open(xfile,'w') 

            # overwrite the file  
            for line in readlines:
                write_file.write(line)

            # close the file
            write_file.close()

# main function
def main():

    # if parameters are wrong, exit with error
    if len(sys.argv) < 5:

        print 'Usage: regexplace.py dirname files-regexp search-regexp replace-string'

        sys.exit(1)

    # make the file list
    fileslist = make_files_list(sys.argv[1], sys.argv[2])

    # real execution
    replace_in_files(fileslist, sys.argv[3], sys.argv[4], 0)        

    # simulated execution
    #replace_in_files(fileslist, sys.argv[3], sys.argv[4], 1)
                
            
if __name__ == '__main__':
    main()
]]></include_file>

<include_file name="b2regexplace.sh" mode="0755"><![CDATA[
#!/bin/sh

# This fixes paths for the bcfg2 encap packaging.
# Do not run more than once; it does not converge.

BASEDIR="`echo ${0} | xargs -n1 dirname`"
REGEXPLACE="${BASEDIR}/b2regexplace.py"
PYTHON="/usr/local/lib/bcfg2/bin/python"
BINARIES="${REGEXPLACE} ${PYTHON}"
COMPILEALL="/usr/local/lib/bcfg2/lib/python2.4/compileall.py"

printf "**** Running postinstall with BASEDIR=|${BASEDIR}|...\n"
for BINARY in ${BINARIES}; do
    if [ ! -x ${BINARY} ]; then
        printf "\nERROR: ${BINARY} is not executable, exiting...\n"
        exit 1
    fi
done

for FILE in ${COMPILEALL}; do
    if [ ! -e ${FILE} ]; then
        printf "\nERROR: ${FILE} does not exist, exiting...\n"
        exit 1
    fi
done

printf "\nRemoving bcfg2 .pyc files...\n"
find ${BASEDIR} -type f | grep "\.pyc$" | xargs -n1 rm

printf "\nFixing bcfg2 paths...\n"

printf "\nReplacing \"/etc/bcfg2.conf\" with \"/usr/local/etc/bcfg2.conf\"...\n"
${REGEXPLACE} ${BASEDIR} .\* \/etc\/bcfg2.conf \/usr\/local\/etc\/bcfg2.conf

printf "\nReplacing \"/local/sbin/epkg\" with \"/usr/local/bin/epkg\"...\n"
${REGEXPLACE} ${BASEDIR} .\* \/local\/sbin\/epkg \/usr\/local\/bin\/epkg

printf "\nReplacing \"/usr/share/bcfg2\" with \"/usr/local/lib/bcfg2/share/bcfg2\"...\n"
${REGEXPLACE} ${BASEDIR} .\* \/usr\/share\/bcfg2\/ \/usr\/local\/lib\/bcfg2\/share\/bcfg2\/

printf "\nReplacing \"prefix = '/usr'\" with \"prefix = '/usr/local/lib/bcfg2'\"...\n"
${REGEXPLACE} ${BASEDIR} .\* prefix\ =\ \'\/usr\' prefix\ =\ \'/usr/local/lib/bcfg2\'

printf "\nReplacing \"xmllint\" with \"/usr/local/bin/b2xmllint\"...\n"
${REGEXPLACE} ${BASEDIR} .\* xmllint \/usr\/local\/bin\/b2xmllint

printf "\nCreating bcfg2 .pyc files...\n"
${PYTHON} ${COMPILEALL} ${BASEDIR}

exit 0
]]></include_file>

<include_file name="postinstall" mode="0755"><![CDATA[
#!/bin/sh
BASEDIR="`echo ${0} | xargs -n1 dirname`"
test -x ${BASEDIR}/b2regexplace.sh || exit 1
${BASEDIR}/b2regexplace.sh > ${BASEDIR}/postinstall.log 2>&1 3>&1
]]></include_file>


<encapinfo>
description Bcfg2 - Provides a declarative interface to system configuration
prereq pkgspec >= bcfg2-zlib-1.2.3
prereq pkgspec >= bcfg2-libiconv-1.9.2
prereq pkgspec >= bcfg2-gettext-0.14.5
prereq pkgspec >= bcfg2-openssl-0.9.8b
prereq pkgspec >= bcfg2-libstdc++-0.1
prereq pkgspec >= bcfg2-libgcc-0.1
prereq pkgspec >= bcfg2-python-2.4.3
prereq pkgspec >= bcfg2-pyopenssl-0.6
prereq pkgspec >= bcfg2-libxml2-2.6.26
prereq pkgspec >= bcfg2-libxslt-1.1.17
prereq pkgspec >= bcfg2-lxml-1.0.1
</encapinfo>

</encap_profile>