summaryrefslogtreecommitdiff
path: root/social/diaspora-git/PKGBUILD
blob: 3f371d1118d539e6dd7d2a0c6a1c838d8a5e3c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Maintainer: fauno <fauno@kiwwwi.com.ar>
# Maintainer: Hilton Medeiros <medeiros.hilton at gmail dot com>
# Contributor: Jonne Haß <me@mrzyx.de>
# Contributor: Splashy <splash at open-web dot fr>

# 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')
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' 'net-tools')
makedepends=('git' 'libmysqlclient' 'postgresql-libs')
provides=('diaspora')
install=diaspora.install
source=('diaspora.bin'
        'diaspora.rc'
        'diaspora.logrotate'
        'diaspora.pam'
        'diaspora.bashrc')
md5sums=('547b0015c83da22bd739dc85fd79f9b9'
         'b7a893271d9ba778f74569eff4190c06'
         '60f6b3972c73cbc6b1c9ab87c88fb655'
         '96f82c38f3f540b53f3e5144900acf17'
         '53867bfd389dd267eefcefb053fecc5b')

_gitroot="git://github.com/diaspora/diaspora.git"
_gitname="diaspora"

# I use this because I'm behind an asshole proxy
# tsocks=tsocks

build() {
  cd "$srcdir"

  msg "Connecting to the Git server..."

  if [[ -d $_gitname ]] ; then
    pushd $_gitname
    git pull origin
    msg "The local files are updated."
    popd
  else
    git clone $_gitroot
    msg "Git clone done."
  fi

  msg "Start making..."

  [[ -d $_gitname-build ]] && rm -fr $_gitname-build
  git clone $_gitname $_gitname-build
  cd ${srcdir}/${_gitname}-build

  # 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

  # 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

  # 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
_package() {
  cd "${srcdir}"

  usrdir="${pkgdir}/usr/share/webapps"

  install -d "${usrdir}"
  cp -a ${_gitname}-build "${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 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"

  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"

  # 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 -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' 'net-tools' 'mysql' 'libmysqlclient')
    options=(!strip)

    export DB="mysql"
    export _db_rc="mysqld"

    _package
}

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' 'net-tools' 'postgresql')
    options=(!strip)

    export DB="postgres"
    export _db_rc="postgresql"

    _package
}