You are not logged in.

#1 2019-06-06 23:54:20

smuise
Member
From: Yarmouth NS
Registered: 2018-08-06
Posts: 7

PKGBUILD review

My first time creating a PKGBUILD. namcap doesn't complain and it built successfully in a clean chroot. Any tips or feedback would be appreciated.

PKGBUILD

# Maintainer: Spencer Muise <smuise@protonmail.com>
pkgname=calibre-web-git
pkgver=0.6.3.r13.gf736a15
pkgrel=1
pkgdesc="Web app for browsing, reading and downloading eBooks store in a Calibre database"
arch=('any')
url="https://github.com/janeczku/calibre-web"
license=('GPL3')
depends=(
  'python'
  'python-babel'
  'python-flask-babel'
  'python-flask-login'
  'python-flask-principal'
  'python-flask'
  'python-pypdf2'
  'python-pytz'
  'python-requests'
  'python-sqlalchemy'
  'python-tornado'
  'python-wand'
  'python-unidecode'
  'python-blinker'
  'python-iso639'
)
makedepends=('git')
provides=('calibre-web')
source=(
  "git+https://github.com/janeczku/calibre-web.git"
  'calibre-web.service'
  'calibre-web.sysusers'
  'calibre-web.tmpfiles'
)
md5sums=('SKIP'
         'f55db8f14ea9e561875e0609969800fc'
         '83b254e94bb77557ce1eef583b8e8fde'
         'e61f04da45effb1b9430082ee7f45252')

pkgver() {
  cd calibre-web
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  install -d -m 755 "${pkgdir}/opt/calibre-web"
  cp -a "${srcdir}/calibre-web"/* "${pkgdir}/opt/calibre-web/"
  rm -rf "${pkgdir}/opt/calibre-web/.git"

  install -D -m 644 "${srcdir}/calibre-web.service" "${pkgdir}/usr/lib/systemd/system/calibre-web.service"
  install -D -m 644 "${srcdir}/calibre-web.sysusers" "${pkgdir}/usr/lib/sysusers.d/calibre-web.conf"
  install -D -m 644 "${srcdir}/calibre-web.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/calibre-web.conf"
}

calibre-web.service

[Unit]
Description=Calibre-web

[Service]
Type=simple
User=calibre-web
Group=calibre-web
ExecStart=/usr/bin/python /opt/calibre-web/cps.py
WorkingDirectory=/opt/calibre-web/
KillSignal=SIGINT
SendSIGHUP=yes

[Install]
WantedBy=multi-user.target

calibre-web.sysusers

u calibre-web - "Calibre-web Server" /opt/calibre-web

calibre-web.tmpfiles

d /opt/calibre-web 0755 calibre-web calibre-web
Z /opt/calibre-web - calibre-web calibre-web

Thanks!

Offline

#2 2019-06-07 00:11:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,264
Website

Re: PKGBUILD review

It looks pretty good, but a couple minor points:

1) purely a nitpicky style issue, but you use single quotes in most places where they can be used except for the first source line.  There is no variable expansion in that source, so why the double quote there?

2) Why are you installing to /opt?

3) Do you need to call python explicitly?  Doesn't the script have a proper shebang?  If it doesn't, you could add one.

EDIT: ignore most of the above - upstream includes setup.py, use setuptools to do build this properly and cleanly.  See examples from other python packages.

Here are a couple examples:
https://aur.archlinux.org/cgit/aur.git/ … =powerpill
https://aur.archlinux.org/cgit/aur.git/ … thon3-xcgf

Last edited by Trilby (2019-06-07 00:20:29)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#3 2019-06-07 00:31:34

smuise
Member
From: Yarmouth NS
Registered: 2018-08-06
Posts: 7

Re: PKGBUILD review

1) purely a nitpicky style issue, but you use single quotes in most places where they can be used except for the first source line.  There is no variable expansion in that source, so why the double quote there?

I just totally overlooked that - initially I had the package name as "calibre-web" and used $pkgname in the first source line, but then when I realized "calibre-web-git" was the proper way to name it, I replaced the variable but didn't even notice the quotes.

2) Why are you installing to /opt?

Honestly I wasn't really 100% sure which directory to put it in, looking at some other packages it looks like /usr/lib would be more appropriate so I'll correct that - please let me know if I'm wrong on that though.

3) Do you need to call python explicitly?  Doesn't the script have a proper shebang?  If it doesn't, you could add one.

That's just my inexperience talking - just tested and it works fine without explicitly calling python so I'll take care of that as well.

EDIT: ignore most of the above - upstream includes setup.py, use setuptools to do build this properly and cleanly.  See examples from other python packages.

I'm honestly not super well acquainted with setuptools, so I'll do some research and have a look at some other packages and go from there.

Thanks so much for the help!

Offline

#4 2019-06-07 01:33:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,264
Website

Re: PKGBUILD review

Basically setup tools does most of the installation for you much like `make install` for projects with a (good) makefile.  It follows good standards and accepts a few options like prefix and root (equivalent of DESTDIR).  It a wide range of cases, it will also ensure an executable script is placed in /bin to run the python tool it "sets up".


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#5 2019-06-07 01:50:05

smuise
Member
From: Yarmouth NS
Registered: 2018-08-06
Posts: 7

Re: PKGBUILD review

Yeah setuptools definitely sounds like the way to go, but if I'm understanding correctly I think upstream's setup.py isn't actually finished yet. Looks like setup() is just empty, and it was added pretty recently. I'll keep an eye on the repo for now and maybe I'll take a crack at writing setup.py myself and opening a pull request.

Thanks again!

Offline

#6 2019-06-07 03:14:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,264
Website

Re: PKGBUILD review

That file does not define the setup function, it just calls it.  In this case, it is called with no parameters.  Generally I include parameters to the setup function call in setup.py, but I have minimal experience with setuptools.  There is a complete setup.cfg which provides all the parameters I'd normally see passed to setup().  And the command as demonstrated in the example PKGBUILDs above does just what it should.

The only exception as the upstream source hasn't configured the entry_points parameter which creates the script in /usr/bin/.  This may need to be created manually (it's pretty much just a couple boilerplate lines).  But perphaps someone more versed in python packaging could chime in on this part.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#7 2019-06-07 16:15:10

smuise
Member
From: Yarmouth NS
Registered: 2018-08-06
Posts: 7

Re: PKGBUILD review

Trilby wrote:

That file does not define the setup function, it just calls it.  In this case, it is called with no parameters.  Generally I include parameters to the setup function call in setup.py, but I have minimal experience with setuptools.  There is a complete setup.cfg which provides all the parameters I'd normally see passed to setup().  And the command as demonstrated in the example PKGBUILDs above does just what it should.

Thanks again - I appreciate your patience in explaining this, I've done some more testing and yeah setup.py totally works I was just being an idiot - that part's fine now.

Trilby wrote:

The only exception as the upstream source hasn't configured the entry_points parameter which creates the script in /usr/bin/.  This may need to be created manually (it's pretty much just a couple boilerplate lines).  But perphaps someone more versed in python packaging could chime in on this part.

This is the last piece of the puzzle it seems, and I'm not really sure what the best way to go about this would be. I’m gonna keep researching and see if I can figure it out on my own but if you or anyone else has any advice on this I'd greatly appreciate it.

Last edited by smuise (2019-06-07 20:07:15)

Offline

Board footer

Powered by FluxBB