bvaudour/kcp

[pckcp] sanitize spaces in functions

Opened this issue · 4 comments

If one of the functions within a PKGBUILD include a whitespace, pckcp reports errors. The PGKBUILD works as expected (bash-magic?), but it doesn't looks right.

For reproduction, try the following:

  1. create a new PKGBUILD with pckcp -g
  2. open the PKGBUILD with you favorite text editor and change line 104 build() { to build () { (added one whitespace after build)
  3. run pckcp

I get the following output:

Warning (L.1-38):                                                                                                                                                                                                                            
  Header was found. Do not use names of maintainers or contributors in PKGBUILD, anyone can contribute, keep the header clean from this.                                                                                                     
Info (L.45):                                                                                                                                                                                                                                 
  pkgrel is clean.                                                                                                                                                                                                                           
Warning (L.72):                                                                                                                                                                                                                              
  Variable 'makedepends' is empty.                                                                                                                                                                                                           
Info (L.72):                                                                                                                                                                                                                                 
  Variable 'makedepends' is clean.                                                                                                                                                                                                           
Warning (L.85):                                                                                                                                                                                                                              
  PKGNAME.install doesn't exist!                                                                                                                                                                                                             
Warning (L.69):                                                                                                                                                                                                                              
  Variable 'depends' is empty.                                                                                                                                                                                                               
Info (L.69):                                                                                                                                                                                                                                 
  Variable 'depends' is clean.                                                                                                                                                                                                               
Warning (L.81):                                                                                                                                                                                                                              
  Variable 'backup' is empty.                                                                                                                                                                                                                
Info (L.56):                                                                                                                                                                                                                                 
  arch is clean.                                                                                                                                                                                                                             
Warning (L.75):                                                                                                                                                                                                                              
  Variable 'checkdepends' is empty.                                                                                                                                                                                                          
Info (L.75):                                                                                                                                                                                                                                 
  Variable 'checkdepends' is clean.
Warning (L.78):
  Variable 'optdepends' is empty.
Info (L.78):
  Variable 'optdepends' is clean.
Info (L.115-118):
  package() function is present.
Error (L.104):
  'build() {' is not valid. You should suppress it
Error (L.105):
  'cd"${pkgname}-${pkgver}"' is not valid. You should suppress it
Error (L.106):
  './configure--prefix=/usr' is not valid. You should suppress it
Error (L.107):
  'make' is not valid. You should suppress it
Error (L.108):
  '}' is not valid. You should suppress it

Expected result: Warning about malformed function name

Yep I know but it's very hard to make a clean parser. there could be white spaces between parenthesises too and that makes the parser more complex.

The question is: Is it worth?

If you think, writing the parser is to much pain because this issue doesn't happen enough to warrant it, I'm on your side.

I just wanted to report it so it doesn't slip through. 😉

And you're right :)
If you've skills in development you can take a look in the parser API: https://github.com/bvaudour/kcp/tree/master/src/parser/pkgbuild

(in particular the file read.go which read the PKGBUILD character by character and analyzes the semantic).

You're completely free to make suggestions to improve the parser, I'll implement them with pleasure ;)

Sorry, I have to pass. I have no knowledge about go. I only know python3, and that isn't even on a good level. 😅 But thanks for your patience.