chaotic-aur / toolbox

Unified kit with all the scripts required for maintaining the repository 🧰
https://aur.chaotic.cx
GNU Affero General Public License v3.0
81 stars 11 forks source link

[Request] universal interfere #89

Closed xiota closed 10 months ago

xiota commented 11 months ago

Add an interfere that applies to all packages.

Can be used to do some clean-up that should be applied to all packages, like:

PedroHLC commented 11 months ago

https://github.com/chaotic-aur/toolbox/blob/90c3586d7c683fb705796a97ca2ecdc65fa90420/src/lib/interfere.sh#L39

This is what this function is all about.

Technetium1 commented 11 months ago

Double check me, but this could do last point

# * Add newline to end if there is not
if [[ $(tail -c 1 "PKGBUILD" | wc -l) -eq 0 ]]; then
    echo -e "\n" >> "PKGBUILD"
fi
xiota commented 11 months ago

Examples of issues with replaces...

AUR submission guidelines state, "Do not use replaces in an AUR PKGBUILD unless the package is to be renamed..."

Have already sent requests for all packages with replaces directives in chaotic-aur.

xiota commented 11 months ago

@Technetium1 Why not just unconditionally printf "\n" >> PKGBUILD ?

Technetium1 commented 11 months ago

@xiota yes lol, that's valid and much simpler. I was assuming it would be less intensive to not write to all the files, instead only appending if needed. If it's running in memory (which I think it might be right now actually), then it's probably faster to just append the newline blindly.

xiota commented 11 months ago

What about storing everything that needs to be appended in a variable.

_PKGBUILD_APPEND+=$'unset PKGEXT\n'
_PKGBUILD_APPEND+=$'unset groups\n'
_PKGBUILD_APPEND+=$'unset replaces\n'

printf '\n\n%s\n' "$_PKGBUILD_APPEND" >> PKGBUILD

Would also be nice for packages with pkgver() to set pkgver, pkgrel, epoch to match last built package. That should allow bumps to work for -git packages.

dr460nf1r3 commented 11 months ago

TIL! Didn't know this was possible, sounds very handy!

PedroHLC commented 11 months ago

What about storing everything that needs to be appended in a variable.

We already do that with the "wizard.sh", there is a command makepkg-gen-bash-append. There is no need to put everything into a variable, as we can already write to the file.

Also, it's important to reuse the current CAUR_ file paths as maximum as possible, as we're 100% sure those changes when building tons of packages, and they don't need cleanup. Which is super important since we fork into new processes for every package.

PedroHLC commented 11 months ago

What about storing everything that needs to be appended in a variable.

We can already append to the PKGBUILD at any time. This is not better than what we already have.

Would also be nice for packages with pkgver() to set pkgver, pkgrel, epoch to match last built package. That should allow bumps to work for -git packages.

This sounds more as an adjusts that should be done in the bump interference (by detecting functions and treating them). But remember, we can't really call pkgver ahead-of-time since they execute code that needs to be run inside the building container.

For this last one open a new issue, it's quite unrelated to this.