From 164067832916c8e59219e1b0f30d7d04618a536e Mon Sep 17 00:00:00 2001 From: root Date: Sun, 22 Jan 2012 23:15:13 +0000 Subject: Sun Jan 22 23:15:13 UTC 2012 --- social/diaspora-git/PKGBUILD | 156 ++++++++++++++++++++++-------------- social/diaspora-git/diaspora.bashrc | 6 ++ social/diaspora-git/diaspora.bin | 13 +-- social/diaspora-git/diaspora.rc | 4 +- 4 files changed, 111 insertions(+), 68 deletions(-) create mode 100644 social/diaspora-git/diaspora.bashrc (limited to 'social') diff --git a/social/diaspora-git/PKGBUILD b/social/diaspora-git/PKGBUILD index 77a11d701..3c241473b 100644 --- a/social/diaspora-git/PKGBUILD +++ b/social/diaspora-git/PKGBUILD @@ -1,41 +1,37 @@ # Maintainer: fauno # Maintainer: Hilton Medeiros +# Contributor: Jonne Haß # Contributor: Splashy # After installing, see the Diaspora wiki page for more information: # https://wiki.archlinux.org/index.php/Diaspora pkgbase=diaspora-git -pkgname=('diaspora-mysql-git' 'diaspora-postgresql-git' 'diaspora-sqlite-git') -<<<<<<< HEAD -pkgver=20110623 -======= -pkgver=20111229 ->>>>>>> ddf6b4309b9f9816e75828359a2d60a23a0ca68c -pkgrel=1 +pkgname=('diaspora-mysql-git' 'diaspora-postgresql-git') +pkgver=20120105 +pkgrel=2 pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network" arch=('i686' 'x86_64') url="https://diasporafoundation.org/" license=('AGPL3') -depends=('ruby' 'redis' 'imagemagick' 'libxslt') -makedepends=('git' 'ruby-headers') +depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'net-tools') +makedepends=('git' 'libmysqlclient' 'postgresql-libs') provides=('diaspora') install=diaspora.install source=('diaspora.bin' 'diaspora.rc' 'diaspora.logrotate' - 'diaspora.pam') -md5sums=('440ce2511485855030e74e28843a037d' - '7bffaaee41b515247ba19a19c77dc5bf' + 'diaspora.pam' + 'diaspora.bashrc') +md5sums=('547b0015c83da22bd739dc85fd79f9b9' + 'b7a893271d9ba778f74569eff4190c06' '60f6b3972c73cbc6b1c9ab87c88fb655' - '96f82c38f3f540b53f3e5144900acf17') + '96f82c38f3f540b53f3e5144900acf17' + '53867bfd389dd267eefcefb053fecc5b') -_gitroot="https://github.com/diaspora/diaspora.git" +_gitroot="git://github.com/diaspora/diaspora.git" _gitname="diaspora" -# I use this because I'm behind an asshole proxy -tsocks=tsocks - build() { cd "$srcdir" @@ -43,35 +39,47 @@ build() { if [[ -d $_gitname ]] ; then pushd $_gitname - $tsocks git pull origin + git pull origin msg "The local files are updated." popd else - $tsocks git clone $_gitroot + git clone $_gitroot msg "Git clone done." fi msg "Start making..." [[ -d $_gitname-build ]] && rm -fr $_gitname-build -<<<<<<< HEAD git clone $_gitname $_gitname-build -======= - $tsocks git clone $_gitname $_gitname-build ->>>>>>> ddf6b4309b9f9816e75828359a2d60a23a0ca68c + cd ${srcdir}/${_gitname}-build -# Include all gems - export GEM_HOME="${PWD}/vendor" - export GEM_PATH="${PWD}/vendor" - export PATH="${PATH}:${GEM_PATH}/bin" + # Symlink configs + ln -s /etc/webapps/$_gitname/application.yml config/application.yml + ln -s /etc/webapps/$_gitname/database.yml config/database.yml + ln -s /etc/webapps/$_gitname/script_server.yml config/script_server.yml + ln -s /etc/webapps/$_gitname/oauth_keys.yml config/oauth_keys.yml - cd ${srcdir}/${_gitname}-build + # Set version header + sed "s|git_cmd = \`git log -1 --pretty=\"format:%H %ci\"\`|git_cmd = \"$(git log -1 --pretty="format:%H %ci")\"|" \ + -i config/initializers/version_header.rb -<<<<<<< HEAD - gem install bundler -======= - $tsocks gem install bundler ->>>>>>> ddf6b4309b9f9816e75828359a2d60a23a0ca68c + # Preconfigure config/script_server.yml.example + sed 's|rails_env: "development"|rails_env: "production"|' \ + -i config/script_server.yml.example + + # Preconfigure right ca_file + sed "s|ca_file: '/etc/pki/tls/certs/ca-bundle.crt' # CentOS|ca_file: '/etc/ssl/certs/ca-certificates.crt' # Arch|" \ + -i config/application.yml.example + + # We make this now because we do not install the git history + # Comply with AGPLv3 + tar czf public/source.tar.gz `git ls-tree -r master | awk '{print $4}'` + + # Remove git repo + rm -fr .git + + # Create gem cache + mkdir -p ${srcdir}/gem-cache } # Helper @@ -83,34 +91,70 @@ _package() { install -d "${usrdir}" cp -a ${_gitname}-build "${usrdir}/${_gitname}" - cd "${usrdir}/${_gitname}" + install -Dm755 $_gitname.bin "$pkgdir/usr/bin/$_gitname" + install -Dm755 $_gitname.rc "$pkgdir/etc/rc.d/$_gitname" + install -Dm644 $_gitname.logrotate "$pkgdir/etc/logrotate.d/$_gitname" + install -Dm644 $_gitname.pam "$pkgdir/etc/pam.d/$_gitname" + install -Dm644 $_gitname.bashrc "$usrdir/$_gitname/.bashrc" -# Set the example config - sed -e 's/rails_env:.*/rails_env: "production"/' \ - -e "s/db:.*/db: \"${DB}\"/" \ - -i config/script_server.yml.example +# Set the DB in the environment + sed -i "s/-DB-/$DB/g" "$usrdir/$_gitname/.bashrc" + sed -i "s/-DB-/$_db_rc/g" "$pkgdir/etc/rc.d/$_gitname" - ${tsocks} bundle install --local --path vendor --without development test + install -Dm644 $_gitname-build/config/application.yml.example "$pkgdir/etc/webapps/$_gitname/application.yml" + install -Dm644 $_gitname-build/config/database.yml.example "$pkgdir/etc/webapps/$_gitname/database.yml" + install -Dm644 $_gitname-build/config/script_server.yml.example "$pkgdir/etc/webapps/$_gitname/script_server.yml" + install -Dm644 $_gitname-build/config/oauth_keys.yml.example "$pkgdir/etc/webapps/$_gitname/oauth_keys.yml" - find -type d -name ".git" -exec rm -fr '{}' \; &>/dev/null || true + # Include all gems + cd "${usrdir}/${_gitname}" + mkdir -p ${usrdir}/${_gitname}/vendor/ruby/1.9.1/ + ln -s ${srcdir}/gem-cache ${usrdir}/${_gitname}/vendor/cache + ln -s ${srcdir}/gem-cache ${usrdir}/${_gitname}/vendor/ruby/1.9.1/cache + + export GEM_HOME="${PWD}/vendor" + export GEM_PATH="${PWD}/vendor" + export PATH="${GEM_PATH}/bin:${PATH}" + +# TODO extract mysql2 version from Gemfile + case $DB in + mysql) + gem install mysql2 -v "0.2.17" -- --with-mysql-config=/usr/bin/mysql_config + + ;; + posgres) + gem install pg -- --with-pg-config=/usr/bin/pg_config + + # Preconfigure right subsection in database.yml.example + sed -e "s/<<: \*mysql/#<<: \*mysql/" \ + -e "s/#<<: \*postgres/<<: \*postgres/" \ + -i $_gitname-build/config/database.yml.example + + # Preconfigure right db in script_server.yml + sed "s/db: \"mysql\"/db: \"postgres\"/" \ + -i $_gitname-build/config/script_server.yml.example + + esac + + gem install bundler + bundle install --path ${GEM_PATH} --without development test heroku - install -Dm755 ${_gitname}.bin "${pkgdir}/usr/bin/${_gitname}" - install -Dm755 ${_gitname}.rc "${pkgdir}/etc/rc.d/${_gitname}" - install -Dm644 ${_gitname}.logrotate "${pkgdir}/etc/logrotate.d/${_gitname}" - install -Dm644 ${_gitname}.pam "${pkgdir}/etc/pam.d/${_gitname}" + install -d $pkgdir/usr/share/licenses/$_gitname/ + install -Dm644 ${srcdir}/$_gitname-build/{AUTHORS,COPYRIGHT,GNU-AGPL-3.0} \ + $pkgdir/usr/share/licenses/$_gitname/ - install -d ${pkgdir}/usr/share/licenses/${_gitname}/ - install -Dm644 ${srcdir}/${_gitname}-build/{AUTHORS,COPYRIGHT,GNU-AGPL-3.0} \ - ${pkgdir}/usr/share/licenses/${_gitname}/ + msg "Removing gem cache" + rm -vr ${usrdir}/${_gitname}/vendor/{,ruby/1.9.1/}cache } package_diaspora-mysql-git() { pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network (MySQL version)" provides=('diaspora-mysql' 'diaspora') - depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'mysql') + depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'net-tools' 'mysql' 'libmysqlclient') options=(!strip) export DB="mysql" + export _db_rc="mysqld" _package } @@ -118,21 +162,11 @@ package_diaspora-mysql-git() { package_diaspora-postgresql-git() { pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network (PostgreSQL version)" provides=('diaspora-postgresql' 'diaspora') - depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'postgresql') - options=(!strip) - - export DB="postgresql" - - _package -} - -package_diaspora-sqlite-git() { - pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network (SQLite3 version)" - provides=('diaspora-sqlite' 'diaspora') - depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'sqlite3') + depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'net-tools' 'postgresql') options=(!strip) - export DB="sqlite" + export DB="postgres" + export _db_rc="postgresql" _package } diff --git a/social/diaspora-git/diaspora.bashrc b/social/diaspora-git/diaspora.bashrc new file mode 100644 index 000000000..b694ca0b0 --- /dev/null +++ b/social/diaspora-git/diaspora.bashrc @@ -0,0 +1,6 @@ +export GEM_HOME="${HOME}/.gems" +export GEM_PATH="${HOME}/.gems" +export PATH="${GEM_PATH}/bin:${PATH}" +export RAILS_ENV="production" +export DB="-DB-" + diff --git a/social/diaspora-git/diaspora.bin b/social/diaspora-git/diaspora.bin index 2168c7e7c..dfd0d026f 100644 --- a/social/diaspora-git/diaspora.bin +++ b/social/diaspora-git/diaspora.bin @@ -1,6 +1,9 @@ -#!/bin/bash +#!/bin/sh -cd /usr/share/webapps/diaspora -export GEM_HOME=${PWD}/vendor - -./script/server &>>/var/log/diaspora.log +if [ "$(whoami)" == "diaspora" ]; then + cd /usr/share/webapps/diaspora + source ./.bashrc + ./script/server &>>/var/log/diaspora.log +else + echo 'Please run this as the "diaspora" user!' +fi diff --git a/social/diaspora-git/diaspora.rc b/social/diaspora-git/diaspora.rc index bd79237ee..8464f3947 100644 --- a/social/diaspora-git/diaspora.rc +++ b/social/diaspora-git/diaspora.rc @@ -10,8 +10,8 @@ PID=`pgrep -u $daemon_name` case "$1" in start) - #Check if mysqld and redis are running, start them if not - ck_daemon mysqld && /etc/rc.d/mysqld start + #Check if db and redis are running, start them if not + ck_daemon -DB- && /etc/rc.d/-DB- start ck_daemon redis && /etc/rc.d/redis start if [ ! -e /var/log/$daemon_name.log ]; then -- cgit v1.2.3-54-g00ecf