summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f38ff2f85c3a23d2fd82a2576296e4a69cd52447 (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
# Maintainer: pzl <alsoelp@gmail.com>

pkgname=jlink
_pkgver="502k"
pkgver="5.02k"
pkgrel=1
pkgdesc="ARM Embedded debugger and flashing software from Segger"
arch=('i686' 'x86_64')
url="https://www.segger.com/jlink-software.html"
license=('custom') #https://www.segger.com/cms/admin/uploads/userfiles/file/J-Link/license_agreement.txt
depends=('glibc')
source=('udev_fix.patch') #fetching the pkg source requires a POST request, so we must do this in prepare()
md5sums=('8134047402c9ac6dc7c3bc24dfcf51b5')
_md5sums_64=("5bffdcfb62d4d29ea7aa80b6687a0d53") #underscored because real md5sums must match source array length, ours is missing package URL
_md5sums_32=("c1bbab7db30defc83b1344363178969b")


prepare() {
    cd "$srcdir"
    if [ "$CARCH" = "x86_64" ]; then
        _ARCH="64"
        _MD5="${_md5sums_64}"
    else
        _ARCH="32"
        _MD5="${_md5sums_32}"
    fi

    #fetch source
    wget -O "${pkgname}.tgz" --post-data="agree=1&confirm=yes" "https://www.segger.com/jlink-software.html?step=1&file=JLinkLinuxTGZ${_ARCH}_${_pkgver}"
    
    #verify
    if [ "$(md5sum "${pkgname}.tgz" | cut -d' ' -f1)" != "${_MD5}" ]; then
        echo "md5 source verification failed" >&2
        exit 1
    fi

    #extract
    tar -xzvf "${pkgname}.tgz"
}

build() {
    #remove `BUS!="usb"` from udev rules. BUS isn't valid anymore
    cd "${srcdir}"/JLink_Linux_V*
    patch -uN 99-jlink.rules ../udev_fix.patch
}

package() {
    cd "${srcdir}"/JLink_Linux_V*
    #documentation and licenses
    install -d "${pkgdir}/usr/share/doc/${pkgname}" "${pkgdir}/usr/lib" "${pkgdir}/usr/bin" "${pkgdir}/etc/udev/rules.d"
    install -Dm644 Doc/License.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -Dm644 Doc/*_JLink.pdf "${pkgdir}/usr/share/doc/${pkgname}/"
    cp -r Samples/JLink/*          "${pkgdir}/usr/share/doc/${pkgname}/"

    #binaries
    install -Dm755 JLink* "${pkgdir}/usr/bin/"

    #libraries and udev rules
    install -Dm644 99-jlink.rules                "${pkgdir}/etc/udev/rules.d/99-jlink.rules"
    install -Dm755 libjlinkarm.so.*.*            "${pkgdir}/usr/lib/"
    cd "${pkgdir}/usr/lib" && ln -s libjlinkarm.so.*.* libjlinkarm.so.5
}