You are not logged in.

#1 2004-04-25 19:55:01

blue_ant
Member
From: Italy
Registered: 2004-04-24
Posts: 19

[network: web utilities] privoxy

I missed this package from the distribution I'm coming from so I decided to build an arch package for it...

If you don't' know privoxy, it is a proxy that filters out ads from the webpages you are visiting, and allows to you to decide how to deal with cookies and referrers...

the PKGBUILD file is the following:

pkgname=privoxy
pkgver=3.0.3_2_stable
pkgrel=1
pkgdesc="A web proxy with advanced filtering capabilities."
url="http://www.privoxy.org"
license=""
depends=()
makedepends=()
provides=()
conflicts=()
replaces=()
backup=()
install=
source=(http://easynews.dl.sourceforge.net/sourceforge/ijbswa/$pkgname-3.0.3-2-stable.src.tar.gz privoxyd config.diff)
md5sums=('d7f6c2fcb926e6110659de6e866b21e4')

pre_remove() {
  /usr/sbin/userdel privoxy
  /usr/sbin/groupdel privoxy
}

build() {
  /usr/sbin/groupadd privoxy
  /usr/sbin/useradd privoxy -g privoxy

  cd $startdir/src/$pkgname-3.0.3-stable
  autoheader
  autoconf
  ./configure --prefix=/usr --sysconfdir=$startdir/pkg/etc/privoxy --localstatedir=$startdir/pkg/var
  make || return 1
  make prefix=$startdir/pkg/usr install

  cd $startdir/pkg/etc/privoxy
  patch config < ../../../config.diff

  cd $startdir/src/$pkgname-3.0.3-stable
  install -D -m755 ../privoxyd $startdir/pkg/etc/rc.d/privoxyd
}

Don't know exactly the arch conventions for building packages, anyway I used _ instead of - for the package version, and didn't put any file in the backup field. Instead of /usr/etc and /usr/var as many packages I've seen, I've put logs in /var/log and configs in /etc/privoxy, beacuse it's a daemon... hope it follows arch standards... if not tell me, and I'll fix it... and the script also creates user and group privoxy.

I've also created a privoxyd script to be put in your rc.conf:

#!/bin/bash

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

PID=`pidof -o %PPID /usr/sbin/privoxy`
case "$1" in
  start)
    stat_busy "Starting Privoxy"
    [ -z "$PID" ] && /usr/sbin/privoxy /etc/privoxy/config > /dev/null 2>&1
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon privoxyd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Privoxy"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon privoxyd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

Starting the daemon does not produce oputput because of the /dev/null.


The small diff applied in PKGBUILD is only for the config file in /etc/privoxy:

107c107
< confdir /var/abs/local/privoxy/pkg/etc/privoxy
---
> confdir /etc/privoxy
134c134
< logdir /var/abs/local/privoxy/pkg/var/log/privoxy
---
> logdir /var/log/privoxy

Ok download the package, put the daemon in rc.confd, start it and set in your browser localhost:8118 as proxy, and enyoy your new privacy! yikes

----
blue_ant

PS: I hope the file is uploaded correctly in incoming, I've got some troubles with my ftp client

AIR
http://bliss-solutions.org/archlinux/in … php?id=636

Offline

#2 2004-04-25 20:59:25

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: [network: web utilities] privoxy

Alright. I'll handle this one.

Having the install functions in the PKGBUILD (pre_remove) will do nothing.  I have no idea where people got the idea that that would work...  You need a seperate install script a la /var/abs/install.proto.

You can download from dl.sourceforge.net and it will pick an available mirror.

Packages should not use /usr/etc or /usr/var and any that do should be bug reported.

Don't add users in the build() function, it'll only add them on the machine the package is built on and not the ones it's installed on.  To options in that case, add users like mysql does (in /etc/rc.d/mysql) or like clamav does (in the post_install script).

Make your configure line look like this:

./configure --prefix=/usr --sysconfdir=/etc/privoxy --localstatedir=/var 

and your make install like look like this:

make prefix=$startdir/pkg/usr sysconfdir=$startdir/pkg/etc/privoxy localstatedir=$startdir/pkg/var install

or even better, if the build system supports DESTDIR:

make DESTDIR=$startdir/pkg install

then you don't need the patch (which wouldn't work if you built it in any directory other than /var/abs/local/privoxy, which I do).

There are a couple other weird things in there... like the last two lines of the build() function.  Why not just do this?

install -D -m755 $startdir/src/privoxyd $startdir/pkg/etc/rc.d/privoxyd

it is allowed you know...


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#3 2004-04-26 06:05:54

blue_ant
Member
From: Italy
Registered: 2004-04-24
Posts: 19

Re: [network: web utilities] privoxy

Xentac wrote:

Alright. I'll handle this one.

Having the install functions in the PKGBUILD (pre_remove) will do nothing.  I have no idea where people got the idea that that would work...  You need a seperate install script a la /var/abs/install.proto.

:oops: You are right... maybe people (like me) make this mistake, because they see the build function and think that pre_remove and othes are in the same file, withouth thinking that the pkgbuild is only for building... maybe the real reason was that I read the wiki too fast... big_smile

Xentac wrote:

You can download from dl.sourceforge.net and it will pick an available mirror.

Ok thank you, Il'' fix this immediately.

Xentac wrote:

Packages should not use /usr/etc or /usr/var and any that do should be bug reported.

on my system:

ls /usr/etc/
dhcpc  gimp  gtk  im_palette-small.pal  im_palette-tiny.pal  im_palette.pal  imrc  mplayer

ls /usr/var/
abs  cache  empty  lib  local  lock  log  mail  opt  run  spool  tmp

I've a small set of packages, maybe there could be others... but I'll bug report these...

Xentac wrote:

Don't add users in the build() function, it'll only add them on the machine the package is built on and not the ones it's installed on.  To options in that case, add users like mysql does (in /etc/rc.d/mysql) or like clamav does (in the post_install script).

Again same mistake of before: doing things without thinking. sad I'll do it in the post_install it will installed as root, and the postinstall will creaste everything and change the owner and group.

Xentac wrote:

Make your configure line look like this:

./configure --prefix=/usr --sysconfdir=/etc/privoxy --localstatedir=/var

and your make install like look like this:

make prefix=$startdir/pkg/usr sysconfdir=$startdir/pkg/etc/privoxy localstatedir=$startdir/pkg/var install

or even better, if the build system supports DESTDIR:

make DESTDIR=$startdir/pkg install

then you don't need the patch (which wouldn't work if you built it in any directory other than /var/abs/local/privoxy, which I do).

You are perfectly right, but whith such a line:

./configure --prefix=/usr --sysconfdir=/etc/privoxy --localstatedir=/var 

and

make prefix=$startdir/pkg/usr sysconfdir=$startdir/pkg/etc/privoxy localstatedir=$startdir/pkg/var install

the strange privoxy scripts does not install in pkg but directly in /etc/ and /usr, but I know my PKGBUILD has not a good workaround, since the patch will not always work, anyways the workaround is still ugly to see wink

I'll find a solution to this problem...

Xentac wrote:

There are a couple other weird things in there... like the last two lines of the build() function.  Why not just do this?

install -D -m755 $startdir/src/privoxyd $startdir/pkg/etc/rc.d/privoxyd

it is allowed you know...

lol Yes I know it's allowed, cut and paste was faster... wink didn't remumber to change it before uploading...

Thank you for showing me my mistakes! At the end of my second PKGBUILD and of my first "arch week" I've learned to chek my PKGBUILD before posting them... lol

Offline

#4 2004-04-26 11:18:42

blue_ant
Member
From: Italy
Registered: 2004-04-24
Posts: 19

Re: [network: web utilities] privoxy

Ok, I've fixed some stupid errors like pre_removal in PKGBUILD, the mirror in sourceforge, etc etc.

Now, this is a fixed version of the build.

# Contributor: blue_ant <blue_ant@hotpop.com>
pkgname=privoxy
pkgver=3.0.3_2_stable
pkgrel=1
pkgdesc="A web proxy with advanced filtering capabilities."
url="http://www.privoxy.org"
license=""
depends=()
makedepends=()
provides=()
conflicts=()
replaces=()
backup=()
install=('privoxy.install')
source=(http://dl.sourceforge.net/sourceforge/ijbswa/$pkgname-3.0.3-2-stable.src.tar.gz privoxyd)
md5sums=('d7f6c2fcb926e6110659de6e866b21e4' 'b2c21635816ef28924761c6266fa800c')

build() {
  cd $startdir/src/$pkgname-3.0.3-stable
  autoheader
  autoconf
  ./configure --prefix=/usr --sysconfdir=/etc/privoxy --localstatedir=/var
  make || return 1

  # make prefix=$startdir/pkg/usr sysconfdir=$startdir/pkg/etc/privoxy localstatedir=$startdir/pkg/var install
  # does not work...
  cp GNUmakefile GNUmakefile.orig
  sed 's+prefix       = /usr+prefix       = '"$startdir"'/pkg/usr+' GNUmakefile.orig | 
  sed 's+CONF_BASE    = /etc/privoxy+CONF_BASE    = '"$startdir"'/pkg/etc/privoxy+' | 
  sed 's+VAR_DEST     = /var+VAR_DEST     = '"$startdir"'/pkg/var+' | 
  sed -r 's/s{5}exit 1 ;/tttttGROUP_T=root;/' | 
  sed 's+confdir $(CONF_DEST)+confdir /etc/privoxy+' | 
  sed 's+logdir $(LOG_DEST)+logdir /var/log/privoxy+' > GNUmakefile

  make install

  install -D -m755 $startdir/src/privoxyd $startdir/pkg/etc/rc.d/privoxyd
}

Yes there are still patches, this time made with sed, they sould be "builddir-aware", I don't patch the Makefiles or configs for fun, the make install is a little broken, and this is the cleanest way I found to do things. But If you have suggestions, they are welcome...
There is also the patch for the privoxy user, (i put the useradd in the previous PKGBUILD in order to avoid this error, and did not think that it was missing for people installing the package big_smile... maybe to many years from my last binary distro... wink) now it compiles without the privoxy user and group and the privoxy.install will do the job.

Of course there is no more diff patch and here is the new entry privoxy.install:

# arg 1:  the new package version
post_install() {
  # user and group ID arbitrary choosen by me (blue_ant)
  /usr/sbin/groupadd -g 74 privoxy
  /usr/sbin/useradd -u 74 -g privoxy -s /bin/false -d /etc/privoxy privoxy
  chown -R privoxy:privoxy /var/log/privoxy 2>/dev/null
  chown -R privoxy:privoxy /etc/privoxy 2>/dev/null
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  /bin/true
}

# arg 1:  the old package version
pre_remove() {
  /usr/sbin/userdel privoxy &> /dev/null
  /usr/sbin/groupdel privoxy &> /dev/null
}

# arg 1:  the old package version
post_remove() {
  /bin/true
}

op=$1
shift
$op $*

and of course the privoxyd remains the same of before...

#!/bin/bash

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

PID=`pidof -o %PPID /usr/sbin/privoxy`
case "$1" in
  start)
    stat_busy "Starting Privoxy"
    [ -z "$PID" ] && /usr/sbin/privoxy /etc/privoxy/config > /dev/null 2>&1
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon privoxyd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Privoxy"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon privoxyd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

Hope it's better than the previous, (i've done my homeworks now: reading the wiki documentation), don't know if it is easy to mantain, or clean enough, anyways if you have suggestion for making the script better they are welcome, or if I made other stupid mistakes tell me, i'll fix them.

Did not upload in incoming, no overwrite permission...

----
blue_ant

Offline

#5 2004-04-27 18:53:42

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: [network: web utilities] privoxy

Ok, I've removed the old privoxy.tar.bz2.  Please upload this version.


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#6 2004-04-27 20:06:32

blue_ant
Member
From: Italy
Registered: 2004-04-24
Posts: 19

Re: [network: web utilities] privoxy

Thank you...

New version uploaded...

----
blue_ant

Offline

#7 2004-05-09 13:03:35

Haakon
Member
From: Bergen, Norway
Registered: 2004-05-09
Posts: 109

Re: [network: web utilities] privoxy

Oh man, I spent a lot of time making my own Privoxy PKGBUILD since I couldn't find any. I should use the forums more smile


Jabber: haakon@jabber.org

Offline

#8 2004-05-12 22:14:51

Haakon
Member
From: Bergen, Norway
Registered: 2004-05-09
Posts: 109

Re: [network: web utilities] privoxy

I'd like to suggest a small change to privoxy.install. The privoxy user is added as a regular user, complete with a shell. I think it would be more secure to add it with /bin/false as a shell, like so:

/usr/sbin/useradd -g privoxy -s /bin/false privoxy


Jabber: haakon@jabber.org

Offline

#9 2004-05-18 06:16:10

blue_ant
Member
From: Italy
Registered: 2004-04-24
Posts: 19

Re: [network: web utilities] privoxy

Thank you Haakon,
I've fixed the install script in the previous post, with your suggestion and adding the post_remove function.
Of course I can't overwrite privoxy.tar.bz2 in incoming, if someone removes it for me, I shall upload the fixed version.

----
blue_ant

Offline

#10 2004-05-18 12:38:47

farphel
Forum Fellow
From: New Hampshire - USA
Registered: 2003-09-18
Posts: 250
Website

Re: [network: web utilities] privoxy

privoxy.tar.bz2 removed from /incoming.


Follow the link below, sign up, and accept one promotional offer.  If I can get five suckers (err... friends) to do this, I'll get a free iPod.  Then you too can try to get a free iPod. Thanks! http://www.freeiPods.com/?r=11363142

Offline

#11 2004-05-18 18:18:31

blue_ant
Member
From: Italy
Registered: 2004-04-24
Posts: 19

Re: [network: web utilities] privoxy

Thank you farphel.

Before uploading I would like to make the last correction, I would specify in privoxy.install  the user and group id < 99, as privoxy is a system user:

  /usr/sbin/groupadd -g 74 privoxy
  /usr/sbin/useradd -u 74 -g privoxy -s /bin/false -d /etc/privoxy privoxy

On RedHat and SuSE it was 73, but in arch it is already used by postfix, with grep in /var/abs it seems that 74 is free.  I don't know arch conventions about user id numbering, but if 74 is a good choice tell me, so I can upload a definitive version.

----
blue_ant

Offline

#12 2004-05-19 11:03:08

farphel
Forum Fellow
From: New Hampshire - USA
Registered: 2003-09-18
Posts: 250
Website

Re: [network: web utilities] privoxy

For now, stick with 74 since it does appear to be unused.  When a package maintainer adopts the package, it might change.  I'd put a comment in the install script saying that the choice of 74 was arbitrarily chosen by you.


Follow the link below, sign up, and accept one promotional offer.  If I can get five suckers (err... friends) to do this, I'll get a free iPod.  Then you too can try to get a free iPod. Thanks! http://www.freeiPods.com/?r=11363142

Offline

#13 2004-05-19 14:15:04

blue_ant
Member
From: Italy
Registered: 2004-04-24
Posts: 19

Re: [network: web utilities] privoxy

Thanks.

I've uploaded in incoming and edited the post with the install script with the revised version...

Sorry for the typo (arbitrary instead of arbitrarily), I saw it after posting and uploading... big_smile

----
blue_ant

Offline

Board footer

Powered by FluxBB