You are not logged in.

#1 2023-03-11 18:03:07

heidegger
Member
Registered: 2013-04-24
Posts: 87

JICMP - Please help with my very first PKGBUILD

This is the first step to accomplishing my goal as mentioned here: https://bbs.archlinux.org/viewtopic.php?id=283673.

The contents of the my PKGBUILD are as follows:

# Maintainer: Stephen Cenkner <scenkner at gmail>
pkgname=JICMP
pkgver=3.0.5
pkgrel=1
pkgdesc="A small library to allow the use of IPv4 ICMP (raw) packets in Java"
arch=('any')
url="https://github.com/OpenNMS/jicmp"
license=('GPL3')
depends=('git' 'jdk8-openjdk')
provides=(JICMP)
source=("https://github.com/OpenNMS/jicmp.git")
sha256sums=('8b22af6aec90ed0faf1634094d80612657dff1836225d83ef77b2f89f3ba1eeb')

build() {
  cd "$pkgname-$pkgver"
  git submodule update --init --recursive
  autoreconf -fvi
  ./configure
  make
}
 
package() {
  cd "$pkgname-$pkgver"

  make DESTDIR="$pkgdir/" install
}

I used updpkgsums to get the above checksum, however when I run makepkg, I get an error that it did not pass validity check.

Any help is appreciated.

I'm also confused as to referencing $pkgdir when it isn't defined at the top.

Thank you!

Offline

#2 2023-03-11 18:10:50

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: JICMP - Please help with my very first PKGBUILD

See https://wiki.archlinux.org/title/VCS_pa … CS_sources so

source=("https://github.com/OpenNMS/jicmp.git")

to

source=("git+https://github.com/OpenNMS/jicmp.git")

pkgname must be lower case.
If you are not intending the package to track upstream git then pin the checkout.
The source is in $pkgname not $pkgname-$pkgver so the cd commands will fail.

Last edited by loqs (2023-03-11 18:11:13)

Offline

#3 2023-03-11 18:30:08

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

Re: JICMP - Please help with my very first PKGBUILD

$pkgdir is defined by makepkg itself, so it is not specified in the PKGBUILD, just used (the same goes for $srcdir).

I suspect git is not a runtime dependency, is it?  It should likely be in makedepends, not depends.  And remove the "provides"; every package provides itself, that's a given.  Of course if you properly name the package with a -git suffix (which you either must add or instead use a pinned release as noted above), then you could keep the provides if you want.

EDIT: and the license is LGPL3 not GPL3.

EDIT 2: the submodule bits should be in prepare() not build() [and see comment below].  I believe autoreconf also belongs in prepare(), though I'm crap with autotools.

Last edited by Trilby (2023-03-11 18:37:05)


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

Offline

#4 2023-03-11 18:32:54

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: JICMP - Please help with my very first PKGBUILD

git submodule update --init --recursive

git submodules require a special tweak in a PKGBUILD, see https://wiki.archlinux.org/title/VCS_pa … submodules


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

#5 2023-03-11 19:33:56

heidegger
Member
Registered: 2013-04-24
Posts: 87

Re: JICMP - Please help with my very first PKGBUILD

Thank you all for your help!

I believe jdk8 is also required for the build only.
Once installed, JICMP is a dependency of openNMS which requires jdk11.

Considering this, should both be indicated as makedepends?
Should I include anything under depends?
I don't think JICMP is useful without any java so it may need depends=('java-environment-openjdk') or something similar.

Last edited by heidegger (2023-03-11 19:35:52)

Offline

#6 2023-03-11 20:42:40

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: JICMP - Please help with my very first PKGBUILD

If it is a dependency of a package needing Java 11 then I would suggest makedepends include jdk11-openjdk and depends include jre11-openjdk.
From a brief inspection of the Makefile maven is required at build time so should also be in makedepends.

Offline

#7 2023-03-11 20:51:07

heidegger
Member
Registered: 2013-04-24
Posts: 87

Re: JICMP - Please help with my very first PKGBUILD

OK, I've successfully built the package using the following:

# Maintainer: Stephen Cenkner <scenkner at gmail>
pkgname=jicmp
pkgver=3.0.5
pkgrel=1
pkgdesc="A small library to allow the use of IPv4 ICMP (raw) packets in Java"
arch=('any')
url="https://github.com/OpenNMS/jicmp"
license=('LGPL3')
makedepends=('git' 'jdk8-openjdk')
provides=('jicmp')
conflicts=('jicmp')
source=("jicmp::git+https://github.com/OpenNMS/jicmp.git")
sha256sums=('SKIP')

prepare() {
  cd "$pkgname"
  git submodule update --init --recursive
}

build() {
  cd "$pkgname"
  autoreconf -fvi
  ./configure
  make
}

package() {
  cd "$pkgname"
  make DESTDIR="$pkgdir/" install
}

When I change the package name to jicmp-git, I get errors from cd as it's trying to change into the jicmp-git directory per the $pkgname, but the folder being created is dropping the -git.

I'm not sure why.

Offline

#8 2023-03-11 20:57:10

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: JICMP - Please help with my very first PKGBUILD

heidegger wrote:

When I change the package name to jicmp-git, I get errors from cd as it's trying to change into the jicmp-git directory per the $pkgname, but the folder being created is dropping the -git.

source=("$pkgname::git+https://github.com/OpenNMS/jicmp.git")

Offline

#9 2023-03-11 21:00:43

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

Re: JICMP - Please help with my very first PKGBUILD

Or just cd to jicmp instead of using the variable. It really doesn't do anything for you and there's no reason to rename the source dir.

I'm seeing a lot of C in the upstream repo, are you sure this is arch=('any')? If there are any architecture-specific binaries, it can't be.

You didn't fix the submodule handling.

Last edited by Scimmia (2023-03-11 21:03:34)

Offline

#10 2023-03-11 21:00:59

heidegger
Member
Registered: 2013-04-24
Posts: 87

Re: JICMP - Please help with my very first PKGBUILD

loqs wrote:

If it is a dependency of a package needing Java 11 then I would suggest makedepends include jdk11-openjdk and depends include jre11-openjdk.
From a brief inspection of the Makefile maven is required at build time so should also be in makedepends.

JICMP uses some deprecated code (no backwards compatibility) so it must be built against jdk8.
However, once it's built openNMS requires jdk11, so it's really only a build time dependency. (I think.)

Eventually I hope to put together a PKGBUILD for openNMS, and I would plan to include the jdk11 dependency there.

I'll look into maven as a dependency.

Thank you!

Offline

#11 2023-03-11 21:04:14

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: JICMP - Please help with my very first PKGBUILD

arch=('any')

The package includes the architecture specific libjicmp.so

  ./configure

missing --prefix=/usr so the default prefix /usr/local is used.

As a git package it should have a pkgver function.
Edit:
I checked building in a clean chroot without maven.  It was not used,  must not be being called by the default make target.
Edit2:

# Maintainer: Stephen Cenkner <scenkner at gmail>
pkgname=jicmp-git
pkgver=jicmp.3.0.4.1.r5.g8af53d1
pkgrel=1
pkgdesc="A small library to allow the use of IPv4 ICMP (raw) packets in Java"
arch=('x86_64')
url="https://github.com/OpenNMS/jicmp"
license=('LGPL3')
makedepends=('git' 'jdk8-openjdk')
provides=('jicmp')
conflicts=('jicmp')
source=(git+https://github.com/OpenNMS/jicmp.git
        git+https://github.com/OpenNMS/autotools.git)
sha256sums=('SKIP'
            'SKIP')

prepare() {
  cd "${pkgname%%-git}"
  git submodule init
  git config submodule.libs/m4.url "$srcdir/autotools"
  git -c protocol.file.allow=always submodule update
  autoreconf -fvi
}

pkgver() {
  cd "${pkgname%%-git}"
  git describe --long --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd "${pkgname%%-git}"
  ./configure --prefix=/usr
  make
}

package() {
  cd "${pkgname%%-git}"
  make DESTDIR="$pkgdir/" install
}

Last edited by loqs (2023-03-11 21:31:56)

Offline

#12 2023-03-11 21:34:51

heidegger
Member
Registered: 2013-04-24
Posts: 87

Re: JICMP - Please help with my very first PKGBUILD

Happy I made it this far!

[camus@daftpunk AUR_jicmp]$ sudo pacman -Qi jicmp
Name            : jicmp-git
Version         : 3.0.5-1
Description     : A small library to allow the use of IPv4 ICMP (raw) packets in Java
Architecture    : x86_64
URL             : https://github.com/OpenNMS/jicmp
Licenses        : LGPL3
Groups          : None
Provides        : jicmp
Depends On      : None
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : jicmp
Replaces        : None
Installed Size  : 44.96 KiB
Packager        : Unknown Packager
Build Date      : Sat 11 Mar 2023 01:22:34 PM PST
Install Date    : Sat 11 Mar 2023 01:24:57 PM PST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : None
# Maintainer: Stephen Cenkner <scenkner at gmail>
pkgname=jicmp-git
pkgver=3.0.5
pkgrel=1
pkgdesc="A small library to allow the use of IPv4 ICMP (raw) packets in Java"
arch=('x86_64')
url="https://github.com/OpenNMS/jicmp"
license=('LGPL3')
depends=()
makedepends=('git' 'jdk8-openjdk')
provides=('jicmp')
conflicts=('jicmp')
source=("jicmp::git+https://github.com/OpenNMS/jicmp.git")
sha256sums=('SKIP')

prepare() {
  cd "jicmp"
  git submodule update --init --recursive
}

build() {
  cd "jicmp"
  autoreconf -fvi
  ./configure --prefix=/usr
  make
}

package() {
  cd "jicmp"
  make DESTDIR="$pkgdir/" install
}

To Do:
Fix the submodule handling.
Include the pkgver function.

I appreciate any more notes you may have!
Stepping away for a while.

Offline

#13 2023-03-11 21:50:51

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: JICMP - Please help with my very first PKGBUILD

pkgver function and possibly changing how you handle the submodule see my edit2 to post #11
In the todo list.
If I understand correctly java 11 compatibility is broken by javah being dropped in java 10+,  the replacement being javac -h which is available from java 8 but not supported by OpenNMS.

Last edited by loqs (2023-03-11 21:51:37)

Offline

#14 2023-04-02 18:03:10

heidegger
Member
Registered: 2013-04-24
Posts: 87

Re: JICMP - Please help with my very first PKGBUILD

Loqs, I think you've got the right idea regarding javah & javac -h.

I'm moving forward with loqs' corrections to the PKGBUILD, but have a few questions.
Can someone confirm that when makepkg runs, it uses the pkgver() function to modify the pkgver= line within the header and rewrite the PKGBUILD file in place?
How was it determined that arch needed to be 'x86_64'? Is C always architecture specific? Are there other clues to look for?
Honestly, I don't yet understand how loqs arrived at the correct submodule handling, but am moving forward with that code.
I was able to use loqs jicmp PKGBUILD as a template to also build the jicmp6 PKGBUILD and both are now installed using pacman.

I would like to move on to finally creating a PKGBUILD to install opennms, however I haven't found a good resource for creating a PKGBUILD which utilizes systemd. Does anyone have some suggested reading?

Offline

#15 2023-04-02 18:12:27

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

Re: JICMP - Please help with my very first PKGBUILD

heidegger wrote:

Can someone confirm that when makepkg runs, it uses the pkgver() function to modify the pkgver= line within the header and rewrite the PKGBUILD file in place?

https://wiki.archlinux.org/title/VCS_pa … )_function

heidegger wrote:

Is C always architecture specific? Are there other clues to look for?

https://wiki.archlinux.org/title/PKGBUILD#arch

heidegger wrote:

I would like to move on to finally creating a PKGBUILD to install opennms, however I haven't found a good resource for creating a PKGBUILD which utilizes systemd.

PKGBUILDs don't "utilize systemd" - what does that even mean?  Packaged software can include service files - and there are countless examples of PKGBUILD for such software (hell, grab any one at random now and your odds are good it includes a service file for the software).

heidegger wrote:

Does anyone have some suggested reading?

Given that these questions would have all been answered by looking at the wiki, I'd suggest reading the wiki.

Last edited by Trilby (2023-04-02 18:14:13)


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

Offline

#16 2023-04-02 18:19:28

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

Re: JICMP - Please help with my very first PKGBUILD

heidegger wrote:

Are there [architecture-specificity] clues to look for?

Generally any use of ./configure, make, make install would imply compiled code.  This may not be quite 100% a perfect test as a Makefile could be provided for scripts - but I highly doubt any would use a configure script.  You can also just check the content of the package for any binaries:

find pkg -type f -executable -exec file '{}' \+ | grep ELF

Or just use namcap, as this is one of many checks it will do for you.

EDIT: sorry for the double post - I meant to edit my last post to add this, but ended up quoting myself instead.

Last edited by Trilby (2023-04-02 18:20:29)


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

Offline

#17 2023-04-02 18:39:57

heidegger
Member
Registered: 2013-04-24
Posts: 87

Re: JICMP - Please help with my very first PKGBUILD

Thank you Trilby!

Offline

Board footer

Powered by FluxBB