Skip to content

Fix logrotate and update rpm spec file #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

alexjfisher
Copy link
Contributor

I think the debian equivalent also needs updating, but with these changes I was able to build a 0.0.4 RPM on CentOS 7.

@alexjfisher
Copy link
Contributor Author

Commit amended to now also include creation of log directory. This already happens in the debian build.

@alexjfisher alexjfisher changed the title Update spec file for 0.0.4 release Update spec file to work with 0.0.4 release Nov 16, 2018
@@ -50,6 +51,7 @@ getent passwd nginx-ldap-auth > /dev/null || \
%preun
/usr/bin/systemctl --no-reload disable nginx-ldap-auth.service >/dev/null 2>&1 ||:
/usr/bin/systemctl stop nginx-ldap-auth.service >/dev/null 2>&1 ||:
rm -f /var/log/nginx-ldap-auth/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no check if this is an upgrade or removal. Either way it looks to be a bad idea to purge all logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't too sure about this (or spec files in general), so went looking for examples. I got this from https://github.com/mozilla-services/squid-rpm/blob/ea9a11c15092788f270730e0264f01ab5503a82e/SPECS/squid.spec#L253
But maybe that's not a very good practice and I'm cargo-cult copying a bad example!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just come across https://fedoraproject.org/wiki/PackagingDrafts/Logfiles

logfiles should not be removed by package removals

I can update the PR to follow those guidelines.

@@ -19,7 +19,7 @@ Reference implementation of method for authenticating users on behalf of
servers proxied by NGINX or NGINX Plus.

%prep
%setup -q
%setup -q -n nginx-ldap-auth-release-%{version}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming directory from 'nginx-ldap-auth-%version' to 'nginx-ldap-auth-release-%version' seems to be useless. Could you please justify this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what's in the 0.0.4 release tarball. After downloading the release, into rpmbuild/SOURCES and extracting the spec file into rpmbuild\SPECS, the build fails with

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.QO2R9V
+ umask 022
+ cd /home/afisher/rpmbuild/BUILD
+ cd /home/afisher/rpmbuild/BUILD
+ rm -rf nginx-ldap-auth-0.0.4
+ /usr/bin/gzip -dc /home/afisher/rpmbuild/SOURCES/nginx-ldap-auth-release-0.0.4.tar.gz
+ /usr/bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd nginx-ldap-auth-0.0.4
/var/tmp/rpm-tmp.QO2R9V: line 35: cd: nginx-ldap-auth-0.0.4: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.QO2R9V (%prep)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it.
I suppose we should change directory name packed into a release tarball. Mostly because it's somehow wrote to make people guess proper directory name while it should be %name-%version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed release naming (and thus - directory naming inside archives). Please, remove this change from your PR.

@oxpa
Copy link
Contributor

oxpa commented Nov 16, 2018

As far as I can see, in debian we are using an init script which redirects output to a log file.

In redhat we rely on a .service file and systemd to store logs in journald (we require systemd in the spec file). I can't find where the daemon writes logs into a file. Could you point that to me?

@alexjfisher
Copy link
Contributor Author

LOG=/var/log/nginx-ldap-auth/daemon.log

Sourced by

EnvironmentFile=/etc/default/nginx-ldap-auth

$LOG is used in

''''which python2 >/dev/null && exec python2 -u "$0" "$@" >> $LOG 2>&1 # '''

In /var/log/messages I had

Nov 16 06:29:47 kibana-01c nginx-ldap-auth-daemon[6058]: /usr/bin/nginx-ldap-auth-daemon: line 3: /var/log/nginx-ldap-auth/daemon.log: No such file or directory

@oxpa
Copy link
Contributor

oxpa commented Nov 16, 2018

Could you please remove %setup modification and logs removal and I will merge your PR.

@alexjfisher alexjfisher changed the title Update spec file to work with 0.0.4 release Fix logrotate and update rpm spec file Nov 16, 2018
@@ -1,4 +1,5 @@
/var/log/nginx-ldap-auth/daemon.log {
compress
delaycompress
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delaycompress doesn't do anything if compress isn't specified. logrotate is deletes all log content without this.

Name: nginx-ldap-auth
Version: 0.0.3
Version: 0.0.5
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the assumption the tarball layout fix will be in a 0.0.5 release.

* Create log directory in spec file
* Fix logrotate file
@oxpa oxpa merged commit bbbde8d into nginxinc:master Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants