You are not logged in.

#1 2007-08-14 13:13:28

morellik
Member
From: Italy
Registered: 2007-04-05
Posts: 43

pre_install function doesn't work

Dear all,

there are some issues to know to use the pre_install function?

I used it to add an user and a group (using groupadd and useradd) before install a package (zabbix-agent),
but the pre_install instructions are bypassed by pacman. So I had to put the instructions in the post_install function
and use chown to do the things that I did using install command.

Enrico

Offline

#2 2007-08-14 13:26:47

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: pre_install function doesn't work

can you post your PKGBUILD and install file please?

Offline

#3 2007-08-14 13:32:32

morellik
Member
From: Italy
Registered: 2007-04-05
Posts: 43

Re: pre_install function doesn't work

# Contributor: Enrico Morelli <morelli@cerm.unifi.it>
pkgname=zabbix-agent
pkgver=1.4.1
pkgrel=1
pkgdesc="Software for monitoring of your applications, network and servers."
arch=(i686)
url="http://www.zabbix.com"
license=('GPL')
install=(zabbix-agent.install)
source=(http://downloads.sourceforge.net/sourceforge/zabbix/zabbix-$pkgver.tar.gz  zabbix_agent.conf zabbix_agentd.conf zabbix-agentd zabbix-agent.install)
md5sums=('c9e9a12eeb3ae784075cb7899f200889'
         'dca8d533925687d02825a5401e723c3d'
         '03be35f02a504402ea6355782675b139'
         '58af39391846bd0f5ab069944979ed53'
         '6eee166f32e28be8ffeeed93a017f055')

build() {
  cd $startdir/src/zabbix-$pkgver
  ./configure --prefix=/usr --enable-agent
  make || return 1
  make DESTDIR=$startdir/pkg install
  install -d -o zabbix -g zabbix  -m0750 $startdir/pkg/var/run/zabbix $startdir/pkg/var/log/zabbix
  install -d -o zabbix -g zabbix  $startdir/pkg/etc/zabbix
  install -D -o zabbix -g zabbix -m0640 $startdir/src/zabbix_agent.conf $startdir/pkg/etc/zabbix/zabbix_agent.conf
  install -D -o zabbix -g zabbix -m0640 $startdir/src/zabbix_agentd.conf $startdir/pkg/etc/zabbix/zabbix_agentd.conf
  install -D -o zabbix -g zabbix -m0755 $startdir/src/zabbix-agentd $startdir/pkg/etc/rc.d/zabbix-agentd
}
pre_install() {
  groupadd zabbix
  useradd -g zabbix -d /dev/null zabbix
}

post_remove() {
   userdel zabbix
   rm -rf /var/run/zabbix
}

op=$1
shift
$op $*

Offline

#4 2007-08-14 14:18:14

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: pre_install function doesn't work

I think you're confused about what pre_install does.  The function pre_install is run before the package is installed via pacman -S or pacman -U.  No functions in the install file will run during package build (ie. during makepkg).

The group won't exist until after the package is installed, so your commands

install -d -o zabbix -g zabbix

won't work.  Generally, the way to handle this is to specify a specific user ID and group ID in the install file, and use those ids in the build() function.

Also, why does the rc.d script (or anything for that matter) need user/group to be set to zabbix?

Offline

#5 2007-08-14 14:58:33

morellik
Member
From: Italy
Registered: 2007-04-05
Posts: 43

Re: pre_install function doesn't work

Cerebral wrote:

I think you're confused about what pre_install does.  The function pre_install is run before the package is installed via pacman -S or pacman -U.  No functions in the install file will run during package build (ie. during makepkg).

The group won't exist until after the package is installed, so your commands

install -d -o zabbix -g zabbix

won't work.  Generally, the way to handle this is to specify a specific user ID and group ID in the install file, and use those ids in the build() function.

Ok. So what is the best solution to solve the problem?
Use useradd in the pre_install  or in the post_install function?

Also, why does the rc.d script (or anything for that matter) need user/group to be set to zabbix?

This is my mistake.   In the real PKGBUILD there isn't changes of owner.

Enrico

Offline

#6 2007-08-14 15:23:01

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: pre_install function doesn't work

Take a look at the way the Cube PKGBUILD and install file does it - http://cvs.archlinux.org/cgi-bin/viewcv … ag=CURRENT

That's generally how you'd add a group and make sure certain files were chgrp'd to that group.

Again, though, why do these files need to be part of the zabbix group?

Offline

Board footer

Powered by FluxBB