I have attached a fixed patch to this email - please ignore the previous
patch. I missed a few things, and it didn't even build correctly. There are
various improvements in this one, and it builds and runs fine for Jessie.

-- 
Rowan Thorpe
PGP fingerprint:
 BB0A 0787 C0EE BDD8 7F97  3D30 49F2 13A5 265D CCBD
----
"There is a great difference between worry and concern. A worried person sees
a problem, and a concerned person solves a problem."
 - Harold Stephens
>From c7a3ce937e9b92c50342ca0d760184102316dc58 Mon Sep 17 00:00:00 2001
From: Rowan Thorpe <[email protected]>
Date: Fri, 15 May 2015 15:44:33 +0300
Subject: [PATCH] Fix sass-cache location for Jessie

* this adds a configurable sass-cache location, and forces a sane location for
  debian - which is in fact necessary for >= Jessie, as the system default
  (/.sass-cache) causes permissions problems

* I also included a small sneaky improvement to the header of the previous
  debian-diff
---
 debian/coquelicot.8.ron                            |   2 +
 debian/coquelicot.postinst                         |   4 +
 debian/coquelicot.postrm                           |   1 +
 .../patches/0011-Improve-running-as-non-root.patch |   4 +
 .../0012-Fix-sass-cache-location-on-jessie.patch   | 113 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 debian/settings.yml                                |   4 +
 7 files changed, 129 insertions(+)
 create mode 100644 debian/patches/0012-Fix-sass-cache-location-on-jessie.patch

diff --git a/debian/coquelicot.8.ron b/debian/coquelicot.8.ron
index d454cf4..b44c182 100644
--- a/debian/coquelicot.8.ron
+++ b/debian/coquelicot.8.ron
@@ -55,6 +55,8 @@ HTTPS reverse proxy.
 
  * `/var/lib/coquelicot`: default directory where user files will be stored.
 
+ * `/var/cache/coquelicot`: default directory where cache files will be stored.
+
  * `/var/log/coquelicot/coquelicot.log`: default log file.
 
 ## SEE ALSO
diff --git a/debian/coquelicot.postinst b/debian/coquelicot.postinst
index c2e4cd4..cea412a 100755
--- a/debian/coquelicot.postinst
+++ b/debian/coquelicot.postinst
@@ -17,6 +17,10 @@ case "$1" in
 		chown coquelicot:coquelicot /var/lib/coquelicot
 		chmod 750 /var/lib/coquelicot
 	fi
+	if ! dpkg-statoverride --list "/var/cache/coquelicot"; then
+		chown coquelicot:coquelicot /var/cache/coquelicot
+		chmod 750 /var/cache/coquelicot
+	fi
 	if ! dpkg-statoverride --list "/var/log/coquelicot"; then
 		chown root:coquelicot /var/log/coquelicot
 		chmod 770 /var/log/coquelicot
diff --git a/debian/coquelicot.postrm b/debian/coquelicot.postrm
index 12a1988..f1590bf 100755
--- a/debian/coquelicot.postrm
+++ b/debian/coquelicot.postrm
@@ -7,6 +7,7 @@ case "$1" in
 	rm -rf /etc/coquelicot
 	rm -rf /var/run/coquelicot
 	rm -rf /var/lib/coquelicot
+	rm -rf /var/cache/coquelicot
 	rm -rf /var/log/coquelicot
 	;;
     *)
diff --git a/debian/patches/0011-Improve-running-as-non-root.patch b/debian/patches/0011-Improve-running-as-non-root.patch
index 076cf05..7d8f100 100644
--- a/debian/patches/0011-Improve-running-as-non-root.patch
+++ b/debian/patches/0011-Improve-running-as-non-root.patch
@@ -4,6 +4,10 @@ Forwarded: not-needed
 Last-Update: 2015-03-05
 ---
 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+---
+ lib/coquelicot/app.rb |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
 --- a/lib/coquelicot/app.rb
 +++ b/lib/coquelicot/app.rb
 @@ -240,7 +240,7 @@
diff --git a/debian/patches/0012-Fix-sass-cache-location-on-jessie.patch b/debian/patches/0012-Fix-sass-cache-location-on-jessie.patch
new file mode 100644
index 0000000..1ca4aab
--- /dev/null
+++ b/debian/patches/0012-Fix-sass-cache-location-on-jessie.patch
@@ -0,0 +1,113 @@
+Description: Force sane sass-cache location (avoids permissions problems on Jessie)
+Author: Rowan Thorpe <[email protected]>
+Forwarded: not-needed
+Last-Update: 2015-05-15
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+---
+ HACKING                     |    4 +++-
+ conf/settings-default.yml   |    4 ++++
+ lib/coquelicot/app.rb       |    4 +++-
+ spec/coquelicot/app_spec.rb |    8 ++++++++
+ spec/spec_helper.rb         |    8 ++++++++
+ 5 files changed, 26 insertions(+), 2 deletions(-)
+
+--- a/HACKING
++++ b/HACKING
+@@ -131,7 +131,9 @@
+ Storage details
+ ---------------
+ 
+-Files are stored in the directory specified by the 'depot_path' setting.
++Files are stored in the directory specified by the 'depot_path' setting, and
++cache files are stored in the directory specified by the 'cache_path'
++setting.
+ One file in Coquelicot is actually stored in two files: one for metadata and
+ one for the file content.
+ 
+--- a/conf/settings-default.yml
++++ b/conf/settings-default.yml
+@@ -70,6 +70,10 @@
+ #
+ depot_path: "./files"
+ 
++# Cache directory in which Coquelicot will write cache files
++#
++cache_path: "./cache"
++
+ # Text to display on top of the upload form
+ #
+ #   This is indexed by locale code to support multiple languages.
+--- a/spec/coquelicot/app_spec.rb
++++ b/spec/coquelicot/app_spec.rb
+@@ -321,7 +321,7 @@
+       around(:each) do |example|
+         settings = Tempfile.new('coquelicot')
+         begin
+-          settings.write(YAML.dump({ 'depot_path' => '/nonexistent' }))
++          settings.write(YAML.dump({ 'depot_path' => '/nonexistent', 'cache_path' => '/nonexistent2' }))
+           settings.close
+           @settings_path = settings.path
+           example.run
+@@ -336,6 +336,13 @@
+         end
+         expect(Coquelicot.settings.depot_path).to be == '/nonexistent'
+       end
++      it 'should use the cache path defined in the given settings' do
++        # We don't give a command, so exit is expected
++        stderr = capture(:stderr) do
++          expect { Coquelicot.run! ['-c', @settings_path] }.to raise_error(SystemExit)
++        end
++        expect(Coquelicot.settings.cache_path).to be == '/nonexistent2'
++      end
+     end
+     context 'when the given settings file does not exist' do
+       it 'should display an error' do
+--- a/spec/spec_helper.rb
++++ b/spec/spec_helper.rb
+@@ -48,9 +48,12 @@
+ 
+   around(:each) do |example|
+     path = Dir.mktmpdir('coquelicot')
++    path2 = Dir.mktmpdir('coquelicot')
+     begin
+       @depot_path = path
++      @cache_path = path2
+       app.set :depot_path, path
++      app.set :cache_path, path2
+       example.run
+     ensure
+       FileUtils.remove_entry_secure path
+--- a/lib/coquelicot/app.rb
++++ b/lib/coquelicot/app.rb
+@@ -37,6 +37,13 @@
+       @depot = Depot.new(settings.depot_path) if @depot.nil? || settings.depot_path != @depot.path
+       @depot
+     end
++    def cache
++      if @cache.nil?
++        @cache = File.join(settings.cache_path, 'sass-cache')
++        FileUtils.mkdir_p(@cache)
++      end
++      @cache
++    end
+     # Called by the +coquelicot+ script.
+     def run!(args = [])
+       parser = OptionParser.new do |opts|
+@@ -232,6 +239,7 @@
+                                              File.join(root, 'public') :
+                                              '/usr/share/coquelicot/public' }
+     set :depot_path, '/var/lib/coquelicot'
++    set :cache_path, '/var/cache/coquelicot'
+     set :max_file_size, 5 * 1024 * 1024 # 5 MiB
+     set :default_expire, 60
+     set :maximum_expire, 60 * 24 * 30 # 1 month
+@@ -280,7 +288,7 @@
+ 
+     get '/style.css' do
+       content_type 'text/css', :charset => 'utf-8'
+-      sass :style
++      sass :style, :cache_location => Coquelicot.cache
+     end
+ 
+     get '/' do
diff --git a/debian/patches/series b/debian/patches/series
index f0b777a..a742015 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,4 @@
 0006-Stop-using-non-free-background-image.patch
 0010-Fix-gem-dependency-issues.patch
 0011-Improve-running-as-non-root.patch
+0012-Fix-sass-cache-location-on-jessie.patch
diff --git a/debian/settings.yml b/debian/settings.yml
index 0d2d3ba..ab31665 100644
--- a/debian/settings.yml
+++ b/debian/settings.yml
@@ -70,6 +70,10 @@ random_pass_length: 16
 #
 depot_path: "/var/lib/coquelicot"
 
+# Cache directory in which Coquelicot will write cache files
+#
+cache_path: "/var/cache/coquelicot"
+
 # Text to display on top of the upload form
 #
 #   This is indexed by locale code to support multiple languages.
-- 
2.1.4

Reply via email to