summaryrefslogtreecommitdiff
path: root/build/mac/cmdline-install
blob: f1cd4ebf89a4b0a7de77a80aaf539a4127bd31f9 (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
#!/bin/sh
#
# install a PCP *.dmg package from the command line ...
# run from the build/mac directory in a PCP build tree after Makepkgs
#
tmp=`mktemp -d /var/tmp/pcp.XXXXXXXXX` || exit 1
sts=1
trap "rm -rf $tmp; exit \$sts" 0 1 2 3 15

disk_image=`echo pcp-*.dmg | sed -e 's/$/ /' -e 's/[^ ]*\.tmp\.dmg / /' -e 's/ $//'`
if [ "$disk_image" = "pcp-*.dmg" ]
then
    echo "Error: no .dmg file?"
    exit
fi

n=`echo "$disk_image" | wc -w | sed -e 's/ //'`
if [ "$n" -gt 1 ]
then
    echo "Error: more than one .dmg file: $disk_image"
    exit
fi

base=`echo $disk_image | sed -e 's/\.dmg$//'`
if hdiutil attach $disk_image >$tmp/out 2>&1
then
    :
else
    cat $tmp/out
    echo "Error: hdiutil attach failed"
    exit
fi

if [ -d /Volumes/$base/$base.pkg ]
then
    if sudo installer -pkg /Volumes/$base/$base.pkg -target / >$tmp/out 2>&1
    then
	sts=0
    else
	cat $tmp/out
	echo "Error: installer failed"
    fi
else
    ls -l /Volumes/$base/
    echo "Error: no package directory /Volumes/$base/$base.pkg?"
    exit
fi

if hdiutil detach /Volumes/$base >$tmp/out 2>&1
then
    :
else
    cat $tmp/out
    echo "Error: hdiutil detach failed"
    sts=1
    exit
fi