Search
j0ke.net Open Build Service
>
Projects
>
server:backup
>
backuppc_community
> backuppc_community.spec
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File backuppc_community.spec of Package backuppc_community (Revision 7)
Currently displaying revision
7
,
show latest
#!BuildIgnore: post-build-checks %define build_srpm 0 %{?srpm_only: %define build_srpm 1} %define enable_debug_packages 0 # Define which Distribution we are building: # Try to detect the distribution we are building: %if %{_vendor} == redhat # Define redhat/fedora common stuff %define install_init %{expand: %{__install} init.d/linux-backuppc %{buildroot}%{_initrddir}/backuppc} # only apache_group is used right now but apache_user will be # useful in the future. %define apache_user apache %define apache_group apache # redhat variants need this package for perl cgi to run suid %define req_perl_suidperl Requires: perl-suidperl %define httpd_conf_dir %{_sysconfdir}/httpd/conf.d # Fedora symlinks /etc/fedora-release to /etc/redhat-release for at least # fc3-8. So RHEL and Fedora look at the same file. Different versions have # different numbers of spaces; hence the use if $3 vs. $4.. %if %(awk '$1 == "Fedora" && $4 ~ /3.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver 3 %endif %if %(awk '$1 == "Fedora" && $4 ~ /4.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver 4 %endif %if %(awk '$1 == "Fedora" && $4 ~ /5.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver 5 %endif %if %(awk '$1 == "Fedora" && $4 ~ /6.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver 6 %endif %if %(awk '$1 == "Fedora" && $3 ~ /7.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver 7 %endif %if %(awk '$1 == "Fedora" && $3 ~ /8.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver 8 %endif %if %(awk '$1 == "Fedora" && $3 ~ /9.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver 9 %endif %if %(awk '$1 == "Red" && $7 ~ /3.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 3 %define tarver 1.14 %endif %if %(awk '$1 == "Red" && $7 ~ /4.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 4 %define tarver 1.14 %endif %if %(awk '$1 == "CentOS" && $3 ~ /4.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 4 %define tarver 1.14 %endif %if %(awk '$1 == "Red" && $7 ~ /5.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 5 %endif %if %(awk '$1 == "CentOS" && $3 ~ /5.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 5 %endif # If we get here, we didn't detect. %{!?dist: %define dist unknown} %endif # Detect Suse variants. Suse gives us some nice macros in their rpms %if %{_vendor} == "suse" # Define suse/sles common stuff %define install_init %{expand: %{__install} init.d/suse-backuppc %{buildroot}%{_initrddir}/backuppc} # only apache_group is used, but apache_user will be useful in # the future. %define apache_user wwwrun %define apache_group www %define httpd_conf_dir /%{_sysconfdir}/apache2/conf.d %if %{suse_version} == 910 %define dist SuSE %define disttag sles %define distver 9 %endif %if %{suse_version} == 1010 %define dist SuSE %define disttag sles %define distver 10 %endif %if %{suse_version} == 1000 %define dist SuSE %define disttag suse %define distver 10 %endif %if %{suse_version} == 1020 %define dist SuSE %define disttag suse %define distver 10 %endif %if %{suse_version} == 1030 %define dist SuSE %define disttag suse %define distver 10 %endif %if %{suse_version} == 1100 %define dist SuSE %define disttag suse %define distver 11 %endif %if %{suse_version} == 1110 %define dist SuSE %define disttag suse %define distver 11 %endif # If we get here, we didn't detect. %{!?dist: %define dist unknown} %endif # Let's die if we haven't detected the distro. This might save some frustration. %{!?distver: %{error:"Your distribution and its version were not detected."}} # Define bpc_version if it is not already defined. %{!?bpc_version: %define bpc_version 3.1.0+ftp} %{!?bpc_release: %define bpc_release 1} %define bpc_user backuppc %define bpc_group backuppc # Standard tags Summary: BackupPC Community Edition Name: backuppc_community Version: %{bpc_version} Release: %{bpc_release}.%{disttag}%{distver} Source: %{name}-%{version}.tar.gz Patch0: %{name}-suse.patch Patch1: %{name}-suse-init.patch License: GPL %{?!packager:Packager: %(id -u -n)} URL: http://www.backuppc.com/ Group: Applications/System BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%{packager}-buildroot BuildArch: noarch Requires: perl >= 5.8 Requires: tar > 1.13.7 Requires: perl(Archive::Zip) Requires: perl(Compress::Zlib) Requires: perl(File::RsyncP) Requires: perl(Time::ParseDate) %{?req_perl_suidperl} Requires: samba-client >= 3.0 Requires: rsync >= 2.6.3 Requires: httpd BuildRequires: httpd Obsoletes: backuppc Provides: backuppc-community = %{version} %description BackupPC is a high-performance, enterprise-grade system for backing up Unix, Linux, WinXX, and MacOSX PCs, desktops and laptops to a server's disk. BackupPC is highly configurable and easy to install and maintain. See www.backuppc.com and http://backuppc.sourceforge.net/ # --- Directory setup --- %define LOG_DIR %{_localstatedir}/log/BackupPC %define INSTALL_DIR /usr/lib/backuppc %define DATA_DIR %{_localstatedir}/lib/backuppc # HTML is all image files used by the cgi scripts %define HTML_DIR %{INSTALL_DIR}/www/images %define HTML_DIR_URL /BackupPC/images %define CGI_DIR %{INSTALL_DIR}/www/html %prep %setup -q %patch0 -p1 %patch1 %clean if [ "%{buildroot}" != "/" ]; then if [ -d "%{buildroot}" ] ; then rm -rf %{buildroot} fi else echo "BuildRoot was somehow set to / !" exit -1 fi %build if [ "%{buildroot}" != "/" ]; then if [ -d "%{buildroot}" ] ; then rm -rf %{buildroot} fi else echo "BuildRoot was somehow set to / !" exit -1 fi %{__perl} ./makeDist --version=%{version} %install cd dist/BackupPC-%{version} %{__perl} ./configure.pl \ --batch \ --backuppc-user=%{bpc_user} \ --cgi-dir %{CGI_DIR} \ --data-dir %{DATA_DIR} \ --dest-dir %{buildroot} \ --html-dir %{HTML_DIR} \ --html-dir-url %{HTML_DIR_URL} \ --install-dir %{INSTALL_DIR} \ --log-dir %{LOG_DIR} \ --no-set-perms \ --uid-ignore \ --hostname localhost # Install init.d script %{__mkdir_p} %{buildroot}%{_initrddir} %{install_init} %{__chmod} ugo+x %{buildroot}%{_initrddir}/backuppc # Install httpd.conf cd ../.. %{__mkdir_p} %{buildroot}%{httpd_conf_dir} %{__install} ./httpd/mod_cgi/backuppc_community.conf.%{disttag}%{distver} %{buildroot}%{httpd_conf_dir}/backuppc_community.conf # Define script variables %define script_vars bpc_user=%{bpc_user}; bpc_group=%{bpc_group}; DATA_DIR=%{DATA_DIR}; DIST=%{dist}; RPM_LOG_DIR=%{_tmppath}; SYSCONFDIR=%{_sysconfdir}; SBINDIR=%{_sbindir}; %pre %{script_vars} info_create_user_success="User ${bpc_user} created." info_user_params="User ${bpc_user} existed on this system, and was not changed. Please confirm that the user has the following settings: Home directory: ${DATA_DIR} Shell: /sbin/nologin" RPM_LOG_FILE=`mktemp ${RPM_LOG_DIR}/rpm-log-bpc_community.XXXXXXXXXXX` if [ $? -ne 0 ]; then echo "Unable to create log file!" exit 1 fi # Common Functions function logger() { # A non-annoying way to log stuff # $@ is all the parameters (quoted or not), also known as the message msg="`date +'%b %e %Y %T'`: ${@}" echo ${msg} >> ${RPM_LOG_FILE} } function log_output_of() { # A non-annouing way to log output of commands # $@ is all the parameters. just execute it, and capture the output in a # variable. output=`"${@}" 2>&1` ret=$? if [ -n "${output}" ] ; then logger "${output}" fi return ${ret} } #Create the user logger Checking for user: ${bpc_user} if ! `id -u ${bpc_user} &> /dev/null` ; then logger "Adding ${bpc_user}." log_output_of groupadd -r "${bpc_group}" &>1 || \ { logger "WARNING: Could not create group ${bpc_group}."; err=1 ; } if [ ! $err ]; then log_output_of useradd -c "BackupPc" \ -d ${DATA_DIR} \ -g "${bpc_group}" \ -r \ -s /sbin/nologin ${bpc_user} &>1 || \ { logger "WARNING: Could not create user ${bpc_user}."; err=1 ; } fi # Only log on success if [ ! $err ]; then logger "${info_create_user_success}" fi else # The user already existed logger "${info_user_params}" fi if [ ${err:=0} -eq 1 ] ; then echo "A nonfatal error occurred. Please see the log ${RPM_LOG_FILE} after installation has finished." else echo "Please check the log ${RPM_LOG_FILE} for install notes." fi %post %{script_vars} # Suse and Redhat variants both have chkconfig chkconfig --add backuppc # Suse needs to have sperl "activated" if [ ${DIST} = SuSE ] ; then PERL_VER=`%{__perl} -e 'printf "%vd\n", $^V';` SPERL="/usr/bin/sperl${PERL_VER}" %{__chmod} +s ${SPERL} fi %preun /etc/init.d/backuppc stop # Delete the init scripts on uninistall if [ $1 = 0 ]; then chkconfig --del backuppc fi %postun # Delete the user on uninstall if [ $1 = 0 ]; then userdel %{bpc_user} # Some systems automatically remove this group, some do not. if [ `grep -e "%{bpc_group}" -c /etc/group` -gt 0 ] ; then groupdel %{bpc_group} fi fi %files %defattr(- root root) %docdir %{INSTALL_DIR}/doc %{INSTALL_DIR} %attr(0755 %{bpc_user} %{bpc_group}) %{INSTALL_DIR}/bin/* %attr(0700 %{bpc_user} %{bpc_group}) %{DATA_DIR} %attr(4750 %{bpc_user} %{apache_group}) %{CGI_DIR}/BackupPC_Admin %{_initrddir}/backuppc %dir %attr(0750 %{bpc_user} %{bpc_group}) /%{_sysconfdir}/BackupPC %config %attr(0640 %{bpc_user} %{bpc_group}) /%{_sysconfdir}/BackupPC/* %config %attr(0644 root root) %{httpd_conf_dir}/backuppc_community.conf %dir %attr(0750 %{bpc_user} %{bpc_group}) %{LOG_DIR} %changelog * Tue Jun 10 2008 Dan Locks <dwlocks at zmanda dot com> 3.1.1 - Initial Release of BackupPC Community Edition