You are not logged in.

#1 2006-07-19 06:20:45

V01D
Member
Registered: 2006-07-18
Posts: 128

creating PKGBUILD for p3scan - I have some questions

I've made a post to tur-users mailing list but there's something not working there. I see the mails from other people in the archives but I'm not getting anything at my mailbox. Until I get that working I thought that I could post here:

Hi,
I'm assembling the PKGBUILD and necessary scripts to build a package for
p3scan (http://p3scan.sourceforge.net). It uses a handcrafted Makefile with
some hardcoded values, so it's a bit of a struggle. I have some questions
about decisions I should take:
a) upon make install, the Makefile creates some directories where the
program will store its .pid file and the infected messages it finds (under
/var/run/p3scan and /var/spool/p3scan). Should I let make install create
this directories (so they get created inside the .pkg and the will get
extracted when installed) or should I create them on post_install? Also,
these directories need to be chowned mail.mail (the default user under which
p3scan runs). make install chowns everything correctly anyway.
b) are these /var directories correct according to Arch standards?
c) The 'install' command used on the Makefile fails when makepkg'ing,
because it can't find directories like /usr/sbin under the package root, it
assumes they're already there. I tried to add the '-D' parameter to it but
it's the same. Therefore I used mkdir -p to create the necessary
directories.

I post my current PKGBUILD here (my .install just echoes something like
"Using clamav package is recommended"). I also include a script to be put
under /etc/rc.d.
PKGBUILD:

# Contributor: v01d <phreakuencies at gmail.com>
pkgname=p3scan
pkgver=2.3.2
pkgrel=1
pkgdesc="Fully transparent POP3/SMTP proxy with Anti-Virus and SPAM
protection"
arch=(i686)
url="http://p3scan.sourceforge.net/"
depends=('pcre' 'openssl')
source=("
http://dl.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz");
md5sums=('9f8decc7d4701228788e3c8717096ca0')
#install=p3scan.install

build() {
  cd $startdir/src/$pkgname-$pkgver

  # Fix CFLAGS and other options hardcoded in Makefiles
  sed -ri "s|^CFLAGS=-Wall( -g)? -O2|CFLAGS=-Wall $CFLAGS|" Makefile
ripmime/Makefile ripmime/tnef/Makefile ripmime/ripOLE/Makefile
  sed -ri 's|^LOCATION=.+$|LOCATION=/usr|' ripmime/Makefile
  sed -ri 's|$(SYSINS) -v -m 550 --strip p3scan
$(PREFIX)/sbin/|$(SYSINS) -D -v -m 550 --strip p3scan
$(DESTDIR)/usr/sbin/|' Makefile
  make || return 1

  # Create base dirs, the Makefile assumes they're there
  mkdir -p $startdir/pkg/usr/sbin $startdir/pkg/etc/rc.d
$startdir/pkg/usr/man/man8

  # install with root set on $startdir/pkg
  make DESTDIR=$startdir/pkg install || return 1

  # NOTE: should I create all dirs created during make install on
post_install?

  # delete init script provided and use an arch compatible one
  rm -f $startdir/pkg/etc/rc.d/rc.p3scan
  cp $startdir/rc.p3scan $startdir/pkg/etc/rc.d/p3scan
  chown root.root $startdir/pkg/etc/rc.d/p3scan
  chmod 700 $startdir/pkg/etc/rc.d/p3scan

  # make absolute link a relative one
  (
        cd $startdir/pkg/etc/p3scan
    ln -sf p3scan-en.mail p3scan.mail
  )

}

And the rc script (I just used the script that comes with the source and
adapted it):

#!/bin/bash

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

case "$1" in
        start)
        stat_busy "Starting p3scan"
          if [ -a /var/run/p3scan/p3scan.pid ]; then stat_die; fi

        # Start p3scan
    /usr/sbin/p3scan
          if ! [ -a /var/run/p3scan/p3scan.pid ]; then stat_die; fi
    add_daemon p3scan
    stat_done
  ;;
  stop)
        stat_busy "Stopping p3scan"

        # Stop p3scan
    if [ -a /var/run/p3scan/p3scan.pid ]; then
        kill `cat /var/run/p3scan/p3scan.pid` &>/dev/null || stat_die
      rm -f /var/run/p3scan/p3scan.pid
      rm_daemon p3scan
      stat_done
    else
        stat_fail
    fi
  ;;
  restart)
        $0 stop
    sleep 1
    $0 start
  ;;
  *)
        echo "Usage: $0 { start | stop | restart }"
esac
exit 0

Thanks

Offline

#2 2006-07-20 04:07:03

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: creating PKGBUILD for p3scan - I have some questions

V01D wrote:

Hi,
I'm assembling the PKGBUILD and necessary scripts to build a package for
p3scan (http://p3scan.sourceforge.net). It uses a handcrafted Makefile with
some hardcoded values, so it's a bit of a struggle. I have some questions
about decisions I should take:
a) upon make install, the Makefile creates some directories where the
program will store its .pid file and the infected messages it finds (under
/var/run/p3scan and /var/spool/p3scan). Should I let make install create
this directories (so they get created inside the .pkg and the will get
extracted when installed) or should I create them on post_install? Also,
these directories need to be chowned mail.mail (the default user under which
p3scan runs). make install chowns everything correctly anyway.

Create these directories in the PKGBUILD (with make install)

V01D wrote:

b) are these /var directories correct according to Arch standards?

Yes, they are correct.

V01D wrote:

c) The 'install' command used on the Makefile fails when makepkg'ing,
because it can't find directories like /usr/sbin under the package root, it
assumes they're already there. I tried to add the '-D' parameter to it but
it's the same. Therefore I used mkdir -p to create the necessary
directories.

That's fine. BTW, you can also use 'install -d' instead of 'mkdir -p' to create the directories.

Some comment about the PKGBUILD:
1. Put rc.p3scan in the source array. Remove the ';' at the end of the source array.
2. If you use a .install file, you'll need to uncomment the #install=p3scan.install
3. To install the script, replace:
  cp $startdir/rc.p3scan $startdir/pkg/etc/rc.d/p3scan
  chown root.root $startdir/pkg/etc/rc.d/p3scan
  chmod 700 $startdir/pkg/etc/rc.d/p3scan
by:
install -D -m755 $startdir/src/rc.p3scan $startdir/pkg/etc/rc.d/p3scan

Offline

#3 2006-07-20 04:25:01

V01D
Member
Registered: 2006-07-18
Posts: 128

Re: creating PKGBUILD for p3scan - I have some questions

thank you for the reply
I also got it on the mailing list, seems I only receive mails that are answers to my posts.

BTW, I made the rc.p3scan script and I can't provide a stable URL from where it should be downloaded. I though adding it to the tarball that I'm going to send to AUR. Is that the proper way?

Offline

#4 2006-07-20 07:22:22

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: creating PKGBUILD for p3scan - I have some questions

ML: You should receive all the emails that are sent to the list. You didn't get other emails yet because nobody (exept me) has posted since your initial e-mail. wink

Yes. Add the script and the .install file, if any, in the tarball.
They should be with the PKGBUILD in a directory named p3scan.

Offline

Board footer

Powered by FluxBB