You are not logged in.

#1 2009-11-23 09:14:40

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Advice on this PKGBUILD?

I've been working on a screencast script called ffcast these two days.
AUR page here: http://aur.archlinux.org/packages.php?ID=32158
I've got a little headache now that I added xrectsel.c...

# Contributor: lolilolicon <lolilolicon{at}gmail{dot}com>

pkgname=ffcast
pkgver=20091123
pkgrel=1
pkgdesc="bash script that takes screencast of given window area using ffmpeg/xwininfo"
arch=('any')
url="http://github.com/lolilolicon/ffcast"
license=('GPL v3')
makedepends=('git')
depends=('bash>=3.0' 'ffmpeg>=0.5' 'x264>=20090416' 'xorg-utils')
source=()
md5sums=()

_gitroot="git://github.com/lolilolicon/ffcast.git"
_gitname=master

build() {
  msg "Connecting to GIT server..."
  if [ -d "$srcdir/$pkgname" ]; then
    cd "$srcdir/$pkgname" && git pull origin $_gitname || return 1
  else
    git clone "$_gitroot" "$srcdir/$pkgname" || return 1
    cd "$srcdir/$pkgname" && git checkout $_gitname || return 1
  fi

  msg "GIT checkout done or server timeout"

  gcc -Wall -lX11 xrectsel.c -o xrectsel
  install -D -m755 xrectsel "$pkgdir/usr/bin/xrectsel"
  install -D -m755 ffcast "$pkgdir/usr/bin/ffcast"
}

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

My questions:
1. Is it normal to put gcc stuff in the build() function? Or, should I write a make file?
2. How to write a make file for this?
3. xrectsel is basically only a helper tool, which will return a geometry value like '600x349+42+300' when you select a rectangle area on your screen. So... is it good to install xrectsel to /usr/bin like this?
4. Also, in xrectsel.c, uses these:

#include<stdio.h>
#include<stdlib.h>
#include<X11/Xlib.h>
#include<X11/cursorfont.h>

the X11/*.h stuff belongs to libx11 package, and libx11 is required by x264, so libx11 does not need to be in the depends array right?
5. Other suggestions?

Thanks in advance


This silver ladybug at line 28...

Offline

#2 2009-11-23 09:18:20

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,425
Website

Re: Advice on this PKGBUILD?

lolilolicon wrote:

1. Is it normal to put gcc stuff in the build() function? Or, should I write a make file?

Yes

lolilolicon wrote:

2. How to write a make file for this?

There are some very good tutorials to be found on google.

lolilolicon wrote:

3. xrectsel is basically only a helper tool, which will return a geometry value like '600x349+42+300' when you select a rectangle area on your screen. So... is it good to install xrectsel to /usr/bin like this?

Yes.

lolilolicon wrote:

4. Also, in xrectsel.c, uses these:

#include<stdio.h>
#include<stdlib.h>
#include<X11/Xlib.h>
#include<X11/cursorfont.h>

the X11/*.h stuff belongs to libx11 package, and libx11 is required by x264, so libx11 does not need to be in the depends array right?

Yes.

Offline

#3 2009-11-23 10:32:25

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: Advice on this PKGBUILD?

So I wrote a makefile

CC=gcc

xrectsel : xrectsel.c -lX11
    ${CC} ${CFLAGS} xrectsel.c -lX11 -o xrectsel

.PHONY : clean
clean :
    -rm xrectsel

Thoughts?

Edit:
second try:

PREFIX=/usr
DESTDIR=
CC=gcc

xrectsel : xrectsel.c -lX11
    ${CC} ${CFLAGS} xrectsel.c -lX11 -o xrectsel

install : xrectsel ffcast
    install -D -m755 xrectsel ${DESTDIR}${PREFIX}/bin/xrectsel
    install -D -m755 ffcast ${DESTDIR}${PREFIX}/bin/ffcast

.PHONY : clean
clean :
    -rm xrectsel

and in PKGBUILD

make
make DESTDIR="$pkgdir" install
make clean

How's that?

Last edited by lolilolicon (2009-11-23 10:52:20)


This silver ladybug at line 28...

Offline

#4 2009-11-23 11:10:24

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,226
Website

Re: Advice on this PKGBUILD?

No need to `make clean`

That's what the srcdir is for, to be dirty with source smile

Offline

#5 2009-11-23 11:43:29

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: Advice on this PKGBUILD?

Hmm sounds reasonable.

But I prefer to `make clean` in the case where git is used -- it keeps srcdir/ffcast look the same as git remote.


This silver ladybug at line 28...

Offline

#6 2009-11-25 19:14:12

tdy
Member
From: Sacremende
Registered: 2008-12-14
Posts: 440

Re: Advice on this PKGBUILD?

lolilolicon wrote:

But I prefer to `make clean` in the case where git is used -- it keeps srcdir/ffcast look the same as git remote.

You might want to take a look at the prototype PKGBUILDs in /usr/share/pacman.  They have a better solution for this.

Last edited by tdy (2009-11-25 19:14:43)

Offline

#7 2009-11-26 03:24:31

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: Advice on this PKGBUILD?

Cool, this *-build dir method is very helpful for bigger projects. I should have thought about that since I actually knew it.
The only pitfall I think, is this method will require extra diskspace for a copy of the git tree.
Besides that, it's good and universal solution. I'll keep that in mind. Thanks tdy.


This silver ladybug at line 28...

Offline

Board footer

Powered by FluxBB