LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File backuppc.spec of Package backuppc (Project home:Tomcat42:branches:Archiving:Backup)

# spec file for package backuppc
# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/

# See also http://en.opensuse.org/openSUSE:Specfile_guidelines
%define backup_user          backuppc
%define backup_userid        126
%define backup_group         backuppc
%define backup_groupid       126
%define backup_root          /var/lib/%{backup_user}
%define backup_logdir        /var/log/%{name}
%define servicename          backuppc

%define apxs                 %{_sbindir}/apxs2
%define apache_sysconfdir    %(%{apxs} -q SYSCONFDIR)

%if 0%{?suse_version} >= 1210
%define has_systemd 1

Name:           backuppc
Version:        3.3.2
Release:        0
Summary:        BackupPC server - a high-performance, enterprise-grade system
License:        GPL-2.0+
Group:          Productivity/Networking/System
Url:            https://github.com/backuppc/backuppc/releases
Source0:        https://github.com/backuppc/backuppc/releases/download/%{version}/BackupPC-%{version}.tar.gz
Source1:	%{name}.conf
Source2:	%{name}.service
Source3:	%{name}.logrotate
Source4:	suse-%{name}.patch
Source5:	%{name}-config.pl_update.patch
Source99:	%{name}.rpmlintrc
BuildArch:	noarch
BuildRoot:	%{_tmppath}/%{name}-%{version}-build
BuildRequires:  apache2-devel
BuildRequires:  samba-client
BuildRequires:  rsync
BuildRequires:  sendmail
BuildRequires:  openssh
BuildRequires:  iputils
BuildRequires:  logrotate
BuildRequires:  perl-base >= 5.8.0
BuildRequires:  perl-CGI
%if 0%{?has_systemd}
BuildRequires:  systemd
PreReq:		%insserv_prereq

Requires(pre): /usr/sbin/useradd, /usr/bin/getent

Requires:       apache2
Requires:       apache2-mod_perl
Requires:       samba-client
Requires:       logrotate
Requires:       tar >= 1.13.20
Requires:       rsync >= 2.6.3
Requires:       perl-base >= 5.8.0
#Requires:       perl-Compress-Zlib
Requires:       perl-Archive-Zip
Requires:       perl-File-RsyncP >= 0.68
Requires:       perl-XML-RSS
Requires:       perl-File-Listing
Requires:       perl-Net-FTP-RetrHandle
Requires:       perl-Net-FTP-AutoReconnect
Requires:       perl-CGI

%if 0%{?suse_version} >= 1210

BackupPC is a high-performance, enterprise-grade system for backing up Linux, WinXX and MacOSX PCs and laptops to a server's disk. BackupPC is highly configurable and easy to install and maintain. 

It provides a http User interface, where the backups can be configured or started manually, files or directories can be restored to zip files, tar files or using one of the backup transfer protocols to restore directly to the clients disk.
Backups can be obtained by using the backup transfer protocols: tar over ssh, rsync, smb, ftp
The backup server deduplicates files and stores them in an uncompressed or compressed pool.
It automatically removes old backups as configured.

%setup -q -n BackupPC-%{version}


perl configure.pl \
  --batch \
  --backuppc-user=%{backup_user} \
  --config-dir=%{_sysconfdir}/%{name} \
  --cgi-dir=%{_datadir}/%{name}/cgi-bin \
  --data-dir=%{backup_root} \
  --dest-dir %{buildroot} \
  --html-dir=%{_datadir}/%{name}/html \
  --html-dir-url=/%{name}/images \
  --install-dir=%{_datadir}/%{name} \
  --log-dir=%{backup_logdir} \
  --uid-ignore \
  --no-set-perms \

# install systemd.service or init.d
mkdir %{buildroot}%{_sbindir}
%if 0%{?has_systemd}
%{__install} -d %{buildroot}%{_unitdir}
%{__install} -p -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/
ln -s service %{buildroot}%{_sbindir}/rc%{servicename}
%{__install} -d %{buildroot}/%{_initrddir}
%{__install} -p -m 0755 init.d/suse-backuppc %{buildroot}/%{_initrddir}/%{servicename}
patch %{buildroot}%{_initrddir}/%{servicename} %{SOURCE4}
ln -s ../..%{_initrddir}/%{servicename} %{buildroot}/%{_sbindir}/rc%{servicename}
# install backuppc.conf to /etc/apache2/conf.d
%{__install} -D -m 0640 %{SOURCE1} %{buildroot}/%{apache_sysconfdir}/conf.d/%{name}.conf
# install logrotate
%{__install} -D -m 0644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}
# folder for pc specific/ individual configuration files
if ! test -d %{buildroot}%{_sysconfdir}/%{name}/pc; then
    mkdir %{buildroot}%{_sysconfdir}/%{name}/pc
# create folder for log files
mkdir -p %{buildroot}%{backup_logdir}
mkdir -p %{buildroot}%{_rundir}/%{name}/
cp %{SOURCE5} %{buildroot}%{_datadir}/%{name}/

# Create the user and group (as from http://fedoraproject.org/wiki/Packaging%3aUsersAndGroups)
getent group %{backup_group}  >/dev/null || groupadd -f -g %{backup_groupid} -r %{backup_group}
if ! getent passwd %{backup_user} >/dev/null ; then
    if ! getent passwd %{backup_userid} >/dev/null ; then
      useradd -r -u %{backup_userid} -g %{backup_group} -d %{backup_root} -s /sbin/nologin -c "Backup server owner" %{backup_user}
      useradd -r -g %{backup_group} -d %{backup_root} -s /sbin/nologin -c "Backup server owner" %{backup_user}
# The user directory is created in the files section
exit 0

%if 0%{?has_systemd}
%service_add_pre %{name}.service

%stop_on_removal %{name}
%if 0%{?has_systemd}
%service_del_preun %{name}.service

%if 0%{?has_systemd}
%service_add_post %{name}.service
%restart_on_update %{name}
# Activate the Apache required modules
a2enmod -q version || a2enmod version
a2enmod -q perl || a2enmod perl
if ! test -f %{_sysconfdir}/%{name}/passwd; then
  echo -ne '\n *** i miss %{_sysconfdir}/%{name}/passwd ...'
  echo -ne '\n *** Please set Username and Password (for the HTTP-Frontend) by running'
  echo -ne '\n ***   htpasswd2 -c %{_sysconfdir}/%{name}/passwd <allowed User/Cgi Admin>\n\n'
if !  grep -v --quiet \'\' %{_sysconfdir}/%{name}/config.pl | grep  '^$Conf{CgiAdminUsers' ; then
  echo ' *** neither CgiAdminUsersGroup, nor CgiAdminUsers ist set in %{_sysconfdir}/%{name}/config.pl'
  echo ' *** You will not be able to modify system settings using the CGI interface.'
# update config.pl by patch:
if grep -q "backuppc.wiki.sourceforge.net" %{_sysconfdir}/%{name}/config.pl; then
  echo "update current config.pl (copyright and Wiki)"
  patch %{_sysconfdir}/%{name}/config.pl %{_datadir}/%{name}/backuppc-config.pl_update.patch

%if 0%{?has_systemd}
%service_del_postun %{name}.service
%restart_on_update %{name}

# backup User directory
%dir %attr(0770,%{backup_user},%{backup_group}) %{backup_root}
%dir %attr(0770,%{backup_user},%{backup_group}) %{backup_root}/pc
%dir %attr(0770,%{backup_user},%{backup_group}) %{backup_root}/pool
%dir %attr(0770,%{backup_user},%{backup_group}) %{backup_root}/cpool
%dir %attr(0770,%{backup_user},%{backup_group}) %{backup_root}/trash
# /etc -> /etc/backuppc. /etc/apache2/..., /etc/logrotate.d/...
%dir %attr(0750,%{backup_user},%{backup_group}) %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*
%dir %attr(0750,%{backup_user},%{backup_group}) %{_sysconfdir}/%{name}/pc
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{name}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
# /usr/share/backuppc
%dir %attr(0750,root,%{backup_group}) %{_datadir}/%{name}
%docdir  %{_datadir}/%{name}/doc
%attr(0754,root,%{backup_group}) %{_datadir}/%{name}/bin/BackupPC*
%attr(0754,root,%{backup_group}) %{_datadir}/%{name}/cgi-bin/BackupPC_Admin
# Log dir
%dir %attr(0750,%{backup_user},%{backup_group}) %{backup_logdir}
%attr(0754,root,%{backup_group}) %{_datadir}/%{name}/backuppc-config.pl_update.patch

%if 0%{?has_systemd}