summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d65debc8cc95d3e7966df6fad296286d808254ed (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="502i"
pkgver="5.02i"
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=("08067be8410e32f346a8f0b948ff8e43") #underscored because real md5sums must match source array length, ours is missing package URL
_md5sums_32=("0d555f431bcd4a27cb329c96758e81f9")


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
}