Copy newly generated files to epan/dissectors to make sure whoever runs this target...
[obnox/wireshark/wip.git] / packaging / svr4 / mkpkg
1 #!/bin/sh
2 #
3 # mkpkg - Builds a pkgadd-installable package from a listing of the contents in
4 # a staging directory.
5 #
6 # This is a modified version of a script written by mark@metalab.unc.edu .
7 # The original is at http://metalab.unc.edu/pub/packages/solaris/sparc/html/creating.solaris.packages.html .
8
9 if [ "$1" != "" ] ; then
10   pkg=$1
11 else
12   echo "Usage: " `basename $0` " <package name> [output file]"
13   exit 1
14 fi
15
16 if [ "$2" != "" ] ; then
17   pkgfile=$2
18 else
19   pkgfile=$pkg
20 fi
21
22 if [ "$3" != "" ] ; then
23   prefix=$3
24 else
25   prefix=/usr/local
26 fi
27
28 if [ "$4" != "" ] ; then
29   srcdir=$4
30 else
31   srcdir=`basename $0`/../..
32 fi
33
34 # Initialize our variables
35 prepdir=`dirname $0`
36 prototype="$prepdir/Prototype"
37 stagedir=$srcdir/${pkg}.inst
38
39 # Create the Prototype file
40 cat > $prototype <<Fin
41 i pkginfo
42 i checkinstall
43 Fin
44 if [ ! -d $stagedir ] ; then
45   echo "Whoops! Staging directory $stagedir doesn't exist.  Bailing."
46   exit 1
47 fi
48
49 find $stagedir/$prefix/* -print | \
50   pkgproto $stagedir/$prefix=$prefix | \
51   # Mimic file permissions under /usr
52   awk ' \
53     /bin/ { print $1, $2, $3, $4, "root bin"; next }; \
54     /lib/ { print $1, $2, $3, $4, "root bin"; next }; \
55     /man/ { print $1, $2, $3, $4, "root bin"; next }; \
56     { print $1, $2, $3, $4, "root sys" } \
57   ' \
58   >> $prototype
59
60 # Make the package installation directory
61 pkgmk -o -r / -d /$srcdir -f $prototype
62 echo "Setting file permissions in $stagedir tree to 644."
63 find $stagedir -type f -print | xargs chmod a+r
64 find $stagedir -type f -print | xargs chmod u+w
65 echo "Setting directory permissions in $stagedir tree to 755."
66 find $stagedir -type d -print | xargs chmod 755
67 if [ -f $stagedir/install/preinstall ]; then
68     chmod 755 $stagedir/install/preinstall
69 fi
70 if [ -f $stagedir/install/postinstall ]; then
71     chmod 755 $stagedir/install/postinstall
72 fi
73 if [ -f $stagedir/install/preremove ]; then
74     chmod 755 $stagedir/install/preremove
75 fi
76 if [ -f $stagedir/install/postremove ]; then
77     chmod 755 $stagedir/install/postremove
78 fi
79 if [ -f $stagedir/install/request ]; then
80     chmod 755 $stagedir/install/request
81 fi
82 if [ -f $stagedir/install/checkinstall ]; then
83     chmod 755 $stagedir/install/checkinstall
84 fi
85
86 # Spool the install directory into its own self-contained file.
87 pkgtrans -s $srcdir $pkgfile $pkg
88
89 # echo "Compressing package file"
90 # gzip -9 $srcdir/$pkgfile