makedeb


shadowsocks-rust-bin 1.14.3-1


A Rust port of shadowsocks https://shadowsocks.org/ (binary version)

Viewing /PKGBUILD.

View raw.

Click here to go back to the Git tree for shadowsocks-rust-bin.

# Maintainer: Menci <huanghaorui301@gmail.com>
# Contributor: 4679 <4679@pm.me>
# Contributor: spyophobia <76800505+spyophobia@users.noreply.github.com>
# Contributor: DuckSoft <realducksoft@gmail.com>

_repo=shadowsocks/shadowsocks-rust
pkgname=shadowsocks-rust-bin
_pkgname=shadowsocks-rust
pkgver=1.14.3
pkgrel=1
pkgdesc='A Rust port of shadowsocks https://shadowsocks.org/ (binary version)'
arch=('any')
url="https://github.com/${_repo}"
license=('MIT')
depends=('libgcc-s1')
provides=("${_pkgname}")
conflicts=("${_pkgname}" "${_pkgname}-git")
source=(
    "${url}/raw/v${pkgver}/LICENSE"
    'shadowsocks-rust@.service'
    'shadowsocks-rust-server@.service'
    "${url}/raw/v${pkgver}/examples/config.json"
    "${url}/raw/v${pkgver}/examples/config_ext.json"
)
sha512sums=(
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
)

pkgver() {
    curl https://api.github.com/repos/${_repo}/releases/latest | sed -nE 's/^  "tag_name": "v(.+)",$/\1/p'
}

_rustarch() {
    DPKG_ARCH="$(dpkg --print-architecture)"
    if [[ "$DPKG_ARCH" == "amd64" ]]; then
        echo "x86_64"
    elif [[ "$DPKG_ARCH" == "arm64" ]]; then
        echo "aarch64"
    else
        echo "$DPKG_ARCH"
    fi
}

build() {
    cd "${srcdir}"

    RELEASE_FILENAME="shadowsocks-v${pkgver}.$(_rustarch)-unknown-linux-gnu.tar.xz"
    wget "https://github.com/${_repo}/releases/download/v${pkgver}/${RELEASE_FILENAME}" -O "${RELEASE_FILENAME}"

    tar xvf "${RELEASE_FILENAME}"
}

package() {
    cd "${srcdir}"
    install -Dm755 -t "${pkgdir}/usr/bin" sslocal ssserver ssurl ssmanager ssservice

    install -Dm644 -t "${pkgdir}/usr/share/licenses/$pkgname" LICENSE
    install -Dm644 -t "${pkgdir}/usr/lib/systemd/system" shadowsocks-rust@.service shadowsocks-rust-server@.service
    install -Dm644 config.json "${pkgdir}/etc/shadowsocks/config_rust.json.example"
    install -Dm644 config_ext.json "${pkgdir}/etc/shadowsocks/config_ext_rust.json.example"

    # Add install scripts
    prerm="src/prerm"
    echo '[ "$1" = "upgrade" ] && exit 0' > "${srcdir}/prerm"
    echo "systemctl stop 'shadowsocks-rust@*'" >> "${srcdir}/prerm"
    echo "systemctl disable shadowsocks-rust@" >> "${srcdir}/prerm"
    echo "systemctl stop 'shadowsocks-rust-server@*'" >> "${srcdir}/prerm"
    echo "systemctl disable shadowsocks-rust-server@" >> "${srcdir}/prerm"
}