d1da9d5f1296de81e1003bb744588e04835aab1a
[ira/wip.git] / packaging / Solaris / makepkg.sh.tmpl
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   # Add the binaries, docs and SWAT files
15
16   echo "#\n# Binaries \n#"
17   cd $DISTR_BASE/source/bin
18   for binfile in *
19   do
20     if [ -f $binfile ]; then
21         case $file in 
22         CP*.so)
23          echo echo f none samba/lib/charset/$binfile=source/bin/$binfile 0755 root other
24          ;;
25         *)
26          echo f none samba/bin/$binfile=source/bin/$binfile 0755 root other
27         ;;
28         esac
29     fi
30   done
31
32   # Add the scripts to bin/
33   echo "#\n# Scripts \n#"
34   cd $DISTR_BASE/source/script
35   for shfile in *
36   do
37     if [ -f $shfile ]; then
38         echo f none samba/bin/$shfile=source/script/$shfile 0755 root other
39     fi
40   done
41
42  # add libraries to /lib for winbind
43   echo "#\n# Libraries \n#"
44     if [ -f $DISTR_BASE/source/nsswitch/libnss_winbind.so ] ; then
45         echo f none /usr/lib/libnss_winbind.so=source/nsswitch/libnss_winbind.so 0755 root other
46         echo s none /usr/lib/libnss_winbind.so.1=/usr/lib/libnss_winbind.so 0755 root other
47         echo s none /usr/lib/libnss_winbind.so.2=/usr/lib/libnss_winbind.so 0755 root other
48         echo s none /usr/lib/nss_winbind.so.1=/usr/lib/libnss_winbind.so 0755 root other
49         echo s none /usr/lib/nss_winbind.so.2=/usr/lib/libnss_winbind.so 0755 root other
50     fi
51
52  # add the .dat codepages
53   echo "#\n# Codepages \n#"
54     for file in $DISTR_BASE/source/codepages/*.dat ; do
55       bfile=`basename $file`
56       echo f none /usr/local/samba/lib/$bfile=source/codepages/$bfile
57     done
58
59   # Add the manpages
60   echo "#\n# man pages \n#"
61   echo d none /usr ? ? ?
62   echo d none /usr/share ? ? ?
63   echo d none /usr/share/man ? ? ?
64
65   # Create directories for man page sections if nonexistent
66   cd $DISTR_BASE/docs/manpages
67   for i in 1 2 3 4 5 6 7 8 9
68   do
69      manpages=`ls *.$i 2>/dev/null`
70      if [ $? -eq 0 ]
71      then
72         echo d none /usr/share/man/man$i ? ? ?
73         for manpage in $manpages 
74         do
75                 echo f none /usr/share/man/man${i}/${manpage}=docs/manpages/$manpage 0644 root other
76         done
77      fi
78   done
79
80   echo "#\n# HTML documentation \n#"
81   cd $DISTR_BASE
82   list=`find docs/htmldocs -type d | grep -v "/CVS$"`
83   for docdir in $list
84   do
85     if [ -d $docdir ]; then
86         echo d none samba/$docdir 0755 root other
87     fi
88   done
89
90   list=`find docs/htmldocs -type f | grep -v /CVS/`
91   for htmldoc in $list
92   do
93     if [ -f $htmldoc ]; then
94       echo f none samba/$htmldoc=$htmldoc 0644 root other
95     fi
96   done
97
98   # Create a symbolic link to the Samba book in docs/ for beginners
99   echo 's none samba/docs/samba_book=htmldocs/using_samba'
100
101   echo "#\n# Text Docs \n#"
102   echo d none samba/docs/textdocs 0755 root other
103   cd $DISTR_BASE/docs/textdocs
104   for textdoc in *
105   do 
106     if [ -f $textdoc ]; then
107       echo f none samba/docs/textdocs/$textdoc=docs/textdocs/$textdoc 0644 root other
108     fi
109   done
110   echo "#\n# SWAT \n#"
111   cd $DISTR_BASE
112   list=`find swat -type d | grep -v "/CVS$"`
113   for i in $list
114   do
115     echo "d none samba/$i 0755 root other"
116   done
117   list=`find swat -type f | grep -v /CVS/`
118   for i in $list
119   do
120     echo "f none samba/$i=$i 0644 root other"
121   done
122   echo "#\n# HTML documentation for SWAT\n#"
123   cd $DISTR_BASE/docs/htmldocs
124   for htmldoc in *
125   do
126     if [ -f $htmldoc ]; then
127       echo f none samba/swat/help/$htmldoc=docs/htmldocs/$htmldoc 0644 root other
128     fi
129   done
130
131   echo "#\n# Using Samba Book files for SWAT\n#"
132   cd $DISTR_BASE/docs/htmldocs
133
134 # set up a symbolic link instead of duplicating the book tree
135   echo 's none samba/swat/using_samba=../docs/htmldocs/using_samba'
136
137 }
138
139 if [ $# = 0 ]
140 then
141         # Try to guess the distribution base..
142         CURR_DIR=`pwd`
143         DISTR_BASE=`echo $CURR_DIR | sed 's|\(.*\)/packaging.*|\1|'`
144         echo "Assuming Samba distribution is rooted at $DISTR_BASE.."
145 else
146         DISTR_BASE=$1
147 fi
148
149 #
150 if [ ! -d $DISTR_BASE ]; then
151         echo "Source build directory $DISTR_BASE does not exist."
152         exit 1
153 fi
154
155 # Set up the prototype file from prototype.master
156 if [ -f prototype ]; then
157         rm prototype
158 fi
159
160 # Setup version from version.h
161 VERSION=PVERSION
162 sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master >pkginfo
163
164 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master >inetd.conf
165 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.server.master >samba.server
166
167 cp prototype.master prototype
168
169 # Add the dynamic part to the prototype file
170 (add_dynamic_entries >> prototype)
171
172 # Create the package
173 pkgmk -o -d /tmp -b $DISTR_BASE -f prototype
174 if [ $? = 0 ]
175 then
176         pkgtrans /tmp samba.pkg samba
177 fi
178 echo The samba package is in /tmp