You are not logged in.

#1 2005-09-25 15:41:49

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

grep / sed help please..

am trying to make a new pkgbuild but the install dirs are coded in the makefile and will not be overridden with DESTDIR or prefix

in the makefile i have already sed out the references to local, however the variables for bin-prefix, data_prefix and highscore_prefix are on lines 1,2 and three respectively.

the sed command for removing local was lifted from another pkgbuild
as i see it there are a few options one is to remove lines 1,2,3 and then move the directories to pkg to be tarred up or to insert pkg into 1,2,3
i know you can also bind the root of the package but am stumped as to the correct commands, any ideas guys?

Offline

#2 2005-09-25 15:48:21

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: grep / sed help please..

Er...dude, you have way over complicated this request!  Better to paste what you start with and what you want to end up with and then we can see what you are trying to do and suggest how you might do it.

Currently this is way to abstract smile

Offline

#3 2005-09-25 15:58:46

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: grep / sed help please..

Sorry  :oops:

here is the pkg build

pkgname=twind
pkgver=1.1.0
pkgrel=1
pkgdesc="An addictive block game"
url="http://twind.sourceforge.net"
depends=('sdl' 'sdl_image' 'sdl_mixer')
source=(http://dl.sourceforge.net/sourceforge/twind/twind-1.1.0.tar.gz)
md5sums=('672dfe032e1f5657996b64cd666aef50')


build() {
  cd $startdir/src/$pkgname-$pkgver
    
  sed -i -e "s:local/::" Makefile
  
  make || return 1
  mkdir -p $startdir/pkg/usr
   make  prefix=$startdir/pkg install
}

but the install command in the makefile will not accept external variable
here is the makefile...

# ONLY CHANGE THESE THREE OPTIONS IF YOU KNOW WHAT YOU ARE DOING
BIN_PREFIX = /usr/bin/
# if you don't have privileges to install systemwide, comment out both 
# lines below and the game will then play from the current directory
DATA_PREFIX = /usr/share/games/twind/
HIGH_SCORE_PREFIX = /var/lib/games/twind/
# uncomment out the EXTENSION if you don't have the png libs on your system
#EXTENSION = ".bmp"
AUDIOFLAG = AUDIO
CC = gcc
ifdef EXTENSION
CFLAGS = -Wall -g -DDATA_PREFIX="$(DATA_PREFIX)" 
    -DEXTENSION="$(EXTENSION)" -D$(AUDIOFLAG) -DLINUX 
    -DHIGH_SCORE_PREFIX="$(HIGH_SCORE_PREFIX)"
else
CFLAGS = -Wall -g -DDATA_PREFIX="$(DATA_PREFIX)" -D$(AUDIOFLAG) -DLINUX 
    -DHIGH_SCORE_PREFIX="$(HIGH_SCORE_PREFIX)"
endif
LIBS = -lm
SDL_CFLAGS = `sdl-config --cflags`
SDL_LIBS = `sdl-config --libs` -lSDL_image
MIXER_LIB = -lSDL_mixer

all: twind

install:
    mkdir -p $(DATA_PREFIX)graphics
    mkdir -p $(DATA_PREFIX)music
    mkdir -p $(DATA_PREFIX)sound
    mkdir -p $(HIGH_SCORE_PREFIX)
ifdef EXTENSION
    cp -r graphics/*.bmp $(DATA_PREFIX)graphics
else
    cp -r graphics/*.png $(DATA_PREFIX)graphics
endif
    cp -r music/*.ogg $(DATA_PREFIX)music
    cp -r sound/*.wav $(DATA_PREFIX)sound
    cp twind $(BIN_PREFIX)
    chown root:games $(BIN_PREFIX)twind
    chmod g+s $(BIN_PREFIX)twind
    touch $(HIGH_SCORE_PREFIX)twind.hscr
    chown root:games $(HIGH_SCORE_PREFIX)twind.hscr
    chmod 664 $(HIGH_SCORE_PREFIX)twind.hscr
    
uninstall:
    rm -rf $(DATA_PREFIX)
    rm -f $(BIN_PREFIX)twind

noaudio:
    make twind MIXER_LIB= AUDIOFLAG=NOAUDIO
     
twind: twind.o
    $(CC) twind.o $(LIBS) $(SDL_LIBS) $(MIXER_LIB) -o twind

twind.o: twind.c
    $(CC) $(CFLAGS) $(SDL_CFLAGS) -c twind.c

clean:
    rm -f twind *.o
  as i said from what i can tell i can either remove the variable and get it to build selfcontained and move this to pkg to be compressed
insert /pkg into the makefile
or bind the root of the install into $startdir

is this any clearer
:?:

as i understand it any of these options will put the needed files into pkg for makepkg to compress.

Offline

#4 2005-09-25 17:17:47

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: grep / sed help please..

Well, that's pretty simple. All you need to do is:

sed -i -e "s:/usr:$startdir/pkg/usr" Makefile

to correct BIN_PREFIX and DATA_PREFIX

Then

sed -i -e "s:/var:$startdir/pkg/var" Makefile

to fix HIGH_SCORE_PREFIX

Offline

#5 2005-09-25 19:10:02

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: grep / sed help please..

nah didn't do it....


=> Starting build()...
sed: -e expression #1, char 29: unterminated `s' command
sed: -e expression #1, char 29: unterminated `s' command
make: Nothing to be done for `all'.
mkdir -p /usr/share/games/twind/graphics
mkdir: cannot create directory `/usr/share/games/twind': Permission denied
make: *** [install] Error 1

Offline

#6 2005-09-25 19:14:44

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: grep / sed help please..

opps - my bad lol

sed -i -e "s:/usr:$startdir/pkg/usr:g" Makefile

sed -i -e "s:/var:$startdir/pkg/var:g" Makefile

spot the deliberate mistake

Offline

#7 2005-09-25 19:54:07

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: grep / sed help please..

ok had to modify that one again to get it to work, however i think I'm starting to understand sed....

take a look at the pkgbuild now.. has now been built and installed without pacman complaining..

Contributor: mpie <michael.kyne-phillips1@ntlworld.com>
pkgname=twind
pkgver=1.1.0
pkgrel=1
pkgdesc="An addictive block game"
url="http://twind.sourceforge.net"
depends=('sdl' 'sdl_image' 'sdl_mixer')
source=(http://dl.sourceforge.net/sourceforge/twind/twind-1.1.0.tar.gz)
md5sums=('672dfe032e1f5657996b64cd666aef50')


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

sed -i -e"s:local/::" Makefile
sed -i -e"s:root.games:root.root:g" Makefile
sed -i -e"s:/usr:pkg/usr:g" Makefile
sed -i -e"s:/var:pkg/var:g" Makefile
mkdir -p pkg/usr/bin
  make || return 1
  make  prefix=$startdir/pkg/usr install
mv /$startdir/src/$pkgname-$pkgver/pkg $startdir/pkg
}

please pass any comments you may have and thanks for the help, i feel i have learned a better understanding of sed, dont fully get it yet but it no longer looks like random characters:D

Offline

#8 2005-09-25 19:58:51

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

Re: grep / sed help please..

EDITED:

try that instead (less awkward)

build() {
  cd $startdir/src/$pkgname-$pkgver
  sed -i -e"s:root.games:root.root:g" Makefile
  mkdir -p $startdir/pkg/usr/bin
  make || return 1
  make BIN_PREFIX=$startdir/usr/bin/ DATA_PREFIX=$startdir/usr/share/games/twind/ HIGH_SCORE_PREFIX=$startdir/var/lib/games/twind/  install
} 

Offline

#9 2005-09-25 20:45:02

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: grep / sed help please..

cheers, think i still need to add the sed line re local as when executing it is looking in local....

here is the final version(fingerscrossed)

#Contributor: mpie <michael.kyne-phillips1@ntlworld.com>
pkgname=twind
pkgver=1.1.0
pkgrel=1
pkgdesc="An addictive block game"
url="http://twind.sourceforge.net"
depends=('sdl' 'sdl_image' 'sdl_mixer')
source=(http://dl.sourceforge.net/sourceforge/twind/twind-1.1.0.tar.gz)
md5sums=('672dfe032e1f5657996b64cd666aef50')


build() {
  cd $startdir/src/$pkgname-$pkgver
  sed -i -e "s:local/::" Makefile
  sed -i -e"s:root.games:root.root:g" Makefile

mkdir -p $startdir/pkg/usr/bin
  make || return 1
  make  BIN_PREFIX=$startdir/pkg/usr/bin/ DATA_PREFIX=$startdir/pkg/usr/share/games/twind/ HIGH_SCORE_PREFIX=$startdir/pkg/var/lib/games/twind/ prefix=$startdir/pkg/usr install
}

Offline

#10 2005-09-25 20:56:32

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

Re: grep / sed help please..

There is no local in the Makefile you posted. If it has been modified, post the original one.

And you don't need prefix=$startdir/pkg/usr in the make install line.  The Makefile doesn't use the prefix variable, instead it uses BIN_PREFIX, DATA_PREFIX and HIGH_SCORE_PREFIX.

Offline

#11 2005-09-25 20:59:22

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: grep / sed help please..

# ONLY CHANGE THESE THREE OPTIONS IF YOU KNOW WHAT YOU ARE DOING
BIN_PREFIX = /usr/local/bin/
# if you don't have privileges to install systemwide, comment out both 
# lines below and the game will then play from the current directory
DATA_PREFIX = /usr/local/share/games/twind/
HIGH_SCORE_PREFIX = /var/lib/games/twind/
# uncomment out the EXTENSION if you don't have the png libs on your system
#EXTENSION = ".bmp"
AUDIOFLAG = AUDIO
CC = gcc
ifdef EXTENSION
CFLAGS = -Wall -g -DDATA_PREFIX="$(DATA_PREFIX)" 
    -DEXTENSION="$(EXTENSION)" -D$(AUDIOFLAG) -DLINUX 
    -DHIGH_SCORE_PREFIX="$(HIGH_SCORE_PREFIX)"
else
CFLAGS = -Wall -g -DDATA_PREFIX="$(DATA_PREFIX)" -D$(AUDIOFLAG) -DLINUX 
    -DHIGH_SCORE_PREFIX="$(HIGH_SCORE_PREFIX)"
endif
LIBS = -lm
SDL_CFLAGS = `sdl-config --cflags`
SDL_LIBS = `sdl-config --libs` -lSDL_image
MIXER_LIB = -lSDL_mixer

all: twind

install:
    mkdir -p $(DATA_PREFIX)graphics
    mkdir -p $(DATA_PREFIX)music
    mkdir -p $(DATA_PREFIX)sound
    mkdir -p $(HIGH_SCORE_PREFIX)
ifdef EXTENSION
    cp -r graphics/*.bmp $(DATA_PREFIX)graphics
else
    cp -r graphics/*.png $(DATA_PREFIX)graphics
endif
    cp -r music/*.ogg $(DATA_PREFIX)music
    cp -r sound/*.wav $(DATA_PREFIX)sound
    cp twind $(BIN_PREFIX)
    chown root:games $(BIN_PREFIX)twind
    chmod g+s $(BIN_PREFIX)twind
    touch $(HIGH_SCORE_PREFIX)twind.hscr
    chown root:games $(HIGH_SCORE_PREFIX)twind.hscr
    chmod 664 $(HIGH_SCORE_PREFIX)twind.hscr
    
uninstall:
    rm -rf $(DATA_PREFIX)
    rm -f $(BIN_PREFIX)twind

noaudio:
    make twind MIXER_LIB= AUDIOFLAG=NOAUDIO
     
twind: twind.o
    $(CC) twind.o $(LIBS) $(SDL_LIBS) $(MIXER_LIB) -o twind

twind.o: twind.c
    $(CC) $(CFLAGS) $(SDL_CFLAGS) -c twind.c

clean:
    rm -f twind *.o

sri  posted the one from src..

Offline

#12 2005-09-25 21:03:20

bardo
Member
Registered: 2004-12-06
Posts: 96

Re: grep / sed help please..

BTW, dibble, shouldn't you escape $ symbol? Otherwise it wouldn't match anything, 'cause $ stands for "match end line"...


dreaming in digital / living in realtime / thinking in binary / talking in ip / welcome to our world

Offline

#13 2005-09-25 21:13:06

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: grep / sed help please..

bardo wrote:

BTW, dibble, shouldn't you escape $ symbol? Otherwise it wouldn't match anything, 'cause $ stands for "match end line"...

no. sed expands the regex when in double quotes but matches the end of line in single quotes.

Offline

#14 2005-09-25 21:21:27

bardo
Member
Registered: 2004-12-06
Posts: 96

Re: grep / sed help please..

Uh, maybe there was a time when I knew it... To tell the truth I didn't even notice the double quotes ^_^


dreaming in digital / living in realtime / thinking in binary / talking in ip / welcome to our world

Offline

#15 2005-09-25 21:36:12

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: grep / sed help please..

...besides - it's not replacing $startdir it is adding $startdir, which needs to be expanded

mpie: not sure just /pkg will work

snowman: does make always work like that?  Can you always pass variables on the command line that are found in the makefile?

Offline

#16 2005-09-25 21:43:14

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: grep / sed help please..

when compiling $startdir/pkg would not work when it came to the install at the end...
when I cut it out it worked have now run the pkg and behaves fine thanks to all

Offline

#17 2005-09-25 23:15:04

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

Re: grep / sed help please..

Dibble: Yes, AFAIK. Unless I'm mistaken, that's how DESTDIR, PREFIX or prefix works. wink
mpie: you don't need local. There was a problem with the app looking for its data in /usr/local. This PKGBUILD works.

#Contributor: mpie <michael.kyne-phillips1@ntlworld.com>
pkgname=twind
pkgver=1.1.0
pkgrel=1
pkgdesc="An addictive block game"
url="http://twind.sourceforge.net"
depends=('sdl' 'sdl_image' 'sdl_mixer')
source=(http://dl.sourceforge.net/sourceforge/twind/twind-1.1.0.tar.gz)
md5sums=('672dfe032e1f5657996b64cd666aef50')

build() {
  cd $startdir/src/$pkgname-$pkgver
  sed -i -e"s:root.games:root.root:g" Makefile
  mkdir -p $startdir/pkg/usr/bin
  make DATA_PREFIX=/usr/share/games/twind/ || return 1
  make BIN_PREFIX=$startdir/pkg/usr/bin/ DATA_PREFIX=$startdir/pkg/usr/share/games/twind/ HIGH_SCORE_PREFIX=$startdir/pkg/var/lib/games/twind/  install
} 

Offline

#18 2005-09-25 23:36:12

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: grep / sed help please..

Thank you all for your help, yeah the locla error came from a prior install , which really i should have deleted before packaging this might have avoided th confusion

Offline

Board footer

Powered by FluxBB