You are not logged in.

#1 2010-04-08 23:06:58

wriggary
Member
Registered: 2009-06-30
Posts: 65

my first from-scratch pkgbuild - [solved]

Hi Archers!

Yesterday, I set off on writing my own PKGBUILD from scratch for a package I have adopted - monkey. (http daemon)  I had used it previously on Damn Small Linux, and it was one of the programs that spurred my initial interest in Linux.  Enough history...

So, I copied over the PKGBUILD.proto into my working directory, and set to work.   I filled in the fields per the wiki's packaging guidelines,  and stared down the build() function.  As much as I know, what happens in here was (and kind of is) still a mystery to me.  From my reading, it appears that the build() calls fakeroot and runs the ./configure && make && make install while inside a fakeroot, of course allowing me to record changes made to a fake root filesystem, tar them up, and make a package out of it.  Now that I've toyed with it for a while, I see thats not the case.  (or maybe it is?)  I'm noticing that if I place the ./configure --(opts here) && make && make install inside the build() function, I run into permission errors as the make install tries to install the files on the real root filesystem.  hmm.

So I go back and check a few other similar PKGBUILDS.  I notice that they use either the prefix= env var or INSTALLDIR= env var to control where to drop the files.  So, I tried both (make prefix=$pkgdir install, or make DESTDIR=$pkgdir install ) but nether of those changed anything, and after closer inspection of the Makefile, it appears that neither of those vars are referenced.  Poo.

So, I changed the ./configure line to read: ./configure --prefix=$pkgdir/usr --confdir=$pkgdir/etc/$pkgname etc etc... for all the configure opts.  That seems to at least drop the files in the right place (the pkg/ dir under the folder that the PKGBUILD is in)

But... there are some changes I would need to make to the Makefile, first of which is that the Makefile actually starts the daemon as part of make install.  I tried to write a little sed one liner, but it doesn't seem to work, and I'm getting a little confused at this point.  (check the attached PKGBUILD)  Also, I tried using diff -u and making a patch which also cut out the last few lines of the make install (@echo  *** instructions here) which would be better placed in an .install file, but I can work on that later.

Anyway, I would appreciate any help getting this to work the right way (i.e. not having a bunch of install commands in the build() func), but I may end up going that way anyway.  Tell me where I'm going wrong.

Thanks,

Gary.

You can check out the very broken sourceball here

My PKGBUILD:

#Maintainer : Gary Wright <wriggary at g mail.com>
pkgname=monkey
pkgver=0.10.0
pkgrel=1
pkgdesc="Monkey HTTP Daemon, is a very small and fast open source web server for Linux"
arch=('i686' 'x86_64')
url="http://www.monkey-project.com/"
license=('GPL2')
groups=()
depends=('gcc-libs')
makedepends=()
optdepends=('php: currently not working, but planned for 0.11.0')
provides=("monkey=$pkgver")
conflicts=()
replaces=()
backup=()
options=()
install=
source=("http://www.monkey-project.com/releases/0.10/$pkgname-$pkgver.tar.gz"
        "monkey")
noextract=()
md5sums=('d96d79d0768812a179c9fcf95317bda8'
         'c6dce4218ef222e60489a4289d8da347')

build() {
  cd $srcdir/$pkgname-$pkgver

  ./configure --prefix=$pkgdir/usr --bindir=$pkgdir/usr/bin --sysconfdir=$pkgdir/etc/$pkgname --datadir=$pkgdir/srv/http/htdocs --logdir=$pkgdir/var/log/$pkgname --plugdir=$pkgdir/usr/share/$pkgname --cgibin=$pkgdir/srv/http/htdocs/cgi-bin
  make || return 1
  sed -n 's/\$(BINDIR)\/monkey/#\${BINDIR}\/monkey/' Makefile
  make install || return 1

}

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

The (stupid) Makefile that gets generated with this ./configure line:

# Monkey HTTP Daemon: Makefile
# ============================
PREFIX=/home/gary/aur/monkey-010/pkg/usr
BINDIR=/home/gary/aur/monkey-010/pkg/usr/bin
CGIBIN=/home/gary/aur/monkey-010/pkg/srv/http/htdocs/cgi-bin
SYSCONFDIR=/home/gary/aur/monkey-010/pkg/etc/monkey
DATADIR=/home/gary/aur/monkey-010/pkg/srv/http/htdocs
LOGDIR=/home/gary/aur/monkey-010/pkg/var/log/monkey
PLUGINDIR=/home/gary/aur/monkey-010/pkg/usr/share/monkey

default:
        @(cd src; make all)
clean:
        @(cd src; make clean)
distclean:
        @(cd src; make distclean)

install:
        make -C src all
        install -d $(BINDIR)
        install -d $(CGIBIN)
        install -d $(SYSCONFDIR) 
        install -d ${SYSCONFDIR}/sites
        install -d ${SYSCONFDIR}/plugins
        install -d $(DATADIR)
        install -d ${DATADIR}/imgs
        install -d ${DATADIR}/php
        install -d ${DATADIR}/docs
        install -d ${LOGDIR}
        install -d ${PLUGINDIR}
        install -m 755 bin/monkey $(BINDIR)
        $(BINDIR)/monkey
        install -m 755 bin/banana $(BINDIR)
        install -m 644 ./conf/*.* $(SYSCONFDIR)
        cp -r conf/plugins/security ${SYSCONFDIR}/plugins/
        install -m 644 ./conf/sites/* ${SYSCONFDIR}/sites
        install -s -m 644 plugins/cheetah/*.so ${PLUGINDIR}
        install -s -m 644 plugins/security/*.so ${PLUGINDIR}
        install -m 644 ./htdocs/*.* $(DATADIR)
        install -m 644 ./htdocs/imgs/*.* ${DATADIR}/imgs

Last edited by wriggary (2010-04-09 15:13:08)

Offline

#2 2010-04-08 23:10:09

Pierre
Developer
From: Bonn
Registered: 2004-07-05
Posts: 1,967
Website

Re: my first from-scratch pkgbuild - [solved]

Use the target paths for configure like /usr instead of $pkgdir/usr. Then hthere should be something like "make install DESTDIR=$pkgdir"

Offline

#3 2010-04-08 23:31:06

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: my first from-scratch pkgbuild - [solved]

Pierre is right. You want configure to have /usr and /usr/bin, so on. make install should put things in $pkgdir

Offline

#4 2010-04-09 00:24:37

wriggary
Member
Registered: 2009-06-30
Posts: 65

Re: my first from-scratch pkgbuild - [solved]

PKGBUILD changed.  Either with just "make install" or "make install DESTDIR=$pkgdir" or " make DESTDIR=$pkgdir install" or "DESTDIR=$pkgdir make install" I get this: (note: this is from the end of the make command and the beginning of make install)

make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/gary/aur/monkey-010/src/monkey-0.10.0/src'
install -d /usr/bin
install -d /srv/http/htdocs/cgi-bin
install: cannot create directory `/srv/http/htdocs': Permission denied
make: *** [install] Error 1
==> ERROR: Build Failed.

I've double-verified that both base-devel and fakeroot are installed.

[edit: typo in make commands]

Last edited by wriggary (2010-04-09 00:28:04)

Offline

#5 2010-04-09 00:31:25

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: my first from-scratch pkgbuild - [solved]

Remove the src/ directory when you change build commands.

Offline

#6 2010-04-09 00:47:42

wriggary
Member
Registered: 2009-06-30
Posts: 65

Re: my first from-scratch pkgbuild - [solved]

Remove the src/ directory when you change build commands.

Yes, I forgot to mention that I already have been 'rm -r src/' before each run of makepkg.  Learned that one when I first compiled a kernel using a PKGBUILD from the AUR, and it would complain about patches failing.

Offline

#7 2010-04-09 02:00:33

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: my first from-scratch pkgbuild - [solved]

Also I just noticed that destdir isn't being honored. Post the current PKGBUILD?

Offline

#8 2010-04-09 02:45:49

wriggary
Member
Registered: 2009-06-30
Posts: 65

Re: my first from-scratch pkgbuild - [solved]

#Maintainer : Gary Wright <wriggary at g mail.com>
pkgname=monkey
pkgver=0.10.0
pkgrel=1
pkgdesc="Monkey HTTP Daemon, is a very small and fast open source web server for Linux"
arch=('i686' 'x86_64')
url="http://www.monkey-project.com/"
license=('GPL2')
groups=()
depends=('gcc-libs')
makedepends=()
#optdepends=('php: currently not working, but planned for 0.11.0')
provides=("monkey=$pkgver")
conflicts=()
replaces=()
backup=()
options=()
install=
source=("http://www.monkey-project.com/releases/0.10/$pkgname-$pkgver.tar.gz"
        "monkey")
noextract=()
md5sums=('d96d79d0768812a179c9fcf95317bda8'
         'c6dce4218ef222e60489a4289d8da347')

build() {
  cd $srcdir/$pkgname-$pkgver
  ./configure --prefix=/usr --bindir=/usr/bin --sysconfdir=/etc/$pkgname --datadir=/srv/http/htdocs --logdir=/var/log/$pkgname --plugdir=/usr/share/$pkgname --cgibin=/srv/http/htdocs/cgi-bin || return 1
  make || return 1
 #sed 's/\$(BINDIR)\/monkey/#\${BINDIR}\/monkey/' 
 # sed -n 's/\$(BINDIR)\/monkey/#\${BINDIR}\/monkey/' Makefile
  make prefix=$pkgdir install  || return 1

}

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

Is where I left it at.  Tried various things on the last line of build() as noted in above post.

Last edited by wriggary (2010-04-09 02:47:00)

Offline

#9 2010-04-09 06:22:51

Andrwe
Member
From: Leipzig/Germany
Registered: 2009-06-17
Posts: 322
Website

Re: my first from-scratch pkgbuild - [solved]

Please try

make DESTDIR=${pkgdir} install || return 1

instead of make prefix=


Website: andrwe.org

Offline

#10 2010-04-09 09:47:04

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: my first from-scratch pkgbuild - [solved]

Andrwe - he already posted the Makefile - it doesn't use DESTDIR, prefix, of any other variable that could specify an alternative package root.

wrigarry - here's my version. It installs everything under $pkgdir, doesn't try to run the daemon, and doesn't echo any message - that's as far as I'm going. You can do the rest. smile

pkgname=monkey
pkgver=0.10.0
pkgrel=1
pkgdesc="Monkey HTTP Daemon, is a very small and fast open source web server 
for Linux"
arch=('i686' 'x86_64')
url="http://www.monkey-project.com/"
license=('GPL2')
depends=('gcc-libs')
#optdepends=('php: currently not working, but planned for 0.11.0')
provides=("monkey=$pkgver")
source=("http://www.monkey-project.com/releases/0.10/$pkgname-$pkgver.tar.gz"
    Makefile.patch)

build() {
  cd $srcdir/$pkgname-$pkgver
  ./configure --prefix=/usr --bindir=/usr/bin --sysconfdir=/etc/$pkgname \
  --datadir=/srv/http/htdocs --logdir=/var/log/$pkgname \
  --plugdir=/usr/share/$pkgname --cgibin=/srv/http/htdocs/cgi-bin || return 1
  patch -Np0 -i ../Makefile.patch || return 1
  make || return 1
  make DESTDIR=$pkgdir install  || return 1

}
md5sums=('d96d79d0768812a179c9fcf95317bda8'
         'cf61afddb4c53bea688bc225678e3001')

Makefile.patch

--- Makefile    2010-04-09 10:30:26.781831483 +0100
+++ Makefile.new    2010-04-09 10:28:08.591830541 +0100
@@ -1,12 +1,12 @@
 # Monkey HTTP Daemon: Makefile
 # ============================
-PREFIX=/usr
-BINDIR=/usr/bin
-CGIBIN=/srv/http/htdocs/cgi-bin
-SYSCONFDIR=/etc/monkey
-DATADIR=/srv/http/htdocs
-LOGDIR=/var/log/monkey
-PLUGINDIR=/usr/share/monkey
+PREFIX=$(DESTDIR)/usr
+BINDIR=$(DESTDIR)/usr/bin
+CGIBIN=$(DESTDIR)/srv/http/htdocs/cgi-bin
+SYSCONFDIR=$(DESTDIR)/etc/monkey
+DATADIR=$(DESTDIR)/srv/http/htdocs
+LOGDIR=$(DESTDIR)/var/log/monkey
+PLUGINDIR=$(DESTDIR)/usr/share/monkey
 
 default:
     @(cd src; make all)
@@ -29,7 +29,6 @@
     install -d ${LOGDIR}
     install -d ${PLUGINDIR}
     install -m 755 bin/monkey $(BINDIR)
-     $(BINDIR)/monkey
     install -m 755 bin/banana $(BINDIR)
     install -m 644 ./conf/*.* $(SYSCONFDIR)
     cp -r conf/plugins/security ${SYSCONFDIR}/plugins/
@@ -38,12 +37,4 @@
     install -s -m 644 plugins/security/*.so ${PLUGINDIR}
     install -m 644 ./htdocs/*.* $(DATADIR)
     install -m 644 ./htdocs/imgs/*.* ${DATADIR}/imgs
-    @echo 
-    @echo  " Running Monkey :"
-    @echo  " ----------------"
-    @echo 
-    @echo  "  # /usr/bin/monkey"
-    @echo 
-    @echo  "  For more help use '-h' option"    
-    @echo

Also, you didn't post the code for the "monkey" in your SOURCE array - I presume it's the rc script - so I left it out.

Offline

#11 2010-04-09 12:40:53

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: my first from-scratch pkgbuild - [solved]

Please also send that patch to the upstream developers -- they need to know how their Makefile sucks

Offline

#12 2010-04-09 15:12:42

wriggary
Member
Registered: 2009-06-30
Posts: 65

Re: my first from-scratch pkgbuild - [solved]

Thank you all very much for your help.  I was getting to that point of information overload where the brain just starts throwing sparks and smoke instead of lines of code... but this is how we learn, right?

Will do on the sending it to their dev mailng list.

I'll keep you posted on the status of the PKGBUILD

Offline

#13 2010-04-09 17:05:50

wriggary
Member
Registered: 2009-06-30
Posts: 65

Re: my first from-scratch pkgbuild - [solved]

Okay, final sourceball is here:  monkey-0.10.0-1.src.tar.gz
I had to monkey (horrible, aren't i?)  around with the patch to get it to work, probably because I copied something wrong out of the code block.... the second and third hunks kept failing... anyway, feel free to test.  The RC script is also included and works on my machine.

And, as a matter of asthetics, /srv/http would be the appropriate place for a simple webserver root, correct?  I noticed that in a base-ish install thats never seen apache, /var/www doesn't exist.

Thanks again,

Gary

Edit: whipped up one with an included install file that spits out the same info the makefile does, plus a little. Here

Last edited by wriggary (2010-04-09 17:27:50)

Offline

#14 2010-04-10 02:32:02

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: my first from-scratch pkgbuild - [solved]

Yes /srv/something is a good place for a user to put a webserver (and I'd prefer it to /var/www), but your PKGBUILD shouldn't install anything there. See discussion here.

Offline

#15 2010-04-10 03:29:15

wriggary
Member
Registered: 2009-06-30
Posts: 65

Re: my first from-scratch pkgbuild - [solved]

Noted.

I will change it back to /var/www when 0.10.1 tarball is released, which should be sometime tonight.  I want to keep the fact that you can compile and install the package, run the rc script and have a working webserver complete with test page.

Upstream has been very responsive.  All my comments were welcomed, and accepted, even though I didn't exactly submit a diff to the autoconf script.  The patch should be unnecessary now, except maybe the @echos at the end that are better echoed in the install script.

Gary

Offline

Board footer

Powered by FluxBB