Imported Upstream version 3.3.3
[debian/amanda] / packaging / rpm / amanda.spec.src
1 #
2 #                  Copyright (C) 2005-2012 Zmanda Incorporated.
3 #                            All Rights Reserved.
4 #
5 #  This program is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU General Public License
7 #  as published by the Free Software Foundation; either version 2
8 #  of the License, or (at your option) any later version.
9
10 #  This program is distributed in the hope that it will be useful, but
11 #  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 #  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 #  for more details.
14
15 #  You should have received a copy of the GNU General Public License along
16 #  with this program; if not, write to the Free Software Foundation, Inc.,
17 #  59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
19 #  Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
20 #  Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
21 #
22
23
24 %define build_srpm 0
25 %{?srpm_only: %define build_srpm 1}
26
27 # Pkg-config sometimes needs its own path set, and we need to allow users to
28 # override our guess during detection.  This macro takes care of that.
29 # If no --define PKG_CONFIG_PATH was passed and env var $PKG_CONFIG_PATH is 
30 # set then use the env var.
31 %{!?PKG_CONFIG_PATH: %{expand:%(echo ${PKG_CONFIG_PATH:+"%%define PKG_CONFIG_PATH $PKG_CONFIG_PATH"})}}
32
33 %{?PKG_CONFIG_PATH:%{echo:PKG_CONFIG_PATH = %{PKG_CONFIG_PATH}\n}}
34
35 # LDFLAGS: newer gnu linkers can use "-Wl,--as-needed", while older ones,
36 # like rhel3 and sles9 can't.
37 %define enable_as_needed --enable-as-needed
38
39 # Define which Distribution we are building:
40 # Try to detect the distribution we are building:
41 %if %{_vendor} == redhat
42     # Fedora symlinks /etc/fedora-release to /etc/redhat-release for at least
43     # fc3-8.  So RHEL and Fedora look at the same file.  Different versions have
44     # different numbers of spaces; hence the use of $3 vs. $4..
45     %if %(awk '$1 == "Fedora" { exit 1; }' /etc/redhat-release; echo $?)
46         %define dist fedora
47         %define disttag fc
48         %define distver %(awk '{print $4}' /etc/redhat-release)
49     %endif
50     # if macro cannot have an empty test and we're just testing the existance
51     %if %{?fedora:yes}%{!?fedora:no} == yes
52         # In theory this should be more reliable than awking for distver.
53         %define distver %{fedora}
54     %endif
55     %if "%{dist}" == "fedora"
56         %if %{distver} <= 8
57             %define requires_libtermcap Requires: libtermcap.so.2
58             %define curl curl
59         %endif
60         %if %{distver} >= 9
61             %define curl libcurl
62         %endif
63         %if %{_host_cpu} == x86_64 && %{_target_cpu} == i686
64                 # Do nothing if PKG_CONFIG_PATH was set by the user above.
65                 %{!?PKG_CONFIG_PATH: %define PKG_CONFIG_PATH /usr/lib/pkgconfig}
66         %endif
67     %endif
68     %if %(awk '$1 == "Red" && $7 ~ /3.*/ { exit 1; }' /etc/redhat-release; echo $?)
69         %define dist redhat
70         %define disttag rhel
71         %define distver 3
72         %define tarver 1.14
73         %define requires_libtermcap Requires: libtermcap.so.2
74         %define curl curl
75         %define without_ipv6 --without-ipv6
76         %undefine enable_as_needed
77         %define prereq_sharutils PreReq: sharutils
78     %endif
79     %if %(awk '$1 == "Red" && $7 ~ /4.*/ { exit 1; }' /etc/redhat-release; echo $?)
80         %define dist redhat
81         %define disttag rhel
82         %define distver 4
83         %define tarver 1.14
84         %define requires_libtermcap Requires: libtermcap.so.2
85         %define curl curl
86         %define prereq_sharutils PreReq: sharutils
87     %endif
88     %if %(awk '$1 == "CentOS" && $3 ~ /4.*/ { exit 1; }' /etc/redhat-release; echo $?)
89         %define dist redhat
90         %define disttag rhel
91         %define distver 4
92         %define tarver 1.14
93         %define requires_libtermcap Requires: libtermcap.so.2
94         %define curl curl
95         %define prereq_sharutils PreReq: sharutils
96     %endif
97     %if %(awk '$1 == "Red" && $7 ~ /5.*/ { exit 1; }' /etc/redhat-release; echo $?)
98         %define dist redhat
99         %define disttag rhel
100         %define distver 5
101         %define curl curl
102     %endif
103     %if %(awk '$1 == "CentOS" && $3 ~ /5.*/ { exit 1; }' /etc/redhat-release; echo $?)
104         %define dist redhat
105         %define disttag rhel
106         %define distver 5
107         %define curl curl
108     %endif
109     %if %(awk '$1 == "Red" && $7 ~ /6.*/ { exit 1; }' /etc/redhat-release; echo $?)
110         %define dist redhat
111         %define disttag rhel
112         %define distver 6
113         %define curl libcurl
114     %endif
115     
116     # If dist is undefined, we didn't detect.
117     %{!?dist:%define dist unknown}
118 %endif
119 # Detect Suse variants.
120 %if %{_vendor} == "suse"
121     %define dist SuSE
122     %define disttag %(awk '$1=="openSUSE" { print "suse"; } $1=="SUSE" {$3=="Enterprise" ? TAG="sles" : TAG="suse" ; print TAG}' /etc/SuSE-release)
123     # use printf to be sure rpm gets a number type
124     %define distver %(awk '$1=="openSUSE" { printf("%d", $2); } $1=="SUSE" {$3=="Enterprise" ? VER=$5 : VER=$3 ; printf("%d", VER)}' /etc/SuSE-release)
125     %define curl curl
126     %if %{distver} == 9
127         %undefine enable_as_needed
128     %endif
129     %if %{distver} < 11
130         %define prereq_sharutils PreReq: sharutils
131     %endif
132 %endif
133
134 # Set options per distribution
135 %if %{dist} == redhat || %{dist} == fedora
136     %define rpm_group Applications/Archiving
137     %define requires_initscripts Requires: initscripts
138 %endif
139 %if %{dist} == SuSE
140     %define rpm_group Productivity/Archiving/Backup
141 %endif
142
143 # Let's die if we haven't detected the distro. This might save some frustration.
144 # RPM does not provide a way to  exit gracefully, hence the tag_to_cause_exit. 
145 %{!?distver: %{error:"Your distribution and its version were not detected."}; %tag_to_cause_exit }
146 # Set minimum tar version if it wasn't set in the per-distro section
147 %{!?tarver: %define tarver 1.15}
148
149 # Define the native binary data encoder (for create_amkey)
150 %define encoder %({ command -v base64 2>/dev/null; } || { command -v uuencode 2>/dev/null; })
151
152 %define packer %(%{__id_u} -n)
153
154 # --- Definitions ---
155
156 # Define amanda_version using the value determined by
157 # packaging/common/substitute.pl.
158 %{!?amanda_version: %define amanda_version %%VERSION%% }
159 %{!?amanda_release: %define amanda_release 1}
160 %define amanda_version_info "Amanda Community Edition - version %{amanda_version}"
161 %define amanda_user amandabackup
162 %define amanda_group disk
163
164 Summary: The Amanda Backup and Archiving System
165 Name: amanda
166 Version: %{amanda_version}
167 %define rpm_release %{amanda_release}.%{disttag}%{distver}
168 %if %{build_srpm}
169 %define rpm_release %{amanda_release}
170 %endif
171 Release: %{rpm_release}
172 Source: %{name}-%{version}.tar.gz
173 License: http://wiki.zmanda.com/index.php/Amanda_Copyright
174 Vendor: Zmanda, Inc.
175 Packager: www.zmanda.com
176 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%{packer}-buildroot
177 Group: %{rpm_group}
178 # TODO - Need required versions for these:
179 BuildRequires: autoconf
180 BuildRequires: automake
181 BuildRequires: binutils
182 BuildRequires: bison
183 BuildRequires: flex
184 BuildRequires: gcc
185 BuildRequires: glib2 >= 2.2.0
186 BuildRequires: glib2-devel
187 BuildRequires: gettext
188 BuildRequires: readline
189 # Note: newer distros have changed most *-devel to lib*-devel, and added a
190 # provides tag for backwards compat.
191 BuildRequires: readline-devel
192 BuildRequires: %{curl} >= 7.10.0
193 BuildRequires: %{curl}-devel >= 7.10.0
194 BuildRequires: openssl
195 BuildRequires: openssl-devel
196 BuildRequires: perl(ExtUtils::Embed)
197 %{?prereq_sharutils}
198 Requires: /bin/awk
199 Requires: /bin/date
200 Requires: /usr/bin/id
201 Requires: /sbin/ldconfig
202 Requires: /bin/sh
203 Requires: /usr/sbin/useradd
204 Requires: /usr/sbin/usermod
205 Requires: fileutils
206 Requires: gettext
207 Requires: grep
208 Requires: gnuplot
209 Requires: %{curl} >= 7.10.0
210 Requires: openssl
211 Requires: xinetd
212 Requires: perl >= 5.6.0
213 Requires: tar >= %{tarver}
214 Requires: readline
215 %{?requires_libtermcap}
216 %{?requires_initscripts}
217
218 %package backup_client
219 Summary: The Amanda Backup and Archiving Client
220 Group: %{rpm_group}
221 Requires: /bin/awk
222 Requires: fileutils
223 Requires: grep
224 %{?requires_libtermcap}
225 %{?requires_initscripts}
226 Requires: xinetd
227 Requires: perl >= 5.6.0
228 Requires: tar >= %{tarver}
229 Requires: readline
230 Provides: amanda-backup_client = %{amanda_version}
231 Provides: libamclient-%{version}.so = %{amanda_version}
232 Provides: libamanda-%{version}.so = %{amanda_version}
233 Conflicts: amanda-backup_server
234 # Native package names
235 Obsoletes: amanda, amanda-client, amanda-server
236
237 %package backup_server
238 Summary: The Amanda Backup and Archiving Server
239 Group: %{rpm_group}
240 Requires: /bin/awk
241 Requires: fileutils
242 Requires: grep
243 %{?requires_libtermcap}
244 %{?requires_initscripts}
245 Requires: xinetd
246 Requires: perl >= 5.6.0
247 Requires: tar >= %{tarver}
248 Provides: amanda-backup_server = %{amanda_version}
249 Provides: libamclient-%{version}.so = %{amanda_version}
250 Provides: libamanda-%{version}.so = %{amanda_version}
251 Provides: libamserver-%{version}.so = %{amanda_version}
252 Provides: libamtape-%{version}.so = %{amanda_version}
253 Provides: libamdevice-%{version}.so = %{amanda_version}
254 Conflicts: amanda-backup_client
255 # Native package names
256 Obsoletes: amanda, amanda-client, amanda-server
257 # --- Package descriptions ---
258
259 %description
260 Amanda is the leading Open-Source Backup and Archiving software.
261
262 The amanda-backup_server package should be installed on the Amanda server, i.e. 
263 the machine attached to backup media (such as a tape drive or disk 
264 drives) where backups will be written. The amanda-backup_server package
265 includes Amanda client.  The amanda-backup_client package needs 
266 to be installed on every system that is being backed up.
267
268 Amanda Forums is located at: http://forums.zmanda.com/
269 Amanda Documentation is available at: http://wiki.zmanda.com/
270
271
272
273 %description backup_server
274 Amanda is the leading Open-Source Backup and Archiving software.
275
276 This package contains the Amanda server.  The amanda-backup_server package 
277 should be installed on the Amanda server, i.e. the machine attached 
278 to backup media (such as a tape drive or disk drives) where backups 
279 will be written.  The amanda-backup_server package includes Amanda client.
280
281 Amanda Forums is located at: http://forums.zmanda.com/
282 Amanda Documentation is available at: http://wiki.zmanda.com/
283
284
285
286 %description backup_client
287 Amanda is the leading Open-Source Backup and Archiving software.
288
289 This package contains the Amanda client.  The amanda-backup_client package  
290 needs to be installed on every system that is being backed up.
291
292 Amanda Forums is located at: http://forums.zmanda.com/
293 Amanda Documentation is available at: http://wiki.zmanda.com/
294
295 # --- Directory setup ---
296
297 # Configure directories:
298 %define PREFIX          /usr
299 %define EPREFIX         %{PREFIX}
300 %define BINDIR          %{EPREFIX}/bin
301 %define SBINDIR         %{EPREFIX}/sbin
302 %define LIBEXECDIR      %{EPREFIX}/libexec
303 %define AMLIBEXECDIR    %{LIBEXECDIR}/amanda
304 %define DATADIR         %{PREFIX}/share
305 %define SYSCONFDIR      /etc
306 %define LOCALSTATEDIR   /var
307 %define AMANDATES       %{AMANDAHOMEDIR}/amandates
308 %define AMANDAHOMEDIR   %{LOCALSTATEDIR}/lib/amanda
309 %ifarch x86_64
310 %define LIBDIR          %{EPREFIX}/lib64
311 %else
312 %define LIBDIR          %{EPREFIX}/lib
313 %endif
314 %define AMLIBDIR        %{LIBDIR}/amanda
315 %define INCLUDEDIR      %{PREFIX}/include
316 %define MANDIR          %{DATADIR}/man
317 %define LOGDIR          /var/log/amanda
318 %define PERLSITELIB     %(eval "`perl -V:installsitelib`"; echo $installsitelib)
319 %define AMDATADIR       /var/lib/amanda
320
321 # Installation directories:
322 %define ROOT_SBINDIR            %{buildroot}/%{SBINDIR}
323 %define ROOT_LIBEXECDIR         %{buildroot}/%{LIBEXECDIR}
324 %define ROOT_DATADIR            %{buildroot}/%{DATADIR}
325 %define ROOT_LOCALSTATEDIR      %{buildroot}/%{LOCALSTATEDIR}
326 %define ROOT_SYSCONFDIR         %{buildroot}/%{SYSCONFDIR}
327 %define ROOT_AMANDAHOMEDIR      %{buildroot}/%{AMANDAHOMEDIR}
328 %define ROOT_LIBDIR             %{buildroot}/%{LIBDIR}
329 %define ROOT_MANDIR             %{buildroot}/%{MANDIR}
330 %define ROOT_LOGDIR             %{buildroot}/%{LOGDIR}
331 %define ROOT_AMDATADIR          %{buildroot}/%{AMDATADIR}
332
333 # --- Unpack ---
334
335 %prep
336 %setup -q
337 # --- Configure and compile ---
338
339 %build
340 %define config_user %{amanda_user}
341 %define config_group %{amanda_group}
342
343 # Set PKG_CONFIG_PATH=some/path if some/path was set on the command line, or by 
344 # the platform detection bits.
345 # without_ipv6 should only be defined on rhel3.
346 # LDFLAGS macro is defined except on rhel3.
347 # --enable-as-needed must be conditional until configure tests whether
348 # ld can accept --as-needed.
349 ./configure \
350         %{?PKG_CONFIG_PATH: PKG_CONFIG_PATH=%PKG_CONFIG_PATH} \
351         CFLAGS="%{optflags} -g -pipe" CXXFLAGS="%{optflags}" \
352         %{?LDFLAGS:LDFLAGS="${LDFLAGS} %{?LDFLAGS:%LDFLAGS}"} \
353         %{?enable_as_needed:%{enable_as_needed}} \
354         --quiet \
355         --prefix=%{PREFIX} \
356         --sysconfdir=%{SYSCONFDIR} \
357         --sharedstatedir=%{LOCALSTATEDIR} \
358         --localstatedir=%{LOCALSTATEDIR} \
359         --libdir=%{LIBDIR} \
360         --includedir=%{INCLUDEDIR} \
361         --mandir=%{MANDIR} \
362         --with-amdatadir=%{AMDATADIR} \
363         --with-gnuplot=/usr/bin/gnuplot \
364         --with-gnutar-listdir=%{AMANDAHOMEDIR}/gnutar-lists \
365         --with-index-server=localhost \
366         --with-tape-server=localhost \
367         --with-user=%{config_user} \
368         --with-group=%{config_group} \
369         --with-owner=%{packer} \
370         --with-fqdn \
371         --with-bsd-security \
372         --with-bsdtcp-security \
373         --with-bsdudp-security \
374         --with-ssh-security \
375         --with-debugging=%{LOGDIR} \
376         --with-assertions \
377         --disable-installperms \
378         %{?without_ipv6}
379
380 make -s LIBTOOLFLAGS=--silent
381
382 # --- Install to buildroot ---
383
384 %install
385 if [ "%{buildroot}" != "/" ]; then
386         if [ -d "%{buildroot}" ] ; then
387                 rm -rf %{buildroot}
388         fi
389 else
390         echo "BuildRoot was somehow set to / !"
391         exit -1
392 fi
393
394 make -s -j1 LIBTOOLFLAGS=--silent DESTDIR=%{buildroot} install
395
396 rm -f %{ROOT_AMANDAHOMEDIR}/example/inetd.conf.amandaclient
397 mkdir %{buildroot}/{etc,var/log}
398 mkdir %{ROOT_LOCALSTATEDIR}/amanda 
399 mkdir %{ROOT_SYSCONFDIR}/amanda
400 mkdir %{ROOT_AMANDAHOMEDIR}/gnutar-lists
401 mkdir %{ROOT_LOGDIR}
402
403 echo "%{amanda_version_info}" >%{ROOT_AMANDAHOMEDIR}/amanda-release
404
405 # --- Clean up buildroot ---
406
407 %clean
408 if [ "%{buildroot}" != "/" ]; then
409         if [ -d "%{buildroot}" ] ; then
410                 rm -rf %{buildroot}
411         fi
412 else
413         echo "BuildRoot was somehow set to / !"
414         exit -1
415 fi
416
417 # --- Pre/post (un)installation scripts ---
418
419 # Define script variables
420 # Some versions of rpmbuild do not like multi-line macros in spec files. ugly.
421 %define script_vars amanda_user=%{amanda_user}; amanda_group=%{amanda_group}; AMANDAHOMEDIR=%{AMANDAHOMEDIR}; os=Linux; wanted_shell=/bin/bash; dist=%{dist}; LOGDIR=%{LOGDIR}; INSTALL_LOG=$LOGDIR/install.log; SYSCONFDIR=%{SYSCONFDIR}; SBINDIR=%{SBINDIR}; encoder=%{encoder};
422 # --- Pre/post (un)installation scripts ---
423
424 %pre backup_server
425 ##########################################
426 LOGFILE=`mktemp /tmp/amanda_server-preinst.log.XXXXXXXXXXX`
427 if [ $? -ne 0 ]; then
428         echo "Unable to create log file!"
429         exit 1
430 fi
431 %{script_vars}
432
433
434 # See packaging/common/ for shell function libraries.
435 # ---------- Common functions ------------
436 %%COMMON_FUNCTIONS%%
437 %%PRE_INST_FUNCTIONS%%
438
439 # -------- End Common functions ----------
440 logger "Preparing to install: Amanda Server %%VERSION%%"
441 create_user
442 check_user_group "${amanda_group}" || add_group "${amanda_group}"
443 check_user_supplemental_group "tape" || add_group "tape"
444 check_user_shell "${wanted_shell}"
445 check_user_homedir "${AMANDAHOMEDIR}"
446 check_homedir || create_homedir
447 create_logdir
448
449 logger "Preinstall done."
450 cat $LOGFILE > $INSTALL_LOG && rm $LOGFILE || \
451     echo "Amanda preinstall logs can be found in '$LOGFILE'."
452
453 %post backup_server
454 ##########################################
455 LOGFILE=`mktemp /tmp/amanda_server-postinst.log.XXXXXXXXXXX`
456 if [ $? -ne 0 ]; then
457         echo "Unable to create log file!"
458         exit 1
459 fi
460 %{script_vars}
461 AMANDATES=%{AMANDATES}
462
463 # ---------- Common functions ------------
464 %%COMMON_FUNCTIONS%%
465 %%POST_INST_FUNCTIONS%%
466
467 # -------- End Common functions ----------
468 /sbin/ldconfig
469
470 check_xinetd "amandaserver"
471 case $? in
472         0) backup_xinetd "amandaserver"
473            install_xinetd "amandaserver"
474         ;;
475         1) install_xinetd "amandaserver" ;;
476         2) logger "Xinetd config not installed: either xinetd config is not present or xinetd.d is a file." ;;
477         *) logger "bad return from check_xinetd"; exit 1 ;;
478 esac
479
480 # Amanda servers should not have the client xinetd installed.
481 check_xinetd "amandaclient"
482 case $? in
483         0) backup_xinetd "amandaclient" ;;
484 esac
485
486 check_superserver_running "xinetd"
487 [ "$?" = "0" ] && action=restart || action=start
488 reload_xinetd $action
489 create_amandates
490 check_amandates
491 create_ampassphrase || \
492     logger "Info: amcryptsimple and amcrpyt will not work until .am_passphrase is created"
493 create_gnupg
494 create_amkey || \
495     logger "Info: amcrypt will not work until keys are created."
496 # Checks permissions, but only tries decrypting if both .am_passphrase
497 # and .gnupg/am_key.gpg exist.
498 check_gnupg
499 create_amandahosts
500 check_amandahosts_entry root amindexd amidxtaped
501 check_amandahosts_entry ${amanda_user} amdump
502 check_amandahosts_perms
503 create_ssh_key server
504 create_ssh_key client
505 create_profile
506 check_profile
507 install_client_conf
508
509 logger "Amanda installation complete."
510 cat $LOGFILE >> $INSTALL_LOG && {
511     rm $LOGFILE;
512     echo "Amanda installation log can be found in '${INSTALL_LOG}'.";
513 } || \
514     echo "Amanda postinstall logs can be found in '$LOGFILE'."
515
516 %postun backup_server
517 ##########################################
518 LOGFILE=`mktemp /tmp/amanda_server-remove.log.XXXXXXXXXXX`
519 if [ $? -ne 0 ]; then
520         echo "Unable to create log file!"
521         exit 1
522 fi
523 %{script_vars}
524
525 # ---------- Common functions ------------
526 %%COMMON_FUNCTIONS%%
527 %%POST_RM_FUNCTIONS%%
528
529 # -------- End Common functions ----------
530 /sbin/ldconfig
531 # Check for parameter to script (are we upgrading?)
532 if [ $1 -gt 0 ]; then
533     # We're upgrading
534     action="upgrade"
535 else
536     # We're uninstalling
537     action="uninstall"
538 fi
539
540 # See http://fedoraproject.org/wiki/Packaging/ScriptletSnippets for the reason
541 # we only remove xinetd on uninstall.
542 if [ "$action" = "uninstall" ]; then
543     # Check for and remove existing xinetd configs
544     check_xinetd "amandaserver"
545     if [ $? -eq 0 ] ; then
546         rm_xinetd "amandaserver"
547         check_superserver_running "xinetd" && reload_xinetd
548     fi
549     check_inetd "amandaserver"
550     if [ $? -eq 0 ] ; then
551         rm_inetd "amandaserver"
552         check_superserver_running "inetd" && reload_inetd
553     fi
554     if [ -f ${SYSCONFDIR}/amandates ]; then
555         logger "Removing ${SYSCONFDIR}/amandates..."
556         rm -rf ${SYSCONFDIR}/amandates
557     fi
558     if [ -d ${SYSCONFDIR}/amanda ]; then
559         logger "Removing ${SYSCONFDIR}/amanda if empty..."
560         rmdir ${SYSCONFDIR}/amanda 2> /dev/null || true
561     fi
562     if [ -d /var/lib/amanda/gnutar-lists ]; then
563         rm -rf /var/lib/amanda/gnutar-lists
564     # Remove ${amanda_user} from sensitive groups.
565     if which deluser >/dev/null 2>&1 ; then
566         for group in tape; do
567             # only call deluser when amandabackup is in $group
568             if getent group "$group" |
569                 awk -F: '{ print $4 }' |
570                 awk -F, '{ for (i=1; i <= NF; i++ ) print $i }' |
571                 grep "^${amanda_user}$" > /dev/null; then
572                     deluser ${amanda_user} $group || true
573             fi
574         done
575     fi
576     echo "Amanda removal log can be found in '$LOGFILE'."
577 fi
578
579
580 %pre backup_client
581 ##########################################
582 LOGFILE=`mktemp /tmp/amanda_client-preinst.log.XXXXXXXXXXX`
583 if [ $? -ne 0 ]; then
584         echo "Unable to create log file!"
585         exit 1
586 fi
587 %{script_vars}
588
589 # ---------- Common functions ------------
590 %%COMMON_FUNCTIONS%%
591 %%PRE_INST_FUNCTIONS%%
592
593 # -------- End Common functions ----------
594 logger "Preparing to install: %{amanda_version_info}" 
595 create_user
596 check_user_group "${amanda_group}" || add_group "${amanda_group}"
597 check_user_shell "${wanted_shell}"
598 check_user_homedir "${AMANDAHOMEDIR}"
599 check_homedir || create_homedir
600 create_logdir
601
602 logger "Preinstall done."
603 cat $LOGFILE >> $INSTALL_LOG && rm $LOGFILE || \
604     echo "Amanda preinstall logs can be found in '$LOGFILE'."
605
606 %post backup_client
607 ##########################################
608 LOGFILE=`mktemp /tmp/amanda_client-postinst.log.XXXXXXXXXXX`
609 if [ $? -ne 0 ]; then
610         echo "Unable to create log file!"
611         exit 1
612 fi
613 %{script_vars}
614 AMANDATES=%{AMANDATES}
615
616 # ---------- Common functions ------------
617 %%COMMON_FUNCTIONS%%
618 %%POST_INST_FUNCTIONS%%
619
620 # -------- End Common functions ----------
621 /sbin/ldconfig
622
623 check_xinetd "amandaclient"
624 case $? in
625         0) backup_xinetd "amandaclient"
626            install_xinetd "amandaclient"
627         ;;
628         1) install_xinetd "amandaclient" ;;
629         2) logger "Xinetd config not installed: either xinetd config is not present or xinetd.d is a file." ;;
630         *) logger "bad return from check_xinetd"; exit 1 ;;
631 esac
632
633 # Amanda clients should not have the server xinetd installed.
634 check_xinetd "amandaserver"
635 case $? in
636         0) backup_xinetd "amandaserver" ;;
637 esac
638
639 reload_xinetd
640 create_amandates
641 check_amandates
642 create_ampassphrase || \
643     logger "Info: amcryptsimple and amcrpyt will not work until .am_passphrase is created"
644 create_gnupg
645 create_amkey || \
646     logger "Info: amcrypt will not work until keys are created."
647 # Checks permissions, but only tries decrypting if both .am_passphrase
648 # and .gnupg/am_key.gpg exist.
649 check_gnupg
650 create_amandahosts
651 check_amandahosts_entry ${amanda_user} amdump
652 check_amandahosts_perms
653 create_ssh_key server
654 create_ssh_key client
655 create_profile
656 check_profile
657 install_client_conf
658
659 logger "Amanda installation complete."
660 cat $LOGFILE >> $INSTALL_LOG && {
661     rm $LOGFILE;
662     echo "Amanda installation log can be found in '${INSTALL_LOG}'.";
663 } || \
664     echo "Amanda postinstall logs can be found in '$LOGFILE'."
665
666 echo "`date +'%b %e %Y %T'`: Sending anonymous distribution and version information to Zmanda" >> ${INSTALL_LOG}
667 if [ -x /usr/bin/wget ]; then 
668         /usr/bin/wget -q -o /dev/null -O - --timeout=5 http://www.zmanda.com/amanda-tips.php\?version=%{amanda_version}\&os=%{disttag}%{distver}\&type=client 
669 fi
670
671 %postun backup_client
672 ##########################################
673 LOGFILE=`mktemp /tmp/amanda_client-remove.log.XXXXXXXXXXX`
674 if [ $? -ne 0 ]; then
675         echo "Unable to create log file!"
676         exit 1
677 fi
678 %{script_vars}
679
680 # ---------- Common functions ------------
681 %%COMMON_FUNCTIONS%%
682 %%POST_RM_FUNCTIONS%%
683
684 # -------- End Common functions ----------
685 /sbin/ldconfig
686
687 # Check for parameter to script (are we upgrading?)
688 if [ $1 -gt 0 ]; then
689     # We're upgrading
690     action="upgrade"
691 else
692     # We're uninstalling
693     action="uninstall"
694 fi
695
696 # See http://fedoraproject.org/wiki/Packaging/ScriptletSnippets for the reason
697 # we only remove xinetd on uninstall.
698 if [ "$action" = "uninstall" ]; then
699     # Check for and remove existing xinetd configs
700     check_xinetd "amandaclient"
701     if [ $? -eq 0 ] ; then
702         rm_xinetd "amandaclient"
703         reload_xinetd
704     fi
705     check_inetd "amandaclient"
706     if [ $? -eq 0 ] ; then
707         rm_inetd "amandaclient"
708         reload_inetd
709     fi
710     if [ -f ${SYSCONFDIR}/amandates ]; then
711         logger "Removing ${SYSCONFDIR}/amandates..."
712         rm -rf ${SYSCONFDIR}/amandates
713     fi
714     if [ -d ${SYSCONFDIR}/amanda ]; then
715         logger "Removing ${SYSCONFDIR}/amanda if empty..."
716         rmdir ${SYSCONFDIR}/amanda 2> /dev/null || true
717     fi
718     if [ -d ${AMANDAHOMEDIR} ]; then
719         logger "Removing ${AMANDAHOMEDIR}..."
720         rm -rf ${AMANDAHOMEDIR}
721     fi
722     # Remove ${amanda_user} from sensitive groups.
723     if which deluser >/dev/null 2>&1 ; then
724         for group in tape; do
725             # only call deluser when amandabackup is in $group
726             if getent group "$group" |
727                 awk -F: '{ print $4 }' |
728                 awk -F, '{ for (i=1; i <= NF; i++ ) print $i }' |
729                 grep "^${amanda_user}$" > /dev/null; then
730                     deluser ${amanda_user} $group || true
731             fi
732         done
733     fi
734     echo "Amanda removal log can be found in '$LOGFILE'."
735 fi
736
737
738 %files backup_client
739 # --- Files to install ---
740 # Notes:  Do not use wildcards on directories not wholly owned by amanda.  An
741 # uninstall of the software will attempt to delete whatever matches here.
742 %defattr(0755,%{amanda_user},%{amanda_group},0755)
743 %{AMLIBEXECDIR}
744 %{AMLIBDIR}
745 %{PERLSITELIB}/auto/Amanda
746 %defattr(4750,root,disk)
747 %{AMLIBEXECDIR}/application/amgtar
748 %{AMLIBEXECDIR}/application/amstar
749 %{AMLIBEXECDIR}/calcsize
750 %{AMLIBEXECDIR}/killpgrp
751 %{AMLIBEXECDIR}/rundump
752 %{AMLIBEXECDIR}/runtar
753 %defattr(0750,%{amanda_user},%{amanda_group},0750)
754 %{LOGDIR}
755 %{SBINDIR}/amaespipe
756 %{SBINDIR}/amcryp*
757 %{SBINDIR}/amgpgcrypt
758 %{SBINDIR}/amoldrecover
759 %{SBINDIR}/amrecover
760 %{SYSCONFDIR}/amanda
761 %defattr(0644,%{amanda_user},%{amanda_group},0755)
762 %{LOCALSTATEDIR}/amanda
763 %{PERLSITELIB}/Amanda
764 %{AMLIBEXECDIR}/amcat.awk
765 %{AMANDAHOMEDIR}/gnutar-lists
766 %doc %{AMANDAHOMEDIR}/amanda-release
767 %doc %{AMANDAHOMEDIR}/example/xinetd.amandaclient
768 %doc %{AMANDAHOMEDIR}/example/xinetd.amandaserver
769 %doc %{AMANDAHOMEDIR}/example/amanda-client.conf
770 %doc %{AMANDAHOMEDIR}/template.d/README
771 %doc %{AMANDAHOMEDIR}/template.d/dumptypes
772 %defattr(0644,root,root,0755)
773 %docdir %{MANDIR}
774 %{MANDIR}/man5/amanda.conf.5.gz
775 %{MANDIR}/man5/amanda-client.conf.5.gz
776 %{MANDIR}/man7/amanda-devices.7.gz
777 %{MANDIR}/man7/amanda-applications.7.gz
778 %{MANDIR}/man7/amanda-scripts.7.gz
779 %{MANDIR}/man8/amaespipe.8.gz
780 %{MANDIR}/man8/amanda.8.gz
781 %{MANDIR}/man8/amcheckdump.8.gz
782 %{MANDIR}/man8/amcrypt*
783 %{MANDIR}/man8/amgpgcrypt.8.gz
784 %{MANDIR}/man8/amrecover.8.gz
785 %doc %{DATADIR}/amanda
786
787 %files backup_server
788 %defattr(0755,%{amanda_user},%{amanda_group})
789 %{AMLIBEXECDIR}
790 %{AMLIBDIR}
791 %{PERLSITELIB}/Amanda
792 %{PERLSITELIB}/auto/Amanda
793 %{AMANDAHOMEDIR}
794 %{LOCALSTATEDIR}/amanda
795 %{SBINDIR}/am*
796 %defattr(4750,root,disk)
797 %{AMLIBEXECDIR}/application/amgtar
798 %{AMLIBEXECDIR}/application/amstar
799 %{AMLIBEXECDIR}/calcsize
800 %{AMLIBEXECDIR}/killpgrp
801 %{AMLIBEXECDIR}/rundump
802 %{AMLIBEXECDIR}/runtar
803 %{AMLIBEXECDIR}/dumper
804 %{AMLIBEXECDIR}/planner
805 %{SBINDIR}/amcheck
806 %{SBINDIR}/amservice
807 %defattr(0750,%{amanda_user},%{amanda_group},0750)
808 %{LOGDIR}
809 %{SYSCONFDIR}/amanda
810 # Files in standard dirs must be listed explicitly
811 %{SBINDIR}/activate-devpay
812 %{SBINDIR}/amaespipe
813 %{SBINDIR}/amcrypt
814 %{SBINDIR}/amcrypt-ossl
815 %{SBINDIR}/amcrypt-ossl-asym
816 %{SBINDIR}/amcryptsimple
817 %{SBINDIR}/amgpgcrypt
818 %{SBINDIR}/amoldrecover
819 %{SBINDIR}/amrecover
820 %defattr(0644,%{amanda_user},%{amanda_group})
821 %{AMLIBEXECDIR}/amcat.awk
822 %{AMLIBEXECDIR}/amplot.awk
823 %{AMLIBEXECDIR}/amplot.g
824 %{AMLIBEXECDIR}/amplot.gp
825 %doc %{AMANDAHOMEDIR}/amanda-release
826 %docdir %{AMANDAHOMEDIR}/example
827 %docdir %{AMANDAHOMEDIR}/template.d
828 %defattr(0644,root,root,0755)
829 %docdir %{MANDIR}
830 %{MANDIR}/man5/am*
831 %{MANDIR}/man5/disklist.5.gz
832 %{MANDIR}/man5/tapelist.5.gz
833 %{MANDIR}/man7/am*
834 %{MANDIR}/man8/am*
835 %{MANDIR}/man8/script-email.8.gz
836 %doc %{DATADIR}/amanda
837
838 # --- ChangeLog
839
840 %changelog
841 * %%DATE%% Dan Locks <dwlocks at zmanda dot com> %{version}
842 - Package created
843 * Fri Aug 20 2010 Dan Locks <dwlocks at zmanda dot com> 3.2.0alpha
844 - use %%VERSION% macro instead of reading a file.  error reported by ssgelm
845 * Thu Aug 19 2010 Dan Locks <dwlocks at zmanda dot com> 3.2.0alpha
846 - Added detection of openSuSE 11 as suggested by ssgelm