summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 173e15fae36fb49f7356d9caf5320959a20a431d (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Maintainer: dreieck


# _check_legal() {
#   # We want to check for this _before_ downloading.
#   # But this has the disadvantage that this is asked at the beginning of a makepkg run, and again when starting the package-functions, and each time `.SRCINFO` is generated, and `namcap` also fails on this `PKGBUILD`.
#   # If anyone has an idea how to make it in a more clean way & that the question is only asked once, while still downloading the source via the 'source' array, please leave a comment!
#   local _legalcopy
#   msg2 "Please make sure you have obtained a legal copy of the game before continuing!"
#   read -e -p "Enter 'i have a legal copy of the riven original soundtrack' (without quotes) to continue, anything else to abort: " _legalcopy
#   if [ "${_legalcopy}x" != "i have a legal copy of the riven original soundtrack"x ]; then
#     error "No legal copy, aborting."
#     return 22
#   fi
# }
# _check_legal || exit "$?"

_pkgbase="riven-original-soundtrack"
pkgbase="${_pkgbase}"
pkgname=(
  "riven-original-soundtrack"
)
pkgdesc="Official Soundtrack of the game 'Riven: The Sequel to Myst'. Soundtrack of the original game."
groups=(
  'myst'
  'riven'
)
arch=('any')
url='http://www.robynmiller.net/music'
# url='https://www.discogs.com/release/1097332-Robyn-Miller-Riven-The-Soundtrack'
# url='https://archive.org/details/Nova_RivenOST_USA'
epoch="0"
pkgver='19980224' # Release date according to https://www.discogs.com/release/1097332-Robyn-Miller-Riven-The-Soundtrack
pkgrel=3
_newestoriginalver=20200101  # Assumed highest possible version number of 'riven-soundtrack' that is from the original game.
makedepends=(
  'ffmpeg'              # To convert the raw CD .bin files to opus.
  'ghostscript'         # To build the CD booklet PDF (build multi-page PDF).
  'imagemagick'         # To build the CD booklet PDF (resize images and convert to PDF).
  'ocrmypdf'            # To build the CD booklet PDF (add OCR data).
  'tesseract-data-eng'  # To build the CD booklet PDF (add OCR data).
)
options+=('emptydirs')

source=(
  'Robyn_Miller_-_Riven_-_The_Soundtrack.7z::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29.7z'
  # 'riven-soundtrack_-_cover.jpg::https://archive.org/download/Nova_RivenOST_USA/__ia_thumb.jpg'
  'riven-soundtrack_-_01.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/1.jpg'
  'riven-soundtrack_-_02.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/2.jpg'
  # 'riven-soundtrack_-_03.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/3.jpg'
  'riven-soundtrack_-_04.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/4.jpg'
  'riven-soundtrack_-_05.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/5.jpg'
  'riven-soundtrack_-_06a.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6a.jpg'
  'riven-soundtrack_-_06b.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6b.jpg'
  'riven-soundtrack_-_06c.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6c.jpg'
  'riven-soundtrack_-_06d.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6d.jpg'
  'riven-soundtrack_-_06e.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6e.jpg'
  'riven-soundtrack_-_06f.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6f.jpg'
  'riven-soundtrack_-_06g.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6g.jpg'
  'riven-soundtrack_-_06h.jpg::https://archive.org/download/Nova_RivenOST_USA/Riven%20-%20The%20Soundtrack%20%28USA%29/6h.jpg'
  'tracks.txt'
  'license-note.txt'
)

sha256sums=(
  'c2268e57d2431781cd3fde942cac54d2015014f4e53ea63d1395e4c8d2888159'
  # '8a7afda926b12a8f97435b51e88974b13e63b9e6dd8495e27a87ecf785a1b4b7'
  '790e1ab6383fcaad4a1b7eb9f1e866dce07fcee2006174244dd9f5bc503eb9fa'
  'e7ee5d43781f7f3699851792851adaed6e943358838318cf2974b1cb753d5851'
  # 'fc83c58111a54a8993dc55aecb0ed1b76441ded090a82dda96e99d674445c011'
  'a51bc788f64ccf40662633f35e47d690efb744ce3eeeffea0ae995044d131a13'
  'e8175556124b0ed6eca972fac33a6cf4c853cc146c4c1ccbda47951d3a6628fd'
  'e1f6faebe88fba254e714e8f164b53f3d4e77cdb6a0fdb805cef03401b5b387e'
  '035ee380d685ed1349b0f3cb0105bb927316fe6415ca5974928067f27958f676'
  'a3fabd6df4345e4a5afbb428d310278c6070c8ac0a8e6ae94c256d2d528537fc'
  '57eda9798780406f37bc4e4e52fb537675e8336f9e3323aaec4783ffada33f31'
  '01fe7d6b65347f31f970cdaa093b7750246fed4743cb59be56991a718bf1e45f'
  '40421ff731ce14d14c2449f6fdc747fe72c56bce33c21fd3a80a3058817d53b5'
  '44ef8066b277b033f3acbee494802df3f1b7010aec65fd594c4033750cd73d0c'
  '810f99659b802b05f1e103d5334b8de85b8a759144755bdcdfe63a9790cf110e'
  'badcd45b33c681bb6185d41a862590a19ef392b590fd3e2c16f7969656b79666'
  'f08b8880a05065200f6481e985f76f5e037b246c77da605b3090219486015435'
)


prepare() {
  cd "${srcdir}"

  if ! (pacman -Qqi 'riven-original-soundtrack' > /dev/null 2>&1 || pacman -Qqi "riven-soundtrack<=${_newestoriginalver}" > /dev/null 2>&1); then
    local _legalcopy
    msg2 "Please make sure you have obtained a legal copy of the soundtrack before continuing!"
    read -e -p "Enter 'i have a legal copy of the riven original soundtrack' (without quotes) to continue, anything else to abort and DELETE DOWNLOADED DATA: " _legalcopy
    if [ "${_legalcopy}x" != "i have a legal copy of the riven original soundtrack"x ]; then
      rm -fv "${SRCDEST}/${source[0]%%::*}"
      rm -Rfv "${srcdir}"/*
      error "No legal copy, aborting."
      return 22
    fi
  fi
}

build() {
  cd "${srcdir}"

  printf '%s\n' "Generating opus sound files ..."
  _composer="Robyn Miller"
  _album="Riven - The Soundtrack"
  _genre="Video Game Music"
  _date="1997"
  _outdir="build/`printf '%s' "${_composer}_-_${_album}" | tr -d \' | tr ' ' '_'`"
  mkdir -p "${_outdir}"
  for _trackno in `seq -w 01 20`; do
    _rawfile="Riven - The Soundtrack (USA) (Track ${_trackno}).bin"
    _title="`sed -n "${_trackno}"p 'tracks.txt'`"
    _outfile="`printf '%s' "${_trackno}_-_${_title}" | tr -d \' | tr ' ' '_'`.opus.webm"
    printf '%s\n' "  Track number ${_trackno}: '${_title}' ..."
    ffmpeg \
      -f s16le -ar 44.1k -ac 2 -i "${_rawfile}" \
      -vn \
      -c:a libopus -b:a 229376 -vbr on -compression_level 10 -frame_duration 60 -application audio \
      -metadata artist="${_composer}" -metadata composer="${_composer}" -metadata album="${_album}" -metadata track="${_trackno}" -metadata title="${_title}" -metadata genre="${_genre}" -metadata date="${_date}" \
      -y "${_outdir}/${_outfile}"
  done

  printf '%s\n' "Generating album art picture ..."
  convert riven-soundtrack_-_01.jpg -resize 1400x1400 -quality 85 "${_outdir}/cover.jpg"
  # convert riven-soundtrack_-_01.jpg -resize 128x128 -quality 65 "${_outdir}/cover.small.jpg"

  printf '%s\n' "Generating CD booklet PDF ..."
  ## Separating re-encoding and combination in order to conserve system memory. Doing all in a single `convert` run leads to out of memory kill on a 8 GiB RAM machine.
  for _jpg in riven-soundtrack_-_04.jpg riven-soundtrack_-_02.jpg riven-soundtrack_-_06*.jpg; do
    printf '%s\n'   "  Converting '$(basename "${_jpg}" '.jpg')' from JPEG to PDF ..."
    convert \
      "${_jpg}" \
      -resize 8192x2048 -compress jpeg -quality 90 \
      "$(basename "${_jpg}" '.jpg').pdf"
  done
  printf '%s\n'   "  Combining to multipage PDF ..."
  gs \
    -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite \
    -sOutputFile="${_outdir}/Robyn_Miller_-_Riven_-_The_Soundtrack.CD-Booklet.pdf" \
    riven-soundtrack_-_04.pdf riven-soundtrack_-_02.pdf riven-soundtrack_-_06*.pdf
  printf '%s\n'   "  Adding OCR information ..."
  ocrmypdf \
    -l eng --output-type pdfa-3 -O 1 \
    --title "Riven - The Soundtrack" --author "Robyn Miller" --subject "CD booklet" --keywords "Video Game Music" \
    "${_outdir}/Robyn_Miller_-_Riven_-_The_Soundtrack.CD-Booklet.pdf" "${_outdir}/Robyn_Miller_-_Riven_-_The_Soundtrack.CD-Booklet.pdf"

  cp "tracks.txt" "${_outdir}/tracklist.txt"
  printf '%s\n' "${url}" > "${_outdir}/website.url"
}

package_riven-original-soundtrack() {
  pkgdesc="Official Soundtrack of the game 'Riven: The Sequel to Myst'."
  url='http://www.robynmiller.net/music'
  license=('LicenseRef-proprietary')
  optdepends=(
    'riven: To play the game.'
    "riven-makingof: Movie 'The Making of Riven'."
  )
  provides=("riven-soundtrack=${pkgver}")
  conflicts=("riven-soundtrack<=${_newestoriginalver}")
  replaces=("riven-soundtrack<=${_newestoriginalver}")

  cd "${srcdir}"

  _destdir="${pkgdir}/usr/share/music"
  install -v -d -m755 "${_destdir}"
  cp -rv "build"/* "${_destdir}/"

  install -v -D -m644 "${srcdir}/license-note.txt" "${pkgdir}/usr/share/licenses/${pkgname}/Riven_-_The_Soundtrack.license-note.txt"
}