makedeb


traefik 2.7.0-2


Modern reverse proxy written in Go

Viewing /PKGBUILD.

View raw.

Click here to go back to the Git tree for traefik.

# Maintainer: Menci <huanghaorui301@gmail.com>
# Contributor: Christian Rebischke <chris.rebischke@archlinux.org>

_repo=traefik/traefik

pkgname=traefik
pkgver=2.7.0
pkgrel=2
pkgdesc="Modern reverse proxy written in Go"
arch=('any')
url="https://github.com/${_repo}"
license=('MIT')
depends=('logrotate')
backup=(
    '/etc/traefik/static.yaml'
    '/etc/logrotate.d/traefik'
)
source=(
    "PKGBUILD.arch::https://raw.githubusercontent.com/archlinux/svntogit-community/packages/${pkgname}/trunk/PKGBUILD"
    'traefik.service'
    'static.yaml'
    'logrotate'
)
sha512sums=(
    'SKIP'
    '7fba4e8e27acd5fdf1bb01788be64dcb221790672de7fc3b5a29019eb0c26353e937936132922890f54474c8e10c0993c10e86b7d8eafb3495c93970ccc66cd0'
    '3b3c610b4f7adac7656c6b8c81e2c2f782c7744765a3ea3781bab3ecce92c079bb14962b80e0bb336d5d19ab99100e88cdc77807444ed72c53809f5aa537bd13'
    'a8375447a1d675fedc855b48616a8ab0972dec1d83d500a96e061d9456e69031f2d82708d4ae1491ed68904860bf1fe2e4a18fc0d188953255bc26866f3c0cea'
)

pkgver() {
    (source PKGBUILD.arch >/dev/null && echo "${pkgver}")
}

_goarch() {
    DPKG_ARCH="$(dpkg --print-architecture)"
    if [[ "$DPKG_ARCH" == "i386" ]]; then
        echo "386"
    else
        echo "$DPKG_ARCH"
    fi
}

build() {
    cd "${srcdir}"

    RELEASE_FILENAME="traefik_v${pkgver}_linux_$(_goarch).tar.gz"
    wget "https://github.com/${_repo}/releases/download/v${pkgver}/${RELEASE_FILENAME}" -O "${RELEASE_FILENAME}"

    tar xzvf "${RELEASE_FILENAME}"
}

package() {
  cd "${srcdir}"
  install -Dm755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
  install -Dm644 LICENSE.md "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm644 "${srcdir}/traefik.service" "${pkgdir}/usr/lib/systemd/system/traefik.service"
  install -Dm644 "${srcdir}/static.yaml" "${pkgdir}/etc/traefik/static.yaml"
  install -Dm644 "${srcdir}/logrotate" "${pkgdir}/etc/logrotate.d/traefik"
  mkdir -p "${pkgdir}/var/log/traefik"

  # create empty acme.json file, otherwise the service file will fail
  touch "${pkgdir}/etc/traefik/acme.json"

  # Add install scripts
  postinst="src/postinst"
  echo 'id traefik >/dev/null 2>/dev/null || useradd -r -c "traefik daemon" -M -d / -s /usr/sbin/nologin traefik' > "${srcdir}/postinst"
  echo "chown traefik:traefik /var/log/traefik" >> "${srcdir}/postinst"
  prerm="src/prerm"
  echo '[ "$1" = "upgrade" ] && exit 0' > "${srcdir}/prerm"
  echo "systemctl disable --now traefik" >> "${srcdir}/prerm"
  postrm="src/postrm"
  echo '[ "$1" = "upgrade" ] && exit 0' > "${srcdir}/postrm"
  echo "userdel traefik" >> "${srcdir}/postrm"
}