g810-led.SlackBuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. # Copyright 2020 Patrick Volkerding, Sebeka, Minnesota, USA
  3. # All rights reserved.
  4. #
  5. # Redistribution and use of this script, with or without modification, is
  6. # permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of this script must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. #
  11. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  12. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  14. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  17. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  18. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  19. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  20. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. cd $(dirname $0) ; CWD=$(pwd)
  22. PRGNAM=g810-led
  23. VERSION=${VERSION:-0.4.2}
  24. BUILD=${BUILD:-1}
  25. TAG=${TAG:-_SBo}
  26. PKGTYPE=${PKGTYPE:-tgz}
  27. # Set this to anything other than "NO" to install the shared library and
  28. # development files. I'm not aware of anything that can make use of these
  29. # at this time. Also, the library will not compile on Slackware 14.2, though
  30. # it does compile on -current.
  31. DEVEL=${DEVEL:-NO}
  32. if [ -z "$ARCH" ]; then
  33. case "$( uname -m )" in
  34. i?86) ARCH=i586 ;;
  35. arm*) ARCH=arm ;;
  36. *) ARCH=$( uname -m ) ;;
  37. esac
  38. fi
  39. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  40. # the name of the created package would be, and then exit. This information
  41. # could be useful to other scripts.
  42. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  43. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  44. exit 0
  45. fi
  46. TMP=${TMP:-/tmp/SBo}
  47. PKG=$TMP/package-$PRGNAM
  48. OUTPUT=${OUTPUT:-/tmp}
  49. set -e
  50. if [ "$ARCH" = "i586" ]; then
  51. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  52. LIBDIRSUFFIX=""
  53. elif [ "$ARCH" = "i686" ]; then
  54. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  55. LIBDIRSUFFIX=""
  56. elif [ "$ARCH" = "x86_64" ]; then
  57. SLKCFLAGS="-O2 -fPIC"
  58. LIBDIRSUFFIX="64"
  59. else
  60. SLKCFLAGS="-O2"
  61. LIBDIRSUFFIX=""
  62. fi
  63. rm -rf $PKG
  64. mkdir -p $TMP $PKG $OUTPUT
  65. cd $TMP
  66. rm -rf $PRGNAM-$VERSION
  67. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  68. cd $PRGNAM-$VERSION
  69. chown -R root:root .
  70. find -L . \
  71. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  72. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  73. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  74. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  75. # Patch the following issues with the makefile:
  76. # - errors when systemd is not present
  77. # - $(DESTDIR) missing in a few places
  78. # - create relative, not absolute symlinks
  79. # - create and install the shared library with a proper soname
  80. # - don't install the udev rules
  81. patch -p1 < $CWD/g810-led.makefile.patch
  82. # Fix libdir:
  83. sed -i "s|libdir?=\$(PREFIX)/lib|libdir?=\$(PREFIX)/lib${LIBDIRSUFFIX}|g" makefile
  84. make bin LIB=libusb
  85. make install DESTDIR=$PKG
  86. if [ ! "$DEVEL" = "NO" ]; then
  87. make lib LIB=libusb
  88. make install-lib DESTDIR=$PKG
  89. make install-dev DESTDIR=$PKG
  90. # Fix permissions on shared library:
  91. chmod 755 $PKG/usr/lib${LIBDIRSUFFIX}/libg810-led.so.*
  92. fi
  93. # Strip binaries:
  94. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  95. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  96. # Don't clobber an existing configuration:
  97. mv $PKG/etc/g810-led/profile $PKG/etc/g810-led/profile.new
  98. mv $PKG/etc/g810-led/reboot $PKG/etc/g810-led/reboot.new
  99. # Install the udev rules manually, filtering out the part that seems broken:
  100. mkdir -p $PKG/lib/udev/rules.d
  101. cat udev/g810-led.rules | grep -v SUBSYSTEMS > $PKG/lib/udev/rules.d/g810-led.rules
  102. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  103. cp -a \
  104. CONTRIBUTING* CONTRIBUTORS* INSTALL* LICENSE* PROFILES* README* \
  105. $PKG/usr/doc/$PRGNAM-$VERSION/
  106. cat $CWD/g810-led.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/g810-led.SlackBuild
  107. mkdir -p $PKG/install
  108. cat $CWD/slack-desc > $PKG/install/slack-desc
  109. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  110. cd $PKG
  111. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE