You are not logged in.

#1 2022-06-30 20:04:47

ynikitenko
Member
From: Aachen, Germany
Registered: 2020-11-15
Posts: 44
Website

[SOLVED] PKGBUILD Review: yarsync

Greetings!
I made this PKGBUILD:

# Maintainer: Yaroslav Nikitenko <metst13 at gmail dot com>

pkgbase='yarsync'
pkgname=('yarsync')
_module='yarsync'
pkgver='0.1.1'
pkgrel=1
pkgdesc="Yet Another Rsync is a file synchronization and backup tool"
url="https://github.com/ynikitenko/yarsync"
depends=('python')
makedepends=('python-setuptools')
license=('GPL3')
arch=('any')
install="yarsync.install"
source=("https://github.com/ynikitenko/yarsync/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('3c306c737ba96c315d6c89b7fab875eb1253527ef954f0facf1c15db72ed44c8')

build() {
    cd "${srcdir}/${_module}-${pkgver}"
    python -m pip install --upgrade build
    python setup.py build
}

package() {
    depends+=("rsync>=3.1.0")
    cd "${srcdir}/${_module}-${pkgver}"
    python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
    # copy source files manually
    local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
    cp -r yarsync ${pkgdir}${site_packages}
    install -D docs/yarsync.1.gz ${pkgdir}/usr/share/man/man1/yarsync.1.gz
}

The install script only calls

mandb -q

because it adds a man page and I think it should be synchronized.

# Copied from /usr/share/pacman/proto.install
# Uncomment only required functions and remove any functions
# you don't need (and this header).

## arg 1:  the new package version
#pre_install() {
	# do something here
#}

## arg 1:  the new package version
post_install() {
   mandb -q
}

## arg 1:  the new package version
## arg 2:  the old package version
#pre_upgrade() {
	# do something here
#}

## arg 1:  the new package version
## arg 2:  the old package version
post_upgrade() {
   mandb -q
}

## arg 1:  the old package version
#pre_remove() {
	# do something here
#}

## arg 1:  the old package version
post_remove() {
    mandb -q
}

Unfortunately, I could not make a source based on git rev-parse:

# does not work.
source=(git+$url.git?signed#tag=$_tag)

Anyway, since I develop that program, I promise not to break tags after I publish the AUR update smile

Also it looks a bit strange to me that I have to copy the sources manually (I don't want to create the wheel, because sources look better for free software, especially an interpreted script (I fix that manually when I need)) - otherwise eggs just link to the code, which is missing.

I hope all this is not so crucial, since the program is installed only once (and I checked that it is installed). However, if you can note something about the code, this might be very useful! (this is my first AUR package).

P.S. I can't publish it yet, because there is another package with that name yarsync on AUR. I wrote to its author on github just in case he doesn't need it anymore, so waiting for his reply.

Last edited by ynikitenko (2022-07-03 13:50:31)

Offline

#2 2022-06-30 22:05:07

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: [SOLVED] PKGBUILD Review: yarsync

pkgbase='yarsync'
pkgname=('yarsync')
_module='yarsync'

Why? pkgbase is already defined by pkgname (which doesn't need to be an array), and having a 3rd variable for the same thing is pretty pointless.

The source file needs to be renamed. The filename is too generic and can cause conflicts when using a single SRCDIR.

What in the world is `python -m pip install --upgrade build` doing? It won't even work as pip isn't in the deps, but it seems like a very bad idea in general. You probably want to read https://wiki.archlinux.org/title/Python … guidelines

Your .install file may fail as-is, since man-db isn't in the deps. If that's something that really needs to be run, it should be done in a hook in the man-db package.

Offline

#3 2022-07-01 07:42:37

ynikitenko
Member
From: Aachen, Germany
Registered: 2020-11-15
Posts: 44
Website

Re: [SOLVED] PKGBUILD Review: yarsync

Dear Scimmia, many thanks for these remarks. Now the file looks like this:

# Maintainer: Yaroslav Nikitenko <metst13 at gmail dot com>

pkgname='yarsync'
pkgver='0.1.1'
pkgrel=1
pkgdesc="Yet Another Rsync is a file synchronization and backup tool"
url="https://github.com/ynikitenko/yarsync"
depends=('python' 'man-db')
makedepends=('python-setuptools')
license=('GPL3')
arch=('any')
install="yarsync.install"
source=("$pkgname-$pkgver.tar.gz::https://github.com/ynikitenko/yarsync/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('3c306c737ba96c315d6c89b7fab875eb1253527ef954f0facf1c15db72ed44c8')

build() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    python setup.py build
}

package() {
    depends+=("rsync>=3.1.0")
    cd "${srcdir}/${pkgname}-${pkgver}"
    python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
    # copy source files manually
    local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
    cp -r yarsync ${pkgdir}${site_packages}
    install -D docs/yarsync.1.gz ${pkgdir}/usr/share/man/man1/yarsync.1.gz
}

# with some links to the wiki in the end

> Why? pkgbase is already defined by pkgname
I automatically generated its first draft with a tool like pip2arch. But you are right, I fixed that.

> The source file needs to be renamed.
You are right, thanks. I didn't know how to do that, but then found in the Wiki.

> What in the world is `python -m pip install --upgrade build` doing?
It installs the latest version of PyPA’s build. This is recommended in the official Python documentation. However, I think it should work without that.

>Your .install file may fail as-is, since man-db isn't in the deps.
You are right, I added that. I think that the documentation is important for my project, so I decided to add that. If some users don't need this, maybe we can agree on something (or they just edit their PKGBUILD). I agree that this is not a very good decision, but I don't know of any better one. If an "average user" installs my package, it would be good if he or she could use its man immediately.

> should be done in a hook in the man-db package.
I don't know how to do that. I don't own the man-db package.

Thanks again for all your in-depth suggestions, they proved really useful!

Offline

Board footer

Powered by FluxBB