timetrap.SlackBuild 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/bash
  2. # Slackware build script for timetrap
  3. # Copyright 2013-2022 Jostein Berntsen <jvbernts@online.no>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. # 20220303 bkw: Modified by SlackBuilds.org, BUILD=2:
  23. # - fix REQUIRES: sequel, not sequel4.
  24. # - get rid of hardcoded dependency versions in the gemspec.
  25. # - remove redundant t and dev_t scripts from /usr/bin.
  26. # 20220520 bkw: Modified by Jostein Berntsen, BUILD=3:
  27. # - fix: Update removal line so the executable t is retained
  28. # - Added variable to check for Ruby version and sed line to ensure compatibility
  29. # for newer Ruby versions than 3.0.0
  30. cd $(dirname $0) ; CWD=$(pwd)
  31. PRGNAM=timetrap
  32. VERSION=${VERSION:-1.15.2}
  33. BUILD=${BUILD:-3}
  34. TAG=${TAG:-_SBo}
  35. PKGTYPE=${PKGTYPE:-tgz}
  36. if [ -z "$ARCH" ]; then
  37. case "$( uname -m )" in
  38. i?86) ARCH=i586 ;;
  39. arm*) ARCH=arm ;;
  40. *) ARCH=$( uname -m ) ;;
  41. esac
  42. fi
  43. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  44. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  45. exit 0
  46. fi
  47. TMP=${TMP:-/tmp/SBo}
  48. PKG=$TMP/package-$PRGNAM
  49. OUTPUT=${OUTPUT:-/tmp}
  50. # 20220303 bkw: no SLKCFLAGS needed: there's no compiled C/C++ code.
  51. # No LIBDIRSUFFIX needed, 'gem install' knows the right path to use.
  52. # The only reason this isn't noarch is that the install path includes
  53. # lib or lib64 (like pure python modules do).
  54. set -e
  55. rm -rf $PKG
  56. mkdir -p $TMP/$PRGNAM-$VERSION $PKG $OUTPUT
  57. cd $TMP/$PRGNAM-$VERSION
  58. DESTDIR=$( ruby -r rbconfig -e '
  59. include RbConfig
  60. printf("%s/%s/gems/%s\n",
  61. CONFIG["libdir"],
  62. CONFIG["RUBY_INSTALL_NAME"],
  63. CONFIG["ruby_version"]
  64. )
  65. ')
  66. gem specification $CWD/$PRGNAM-$VERSION.gem | \
  67. ruby -r yaml -r rbconfig -e '
  68. c = RbConfig::CONFIG
  69. path = sprintf("%s/%s/gems/%s",
  70. c["libdir"],
  71. c["RUBY_INSTALL_NAME"],
  72. c["ruby_version"])
  73. sys_gemspecs = Dir.glob(path + "/specifications/**/*.gemspec").map {|g| gs = Gem::Specification.load(g); gs.name }
  74. obj = Gem::Specification.from_yaml($stdin)
  75. obj.dependencies.each {|dep|
  76. if not(dep.type == :runtime)
  77. next
  78. end
  79. if not(sys_gemspecs.include?(dep.name))
  80. $stderr.write("WARNING: #{dep.name} gem not found\n")
  81. sleep 0.5
  82. end
  83. }'
  84. gem install \
  85. --local \
  86. --no-update-sources \
  87. --ignore-dependencies \
  88. --backtrace \
  89. --install-dir $PKG/$DESTDIR \
  90. --bindir $PKG/usr/bin \
  91. $CWD/$PRGNAM-$VERSION.gem
  92. # 20220303 bkw: don't need these extra almost-identical scripts in /usr/bin:
  93. rm -f $PKG/usr/bin/{dev_t}
  94. # 20220303 bkw: the version numbers of the deps are hardcoded in the
  95. # .gemspec. Any time someone updates one of them, it would break
  96. # timetrap. So get rid of the version numbers. This may lead to
  97. # breakage at some point, but right now it fixes timetrap complaining
  98. # that it can't find its sequel dep at runtime (it wants 5.30.0,
  99. # we actually have 5.42.0, and it seems to work fine). This diff is
  100. # unusual as it patches $PKG after the build, because picking apart
  101. # the .gem file, patching it, and reassembling it (and fixing the
  102. # checksum) is more work than I care to do.
  103. # Note that the patch has hardcoded lib64 paths, so we sed it.
  104. cd $PKG
  105. cp $CWD/remove_hardcoded_versions.diff tmp.diff
  106. [ "$ARCH" = "x86_64" ] || sed -i 's,usr/lib64,usr/lib,g' tmp.diff
  107. RUBYVERSION=$(ls /usr/lib*/ruby/gems)
  108. sed -i "s/gems\/3\.[0-9]\.[0-9]\//gems\/$RUBYVERSION\//g" *.diff
  109. patch -p1 < tmp.diff
  110. rm -f tmp.diff
  111. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  112. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  113. mkdir -p $PKG/install
  114. cat $CWD/slack-desc > $PKG/install/slack-desc
  115. cd $PKG
  116. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE