1 | #!/bin/sh
|
---|
2 | set -e
|
---|
3 | # innotek VirtualBox
|
---|
4 | # VirtualBox Solaris package creation script.
|
---|
5 | #
|
---|
6 | # Copyright (C) 2007-2008 innotek GmbH
|
---|
7 | #
|
---|
8 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | # available from http://www.virtualbox.org. This file is free software;
|
---|
10 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | # General Public License (GPL) as published by the Free Software
|
---|
12 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | #
|
---|
16 |
|
---|
17 | #
|
---|
18 | # Usage:
|
---|
19 | # makespackage.sh $(PATH_TARGET)/install packagename $(BUILD_TARGET_ARCH)
|
---|
20 |
|
---|
21 | if [ -z "$3" ]; then
|
---|
22 | echo "Usage: $0 installdir packagename x86|amd64"
|
---|
23 | exit 1
|
---|
24 | fi
|
---|
25 |
|
---|
26 | MY_PKGNAME=SUNWvbox
|
---|
27 | MY_GGREP=/usr/sfw/bin/ggrep
|
---|
28 | MY_AWK=/usr/bin/awk
|
---|
29 | MY_GTAR=/usr/sfw/bin/gtar
|
---|
30 |
|
---|
31 | # check for GNU grep we use which might not ship with all Solaris
|
---|
32 | if test ! -f "$MY_GGREP" || test ! -h "$MY_GGREP"; then
|
---|
33 | echo "## GNU grep not found in $MY_GGREP."
|
---|
34 | exit 1
|
---|
35 | fi
|
---|
36 |
|
---|
37 | # check for GNU tar we use which might not ship with all Solaris
|
---|
38 | if test ! -f "$MY_GTAR" || test ! -h "$MY_GTAR"; then
|
---|
39 | echo "## GNU tar not found in $MY_GTAR."
|
---|
40 | exit 1
|
---|
41 | fi
|
---|
42 |
|
---|
43 |
|
---|
44 | # prepare file list
|
---|
45 | cd "$1"
|
---|
46 | echo 'i pkginfo=./vbox.pkginfo' > prototype
|
---|
47 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
48 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
49 | echo 'i space=./vbox.space' >> prototype
|
---|
50 | echo 'e sed /etc/devlink.tab ? ? ?' >> prototype
|
---|
51 | find . -print | $MY_GGREP -v -E 'prototype|makepackage.sh|vbox.pkginfo|postinstall.sh|preremove.sh|ReadMe.txt|vbox.space' | pkgproto >> prototype
|
---|
52 |
|
---|
53 | # don't grok for the sed class files
|
---|
54 | $MY_AWK 'NF == 6 && $2 == "none" { $5 = "root"; $6 = "bin" } { print }' prototype > prototype2
|
---|
55 | $MY_AWK 'NF == 6 && $2 == "none" { $3 = "opt/VirtualBox/"$3"="$3 } { print }' prototype2 > prototype
|
---|
56 |
|
---|
57 | # install the kernel module to the right place.
|
---|
58 | if test "$3" = "x86"; then
|
---|
59 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBox/vboxdrv=vboxdrv" { $3 = "platform/i86pc/kernel/drv/vboxdrv=vboxdrv" } { print }' prototype > prototype2
|
---|
60 | else
|
---|
61 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBox/vboxdrv=vboxdrv" { $3 = "platform/i86pc/kernel/drv/amd64/vboxdrv=vboxdrv" } { print }' prototype > prototype2
|
---|
62 | fi
|
---|
63 |
|
---|
64 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBox/vboxdrv.conf=vboxdrv.conf" { $3 = "platform/i86pc/kernel/drv/vboxdrv.conf=vboxdrv.conf" } { print }' prototype2 > prototype
|
---|
65 |
|
---|
66 | rm prototype2
|
---|
67 |
|
---|
68 | # explicitly set timestamp to shutup warning
|
---|
69 | VBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`
|
---|
70 |
|
---|
71 | # create the package instance
|
---|
72 | pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
73 | if test $? -ne 0; then
|
---|
74 | exit 1
|
---|
75 | fi
|
---|
76 |
|
---|
77 | # translate into package datastream
|
---|
78 | pkgtrans -s -o /var/spool/pkg `pwd`/$2 "$MY_PKGNAME"
|
---|
79 | if test $? -ne 0; then
|
---|
80 | exit 1
|
---|
81 | fi
|
---|
82 |
|
---|
83 | $MY_GTAR zcvf $2.tar.gz $2 autoresponse ReadMe.txt
|
---|
84 |
|
---|
85 | if test $? -eq 0; then
|
---|
86 | echo "## Packaging and transfer completed successfully!"
|
---|
87 | fi
|
---|
88 | rm -rf "/var/spool/pkg/$MY_PKGNAME"
|
---|
89 | exit $?
|
---|
90 |
|
---|