You are not logged in.

#1 2013-12-22 04:16:48

mavant
Member
Registered: 2013-09-30
Posts: 11

Creating a PKGBUILD for sejda-console

I would like to submit an AUR package for sejda-console (http://www.sejda.org/). However, I've never made a PKGBUILD before, and I want to make sure I haven't done something horribly wrong. The following works on my system, but if you see any mistakes or faux pas I've made, I'd be very glad to hear them!

# Maintainer: Matthew Avant <matthew dot avant at gmail dot com>
pkgname=sejda-console-bin
pkgver=1.0.0.M7
pkgrel=1
pkgdesc="A CLI to execute Sejda commands."
url="www.sejda.org/download/"
arch=('any')
license=('Apache')
depends=('java-environment>=5')
source=('https://github.com/torakiki/sejda/releases/download/v1.0.0.M7/sejda-console-1.0.0.M7-bin.zip')
md5sums=('3bdcc8b4210f83b3cbc439c18e86a38c')

package() {
	install -m 755 -d $pkgdir/opt/sejda/{bin,lib,etc,doc/config,doc/examples/xsd} $pkgdir/usr/bin
	cp -drn --no-preserve=mode -t $pkgdir/opt/sejda/ $srcdir/sejda-console-$pkgver/*
	echo "/opt/sejda/bin/sejda-console" > $pkgdir/usr/bin/sejda-console
	chmod 755 $pkgdir/opt/sejda/bin/sejda-console $pkgdir/usr/bin/sejda-console
}

Last edited by mavant (2013-12-22 22:50:43)

Offline

#2 2013-12-22 04:19:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Creating a PKGBUILD for sejda-console

Use the source(), Luke https://wiki.archlinux.org/index.php/Pkgbuild#source


Edit:

echo "alias sejda-console='/opt/sejda/bin/sejda-console'" >> ~/.bashrc

Please leave my ~/.bashrc alone. I know how to make an alias and I can create one if I like or add the path to the $PATH.

Last edited by karol (2013-12-22 04:21:56)

Offline

#3 2013-12-22 04:28:46

mavant
Member
Registered: 2013-09-30
Posts: 11

Re: Creating a PKGBUILD for sejda-console

Thank you (and edited above). What would be a better way to make the command available? I tried symlinking /bin/sejda to the executable in /opt, but that gives java conniptions.

Offline

#4 2013-12-22 04:34:55

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: Creating a PKGBUILD for sejda-console

sudo does not belong in PKGBUILD. makepkg should not require privileges.

You are supposed to be building a package to be installed with pacman. You are not supposed to be installing anything. Nor are you supposed to be removing anything.

Note that I build all packages as a user who cannot use sudo at all. I should be able to build your package as that user. Of course, I won't be able to install it as that user because I'll need privileges for that.

Also you should not assume, in any case, that everyone has sudo installed.

And if the software really needs something in /opt to be 777 then it is horribly insecure and you ought not encourage anybody to use it.

Last edited by cfr (2013-12-22 04:35:21)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#5 2013-12-22 04:40:52

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: Creating a PKGBUILD for sejda-console

mavant wrote:

Thank you (and edited above). What would be a better way to make the command available? I tried symlinking /bin/sejda to the executable in /opt, but that gives java conniptions.

Provide a message in pacman's output suggesting this.

In any case, symlinking from /bin/ is poor practice since /bin is a sym link.

I don't intend any offence but you clearly have no idea what you are doing. You do not seem to understand what a package manager is or what a package is, let alone how to produce a PKGBUILD. I suggest you start by reading the wiki pages on pacman, makepkg and PKGBUILDs before having another go. Also, read some PKGBUILDs. You should always read them before building anything from AUR anyway, but I suspect you either don't or you just haven't built many AUR packages. Either way read some good ones. E.g. pick something one of the devs has written (like cower) and see how they handle things.

EDIT: OK. cower isn't a good example because it does very little in the PKGBUILD. Here is a list of packages maintained by falconindy:

autoconf-git
bash3
burp-git
cower
cower-git
curl-git
dbus-git
expac-git
kmod-git
libcgroup-git
m4-git
modtree
nghttp2-git
pacman-git
patchelf
pkgfile-git
ponymix
ponymix-git
procps-ng-git
pyalpm-git
python-pyyajl-git
python2-kmod-git
python2-leveldb-svn
spdylay
spindly-git
systemd-git
uber-mutt
util-linux-git
zlib-asm

EDIT: Also https://wiki.archlinux.org/index.php/Creating_Packages. If this is java, you also need to read https://wiki.archlinux.org/index.php/Ja … Guidelines.

Last edited by cfr (2013-12-22 04:58:17)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2013-12-22 05:45:41

mavant
Member
Registered: 2013-09-30
Posts: 11

Re: Creating a PKGBUILD for sejda-console

Thank you for your help (and candor). After going back to reread the relevant wiki pages and looking over some of the packages you've listed, I have edited the original post and hopefully fixed everything you pointed out (and of course checked that this builds, installs, and executes as desired with makepkg and pacman -U). Is this proper form, or is there more to address?

Last edited by mavant (2013-12-22 05:58:51)

Offline

#7 2013-12-22 12:48:40

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,922

Re: Creating a PKGBUILD for sejda-console

# Maintainer: Matthew Avant <matthew dot avant at gmail dot com>
pkgname=sejda-console-bin
pkgver=1.0.0.M7
pkgrel=1
pkgdesc="A CLI to execute Sejda commands."
url="www.sejda.org/download/"
arch=('i686' 'x86_64')
license=('Apache 2.0 [url=http://www.sejda.org/about/license/)]http://www.sejda.org/about/license/')[/url]
depends=('jdk7-openjdk')
makedepends=('unzip')
source=('https://github.com/torakiki/sejda/releases/download/v1.0.0.M7/sejda-console-1.0.0.M7-bin.zip')
md5sums=('3bdcc8b4210f83b3cbc439c18e86a38c')

package() {
    cd $srcdir
    mkdir $pkgdir/opt
    mkdir $pkgdir/opt/sejda
    mkdir $pkgdir/bin
    unzip -o sejda-console-$pkgver-bin.zip
    mv $srcdir/sejda-console-$pkgver/* $pkgdir/opt/sejda/
    echo "/opt/sejda/bin/sejda-console" > $pkgdir/bin/sejda-console
    chmod +x $pkgdir/bin/sejda-console
    chmod -R 755 $pkgdir/*
}



The license field is wrong, check https://wiki.archlinux.org/index.php/PKGBUILD#license

Most java packages don't have i686 or x86_64 binaries but instead run on any architecture supported by java,
The main executable in the sourcefile , sejda-console is a shell script that starts java.
The 'any' architecture is likely to the one you should use.

makepkg handles zip files, the unzip command you have is probably unneeded.


echo "/opt/sejda/bin/sejda-console" > $pkgdir/bin/sejda-console
	chmod +x $pkgdir/bin/sejda-console

you should put the start script in $pkgdir/usr/bin , not $pkgdir/bin


Edit : added code tags

Last edited by Lone_Wolf (2013-12-22 13:55:22)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#8 2013-12-22 13:38:40

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: Creating a PKGBUILD for sejda-console

That is definitely much improved!

You don't need the first chmod given the second but are you sure everything in the package should be executable?

Last edited by cfr (2013-12-22 13:39:04)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#9 2013-12-22 16:12:52

progandy
Member
Registered: 2012-05-17
Posts: 5,196

Re: Creating a PKGBUILD for sejda-console

Some more issues I have with the PKGBUILD:
Dont't use mkdir, but "install -d". Always use "install" to move files from $srcdir to $pkgdir. The only exception is "cp -a" if you have large directory structures.
Use a symlink from usr/bin/sejda to opt/sejda/bin/sejda, don't add another shellscript if it is not necessary.
Why the hard dependency on jdk7-openjdk? I think "java-environment>=7" would be better.

Your package function can be reduced to six lines: install opt/sejda structure, copy files, fix permissions, install usr/bin structure, create symlink.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#10 2013-12-22 22:36:14

mavant
Member
Registered: 2013-09-30
Posts: 11

Re: Creating a PKGBUILD for sejda-console

Thank you all. I've attempted to fix everything you pointed out.

Progandy, a symlink was my first thought as well, but the main executable needs to be called from that position relative to the libraries, as it dispatches based on pwd without the -P flag. It'd be relatively easy to fix by modifying the script, but I'm not sure if it's acceptable to modify someone else's source code just for the sake of packaging...

Offline

#11 2013-12-22 22:38:00

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Creating a PKGBUILD for sejda-console

Please edit your first post and use a title that reflects your issue (the package name would be good); this will show up in future searches and will be of much more help to people:
https://wiki.archlinux.org/index.php/Fo … ow_to_Post


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#12 2013-12-23 02:55:31

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: Creating a PKGBUILD for sejda-console

Don't you want to copy from srcdir to pkgdir rather than the other way around?

Also, if progandy's point applies to files, you should use install rather than cp. (But I'm not clear what the rationale for this is so I am not sure if it applies in this case or not.)

Last edited by cfr (2013-12-23 02:57:11)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#13 2013-12-23 05:39:42

mavant
Member
Registered: 2013-09-30
Posts: 11

Re: Creating a PKGBUILD for sejda-console

It is copying from srcdir to pkgdir: the -t flag specifies the target directory, and then the last argument is the source.

I am (obviously) not an expert, but what I could find about install vs cp indicated that install is very important when overwriting in-place system files or anything that might be currently in use, but essentially a personal choice when building packages and when using the -n (--no-clobber) flag. Unless I've misunderstood the man page for install, there's no way of calling it quite as succinctly as cp for this purpose.

Offline

#14 2013-12-24 03:08:20

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: Creating a PKGBUILD for sejda-console

mavant wrote:

It is copying from srcdir to pkgdir: the -t flag specifies the target directory, and then the last argument is the source.

Sorry. Missed the -t.

I am (obviously) not an expert, but what I could find about install vs cp indicated that install is very important when overwriting in-place system files or anything that might be currently in use, but essentially a personal choice when building packages and when using the -n (--no-clobber) flag. Unless I've misunderstood the man page for install, there's no way of calling it quite as succinctly as cp for this purpose.

As I say, I don't know the rationale for this. Perhaps progandy can comment?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#15 2013-12-24 03:32:53

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

Re: Creating a PKGBUILD for sejda-console

mavant, I have no input on the PKGBUILD, but I've looked in on this thread several times since it started and I wanted to complement the degree to which you've taken and used all the feedback you've recieved.  The first draft of the PKGBUILD had many issues, now it seems to be very well written and ready for the AUR (IMHO).


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

Offline

#16 2013-12-25 03:51:59

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: Creating a PKGBUILD for sejda-console

Trilby wrote:

mavant, I have no input on the PKGBUILD, but I've looked in on this thread several times since it started and I wanted to complement the degree to which you've taken and used all the feedback you've recieved.  The first draft of the PKGBUILD had many issues, now it seems to be very well written and ready for the AUR (IMHO).

I'd like to second this. I was rather blunt because I felt that you were getting feedback which suggested that if you just tweaked one or two things, all would be well, whereas I thought you needed to start from the basics of what a PKGBUILD is and is not supposed to do. Frankly, I was not sure whether you would see it that way and half-expected to get flamed as a result. I'm so glad that you responded by improving your package instead! wink


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#17 2013-12-25 04:30:22

mavant
Member
Registered: 2013-09-30
Posts: 11

Re: Creating a PKGBUILD for sejda-console

Thank you both. I am certainly glad to receive constructive criticism, particularly when I am pointed in entirely the wrong direction. But the positive reinforcement is nice too smile

Offline

#18 2013-12-25 14:40:11

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Creating a PKGBUILD for sejda-console

If I may suggest a small change, put quotes around $srcdir and $pkgdir. Otherwise there will be errors if the path to the build directory has spaces.

Since a lot of PKGBUILDs don't have that, I doubt many people build stuff in a path with spaces. Nonetheless, it's a good habit to quote variables, especially when they represent paths.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#19 2017-05-11 18:56:35

chandra
Member
Registered: 2017-05-11
Posts: 1

Re: Creating a PKGBUILD for sejda-console

mavant: I realize that this is quite late in the day, but did you by any chance post an AUR package for sejda-console?

Thanks.

Offline

#20 2017-05-11 20:16:38

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,865
Website

Re: Creating a PKGBUILD for sejda-console


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB