1#!/usr/bin/sh
2#- Below variables are editable.
3#-  VERSION     Script tries to set the version automatically if it's empty
4#-              string. The version number is assumed to be in
5#-              ../../source/include/version.h. Should this fail to find correct
6#-              version, set it manually to override automatic search.
7#-  BIN         List of binaries from ../../source/bin. Note: do not include
8#-              swat here for it is a part of Samba.swat fileset
9#-  SCRIPT      List of scripts
10#-  OS_REVISION The regular expression to determine the supported OS version.
11#-              The default versions are HP-UX 10.10 or later as well as 11.*.
12#-              You can modify this to reflect the OS you compile on. For
13#-              instance, to support any 10.? and 11.? releases, use the
14#-              following string:
15#-                  '?.10.*|?.11.*
16    VERSION=""
17
18        BIN="smbd nmbd smbclient testparm testprns smbstatus\
19             rpcclient smbpasswd make_smbcodepage nmblookup make_printerdef"
20
21     SCRIPT="smbtar addtosmbpass convert_smbpasswd"
22
23 OS_RELEASE='?.10.[2-9]?|?.11.*'
24
25
26#- Below variables should be exported from create_package.sh
27
28if [ -z "$PSF" ]
29then
30  PSF=samba.psf
31fi
32
33if [ -z "$DEPOT" ]
34then
35  DEPOT=samba.depot
36fi
37
38if [ -z "$PRODUCT" ]
39then
40  PRODUCT=Samba
41fi
42
43#--------------------------------------------------------------------------
44CODEPAGES=""
45if [ -z "$VERSION" ]
46then
47  echo "Deducing Samba version from version.h ... \c"
48  VERSION=`grep VERSION ../../source/include/version.h | awk '{print $3}' |\
49           tr -d '"'`
50  if [ $? -ne 0 -o -z "$VERSION" ]
51  then
52    echo "failed."
53    echo "Cannot find Samba version. Edit gen_psf.sh and set VERSION"
54    echo "variable manually."
55    exit 1
56  else
57    echo "$VERSION"
58  fi
59fi
60
61echo "Creating list of codepage definitions ..."
62
63#- create codepages from definition and add them to PSF file
64for a in ../../source/codepages/codepage_def.[0-9][0-9][0-9]
65do
66  b=${a##../../source/codepages/codepage_def.}
67  CODEPAGES="$CODEPAGES $b"
68done
69echo "\t$CODEPAGES"
70
71echo "Running make_smbcodepage on codepage definitions ... \c"
72
73mkdir codepage >/dev/null 2>&1
74for a in $CODEPAGES
75do
76../../source/bin/make_smbcodepage c $a ../../source/codepages/codepage_def.$a\
77                                    codepage/codepage.$a
78done
79echo "done."
80
81#- HP-UX uses slightly different section numbers for man pages. The following
82#- compares to "normal" sections:
83#-
84#-             Section        HP-UX section
85#-                 1          1                user commands
86#-                 5          4                files
87#-                 7          5                concepts
88#-                 8          1m               administration commands
89#- NOTE:
90#- Sed expressions used in below loops replaces original section references
91#- inside man page with HP-UX section references. Assumption is that
92#- only numbers in brackets are section references and nothing else.
93#- So far I did not see the man pages corrupted by replacing anything
94#- else but section references.
95
96mkdir man >/dev/null 2>&1
97echo "Coverting man pages to HP-UX numbering ..."
98echo "\t Sections 1 \c"
99for a in ../../docs/manpages/*.1
100do
101  sed -e 's/^[.]TH \([^ ][^ ]*\) .*/.TH \1 1/'\
102      -e '1a\
103.ds )H Samba Team'\
104      -e "1a\\
105.ds ]W $VERSION"\
106      -e 's/(8)/(1m)/g' \
107      -e 's/(5)/(4)/g' \
108      -e 's/(7)/(5)/g' \
109      $a >man/`basename $a`
110done
111echo "1m \c"
112for a in ../../docs/manpages/*.8
113do
114  b=`basename $a`
115  c=${b%.8}
116  sed -e 's/^[.]TH \([^ ][^ ]*\) .*/.TH \1 1M/'\
117      -e '1a\
118.ds )H Samba Team'\
119      -e "1a\\
120.ds ]W $VERSION"\
121      -e 's/(8)/(1m)/g' \
122      -e 's/(5)/(4)/g' \
123      -e 's/(7)/(5)/g' \
124      $a >man/$c.1m
125done
126echo "4 \c"
127for a in ../../docs/manpages/*.5
128do
129  b=`basename $a`
130  c=${b%.5}
131  sed -e 's/^[.]TH \([^ ][^ ]*\) .*/.TH \1 4/'\
132      -e '1a\
133.ds )H Samba Team'\
134      -e "1a\\
135.ds ]W $VERSION"\
136      -e 's/(8)/(1m)/g' \
137      -e 's/(5)/(4)/g' \
138      -e 's/(7)/(5)/g' \
139      $a >man/$c.4
140done
141echo "5"
142for a in ../../docs/manpages/*.7
143do
144  b=`basename $a`
145  c=${b%.7}
146  sed -e 's/^[.]TH \([^ ][^ ]*\) .*/.TH \1 5/'\
147      -e '1a\
148.ds )H Samba Team'\
149      -e "1a\\
150.ds ]W $VERSION"\
151      -e 's/(8)/(1m)/g' \
152      -e 's/(5)/(4)/g' \
153      -e 's/(7)/(5)/g' \
154      $a >man/$c.5
155done
156
157echo "Creating product specification file:"
158echo "\tVendor and product description"
159#- vendor and header of product definition
160cat <<_EOF_ >$PSF
161vendor
162	tag   	Samba
163	title 	Samba Team
164	description <vendor_description
165end
166
167product
168  tag   	$PRODUCT
169  title		Samba Server
170  description	< ../../WHATSNEW.txt
171  copyright	"Copyright (c) 1998 Samba Team. See COPYING for details."
172  readme	< ../../README
173  revision	$VERSION
174  machine_type	*
175  os_name	HP-UX
176  os_release	$OS_RELEASE
177  os_version	*
178  directory	/
179  is_locatable	false
180  vendor_tag	Samba
181
182_EOF_
183
184echo "\tFileset $PRODUCT.core"
185
186cat <<_EOF_ >>$PSF
187  fileset
188    tag			core
189    title		Samba server core components
190    revision		$VERSION
191    is_kernel		false
192    is_reboot		false
193    is_secure		false
194    configure		configure.bin
195    unconfigure		unconfigure.bin
196
197    file    -m 0755 -o root -g sys / /opt/samba/
198    file    -m 0755 -o root -g sys / /opt/samba/bin/
199    file    -m 0755 -o root -g sys / /opt/samba/lib/
200    file    -m 0755 -o root -g sys / /opt/samba/lib/codepages/
201    file    -m 0755 -o root -g sys / /opt/samba/newconfig/
202    file    -m 0755 -o root -g sys / /opt/samba/newconfig/examples/
203    file    -m 0700 -o root -g sys / /opt/samba/private/
204    file    -m 0755 -o root -g sys / /var/opt/samba/
205    file    -m 0755 -o root -g sys / /var/opt/samba/locks/
206
207    file    -m 0444 -o root -g sys ../../COPYING /opt/samba/COPYING
208    file    -m 0555 -o root -g sys ./samba.boot /sbin/init.d/samba
209    file    -m 0444 -o root -g sys ./samba.config /opt/samba/newconfig/samba.config
210
211    file    -m 0444 -o root -g sys ../../examples/smb.conf.default /opt/samba/newconfig/examples/smb.conf.default
212    file    -m 0444 -o root -g sys ../../examples/simple/smb.conf /opt/samba/newconfig/examples/smb.conf.simple
213    file    -m 0444 -o root -g sys ../../examples/dce-dfs/smb.conf /opt/samba/newconfig/examples/smb.conf.dce-dfs
214
215    directory ../../source/bin=/opt/samba/bin
216_EOF_
217  for a in $BIN
218  do
219    echo "    file    -m 0555 -o root -g sys $a" >>$PSF
220  done
221
222  echo "    directory ../../source/script=/opt/samba/bin" >>$PSF
223
224  for a in $SCRIPT
225  do
226    echo "    file    -m 0555 -o root -g sys $a" >>$PSF
227  done
228
229  echo "    directory ./codepage=/opt/samba/lib/codepages" >> $PSF
230
231  for a in $CODEPAGES
232  do
233    echo "    file    -m 0444 -o root -g sys codepage.$a" >>$PSF
234  done
235  echo "  end" >>$PSF
236#- end of fileset CORE
237
238echo "\tFileset $PRODUCT.man"
239#- Man pages
240cat <<_EOF_ >>$PSF
241  fileset
242    tag             man
243    title           Samba server man pages
244    revision        $VERSION
245    is_kernel       false
246    is_reboot       false
247    is_secure       false
248    configure       configure.man
249
250    file    -m 0755 -o root -g sys / /opt/samba/man/
251    file    -m 0755 -o root -g sys / /opt/samba/man/man1/
252    file    -m 0755 -o root -g sys / /opt/samba/man/man1m/
253    file    -m 0755 -o root -g sys / /opt/samba/man/man4/
254    file    -m 0755 -o root -g sys / /opt/samba/man/man5/
255
256_EOF_
257
258#- HP-UX uses slightly different section numbers for man pages. The following
259#- compares to "normal" sections:
260#-
261#-             Section        HP-UX section
262#-                 1          1                user commands
263#-                 5          4                files
264#-                 7          5                concepts
265#-                 8          1m               administration commands
266
267  for a in man/*.1
268  do
269    b=`basename $a`
270    echo "    file    -m 0444 -o root -g sys $a /opt/samba/man/man1/$b" >>$PSF
271  done
272
273  for a in man/*.1m
274  do
275    b=`basename $a`
276    echo "    file    -m 0444 -o root -g sys $a /opt/samba/man/man1m/$b" >>$PSF
277  done
278
279  for a in man/*.4
280  do
281    b=`basename $a`
282    echo "    file    -m 0444 -o root -g sys $a /opt/samba/man/man4/$b" >>$PSF
283  done
284
285  for a in man/*.5
286  do
287    b=`basename $a`
288    echo "    file    -m 0444 -o root -g sys $a /opt/samba/man/man5/$b" >>$PSF
289  done
290
291  echo "  end" >>$PSF
292
293echo "\tFileset $PRODUCT.swat"
294
295cat <<_EOF_ >>$PSF
296
297  fileset
298    tag             swat
299    title           Samba Web-based administration tool
300    revision        $VERSION
301    is_kernel       false
302    is_reboot       false
303    is_secure       false
304    prerequisite    Samba.core
305    configure       configure.swat
306    unconfigure     unconfigure.swat
307
308    file    -m 0755 -o root -g sys / /opt/samba/swat/
309    file    -m 0755 -o root -g sys / /opt/samba/swat/help/
310    file    -m 0755 -o root -g sys / /opt/samba/swat/images/
311    file    -m 0755 -o root -g sys / /opt/samba/swat/include/
312
313    directory ../../swat=/opt/samba/swat
314    file    -m 0444 -o root -g sys README
315
316    directory ../../source/bin=/opt/samba/bin
317    file    -m 0555 -o root -g sys swat
318
319    directory ../../swat/images=/opt/samba/swat/images
320_EOF_
321
322  for a in ../../swat/images/*.gif
323  do
324    b=`basename $a`
325    echo "    file    -m 0444 -o root -g sys $b" >>$PSF   
326  done
327
328  echo "    directory ../../swat/help=/opt/samba/swat/help" >>$PSF
329
330  for a in ../../swat/help/*.html
331  do
332    b=`basename $a`
333    echo "    file    -m 0444 -o root -g sys $b" >>$PSF   
334  done
335
336  echo "    directory ../../docs/htmldocs=/opt/samba/swat/help" >>$PSF
337
338  for a in ../../docs/htmldocs/*.html
339  do
340    b=`basename $a`
341    echo "    file    -m 0444 -o root -g sys $b" >>$PSF   
342  done
343  
344  echo "    directory ../../swat/include=/opt/samba/swat/include" >>$PSF
345
346  for a in ../../swat/include/*.html
347  do
348    b=`basename $a`
349    echo "    file    -m 0444 -o root -g sys $b" >>$PSF   
350  done
351
352cat <<_EOF_ >>$PSF
353  end
354
355end
356_EOF_
357
358