You are not logged in.

#1 2007-10-10 14:03:26

tardo
Member
Registered: 2006-07-15
Posts: 526

[Help] PKGBUILD parsing php script

Greetings. Since Paul seems to be committed to getting this into AUR 1.5, I thought I'd post on the forums to get more people to test my script. You can read about it on this ML thread.

Here are some features:
- Complete PKGBUILD parsing using lexical grammar (regex and php, using lemon parser generator)
- Checks all variables for sanity
- Uses a decent OOP structure so variables are readily available after running parse()
- Helps to somewhat enforce Arch Packaging Standards
- Custom variables are properly substituted into other variables (provided they are declared beforehand)

Here are some things it won't do:
- build() function is not checked for sanity
- won't check if deps are correct, or if they exist
- won't do advanced bash substitution (yet?), e.g. ${pkgname/test/newtest}

At the moment, if the PKGBUILD fails, it spits out a nearly meaningless error, but I'm working to have that changed. I've had a handful of people test the script for me with mixed reports, and have been able to fix several bugs. But I'd still like to have it thoroughly tested which is why I'm now posting here. If you think you have standards compliant PKGBUILDs, take the test lol

All you have to do is click browse, locate a PKGBUILD, click submit. On success, some variables are displayed. If it fails, post your PKGBUILD here, or email it to me for review.

Thanks.

Offline

#2 2007-10-10 14:36:11

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: [Help] PKGBUILD parsing php script

Fatal error: Uncaught exception 'Exception' with message 'Unexpected input at line10: i' in 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php:251 Stack trace: #0 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(90): Pkgbuild->yylex1() #1 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(80): Pkgbuild->yylex() #2 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/parser.php(12): Pkgbuild->parse() #3 {main} thrown in 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php on line 251

Error in your code?

Tested PKGBUILD.

Last edited by [vEX] (2007-10-10 14:38:29)


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#3 2007-10-10 23:41:42

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

Fixed. Here's what failed:

license=('custom: "bsnes (TM) Open Source Reference License"')
[ "$CARCH" = "x86_64" ] && makedepends=('yasm')

Didn't know " and () were allowed in license.
And completely forgot about conditionals.

Offline

#4 2007-10-11 03:53:13

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: [Help] PKGBUILD parsing php script

I like to use ' whereever possible and that includes pkgdesc (instead of "). I couldn't think of anything else where it could have failed.

Last edited by byte (2007-10-11 03:53:40)


1000

Offline

#5 2007-10-11 03:57:36

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

easy fix. done.

Offline

#6 2007-10-11 04:58:06

sinecure
Member
Registered: 2007-09-22
Posts: 21
Website

Re: [Help] PKGBUILD parsing php script

Here's another (looks like a similar error):

Fatal error: Uncaught exception 'Exception' with message 'Unexpected input at line11: l' in
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php:253 Stack trace: #0
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(90): Pkgbuild->yylex1() #1
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(80): Pkgbuild->yylex() #2
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/parser.php(12): Pkgbuild->parse() #3 {main} thrown in
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php on line 253

Tested http://aur.archlinux.org/packages/perl- … p/PKGBUILD

Offline

#7 2007-10-11 05:02:35

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

license should be an array. take a look at the arch packaging standards in the wiki.

Offline

#8 2007-10-11 08:48:47

sinecure
Member
Registered: 2007-09-22
Posts: 21
Website

Re: [Help] PKGBUILD parsing php script

Ack, thanks.  After that fix, works as advertised.

Last edited by sinecure (2007-10-11 08:51:03)

Offline

#9 2007-10-11 13:04:12

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: [Help] PKGBUILD parsing php script

tardo wrote:

Fixed. Here's what failed:

license=('custom: "bsnes (TM) Open Source Reference License"')
[ "$CARCH" = "x86_64" ] && makedepends=('yasm')

Didn't know " and () were allowed in license.
And completely forgot about conditionals.

The license field is an array, just check the PKGBUILD prototype, as well as the following quote.

Quote from http://wiki.archlinux.org/index.php/Arc … s#Licenses:

3. Add 'custom' to the licenses array. Optionally, you can replace 'custom' with 'custom:"name of license"'.

This is also where it shows how to describe the custom license, but the " could also just be to indicate that 'name of license' should be replaced with the license name. Actually, since there is a colon after 'Custom' it actually doesn't make any sense having the quotation mark.

EDIT: Aye, a bit below the quoted text above one can read this:

Some packages may not be covered by a single license. In these cases multiple entries may be made in the license array e.g. license=("GPL" "custom:some commercial license").

Which means my PKGBUILD is invalid since I use the quotation marks in my license array, I guess that's what you get for just copying the example and not read the rest of the text.

Last edited by [vEX] (2007-10-11 13:10:54)


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#10 2007-10-11 20:04:50

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [Help] PKGBUILD parsing php script

Fatal error: Uncaught exception 'Exception' with message 'Unexpected input at line10: g' in 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php:253 Stack trace: #0 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(90): Pkgbuild->yylex1() #1 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(80): Pkgbuild->yylex() #2 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/parser.php(12): Pkgbuild->parse() #3 {main} thrown in 
/home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php on line 253

This PKGBUILD

Last edited by Lone_Wolf (2007-10-11 20:05:30)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#11 2007-10-11 20:26:12

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: [Help] PKGBUILD parsing php script

Lone_Wolf wrote:

Probably because of this (I'm just guessing though):

install=oolite.install
install=

That is, you have 'install' twice! And you really should remove those unused arrays to make the PKGBUILD look nicer.


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#12 2007-10-11 20:54:51

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

actually you can have a variable listed twice. you just cant have empty variables.

Offline

#13 2007-10-11 20:56:20

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [Help] PKGBUILD parsing php script

tardo wrote:

actually you can have a variable listed twice. you just cant have empty variables.

Sometimes it's useful to have empty variables, to explicitly say "Hey, this PKGBUILD has no source" for example.

Offline

#14 2007-10-11 21:02:08

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

source and md5sum are allowed to be empty (i think this is a svn/cvs/etc rule). just not anything else.

edit: and by not including the source array as well, i would think you're explicitly saying there is no source tongue

Last edited by tardo (2007-10-11 21:03:14)

Offline

#15 2007-10-11 21:07:19

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [Help] PKGBUILD parsing php script

Nope, removing the empty install= line still gives the same error.

When i start making a new pkgbuild i usually copy PKGBUILD.proto and adjust it.
I believe the PKGBUILD should give a clear picture what is being done, and imo listing all variables helps with that.

Edit :
After removing all empty var lines, the error is gone.

Last edited by Lone_Wolf (2007-10-11 21:09:24)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#16 2007-10-11 23:58:07

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: [Help] PKGBUILD parsing php script

Also craps out on stuff like source=("http://fooo.../$pkgname-$_realver.tar.gz")


1000

Offline

#17 2007-10-12 01:43:33

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

byte wrote:

Also craps out on stuff like source=("http://fooo.../$pkgname-$_realver.tar.gz")

what exactly?

Offline

#18 2007-10-12 09:04:25

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: [Help] PKGBUILD parsing php script

Fatal error: Uncaught exception 'Exception' with message 'Unexpected input at line15: h' in /home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php:253
Stack trace: #0 /home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(90):
Pkgbuild->yylex1() #1 /home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php(80):
Pkgbuild->yylex() #2 /home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/parser.php(12):
Pkgbuild->parse() #3 {main} thrown in /home/.anika/tardo/nagi-fanboi.net/arch/pkgbuild/pkgbuild.php on line 253

http://aur.archlinux.org/packages/pctel/pctel/PKGBUILD

Last edited by byte (2007-10-12 09:06:08)


1000

Offline

#19 2007-10-12 11:55:44

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [Help] PKGBUILD parsing php script

tardo wrote:

source and md5sum are allowed to be empty (i think this is a svn/cvs/etc rule). just not anything else.

edit: and by not including the source array as well, i would think you're explicitly saying there is no source tongue

By not including something, it becomes implicit, as you're allowing the default to take over.  There's nothing explicit about omission. wink

Offline

#20 2007-10-12 12:02:40

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

Cerebral wrote:
tardo wrote:

source and md5sum are allowed to be empty (i think this is a svn/cvs/etc rule). just not anything else.

edit: and by not including the source array as well, i would think you're explicitly saying there is no source tongue

By not including something, it becomes implicit, as you're allowing the default to take over.  There's nothing explicit about omission. wink

Haha, but the default is an empty set anyway tongue

@byte: I'll look at it later this evening. I have an idea what the problem is.

Offline

#21 2007-10-12 17:15:59

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: [Help] PKGBUILD parsing php script

OK fixed. Problem was with pkgdesc. Not exactly sure what but I rewrote that regex to be a little more and less generic. Please try it again.

Offline

Board footer

Powered by FluxBB