-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkgpl
99 lines (83 loc) · 1.84 KB
/
mkgpl
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
91
92
93
94
95
96
97
98
99
#!/bin/sh
#
# History
#
# Jul 04 2005 stuartm
#
# First release.
#
VERSION="v1.00 Jul 04 2005"
#
# This uses only shell builtins to set up the utilities for require() to use
# at which point other utilities can be require()ed. This includes setting
# up $basename and $THIS for die().
#
init_require() {
which which > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$0: Error: Required utility 'which' not found"
exit 1
fi
which basename > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$0: Error: Required utility 'basename' not found"
exit 127
fi
which=`which which`
basename=`which basename`
THIS=`$basename $0`
}
die() {
echo "$THIS: Error: $*"
exit 1
}
require() {
local util
util=`$which $1`
if [ $? -ne 0 ] || [ "$util" = "" ]; then
die "Required utility '$1' not found"
fi
eval "$1=$util"
}
#
# Main
#
init_require
require gunzip
require tar
require dirname
require gzip
require rm
require awk
while [ "$1" != "" ]; do
case $1 in
-h)
echo "$VERSION"
echo
echo "$THIS -h"
echo "$THIS <SDK>"
echo
echo "Specify a source SDK from which the GPL-only SDK will be created."
exit 0
;;
*)
if [ "$SDK" = "" ]; then
SDK=$1
else
die "Too many arguments"
fi
esac
shift
done
[ "$SDK" = "" ] && die "Missing <SDK>"
[ ! -f "$SDK" ] && die "$SDK is not a file"
$gunzip < $SDK | $tar xf - || die "Couldn't unpack $SDK"
DIR_SDK=`$dirname $SDK`
if [ "$DIR_SDK" = "." ]; then
DIR_SDK=
else
DIR_SDK="$DIR_SDK/"
fi
BASE_SDK=`$basename $SDK | $awk '{ match($1, "(.*).sdk.*", a); print a[1]; }'`
$tar cf - $BASE_SDK.sdk $BASE_SDK.gpl | $gzip > ${DIR_SDK}$BASE_SDK.sdk.gpl-only.tar.gz || die "Couldn't pack ${DIR_SDK}$BASE_SDK.sdk.gpl-only.tar.gz"
$rm -f $BASE_SDK.sdk $BASE_SDK.gpl $BASE_SDK.nda || die "Couldn'r clean up temporary files"