Skip to content

Commit

Permalink
clean specfile (#141)
Browse files Browse the repository at this point in the history
Drop deprecated Group and BuildRoot tags
Don't clean buildroot at start of %%install and drop %%clean section
Re-order preamble and drop useless variables
Use %%global instead of %%define
Split long line in %%description
Split long lines / simplify
Don't change dirs ownership in %%post
Drop default %%defattr
Convert License tag to SPDX and distribute LICENSE file
Distribute AUTHORS and README.md
Move conf file to %%_sysconfdir
Use macros instead of straigh paths
Drop comments duplicating sections name
Add blank lines between changelog entries for legibility
Fix changelog entries format
Use full URL for Source0
Add provides for bundled stuff
Run checks (Fedora only)
Specify all deps and provide a custom autoloader
Specify min php version
Install a minimal local config
Re-order directories creation
Preserve timestamps
Update URL tag
  • Loading branch information
xavierba authored and David Coutadeur committed Jul 25, 2024
1 parent 7a39be8 commit 524393d
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 78 deletions.
36 changes: 36 additions & 0 deletions packaging/rpm/SPECS/service-desk-config_inc_local
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
#==============================================================================
# LTB Service Desk
#
# Copyright (C) 2016 Clement OUDOT
# Copyright (C) 2016 LTB-project.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# GPL License: http://www.gnu.org/licenses/gpl.txt
#
#==============================================================================

#==============================================================================
# Overriding the ldap variables should be the bare minimum to get a working
# config. All other defaults from config.inc.php can be overrided here too.
#==============================================================================
# LDAP
#$ldap_url = "ldap://localhost";
#$ldap_starttls = false;
#$ldap_binddn = "cn=manager,dc=example,dc=com";
#$ldap_bindpw = "secret";
#$ldap_base = "dc=example,dc=com";
#$ldap_user_base = "ou=users,".$ldap_base;
#$ldap_user_filter = "(objectClass=inetOrgPerson)";
#$ldap_group_base = "ou=groups,".$ldap_base;
#$ldap_group_filter = "(|(objectClass=groupOfNames)(objectClass=groupOfUniqueNames))";
?>
7 changes: 7 additions & 0 deletions packaging/rpm/SPECS/service-desk-vendor_autoload
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
require_once "/usr/share/php/Smarty/Smarty.class.php";
#require_once "/usr/share/php/Smarty/Autoloader.php";
require_once "/usr/share/php/PHPMailer/PHPMailer6/autoload.php";
require_once "/usr/share/php/Ltb/LtbUtil.php";
require_once "/usr/share/php/Ltb/Ldap.php";
?>
174 changes: 96 additions & 78 deletions packaging/rpm/SPECS/service-desk.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,119 +10,132 @@
# Copyright (C) 2020 LTB-project
#=================================================

#=================================================
# Variables
#=================================================
%define sd_name service-desk
%define sd_realname ltb-project-%{name}
%define sd_version 0.5.1
%define sd_destdir /usr/share/%{name}
%define sd_cachedir /var/cache/%{name}
%global sd_destdir %{_datadir}/%{name}
%global sd_cachedir %{_localstatedir}/cache/%{name}

Name: service-desk
Version: 0.5.1
Release: 1%{?dist}
Summary: LDAP Tool Box Service Desk web interface
URL: https://github.com/ltb-project/service-desk
License: GPL-3.0-only

#=================================================
# Header
#=================================================
Summary: LDAP Tool Box Service Desk web interface
Name: %{sd_name}
Version: %{sd_version}
Release: 1%{?dist}
License: GPL
BuildArch: noarch

Group: Applications/Web
URL: https://ltb-project.org
Source0: https://github.com/ltb-project/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: service-desk-apache.conf
Source2: service-desk-vendor_autoload
Source3: service-desk-config_inc_local

Source: %{sd_realname}-%{sd_version}.tar.gz
Source1: service-desk-apache.conf
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%{?fedora:BuildRequires: phpunit9}
Requires(pre): httpd
Requires: coreutils
Requires: php(language) >= 5.6
Requires: php-ldap
Requires: php-Smarty
Requires: php-ltb-project-ldap
Requires: php-phpmailer6

Provides: bundled(js-bootstrap) = 3.4.1
Provides: bundled(js-datatables) = 1.10.16
Provides: bundled(js-jquery) = 1.10.2
Provides: bundled(fontawesome-fonts) = 4.7.0

Requires(pre,preun): coreutils
Requires: php, php-ldap

%description
Service Desk is a PHP application that allows administrators to check, unlock and reset user passwords in an LDAP directory.
Service Desk is a PHP application that allows administrators to check, unlock
and reset user passwords in an LDAP directory.
Service Desk is provided by LDAP Tool Box project: https://ltb-project.org

#=================================================
# Source preparation
#=================================================

%prep
%setup -n %{sd_realname}-%{sd_version}
%setup -q

#=================================================
# Installation
#=================================================
%install
rm -rf %{buildroot}

%install
# Create directories
mkdir -p %{buildroot}/%{sd_destdir}
mkdir -p %{buildroot}/%{sd_cachedir}/cache
mkdir -p %{buildroot}/%{sd_destdir}/conf
mkdir -p %{buildroot}/%{sd_destdir}/htdocs
mkdir -p %{buildroot}/%{sd_destdir}/lang
mkdir -p %{buildroot}/%{sd_destdir}/lib
mkdir -p %{buildroot}/%{sd_destdir}/templates
mkdir -p %{buildroot}/%{sd_cachedir}/templates_c
mkdir -p %{buildroot}/%{sd_destdir}/vendor
mkdir -p %{buildroot}/etc/httpd/conf.d
mkdir -p %{buildroot}/%{sd_cachedir}/cache
mkdir -p %{buildroot}/%{sd_cachedir}/templates_c

# Copy files
## Program
install -m 644 conf/* %{buildroot}/%{sd_destdir}/conf
install -m 644 htdocs/*.php %{buildroot}/%{sd_destdir}/htdocs
cp -a htdocs/css %{buildroot}/%{sd_destdir}/htdocs
cp -a htdocs/images %{buildroot}/%{sd_destdir}/htdocs
cp -a htdocs/vendor %{buildroot}/%{sd_destdir}/htdocs
install -m 644 lang/* %{buildroot}/%{sd_destdir}/lang
install -m 644 lib/* %{buildroot}/%{sd_destdir}/lib
install -m 644 templates/* %{buildroot}/%{sd_destdir}/templates
cp -a vendor/* %{buildroot}/%{sd_destdir}/vendor
install -p -m 644 htdocs/*.php %{buildroot}/%{sd_destdir}/htdocs
cp -a htdocs/css %{buildroot}/%{sd_destdir}/htdocs
cp -a htdocs/images %{buildroot}/%{sd_destdir}/htdocs
cp -a htdocs/vendor %{buildroot}/%{sd_destdir}/htdocs
install -p -m 644 lang/* %{buildroot}/%{sd_destdir}/lang
install -p -m 644 lib/* %{buildroot}/%{sd_destdir}/lib
install -p -m 644 templates/* %{buildroot}/%{sd_destdir}/templates

install -p -m 0644 %{SOURCE2} \
%{buildroot}%{_datadir}/%{name}/vendor/autoload.php

## Apache configuration
install -m 644 %{SOURCE1} %{buildroot}/etc/httpd/conf.d/service-desk.conf
mkdir -p %{buildroot}/%{_sysconfdir}/httpd/conf.d
install -m 644 %{SOURCE1} \
%{buildroot}/%{_sysconfdir}/httpd/conf.d/service-desk.conf

# Adapt Smarty paths
sed -i 's:/usr/share/php/smarty3:/usr/share/php/Smarty:' %{buildroot}%{sd_destdir}/conf/config.inc.php
sed -i 's:^#$smarty_cache_dir.*:$smarty_cache_dir = "'%{sd_cachedir}/cache'";:' %{buildroot}%{sd_destdir}/conf/config.inc.php
sed -i 's:^#$smarty_compile_dir.*:$smarty_compile_dir = "'%{sd_cachedir}/templates_c'";:' %{buildroot}%{sd_destdir}/conf/config.inc.php
sed -i \
-e 's:/usr/share/php/smarty3:/usr/share/php/Smarty:' \
-e 's:^#$smarty_cache_dir.*:$smarty_cache_dir = "'%{sd_cachedir}/cache'";:' \
-e 's:^#$smarty_compile_dir.*:$smarty_compile_dir = "'%{sd_cachedir}/templates_c'";:' \
conf/config.inc.php

%post
#=================================================
# Post Installation
#=================================================
# Move conf file to %%_sysconfdir
mkdir -p %{buildroot}/%{_sysconfdir}/%{name}
install -p -m 644 conf/config.inc.php \
%{buildroot}/%{_sysconfdir}/%{name}/
ln -s %{_sysconfdir}/%{name}/config.inc.php \
%{buildroot}%{sd_destdir}/conf/config.inc.php
install -p -m 644 %{SOURCE3} \
%{buildroot}/%{_sysconfdir}/%{name}/config.inc.local.php

# Change owner
/bin/chown apache:apache %{sd_cachedir}/cache
/bin/chown apache:apache %{sd_cachedir}/templates_c

#=================================================
# Cleaning
#=================================================
%clean
rm -rf %{buildroot}
%check
%{?fedora:phpunit9 --verbose --testdox --do-not-cache-result tests}


%post
if [ -f "%{sd_destdir}/conf/config.inc.php" ]; then
mv %{sd_destdir}/conf/config.inc.php %{_sysconfdir}/%{name}/config.inc.php
fi
# Move configuration override too
if [ -f "%{sd_destdir}/conf/config.inc.local.php" ]; then
mv %{sd_destdir}/conf/config.inc.local.php \
%{_sysconfdir}/%{name}/config.inc.local.php
fi


#=================================================
# Files
#=================================================
%files
%defattr(-, root, root, 0755)
%config(noreplace) %{sd_destdir}/conf/config.inc.php
%config(noreplace) /etc/httpd/conf.d/service-desk.conf
%license LICENSE
%doc AUTHORS README.md
%config(noreplace) %{_sysconfdir}/%{name}/config.inc.php
%config(noreplace) %{_sysconfdir}/%{name}/config.inc.local.php
%config(noreplace) %{_sysconfdir}/httpd/conf.d/service-desk.conf
%{sd_destdir}
%{sd_cachedir}
%dir %{sd_cachedir}
%attr(-,apache,apache) %{sd_cachedir}/cache
%attr(-,apache,apache) %{sd_cachedir}/templates_c


#=================================================
# Changelog
#=================================================
%changelog
* Wed May 17 2023 - Clement Oudot <[email protected]> - 0.5.1-1
* Wed May 17 2023 Clement Oudot <[email protected]> - 0.5.1-1
- gh#92: Message override broken in 0.5
- gh#94: Missing replacement for lang value (issue #92)
- gh#95: Some documentation improvements
- gh#96: Add source IP in audit
- gh#98: Add IP in audit
- gh#99: Provide result codes for lock/unlock account actions
* Mon Apr 24 2023 - Clement Oudot <[email protected]> - 0.5-1

* Mon Apr 24 2023 Clement Oudot <[email protected]> - 0.5-1
- gh#45: Do not enable lockout feature if no ppolicy associated to account or ppolicy has pwdLockout value to FALSE
- gh#47: Don't lock account until a valid ppolicy with pwdLockout=TRUE is associated (#45)
- gh#49: Timestamp value displayer
Expand Down Expand Up @@ -152,7 +165,8 @@ rm -rf %{buildroot}
- gh#88: Force line break
- gh#89: Address displayer
- gh#90: Prehook feature
* Mon May 17 2021 - Clement Oudot <[email protected]> - 0.4-1

* Mon May 17 2021 Clement Oudot <[email protected]> - 0.4-1
- gh#19: Display expiration date
- gh#20: fix(undefined)
- gh#22: Configure cache dir and template cache dir
Expand All @@ -167,16 +181,20 @@ rm -rf %{buildroot}
- gh#40: Dashboard will expire passwords
- gh#42: Dashboard idle accounts
- gh#44: Multi tenancy
* Mon Jun 29 2020 - Clement Oudot <[email protected]> - 0.3-1

* Mon Jun 29 2020 Clement Oudot <[email protected]> - 0.3-1
- Bug #15: Handle the case where pwdAccountLockedTime is set but pwdLockoutDuration is not set or is equal to 0
- Feature #16: Possibility to lock an account
- Feature #17: Allow the Smarty path to be set in conf.inc.local.php
* Tue May 19 2020 - Clement Oudot <[email protected]> - 0.2-2

* Tue May 19 2020 Clement Oudot <[email protected]> - 0.2-2
- Bug #13: Syntax error in resetpassword.php
* Fri May 15 2020 - Clement Oudot <[email protected]> - 0.2-1

* Fri May 15 2020 Clement Oudot <[email protected]> - 0.2-1
- Bug #5: Password is marked as expired if policy do not set pwdMaxAge
- Bug #7: The pwdReset radio button is not checked by default
- Feature #9: PostHook
- Feature #10: Viewer for quota attributes
* Mon Mar 30 2020 - Clement Oudot <[email protected]> - 0.1-1

* Mon Mar 30 2020 Clement Oudot <[email protected]> - 0.1-1
- First release

0 comments on commit 524393d

Please sign in to comment.