app-admin/awscli: Bump to 1.37.9
[gentoo/gentoo.git] / www-apps / redmine / redmine-5.1.3.ebuild
blob16bf9021f4f50155eb918f40a9bf5f915bf140f7
1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
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"
13 LICENSE="GPL-2"
14 SLOT="0"
15 KEYWORDS="~amd64"
16 IUSE="fastcgi imagemagick ldap +minimagick mysql passenger pdf postgres +standalone sqlite"
18 ruby_add_bdepend "
19         fastcgi? ( dev-ruby/fcgi )
20         ldap? ( >=dev-ruby/ruby-net-ldap-0.17.0 )
21         minimagick? ( >=dev-ruby/mini_magick-4.12.0 )
22         mysql? (
23                 >=dev-ruby/mysql2-0.5.0:0.5
24                 dev-ruby/with_advisory_lock
25         )
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
30         dev-ruby/addressable
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
36         >=dev-ruby/mail-2.8.1
37         dev-ruby/marcel
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
47         dev-ruby/rexml
48         >=dev-ruby/roadie-rails-3.1.0:3
49         >=dev-ruby/rotp-5.0.0
50         >=dev-ruby/rouge-4.2.0
51         dev-ruby/rqrcode
52         >=dev-ruby/rubyzip-2.3.0:2
53         >=dev-ruby/sanitize-6.0:6
56 RDEPEND="
57         acct-group/redmine
58         acct-user/redmine
59         imagemagick? ( media-gfx/imagemagick )
60         pdf? (
61                 app-text/ghostscript-gpl
62                 media-gfx/imagemagick
63         )
64         standalone? ( www-servers/puma )
67 REDMINE_DIR="/var/lib/${PN}"
69 all_ruby_prepare() {
70         rm -fr log files/delete.me .github || die
72         # bug #406605
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"
79         EOF
81         # Fixing versions in Gemfile
82         sed -i -e "s/~>/>=/g" Gemfile || die
84         # bug #724464
85         sed -i -e "s/gem 'rails',.*/gem 'rails', '~>6.1.7'/" Gemfile || die
87         # Commonmark
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
95         fi
96         if ! use ldap ; then
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
100         fi
101         # Additional dependency for Gemfile (#657156)
102         if use fastcgi; then
103                 echo "gem 'fcgi'" >> Gemfile.local || die
104         fi
105         if use standalone; then
106                 echo "gem 'puma'" >> Gemfile.local || die
107         fi
110 all_ruby_install() {
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}"
117         doins -r .
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" \
129                 /var/log/${PN}
131         fowners redmine:redmine "${REDMINE_DIR}"
133         # protect sensitive data, see bug #406605
134         fperms -R go-rwx \
135                 "${REDMINE_DIR}/config" \
136                 "${REDMINE_DIR}/files" \
137                 "${REDMINE_DIR}/tmp" \
138                 /var/log/${PN}
140         if use passenger; then
141                 has_apache
142                 insinto "${APACHE_VHOSTS_CONFDIR}"
143                 doins "${FILESDIR}/10_redmine_vhost.conf"
144         fi
146         # logrotate
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}"
155 pkg_postinst() {
156         if [[ -e "${EROOT}${REDMINE_DIR}/config/initializers/session_store.rb" \
157         || -e "${EROOT}${REDMINE_DIR}/config/initializers/secret_token.rb" ]]
158         then
159                 elog "Execute the following command to upgrade environment:"
160                 elog
161                 elog "# emerge --config \"=${CATEGORY}/${PF}\""
162                 elog
163                 elog "For upgrade instructions take a look at:"
164                 elog "http://www.redmine.org/wiki/redmine/RedmineUpgrade"
165         else
166                 elog "Execute the following command to initialize environment:"
167                 elog
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}\""
173                 elog
174                 elog "Installation notes are at official site"
175                 elog "http://www.redmine.org/wiki/redmine/RedmineInstall"
176         fi
178         elog
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."
182         elog
185 pkg_config() {
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."
194                 die
195         fi
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`"
201                 die
202         fi
203         if [[ $RUBY_TARGETS != *$( eselect ruby show | awk 'NR==2' | tr  -d ' '  )* ]]
204         then
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`"
208                 die
209         fi
210         local RUBY=${RUBY:-ruby}
212         cd "${EROOT}${REDMINE_DIR}" || die
213         if [[ -e "${EROOT}${REDMINE_DIR}/config/initializers/session_store.rb" ]]
214         then
215                 einfo
216                 einfo "Generating secret token."
217                 einfo
218                 rm config/initializers/session_store.rb || die
219                 RAILS_ENV="${RAILS_ENV}" ${RUBY} -S rake generate_secret_token || die
220         fi
221         if [[ -e "${EROOT}${REDMINE_DIR}/config/initializers/secret_token.rb" ]]
222         then
223                 einfo
224                 einfo "Upgrading database."
225                 einfo
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
238         else
239                 einfo
240                 einfo "Initializing database."
241                 einfo
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
250                 einfo
251                 einfo "If you use sqlite3, please do not forget to change the ownership"
252                 einfo "of the sqlite files."
253                 einfo
254                 einfo "# cd \"${EROOT}${REDMINE_DIR}\""
255                 einfo "# chown redmine:redmine db/ db/*.sqlite3"
256                 einfo
257         fi