summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c09d09c0205e9405c6d37cc165a8e3f6a35d463c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Maintainer: Fredrick R. Brennan <copypaste@kittens.ph>
_pkgname=overdrive-m4b
pkgbase=$_pkgname-git
pkgname=$pkgbase
pkgver=1.0.0.r4.g80242f4
pkgrel=2
pkgdesc='A dirty script to convert OverDrive audiobooks to a single `.m4b` file. According to its author: use at your peril.'
arch=("any")
url="https://github.com/pflouret/$_pkgname"
license=('Apache')
checkdepends=(ruby-rspec)
depends=(ffmpeg grep id3lib libfdk-aac libmp4v2 ruby ruby-id3tag ruby-nokogiri xidel)
makedepends=(git)
source=("git+https://github.com/pflouret/$_pkgname.git")
provides=($_pkgname)
conflicts=($_pkgname)
b2sums=('SKIP')

# Most of this file comes from https://wiki.archlinux.org/title/Ruby_package_guidelines

pkgver() {
  cd "${_pkgname}"
  git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd "${_pkgname}"

  # update gemspec/Gemfile to allow newer version of the dependencies
  sed --in-place --regexp-extended 's|~>|>=|g' "${_pkgname}.gemspec"
}

build() {
  cd "${_pkgname}"

  local _gemdir="$(gem env gemdir)"

  gem build "${_pkgname}.gemspec"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/${_gemdir}" \
    --bindir "tmp_install/usr/bin" \
    "${_pkgname}-${pkgver%%.r*}.gem"

  # remove unrepreducible files
  rm --force --recursive --verbose \
    "tmp_install/${_gemdir}/cache/" \
    "tmp_install/${_gemdir}/gems/${_pkgname}-${pkgver}/vendor/" \
    "tmp_install/${_gemdir}/doc/${_pkgname}-${pkgver}/ri/ext/"

  find "tmp_install/${_gemdir}/extensions/" \
    -type f \
    \( \
      -iname "mkmf.log" -o \
      -iname "gem_make.out" \
    \) \
    -delete
}

check() {
  GEM_HOME="tmp_install/${_gemdir}" rspec
}

package() {
  cd "${_pkgname}"

  cp --archive --verbose tmp_install/* "${pkgdir}"

  install --verbose -D --mode=0644 LICENSE --target-directory "${pkgdir}/usr/share/licenses/${pkgname}"
  install --verbose -D --mode=0644 *.md --target-directory "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: syntax=bash