PKGBUILDs/community/gitlab/PKGBUILD

223 lines
11 KiB
Bash
Raw Normal View History

2016-12-10 18:01:59 +00:00
# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Pavol (Lopo) Hluchy <lopo AT losys DOT eu>
# Contributor: Jonas Heinrich <onny@project-insanity.org>
# Contributor: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Tobias Hunger <tobias DOT hunger AT gmail DOT com>
# Contributor: Stefan Tatschner <stefan@sevenbyte.org>
# Contributor: Caleb Maclennan <caleb@alerque.com>
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# - build unf_ext with -fsigned-char
2017-03-09 02:17:45 +00:00
# - disable webpack build
2016-12-10 18:01:59 +00:00
pkgname=gitlab
2017-11-01 19:20:39 +00:00
pkgver=10.1.1
2017-10-18 12:20:29 +00:00
pkgrel=1
2016-12-10 18:01:59 +00:00
pkgdesc="Project management and code hosting application"
2017-06-28 12:37:50 +00:00
arch=('x86_64')
2017-09-06 13:43:17 +00:00
url="https://gitlab.com/gitlab-org/gitlab-ce"
2016-12-10 18:01:59 +00:00
license=('MIT')
2017-08-06 19:22:04 +00:00
options=(!buildflags)
depends=('ruby2.3' 'git' 'ruby2.3-bundler' 'gitlab-workhorse' 'gitlab-gitaly' 'openssh' 'redis' 'libxslt' 'icu' 'nodejs' 're2')
2017-06-29 18:22:02 +00:00
makedepends=('cmake' 'postgresql' 'mariadb' 'yarn' 'go')
2016-12-10 18:01:59 +00:00
optdepends=('postgresql: database backend'
'mysql: database backend'
'python2-docutils: reStructuredText markup language support'
'smtp-server: mail server in order to receive mail notifications')
backup=("etc/webapps/${pkgname}/application.rb"
"etc/webapps/${pkgname}/gitlab.yml"
"etc/webapps/${pkgname}/resque.yml"
"etc/webapps/${pkgname}/unicorn.rb"
"etc/logrotate.d/${pkgname}")
2017-11-01 19:20:39 +00:00
source=("$pkgname-$pkgver.tar.bz2::https://gitlab.com/gitlab-org/gitlab-ce/repository/archive.tar.bz2?ref=v${pkgver}"
2016-12-10 18:01:59 +00:00
gitlab-unicorn.service
gitlab-sidekiq.service
gitlab-backup.service
gitlab-mailroom.service
gitlab-backup.timer
gitlab.target
gitlab.tmpfiles.d
gitlab.logrotate
yarn.lock)
2016-12-10 18:01:59 +00:00
install='gitlab.install'
2017-11-01 19:20:39 +00:00
sha512sums=('ba64a758e7450a682189dad9bb35201b2237b3f0ead149d1453f16bc1c5d06a6ae370620805915df2e0c57cb3167740e3f4fceec363d95aa7903228216b7d340'
2017-01-16 15:08:47 +00:00
'56cce150645ef74fa42a6100c8bc7689c4012579e1f3ba237c06c367b121246b39e968044615fa21c4757bc8e9d06f37f8ac8d39aa8b808c758e716857553f66'
2017-04-19 23:35:18 +00:00
'8678b2f0632a830e42a8a62b59ffe66b629b7d96034ff167e2a93fdbb3c7617db0c7529990b73c7a12a78a900ec833e48c691ebbac6cd8257e53de060da16a37'
2017-01-16 15:08:47 +00:00
'79cfb8ee740ab30f970c3113659b8349128abeae5e32cc81bb905f89a6db9941b7778040a094b884262daf020f66a1aee49a12d34fbb94efce6ade946bb4625b'
'c097a26d1c24f120967ae457f9008df06af0cd2662306410d8e3f6cc4b5772416125fcd3c895bc35872251060083e8c95b37455b8d20154518d8c467625291eb'
2016-12-24 00:05:24 +00:00
'c11d2c59da8325551a465227096e8d39b0e4bcd5b1db21565cf3439e431838c04bc00aa6f07f4d493f3f47fd6b4e25aeb0fe0fc1a05756064706bf5708c960ec'
'bf33b818e4ea671c16f58563997ba5fe0a09090e5c03577ff974d31324d4e9782b85a9bb4f1749b97257ce93400c692de935f003770d52b5994c9cab9aee57c6'
2016-12-24 00:05:24 +00:00
'abacbff0d7be918337a17b56481c84e6bf3eddd9551efe78ba9fb74337179e95c9b60f41c49f275e05074a4074a616be36fa208a48fc12d5b940f0554fbd89c3'
'20b93eab504e82cc4401685b59e6311b4d2c0285bc594d47ce4106d3f418a3e2ba92c4f49732748c0ba913aa3e3299126166e37d2a2d5b4d327d66bae4b8abda'
'ef4a91d2e5db3aabf83092d9fdff5cd830d291b78d05b4fc9ea991fc5f3299c1a70bbde2632935f899dbf0be084348d125e62df0e87d7925e2ea8068b3463d4d')
2016-12-10 18:01:59 +00:00
_datadir="/usr/share/webapps/${pkgname}"
_etcdir="/etc/webapps/${pkgname}"
_homedir="/var/lib/${pkgname}"
_logdir="/var/log/${pkgname}"
2016-12-24 00:05:24 +00:00
_srcdir="gitlab-ce-v${pkgver}"
2016-12-10 18:01:59 +00:00
prepare() {
2017-08-07 18:19:58 +00:00
cd "${srcdir}"
# Get first 7 characters from sha1 which has 40 characters in total
local revision=$(ls -d ${_srcdir}* | rev | cut -c 34-40 | rev)
cd "${_srcdir}"*
# Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/36397
2017-10-27 00:19:05 +00:00
# We used to need this but now the package doesn't build anymore with this. Leaving it commented for now.
# See also https://gitlab.com/gitlab-org/gitlab-ce/issues/38525
# cp "${srcdir}"/yarn.lock .
2017-08-07 18:19:58 +00:00
msg2 "Patching git revision in config/initializers/2_app.rb..."
sed -i -e "s|REVISION = Gitlab::Popen.popen(%W(#{config.git.bin_path} log --pretty=format:%h -n 1)).first.chomp.freeze|REVISION = \"${revision}\"|" \
config/initializers/2_app.rb
2016-12-10 18:01:59 +00:00
export SKIP_STORAGE_VALIDATION='true'
# Patching config files:
msg2 "Patching paths in and username gitlab.yml..."
sed -e "s|# user: git|user: gitlab|" \
-e "s|/home/git/repositories|${_homedir}/repositories|" \
-e "s|/home/git/gitlab-satellites|${_homedir}/satellites|" \
-e "s|# path: /mnt/gitlab|path: ${_homedir}/shared|" \
-e "s|/home/git/gitlab-shell|/usr/share/webapps/gitlab-shell|" \
-e "s|tmp/backups|${_homedir}/backups|" \
2017-06-30 18:06:37 +00:00
-e "s|/home/git/gitlab/tmp/sockets/private/gitaly.socket|${_homedir}/sockets/gitlab-gitaly.socket|" \
2016-12-10 18:01:59 +00:00
config/gitlab.yml.example > config/gitlab.yml
msg2 "Patching paths and timeout in unicorn.rb..."
sed -e "s|/home/git/gitlab/tmp/.*/|/run/gitlab/|g" \
-e "s|/var/run/|/run/|g" \
-e "s|/home/git/gitlab|${_datadir}|g" \
-e "s|timeout 30|timeout 300|" \
-e "s|${_datadir}/log/|${_logdir}/|g" \
config/unicorn.rb.example > config/unicorn.rb
# We need this one untouched because otherwise assets will fail
cp config/database.yml.postgresql config/database.yml.postgresql.orig
msg2 "Patching username in database.yml.{mysql,postgresql}..."
sed -i -e "s|username: git|username: gitlab|" config/database.yml.mysql
sed -i -e "s|username: git|username: gitlab|" config/database.yml.postgresql
msg2 "Patching redis connection in resque.yml"
sed -e "s|production: unix:/var/run/redis/redis.sock|production: redis://localhost:6379|" \
config/resque.yml.example > config/resque.yml.patched
msg2 "Setting up systemd service files ..."
for service_file in gitlab-sidekiq.service gitlab-unicorn.service gitlab.logrotate gitlab-backup.service gitlab-mailroom.service; do
sed -i "s|<HOMEDIR>|${_homedir}|g" "${srcdir}/${service_file}"
sed -i "s|<DATADIR>|${_datadir}|g" "${srcdir}/${service_file}"
sed -i "s|<LOGDIR>|${_logdir}|g" "${srcdir}/${service_file}"
done
}
build() {
2016-12-24 00:05:24 +00:00
cd "${srcdir}/${_srcdir}"*
2016-12-10 18:01:59 +00:00
msg "Fetching bundled gems..."
# Gems will be installed into vendor/bundle
2017-01-15 23:38:37 +00:00
bundle-2.3 config build.nokogiri --use-system-libraries
bundle-2.3 config build.unf_ext "--with-cxxflags='$CFLAGS -fsigned-char'" "--with-cflags='$CXXFLAGS -fsigned-char'"
2017-08-06 19:22:04 +00:00
bundle-2.3 install --no-cache --deployment --without development test aws kerberos
2016-12-10 18:01:59 +00:00
# We'll temporarily stick this in here so we can build the assets
cp config/database.yml.postgresql.orig config/database.yml
cp config/resque.yml.example config/resque.yml
sed -i 's/url.*/nope.sock/g' config/resque.yml
2017-01-15 23:38:37 +00:00
bundle-2.3 exec rake assets:precompile RAILS_ENV=production --trace
2017-03-11 03:24:58 +00:00
2017-04-16 03:02:13 +00:00
# yarn install --production --pure-lockfile
# bundle-2.3 exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
2017-06-29 18:22:02 +00:00
bundle-2.3 exec rake gettext:compile RAILS_ENV=production
2016-12-10 18:01:59 +00:00
# After building assets, clean this up again
rm config/database.yml config/database.yml.postgresql.orig
mv config/resque.yml.patched config/resque.yml
}
package() {
2016-12-24 00:05:24 +00:00
cd "${srcdir}/${_srcdir}"*
2017-06-29 18:22:02 +00:00
depends+=('gitlab-shell')
2016-12-10 18:01:59 +00:00
install -d "${pkgdir}/usr/share/webapps"
2016-12-24 00:05:24 +00:00
cp -r "${srcdir}/${_srcdir}"* "${pkgdir}${_datadir}"
2016-12-10 18:01:59 +00:00
chown -R root:root "${pkgdir}${_datadir}"
chmod 755 "${pkgdir}${_datadir}"
install -dm750 -o 105 -g 105 "${pkgdir}${_homedir}"
install -dm750 -o 105 -g 105 "${pkgdir}${_homedir}/satellites"
install -dm750 -o 105 -g 105 "${pkgdir}${_homedir}/shared/"{,artifacts,lfs-objects}
install -dm750 -o 105 -g 105 "${pkgdir}${_homedir}/builds"
install -dm750 -o 105 -g 105 "${pkgdir}${_homedir}/uploads"
install -dm750 -o 105 -g 105 "${pkgdir}${_homedir}/backups"
install -dm750 -o 105 -g 105 "${pkgdir}${_etcdir}"
install -dm755 "${pkgdir}/usr/share/doc/${pkgname}"
ln -fs /run/gitlab "${pkgdir}${_homedir}/pids"
ln -fs /run/gitlab "${pkgdir}${_homedir}/sockets"
ln -fs ${_datadir}/log "${pkgdir}${_homedir}/log"
rm -rf "${pkgdir}${_datadir}/public/uploads" && ln -fs "${_homedir}/uploads" "${pkgdir}${_datadir}/public/uploads"
rm -rf "${pkgdir}${_datadir}/builds" && ln -fs "${_homedir}/builds" "${pkgdir}${_datadir}/builds"
rm -rf "${pkgdir}${_datadir}/tmp" && ln -fs /var/tmp "${pkgdir}${_datadir}/tmp"
rm -rf "${pkgdir}${_datadir}/log" && ln -fs "${_logdir}" "${pkgdir}${_datadir}/log"
mv "${pkgdir}${_datadir}/.gitlab_workhorse_secret" "${pkgdir}${_etcdir}/gitlab_workhorse_secret"
chmod 660 "${pkgdir}${_etcdir}/gitlab_workhorse_secret"
chown root:105 "${pkgdir}${_etcdir}/gitlab_workhorse_secret"
ln -fs "${_etcdir}/gitlab_workhorse_secret" "${pkgdir}${_datadir}/.gitlab_workhorse_secret"
ln -fs /etc/webapps/gitlab-shell/secret "${pkgdir}${_datadir}/.gitlab_shell_secret"
sed -i "s|require_relative '../lib|require '${_datadir}/lib|" config/application.rb
2017-01-15 23:38:37 +00:00
# Fix for ruby-2.3 and bundle-2.3
sed -i "s|bundle|bundle-2.3|g" "${pkgdir}${_datadir}/lib/tasks/gitlab/check.rake"
grep -rl "bin/env ruby" "${pkgdir}${_datadir}" | xargs sed -i "s|bin/env ruby$|bin/env ruby-2.3|g"
2017-10-10 00:56:30 +00:00
sed -i \
-e "s|ruby --version|ruby-2.3 --version|g" \
-e "s|gem --version|gem-2.3 --version|g" \
-e "s|bundle --version|bundle-2.3 --version|g" \
-e "s|rake --version|rake-2.3 --version|g" \
"${pkgdir}${_datadir}/lib/tasks/gitlab/info.rake"
2017-01-15 23:38:37 +00:00
2016-12-10 18:01:59 +00:00
# Install config files
for config_file in application.rb gitlab.yml unicorn.rb resque.yml; do
mv "config/${config_file}" "${pkgdir}${_etcdir}/"
[[ -f "${pkgdir}${_datadir}/config/${config_file}" ]] && rm "${pkgdir}${_datadir}/config/${config_file}"
ln -fs "${_etcdir}/${config_file}" "${pkgdir}${_datadir}/config/"
done
# Install database symlink
ln -fs "${_etcdir}/database.yml" "${pkgdir}${_datadir}/config/database.yml"
# Install secrets symlink
ln -fs "${_etcdir}/secrets.yml" "${pkgdir}${_datadir}/config/secrets.yml"
# Install license and help files
mv README.md MAINTENANCE.md CONTRIBUTING.md CHANGELOG.md PROCESS.md VERSION config/*.{example,mysql,postgresql} "${pkgdir}/usr/share/doc/${pkgname}"
install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# https://gitlab.com/gitlab-org/gitlab-ce/issues/765
cp -r "${pkgdir}${_datadir}/doc" "${pkgdir}${_datadir}/public/help"
find "${pkgdir}${_datadir}/public/help" -name "*.md" -exec rm {} \;
find "${pkgdir}${_datadir}/public/help/" -depth -type d -empty -exec rmdir {} \;
chown 105:105 "${pkgdir}${_datadir}/db/schema.rb"
# Install systemd service files
for service_file in gitlab-unicorn.service gitlab-sidekiq.service gitlab-backup.service gitlab-backup.timer gitlab.target gitlab-mailroom.service; do
install -Dm644 "${srcdir}/${service_file}" "${pkgdir}/usr/lib/systemd/system/${service_file}"
done
install -Dm644 "${srcdir}/gitlab.tmpfiles.d" "${pkgdir}/usr/lib/tmpfiles.d/gitlab.conf"
install -Dm644 "${srcdir}/gitlab.logrotate" "${pkgdir}/etc/logrotate.d/gitlab"
}
# vim:set ts=2 sw=2 et: