uninstall.in 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. #!/bin/sh
  27. if [ ! "`id -u`" = "0" ]; then
  28. echo "ERROR: This script must be executed as root"
  29. exit -1
  30. fi
  31. PACKAGE=@PKGNAME@
  32. MACPACKAGE=com.$PACKAGE.$PACKAGE
  33. RECEIPT=/Library/Receipts/$PACKAGE.pkg
  34. LSBOM=
  35. if [ -d $RECEIPT ]; then
  36. LSBOM='lsbom -s -f -l '$RECEIPT'/Contents/Archive.bom'
  37. else
  38. LSBOM='pkgutil --files '$MACPACKAGE
  39. fi
  40. mylsbom()
  41. {
  42. $LSBOM || (echo "ERROR: Could not list package contents"; exit -1)
  43. }
  44. echo Removing package files ...
  45. EXITSTATUS=0
  46. pushd /
  47. mylsbom | while read file; do
  48. if [ ! -d "$file" ]; then rm "$file" 2>&1 || EXITSTATUS=-1; fi
  49. done
  50. popd
  51. echo Removing package directories ...
  52. PREFIX=%{__prefix}
  53. BINDIR=%{__bindir}
  54. DATADIR=%{__datadir}
  55. INCLUDEDIR=%{__includedir}
  56. LIBDIR=%{__libdir}
  57. MANDIR=%{__mandir}
  58. if [ -d $BINDIR ]; then
  59. rmdir $BINDIR 2>&1 || EXITSTATUS=-1
  60. fi
  61. if [ -d $LIBDIR/pkgconfig ]; then
  62. rmdir $LIBDIR/pkgconfig 2>&1 || EXITSTATUS=-1
  63. fi
  64. if [ -d $LIBDIR ]; then
  65. rmdir $LIBDIR 2>&1 || EXITSTATUS=-1
  66. fi
  67. if [ -d $INCLUDEDIR ]; then
  68. rmdir $INCLUDEDIR 2>&1 || EXITSTATUS=-1
  69. fi
  70. if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$LIBDIR" = "/opt/libjpeg-turbo/lib" ]; then
  71. if [ -h $LIBDIR\32 ]; then
  72. rm $LIBDIR\32 2>&1 || EXITSTATUS=-1
  73. fi
  74. if [ -h $LIBDIR\64 ]; then
  75. rm $LIBDIR\64 2>&1 || EXITSTATUS=-1
  76. fi
  77. fi
  78. if [ -d $MANDIR/man1 ]; then
  79. rmdir $MANDIR/man1 2>&1 || EXITSTATUS=-1
  80. fi
  81. if [ -d $MANDIR ]; then
  82. rmdir $MANDIR 2>&1 || EXITSTATUS=-1
  83. fi
  84. if [ -d $DATADIR/classes ]; then
  85. rmdir $DATADIR/classes 2>&1 || EXITSTATUS=-1
  86. fi
  87. if [ -d $DATADIR -a "$DATADIR" != "$PREFIX" ]; then
  88. rmdir $DATADIR 2>&1 || EXITSTATUS=-1
  89. fi
  90. if [ "$PREFIX" = "/opt/libjpeg-turbo" -a -h "$PREFIX/doc" ]; then
  91. rm $PREFIX/doc 2>&1 || EXITSTATUS=-1
  92. fi
  93. rmdir $PREFIX 2>&1 || EXITSTATUS=-1
  94. rmdir /Library/Documentation/$PACKAGE 2>&1 || EXITSTATUS=-1
  95. if [ -d $RECEIPT ]; then
  96. echo Removing package receipt ...
  97. rm -r $RECEIPT 2>&1 || EXITSTATUS=-1
  98. else
  99. echo Forgetting package $MACPACKAGE ...
  100. pkgutil --forget $MACPACKAGE
  101. fi
  102. exit $EXITSTATUS