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