Package: coquelicot Version: 0.9.3-1 Tags: patch Control: block -1 by 782634
This patch follows from #782634, and adds configurable cache location (and sets it to something sane for Debian, because otherwise the default sass-cache location when running as a daemon is /.sass-cache, which breaks with permissions errors. Although I marked the patch as "Forwarded: not-needed", you may wish to add cache_path to upstream's default config too, with a local setting like "./cache", in which case feel free to forward this to yourself :-D and add that line. As mentioned before, I am not so familiar with Ruby idioms, so although I also took a stab at updating the various spec/etc files for the new config-var, I strongly recommend reviewing those bits, as I probably got something wrong with them. -- 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 8a93d4c2ff446a18532a45412a6392ec81403983 Mon Sep 17 00:00:00 2001 From: Rowan Thorpe <ro...@rowanthorpe.com> Date: Fri, 15 May 2015 15:44:33 +0300 Subject: [PATCH] Add configurable cache location (needed in Jessie) * This adds a configurable cache location, and sets a sane default for debian - which is in fact necessary for >= Jessie, as otherwise the default sass-cache location is /.sass-cache which causes permissions problems * I also included a small sneaky improvement to the header of the previous debian-diff --- debian/coquelicot.postinst | 4 + .../patches/0011-Improve-running-as-non-root.patch | 4 + .../0012-Fix-sass-cache-location-on-jessie.patch | 108 +++++++++++++++++++++ debian/patches/series | 1 + debian/settings.yml | 4 + 5 files changed, 121 insertions(+) create mode 100644 debian/patches/0012-Fix-sass-cache-location-on-jessie.patch 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/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..d20b5f3 --- /dev/null +++ b/debian/patches/0012-Fix-sass-cache-location-on-jessie.patch @@ -0,0 +1,108 @@ +Description: Force sane sass-cache location (avoids permissions problems on Jessie) +Author: Rowan Thorpe <ro...@rowanthorpe.com> +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 throwaway 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 +@@ -322,6 +322,7 @@ + settings = Tempfile.new('coquelicot') + begin + settings.write(YAML.dump({ 'depot_path' => '/nonexistent' })) ++ settings.write(YAML.dump({ 'cache_path' => '/nonexistent2' })) + settings.close + @settings_path = settings.path + example.run +@@ -336,6 +337,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 +@@ -55,6 +55,14 @@ + ensure + FileUtils.remove_entry_secure path + end ++ path = Dir.mktmpdir('coquelicot') ++ begin ++ @cache_path = path ++ app.set :cache_path, path ++ example.run ++ ensure ++ FileUtils.remove_entry_secure path ++ end + end + end + +--- a/lib/coquelicot/app.rb ++++ b/lib/coquelicot/app.rb +@@ -232,6 +232,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 +@@ -255,6 +256,7 @@ + use Coquelicot::Rack::Upload + # limit requests other than upload to an input body of 5 kiB max + use Rainbows::MaxBody, 5 * 1024 ++ FileUtils.mkdir_p(File.join(settings.cache_path, 'sass-cache')) + + not_found do + @uri = env['REQUEST_URI'] +@@ -280,7 +282,7 @@ + + get '/style.css' do + content_type 'text/css', :charset => 'utf-8' +- sass :style ++ sass :style, :cache_location => File.join(settings.cache_path, 'sass-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..0951409 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 throwaway 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