summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4bf709596d783bd313ba2f5501b1c22e9b9401ea (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
# Maintainer: John Beard <john.j.beard@gmail.com>
pkgname=goldendict-cc-cedict-content
pkgver=1.0_r20200514
pkgrel=1
pkgdesc="CC-CEDICT Chinese-English Dictionary for Goldendict"
arch=("any")
url="https://www.mdbg.net/chinese/dictionary?page=cedict"
license=("custom:cc-by-sa-4.0" "custom")
install=$pkgname.install
optdepends=(
"goldendict: for using this dictionary"
"goldendict-qt5-git: for using this dictionary"
)
makedepends=(
"pyglossary"
)
source=("cc-cedict.png"
"LICENSE"
"https://www.mdbg.net/chinese/export/cedict/cedict_1_0_ts_utf-8_mdbg.txt.gz")
md5sums=('729e16b892fb38a6d1c5853330191e93'
         '747cb41a7c6ddb22a508164f768dae2a'
         'SKIP')

prepare() {

    cd "${srcdir}"

    extracted="cedict.txt"

    gzip -d -c cedict*.txt.gz > ${extracted}
}

pkgver() {

    cd "${srcdir}"

    version=$(grep -m 100 '#! version' ${extracted} | cut -d'=' -f2 | tr -d '\r\n')
    subversion=$(grep -m 100 '#! subversion' ${extracted} | cut -d= -f2 | tr -d '\r\n')
    datecode=$(grep -m 100 '#! date' ${extracted} | cut -d= -f2 | cut -dT -f1 | tr -d '\r\n-')

    verstr="${version}.${subversion}_r${datecode}"

    echo -n "${verstr}"
}

build() {

  cd "${srcdir}"

  # convert to Stardict format
  pyglossary cedict.txt cc-cedict.ifo\
    --read-format=CC-CEDICT --write-format=Stardict

  # update the bookname: this is what GoldenDict will display as the dictionary name
  sed -i 's/bookname=.*/bookname=CC-CEDICT/' cc-cedict.ifo

  # the .ifo version field if the Stardict format version, _not_ the dictionary version

  # zip the dict file to save installation space
  # gzip -c cc-cedict.dict > cc-cedict.dict.dz
}



package() {
  TARGET="/usr/share/goldendict"
  contentdir="${pkgdir}${TARGET}/content/cc-cedict"

  install -dm 755 ${contentdir}

  install -Dm 644 ${srcdir}/cc-cedict.{syn,ifo,dict,idx} ${contentdir}
  install -Dm 644 cc-cedict.png ${contentdir}

  install -D -m644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
}