[pacman-dev] pkgbuild parser in python

Allan McRae allan at archlinux.org
Thu Oct 1 10:54:36 EDT 2009


Xavier wrote:
> On Thu, Oct 1, 2009 at 4:22 PM, Sebastian Nowicki <sebnow at gmail.com> wrote:
>   
>> On Oct 1, 2009, at 2:52 PM, Allan McRae wrote:
>>
>>     
>>> Hi,
>>>
>>> This is one part of the makepkg test suite I am working on.   It is fairly
>>> a simple class that takes a pacman package filename and does some parsing.
>>>  Currently that involves getting the file list and the info from the
>>> .PKGINFO file.
>>>
>>> I am still fairly new to python so I am looking for comments on how this
>>> could be improved.
>>> One idea I have had is to not initialize all the fields in the pkginfo
>>> dict and add a test if an array exists before appending.  It would make the
>>> code tidier but that would mean the need to test if the field exists when
>>> comparing it later.
>>>       
>> I didn't really look at the script, but I made a similar parser [1] earlier,
>> initially for AUR2 purposes. Looking over it, it seems I don't include the
>> file list during parsing, but that can probably be easily added in. Perhaps
>> it can be expanded upon, instead of creating a new one. If not it should at
>> least help.
>>
>> [1] http://github.com/sebnow/parched/blob/master/parched.py
>>
>>
>>     
>
> So this is both a pkgbuild and pkginfo parser ?
>
> For the AUR, you just need pkgbuild parser, right ? And this is much
> more complex than pkginfo parser.
> Actually that's why I hate pkgbuild :)
>
> There was another pkgbuild parser in python , written by stonecrest,
> and used there :
> http://projects.archlinux.org/?p=dbscripts.git;a=blob;f=cron-jobs/check_archlinux.py;h=cb433513ce53a515a5a6959e6da4da4a8bf0012f;hb=f404689fc11bbeace243779305ede5b7d7270ae8
>
> But I switched to using bash, because this is just much simpler and
> works much better (well this has changed with split pkgbuilds though
> :P).
>
> Anyway, go Xyne :P
> http://xyne.archlinux.ca/ideas/pkgmeta
>   


For the makepkg test suite, the PKGBUILD parser will be very, very 
simple;  no variable substitution or other bash features.  Otherwise, I 
would probably not do this in python.  But given that parsing a split 
PKGBUILD in bash is not fun either...

Allan



More information about the pacman-dev mailing list