• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C)2009-2011, 2013, 2016 D. R. Commander.  All Rights Reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are met:
5#
6# - Redistributions of source code must retain the above copyright notice,
7#   this list of conditions and the following disclaimer.
8# - Redistributions in binary form must reproduce the above copyright notice,
9#   this list of conditions and the following disclaimer in the documentation
10#   and/or other materials provided with the distribution.
11# - Neither the name of the libjpeg-turbo Project nor the names of its
12#   contributors may be used to endorse or promote products derived from this
13#   software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26
27#!/bin/sh
28
29if [ ! "`id -u`" = "0" ]; then
30	echo "ERROR: This script must be executed as root"
31	exit -1
32fi
33
34PKGNAME=@PKGNAME@
35PKGID=@PKGID@
36RECEIPT=/Library/Receipts/$PKGNAME.pkg
37
38LSBOM=
39if [ -d $RECEIPT ]; then
40	LSBOM='lsbom -s -f -l '$RECEIPT'/Contents/Archive.bom'
41else
42	LSBOM='pkgutil --files '$PKGID
43fi
44
45mylsbom()
46{
47	$LSBOM || (echo "ERROR: Could not list package contents"; exit -1)
48}
49
50echo Removing package files ...
51EXITSTATUS=0
52pushd /
53mylsbom | while read file; do
54	if [ ! -d "$file" ]; then rm "$file" 2>&1 || EXITSTATUS=-1; fi
55done
56popd
57
58echo Removing package directories ...
59PREFIX=@CMAKE_INSTALL_PREFIX@
60BINDIR=@CMAKE_INSTALL_FULL_BINDIR@
61DATAROOTDIR=@CMAKE_INSTALL_FULL_DATAROOTDIR@
62INCLUDEDIR=@CMAKE_INSTALL_FULL_INCLUDEDIR@
63JAVADIR=@CMAKE_INSTALL_FULL_JAVADIR@
64LIBDIR=@CMAKE_INSTALL_FULL_LIBDIR@
65MANDIR=@CMAKE_INSTALL_FULL_MANDIR@
66
67if [ -d $BINDIR ]; then
68	rmdir $BINDIR 2>&1 || EXITSTATUS=-1
69fi
70if [ -d $LIBDIR/pkgconfig ]; then
71	rmdir $LIBDIR/pkgconfig 2>&1 || EXITSTATUS=-1
72fi
73if [ -d $LIBDIR ]; then
74	rmdir $LIBDIR 2>&1 || EXITSTATUS=-1
75fi
76if [ -d $INCLUDEDIR ]; then
77	rmdir $INCLUDEDIR 2>&1 || EXITSTATUS=-1
78fi
79if [ "$PREFIX" = "@CMAKE_INSTALL_DEFAULT_PREFIX@" -a "$LIBDIR" = "@CMAKE_INSTALL_DEFAULT_PREFIX@/lib" ]; then
80	if [ -h $LIBDIR\32 ]; then
81		rm $LIBDIR\32 2>&1 || EXITSTATUS=-1
82	fi
83	if [ -h $LIBDIR\64 ]; then
84		rm $LIBDIR\64 2>&1 || EXITSTATUS=-1
85	fi
86fi
87if [ -d $MANDIR/man1 ]; then
88	rmdir $MANDIR/man1 2>&1 || EXITSTATUS=-1
89fi
90if [ -d $MANDIR ]; then
91	rmdir $MANDIR 2>&1 || EXITSTATUS=-1
92fi
93if [ -d $JAVADIR ]; then
94	rmdir $JAVADIR 2>&1 || EXITSTATUS=-1
95fi
96if [ -d $DATAROOTDIR -a "$DATAROOTDIR" != "$PREFIX" ]; then
97	rmdir $DATAROOTDIR 2>&1 || EXITSTATUS=-1
98fi
99if [ "$PREFIX" = "@CMAKE_INSTALL_DEFAULT_PREFIX@" -a -h "$PREFIX/doc" ]; then
100	rm $PREFIX/doc 2>&1 || EXITSTATUS=-1
101fi
102rmdir $PREFIX 2>&1 || EXITSTATUS=-1
103rmdir /Library/Documentation/$PKGNAME 2>&1 || EXITSTATUS=-1
104
105if [ -d $RECEIPT ]; then
106	echo Removing package receipt ...
107	rm -r $RECEIPT 2>&1 || EXITSTATUS=-1
108else
109	echo Forgetting package $PKGID ...
110	pkgutil --forget $PKGID
111fi
112
113exit $EXITSTATUS
114