You are not logged in.

#1 2010-06-30 13:33:53

billy
Member
From: Slovenia
Registered: 2006-09-13
Posts: 164

[request] redmine

Hi, I created a package for redmine (issue tracker) and I have some question about packaging:

  - I put the program in /opt/ dir because some folders are owned by 'redmine' user and some files are created after first run so they are not deleted on package removal. I think that this shouldn't go in /usr/. Or should I put the program elsewhere?
  - Is the package good enough for AUR?

PKGBUILD:

# Maintainer: Blaž Tomažič <blaz.tomazic@gmail.com>
pkgname=ruby-redmine
pkgver=0.9.5
pkgrel=1
_realname="redmine"
pkgdesc="Redmine is a flexible project management web application written using Ruby on Rails framework."
arch=('i686' 'x86_64')
url="http://www.redmine.org/"
license=('GPL')
depends=('ruby1.8' 'ruby-rails' 'ruby-rack' 'ruby-rake' 'mysql-ruby' 'procps')
options=()
install=ruby-redmine.install
changelog=
source=("http://rubyforge.org/frs/download.php/71421/$_realname-$pkgver.tar.gz"
        "redmine")
md5sums=('9ffa4985d200606263b2a2d430e3e441'
         'b301b569c4a0eb5e461a75afa8f1b8dd')

#build() {
#}

package() {
  cd "$srcdir/$_realname-$pkgver"
  
  #install in /opt/
  _instdir="$pkgdir/opt/$_realname"
  mkdir -p ${_instdir}
  cp -ra . ${_instdir}
  
  #create some needed dir
  mkdir -p public/plugin_assets
  
  #create /etc/rc.d/redmine
  mkdir -p "$pkgdir/etc/rc.d/"
  cp "$srcdir/redmine" "$pkgdir/etc/rc.d/redmine"
  
  #create redmine user home
  mkdir -p "$pkgdir/var/lib/redmine/"
}

# vim:set ts=2 sw=2 et:

ruby-redmine.install:

post_install() {
  #create user and group
  getent group "redmine" &>/dev/null || groupadd -r -g 155 redmine 1>/dev/null
  getent passwd "redmine" &>/dev/null || useradd -r -u 155 -g redmine -d "/var/lib/redmine" -s "/bin/true" redmine 1>/dev/null
  chown -R redmine:redmine "/var/lib/redmine" 1>/dev/null
  
  #change owner
  for dir in /opt/redmine/{files,log,tmp,public/plugin_assets}; do
    chown -R redmine:redmine "$dir" 1>/dev/null
    chmod -R 755 "$dir" 1>/dev/null
  done 
  
  #generate session secret
  cd /opt/redmine/
  rake generate_session_store 1>/dev/null
  
  echo "==> redmine: Create a config under /opt/redmine/config/database.yml (Example: /opt/redmine/config/database.yml.example) and follow steps 2,3,5,6,9 on http://www.redmine.org/wiki/redmine/RedmineInstall before using Redmine"
}

post_upgrade() {
  echo "==> redmine: Create a config under /opt/redmine/config/database.yml (Example: /opt/redmine/config/database.yml.example) and follow steps 2,3,5,6,9 on http://www.redmine.org/wiki/redmine/RedmineInstall before using Redmine"
}

post_remove() {
  getent passwd "redmine" &>/dev/null && userdel redmine 1>/dev/null
  getent group "redmine" &>/dev/null && groupdel redmine 1>/dev/null
  return 0
}


# vim:set ts=2 sw=2 et:

/etc/rc.d/redmine:

#!/bin/bash

daemon_name=redmine
daemon_command="ruby /opt/redmine/script/server webrick -d -e production"

. /etc/rc.conf
. /etc/rc.d/functions

get_pid() {
    pgrep -u redmine -f "${daemon_command}"
}

case "$1" in
  start)
    stat_busy "Starting $daemon_name daemon"

    PID=$(get_pid)
    if [ -z "$PID" ]; then
      [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
      # RUN
      su -s '/bin/sh' redmine -c "${daemon_command} &>/dev/null"
      #
      if [ $? -gt 0 ]; then
        stat_fail
        exit 1
      else
        echo $(get_pid) > /var/run/$daemon_name.pid
        add_daemon $daemon_name
        stat_done
      fi
    else
      stat_fail
      exit 1
    fi
    ;;

  stop)
    stat_busy "Stopping $daemon_name daemon"
    PID=$(get_pid)
    # KILL
    [ ! -z "$PID" ] && kill -9 $PID &> /dev/null
    #
    if [ $? -gt 0 ]; then
      stat_fail
      exit 1
    else
      rm -f /var/run/$daemon_name.pid &> /dev/null
      rm_daemon $daemon_name
      stat_done
    fi
    ;;

  restart)
    $0 stop
    sleep 1
    $0 start
    ;;

  status)
    stat_busy "Checking $daemon_name status";
    ck_status $daemon_name
    ;;

  *)
    echo "usage: $0 {start|stop|restart|status}"
esac

exit 0

Offline

#2 2010-07-22 12:14:48

cl
Member
Registered: 2010-07-22
Posts: 4

Re: [request] redmine

+1

It would be nice to see a proper PkgBuild of the latest redmine version in the AUR.
Unfortunately,  i've no idea to do this in the right way...

Offline

#3 2010-07-22 14:13:46

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [request] redmine

Generally, things in /opt are programs that conflicts with "standard" or non-current packages. Examples:

* Installing an old version of GCC
* virtualbox_bin vs. virtualbox-ose (_bin is the AUR pkg and installed to /opt)
* jdk vs. openjdk6 (both are in pacman, but jdk is installed to /opt/java)

Your package doesn't fit this criteria. There's also plenty of examples of programs leaving behind data after uninstallation, complete with their own user. mysql and mpd come to mind. You're creating a home directory in /var/lib for user redmine, why not put the database and other directory structures there?

Offline

#4 2010-07-25 11:23:25

billy
Member
From: Slovenia
Registered: 2006-09-13
Posts: 164

Re: [request] redmine

Thx for the info smile. I''l update the package and upload it to AUR in next few days when I will have more time.

Offline

#5 2010-08-07 09:25:59

billy
Member
From: Slovenia
Registered: 2006-09-13
Posts: 164

Re: [request] redmine

Finally I did it smile. I moved package to /var/lib/redmine and added post_upgrade function to migrate database properly.

Package is located here: http://aur.archlinux.org/packages.php?ID=39468.

You can run ruby on rails server on localhost:3000 with /etc/rc.d/redmine. If you want to run it with apache or some other webserver you have to do it on your own.

Last edited by billy (2010-08-07 09:36:10)

Offline

Board footer

Powered by FluxBB