You are not logged in.

#1 2021-01-05 22:47:41

Registered: 2021-01-03
Posts: 2

PKGBUILD Review Request

Hello. I have recently made an installable package that I would like to upload to the AUR as my first package. However, my PKGBUILD has some glaring issues that I would greatly appreciate some feedback on.

To give some more context about my program: I've written a Python program and it's using setuptools (or, what I understand to be handling certain automation during 'makepkg'). These are the main issues I'm experiencing, specifically in the package() function:  I've had to manually install a configuration file, manually edit a line of text from the repository, and manually assign execute permissions to the main module. All other files were automatically placed in the correct system directories as expected. As to whether my decisions are the right way to go about things, I'm definitely unclear on- largely because the program is running just fine from the command line after installing.

Here's my PKGBUILD:

# Maintainer: Lawrence <>
pkgdesc="A tray application designed to dim the brightness of your monitors."
makedepends=('git' 'python-setuptools')

build() {
        cd "$pkgname"           
        python build

package() {     

        cd "$pkgname"
        python install --root="$pkgdir" --optimize=1 --skip-build      

        # Need perms on following file  
        install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
        install -Dm644 brightness.ini "$pkgdir/etc/$pkgname/brightness.ini"
        install -Dm644 "$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
        install -Dm644 "$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"

        # Make sure the shell scripts points to the correct Python version:
        # (setuptools seems to automatically creates this directory depending on the Python version I've used)
        _python_version="$printf$(ls $pkgdir/usr/lib/)"                 
        _line2="exec /usr/lib/$_python_version/site-packages/$pkgname/"               
        printf "$_line1\n$_line2" > "$pkgdir/usr/bin/$pkgname"

        # Lastly, assign execute permission to main module
        chmod +x "$pkgdir/usr/lib/$_python_version/site-packages/$pkgname/"

That said, I'm open to feedback, and feel free to let me know if I can provide any more information.


#2 2021-01-05 23:35:05

Bug Wrangler
Registered: 2012-09-01
Posts: 8,203

Re: PKGBUILD Review Request

The upstream setup is bad. If is the main script that the user should be running, why isn't that being installed to /usr/bin/? Or make that a library and just import that and create_tray from a separate script?


#3 2021-01-06 01:29:27

Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 3,876

Re: PKGBUILD Review Request

You're currently using the old distutils "scripts" method of installing a program in /usr/bin -- but you're doing it wrong. Don't create a bash script that execs, create a python script with:


from screendimmer.tray import create_tray

setuptools will auto-rewrite the shebang to target the version of python you used to run install, so this works for any version of python, inside or outside of virtualenvs, etc.

You'll need to remove the final line from, or guard it in the common python pattern for a file that can be imported *or* executed as a module:

Another method of doing this is to forego the "scripts" and instead use

        'gui_scripts': [

setuptools will then generate its own script for you; this script might be a python script importing the same function and running it, but on Windows it could instead be a special .exe file handling the Windows... shortcomings... when it comes to scripts. This is very useful for cross-platform code.

More info: … point.html


P.S. The software needs to use git tags: … immer/tags

You can then use the source line:

# git is not needed

If your package uses the latest git master then you need to follow the instructions at … guidelines including use pkgname=screendimmer-git and including a pkgver() function.

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)


#4 2021-01-06 01:57:51

Registered: 2021-01-03
Posts: 2

Re: PKGBUILD Review Request

Thanks for taking the time to write your feedback eschwartz. You've cleared up several misconceptions I've held for a while that I struggled to articulate as a question. I'll be taking another shot with this information soon.

Scimmia wrote:

If is the main script that the user should be running, why isn't that being installed to /usr/bin/? Or make that a library and just import that and create_tray from a separate script?

It's an educated guess based on googling, looking at other PKGBUILDs, and trying to fit the pieces together from the Wiki. Now I understand your latter suggestion is the right way to go about it. Thanks for the feedback.


Board footer

Powered by FluxBB