summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: aad687b922ee5410573bb80c6dfd4103fa4c968f (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Maintainer:

## useful linkes
# https://rsync.samba.org/
# https://github.com/WayneD/rsync
# https://github.com/WayneD/rsync-patches

## options
: ${_build_git:=true}

unset _pkgtype
[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"

## basic info
_gitname="rsync"
_pkgname="$_gitname-reflink"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=3.2.7.r33.g2f9b963a
pkgrel=1
pkgdesc='A fast and versatile file copying tool for remote and local files - with reflink support'
url='https://github.com/WayneD/rsync'
license=('GPL-3.0-or-later')
arch=('x86_64')

# main package
_main_package() {
  depends=(
    'libacl.so' # acl
    'libxxhash.so' # xxhash
    'openssl'
    'popt'
    'zstd'

    ## implicit
    #bash
    #glibc
    #lz4
    #zlib
  )
  optdepends=(
    'python: for rrsync'
  )
  makedepends=(
    'git'
    'python-commonmark'
  )

  provides=("$_pkgname=${pkgver%%.r*}")
  conflicts=("$_pkgname")

  backup=(
    'etc/rsyncd.conf'
    'etc/xinetd.d/rsync'
  )

  if [ "${_build_git::1}" != "t" ] ; then
    _main_stable
  else
    _main_git
  fi

  source+=(
    "$url-patches/raw/master/clone-dest.diff"
    "$url-patches/raw/master/detect-renamed.diff"
    "$url-patches/raw/master/detect-renamed-lax.diff"
    'rsyncd.conf'
  )
  sha256sums+=(
    'SKIP'
    'SKIP'
    'SKIP'
    '733ccb571721433c3a6262c58b658253ca6553bec79c2bdd0011810bb4f2156b'
  )
}

# stable package
_main_stable() {
  : ${_pkgver:=${pkgver%%.r*}}

  _pkgsrc="$_gitname"
  source+=("$_pkgsrc"::"git+$url.git#tag=v${_pkgver:?}")
  sha256sums+=('SKIP')

  pkgver() {
    echo "${_pkgver:?}"
  }
}

# git package
_main_git() {
  provides=("$_pkgname=${pkgver%%.r*}")
  conflicts=("$_pkgname")

  _pkgsrc="$_gitname"
  source+=("$_pkgsrc"::"git+$url.git")
  sha256sums+=('SKIP')

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

# common functions
prepare() {
  apply-patch() {
    printf '\nApplying patch %s\n' "$1"
    patch -Np1 -F100 -i "$1"
  }

  cd "$_pkgsrc"

  # patches
  apply-patch "$srcdir/clone-dest.diff"
  apply-patch "$srcdir/detect-renamed.diff"
  apply-patch "$srcdir/detect-renamed-lax.diff"
}

build() {
  cd "$_pkgsrc"

  local _configure_options=(
    --prefix=/usr
    --enable-ipv6
    --disable-debug
    --with-rrsync
    --with-included-popt=no
    --with-included-zlib=no
  )

  ./configure "${_configure_options[@]}"
  make
}

check() {
  cd "$_pkgsrc"
  make test
}

package() {
  cd "$_pkgsrc"
  make DESTDIR="$pkgdir" install

  install -Dm644 \
    "$srcdir/rsyncd.conf" \
    "$pkgdir/etc/rsyncd.conf"

  install -Dm644 \
    "packaging/lsb/rsync.xinetd" \
    "$pkgdir/etc/xinetd.d/rsync"

  install -Dm644 \
    "packaging/systemd/rsync.service" \
    "$pkgdir/usr/lib/systemd/system/rsyncd.service"

  install -Dm644 \
    "packaging/systemd/rsync.socket" \
    "$pkgdir/usr/lib/systemd/system/rsyncd.socket"

  install -Dm644 \
    "packaging/systemd/rsync@.service" \
    "$pkgdir/usr/lib/systemd/system/rsyncd@.service"
}

# execute
_main_package