This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[kai/samba.git] / packaging / Solaris / makepkg.sh
1 #!/bin/sh
2 #
3 # Copyright (C) Shirish A Kalele 2000
4 #
5 # Builds a Samba package from the samba distribution. 
6 # By default, the package will be built to install samba in /usr/local
7 # Change the INSTALL_BASE variable to change this: will modify the pkginfo 
8 # and samba.server files to point to the new INSTALL_BASE
9 #
10 INSTALL_BASE=/usr/local
11
12 add_dynamic_entries() 
13 {
14   # First build the codepages and append codepage entries to prototype
15   echo "#\n# Codepages \n#"
16   echo d none samba/lib/codepages 0755 root other
17
18   CODEPAGELIST="437 737 850 852 861 932 866 949 950 936"
19   # Check if make_smbcodepage exists
20   if [ ! -f $DISTR_BASE/source/bin/make_smbcodepage ]; then
21     echo "Could not find $DISTR_BASE/source/bin/make_smbcodepage to generate codepages.\n\
22      Please create the binaries before packaging." >&2
23     exit 1
24   fi
25
26   for p in $CODEPAGELIST; do
27     $DISTR_BASE/source/bin/make_smbcodepage c $p $DISTR_BASE/source/codepages/codepage_def.$p $DISTR_BASE/source/codepages/codepage.$p
28     echo f none samba/lib/codepages/codepage.$p=source/codepages/codepage.$p 0644 root other
29   done
30
31   # Create unicode maps
32   if [ ! -f $DISTR_BASE/source/bin/make_unicodemap ]; then
33     echo "Missing $DISTR_BASE/source/bin/make_unicodemap. Aborting." >&2
34     exit 1
35   fi
36
37   # Pull in all the unicode map files from source/codepages/CP*.TXT
38   list=`find $DISTR_BASE/source/codepages -name "CP*.TXT" | sed 's|^.*CP\(.*\)\.TXT|\1|'`
39   for umap in $list
40   do
41     $DISTR_BASE/source/bin/make_unicodemap $umap $DISTR_BASE/source/codepages/CP$umap.TXT $DISTR_BASE/source/codepages/unicode_map.$umap
42     echo f none samba/lib/codepages/unicode_map.$umap=source/codepages/unicode_map.$umap 0644 root other
43   done
44
45   # Add the binaries, docs and SWAT files
46
47   echo "#\n# Binaries \n#"
48   cd $DISTR_BASE/source/bin
49   for binfile in *
50   do
51     if [ -f $binfile ]; then
52       echo f none samba/bin/$binfile=source/bin/$binfile 0755 root other
53     fi
54   done
55
56   # Add the scripts to bin/
57   echo "#\n# Scripts \n#"
58   cd $DISTR_BASE/source/script
59   for shfile in *
60   do
61     if [ -f $shfile ]; then
62         echo f none samba/bin/$shfile=source/script/$shfile 0755 root other
63     fi
64   done
65
66   # Add the manpages
67   echo "#\n# man pages \n#"
68   echo d none /usr ? ? ?
69   echo d none /usr/share ? ? ?
70   echo d none /usr/share/man ? ? ?
71
72   # Create directories for man page sections if nonexistent
73   cd $DISTR_BASE/docs/manpages
74   for i in 1 2 3 4 5 6 7 8 9
75   do
76      manpages=`ls *.$i 2>/dev/null`
77      if [ $? -eq 0 ]
78      then
79         echo d none /usr/share/man/man$i ? ? ?
80         for manpage in $manpages 
81         do
82                 echo f none /usr/share/man/man${i}/${manpage}=docs/manpages/$manpage 0644 root other
83         done
84      fi
85   done
86
87   echo "#\n# HTML documentation \n#"
88   cd $DISTR_BASE
89   list=`find docs/htmldocs -type d | grep -v "/CVS$"`
90   for docdir in $list
91   do
92     if [ -d $docdir ]; then
93         echo d none samba/$docdir 0755 root other
94     fi
95   done
96
97   list=`find docs/htmldocs -type f | grep -v /CVS/`
98   for htmldoc in $list
99   do
100     if [ -f $htmldoc ]; then
101       echo f none samba/$htmldoc=$htmldoc 0644 root other
102     fi
103   done
104
105   # Create a symbolic link to the Samba book in docs/ for beginners
106   echo 's none samba/docs/samba_book=htmldocs/using_samba'
107
108   echo "#\n# Text Docs \n#"
109   echo d none samba/docs/textdocs 0755 root other
110   cd $DISTR_BASE/docs/textdocs
111   for textdoc in *
112   do 
113     if [ -f $textdoc ]; then
114       echo f none samba/docs/textdocs/$textdoc=docs/textdocs/$textdoc 0644 root other
115     fi
116   done
117   echo "#\n# SWAT \n#"
118   cd $DISTR_BASE
119   list=`find swat -type d | grep -v "/CVS$"`
120   for i in $list
121   do
122     echo "d none samba/$i 0755 root other"
123   done
124   list=`find swat -type f | grep -v /CVS/`
125   for i in $list
126   do
127     echo "f none samba/$i=$i 0644 root other"
128   done
129   echo "#\n# HTML documentation for SWAT\n#"
130   cd $DISTR_BASE/docs/htmldocs
131   for htmldoc in *
132   do
133     if [ -f $htmldoc ]; then
134       echo f none samba/swat/help/$htmldoc=docs/htmldocs/$htmldoc 0644 root other
135     fi
136   done
137
138   echo "#\n# Using Samba Book files for SWAT\n#"
139   cd $DISTR_BASE/docs/htmldocs
140
141 # set up a symbolic link instead of duplicating the book tree
142   echo 's none samba/swat/using_samba=../docs/htmldocs/using_samba'
143
144 }
145
146 if [ $# = 0 ]
147 then
148         # Try to guess the distribution base..
149         CURR_DIR=`pwd`
150         DISTR_BASE=`echo $CURR_DIR | sed 's|\(.*\)/packaging.*|\1|'`
151         echo "Assuming Samba distribution is rooted at $DISTR_BASE.."
152 else
153         DISTR_BASE=$1
154 fi
155
156 #
157 if [ ! -d $DISTR_BASE ]; then
158         echo "Source build directory $DISTR_BASE does not exist."
159         exit 1
160 fi
161
162 # Set up the prototype file from prototype.master
163 if [ -f prototype ]; then
164         rm prototype
165 fi
166
167 # Setup version from version.h
168 VERSION=`sed 's/#define VERSION \"\(.*\)\"$/\1/' ../../source/include/version.h`
169 sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master >pkginfo
170
171 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master >inetd.conf
172 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.server.master >samba.server
173
174 cp prototype.master prototype
175
176 # Add the dynamic part to the prototype file
177 (add_dynamic_entries >> prototype)
178
179 # Create the package
180 pkgmk -o -d /tmp -b $DISTR_BASE -f prototype
181 if [ $? = 0 ]
182 then
183         pkgtrans /tmp samba.pkg samba
184 fi
185 echo The samba package is in /tmp