Bug 201045 - www/nginx: tmpdir removed on binary package upgrade using pkg, breaking running instance
Summary: www/nginx: tmpdir removed on binary package upgrade using pkg, breaking runni...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Sergey A. Osokin
URL:
Keywords:
: 184721 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-06-22 13:58 UTC by Michael Gmelin
Modified: 2015-10-12 01:29 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (osa)


Attachments
Patch (749 bytes, patch)
2015-06-22 22:24 UTC, Sergey A. Osokin
no flags Details | Diff
Update patch (1016 bytes, patch)
2015-06-25 08:50 UTC, Michael Gmelin
grembo: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Gmelin freebsd_committer freebsd_triage 2015-06-22 13:58:29 UTC
When upgrading nginx using pkg, NGINX_TMPDIR (usually /var/tmp/nginx) is removed. In setups relying on tmpdir this breaks the webserver (file upload, caches etc.) and therefore an immediate restart of nginx is required right after the upgrade (plus user experience might by suboptimal due to removed files).

The plist already contains a fix for portmaster (which sets UPGRADE_PORT when upgrading the port):

nginx/pkg-plist:@unexec if [ -z ${UPGRADE_PORT} ] ; then rm -fr %%NGINX_TMPDIR%%; fi

Unfortunately this doesn't help when using pkg, so pkg install will remove /var/tmp/nginx, essentially breaking the webserver.

The workaround is to set UPGRADE_PORT yourself on pkg install, e.g.:

UPGRADE_PORT=nginx pkg install nginx

This is not really user friendly though, so it might be better to simply not remove the temporary directory on pkg delete by default.
Comment 1 Sergey A. Osokin freebsd_committer freebsd_triage 2015-06-22 22:24:11 UTC
Created attachment 157995 [details]
Patch

Could you try following patch, thanks in advance.
Comment 2 Michael Gmelin freebsd_committer freebsd_triage 2015-06-25 08:50:18 UTC
Created attachment 158042 [details]
Update patch
Comment 3 Michael Gmelin freebsd_committer freebsd_triage 2015-06-25 08:51:23 UTC
This gives

"pkg-static: lstat(/usr/ports/www/nginx/work/stage/var/tmp/nginx/): No such file or directory"

on make install, adding "${MKDIR} ${STAGEDIR}${NGINX_TMPDIR}" to do-install fixes that.

I attached an updated version of the patch that adds that line.

With this it works as expected (empty /var/tmp/nginx gets removed, while populated /var/tmp/nginx stays intact).
Comment 4 commit-hook freebsd_committer freebsd_triage 2015-06-25 21:06:55 UTC
A commit references this bug:

Author: osa
Date: Thu Jun 25 21:06:40 UTC 2015
New revision: 390602
URL: https://svnweb.freebsd.org/changeset/ports/390602

Log:
  Be more accurate with tmpdir removal and remove only empty tmpdir.
  Cause otherwise removal non-empty tmpdir breaks running nginx instance.

  Bump PORTREVISION.

  PR:		201045
  Tested by:	grembo

Changes:
  head/www/nginx/Makefile
  head/www/nginx/pkg-plist
  head/www/nginx-devel/Makefile
  head/www/nginx-devel/pkg-plist
Comment 5 Sergey A. Osokin freebsd_committer freebsd_triage 2015-06-25 21:07:25 UTC
Committed, thanks for report.
Comment 6 Jason Unovitch freebsd_committer freebsd_triage 2015-10-12 01:29:36 UTC
*** Bug 184721 has been marked as a duplicate of this bug. ***