summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5004095e3bfaaffb53c463cc46667ee7ea02bb0e (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
# Maintainer: Gleb Liutsko <gleb@liutsko.ru>

pkgname=sqltoolsservice
pkgver=4.3.0.3
pkgrel=1
pkgdesc='SQL Tools API service that provides SQL Server data management capabilities.'
url='https://github.com/microsoft/sqltoolsservice'
license=('MIT')

arch=('any')
depends=('dotnet-runtime')
makedepends=('dotnet-sdk')

source=("https://github.com/microsoft/${pkgname}/archive/refs/tags/$pkgver.tar.gz")
sha256sums=('2c19b9d307decbe0e8d5dfab9d60e893026ecd9377e560958690aed87805bbf5')

fixLocaleName() {
    oldName=$1
    newName=$2

    grep -il $oldName -R . | xargs -I FILE sed -i -e "s/$oldName/$newName/gI" FILE

    find . -iname "*$oldName*" | while read filename; do
        newFilename=$(sed "s/$oldName/$newName/gI" <<< $filename)
        if [ "$newFilename" != "$filename" ]; then
            mv -v "$filename" "$newFilename"
        fi
    done

    mkdir -v -p "bin/"{Debug,Release}"/net6.0/$newName"
}

prepare() {
    cd "$pkgname-$pkgver"

    # Fix case localization files
    #
    # https://github.com/r-k-b/sqltoolsservice/commit/1a949aff0e5bc28dd8b7200cf806c2812b1f7d86
    # https://github.com/microsoft/sqltoolsservice/issues/886
    # Thanks https://github.com/r-k-b
    fixLocaleName pt-br pt-BR
    fixLocaleName zh-hans zh-Hans
    fixLocaleName zh-hant zh-Hant

    # Fix version dotnet
    newGlobal=$(jq ".sdk.version = \"$(cd /; dotnet --version)\"" global.json)
    echo $newGlobal > global.json
}

build() {
    cd "$pkgname-$pkgver"

    dotnet publish src/Microsoft.SqlTools.ServiceLayer -c Release -f net6.0 -r linux-x64 --no-self-contained /p:DebugType=None /p:DebugSymbols=false -o ../publish
}

package() {
    mkdir -p "$pkgdir/usr/lib/"

    cp -r publish "$pkgdir/usr/lib/$pkgname"
    find "$pkgdir" -type f -exec chmod 644 {} \;
    find "$pkgdir" -iname '*.dll' -type f -exec chmod 755 {} \;
    find "$pkgdir" -type d -exec chmod 755 {} \;
    chmod +x "$pkgdir/usr/lib/$pkgname/"{MicrosoftSqlToolsCredentials,MicrosoftSqlToolsServiceLayer}
}