aboutsummaryrefslogtreecommitdiffstats
path: root/packaging/svr4/mkpkg
blob: 27456964c7512fb6ca8540ca9400eca668aa74e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
#
# mkpkg - Builds a pkgadd-installable package from a listing of the contents in
# a staging directory.
#
# This is a modified version of a script written by mark@metalab.unc.edu .
# The original is at http://metalab.unc.edu/pub/packages/solaris/sparc/html/creating.solaris.packages.html .

if [ "$1" != "" ] ; then
  pkg=$1
else
  echo "Usage: " `basename $0` " <package name> [output file]"
  exit 1
fi

if [ "$2" != "" ] ; then
  pkgfile=$2
else
  pkgfile=$pkg
fi

if [ "$3" != "" ] ; then
  prefix=$3
else
  prefix=/usr/local
fi

if [ "$4" != "" ] ; then
  srcdir=$4
else
  srcdir=`basename $0`/../..
fi

# Initialize our variables
prepdir=`dirname $0`
prototype="$prepdir/Prototype"
stagedir=$srcdir/${pkg}.stage

# Create the Prototype file
cat > $prototype <<Fin
i pkginfo
i checkinstall
Fin
if [ ! -d $stagedir ] ; then
  echo "Whoops! Staging directory $stagedir doesn't exist.  Bailing."
  exit 1
fi

find $stagedir/$prefix/* -print | \
  pkgproto $stagedir/$prefix=$prefix | \
  # Mimic file permissions under /usr
  awk ' \
    /bin/ { print $1, $2, $3, $4, "root bin"; next }; \
    /lib/ { print $1, $2, $3, $4, "root bin"; next }; \
    /man/ { print $1, $2, $3, $4, "root bin"; next }; \
    { print $1, $2, $3, $4, "root sys" } \
  ' \
  >> $prototype

# Make the package installation directory
pkgmk -o -r / -d /$srcdir -f $prototype
echo "Setting file permissions in $stagedir tree to 644."
find $stagedir -type f -print | xargs chmod a+r
find $stagedir -type f -print | xargs chmod u+w
echo "Setting directory permissions in $stagedir tree to 755."
find $stagedir -type d -print | xargs chmod 755
if [ -f $stagedir/install/preinstall ]; then
    chmod 755 $stagedir/install/preinstall
fi
if [ -f $stagedir/install/postinstall ]; then
    chmod 755 $stagedir/install/postinstall
fi
if [ -f $stagedir/install/preremove ]; then
    chmod 755 $stagedir/install/preremove
fi
if [ -f $stagedir/install/postremove ]; then
    chmod 755 $stagedir/install/postremove
fi
if [ -f $stagedir/install/request ]; then
    chmod 755 $stagedir/install/request
fi
if [ -f $stagedir/install/checkinstall ]; then
    chmod 755 $stagedir/install/checkinstall
fi

# Spool the install directory into its own self-contained file.
pkgtrans -s $srcdir $pkgfile $pkg

# echo "Compressing package file"
# gzip -9 $srcdir/$pkgfile