diff options
-rw-r--r-- | pcr/diaspora/PKGBUILD | 153 | ||||
-rw-r--r-- | pcr/diaspora/diaspora.bash_profile | 1 | ||||
-rw-r--r-- | pcr/diaspora/diaspora.bashrc | 4 | ||||
-rw-r--r-- | pcr/diaspora/diaspora.install | 30 | ||||
-rw-r--r-- | pcr/diaspora/diaspora.service | 14 | ||||
-rw-r--r-- | pcr/diaspora/diaspora.tmpfiles.d.conf | 1 |
6 files changed, 203 insertions, 0 deletions
diff --git a/pcr/diaspora/PKGBUILD b/pcr/diaspora/PKGBUILD new file mode 100644 index 000000000..7f401a4d7 --- /dev/null +++ b/pcr/diaspora/PKGBUILD @@ -0,0 +1,153 @@ +# Maintainer (Arch): Jonne Haß <me@mrzyx.de> +pkgbase=diaspora +pkgname=('diaspora-mysql' 'diaspora-postgresql') +pkgver=0.5.0.1 +pkgrel=1 +pkgdesc="A distributed privacy aware social network" +arch=('i686' 'x86_64') +url="http://diasporafoundation.org" +license=('AGPL3') +depends=('ruby2.1' 'ruby2.1-bundler' 'redis' 'imagemagick' 'libxslt' 'net-tools' 'gsfonts') +makedepends=('nodejs' 'postgresql-libs' 'libmysqlclient') +conflicts=('diaspora-git' 'diaspora-mysql-git' 'diaspora-postgresql-git') +options=(!strip) +backup=("etc/webapps/$pkgbase/diaspora.yml" + "etc/webapps/$pkgbase/database.yml" + "etc/webapps/$pkgbase/secret_token.rb") +install="$pkgbase.install" +source=("$pkgbase-$pkgver.tar.gz::https://github.com/$pkgbase/$pkgbase/tarball/v$pkgver" + "$pkgbase.install" + "$pkgbase.service" + "$pkgbase.tmpfiles.d.conf" + "$pkgbase.bashrc" + "$pkgbase.bash_profile") + +# Get rid of any possible ruby version managers +# From https://github.com/postmodern/chruby +_reset_ruby() { + [[ -z "$RUBY_ROOT" ]] && return + + export PATH=":$PATH:"; export PATH=${PATH//:$RUBY_ROOT\/bin:/:} + + [[ -n "$GEM_HOME" ]] && export PATH=${PATH//:$GEM_HOME\/bin:/:} + [[ -n "$GEM_ROOT" ]] && export PATH=${PATH//:$GEM_ROOT\/bin:/:} + + export GEM_PATH=":$GEM_PATH:" + export GEM_PATH=${GEM_PATH//:$GEM_HOME:/:} + export GEM_PATH=${GEM_PATH//:$GEM_ROOT:/:} + export GEM_PATH=${GEM_PATH#:}; export GEM_PATH=${GEM_PATH%:} + unset GEM_ROOT GEM_HOME + + export PATH=${PATH#:}; export PATH=${PATH%:} + unset RUBY_ROOT RUBY_ENGINE RUBY_VERSION RUBYOPT +} + +_package() { + _bundle=bundle-2.1 + _ruby=ruby-2.1 + _rake=rake-2.1 + _db=$1 + _srcdir=$srcdir/$pkgname-$pkgver + + _reset_ruby + + msg "Setup build directory" + mkdir -p $_srcdir + cp -Rf $srcdir/$pkgbase-$pkgbase-*/{app,config,db,public,lib,script,vendor,config.ru,Gemfile,Gemfile.lock,Procfile,Rakefile} $_srcdir + + cd $_srcdir + + msg "Bundle dependencies" + echo "gem: --no-rdoc --no-ri --no-user-install" > $_srcdir/.gemrc + HOME=$_srcdir DB=$_db $_bundle install \ + --without development test heroku --path vendor/bundle + HOME=$_srcdir DB=$_db $_bundle clean + + msg "Patch configuration examples" + sed -i -e "s|#certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'|certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'|" \ + -e "s|#rails_environment: 'production'|rails_environment: 'production'|" \ + -e "s|#database: 'mysql'|database: '$_db'|" \ + $_srcdir/config/diaspora.yml.example + sed -i -e "s|<<: \*mysql|<<: *$_db|" \ + -e "s|#<<: \*postgres||" \ + $_srcdir/config/database.yml.example + + cp $_srcdir/config/diaspora.yml{.example,} + cp $_srcdir/config/database.yml{.example,} + + msg "Create secret token" + HOME=$_srcdir DB=$_db $_bundle exec $_rake generate:secret_token + + msg "Precompile assets" + DB=$_db $_bundle exec $_rake assets:precompile + + rm $_srcdir/config/{diaspora,database}.yml + + msg "Copy contents to package directory" + install -dm755 $pkgdir/usr/share/webapps/$pkgbase + cp -Rf $_srcdir/* $pkgdir/usr/share/webapps/$pkgbase/ + cp -Rf $_srcdir/.bundle $pkgdir/usr/share/webapps/$pkgbase/ + install -Dm644 $_srcdir/.gemrc $pkgdir/usr/share/webapps/$pkgbase/.gemrc + install -Dm640 $_srcdir/config/initializers/secret_token.rb $pkgdir/etc/webapps/$pkgbase/secret_token.rb + install -Dm644 $srcdir/$pkgbase.service $pkgdir/usr/lib/systemd/system/$pkgbase.service + install -Dm644 $srcdir/$pkgbase.tmpfiles.d.conf $pkgdir/usr/lib/tmpfiles.d/$pkgbase.conf + install -Dm644 $srcdir/$pkgbase.bashrc $pkgdir/usr/share/webapps/$pkgbase/.bashrc + install -Dm644 $srcdir/$pkgbase.bash_profile $pkgdir/usr/share/webapps/$pkgbase/.bash_profile + + msg "Build source.tar.gz to conform the AGPL" + tar czf $pkgdir/usr/share/webapps/$pkgbase/public/source.tar.gz \ + $pkgdir/usr/share/webapps/$pkgbase/{app,db,lib,script,Gemfile,Gemfile.lock,Rakefile,Procfile,config.ru} + + msg "Symlink ruby and bundle" + install -dm755 $pkgdir/usr/share/webapps/$pkgbase/bin + ln -s /usr/bin/$_ruby $pkgdir/usr/share/webapps/$pkgbase/bin/ruby + ln -s /usr/bin/$_bundle $pkgdir/usr/share/webapps/$pkgbase/bin/bundle + + msg "Prepare configuration files" + install -dm750 $pkgdir/etc/webapps/$pkgbase + install -Dm640 $_srcdir/config/diaspora.yml.example $pkgdir/etc/webapps/$pkgbase/diaspora.yml + install -Dm640 $_srcdir/config/database.yml.example $pkgdir/etc/webapps/$pkgbase/database.yml + + sed -i -e "s|%db%|$_db|" \ + $pkgdir/usr/share/webapps/$pkgbase/.bashrc + sed -i -e "s|%db%|$_db|" \ + -e "s|mysql|mysqld|" \ + -e "s|postgres|postgresql|" \ + $pkgdir/usr/lib/systemd/system/$pkgbase.service + + msg "Create symlinks" + install -dm755 $pkgdir/var/log/$pkgbase + install -dm755 $pkgdir/var/lib/$pkgbase/uploads + rm -Rf $pkgdir/usr/share/webapps/$pkgbase/log \ + $pkgdir/usr/share/webapps/$pkgbase/tmp \ + $pkgdir/usr/share/webapps/$pkgbase/public/uploads + ln -s /etc/webapps/$pkgbase/diaspora.yml $pkgdir/usr/share/webapps/$pkgbase/config/diaspora.yml + ln -s /etc/webapps/$pkgbase/database.yml $pkgdir/usr/share/webapps/$pkgbase/config/database.yml + ln -sf /etc/webapps/$pkgbase/secret_token.rb $pkgdir/usr/share/webapps/$pkgbase/config/initializers/secret_token.rb + ln -sf /var/lib/$pkgbase/uploads $pkgdir/usr/share/webapps/$pkgbase/public/uploads + ln -sf /tmp/$pkgbase $pkgdir/usr/share/webapps/$pkgbase/tmp + ln -sf /var/log/$pkgbase $pkgdir/usr/share/webapps/$pkgbase/log +} + +package_diaspora-mysql() { + pkgdesc="$pkgdesc (MySQL)" + conflicts=(${conflicts[@]} 'diaspora-postgresql') + depends=(${depends[@]} 'libmysqlclient' 'mysql') + + _package mysql +} + +package_diaspora-postgresql() { + pkgdesc="$pkgdesc (PostgreSQL)" + conflicts=(${conflicts[@]} 'diaspora-mysql') + depends=(${depends[@]} 'postgresql-libs' 'postgresql') + + _package postgres +} + +sha256sums=('b5a5799f9db3a57802f19644276e0f5f7d40d9e42edbadee18ae3859c3a329a4' + 'aae126c4b1bcba6265d3d925dc3845bb034defa5606385c22dfb053111b57685' + 'f1770d7cfa2b3344e697ee664f5ab49e7cdeb50e93230a358a1ab5776824c81b' + '8864dc640545f53f5491a8edbda21d883c9731f8f6909d6a59c71e5fed49f2ca' + 'a3e17221e8cdbe5a8073f4725960f794c31208b0098177a296356af293b14596' + '29cfd5116e919d8851ff70b8b82af8d4a6c8243a9d1ca555981a1a695e2d7715') diff --git a/pcr/diaspora/diaspora.bash_profile b/pcr/diaspora/diaspora.bash_profile new file mode 100644 index 000000000..ab10789d9 --- /dev/null +++ b/pcr/diaspora/diaspora.bash_profile @@ -0,0 +1 @@ +source .bashrc diff --git a/pcr/diaspora/diaspora.bashrc b/pcr/diaspora/diaspora.bashrc new file mode 100644 index 000000000..8a1af05dc --- /dev/null +++ b/pcr/diaspora/diaspora.bashrc @@ -0,0 +1,4 @@ +export HOME=/usr/share/webapps/diaspora \ + RAILS_ENV=production \ + DB=%db% +export PATH=$HOME/bin:$PATH diff --git a/pcr/diaspora/diaspora.install b/pcr/diaspora/diaspora.install new file mode 100644 index 000000000..30d4f6167 --- /dev/null +++ b/pcr/diaspora/diaspora.install @@ -0,0 +1,30 @@ +dusr=diaspora +dhome=/usr/share/webapps/diaspora +dlog=/var/log/diaspora +detc=/etc/webapps/diaspora +ddata=/var/lib/diaspora + +_chown() { + chown -R $dusr:$dusr $dhome $dlog $detc $ddata + systemd-tmpfiles --create diaspora.conf +} + +## arg 1: the new package version +post_install() { + getent passwd $dusr &> /dev/null || useradd -r -d $dhome -s /bin/bash $dusr + _chown + echo "Read the installation instructions at https://wiki.archlinux.org/index.php/Diaspora" +} + +post_upgrade() { + _chown + echo "Read the upgrade instructions at https://wiki.archlinux.org/index.php/Diaspora" +} + +## arg 1: the old package version +post_remove() { + getent passwd $dusr &>/dev/null && userdel -f $dusr + return 0 +} + +# vim:set ts=2 sw=2 et: diff --git a/pcr/diaspora/diaspora.service b/pcr/diaspora/diaspora.service new file mode 100644 index 000000000..9dc63a365 --- /dev/null +++ b/pcr/diaspora/diaspora.service @@ -0,0 +1,14 @@ +[Unit] +Wants=redis.service +Wants=%db%.service + +[Service] +User=diaspora +WorkingDirectory=/usr/share/webapps/diaspora +ExecStart=/bin/bash -lc "true; source .bashrc; ./script/server" +Restart=always +StandardInput=null +KillMode=control-group + +[Install] +WantedBy=multi-user.target diff --git a/pcr/diaspora/diaspora.tmpfiles.d.conf b/pcr/diaspora/diaspora.tmpfiles.d.conf new file mode 100644 index 000000000..b82bc6a9a --- /dev/null +++ b/pcr/diaspora/diaspora.tmpfiles.d.conf @@ -0,0 +1 @@ +d /tmp/diaspora 0755 diaspora users - |