blob: f167bbdf1e63c1b67efbca3bc81e386a6bb72262 [file] [log] [blame]
DRC45789532013-04-24 23:39:37 +00001# Copyright (C)2009-2011, 2013 D. R. Commander. All Rights Reserved.
DRC7f73d9b2011-05-25 03:51:29 +00002#
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.
DRC6533b6e2010-02-15 14:57:18 +000026
27#!/bin/sh
28
DRC6533b6e2010-02-15 14:57:18 +000029if [ ! "`id -u`" = "0" ]; then
DRC81f5f7c2011-05-24 13:59:14 +000030 echo "ERROR: This script must be executed as root"
31 exit -1
DRC6533b6e2010-02-15 14:57:18 +000032fi
33
DRC45789532013-04-24 23:39:37 +000034PACKAGE=@PKGNAME@
DRC81f5f7c2011-05-24 13:59:14 +000035MACPACKAGE=com.$PACKAGE.$PACKAGE
36RECEIPT=/Library/Receipts/$PACKAGE.pkg
DRC6533b6e2010-02-15 14:57:18 +000037
38LSBOM=
DRC81f5f7c2011-05-24 13:59:14 +000039if [ -d $RECEIPT ]; then
40 LSBOM='lsbom -s -f -l '$RECEIPT'/Contents/Archive.bom'
DRC6533b6e2010-02-15 14:57:18 +000041else
DRC81f5f7c2011-05-24 13:59:14 +000042 LSBOM='pkgutil --files '$MACPACKAGE
DRC6533b6e2010-02-15 14:57:18 +000043fi
44
DRC7f73d9b2011-05-25 03:51:29 +000045mylsbom()
46{
47 $LSBOM || (echo "ERROR: Could not list package contents"; exit -1)
48}
49
DRC81f5f7c2011-05-24 13:59:14 +000050echo Removing package files ...
51EXITSTATUS=0
52pushd /
DRC7f73d9b2011-05-25 03:51:29 +000053mylsbom | while read file; do
DRC81f5f7c2011-05-24 13:59:14 +000054 if [ ! -d "$file" ]; then rm "$file" 2>&1 || EXITSTATUS=-1; fi
DRC6533b6e2010-02-15 14:57:18 +000055done
DRC81f5f7c2011-05-24 13:59:14 +000056popd
DRC6533b6e2010-02-15 14:57:18 +000057
DRC81f5f7c2011-05-24 13:59:14 +000058echo Removing package directories ...
DRC7175e512013-04-23 22:29:00 +000059PREFIX=%{__prefix}
60BINDIR=%{__bindir}
61DATADIR=%{__datadir}
62INCLUDEDIR=%{__includedir}
63LIBDIR=%{__libdir}
64MANDIR=%{__mandir}
65
66if [ -d $BINDIR ]; then
67 rmdir $BINDIR 2>&1 || EXITSTATUS=-1
DRC995c8312010-06-05 01:20:35 +000068fi
DRC7175e512013-04-23 22:29:00 +000069if [ -d $LIBDIR ]; then
70 rmdir $LIBDIR 2>&1 || EXITSTATUS=-1
DRC6533b6e2010-02-15 14:57:18 +000071fi
DRC7175e512013-04-23 22:29:00 +000072if [ -d $INCLUDEDIR ]; then
73 rmdir $INCLUDEDIR 2>&1 || EXITSTATUS=-1
DRC6533b6e2010-02-15 14:57:18 +000074fi
DRC7175e512013-04-23 22:29:00 +000075if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$LIBDIR" = "/opt/libjpeg-turbo/lib" ]; then
76 if [ -h $LIBDIR\32 ]; then
77 rm $LIBDIR\32 2>&1 || EXITSTATUS=-1
78 fi
79 if [ -h $LIBDIR\64 ]; then
80 rm $LIBDIR\64 2>&1 || EXITSTATUS=-1
81 fi
DRC995c8312010-06-05 01:20:35 +000082fi
DRC7175e512013-04-23 22:29:00 +000083if [ -d $MANDIR/man1 ]; then
84 rmdir $MANDIR/man1 2>&1 || EXITSTATUS=-1
DRC995c8312010-06-05 01:20:35 +000085fi
DRC7175e512013-04-23 22:29:00 +000086if [ -d $MANDIR ]; then
87 rmdir $MANDIR 2>&1 || EXITSTATUS=-1
DRCf2602ce2011-04-01 00:20:33 +000088fi
DRC7175e512013-04-23 22:29:00 +000089if [ -d $DATADIR/classes ]; then
90 rmdir $DATADIR/classes 2>&1 || EXITSTATUS=-1
91fi
92if [ -d $DATADIR -a "$DATADIR" != "$PREFIX" ]; then
93 rmdir $DATADIR 2>&1 || EXITSTATUS=-1
94fi
95if [ "$PREFIX" = "/opt/libjpeg-turbo" -a -h "$PREFIX/doc" ]; then
96 rm $PREFIX/doc 2>&1 || EXITSTATUS=-1
97fi
98rmdir $PREFIX 2>&1 || EXITSTATUS=-1
DRC81f5f7c2011-05-24 13:59:14 +000099rmdir /Library/Documentation/$PACKAGE 2>&1 || EXITSTATUS=-1
DRC6533b6e2010-02-15 14:57:18 +0000100
DRC81f5f7c2011-05-24 13:59:14 +0000101if [ -d $RECEIPT ]; then
102 echo Removing package receipt ...
103 rm -r $RECEIPT 2>&1 || EXITSTATUS=-1
DRC6533b6e2010-02-15 14:57:18 +0000104else
DRC81f5f7c2011-05-24 13:59:14 +0000105 echo Forgetting package $MACPACKAGE ...
106 pkgutil --forget $MACPACKAGE
DRC6533b6e2010-02-15 14:57:18 +0000107fi
108
DRC81f5f7c2011-05-24 13:59:14 +0000109exit $EXITSTATUS