1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 USE_RUBY="ruby31 ruby32"
7 inherit depend.apache ruby-ng
9 DESCRIPTION="Flexible project management web application using the Ruby on Rails framework"
10 HOMEPAGE="https://www.redmine.org/"
11 SRC_URI="https://www.redmine.org/releases/${P}.tar.gz"
16 IUSE="fastcgi imagemagick ldap +minimagick mysql passenger pdf postgres +standalone sqlite"
19 fastcgi? ( dev-ruby/fcgi )
20 ldap? ( >=dev-ruby/ruby-net-ldap-0.17.0 )
21 minimagick? ( >=dev-ruby/mini_magick-4.12.0 )
23 >=dev-ruby/mysql2-0.5.0:0.5
24 dev-ruby/with_advisory_lock
26 passenger? ( www-apache/passenger )
27 postgres? ( >=dev-ruby/pg-1.5.3:1 )
28 sqlite? ( >=dev-ruby/sqlite3-1.6.0 )
29 dev-ruby/actionpack-xml_parser:2
31 >=dev-ruby/commonmarker-0.23.8
32 >=dev-ruby/csv-3.2.6:3
33 >=dev-ruby/deckar01-task_list-2.3.2
34 >=dev-ruby/html-pipeline-2.13.2
35 >=dev-ruby/i18n-1.14.1:1
38 >=dev-ruby/mini_mime-1.1.0
39 >=dev-ruby/net-imap-0.3.4
40 >=dev-ruby/net-pop-0.1.2
41 >=dev-ruby/net-smtp-0.3.3
42 >=dev-ruby/nokogiri-1.15.2
43 >=dev-ruby/rails-6.1.7.6:6.1
44 >=dev-ruby/rbpdf-1.21.3
45 >=dev-ruby/redcarpet-3.6.0
46 >=dev-ruby/request_store-1.5.0:0
48 >=dev-ruby/roadie-rails-3.1.0:3
50 >=dev-ruby/rouge-4.2.0
52 >=dev-ruby/rubyzip-2.3.0:2
53 >=dev-ruby/sanitize-6.0:6
59 imagemagick? ( media-gfx/imagemagick )
61 app-text/ghostscript-gpl
64 standalone? ( www-servers/puma )
67 REDMINE_DIR="/var/lib/${PN}"
70 rm -fr log files/delete.me .github || die
73 rm .{git,hg}ignore || die
75 # newenvd not working here
76 cat > "${T}/50${PN}" <<-EOF || die
77 CONFIG_PROTECT="${EROOT}/${REDMINE_DIR}/config"
78 CONFIG_PROTECT_MASK="${EROOT}/${REDMINE_DIR}/config/locales ${EROOT}/${REDMINE_DIR}/config/settings.yml"
81 # Fixing versions in Gemfile
82 sed -i -e "s/~>/>=/g" Gemfile || die
85 sed -i -e "s/gem 'rails',.*/gem 'rails', '~>6.1.7'/" Gemfile || die
88 sed -i -e "s/'2.3.2'/'>=2.3.2'/" Gemfile || die
90 sed -i -e "/group :development do/,/^end$/d" Gemfile || die
91 sed -i -e "/group :test do/,/^end$/d" Gemfile || die
93 if ! use imagemagick ; then
94 sed -i -e "/group :minimagick do/,/^end$/d" Gemfile || die
97 # remove ldap stuff module if disabled to avoid #413779
98 use ldap || rm app/models/auth_source_ldap.rb || die
99 sed -i -e "/group :ldap do/,/^end$/d" Gemfile || die
101 # Additional dependency for Gemfile (#657156)
103 echo "gem 'fcgi'" >> Gemfile.local || die
105 if use standalone; then
106 echo "gem 'puma'" >> Gemfile.local || die
111 dodoc doc/* README.rdoc
112 rm -r doc test appveyor.yml CONTRIBUTING.md README.rdoc || die
114 keepdir /var/log/${PN}
116 insinto "${REDMINE_DIR}"
118 insinto "${REDMINE_DIR}/config"
119 doins "${FILESDIR}/additional_environment.rb"
120 keepdir "${REDMINE_DIR}"/{app/views/previews,files,public/plugin_assets,vendor}
121 keepdir "${REDMINE_DIR}"/tmp/{cache,imports,sessions,sockets}
123 fowners -R redmine:redmine \
124 "${REDMINE_DIR}/config.ru" \
125 "${REDMINE_DIR}/config" \
126 "${REDMINE_DIR}/files" \
127 "${REDMINE_DIR}/public/plugin_assets" \
128 "${REDMINE_DIR}/tmp" \
131 fowners redmine:redmine "${REDMINE_DIR}"
133 # protect sensitive data, see bug #406605
135 "${REDMINE_DIR}/config" \
136 "${REDMINE_DIR}/files" \
137 "${REDMINE_DIR}/tmp" \
140 if use passenger; then
142 insinto "${APACHE_VHOSTS_CONFDIR}"
143 doins "${FILESDIR}/10_redmine_vhost.conf"
147 insinto /etc/logrotate.d
148 newins "${FILESDIR}"/redmine.logrotate redmine
150 use standalone && newconfd "${FILESDIR}/${PN}.confd" ${PN}
151 use standalone && newinitd "${FILESDIR}/${PN}-3.initd" ${PN}
152 doenvd "${T}/50${PN}"
156 if [[ -e "${EROOT}${REDMINE_DIR}/config/initializers/session_store.rb" \
157 || -e "${EROOT}${REDMINE_DIR}/config/initializers/secret_token.rb" ]]
159 elog "Execute the following command to upgrade environment:"
161 elog "# emerge --config \"=${CATEGORY}/${PF}\""
163 elog "For upgrade instructions take a look at:"
164 elog "http://www.redmine.org/wiki/redmine/RedmineUpgrade"
166 elog "Execute the following command to initialize environment:"
168 elog "# cd ${EROOT}${REDMINE_DIR}"
169 elog "# cp config/database.yml.example config/database.yml"
170 elog "# \${EDITOR} config/database.yml"
171 elog "# chown redmine:redmine config/database.yml"
172 elog "# emerge --config \"=${CATEGORY}/${PF}\""
174 elog "Installation notes are at official site"
175 elog "http://www.redmine.org/wiki/redmine/RedmineInstall"
179 elog "OpenID support was removed in Redmine 5.0. If you are using OpenID"
180 elog "authentication, you should switch back to Redmine 4.2 or install and"
181 elog "enable an OpenID plugin. See https://redmine.org/issues/35755."
186 # Remove old lock file
187 rm -f "${EROOT}${REDMINE_DIR}/Gemfile.lock"
189 if [[ ! -e "${EROOT}${REDMINE_DIR}/config/database.yml" ]]; then
190 eerror "Copy ${EROOT}${REDMINE_DIR}/config/database.yml.example to"
191 eerror "${EROOT}${REDMINE_DIR}/config/database.yml then edit this"
192 eerror "file in order to configure your database settings for"
193 eerror "\"production\" environment."
197 local RAILS_ENV=${RAILS_ENV:-production}
198 if [[ ! -L /usr/bin/ruby ]]; then
199 eerror "/usr/bin/ruby is not a valid symlink to any ruby implementation."
200 eerror "Please update it via `eselect ruby`"
203 if [[ $RUBY_TARGETS != *$( eselect ruby show | awk 'NR==2' | tr -d ' ' )* ]]
205 eerror "/usr/bin/ruby is currently not included in redmine's ruby targets:"
206 eerror "${RUBY_TARGETS}."
207 eerror "Please update it via `eselect ruby`"
210 local RUBY=${RUBY:-ruby}
212 cd "${EROOT}${REDMINE_DIR}" || die
213 if [[ -e "${EROOT}${REDMINE_DIR}/config/initializers/session_store.rb" ]]
216 einfo "Generating secret token."
218 rm config/initializers/session_store.rb || die
219 RAILS_ENV="${RAILS_ENV}" ${RUBY} -S rake generate_secret_token || die
221 if [[ -e "${EROOT}${REDMINE_DIR}/config/initializers/secret_token.rb" ]]
224 einfo "Upgrading database."
227 einfo "Generating secret token."
228 # Migration from Redmine 2.x
229 rm config/initializers/secret_token.rb || die
230 RAILS_ENV="${RAILS_ENV}" ${RUBY} -S rake generate_secret_token || die
232 einfo "Migrating database."
233 RAILS_ENV="${RAILS_ENV}" ${RUBY} -S rake db:migrate || die
234 einfo "Upgrading the plugin migrations."
235 RAILS_ENV="${RAILS_ENV}" ${RUBY} -S rake redmine:plugins:migrate || die
236 einfo "Clear the cache."
237 ${RUBY} -S rake tmp:cache:clear || die
240 einfo "Initializing database."
243 einfo "Generating a session store secret."
244 ${RUBY} -S rake generate_secret_token || die
245 einfo "Creating the database structure."
246 RAILS_ENV="${RAILS_ENV}" ${RUBY} -S rake db:migrate || die
247 einfo "Populating database with default configuration data."
248 RAILS_ENV="${RAILS_ENV}" ${RUBY} -S rake redmine:load_default_data || die
249 chown redmine:redmine -R "${EROOT}/var/log/redmine/" || die
251 einfo "If you use sqlite3, please do not forget to change the ownership"
252 einfo "of the sqlite files."
254 einfo "# cd \"${EROOT}${REDMINE_DIR}\""
255 einfo "# chown redmine:redmine db/ db/*.sqlite3"