LDraw_data.SlackBuild 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/bin/bash
  2. # Slackware build script for LDRAW datafiles, needed by
  3. # several LDraw utilities
  4. # Copyright 2009-2013 Niels Horn, Rio de Janeiro, RJ, Brazil
  5. # Copyright 2016 Philip van der Hoeven, Almere, The Netherlands
  6. # All rights reserved.
  7. #
  8. # Redistribution and use of this script, with or without modification, is
  9. # permitted provided that the following conditions are met:
  10. #
  11. # 1. Redistributions of this script must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
  15. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  17. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  22. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  23. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. # 20220222 bkw: Modified by SlackBuilds.org:
  25. # - update for v202201.
  26. # - host download file on slackware.uk, for now. this gives us a little
  27. # breathing space, when upstream changes the download file again.
  28. cd $(dirname $0) ; CWD=$(pwd)
  29. PRGNAM=LDraw_data
  30. VERSION=${VERSION:-202201}
  31. ARCH=noarch
  32. BUILD=${BUILD:-1}
  33. TAG=${TAG:-_SBo}
  34. PKGTYPE=${PKGTYPE:-tgz}
  35. PRGSRC=complete.zip
  36. PRGUNZIPPED=ldraw
  37. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  38. # the name of the created package would be, and then exit. This information
  39. # could be useful to other scripts.
  40. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  41. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  42. exit 0
  43. fi
  44. TMP=${TMP:-/tmp/SBo}
  45. PKG=$TMP/package-$PRGNAM
  46. OUTPUT=${OUTPUT:-/tmp}
  47. set -e
  48. rm -rf $PKG
  49. mkdir -p $TMP $PKG $OUTPUT
  50. cd $TMP
  51. rm -rf $PRGUNZIPPED
  52. unzip $CWD/$PRGSRC
  53. cd $PRGUNZIPPED
  54. # Check if we have the right version of the "source"
  55. srcver=$(echo "20$(basename $(ls -1 models/Note*.txt | tail -n1) .txt | cut -b5-8)")
  56. if [ "$srcver" -ne "$VERSION" ] ; then
  57. echo "Version of source ($srcver) does not match VERSION variable ($VERSION)"
  58. exit 1
  59. fi
  60. chown -R root:root .
  61. find . -type d -exec chmod 0755 {} \;
  62. find . -type f -exec chmod 0644 {} \;
  63. # Copy the 'read-only' data to the package
  64. mkdir -p $PKG/usr/share/LDRAW
  65. cp -a \
  66. *.ldr p parts \
  67. $PKG/usr/share/LDRAW/
  68. # Create / Copy the 'writable' sub-directories to /var/lib/ldraw/ and correct permissions
  69. mkdir -p $PKG/var/lib/ldraw/{models,bitmap}
  70. cp -a \
  71. models \
  72. $PKG/var/lib/ldraw/
  73. chgrp -R users $PKG/var/lib/ldraw/{models,bitmap}
  74. chmod 0775 $PKG/var/lib/ldraw/{models,bitmap}
  75. chmod 0664 $PKG/var/lib/ldraw/models/*
  76. # Create symlinks
  77. cd $PKG/usr/share/LDRAW
  78. ln -s ../../../var/lib/ldraw/bitmap BITMAP ; ln -s BITMAP bitmap
  79. ln -s ../../../var/lib/ldraw/models MODELS ; ln -s MODELS models
  80. ln -s parts PARTS
  81. ln -s s PARTS/S
  82. ln -s p P
  83. cd -
  84. # Move documentation
  85. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/
  86. cp -a \
  87. *.txt \
  88. $PKG/usr/doc/$PRGNAM-$VERSION/
  89. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  90. # unzip & make 'mklist'
  91. # (this is a one-time executable, that won't be installed,
  92. # so we don't worry about CFLAGS)
  93. unzip -o mklist1_6.zip
  94. sed -i 's/_MAX_PATH/MAX_PATH/' mklist.c
  95. sed -i 's/shortpath)/shortpath))/' mklist.c
  96. make
  97. # Run 'mklist' to generate "parts.lst"
  98. cd $PKG/usr/share/LDRAW
  99. $TMP/$PRGUNZIPPED/mklist -d -f
  100. cd -
  101. mkdir -p $PKG/install
  102. cat $CWD/slack-desc > $PKG/install/slack-desc
  103. cd $PKG
  104. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE