-
Notifications
You must be signed in to change notification settings - Fork 11
/
create_package.sh
47 lines (33 loc) · 1.23 KB
/
create_package.sh
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
#!/usr/bin/ksh
TMPFILE=/tmp/` basename $0`.$$
CURDIR=`pwd`
VERSION=` basename ${CURDIR}`
DUMMY=` dirname ${CURDIR}`
PACKAGE=` basename ${DUMMY} `
PACKAGE_FILE="${CURDIR}/../${PACKAGE}_v${VERSION}.pkg"
die() {
typeset THISRC=$1
shift
echo $*
exit ${THISRC}
}
echo "Creating the package \"${PACKAGE}\" version \"${VERSION}\" ..."
[ ! -f ./pkginfo ] && die 2 "./pkginfo file missing"
[ ! -f ./pkgproto.template ] && die 2 "./pkgproto.template file missing"
echo "Changing the version info in the ./pkginfo file ..."
grep -v "^VERSION=" ./pkginfo >${TMPFILE}
echo "VERSION=${VERSION}" >./pkginfo
cat ${TMPFILE} >>./pkginfo
rm ${TMPFILE}
echo "Creating the pkgproto file ..."
cp pkgproto.template ./pkgproto
[ $? -ne 0 ] && die 1 "Error creating the pkgproto file"
( cd root ; pkgproto . >>../pkgproto )
[ $? -ne 0 ] && die 2 "Error creating the pkgproto file"
echo "Creating the package ..."
pkgmk -o -r ./root -f pkgproto ${PACKAGE}
[ $? -ne 0 ] && die 1 "Error creating the package"
echo "Transfering the package into file format ..."
pkgtrans /var/spool/pkg ${PACKAGE_FILE} ${PACKAGE}
[ $? -ne 0 ] && die 1 "Error tranfering the package"
echo "Package \"${PACKAGE}\" version \"${VERSION}\" created in the file \"${PACKAGE_FILE}\" ..."