Description: Do not create user/group    
 make install no longer creates a user/group ffmpeg. Caused problems when
 building packages for Debian. The cache directory /var/cache/ffmepgfs is
 now created as user root.
 Regular user will have the cache in $HOME/.cache/ffmpegfs instead.
 .
 ffmpegfs (1.10-2) unstable; urgency=low
 .
   * Support: No longer creating a user/group ffmpegfs while "make install".
              The user is not really required, just bloats the system's user
              database.
   * Support: Reduced quality of the test video to make the distribution archive
              slimmer. A full HD (1920x1280) video at 60 frames per second was a
              bit of an overkill anyway. 720x400 at 30 fps should be enough for
              everybody.
   * Feature: Cache dir changed to ${XDG_CACHE_HOME:-~/.cache}/ffmpegfs (as
              specified in the XDG Base Directory Specification). Falls back to
              ${HOME:-~/.cache}/ffmpegfs if not defined. Only if executed with
              root privileges, "/var/cache/ffmpegfs" will be used (e.g. if
              invoked via /etc/fstab entry).
   * Bugfix: Issue #46 - Ensure the selected bitrate is used. Files could become
             much larger than expected. There's a strange FFmpeg API behaviour
             behind that, added the solution used in ffmpeg.c to fix.
   * Known bug: Libav support for videos seems broken. Not sure if this will be
                fixed or Libav be simply dropped.
Author: Norbert Schlia <nschlia@oblivion-software.de>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2020-02-19

--- ffmpegfs-1.10.orig/Makefile.am
+++ ffmpegfs-1.10/Makefile.am
@@ -4,9 +4,7 @@ export WARNINGS = -Wall -Wextra -Wconver
 export AM_CFLAGS = -std=c11 $(INCLUDES) $(WARNINGS) $(OPTIMISATION) -D_GNU_SOURCE
 export AM_CXXFLAGS = -std=c++11 $(INCLUDES) $(WARNINGS) $(OPTIMISATION) -D_GNU_SOURCE
 
-export USERNAME=ffmpegfs
-export USERGROUP=ffmpegfs
-export CACHEDIR=/var/cache/ffmpegfs
+export CACHEDIR="$(DESTDIR)/var/cache/ffmpegfs"
 
 SUBDIRS = src test
 
@@ -80,7 +78,7 @@ doxyfile.inc: Doxyfile Makefile
 	@echo "EXAMPLE_PATH           += TODO" >> doxyfile.inc
 	@echo "EXAMPLE_PATH           += COPYING" >> doxyfile.inc
 	@echo "EXAMPLE_PATH           += COPYING.DOC" >> doxyfile.inc
-	@echo "EXAMPLE_PATH           += COPYING" >> doxyfile.inc
+	@echo "EXAMPLE_PATH           += COPYING.CC0" >> doxyfile.inc
 	@echo "RECURSIVE              = YES" >> doxyfile.inc
 	@echo "SOURCE_BROWSER         = YES" >> doxyfile.inc
 	@echo "DISTRIBUTE_GROUP_DOC   = YES" >> doxyfile.inc
@@ -104,32 +102,15 @@ clean-local: doxy-clean
 # Really clean up everything
 wipe-all: doxy-clean distclean
 	rm -Rf autom4te.cache configure config aclocal.m4 Makefile.in test/Makefile.in src/Makefile.in
-	
-install-exec-hook:
-	@if getent passwd $(USERNAME) > /dev/null 2>&1; \
-	then \
-		echo "User $(USERNAME) already exists."; \
-	else \
-		echo "Creating user $(USERNAME)."; \
-		useradd -M $(USERNAME); \
-		usermod -L $(USERNAME); \
-	fi
 
+install-exec-hook:
 	@if [ -d "$(CACHEDIR)" ]; \
 	then \
 		echo "$(CACHEDIR) already exists."; \
 	else \
 		echo "Creating cache in $(CACHEDIR)."; \
-		mkdir $(CACHEDIR); \
-		if [ -d "/tmp/ffmpegfs" ]; \
-		then \
-			echo "Moving old cache from /tmp to $(CACHEDIR)."; \
-			mv /tmp/ffmpegfs/* $(CACHEDIR)/ || true; \
-			rmdir /tmp/ffmpegfs/; \
-		fi \
+		mkdir -p $(CACHEDIR); \
 	fi
-	@chown -R $(USERNAME):$(USERGROUP) $(CACHEDIR)
-	@chmod -R 777 $(CACHEDIR)
 
 uninstall-hook:
 	@if [ -d "$(CACHEDIR)" ]; \
@@ -137,9 +118,3 @@ uninstall-hook:
 		echo "Removing cache directory $(CACHEDIR)."; \
 		rm -Rf "$(CACHEDIR)"; \
 	fi
-	
-	@if getent passwd $(USERNAME) > /dev/null 2>&1; \
-	then \
-		echo "Removing user $(USERNAME)."; \
-		userdel $(USERNAME); \
-	fi
--- ffmpegfs-1.10.orig/ffmpegfs.1.txt
+++ ffmpegfs-1.10/ffmpegfs.1.txt
@@ -228,7 +228,7 @@ Default: 0 (no minimum space)
 *--cachepath*=DIR, *-o cachepath*=DIR::
 Sets the disk cache directory to 'DIR'. Will be created if not existing. The user running ffmpegfs must have write access to the location.
 +
-Default: /var/cache/ffmpegfs
+Default: ${XDG_CACHE_HOME:-~/.cache}/ffmpegfs (as specified in the XDG Base Directory Specification). Falls back to ${HOME:-~/.cache}/ffmpegfs if not defined. If executed with root privileges, "/var/cache/ffmpegfs" will be used.
 
 *--disable_cache*, -o *disable_cache*::
 Disable the cache functionality.
--- ffmpegfs-1.10.orig/src/transcode.cc
+++ ffmpegfs-1.10/src/transcode.cc
@@ -173,7 +173,23 @@ void transcoder_cache_path(std::string &
     }
     else
     {
-        path = "/var/cache";
+        if (geteuid() == 0)
+        {
+            // Running as root
+            path = "/var/cache";
+        }
+        else
+        {
+            // Running as regular user, put cache in home dir
+            if (const char* cache_home = std::getenv("XDG_CACHE_HOME"))
+            {
+                path = cache_home;
+            }
+            else
+            {
+                expand_path(&path, "~/.cache");
+            }
+        }
     }
 
     append_sep(&path);
