updated on Wed Jan 11 00:07:16 UTC 2012
[aur-mirror.git] / diaspora-git / PKGBUILD
blob86d3dfc913e66ed78b8432eb7d695a1b1309f109
1 # Maintainer: fauno <fauno@kiwwwi.com.ar>
2 # Maintainer: Hilton Medeiros <medeiros.hilton at gmail dot com>
3 # Contributor: Jonne Haß <me@mrzyx.de>
4 # Contributor: Splashy <splash at open-web dot fr>
6 # After installing, see the Diaspora wiki page for more information:
7 # https://wiki.archlinux.org/index.php/Diaspora
9 pkgbase=diaspora-git
10 pkgname=diaspora-git
11 true && pkgname=('diaspora-mysql-git' 'diaspora-postgresql-git')
12 pkgver=20120105
13 pkgrel=1
14 pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network"
15 arch=('i686' 'x86_64')
16 url="https://diasporafoundation.org/"
17 license=('AGPL3')
18 depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'net-tools')
19 makedepends=('git' 'libmysqlclient' 'postgresql-libs')
20 provides=('diaspora')
21 install=diaspora.install
22 source=('diaspora.bin'
23         'diaspora.rc'
24         'diaspora.logrotate'
25         'diaspora.pam'
26         'diaspora.bashrc')
27 md5sums=('547b0015c83da22bd739dc85fd79f9b9'
28          'b7a893271d9ba778f74569eff4190c06'
29          '60f6b3972c73cbc6b1c9ab87c88fb655'
30          '96f82c38f3f540b53f3e5144900acf17'
31          '53867bfd389dd267eefcefb053fecc5b')
33 _gitroot="git://github.com/diaspora/diaspora.git"
34 _gitname="diaspora"
36 build() {
37   cd "$srcdir"
39   msg "Connecting to the Git server..."
41   if [[ -d $_gitname ]] ; then
42     pushd $_gitname
43     tsocks git pull origin
44     msg "The local files are updated."
45     popd
46   else
47     tsocks git clone $_gitroot
48     msg "Git clone done."
49   fi
51   msg "Start making..."
53   [[ -d $_gitname-build ]] && rm -fr $_gitname-build
54   git clone $_gitname $_gitname-build
55   cd ${srcdir}/${_gitname}-build
57   # Symlink configs 
58   ln -s /etc/webapps/$_gitname/application.yml config/application.yml
59   ln -s /etc/webapps/$_gitname/database.yml config/database.yml
60   ln -s /etc/webapps/$_gitname/script_server.yml config/script_server.yml
61   ln -s /etc/webapps/$_gitname/oauth_keys.yml config/oauth_keys.yml
63   # Set version header
64   sed "s|git_cmd = \`git log -1 --pretty=\"format:%H %ci\"\`|git_cmd = \"$(git log -1 --pretty="format:%H %ci")\"|" \
65       -i config/initializers/version_header.rb
67   # Preconfigure config/script_server.yml.example
68   sed 's|rails_env: "development"|rails_env: "production"|' \
69       -i config/script_server.yml.example
70   
71   # Preconfigure right ca_file
72   sed "s|ca_file: '/etc/pki/tls/certs/ca-bundle.crt' # CentOS|ca_file: '/etc/ssl/certs/ca-certificates.crt' # Arch|" \
73       -i config/application.yml.example
75   # We make this now because we do not install the git history
76   # Comply with AGPLv3
77   tar czf public/source.tar.gz  `git ls-tree -r master | awk '{print $4}'`
79   # Remove git repo
80   rm -fr .git
82   # Create gem cache
83   mkdir -p ${srcdir}/gem-cache
86 # Helper
87 _package() {
88   cd "${srcdir}"
90   usrdir="${pkgdir}/usr/share/webapps"
92   install -d "${usrdir}"
93   cp -a ${_gitname}-build "${usrdir}/${_gitname}"
95   install -Dm755 $_gitname.bin "$pkgdir/usr/bin/$_gitname"
96   install -Dm755 $_gitname.rc "$pkgdir/etc/rc.d/$_gitname"
97   install -Dm644 $_gitname.logrotate "$pkgdir/etc/logrotate.d/$_gitname"
98   install -Dm644 $_gitname.pam "$pkgdir/etc/pam.d/$_gitname"
99   install -Dm644 $_gitname.bashrc "$usrdir/$_gitname/.bashrc"
101 # Set the DB in the environment
102   sed -i "s/-DB-/$DB/g" "$usrdir/$_gitname/.bashrc"
103   sed -i "s/-DB-/$_db_rc/g" "$pkgdir/etc/rc.d/$_gitname"
105   install -Dm644 $_gitname-build/config/application.yml.example "$pkgdir/etc/webapps/$_gitname/application.yml"
106   install -Dm644 $_gitname-build/config/database.yml.example "$pkgdir/etc/webapps/$_gitname/database.yml"
107   install -Dm644 $_gitname-build/config/script_server.yml.example "$pkgdir/etc/webapps/$_gitname/script_server.yml"
108   install -Dm644 $_gitname-build/config/oauth_keys.yml.example "$pkgdir/etc/webapps/$_gitname/oauth_keys.yml"
110   # Include all gems
111   cd "${usrdir}/${_gitname}"
112   mkdir -p ${usrdir}/${_gitname}/vendor/ruby/1.9.1/
113   ln -s ${srcdir}/gem-cache ${usrdir}/${_gitname}/vendor/cache
114   ln -s ${srcdir}/gem-cache ${usrdir}/${_gitname}/vendor/ruby/1.9.1/cache
116   export GEM_HOME="${PWD}/vendor"
117   export GEM_PATH="${PWD}/vendor"
118   export PATH="${GEM_PATH}/bin:${PATH}"
120 # TODO extract mysql2 version from Gemfile
121   case $DB in
122     mysql)
123       tsocks gem install mysql2 -v "0.2.17" -- --with-mysql-config=/usr/bin/mysql_config
125       ;;
126     posgres)
127       tsocks gem install pg -- --with-pg-config=/usr/bin/pg_config
129       # Preconfigure right subsection in database.yml.example
130       sed -e "s/<<: \*mysql/#<<: \*mysql/" \
131           -e "s/#<<: \*postgres/<<: \*postgres/" \
132           -i $_gitname-build/config/database.yml.example
133       
134       # Preconfigure right db in script_server.yml
135       sed "s/db: \"mysql\"/db: \"postgres\"/" \
136           -i $_gitname-build/config/script_server.yml.example
137       
138   esac
140   tsocks gem install bundler
141   tsocks bundle install --path ${GEM_PATH} --without development test heroku
143   install -d $pkgdir/usr/share/licenses/$_gitname/
144   install -Dm644 ${srcdir}/$_gitname-build/{AUTHORS,COPYRIGHT,GNU-AGPL-3.0} \
145                  $pkgdir/usr/share/licenses/$_gitname/
147   msg "Removing gem cache"
148   rm -vr ${usrdir}/${_gitname}/vendor/{,ruby/1.9.1/}cache
151 package_diaspora-mysql-git() {
152     pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network (MySQL version)"
153     provides=('diaspora-mysql' 'diaspora')
154     depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'net-tools' 'mysql' 'libmysqlclient')
155     options=(!strip)
157     export DB="mysql"
158     export _db_rc="mysqld"
160     _package
163 package_diaspora-postgresql-git() {
164     pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network (PostgreSQL version)"
165     provides=('diaspora-postgresql' 'diaspora')
166     depends=('ruby' 'redis' 'imagemagick' 'libxslt' 'net-tools' 'postgresql')
167     options=(!strip)
169     export DB="postgres"
170     export _db_rc="postgresql"
172     _package
174 pkgdesc="A privacy aware, personally controlled, do-it-all, open source social network"