1#!/usr/bin/perl
2
3# This perl script generates the samba.spec file based on the version
4# information in the version.h file in the source tree
5
6open (VER,'../../source/include/version.h') || die "Unable to open version.h\n";
7($_ = <VER>) =~ s/"//g;
8close (VER);
9@foo = split(' ');
10splice(@foo,0,2);
11$_ = $foo[0];
12
13# create the package name
14$vername = "    id \"Samba Version ".$_."\"\n";
15
16$patch = 0;
17#create the subsystem version numbers
18if (/alpha/) {
19  $_ =~ s/alpha/.00./;
20}
21elsif (/-HEAD/) {
22  $_ =~ s/-HEAD/.01/;
23  $_ .= '.99';
24}
25elsif (/pre-/) {
26  $_ =~ s/pre-//;
27  $_ .= '.00';
28}
29elsif (/p/) {
30  $_ =~ s/p/./;
31  $_ .= '.00';
32  $patch = 1;
33}
34else {
35 $_ .='.01.00';
36}
37
38($v1,$v2,$v3,$v4,$v5) = split('\.');
39$v4 = $v4 + $patch;
40$vernum = sprintf("        version %02d%02d%02d%02d%02d\n",$v1,$v2,$v3,$v4,$v5);
41
42# generate the samba.spec file
43open(SPEC,">samba.spec") || die "Unable to open samba.spec for output\n";
44print SPEC "product samba\n";
45print SPEC $vername;
46print SPEC "    image sw\n";
47print SPEC "        id \"Samba Execution Environment\"\n";
48print SPEC $vernum;
49print SPEC "        order 0\n";
50print SPEC "        subsys base default\n";
51print SPEC "            id \"Samba Execution Environment\"\n";
52print SPEC "            replaces fw_samba.sw.base 0 9999999999\n";
53print SPEC "            replaces fw_samba.sw.samba 0 9999999999\n";
54print SPEC "            exp samba.sw.base\n";
55print SPEC "        endsubsys\n";
56print SPEC "    endimage\n";
57print SPEC "    image man\n";
58print SPEC "        id \"Samba Online Documentation\"\n";
59print SPEC $vernum;
60print SPEC "        order 1\n";
61print SPEC "        subsys manpages default\n";
62print SPEC "            id \"Samba Man Page\"\n";
63print SPEC "            replaces fw_samba.man.manpages 0 9999999999\n";
64print SPEC "            replaces fw_samba.man.samba 0 9999999999\n";
65print SPEC "            exp samba.man.manpages\n";
66print SPEC "        endsubsys\n";
67print SPEC "        subsys doc default\n";
68print SPEC "            id \"Samba Documentation\"\n";
69print SPEC "            replaces fw_samba.man.doc 0 9999999999\n";
70print SPEC "            exp samba.man.doc\n";
71print SPEC "        endsubsys\n";
72print SPEC "        subsys relnotes default\n";
73print SPEC "            id \"Samba Release Notes\"\n";
74print SPEC "            replaces fw_samba.man.relnotes 0 9999999999\n";
75print SPEC "            exp samba.man.relnotes\n";
76print SPEC "        endsubsys\n";
77print SPEC "    endimage\n";
78print SPEC "    image src\n";
79print SPEC "        id \"Samba Source Code\"\n";
80print SPEC $vernum;
81print SPEC "        order 2\n";
82print SPEC "        subsys samba\n";
83print SPEC "            id \"Samba Source Code\"\n";
84print SPEC "            replaces fw_samba.src.samba 0 9999999999\n";
85print SPEC "            exp samba.src.samba\n";
86print SPEC "        endsubsys\n";
87print SPEC "    endimage\n";
88print SPEC "endproduct\n";
89close SPEC || die "Error on close of samba.spec\n";
90
91print "\nsamba.spec file has been created\n\n";
92