summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 76d61bf4d66c8b75e0c4aa6ff91b607b874f7d99 (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Maintainer: taotieren <admin@taotieren.com>

pkgbase=mcu-jlink-pack
pkgname=({airmcu,mcu,hkmicrochip,holtek,nationstech,py32}-jlink-pack)
pkgver=r8.94c90db
pkgrel=3
epoch=
arch=('any')
url="https://github.com/taotieren/mcu-jlink-pack"
license=('custom' 'Commercial' 'MIT')
groups=()
depends=(
    bash
    "jlink-software-and-documentation>=7.62")
makedepends=(git)
checkdepends=()
optdepends=()
conflicts=()
replaces=()
backup=()
options=('!strip' '!debug' '!lto')
changelog=
source=("${pkgbase}::git+${url}.git"
    "AirMCU-Jlink::git+https://github.com/Air-duino/AirMCU-Jlink.git"
    "airmcu-jlink-pack.install"
    "hkmicrochip-jlink-pack.install"
    "holtek-jlink-pack.install"
    "nationstech-jlink-pack.install"
    "py32-jlink-pack.install")
noextract=()
sha256sums=('SKIP'
            'SKIP'
            '42a0931b0b5f6c84655fe6aace1902abde56b7fee42b2147ee3364789d6389d2'
            'a526e928d9c5f57a05e7f938818c66504409809b9614c5450bc7c15c8b12871a'
            '5453ba72d95c28241b5e8af002ce601ee6cf7749023256598457df219659326a'
            '2281486bc2005550ff062e9788aff466d6b7d438551d97202c15579b7f344630'
            '9e580eb5f854343c2f2d9c1a289911b4f5d275d841d5bf91d966f1716e9ec487')

prepare() {
    git -C "${srcdir}/${pkgbase}" clean -dfx
    cd "${srcdir}/${pkgbase}"
    git submodule init
    git config submodule.AirMCU-Jlink.url "$srcdir/AirMCU-Jlink"
    git -c protocol.file.allow=always submodule update
}

pkgver() {
    cd "${srcdir}/${pkgbase}"
    (
        set -o pipefail
        git describe --long --tag --abbrev=7 2>/dev/null | sed 's/^v//g;s/\([^-]*-g\)/r\1/;s/-/./g' ||
            printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
    )
}

package_mcu-jlink-pack() {
    pkgdesc="JLINK Pack 支持包支持 MCU 全系列芯片,在 SEGGER JLink 7.62 及以上版本下的安装。"
    provides=('MCU_JLINK_pack')
    depends=(
        airmcu-jlink-pack
        hkmicrochip-jlink-pack
        holtek-jlink-pack
        nationstech-jlink-pack
        py32-jlink-pack)
}

package_airmcu-jlink-pack() {
    pkgdesc="JLINK Pack 支持包支持合宙(AirMCU) MCU 全系列芯片,在 SEGGER JLink 7.62 及以上版本下的安装。"
    provides=('AirMCU_JLINK_pack')
    install=${pkgname}.install

    _name=AirMCU
    _aname=AirM2M
    _path=$_name/$_aname

    install -dm0755 "${pkgdir}/opt/$_path/"

    mv -f "${srcdir}"/${pkgbase}/AirMCU-Jlink/$_aname/FLM/AIR32F10X_1024.FLM "${srcdir}"/${pkgbase}/AirMCU-Jlink/$_aname/FLM/Air32F10X_1024.FLM

    cp -rv "${srcdir}"/${pkgbase}/AirMCU-Jlink/$_aname/* "${pkgdir}/opt/$_path/"

    find "${pkgdir}/opt/$_path/" -type f -exec chmod 644 "{}" \;
    find "${pkgdir}/opt/$_path/" -type d -exec chmod 755 "{}" \;

    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/${pkgname}" <<EOF
#!/bin/bash

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices ] ; then
    mkdir -p \$HOME/.config/SEGGER/JLinkDevices || exit 1
fi

if [ -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    rm -rf \$HOME/.config/SEGGER/JLinkDevices/$_aname || exit 1
fi

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    cp -r /opt/$_path \$HOME/.config/SEGGER/JLinkDevices/ || exit 1
fi
EOF
}

package_hkmicrochip-jlink-pack() {
    pkgdesc="JLINK Pack 支持包支持航顺(HK32) MCU 全系列芯片,在 SEGGER JLink 7.62 及以上版本下的安装。"
    provides=('HK32_JLINK_pack')
    install=${pkgname}.install

    _name=hkmicrochip
    _aname=hk32
    _path=$_name/$_aname

    install -dm0755 "${pkgdir}/opt/$_path/"

    cp -rv "${srcdir}"/${pkgbase}/HKMicroChip/* "${pkgdir}/opt/$_path/"
    #     mv "${pkgdir}"/opt/$_path/Devices/HKMicrochip "${pkgdir}"/opt/$_path/HKMicrochip
    #     rm -rf "${pkgdir}"/opt/$_path/Devices
    #
    #     sed "s|Devices/||g" -i "${pkgdir}/opt/$_path/$_aname.xml"

    find "${pkgdir}/opt/$_path/" -type f -exec chmod 644 "{}" \;
    find "${pkgdir}/opt/$_path/" -type d -exec chmod 755 "{}" \;

    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/${pkgname}" <<EOF
#!/bin/bash

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices ] ; then
    mkdir -p \$HOME/.config/SEGGER/JLinkDevices || exit 1
fi

if [ -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    rm -rf \$HOME/.config/SEGGER/JLinkDevices/$_aname || exit 1
fi

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    cp -r /opt/$_path \$HOME/.config/SEGGER/JLinkDevices/ || exit 1
fi
EOF

}

package_holtek-jlink-pack() {
    pkgdesc="JLINK Pack 支持包支持合泰(HT32) MCU 全系列芯片,在 SEGGER JLink 7.62 及以上版本下的安装。"
    provides=('HK32_JLINK_pack')
    install=${pkgname}.install

    _name=holtek
    _aname=ht32
    _path=$_name/$_aname

    install -dm0755 "${pkgdir}/opt/$_path/"

    cp -rv "${srcdir}"/${pkgbase}/Holtek/* "${pkgdir}/opt/$_path/"

    sed "1i<DataBase>" -i "${pkgdir}/opt/$_path/$_aname.xml"
    echo "</DataBase>" >>"${pkgdir}/opt/$_path/$_aname.xml"

    find "${pkgdir}/opt/$_path/" -type f -exec chmod 644 "{}" \;
    find "${pkgdir}/opt/$_path/" -type d -exec chmod 755 "{}" \;

    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/${pkgname}" <<EOF
#!/bin/bash

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices ] ; then
    mkdir -p \$HOME/.config/SEGGER/JLinkDevices || exit 1
fi

if [ -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    rm -rf \$HOME/.config/SEGGER/JLinkDevices/$_aname || exit 1
fi

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    cp -r /opt/$_path \$HOME/.config/SEGGER/JLinkDevices/ || exit 1
fi
EOF
}

package_nationstech-jlink-pack() {
    pkgdesc="JLINK Pack 支持包支持 Nationstech (国民技术) 全系列芯片,在 SEGGER JLink 7.62 及以上版本下的安装。"
    provides=('Nationstech_JLINK_pack')
    install=${pkgname}.install

    _name=nationstech
    _aname=n32
    _path=$_name/$_aname

    install -dm0755 "${pkgdir}/opt/$_path/"

    cp -rv "${srcdir}"/${pkgbase}/Nationstech/* "${pkgdir}/opt/$_path/"

    rm -rf "${pkgdir}/opt/$_path/JLink*"

    find "${pkgdir}/opt/$_path/" -type f -exec chmod 644 "{}" \;
    find "${pkgdir}/opt/$_path/" -type d -exec chmod 755 "{}" \;

    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/${pkgname}" <<EOF
#!/bin/bash

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices ] ; then
    mkdir -p \$HOME/.config/SEGGER/JLinkDevices || exit 1
fi

if [ -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    rm -rf \$HOME/.config/SEGGER/JLinkDevices/$_aname || exit 1
fi

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    cp -r /opt/$_path \$HOME/.config/SEGGER/JLinkDevices/ || exit 1
fi
EOF
}

package_py32-jlink-pack() {
    pkgdesc="JLINK Pack 支持包支持 py32 (普冉半导体) 全系列芯片,在 SEGGER JLink 7.62 及以上版本下的安装。"
    provides=('PY32_JLINK_pack')
    install=${pkgname}.install

    _name=Puya
    _aname=py32
    _path=$_name/$_aname

    install -dm0755 "${pkgdir}/opt/$_path/"

    cp -rv "${srcdir}"/${pkgbase}/PY32_JFlash/* "${pkgdir}/opt/$_path/"

    rm -rf "${pkgdir}/opt/$_path/JLink*"

    find "${pkgdir}/opt/$_path/" -type f -exec chmod 644 "{}" \;
    find "${pkgdir}/opt/$_path/" -type d -exec chmod 755 "{}" \;

    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/${pkgname}" <<EOF
#!/bin/bash

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices ] ; then
    mkdir -p \$HOME/.config/SEGGER/JLinkDevices || exit 1
fi

if [ -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    rm -rf \$HOME/.config/SEGGER/JLinkDevices/$_aname || exit 1
fi

if [ ! -d "\$HOME"/.config/SEGGER/JLinkDevices/$_aname ] ; then
    cp -r /opt/$_path \$HOME/.config/SEGGER/JLinkDevices/ || exit 1
fi
EOF
}