lv2-bundles-svn pkgbuild

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
79
80
81
82
83
84
85
86
87
88
89
90
91
# Maintainer : SpepS <dreamspepser at yahoo dot it>
# Contributor: Bernardo Barros <bernardobarros@gmail.com>
# Contributor: Ray Rashif <schivmeister@gmail.com>

pkgname=lv2-bundles-svn
_pkg="${pkgname%-svn}"
pkgver=292
pkgrel=1
pkgdesc="The LV2 plugin standard for audio systems, and all the extensions and scripts from <http://lv2plug.in/>"
arch=("i686" "x86_64")
url="http://lv2plug.in/"
depends=("glibc")
makedepends=("subversion")

_svntrunk="${url}/repo/trunk"
_svnmod="$_pkg"

build() {
  cd "$srcdir"

  if [[ -d "${_svnmod}/.svn" ]]; then
    (cd "$_svnmod" && svn up -r "$pkgver")
  else
    svn co "$_svntrunk" --config-dir ./ -r "$pkgver" "$_svnmod"
  fi

  msg "SVN checkout done or server timeout"
  msg "Starting build..."

  rm -rf "${srcdir}/${_svnmod}-build"
  cp -a "${srcdir}/${_svnmod}" "${srcdir}/${_svnmod}-build"
  cd "${srcdir}/${_svnmod}-build"

  #
  # BUILD
  #

  python2 ./waf configure --prefix=/usr --mandir=/usr/share/man
  python2 ./waf build
}

package() {
  cd "${srcdir}/${_svnmod}-build"

  python2 ./waf install --destdir="$pkgdir"

  unset provides conflicts _i
  unset _licenses; declare -A _licenses
  while IFS= read -r -d $'\0' line; do
    local _ns=$(grep "^<http" "$line" | sed "s|<http://\(.*\)>|\1|")
    local _name="${_ns/*\/}"
    local _path="${pkgdir}/usr/include/lv2/${_ns%/*}"
    local _infofile="$(sed -n 's/^\s*rdfs:seeAlso\s*<\(.*\)>\s*.$/\1/p' "$line")"
    local _infopath="${pkgdir}/usr/lib/lv2/${_name}.lv2/${_infofile}"
    local _version="$(sed -n 's/^\s*doap:revision\s*"\([.0-9]*\)"\s*;$/\1/p' "$_infopath")"
    local _license="$(sed -n 's|^\s*doap:license\s*<\([^/]*/\)*\([^/]*\)/\?>\s*;$|\2|p' "$_infopath" | sed 's|-\?license-\?||')"
    local _bundlename
    # generate the bundle name
    if [[ "$_name" =~ lv2* ]]; then
      _bundlename="$_name"
    else
      _bundlename="lv2-${_name}"
    fi
    # generate the provides and conflicts directives
    conflicts[_i]="$_bundlename"
    if [[ -n "$_version" ]]; then
      provides[_i++]="${_bundlename}=${_version}"
    else
      provides[_i++]="$_bundlename"
    fi
    # generate headers - replace lv2config (FS#23514)
    install -m755 -d "$_path"
    msg "${_path}/${_name} => /usr/lib/lv2/${_name}.lv2"
    ln -s "/usr/lib/lv2/${_name}.lv2" "${_path}/${_name}"
    # record individualized licenses and generate license files
    case "${_license,,}" in
      "bsd"|"mit"|"isc")
        [[ ! -d "${pkgdir}/usr/share/licenses/${_pkg}" ]] && install -m755 -d "${pkgdir}/usr/share/licenses/${_pkg}"
        install -m644 -D <(awk '/^#/ && !i {print; next} {i=1}' "$_infopath") "${pkgdir}/usr/share/licenses/${_pkg}/LICENSE-${_name}"
        ;;
    esac
    if [[ -n "$_license" ]]; then
      ((_licenses["${_license^^}"]++)) || true
    fi
  done < <(find "${pkgdir}/usr/lib/lv2/" -type f -name "manifest.ttl" -print0)

  # set the license directive
  license=( "${!_licenses[@]}"  )
}

# vim:set ts=2 sw=2 et: