Package Details: makepkg-optimize 15-1

Git Clone URL: (read-only)
Package Base: makepkg-optimize
Description: Supplemental build and packaging optimizations for makepkg
Upstream URL:
Licenses: GPL
Submitter: quequotion
Maintainer: quequotion
Last Packager: quequotion
Votes: 9
Popularity: 0.95
First Submitted: 2016-03-20 15:08
Last Updated: 2019-11-01 03:50

Pinned Comments

quequotion commented on 2019-02-27 07:49

makepkg-optimize is a collection of libmakepkg tidy, buildenv, and executable extensions, and a supplement to pacman-git. These enable various optimization routines for building and packaging such as upx compression, profile guided optimization, link time optimization, polyhedral model optimization, etc..

Note: Over-optimization is a thing, and it is not good.

See the wiki article for details.

Note to packagers: makepkg-optmize's macros may be enabled or disabled in options() as well!

Latest Comments

« First ‹ Previous 1 2 3 4 Next › Last »

quequotion commented on 2018-12-30 12:11

@brikler Aha, another filetype that is excluded. Yes, you could get upx to compress this by adding it to the list. Again, I don't know if it is safe to do so. You should look up if anyone has tried upx on shared libraries.

After the holidays, I think what I will do with the script in this package is add a catch-all case that will ouput something like:

Skipping upx compression for unsupported binary: $binary $filetype

Of course any filetypes that can be proven safe to upx compress I will add to the list!

brikler commented on 2018-12-26 17:18

[tom@donar upx]$ file --brief --mime-type upx

is it helpful?

edit your idea solves the problem :)

        case "$(file --brief --mime-type "$binary")" in
                'application/x-executable' | 'application/x-dosexec' | 'application/x-sharedlib') 

thank you for your help :)

quequotion commented on 2018-12-26 08:35

@brikler could you run:

file --brief --mime-type "$binary"

On that unpacked upx binary? (put it in place of $binary). I'm pretty sure you're going to get "application/x-pie-executable".

I've tried to run a a few PIE programs compressed by UPX, but they crash. This type of executable was excluded by the pacman developers when the upx script was part of it. I don't know if that is because it is known to be unsafe, or just an oversight. I found very little about PIE and UPX by google search, but what I could find suggests that it may be unsafe.

brikler commented on 2018-12-21 09:45

@quequotion doesn't work. i have build upx withe "upx" in the option array but the binary wasn't compressed. a really simple test unpack the package and compress the binary:

[tom@donar upx]$ upx --exact upx
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
   1958664 ->    493528   25.20%   linux/amd64   upx                           

Packed 1 file.
[tom@donar upx]$ upx -d --exact upx
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
   1958664 <-    493528   25.20%   linux/amd64   upx

Unpacked 1 file.

if it where compressed there would be throw a "cant pack exception"

[tom@donar upx]$ upx --exact upx
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
upx: upx: CantPackException: bad e_shstrndx

Packed 0 files.

quequotion commented on 2018-12-20 06:22

@brikler please post the error messages you received, if any. posting the code is not necessary, but if you do post code, put it between two lines of ``` to make a code block (AUR supports markdown).

here is an example

I'm looking into this, but I believe this code works. It is exactly the same code as was removed from pacman.

I added a catchall statement to the case switch:

    echo "$(file --brief --mime-type "$binary")"

This showed executables having the filetype "application/x-pie-executable". I'm not sure if it is safe to compress a PIE executable with UPX.

brikler commented on 2018-12-19 14:38

the upx script doesn't work as expected i noticed because i had build some packages with set upx in the option array but the binaries was never compressed.

tidy_upx() {
    if check_option "upx" "y"; then
        msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
        local binary
        find . -type f -perm -u+w 2>/dev/null | while read -r binary ; do
            case "$(file --brief --mime-type "$binary")" in
                'application/x-executable' | 'application/x-dosexec')
                    upx "${UPXFLAGS[@]}" "$binary" &>/dev/null ||
                        warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"

it seems binary never reached the upx comman

quequotion commented on 2018-11-28 02:34

Good news, buildenv is now extendable:

makepkg-optimize 5-1 is now a supplement to pacman-git!

As such, the package now conflicts() and replaces() pacman-buildenv_ext-git, which is deprecated, and depends() on pacman-git.

To avoid the possibility of pacman removing itself, remove old versions of makepkg-optimize and install pacman-git before upgrading.

If you use an AUR helper, you can probably install them simultaneously:

pikaur -S makepkg-optimize pacman-git

See the wiki article for details.

quequotion commented on 2016-11-14 17:18


Long story short, the concept may get in there, someday...

I have grown tired of waiting. I've uploaded a patched "pacman-buildenv_ext-git" and "makepkg-optimize" to demonstrate how this {c,sh}ould work in the future: pacman patched to allow extensions to BUILDENV and separate packages of supplemental BUILDENV and Tidy extensions.

wolf commented on 2016-06-30 12:36

> Neither would be necessary, were my proposal to pacman-dev approved

what as the reason it was not approved? I went throught the mailing list and saw no response to your patch. Did you get back any feedback at all?

It sounds pretty useful.

quequotion commented on 2016-04-01 06:29

For now, makepkg-optimize installs an alternative script and configuration file.

Neither would be necessary, were my proposal to pacman-dev approved: