summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5eabe36e72d4093018c26a9195c4cc390fdd4f6c (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
# Maintainer:
# Contributor: Ahmad Hasan Mubashshir <ahmubashshir@gmail.com>
# Contributor: Konstantin Stepanov <me@kstep.me>

# options
: ${CARGO_HOME:=$SRCDEST/cargo}

# basic info
_pkgname="systemd-cron-next"
pkgname="$_pkgname-git"
pkgver=1.0.2.r22.gfe1f4a6
pkgrel=2
pkgdesc="Systemd generator to generate timers/services from crontab and anacrontab files"
url="https://github.com/systemd-cron/systemd-cron-next"
license=('MIT')
arch=('i686' 'x86_64')

depends=(
  'run-parts'
  'systemd'
)
makedepends=(
  'git'
  'rustup'
)
optdepends=(
  'smtp-forwarder: sending emails'
)

provides=(
  "$_pkgname=$pkgver"
  'anacron'
  'cron'
  'systemd-cron'
)
conflicts=(
  "$_pkgname"
  'anacron'
  'cron'
)

_pkgsrc="$_pkgname"
source=(
  "$_pkgsrc"::"git+$url.git"
  "0001-makefile-git.patch"
)
sha256sums=(
  'SKIP'
  '095f20fd780717da18c0251df0ff702a5953816120f3040a317ccc9dc3e1572b'
)

_cargo_env() {
  export RUSTUP_TOOLCHAIN=nightly
  export CARGO_TARGET_DIR="$srcdir/target"
}

pkgver() (
  cd "$_pkgsrc"
  git describe --long --tags --exclude='*[a-zA-Z][a-zA-Z]*' 2> /dev/null \
    | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
)

prepare() {
  cd "$_pkgsrc"

  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    src="${src%.zst}"
    if [[ $src == *.patch ]]; then
      printf '\nApplying patch: %s\n' "$src"
      patch -Np1 -F100 -i "$srcdir/$src"
    fi
  done

  sed -E \
    -e '1i #![feature(rustc_encodable_decodable)]' \
    -i "src/bin/crontab.rs"

  _cargo_env
  cargo update
  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  _cargo_env

  cd "$_pkgsrc"
  ./configure --prefix="/usr" --confdir="/etc"
  DESTDIR="$pkgdir" make build
}

package() {
  cd "$_pkgsrc"
  DESTDIR="$pkgdir" make install
  install -dm775 "$pkgdir/var/spool/cron"
  install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}