uninstall.in 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. PKGNAME=@PKGNAME@
  32. PKGID=@PKGID@
  33. RECEIPT=/Library/Receipts/$PKGNAME.pkg
  34. LSBOM=
  35. if [ -d $RECEIPT ]; then
  36. LSBOM='lsbom -s -f -l '$RECEIPT'/Contents/Archive.bom'
  37. else
  38. LSBOM='pkgutil --files '$PKGID
  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=@CMAKE_INSTALL_PREFIX@
  53. BINDIR=@CMAKE_INSTALL_FULL_BINDIR@
  54. DATAROOTDIR=@CMAKE_INSTALL_FULL_DATAROOTDIR@
  55. INCLUDEDIR=@CMAKE_INSTALL_FULL_INCLUDEDIR@
  56. JAVADIR=@CMAKE_INSTALL_FULL_JAVADIR@
  57. LIBDIR=@CMAKE_INSTALL_FULL_LIBDIR@
  58. MANDIR=@CMAKE_INSTALL_FULL_MANDIR@
  59. if [ -d $BINDIR ]; then
  60. rmdir $BINDIR 2>&1 || EXITSTATUS=-1
  61. fi
  62. if [ -d $LIBDIR/pkgconfig ]; then
  63. rmdir $LIBDIR/pkgconfig 2>&1 || EXITSTATUS=-1
  64. fi
  65. if [ -d $LIBDIR ]; then
  66. rmdir $LIBDIR 2>&1 || EXITSTATUS=-1
  67. fi
  68. if [ -d $INCLUDEDIR ]; then
  69. rmdir $INCLUDEDIR 2>&1 || EXITSTATUS=-1
  70. fi
  71. if [ "$PREFIX" = "@CMAKE_INSTALL_DEFAULT_PREFIX@" -a "$LIBDIR" = "@CMAKE_INSTALL_DEFAULT_PREFIX@/lib" ]; then
  72. if [ -h $LIBDIR\32 ]; then
  73. rm $LIBDIR\32 2>&1 || EXITSTATUS=-1
  74. fi
  75. if [ -h $LIBDIR\64 ]; then
  76. rm $LIBDIR\64 2>&1 || EXITSTATUS=-1
  77. fi
  78. fi
  79. if [ -d $MANDIR/man1 ]; then
  80. rmdir $MANDIR/man1 2>&1 || EXITSTATUS=-1
  81. fi
  82. if [ -d $MANDIR ]; then
  83. rmdir $MANDIR 2>&1 || EXITSTATUS=-1
  84. fi
  85. if [ -d $JAVADIR ]; then
  86. rmdir $JAVADIR 2>&1 || EXITSTATUS=-1
  87. fi
  88. if [ -d $DATAROOTDIR -a "$DATAROOTDIR" != "$PREFIX" ]; then
  89. rmdir $DATAROOTDIR 2>&1 || EXITSTATUS=-1
  90. fi
  91. if [ "$PREFIX" = "@CMAKE_INSTALL_DEFAULT_PREFIX@" -a -h "$PREFIX/doc" ]; then
  92. rm $PREFIX/doc 2>&1 || EXITSTATUS=-1
  93. fi
  94. rmdir $PREFIX 2>&1 || EXITSTATUS=-1
  95. rmdir /Library/Documentation/$PKGNAME 2>&1 || EXITSTATUS=-1
  96. if [ -d $RECEIPT ]; then
  97. echo Removing package receipt ...
  98. rm -r $RECEIPT 2>&1 || EXITSTATUS=-1
  99. else
  100. echo Forgetting package $PKGID ...
  101. pkgutil --forget $PKGID
  102. fi
  103. exit $EXITSTATUS