# # spec file for package nextcloud # # # %if 0%{?suse_version} %define apache_serverroot /srv/www/htdocs %define apache_confdir /etc/apache2/conf.d %define apache_docdir /usr/share/doc/packages %define apache_user wwwrun %define apache_group www %else %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version} %define apache_serverroot /var/www/html %define apache_confdir /etc/httpd/conf.d %define apache_user apache %define apache_group apache %define __jar_repack 0 %else %define apache_serverroot /var/www %define apache_confdir /etc/httpd/conf.d %define apache_user www %define apache_group www %endif %endif %define oc_user %{apache_user} %define oc_dir %{apache_serverroot}/%{name} %define ocphp_bin /usr/bin %if 0%{?rhel} == 600 || 0%{?rhel_version} == 600 || 0%{?centos_version} == 600 %define statedir /var/run %else %define statedir /run %endif Name: nextcloud # Downloaded from https://download.nextcloud.com/server/releases/nextcloud-9.0.51.zip %define base_version 9.0.53 Version: %{base_version} Release: 0 Source0: nextcloud-%{version}.tar.bz2 Source1: apache_secure_data Source2: README Source3: README.SELinux Source4: robots.txt Url: http://www.nextcloud.com BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch Summary: A safe home for all your data, community-driven, free & open source License: AGPL-3.0 Group: Productivity/Networking/Web/Utilities %if 0%{?suse_version} BuildRequires: fdupes %if 0%{?suse_version} != 1110 # For all SUSEs except SLES 11 Requires: apache2 apache2-mod_php5 php5 >= 5.3.3 sqlite3 php5-sqlite php5-mbstring php5-zip php5-json php5-posix curl php5-curl php5-gd php5-ctype php5-xmlreader php5-xmlwriter php5-zlib php5-pear php5-iconv BuildRequires: apache2 unzip %else # SLES 11 requires # require mysql directly for SLES 11 Requires: apache2 apache2-mod_php53 php53 >= 5.3.3 mysql php53-sqlite php53-mbstring php53-zip php53-json php53-posix curl php53-curl php53-gd php53-ctype php53-xmlreader php53-xmlwriter php53-zlib php53-pear php53-iconv BuildRequires: apache2 unzip %endif %endif #Requires: curl %{name}-3rdparty %if 0%{?suse_version} # SUSE does not include the fileinfo module in php-common. Requires: php-fileinfo %if 0%{?suse_version} != 1110 Recommends: php5-mysql mysql php5-imagick %else Recommends: php53-mysql mysql php53-imagick %endif %else Requires: mysql %endif %description A safe home for all your data, community-driven, free & open source Access & share your files, calendars, contacts, mail & more from any device, on your terms %prep %setup -q -n %{name} cp %{SOURCE2} . cp %{SOURCE3} . cp %{SOURCE4} . #%%patch0 -p0 %build %install # no server side java code contained, alarm is false idir=$RPM_BUILD_ROOT/%{apache_serverroot}/%{name} mkdir -p $idir mkdir -p $idir/data mkdir -p $idir/search cp -aRf * $idir cp -aRf .htaccess $idir cp -aRf .user.ini $idir # $idir/l10n to disappear in future #rm -f $idir/l10n/l10n.pl if [ ! -f $idir/robots.txt ]; then install -p -D -m 644 %{SOURCE4} $idir/robots.txt fi # create the AllowOverride directive install -p -D -m 644 %{SOURCE1} $RPM_BUILD_ROOT/%{apache_confdir}/nextcloud.conf ocpath="%{apache_serverroot}/%{name}" sed -i -e"s|@DATAPATH@|${ocpath}|g" $RPM_BUILD_ROOT/%{apache_confdir}/nextcloud.conf # not needed for distro packages rm -f ${idir}/indie.json %if 0%{?suse_version} # link duplicate doc files %fdupes -s $RPM_BUILD_ROOT/%{apache_serverroot}/%{name} %endif %postun %pre # avoid fatal php errors, while we are changing files # https://github.com/nextcloud # # We don't do this for new installs. Only for updates. # If the first argument to pre is 1, the RPM operation is an initial installation. If the argument is 2, # the operation is an upgrade from an existing version to a new one. if [ $1 -gt 1 -a ! -s /tmp/apache_stopped_during_nextcloud_install ]; then echo "%{name} update: Checking for running Apache" # FIXME: this above should make it idempotent -- a requirement with openSUSE. # it does not work. %if 0%{?suse_version} && 0 %if 0%{?suse_version} <= 1110 rcapache2 status | grep running > /tmp/apache_stopped_during_nextcloud_install rcapache2 stop %else service apache2 status | grep running > /tmp/apache_stopped_during_nextcloud_install service apache2 stop %endif %endif %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version} service httpd status | grep running > /tmp/apache_stopped_during_nextcloud_install service httpd stop %endif fi if [ -s /tmp/apache_stopped_during_nextcloud_install ]; then echo "%{name} pre-install: Stopping Apache" fi if [ $1 -eq 1 ]; then echo "%{name}-server: First install starting" else echo "%{name}-server: installing upgrade ..." fi # https://github.com/nextcloud if [ -x %{ocphp_bin}/php -a -f %{oc_dir}/occ ]; then echo "%{name}: occ maintenance:mode --on" su %{oc_user} -s /bin/sh -c "cd %{oc_dir}; PATH=%{ocphp_bin}:$PATH php ./occ maintenance:mode --on" || true echo yes > %{statedir}/occ_maintenance_mode_during_nextcloud_install fi %post if [ $1 -eq 1 ]; then echo "%{name} First install complete" else echo "%{name} Upgrade complete" fi %if 0%{?suse_version} # make sure php5 is not in APACHE_MODULES, so that we don't create dups. perl -pani -e 's@^(APACHE_MODULES=".*)\bphp5\b@$1@' /etc/sysconfig/apache2 # add php5 to APACHE_MODULES perl -pani -e 's@^(APACHE_MODULES=")@${1}php5 @' /etc/sysconfig/apache2 %endif if [ -s /tmp/apache_stopped_during_nextcloud_install ]; then echo "%{name} post-install: Restarting Apache" ## If we stopped apache in pre section, we now should restart. -- but *ONLY* then! ## Maybe delegate that task to occ upgrade? They also need to handle this, somehow. %if 0%{?suse_version} %if 0%{?suse_version} <= 1310 rcapache2 start %else rcapache2 restart apache2.service %endif %endif %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version} service httpd start %endif echo "%{name}: occ maintenance:mode --off" su %{oc_user} -s /bin/sh -c "cd %{oc_dir}; PATH=%{ocphp_bin}:$PATH php ./occ maintenance:mode --off" || true fi rm -f /tmp/apache_stopped_during_nextcloud_install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,wwwrun,www) %exclude %{apache_serverroot}/%{name}/README %exclude %{apache_serverroot}/%{name}/README.SELinux %doc README README.SELinux %{apache_serverroot}/%{name} %config %attr(0644,root,root) %{apache_confdir}/nextcloud.conf %changelog