ava1ar / customizepkg

A tool for Arch Linux package manager pacman to modify PKGBUILD automatically
GNU General Public License v3.0
49 stars 14 forks source link

Eval broken for a pkgname with multiple names #19

Closed stevenhoneyman closed 8 years ago

stevenhoneyman commented 9 years ago

I'll try and get something in place to fix as soon as I can, but I've had very little time to spend on open source stuff lately. My current broken package is qemu. this breaks the script at line 149:

pkgname=('qemu'
         'qemu-block-iscsi'
         'qemu-block-rbd'
         'qemu-block-gluster'
         'libcacard')
ava1ar commented 9 years ago

What customizations are you applying for qemu (just want to reproduce the issue)?

stevenhoneyman commented 9 years ago

Any change should trigger it, but here's my slightly out-of-date config anyway:

remove#makedepends#libpulse
remove#makedepends#libcacard
##remove#makedepends#libseccomp
remove#makedepends#seabios
remove#makedepends#bluez-libs
remove#makedepends#spice
remove#makedepends#spice-protocol

remove#global#'libpulse'
remove#global#'seabios'
remove#global#'bluez-libs'
remove#global#'spice'
remove#global#'libcacard'
##remove#global#'libseccomp'
replace#global#!strip#strip

replace#global#--audio-drv-list='pa alsa sdl'#--audio-drv-list='alsa sdl'
replace#global#--enable-docs#--disable-docs
##replace#global#--enable-seccomp#--disable-seccomp
replace#global#--enable-spice#--disable-spice

replace#global#--enable-tpm #&--enable-{pie,curses,user,sdl,vnc} --disable-{werror,libnfs,smartcard-nss,guest-agent,libssh2,vhdx,quorum,bluez,xen,debug-info} --target-list="i386-softmmu x86_64-softmmu arm-softmmu arm-linux-user" 

replace#global#rm -r "${pkgdir}\/var"#rm -rf "${pkgdir}\/var"
removeline#global#rm....pkgdir.\/usr\/share\/qemu

I think the solution is going to involve changing that grep command to a small awk script, but maybe we can get away with using a PCRE instead.

stevenhoneyman commented 8 years ago

August... wow, that's gone quickly!

How do you like the look of this as a fix for this issue? My PCRE skills are incredibly rusty (and basic to begin with) but this seems to do the job and hasn't broken anything else yet. Maybe test for a couple of weeks before merging?

--- /bin/customizepkg   2015-12-27 21:42:26.000000000 +0000
+++ ./customizepkg  2015-12-27 21:37:33.538483104 +0000
@@ -167 +167 @@
-eval $(grep -Po '^[[:blank:]]*_?(pkg.*|name)=[^#]*(?= *#|$)' ./PKGBUILD | grep -Ev '\$\(|`')
+eval $(grep -Pzo '^[[:blank:]]*_?(pkg.*|name)=(\((.|\n)*?\)|[^#]*?(?= *#|$))' ./PKGBUILD | grep -Ev '\$\(|`')
ava1ar commented 8 years ago

I tried new varian on my cistomizations - looks like it works good. Regarding PCRE, my skills are also very limited, but we can always revert the change if it breaks something for somebody. Merging the fix.

ava1ar commented 8 years ago

Actual again: due to changes in grep behavior fix with "-Pz" options won't work anymore.

stevenhoneyman commented 8 years ago

How about

--- customizepkg    2016-04-03 15:53:58.904323720 +0100
+++ /bin/customizepkg   2016-04-03 15:54:34.274324246 +0100
@@ -167 +167 @@
-eval $(grep -Pzo '^[[:blank:]]*_?(pkg.*|name)=(\((.|\n)*?\)|[^#]*?(?= *#|$))' ./PKGBUILD | grep -Ev '\$\(|`')
+eval $(grep -Pzo '[^[:print:]][[:blank:]]*_?(pkg.*|name)=(\((.|\n)*?\)|[^#]*?(?= *#|\x0a))' ./PKGBUILD | grep -Ev '\$\(|`')

Please note that it requires an upstream bugfix to work: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d97cfd43d091662065482a8b72f17e25e296d15b

stevenhoneyman commented 8 years ago

Tiny addition needed (ascii files), other than this, no problems in the past month:

--- customizepkg    2016-04-28 17:59:51.025211419 +0100
+++ /bin/customizepkg   2016-04-28 18:01:42.078546397 +0100
@@ -167 +167 @@
-eval $(grep -Po '^[[:blank:]]*_?(pkg.*|name)=[^#]*(?= *#|$)' ./PKGBUILD | grep -Ev '\$\(|`')
+eval $(grep -Pazo '[^[:print:]][[:blank:]]*_?(pkg.*|name)=(\((.|\n)*?\)|[^#]*?(?= *#|\x0a))' ./PKGBUILD | grep -Eva '\$\(|`')
ava1ar commented 8 years ago

@stevenhoneyman Did the bugix for grep you mentioned already released?

stevenhoneyman commented 8 years ago

Yes, it's included in v2.25, released 9 days ago.

ava1ar commented 8 years ago

Merged the fix. Thanks, @stevenhoneyman!