summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: bef62032a7ee37e2c975983117e2725f1f573c58 (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
# Maintainer: pragerabez

pkgname=mbed-studio-bin
_archivename=MbedStudio
_binname=${pkgname%%-bin}
DOMAIN="https://studio.mbed.com"
INSTALLER_PATH="/installers/latest/linux/MbedStudio.sh"
pkgver=1.4.6
pkgrel=17
pkgdesc="free IDE and toolchain for Mbed OS 5 application and library development"
arch=('x86_64')
url="https://os.mbed.com/studio/"
license=('COMMERCIAL')
depends=('ncurses' 'gnome-keyring' 'fuse2' 'alsa-lib' 'nss')
provides=('mbed-studio')
options=(!strip)
source=("$_archivename-official-installer.sh::$DOMAIN$INSTALLER_PATH"
"$pkgname.sh"
"$pkgname.install")

prepare() {
    cd "$srcdir"
    # find archive path
    ARCHIVE_PATH=$(grep -oP '(?<=ARCHIVE_PATH=).*' $_archivename-official-installer.sh)

    # download and extract archive
    msg2 "Downloading... $DOMAIN$ARCHIVE_PATH"
    curl -L -o "$_archivename.tar.gz" "$DOMAIN$ARCHIVE_PATH"
    msg2 "Extracting..."
    tar -xzf "$_archivename.tar.gz" && rm "$_archivename.tar.gz"
}

package() {
	cd "$srcdir"
	msg2 "Patching..."

	INSTALL_PATH="$pkgdir/usr/share/$pkgname"
    TOOLS_PATH="$INSTALL_PATH/mbed-studio-tools"
    LAUNCHER_PATH="$pkgdir/usr/share/applications"
    ICON_PATH_PREFIX="$pkgdir/usr/share/icons/hicolor"
    BIN_PATH="$INSTALL_PATH/bin"
    #EXEC_PATH contain a modified bash file checks if mbed-studio-tools exist in user .config before running mbed-studio else symlink
    EXEC_PATH="$pkgdir/usr/bin/$pkgname"

    # move the tools where needed
    mkdir -p "$INSTALL_PATH"
    cp -r "$_archivename/$_binname-tools" "$INSTALL_PATH"
    chmod -R 755 "$TOOLS_PATH/ac6"

    # copy tools.json where needed
    install -D "$_archivename/tools.json" "$TOOLS_PATH/tools.json"

    # move the application where needed
    install -D "$_archivename/$_binname" "$INSTALL_PATH/$_binname"

    # move bash runfile (custom) where needed
    install -D "$pkgname.sh" "$pkgdir/usr/bin/$pkgname"

    # add icons
    ICO_SIZES=(16 24 32 48 64 96 128 256 512 1024)
    for SIZE in "${ICO_SIZES[@]}"
    do
        ICON_PATH="$ICON_PATH_PREFIX/${SIZE}x${SIZE}/apps"
        mkdir -p "$ICON_PATH"
        FILENAME1="icons/icon_${SIZE}x${SIZE}.png"
        if [ -f $_archivename/$FILENAME1 ]; then
            install -D "$_archivename/$FILENAME1" "$ICON_PATH/$_binname.png"
        else
            FILENAME2="icons/icon_${SIZE}.png"
            if [ -f $_archivename/$FILENAME2 ]; then
            install -D "$_archivename/$FILENAME2" "$ICON_PATH/$_binname.png"
            fi
        fi
    done

    # create a launcher
    ICON_PATH_PREFIX="/usr/share/icons/hicolor"
    ICON_PATH="$ICON_PATH_PREFIX/256x256/apps/$_binname.png"
    install -d "$LAUNCHER_PATH"
    sed -e "s,\\\$bin_path\\\$,/usr/bin/$pkgname,g" -e "s,\\\$icon_path\\\$,${ICON_PATH},g" $_archivename/$_binname.desktop.template > "$LAUNCHER_PATH/$_binname.desktop"

    # udev rules (https://github.com/mbedmicro/pyOCD/tree/master/udev)
    # copy udev rules
    mkdir -p "$pkgdir/etc/udev/rules.d/"
    cp $_archivename/pyocd-udev-rules/*.rules "$pkgdir/etc/udev/rules.d/"
	chmod +x "$INSTALL_PATH/$_binname"
	chmod +x "$EXEC_PATH"
}

md5sums=('SKIP'
         'ba5f16b0d7eeef5b124cd68078a38672'
         '7cf4ae1f6777f0c610125a59b0fefca6')