Adding Solaris packaging files to HEAD.
[garming/samba-autobuild/.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   # Add the binaries, docs and SWAT files
32
33   echo "#\n# Binaries \n#"
34   cd $DISTR_BASE/source/bin
35   for binfile in *
36   do
37     if [ -f $binfile ]; then
38       echo f none samba/bin/$binfile=source/bin/$binfile 0755 root other
39     fi
40   done
41   echo "#\n# HTML documentation \n#"
42   echo d none samba/docs/htmldocs 0755 root other
43   cd $DISTR_BASE/docs/htmldocs
44   for htmldoc in *
45   do
46     if [ -f $htmldoc ]; then
47       echo f none samba/docs/htmldocs/$htmldoc=docs/htmldocs/$htmldoc 0644 root other
48     fi
49   done
50   echo "#\n# Text Docs \n#"
51   echo d none samba/docs/textdocs 0755 root other
52   cd $DISTR_BASE/docs/textdocs
53   for textdoc in *
54   do 
55     if [ -f $textdoc ]; then
56       echo f none samba/docs/textdocs/$textdoc=docs/textdocs/$textdoc 0644 root other
57     fi
58   done
59   echo "#\n# SWAT \n#"
60   cd $DISTR_BASE
61   list=`find swat -type d`
62   for i in $list
63   do
64     echo "d none samba/$i 0755 root other"
65   done
66   list=`find swat -type f`
67   for i in $list
68   do
69     echo "f none samba/$i=$i 0644 root other"
70   done
71   echo "#\n# HTML documentation for SWAT\n#"
72   cd $DISTR_BASE/docs/htmldocs
73   for htmldoc in *
74   do
75     if [ -f $htmldoc ]; then
76       echo f none samba/swat/help/$htmldoc=docs/htmldocs/$htmldoc 0644 root other
77     fi
78   done
79
80 }
81
82 if [ $# = 0 ]
83 then
84         # Try to guess the distribution base..
85         CURR_DIR=`pwd`
86         DISTR_BASE=`echo $CURR_DIR | sed 's|\(.*\)/packaging.*|\1|'`
87         echo "Assuming Samba distribution is rooted at $DISTR_BASE.."
88 else
89         DISTR_BASE=$1
90 fi
91
92 #
93 if [ ! -d $DISTR_BASE ]; then
94         echo "Source build directory $DISTR_BASE does not exist."
95         exit 1
96 fi
97
98 # Set up the prototype file from prototype.master
99 if [ -f prototype ]; then
100         rm prototype
101 fi
102
103 # Setup version from version.h
104 VERSION=`sed 's/#define VERSION \"\(.*\)\"$/\1/' ../../source/include/version.h`
105 sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master >pkginfo
106
107 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master >inetd.conf
108 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.server.master >samba.server
109
110 cp prototype.master prototype
111
112 # Add the dynamic part to the prototype file
113 (add_dynamic_entries >> prototype)
114
115 # Create the package
116 pkgmk -o -d /tmp -b $DISTR_BASE -f prototype
117 if [ $? = 0 ]
118 then
119         pkgtrans /tmp samba.pkg samba
120 fi
121 echo The samba package is in /tmp
122 rm -f prototype