diff --git a/app/models/image.rb b/app/models/image.rb index 1d4a7aa..3390cd2 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -7,6 +7,7 @@ class Image < ActiveRecord::Base has_attachment :content_type => :image, :storage => :file_system, + :path_prefix => 'public/image_uploads', :resize_to => '320x200>', :thumbnails => { :big => '150x150', :thumb => '100x100', diff --git a/config/environment.rb b/config/environment.rb index fefea3b..12d0059 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -19,7 +19,7 @@ extra_controller_dirs = %w[ ].map {|item| File.join(RAILS_ROOT, item) } def noosfero_session_secret - file = File.join(File.dirname(__FILE__), 'session.secret') + file = File.join(File.dirname(__FILE__), '/../tmp/session.secret') if !File.exists?(file) secret = (1..128).map { %w[0 1 2 3 4 5 6 7 8 9 a b c d e f][rand(16)] }.join('') File.open(file, 'w') do |f| @@ -56,7 +56,14 @@ Rails::Initializer.run do |config| # config.active_record.observers = :cacher, :garbage_collector # don't load the sweepers while loading the database - unless $PROGRAM_NAME =~ /rake$/ && (ARGV.first == 'db:schema:load' || ARGV.first == 'gems:install') + ignore_rake_commands = %w[ + db:schema:load + gems:install + clobber + noosfero:translations:compile + makemo + ] + unless $PROGRAM_NAME =~ /rake$/ && (ignore_rake_commands.include?(ARGV.first)) config.active_record.observers = :article_sweeper, :role_assignment_sweeper, :friendship_sweeper, :category_sweeper end # Make Active Record use UTC-base instead of local time diff --git a/config/initializers/default_icon_theme.rb b/config/initializers/default_icon_theme.rb index 194241c..f59cc27 100644 --- a/config/initializers/default_icon_theme.rb +++ b/config/initializers/default_icon_theme.rb @@ -1,11 +1,13 @@ -# create the symlink to the default theme if it does not exist -default = File.join(RAILS_ROOT, 'public', 'designs', 'icons', 'default') -if !File.exists?(default) - File.symlink('tango', default) -end +if File.writable?(Rails.root) + # create the symlink to the default theme if it does not exist + default = File.join(RAILS_ROOT, 'public', 'designs', 'icons', 'default') + if !File.exists?(default) + File.symlink('tango', default) + end -# create a symlink to system-wide Tango icon set if it does not exist -tango_symlink = File.join(RAILS_ROOT, 'public', 'designs', 'icons', 'tango', 'Tango') -if !File.exist?(tango_symlink) - File.symlink('/usr/share/icons/Tango', tango_symlink) + # create a symlink to system-wide Tango icon set if it does not exist + tango_symlink = File.join(RAILS_ROOT, 'public', 'designs', 'icons', 'tango', 'Tango') + if !File.exist?(tango_symlink) + File.symlink('/usr/share/icons/Tango', tango_symlink) + end end diff --git a/config/initializers/default_theme.rb b/config/initializers/default_theme.rb index 6045a1a..b2bfae8 100644 --- a/config/initializers/default_theme.rb +++ b/config/initializers/default_theme.rb @@ -1,5 +1,7 @@ -# create the symlink to the default theme if it does not exist -default = File.join(RAILS_ROOT, 'public', 'designs', 'themes', 'default') -if !File.exists?(default) - File.symlink('noosfero', default) +if File.writable?(Rails.root) + # create the symlink to the default theme if it does not exist + default = File.join(RAILS_ROOT, 'public', 'designs', 'themes', 'default') + if !File.exists?(default) + File.symlink('noosfero', default) + end end diff --git a/config/initializers/image_uploads.rb b/config/initializers/image_uploads.rb new file mode 100644 index 0000000..faa7d22 --- /dev/null +++ b/config/initializers/image_uploads.rb @@ -0,0 +1,12 @@ +if File.writable?(Rails.root) + misplaced_directories = Dir.glob(Rails.root + '/public/images/[0-9]*') + unless misplaced_directories.empty? + new_location = Rails.root + '/public/image_uploads' + if !File.exists?(new_location) + FileUtils.mkdir(new_location) + end + misplaced_directories.each do |path| + FileUtils.mv(path, new_location) + end + end +end diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..aaa2d81 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,13 @@ +Noosfero for Debian +------------------- + +In order to function properly, Noosfero needs a working e-mail setup. You need +to make sure that your local MTA is able to deliver messages to the internet. + +Alternatively, you can also configure Noosfero to use an external SMTP server +by means of the file /etc/noosfero/local.rb. To do that, follow the +instructions at the following URL: + +http://noosfero.org/Development/SMTPMailSending + + -- Antonio Terceiro Thu, 27 Jan 2011 19:48:03 -0300 diff --git a/debian/TODO b/debian/TODO new file mode 100644 index 0000000..cf39201 --- /dev/null +++ b/debian/TODO @@ -0,0 +1,25 @@ +================================================================================= + +install config/noosfero.yml + +how to handle local themes? + +create admin user during installation using debconf to prompt for password + +the `noosfero` postgres user must have permission to drop and create schemas. + +e-mail setup? +noosfero setup + +install varnish conf - create package noosfero-varnish? + +remove /etc/noosfero/database.yml in postrm/purge! + +remove /etc/noosfero in postrm/purge! in special: + /etc/noosfero/apache/mongrel.conf + +fix problems reported by lintian (start by removing the overrides) + +try to get rid of dependencies that should be needed only in development (such +as rcov) + diff --git a/debian/apache2/conf.d/noosfero-mongrel.conf b/debian/apache2/conf.d/noosfero-mongrel.conf new file mode 100644 index 0000000..380f671 --- /dev/null +++ b/debian/apache2/conf.d/noosfero-mongrel.conf @@ -0,0 +1,7 @@ + + Include /etc/noosfero/apache/mongrel.conf + Order Allow,Deny + Allow from All + + +# vim: ft=apache diff --git a/debian/apache2/virtualhost.conf b/debian/apache2/virtualhost.conf new file mode 100644 index 0000000..ac7b299 --- /dev/null +++ b/debian/apache2/virtualhost.conf @@ -0,0 +1,38 @@ +DocumentRoot "/usr/share/noosfero/public" + + Options FollowSymLinks -Indexes + AllowOverride None + Order Allow,Deny + Allow from all + + +RewriteEngine On + +# Rewrite index to check for static index.html +RewriteRule ^/$ /index.html [QSA] + +# Rewrite to check for Rails cached page +RewriteRule ^([^.]+)$ $1.html [QSA] + +RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f +RewriteRule ^.*$ balancer://noosfero%{REQUEST_URI} [P,QSA,L] + +ErrorDocument 503 /503.html + +ErrorLog /var/log/apache2/noosfero.log +LogLevel warn +CustomLog /var/log/apache2/noosfero.access.log vhost_combined + +# Compress outgoing text content +AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript + +# Add Expires: header +ExpiresActive On +ExpiresByType text/css "access plus 1 month" +ExpiresByType application/javascript "access plus 1 month" +ExpiresByType image/png "access plus 1 month" +ExpiresByType image/gif "access plus 1 month" +ExpiresByType image/jpeg "access plus 1 month" +ExpiresByType image/x-icon "access plus 1 month" + +# vim: ft=apache diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..69a4bb2 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +noosfero (0.28.0~1) unstable; urgency=low + + * Initial Release. + + -- Antonio Terceiro Thu, 27 Jan 2011 09:49:08 -0300 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..3184031 --- /dev/null +++ b/debian/control @@ -0,0 +1,33 @@ +Source: noosfero +Section: web +Priority: extra +Maintainer: Noosfero developers +Uploaders: Antonio Terceiro +Build-Depends: debhelper (>= 7.0.50~), po4a, libgettext-ruby-util, libgettext-ruby1.8, libsqlite3-ruby1.8, +Standards-Version: 3.8.4 +Homepage: http://noosfero.org/ +Vcs-Git: git://git.colivre.coop.br/noosfero.git +Vcs-Browser: http://git.colivre.coop.br/?p=noosfero.git + +Package: noosfero +Architecture: all +Depends: rails, ruby1.8, ruby, rake, libgettext-ruby-data, libsqlite3-ruby, libpgsql-ruby, libmysql-ruby, librmagick-ruby, libredcloth-ruby, libwill-paginate-ruby, iso-codes, libfeedparser-ruby, libferret-ruby, libdaemons-ruby, rcov, mongrel, mongrel-cluster, tango-icon-theme, libhpricot-ruby, iso-codes, memcached, debconf, dbconfig-common, postgresql, adduser, ${misc:Depends} +Recommends: postgresql-client +Description: free web-based platform for social networks + Noosfero is a web platform for social and solidarity economy networks with + blog, e-Porfolios, CMS, RSS, thematic discussion, events agenda and collective + inteligence for solidarity economy in the same system. + . + This package contains the Noosfero application server. + +Package: noosfero-apache +Architecture: all +Depends: apache2, debconf +Suggests: noosfero +Description: free web-based platform for social networks (apache frontend) + Noosfero is a web platform for social and solidarity economy networks with + blog, e-Porfolios, CMS, RSS, thematic discussion, events agenda and collective + inteligence for solidarity economy in the same system. + . + This package contains the configuration files needed to run Noosfero with the + Apache HTTPD server as frontend. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..5d56851 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,35 @@ +This work was packaged for Debian by: + + Antonio Terceiro on Thu, 25 Nov 2010 16:42:48 -0300 + +It was downloaded from: + + + +Upstream Authors: + + Too many to list here. See /usr/share/doc/noosfero/AUTHORS + +Copyright: + + Copyright (c) 2007-2009, Cáritas Brasileira + Copyright (c) 2007-2009, Ynternet.org Foundation + Copyright (c) 2008-2011, Colivre + +License: + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +The Debian packaging files are part of Noosfero source code, and are covered by +the same copyrights and licensing as the rest of the project. diff --git a/debian/database.yml.template b/debian/database.yml.template new file mode 100644 index 0000000..113087a --- /dev/null +++ b/debian/database.yml.template @@ -0,0 +1,8 @@ +production: + adapter: _DBC_DBTYPE_ + database: _DBC_DBNAME_ + encoding: unicode + username: _DBC_DBUSER_ + password: _DBC_DBPASS_ + + diff --git a/debian/dbinstall b/debian/dbinstall new file mode 100755 index 0000000..5900966 --- /dev/null +++ b/debian/dbinstall @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +# dbconfig-common uses "pgsql", but we want "postgresql" +sed -i -e 's/adapter: pgsql/adapter: postgresql/' /etc/noosfero/database.yml + +/etc/init.d/noosfero setup + +cd /usr/share/noosfero && su noosfero -c "rake db:schema:load RAILS_ENV=production" +cd /usr/share/noosfero && su noosfero -c "rake db:data:minimal RAILS_ENV=production" diff --git a/debian/dbupgrade b/debian/dbupgrade new file mode 100755 index 0000000..653cbf9 --- /dev/null +++ b/debian/dbupgrade @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +/etc/init.d/noosfero setup + +cd /usr/share/noosfero && su noosfero -c "rake db:migrate RAILS_ENV=production SCHEMA=/dev/null" + diff --git a/debian/default/noosfero b/debian/default/noosfero new file mode 100644 index 0000000..4a314e4 --- /dev/null +++ b/debian/default/noosfero @@ -0,0 +1,2 @@ +NOOSFERO_DIR="/usr/share/noosfero" +NOOSFERO_USER="noosfero" diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..62deb04 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +AUTHORS diff --git a/debian/ferret_server.yml b/debian/ferret_server.yml new file mode 100644 index 0000000..1b2010f --- /dev/null +++ b/debian/ferret_server.yml @@ -0,0 +1,4 @@ +production: + host: localhost + port: 51000 + pid_file: tmp/pids/ferret.production.pid diff --git a/debian/mongrel_cluster.yml b/debian/mongrel_cluster.yml new file mode 100644 index 0000000..077236e --- /dev/null +++ b/debian/mongrel_cluster.yml @@ -0,0 +1,10 @@ +--- +address: 127.0.0.1 +cwd: /usr/share/noosfero +environment: production +group: noosfero +log_file: log/mongrel.log +pid_file: tmp/pids/mongrel.pid +port: 50000 +servers: 1 +user: noosfero diff --git a/debian/noosfero-apache.config b/debian/noosfero-apache.config new file mode 100644 index 0000000..8bfd361 --- /dev/null +++ b/debian/noosfero-apache.config @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +db_input medium noosfero-apache/enable_apache_site || true +db_go + +#DEBHELPER# diff --git a/debian/noosfero-apache.dirs b/debian/noosfero-apache.dirs new file mode 100644 index 0000000..4183e3d --- /dev/null +++ b/debian/noosfero-apache.dirs @@ -0,0 +1 @@ +etc/noosfero/apache diff --git a/debian/noosfero-apache.install b/debian/noosfero-apache.install new file mode 100644 index 0000000..f9580c4 --- /dev/null +++ b/debian/noosfero-apache.install @@ -0,0 +1,3 @@ +debian/apache2/conf.d/noosfero-mongrel.conf etc/apache2/conf.d +debian/apache2/virtualhost.conf etc/noosfero/apache +debian/update-noosfero-apache usr/sbin diff --git a/debian/noosfero-apache.postinst b/debian/noosfero-apache.postinst new file mode 100644 index 0000000..800c495 --- /dev/null +++ b/debian/noosfero-apache.postinst @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +db_get noosfero-apache/enable_apache_site +enable_apache_site="$RET" + +if test -x /usr/sbin/a2enmod; then + a2enmod deflate expires proxy proxy_balancer proxy_http rewrite +fi + +if which update-noosfero-apache >/dev/null; then + + + update-noosfero-apache + + if [ "$enable_apache_site" = 'true' ]; then + a2ensite noosfero + invoke-rc.d apache2 reload + fi +fi + +#DEBHELPER# diff --git a/debian/noosfero-apache.templates b/debian/noosfero-apache.templates new file mode 100644 index 0000000..1a62f58 --- /dev/null +++ b/debian/noosfero-apache.templates @@ -0,0 +1,13 @@ +Template: noosfero-apache/enable_apache_site +Type: boolean +Default: true +Description: Enable Noosfero in Apache? + If you choose "Yes" here, them Noosfero's apache site will be automatically + enabled and Noosfero will be immediately available through Apache using the + domain name you choose before. + . + This option will not interfere with anything besides the domain name you chose + for your Noosfero site, so if this is a new server installation, you should + probably answer "Yes". If, for any reason, you do not want to enable Noosfero + in Apache right now, then you should answer "No". You can enable Noosfero + later by running `a2ensite nooosfero`. diff --git a/debian/noosfero.config b/debian/noosfero.config new file mode 100644 index 0000000..6a773d8 --- /dev/null +++ b/debian/noosfero.config @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule +if [ -f /usr/share/dbconfig-common/dpkg/config ]; then + # comma-separated, e.g. "mysql, pgsql, sqlite3" + dbc_dbtypes="pgsql" + + . /usr/share/dbconfig-common/dpkg/config + dbc_go noosfero $@ + + if [ "$dbc_install" = 'true' ]; then + db_input high noosfero/initial_domain || true + db_go + fi + + db_input high noosfero/email_setup_warning | true + db_go + +fi diff --git a/debian/noosfero.dirs b/debian/noosfero.dirs new file mode 100644 index 0000000..ff47a9f --- /dev/null +++ b/debian/noosfero.dirs @@ -0,0 +1,3 @@ +etc/noosfero +etc/noosfero/plugins +usr/share/noosfero/locale diff --git a/debian/noosfero.install b/debian/noosfero.install new file mode 100644 index 0000000..751fdd2 --- /dev/null +++ b/debian/noosfero.install @@ -0,0 +1,35 @@ +app usr/share/noosfero +db usr/share/noosfero +doc usr/share/noosfero +lib usr/share/noosfero +script usr/share/noosfero +util usr/share/noosfero +Rakefile usr/share/noosfero +vendor/cardmagic-contacts-f66219e6589ccaf3ab9e3574fdd41225d0dd5073 usr/share/noosfero/vendor +vendor/gdata-1.1.1 usr/share/noosfero/vendor +vendor/plugins usr/share/noosfero/vendor +vendor/terceiro-fast_gettext-fe7bb09e30f7b1b5876a3b7a18fe8a254c6f59cb usr/share/noosfero/vendor +vendor/ezcrypto-0.7.2 usr/share/noosfero/vendor + +config/boot.rb usr/share/noosfero/config +config/environment.rb usr/share/noosfero/config +config/environments usr/share/noosfero/config +config/initializers usr/share/noosfero/config +config/routes.rb usr/share/noosfero/config + +plugins usr/share/noosfero + +debian/dbinstall usr/lib/noosfero +debian/dbupgrade usr/lib/noosfero +debian/database.yml.template usr/share/noosfero/config + +public usr/share/noosfero + +debian/default/noosfero etc/default +etc/init.d/noosfero etc/init.d +debian/mongrel_cluster.yml etc/noosfero +debian/ferret_server.yml etc/noosfero +etc/logrotate.d/noosfero etc/logrotate.d + +locale usr/share/noosfero +doc/noosfero usr/share/noosfero/doc diff --git a/debian/noosfero.links b/debian/noosfero.links new file mode 100644 index 0000000..97312ba --- /dev/null +++ b/debian/noosfero.links @@ -0,0 +1,19 @@ +usr/share/rails usr/share/noosfero/vendor/rails +var/tmp/noosfero usr/share/noosfero/tmp +var/log/noosfero usr/share/noosfero/log +etc/noosfero/database.yml usr/share/noosfero/config/database.yml +etc/noosfero/mongrel_cluster.yml usr/share/noosfero/config/mongrel_cluster.yml +etc/noosfero/ferret_server.yml usr/share/noosfero/config/ferret_server.yml +etc/noosfero/plugins usr/share/noosfero/config/plugins +etc/noosfero/noosfero.yml usr/share/noosfero/config/noosfero.yml +etc/noosfero/local.rb usr/share/noosfero/config/local.rb +var/lib/noosfero-data/index usr/share/noosfero/index +var/lib/noosfero-data/cache/cache-general.js usr/share/noosfero/public/javascripts/cache-general.js +var/lib/noosfero-data/cache/cache-chat.js usr/share/noosfero/public/javascripts/cache-chat.js +var/lib/noosfero-data/cache/cache-slideshow.js usr/share/noosfero/public/javascripts/cache-slideshow.js +var/lib/noosfero-data/cache/cache.css usr/share/noosfero/public/stylesheets/cache.css +var/lib/noosfero-data/public/articles usr/share/noosfero/public/articles +var/lib/noosfero-data/public/image_uploads usr/share/noosfero/public/image_uploads +var/lib/noosfero-data/public/thumbnails usr/share/noosfero/public/thumbnails +usr/share/noosfero/public/designs/themes/noosfero usr/share/noosfero/public/designs/themes/default +usr/share/noosfero/public/designs/icons/tango usr/share/noosfero/public/designs/icons/icons/default diff --git a/debian/noosfero.lintian-overrides b/debian/noosfero.lintian-overrides new file mode 100644 index 0000000..3c57d11 --- /dev/null +++ b/debian/noosfero.lintian-overrides @@ -0,0 +1,6 @@ +noosfero binary: python-script-but-no-python-dep +noosfero binary: script-not-executable +noosfero binary: executable-not-elf-or-script +noosfero binary: extra-license-file +noosfero binary: embedded-javascript-library +noosfero binary: package-contains-vcs-control-file diff --git a/debian/noosfero.postinst b/debian/noosfero.postinst new file mode 100644 index 0000000..21c6dad --- /dev/null +++ b/debian/noosfero.postinst @@ -0,0 +1,59 @@ +#!/bin/sh + +set -e + +makedir() { + if [ ! -d $1 ]; then + mkdir $1 + fi + chown noosfero:noosfero $1 +} + +# create user noosfero in a portable way, while creating the log directory. +# (idea taken from the postfix package) +############################################################################## +if [ ! -d /var/log/noosfero ]; then + mkdir /var/log/noosfero +fi +chgrp noosfero /var/log/noosfero 2>/dev/null || + addgroup --system noosfero +chown noosfero /var/log/noosfero 2>/dev/null || + adduser --system --home /usr/share/noosfero --shell /bin/sh --no-create-home --disabled-password --ingroup noosfero noosfero + +# create noosfero dynamic data directories +############################################################################## +noosfero_data_dir='/var/lib/noosfero-data' +makedir $noosfero_data_dir +makedir $noosfero_data_dir/index +makedir $noosfero_data_dir/cache +makedir $noosfero_data_dir/public +makedir $noosfero_data_dir/public/articles +makedir $noosfero_data_dir/public/image_uploads +makedir $noosfero_data_dir/public/thumbnails + +# Instruct dbconfig-common to generate database configuration file +############################################################################## +noosfero_database_yml="/etc/noosfero/database.yml" +dbc_generate_include="template:$noosfero_database_yml" +dbc_generate_include_args="-o template_infile=/usr/share/noosfero/config/database.yml.template" +dbc_generate_include_owner="root:noosfero" +dbc_generate_include_perms="640" + +. /usr/share/debconf/confmodule + +db_get noosfero/initial_domain +if [ ! -z "$RET" ]; then + # this is going to be used by the db:data:minimal rake task, called by + # /usr/lib/noosfero/dbinstall + export NOOSFERO_DOMAIN="$RET" +fi + +# dbconfig-common magic +. /usr/share/dbconfig-common/dpkg/postinst +dbc_go noosfero $@ + +# stop debconf to avoid the problem with infinite hanging, cfe +# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295477 +db_stop + +#DEBHELPER# diff --git a/debian/noosfero.postrm b/debian/noosfero.postrm new file mode 100644 index 0000000..162624f --- /dev/null +++ b/debian/noosfero.postrm @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule +if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then + . /usr/share/dbconfig-common/dpkg/postrm + dbc_go noosfero $@ +fi +db_purge + +#DEBHELPER# diff --git a/debian/noosfero.prerm b/debian/noosfero.prerm new file mode 100644 index 0000000..a25c14b --- /dev/null +++ b/debian/noosfero.prerm @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule +. /usr/share/dbconfig-common/dpkg/prerm +dbc_go noosfero $@ + +#DEBHELPER# + +# some dirty work is needed after Noosfero is stopped +if [ "$1" = "upgrade" ]; then + # delete cached files + rm -f /var/lib/noosfero-data/cache/* + + # restart memcache + invoke-rc.d memcached restart + + # stop debconf to avoid the problem with infinite hanging, cfe + # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295477 + db_stop +fi diff --git a/debian/noosfero.templates b/debian/noosfero.templates new file mode 100644 index 0000000..06bbec8 --- /dev/null +++ b/debian/noosfero.templates @@ -0,0 +1,20 @@ +Template: noosfero/initial_domain +Type: string +Description: Domain name for your noosfero site: + Enter the domain name that will be used for your Noosfero site. This domain + name will be automatically added to Noosfero's database. The Noosfero frontend + packages (such as noosfero-apache) will also automatically configure proper + virtual hosts to respond for this domain name. + . + If you do not enter a domain name here, you will have to make some further + manual configuration to have your frontend server properly configured. + +Template: noosfero/email_setup_warning +Type: note +Description: Noosfero needs a working e-mail setup + To function properly, Noosfero needs a working e-mail setup. This is used to + send friendship request e-mails, recovering passwords, and other things. + . + Basically, your local MTA needs to deliver e-mail to the internet. Please + check /usr/share/doc/noosfero/README.Debian for detailed instructions on + settings this up. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..aa91a5d --- /dev/null +++ b/debian/rules @@ -0,0 +1,32 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +VERSION = $(shell dpkg-parsechangelog | grep '^Version:' | cut -d ' ' -f 2) +# to support new databases, change debian/noosfero.config! +SUPPORTED_DATABASES = $(shell sed -e '/dbc_dbtypes=/!d; s/.*"\(.*\)".*/\1/; s/,//g' debian/noosfero.config) + +%: + dh --without=python-support $@ + +override_dh_link: + dh_link + for db in $(SUPPORTED_DATABASES); do \ + dh_link usr/lib/noosfero/dbupgrade usr/share/dbconfig-common/scripts/noosfero/upgrade/$$db/$(VERSION); \ + dh_link usr/lib/noosfero/dbinstall usr/share/dbconfig-common/scripts/noosfero/install/$$db; \ + done + +override_dh_installinit: + dh_installinit -pnoosfero --onlyscripts + +override_dh_clean: + dh_clean + rake clobber + +override_dh_auto_build: + dh_auto_build + rake noosfero:translations:compile diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 0000000..75c3dbe --- /dev/null +++ b/debian/source/lintian-overrides @@ -0,0 +1 @@ +noosfero source: python-script-but-no-python-dep diff --git a/debian/update-noosfero-apache b/debian/update-noosfero-apache new file mode 100755 index 0000000..ee164d2 --- /dev/null +++ b/debian/update-noosfero-apache @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +# automatically update configuration, but if package noosfero is also installed +if test -x /usr/share/noosfero/script/apacheconf; then + datadir="/etc/noosfero/apache" + mongrel_file="$datadir/mongrel.conf" + if test -e "$mongrel_file"; then + echo "Overwriting $mongrel_file ..." + fi + /usr/share/noosfero/script/apacheconf mongrel > "$mongrel_file" + + apache_site='/etc/apache2/sites-available/noosfero' + if ! test -e "$apache_site"; then + echo "Generating apache virtual host ..." + cd /usr/share/noosfero && su noosfero -c "RAILS_ENV=production ./script/apacheconf virtualhosts" > "$apache_site" + fi + + echo 'Noosfero Apache configuration updated.' + echo "Run '/etc/init.d/apache2 reload' to activate new configuration!" +fi diff --git a/etc/init.d/noosfero b/etc/init.d/noosfero index ed8885c..f6d44ab 100755 --- a/etc/init.d/noosfero +++ b/etc/init.d/noosfero @@ -1,6 +1,6 @@ #! /bin/sh ### BEGIN INIT INFO -# Provides: skeleton +# Provides: noosfero # Required-Start: $remote_fs # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 @@ -122,8 +122,11 @@ case "$1" in start|stop|restart|setup) do_$1 ;; + force-reload) + do_restart + ;; *) - echo "Usage: $SCRIPTNAME {start|stop|restart|setup}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|setup}" >&2 exit 3 ;; esac diff --git a/gitignore.example b/gitignore.example index 23d4b2d..07bfd11 100644 --- a/gitignore.example +++ b/gitignore.example @@ -12,7 +12,7 @@ index locale log public/articles -public/images/0000 +public/image_uploads public/thumbnails public/user_themes public/designs/themes/default diff --git a/lib/noosfero/i18n.rb b/lib/noosfero/i18n.rb index 94ca194..a7f8859 100644 --- a/lib/noosfero/i18n.rb +++ b/lib/noosfero/i18n.rb @@ -153,31 +153,14 @@ module ActionController::Caching::Fragments alias_method_chain :expire_fragment, :fast_gettext end -FileUtils.mkdir_p(Rails.root + '/locale') -Dir.glob(Rails.root + '/locale/*').each do |dir| - lang = File.basename(dir) - FileUtils.mkdir_p("#{Rails.root}/locale/#{lang}/LC_MESSAGES") - ['iso_3166', 'rails'].each do |domain| - target = "#{Rails.root}/locale/#{lang}/LC_MESSAGES/#{domain}.mo" - if !File.exists?(target) - orig = "/usr/share/locale/#{lang}/LC_MESSAGES/#{domain}.mo" - if File.exists?(orig) - File.symlink(orig, target) - else - alternatives = Dir.glob("/usr/share/locale/#{lang}_*/LC_MESSAGES/#{domain}.mo") - unless alternatives.empty? - File.symlink(alternatives.first, target) - end - end - end - end +# translations in place? +if File.exists?(Rails.root + '/locale') + repos = [ + FastGettext::TranslationRepository.build('noosfero', :type => 'mo', :path => Rails.root + '/locale'), + FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => Rails.root + '/locale'), + FastGettext::TranslationRepository.build('rails', :type => 'mo', :path => Rails.root + '/locale'), + ] + + FastGettext.add_text_domain 'noosferofull', :type => :chain, :chain => repos + FastGettext.default_text_domain = 'noosferofull' end - -repos = [ - FastGettext::TranslationRepository.build('noosfero', :type => 'mo', :path => Rails.root + '/locale'), - FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => Rails.root + '/locale'), - FastGettext::TranslationRepository.build('rails', :type => 'mo', :path => Rails.root + '/locale'), -] - -FastGettext.add_text_domain 'noosferofull', :type => :chain, :chain => repos -FastGettext.default_text_domain = 'noosferofull' diff --git a/lib/tasks/clean.rake b/lib/tasks/clean.rake new file mode 100644 index 0000000..5efac37 --- /dev/null +++ b/lib/tasks/clean.rake @@ -0,0 +1,28 @@ +task :clean => 'noosfero:clean' + +namespace :noosfero do + task :clean do + + if Rails.env == 'production' + raise 'You should NOT run this in production mode!' + end + + clean_patterns = %w[ + db/*.db + public/javascripts/cache*.js + public/stylesheets/cache*.css + public/designs/themes/default + public/designs/icons/default + public/articles/ + public/image_uploads/ + public/thumbnails/ + locale/ + ] + clean_patterns << Dir.glob('public/designs/themes/*').select { |f| File.symlink?(f) } + + clean_patterns.each do |pattern| + list = Dir.glob(pattern) + rm_rf list unless list.empty? + end + end +end diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake new file mode 100644 index 0000000..32a6555 --- /dev/null +++ b/lib/tasks/data.rake @@ -0,0 +1,10 @@ +namespace :db do + namespace :data do + task :minimal do + environment = Environment.create!(:name => 'Noosfero', :is_default => true) + unless ENV['NOOSFERO_DOMAIN'].blank? + environment.domains << Domain.new(:name => ENV['NOOSFERO_DOMAIN']) + end + end + end +end diff --git a/lib/tasks/doc.rake b/lib/tasks/doc.rake index 314114f..317f28a 100644 --- a/lib/tasks/doc.rake +++ b/lib/tasks/doc.rake @@ -152,3 +152,5 @@ namespace :noosfero do end end end + +task :clean => 'noosfero:doc:clean' diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index c02dd41..2af89f5 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -9,9 +9,34 @@ desc "Create mo-files for L10n" task :makemo => makemo_stamp file makemo_stamp => Dir.glob('po/*/noosfero.po') do ruby '-rconfig/boot -rgettext -rgettext/utils -e \'GetText.create_mofiles(true, "po", "locale")\' 2>/dev/null' + Rake::Task['symlinkmo'].invoke FileUtils.touch makemo_stamp end +task :cleanmo do + rm_f makemo_stamp +end +task :clean => 'cleanmo' + +task :symlinkmo do + langmap = { + 'pt' => 'pt_BR', + } + FileUtils.mkdir_p(Rails.root + '/locale') + Dir.glob(Rails.root + '/locale/*').each do |dir| + lang = File.basename(dir) + orig_lang = langmap[lang] || lang + FileUtils.mkdir_p("#{Rails.root}/locale/#{lang}/LC_MESSAGES") + ['iso_3166', 'rails'].each do |domain| + origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo" + target = "#{Rails.root}/locale/#{lang}/LC_MESSAGES/#{domain}.mo" + if !File.symlink?(target) + ln_s origin, target + end + end + end +end + desc "Update pot/po files to match new version." task :updatepo do require 'gettext' diff --git a/lib/tasks/release.rake b/lib/tasks/release.rake index c903ec7..23f1b77 100644 --- a/lib/tasks/release.rake +++ b/lib/tasks/release.rake @@ -20,6 +20,17 @@ namespace :noosfero do puts "Not found tag for version #{version}, we can go on." end + desc 'checks the version of the Debian package' + task :check_debian_package do + debian_version = `dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2`.strip + unless debian_version =~ /^#{Noosfero::VERSION}/ + puts "Version mismatch: Debian version = #{debian_version}, Noosfero upstream version = #{Noosfero::VERSION}" + puts "Run `dch -v #{Noosfero::VERSION}` to add a new changelog entry that upgrades the Debian version" + raise "Version mismatch between noosfero version and debian package version" + end + end + + AUTHORS_HEADER = < [ :check_tag, 'noosfero:error-pages:translate', :authors, :check_repo, :package ] do + task :release => [ :check_tag, :check_debian_package, 'noosfero:error-pages:translate', :authors, :check_repo, :package, :debian_packages ] do sh "git tag #{version}" - puts "I: please upload the tarball to the website!" + puts "I: please upload the tarball and Debian packages to the website!" puts "I: please push the tag for version #{version} that was just created!" end + + desc 'Build Debian packages' + task :debian_packages => :package do + target = "pkg/noosfero-#{Noosfero::VERSION}" + mkdir "#{target}/tmp" + ln_s '../../../vendor/rails', "#{target}/vendor/rails" + cp "#{target}/config/database.yml.sqlite3", "#{target}/config/database.yml" + sh "cd #{target} && dpkg-buildpackage -us -uc -b" + end + + desc 'Test Debian package' + task 'debian:test' => :debian_packages do + Dir.chdir 'pkg' do + rm_rf "noosfero-#{Noosfero::VERSION}" + sh 'apt-ftparchive packages . > Packages' + sh 'apt-ftparchive release . > Release' + end + end end diff --git a/public/designs/icons/default b/public/designs/icons/default deleted file mode 120000 index 9c5e09a..0000000 --- a/public/designs/icons/default +++ /dev/null @@ -1 +0,0 @@ -tango \ No newline at end of file diff --git a/script/apacheconf b/script/apacheconf new file mode 100755 index 0000000..43d39d0 --- /dev/null +++ b/script/apacheconf @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby + +case ARGV.first +when 'mongrel' + require 'yaml' + mongrel_config = YAML.load_file(File.dirname(__FILE__) + "/../config/mongrel_cluster.yml") + ip = mongrel_config['address'] || '127.0.0.1' + ports = port_range = mongrel_config['port']..(mongrel_config['port']+mongrel_config['servers']-1) + ports.each do |port| + puts "BalancerMember http://#{ip}:#{port}" + end +when 'virtualhosts' + require File.dirname(__FILE__) + '/../config/environment' + Environment.all.each do |environment| + domains = environment.domains.sort do |domain| + domain.is_default ? 0 : 1 + end + if domains.empty? + domains << Domain.new(:name => 'localhost') + end + puts "# #{environment.name}" + puts "" + server_directive = 'ServerName' + domains.each do |domain| + puts " #{server_directive} #{domain.name}" + server_directive = 'ServerAlias' + end + puts " Include /etc/noosfero/apache/virtualhost.conf" + puts "" + end + puts "# vim: ft=apache" +else + puts "usage: %s mongrel|virtualhosts" % $PROGRAM_NAME + exit 1 +end diff --git a/script/production b/script/production index c6ac6dc..52bc141 100755 --- a/script/production +++ b/script/production @@ -1,13 +1,17 @@ #!/bin/sh +set -e + export RAILS_ENV=production ACTION=$1 shift clear_cache() { - rm -f ./public/javascripts/cache-*.js - rm -f ./public/stylesheets/cache.css + if test -w ./public; then + rm -f ./public/javascripts/cache-*.js + rm -f ./public/stylesheets/cache.css + fi } do_start() { @@ -40,7 +44,7 @@ case "$ACTION" in do_start echo "=> Running in production mode. Hit ctrl-C to stop." trap do_stop INT TERM - tail -n 0 -f log/production.log + tail -n 0 -f log/production.log || true ;; restart) diff --git a/vendor/plugins/attachment_fu/Rakefile b/vendor/plugins/attachment_fu/Rakefile index 0851dd4..faa7ad1 100644 --- a/vendor/plugins/attachment_fu/Rakefile +++ b/vendor/plugins/attachment_fu/Rakefile @@ -16,7 +16,6 @@ desc 'Generate documentation for the attachment_fu plugin.' Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'ActsAsAttachment' - rdoc.options << '--line-numbers --inline-source' rdoc.rdoc_files.include('README') rdoc.rdoc_files.include('lib/**/*.rb') end -- libgit2 0.21.2