You are not logged in.
Hello,
I haven't packaged for a while and noticed that with pacman 4.1 many things changed. Thus I would like to get your feedback on my PKGBUILD for a Google Tasks cli client called tasky. It uses a Github repository and requires python2 which is why I used sed to replace the shebang. Is that the correct way to go?
_pkgname=tasky
pkgname=${_pkgname}-git
pkgver=27
pkgrel=1
pkgdesc="A command-line desktop client for Google Tasks."
arch=('any')
url="https://github.com/connermcd/tasky"
license=('GPL')
depends=('python2' 'python2-google-api-python-client')
makedepends=('git')
provides=("${_pkgname}")
source=('git://github.com/connermcd/tasky.git')
md5sums=('SKIP')
pkgver() {
cd "$_pkgname"
# Use the tag of the last commit
local ver="$(git describe --long)"
printf "%s" "${ver//-/.}"
}
package() {
cd "$_pkgname"
# fixing shebang to python2
sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" "$srcdir/$_pkgname/src/tasky.py"
# copying binaries
install -D -m755 "$srcdir/$_pkgname/src/tasky.py" "${pkgdir}/usr/bin/tasky"
install -D -m755 "$srcdir/$_pkgname/src/keys.py" "${pkgdir}/usr/bin/keys"
# copying readme information
install -D -m644 "$srcdir/$_pkgname/README.md" "$pkgdir/usr/share/doc/$pkgname/README"
}
# vim:set ts=2 sw=2 et:
Thank you!
Offline
Overall it looks fine. I have just a few notes:
You should change "_pkgname" to "_gitname" (this is simply a convention).
Any code that alters the sources such as the sed statement should be in a separate prepare function.
You should always use cd "$srdcir/foo" instead of cd foo. This is more clearer and future proof. See this post and the rest of the thread for more.
I would omit the curly brackets when quoting a single variable, e.g "${_pkgname}" -> "$_pkgname", but that is just a matter of taste.
You may as well quote the variable in the assignment to pkgname.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks Xyne!
Here is the updated PKGBUILD:
_gitname=tasky
gitname=${_gitname}-git
pkgver=27
pkgrel=1
pkgdesc="A command-line desktop client for Google Tasks."
arch=('any')
url="https://github.com/connermcd/tasky"
license=('GPL')
depends=('python2' 'python2-google-api-python-client')
makedepends=('git')
provides=("$_gitname")
source=('git://github.com/connermcd/tasky.git')
md5sums=('SKIP')
pkgver() {
cd "$srcdir/$_gitname""
# Use the tag of the last commit
local ver="$(git describe --long)"
printf "%s" "${ver//-/.}"
}
prepare() {
cd "$srcdir/$_gitname""
# fixing shebang to python2
sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" "$srcdir/$_gitname/src/tasky.py"
}
package() {
cd "$srcdir/$_gitname"
# copying binaries
install -D -m755 "$srcdir/$_gitname/src/tasky.py" "${pkgdir}/usr/bin/tasky"
install -D -m755 "$srcdir/$_gitname/src/keys.py" "${pkgdir}/usr/bin/keys"
# copying readme information
install -D -m644 "$srcdir/$_gitname/README.md" "$pkgdir/usr/share/doc/$gitname/README"
}
However, makepkg fails to build:
==> ERROR: pkgname is not allowed to be empty.
That is, although using gitname I also need a pkgname?
Offline
You should use _gitname instead of _pkgname (with underscore), but keep pkgname. In my opinion _pkgname is acceptable, too since _pkgname contains the name of the original package for which you provide a -git version. Luckily the git repository has the same name as the original package, so you don't need another variable.
So either use
_gitname=tasky
pkgname="${_gitname}-git"
provides=("$_gitname")
source=('git://github.com/connermcd/${_gitname}.git')
or
_pkgname=tasky
pkgname="${_pkgname}-git"
provides=("$_pkgname")
source=('git://github.com/connermcd/${_pkgname}.git')
Last edited by progandy (2013-09-23 07:58:11)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
One last question.
I just noticed that I cannot install keys.py to /usr/bin since it is just the library required by tasky.py.
I think the right place to put it is in /usr/lib/python<python version>/site-packages/pkgname. But how do I set the properly in PKGBUILD in order to account for the different python2 versions a user might be using?
Last edited by orschiro (2013-09-23 08:11:41)
Offline
If I use the following line in PKGBUILD, then tasky complains that it cannot find the module keys.py:
install -D -m644 "${srcdir}/${_gitname}/src/keys.py" "${pkgdir}/usr/lib/python2.7/site-packages/${_gitname}/keys.py"
Traceback (most recent call last):
File "/usr/bin/tasky", line 24, in <module>
import keys
ImportError: No module named keys
[orschiro@thinkpad ~]$ ls /usr/lib/python2.7/site-packages/tasky/keys.py
-rw-r--r-- 1 root root 947 Sep 23 10:23 /usr/lib/python2.7/site-packages/tasky/keys.py
Offline
For now I just put keys.py back into /usr/bin. However, I am not sure if this is the correct way since keys.py is just a module that tasky.py needs to import.
EDIT:
Here is the final PKGBUILD for now:
https://aur.archlinux.org/packages/tasky-git/
_gitname=tasky
pkgname=${_gitname}-git
pkgver=27
pkgrel=1
pkgdesc="A command-line desktop client for Google Tasks."
arch=('any')
url="https://github.com/connermcd/tasky"
license=('GPL')
depends=('python2>=2.7' 'python2-google-api-python-client')
makedepends=('git')
provides=("$_gitname")
source=('git://github.com/connermcd/tasky.git')
md5sums=('SKIP')
pkgver() {
cd "$srcdir/$_gitname"
# Use the tag of the last commit
local ver="$(git describe --long)"
printf "%s" "${ver//-/.}"
}
prepare() {
cd "$srcdir/$_gitname"
# Fixing shebang to python2
sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" "${srcdir}/${_gitname}/src/tasky.py"
# Adjusting tasky_dir to $HOME/.tasky
sed -i -e "s|import os.path|import os|" "${srcdir}/${_gitname}/src/tasky.py"
sed -i -e "s|os.path.dirname(os.path.realpath(__file__))|os.environ['HOME'] + '/.${_gitname}'|" "${srcdir}/${_gitname}/src/tasky.py"
# writing keys.txt to $HOME/.tasky
sed -i -e '1i\import os' "${srcdir}/${_gitname}/src/keys.py"
sed -i -e "s|'keys.txt'|os.environ['HOME'] + '/.${_gitname}/keys.txt'|" "${srcdir}/${_gitname}/src/keys.py"
}
package() {
cd "$srcdir/$_gitname"
# create user directory
install -dm755 "${HOME}/.${_gitname}/"
# copying binaries and libaries
install -D -m755 "${srcdir}/${_gitname}/src/tasky.py" "${pkgdir}/usr/bin/${_gitname}"
install -D -m644 "${srcdir}/${_gitname}/src/keys.py" "${pkgdir}/usr/bin/keys.py"
# copying readme information
install -D -m644 "${srcdir}/${_gitname}/README.md" "${pkgdir}/usr/share/doc/${_gitname}/README"
}
# vim:set ts=2 sw=2 et:
Last edited by orschiro (2013-09-23 14:36:59)
Offline
# create user directory
install -dm755 "${HOME}/.${_gitname}/"
This is wrong. PKGBUILDs should never, ever touch the home dirs. If you really, really have to, you need to do this in a post-install script.
Online
The problem is that right now, that dir gets created for the user that build the package. No matter who installs or uses it, it only gives you a dir at /home/<builduser>/.${_gitname}. This obviously won't work a lot of the time. If you create the dir in the post-install script, atleast it will create it for the user who installs the package - progress, but still not good since no other uses will be able to use the program. Really, the program itself needs to check for the dir and create it if it's not there at runtime.
Online
The problem is that at the moment, tasky expects some files to be in the same directory than the executable. Thus I decided to move them to the user directory.
But you are of course right. This really should be up to the program and not the package manager to create the folder.
For now I will use a post_install() note to ask the user for creating the directory himself.
Offline
Sorry, I had written my previous post in markdown and the converter recognized the underscores in _pkgname and _gitname as emphasis tags.
Anything that belongs in /usr/lib/python<python version>/site-packages/pkgname is usually installed with a setup.py file, which handles version resolution among other things. Upstream should really provide this as it is very simple to write, but the codes looks as though it is intended to be run without proper installation ("keys" is a very generic module name for such a small application, and there is only one very simple class in it which could have just as well been dumped in the main file).
You should consider contacting upstream about this.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks Xyne.
Upstream merged the "keys" module into the main module and takes care of the user directory.
That makes the whole PKGBUILD a lot easier now.
Last edited by orschiro (2013-09-30 12:40:09)
Offline