summaryrefslogtreecommitdiff
path: root/manualPorts/bareos-filedaemon/Pkgfile
blob: 0175c51aed0a0d24dd5d0077a8eb3f01b663339c (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
# Description: Backup Archiving REcovery Open Sourced - client.
# URL: http://www.bareos.org
# Maintainer: Erich Eckner, crux at eckner dot net
# Depends on: acl bash cmake glibc libcap lzo openssl python readline sqlite3 zlib

name=bareos-filedaemon
_name=${name%-*}
version=20.0.4
release=1
source=("https://github.com/$_name/$_name/archive/Release/$version.tar.gz"
'nullify-os-specifics.patch'
'check-if-bareos-backup-is-running'
'bareos-fd')

build() {

  cd "${SRC}/${_name}-Release-${version}"
  patch -p1 -i "${SRC}/nullify-os-specifics.patch"

  mkdir build
  cd build

  cmake .. \
    -Dprefix=/usr \
    -Dsbindir=/usr/bin \
    -Dsysconfdir=/etc \
    -Dconfdir=/etc/$_name \
    -Dworkingdir=/etc/$_name \
    -Dlocalstatedir=/ \
    -Dlibdir=/usr/lib/$_name \
    -Dmandir=/usr/share/man \
    -Ddisable-conio=yes \
    -Ddynamic-cats-backends=yes \
    -Ddynamic-storage-backends=yes \
    -Dpython=yes \
    -Dopenssl=yes \
    -Dmysql=no \
    -Ddisable-rpath=yes \
    -Dpostgresql=no \
    -Dsqlite3=yes \
    -Dndmp=no \
    -Dhostname='XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX' \
    -Ddir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
    -Dfd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
    -Dsd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
    -Dmon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
    -Dmon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
    -Dmon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
    -Dbasename="XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX" \
    -Dlogdir=/var/log/$_name \
    -Ddir-user=$_name \
    -Ddir-group=$_name \
    -Dsd-user=$_name \
    -Dsd-group=$_name \
    -Dfd-user=root \
    -Dpid-dir=/run/bareos \
    -Dfd-group=root \
    -Dconfigtemplatedir=/usr/share/$_name/config \
    -Dworking-dir=/var/lib/$_name \
    -Dplugindir=/usr/lib/$_name/plugins \
    -Dscriptdir=/usr/lib/$_name/scripts \
    -Dbackenddir=/usr/lib/$_name/backends \
    -Darchivedir=/var/lib/$_name/storage \
    -Dbsrdir=/var/lib/$_name \
    -Dsubsys-dir=/run/$_name \
    -Dsystemd=no

  make
  make DESTDIR="$PKG" install

  sed -i '1 a  PID Directory = /run/bareos/fd' \
    "$PKG/usr/share/bareos/config/bareos-fd.d/client/myself.conf"

  # ok, we only want the filedaemon and all it takes to run it
  rm -rf --one-file-system \
    "$PKG/bareos-webui" \
    "$PKG/etc" \
    "$PKG/usr/local"
  find "$PKG/usr/bin" -xdev -depth \
    -not -name "bareos-fd" \
    \( -type f -o -empty \) \
    -delete

  install -dm750 "$PKG/etc/bareos"
  mv \
    "$PKG/usr/share/bareos/config/bareos-fd.d" \
    "$PKG/etc/bareos/"
  rm -rf --one-file-system "$PKG/usr/share/bareos"
  find "$PKG/usr/share/man" -xdev -depth \
    -not -name 'bareos-fd.*' \
    \( -type f -o -empty \) \
    -delete

  new_needed_libs=$(
    find "$PKG/usr/bin" -type f \
      -exec objdump -x {} \; \
    | sed '
      s/^\s*NEEDED\s\+\(\S\+\.so\)\(\.[0-9.]\+\)\?$/\1/
      t
      d
    ' \
    | sort -u
  )
  while [ -n "$new_needed_libs" ]; do
    needed_libs=$(
      printf '%s\n' \
        ${needed_libs} ${new_needed_libs} \
      | sort -u
    )
    new_needed_libs=$(
      find "$PKG/usr/lib" \
        \( \
          -false \
          $(
            printf -- ' -o -name %s\n' ${new_needed_libs}
          ) \
        \) \
        -exec objdump -x {} \; \
      | sed '
        s/^\s*NEEDED\s\+\(\S\+\.so\)\(\.[0-9.]\+\)\?$/\1/
        t
        d
      ' \
      | grep -vxF "${needed_libs}" \
      | sort -u
    )
  done
  find "$PKG/usr/lib" -xdev \
    -type d -name scripts -prune , \
    $(
      printf -- ' -not -name %s*\n' ${needed_libs}
    ) \
    -not -type d \
    -exec rm {} +

  find "$PKG/usr/lib/bareos/scripts" -xdev \
    -not -name 'bareos-config*' \
    \( -not -type d -o -empty \) \
    -delete

  find \
    "$PKG/usr/lib" \
    "$PKG/var" \
    -xdev \
    -type d \
    -empty \
    -delete

  install -Dm755 \
    "$SRC/check-if-bareos-backup-is-running" \
    -t "$PKG/usr/bin"

  chmod -R o-rx "$PKG/etc/bareos"

  install -Dm755 \
    "$SRC/bareos-fd" \
    -t "$PKG/etc/rc.d"
}