I thought I'd start a new thread after @rvp encouraged me to give this a go.

rvp ueberzug is now in FreeBSD ports.

If you ever decide to add it to NetBSD, please use the FreeBSD patches to the python files instead of what I posted above. They're simpler and don't need a mounted /proc filesystem.

Mate, I may need this explained to me like a newbie. While I managed to patch it last time I'm still pretty much just following instructions here. One noteworthy change is that python-Xlib is no longer a dependency.

Anyway, I have gone through the steps in the link to Chapter 14: creating a new pkgsrc package from scratch and I think I'm getting there.

Makefile: UPDATED

# $NetBSD$

DISTNAME=       ueberzug-18.1.9
CATEGORIES=     local
MASTER_SITES=   ${MASTER_SITE_GITHUB:=seebye/}

MAINTAINER=     david.pfeiffer@pm.me
HOMEPAGE=       https://github.com/seebye/ueberzug
COMMENT=        Command line util to display images in the terminal
LICENSE=        gnu-gpl-v3

PYTHON_VERSIONS_INCOMPATIBLE=   27

DEPENDS+=       ${PYPKGPREFIX}-psutil>=5.8.0:../../sysutils/py-psutil
DEPENDS+=       ${PYPKGPREFIX}-Pillow>=8.2.0:../../graphics/py-Pillow
DEPENDS+=       ${PYPKGPREFIX}-docopt>=0.6.2:../../devel/py-docopt
DEPENDS+=       ${PYPKGPREFIX}-attrs>=18.2.0:../../devel/py-attrs

WRKSRC= ${WRKDIR}/ueberzug-18.1.9

.include "../../x11/libXext/buildlink3.mk"
.include "../../x11/libXres/buildlink3.mk"
.include "../../lang/python/egg.mk"
.include "../../mk/bsd.pkg.mk"

pkglint seems happy

$ pwd
/home/dave/pkgsrc/local/py-Ueberzug
$ pkglint -e
Looks fine.

It appears to build... and install

$ bmake clean
===> Cleaning for ueberzug-18.1.9
$ bmake CHECK_FILES=no install
=> Bootstrap dependency digest>=20010302: found digest-20190127
=> Checksum SHA1 OK for ueberzug/18.1.9.tar.gz
=> Checksum RMD160 OK for ueberzug/18.1.9.tar.gz
=> Checksum SHA512 OK for ueberzug/18.1.9.tar.gz
===> Installing dependencies for ueberzug-18.1.9
==========================================================================
The following variables will affect the build process of this package,
ueberzug-18.1.9.  Their current value is shown below:

        * PYTHON_VERSION_DEFAULT = 38

Based on these variables, the following variables have been set:

        * PYPACKAGE = python38

You may want to abort the process now with CTRL-C and change the value
of variables in the first group before continuing.  Be sure to run
`/usr/pkg/bin/bmake clean' after the changes.
==========================================================================
=> Tool dependency bsdtar-[0-9]*: found bsdtar-3.4.3
=> Tool dependency checkperms>=1.1: found checkperms-1.12
=> Build dependency x11-links>=1.33: found x11-links-1.33
=> Build dependency cwrappers>=20150314: found cwrappers-20180325
=> Full dependency py38-Pillow>=8.2.0: found py38-Pillow-8.2.0
=> Full dependency py38-docopt>=0.6.2: found py38-docopt-0.6.2
=> Full dependency py38-attrs>=18.2.0: found py38-attrs-19.3.0
=> Full dependency py38-setuptools-[0-9]*: found py38-setuptools-56.0.0
=> Full dependency python38>=3.8.0: found python38-3.8.10nb1
===> Checking for vulnerabilities in ueberzug-18.1.9
===> Overriding tools for ueberzug-18.1.9
===> Extracting for ueberzug-18.1.9
===> Patching for ueberzug-18.1.9
===> Creating toolchain wrappers for ueberzug-18.1.9
===> Configuring for ueberzug-18.1.9
=> Checking for portability problems in extracted files
===> Building for ueberzug-18.1.9
...
=> Checking for non-existent script interpreters in ueberzug-18.1.9
=> Checking file permissions in ueberzug-18.1.9
=> Checking for missing run-time search paths in ueberzug-18.1.9
=> Checking for work-directory references in ueberzug-18.1.9
=> Creating binary package /home/dave/pkgsrc/local/py-Ueberzug/work/.packages/ueberzug-18.1.9.tgz
===> Building binary package for ueberzug-18.1.9
=> Creating binary package /home/dave/pkgsrc/packages/All/ueberzug-18.1.9.tgz
===> Installing binary package of ueberzug-18.1.9
$
$
$ please bmake print-PLIST >PLIST
[please] password for dave:
$ please bmake deinstall
===> Deinstalling for ueberzug-18.1.9
Running /usr/pkg/sbin/pkg_delete -K /usr/pkg/pkgdb  ueberzug-18.1.9
$ please bmake install
=> Bootstrap dependency digest>=20010302: found digest-20190127
===> Installing binary package of ueberzug-18.1.9
$

Neat! But Now I need to add the patch.

  • rvp replied to this.
  • Jay likes this.
    pin changed the title to My first package attempt .

    pfr Now I need to add the patch.

    Ah... erm, truth be told, I don't know--unlike you I'm still a pkgsrc virgin. Punting to @pin

    One contribution I can make: the FreeBSD python patches will bring in an additional dependency: py38-psutil

      pfr I've noticed that the FreeBSD port has py-setuptools also.. Does this also need to be added or is it covered by that egg.mk?

      setuptools is redundant here, I think--it's used for standalone python pkg. mgmt. Somebody correct me.
      EDIT: correcting myself: setuptools is needed for building ueberzug; not needed afterwards (ie. for running it).

      pfr it's not so much adding the patches but finding the patches. Where are they?

      Follow the links marked SVNWeb or git in Description on the Freshports page--just like @pin did.

      • pfr replied to this.
      • pfr likes this.

        I need to give this another go. I was mid-semester during my principles of distributed computing class, and that was just time consuming so I didnt get to dedicate as much time playing around with pkgsrc. Definitely keep documenting your progress and what you learn! Ill be done with this session of classes soon and able to play again. So anything you can share, Ill definitely be looking at it!

        pfr Do these patches need tweaking for NetBSD or will they do as they are?

        You should be able to use the same patches if you use the same version as FreeBSD. A newer version might need different patches because the code has changed.

        • pin replied to this.

          rvp A newer version might need different patches because the code has changed.

          And this is the painfull part of maintaing patches 😉

          • rvp replied to this.
          • pfr likes this.

            pin Yah--Another headache is what I term "patrolling"--keeping an eye on the various websites/mailing-lists/whatever to see if new versions have dropped; then judging if the new versions merit a new package or should be skipped... Our friend will learn all this in due course.

            @pfr: if you get a taste for this, tell me. I have another thing lined up for you to package (I've done the NetBSD-related work already; just got to do the FreeBSD stuff, then send it upstream). It's something you've already requested... but I'll keep it as a surprise for the time being.

            it primarily matters that stuff in pkgsrc works, not that it's the freshest version, especially when it's a leaf package and not security critical.

            of course, this wouldn't matter if the freshest software always worked and didn't introduce incompatibilities and portability sins.

            Coolio, thanks everyone. I have been super busy lately so no progress on this. I did start this on the latest release v18.1.9 whereas the FreeBSD ports are still on v18.1.8.

            Obviously waiting for the package, along with the patches, to be updated on FreeBSD ports would make it a little easier.
            When I get time though, I will look at the patches in detail and see if the patches will need changes, if so hopefully only the line numbers. Probably wise that I actually understand what the patches do hey 😉

            • Jay likes this.

            pfr Use mkpatches from pkgtools/pkgdiff to regenerate the patch files from the patched sources. You're gonna need to learn to use it at some point if you're doing pkgsrc - I assure you it's much easier than how other package managers deal with patches 🙂

              pfr So I couldn't get it to work with the lates version

              Try this (a minor update was needed):

              diff -urN ueberzug-18.1.9.orig/Xshm/Xshm.c ueberzug-18.1.9/Xshm/Xshm.c
              --- ueberzug-18.1.9.orig/Xshm/Xshm.c	2021-01-09 11:39:14.000000000 +0000
              +++ ueberzug-18.1.9/Xshm/Xshm.c	2021-06-22 07:39:45.134536810 +0000
              @@ -67,9 +67,6 @@
               
                   if (self->segmentInfo.shmaddr != INVALID_SHM_ADDRESS) {
                       self->segmentInfo.readOnly = true;
              -        // Mark the shared memory segment for removal
              -        // It will be removed even if this program crashes
              -        shmctl(self->segmentInfo.shmid, IPC_RMID, 0);
                       return true;
                   }
               
              @@ -111,6 +108,7 @@
               Image_free_shared_memory(Image *self) {
                   if(self->segmentInfo.shmaddr != INVALID_SHM_ADDRESS) {
                       shmdt(self->segmentInfo.shmaddr);
              +        shmctl(self->segmentInfo.shmid, IPC_RMID, 0);
                       self->segmentInfo.shmaddr = INVALID_SHM_ADDRESS;
                   }
               }
              diff -urN ueberzug-18.1.9.orig/examples/fzfimg.sh ueberzug-18.1.9/examples/fzfimg.sh
              --- ueberzug-18.1.9.orig/examples/fzfimg.sh	2021-01-09 11:39:14.000000000 +0000
              +++ ueberzug-18.1.9/examples/fzfimg.sh	2021-06-22 07:39:45.135089990 +0000
              @@ -18,7 +18,7 @@
               readonly REDRAW_COMMAND="toggle-preview+toggle-preview"
               readonly REDRAW_KEY="µ"
               declare -r -x DEFAULT_PREVIEW_POSITION="right"
              -declare -r -x UEBERZUG_FIFO="$(mktemp --dry-run --suffix "fzf-$$-ueberzug")"
              +declare -r -x UEBERZUG_FIFO="$(T="$(mktemp -t fzf-$$-ueberzug)"; rm -f "$T"; echo "$T")"
               declare -r -x PREVIEW_ID="preview"
               
               
              diff -urN ueberzug-18.1.9.orig/ueberzug/query_windows.py ueberzug-18.1.9/ueberzug/query_windows.py
              --- ueberzug-18.1.9.orig/ueberzug/query_windows.py	2021-01-09 11:39:14.000000000 +0000
              +++ ueberzug-18.1.9/ueberzug/query_windows.py	2021-06-22 07:39:45.135911143 +0000
              @@ -2,6 +2,7 @@
               import signal
               import errno
               
              +import psutil
               
               def get_command(pid):
                   """Figures out the associated command name
              @@ -13,8 +14,7 @@
                   Returns:
                       str: the associated command name
                   """
              -    with open('/proc/{}/comm'.format(pid), 'r') as commfile:
              -        return '\n'.join(commfile.readlines())
              +    psutil.Process(pid=pid).name()
               
               
               def is_same_command(pid0, pid1):
              diff -urN ueberzug-18.1.9.orig/ueberzug/xutil.py ueberzug-18.1.9/ueberzug/xutil.py
              --- ueberzug-18.1.9.orig/ueberzug/xutil.py	2021-01-09 11:39:14.000000000 +0000
              +++ ueberzug-18.1.9/ueberzug/xutil.py	2021-06-22 07:40:05.091510744 +0000
              @@ -1,6 +1,7 @@
               """This module contains x11 utils"""
               import functools
               import asyncio
              +import psutil
               
               import Xlib
               import Xlib.display as Xdisplay
              @@ -144,9 +145,9 @@
                   the first process in the passed list which owns one.
                   """
                   for pid in pids:
              -        pty_slave_file = process.get_pty_slave(pid)
              -        if pty_slave_file:
              -            return pty_slave_file
              +        process = psutil.Process(pid=pid)
              +        if process is not None and process.terminal() is not None:
              +            return process.terminal()
               
                   return None

                nia Thanks. Yes, I did use mkpatches after manually editing each file. Now I have the patch files that were auto generated with mkpatches

                rvp Thanks buddy, this worked. I did as @nia suggested and used mkpatches after manually editing each file.

                I know I did this the hard way. How could I patch all these files at once using patch ?

                Thanks.

                Proof that it works:

                The next step I suppose it pushing it to pkgsrc/wip ?

                I'll try and package ytfzf as well 👍

                  pfr Nice! Minor nitpick...
                  On your Makefile,

                  # $NetBSD$
                  
                  GITHUB_PROJECT= ueberzug
                  GITHUB_TAG= refs/tags/18.1.9
                  DISTNAME=   18.1.9
                  PKGNAME=    ${GITHUB_PROJECT}-${DISTNAME}
                  CATEGORIES= local
                  MASTER_SITES=   ${MASTER_SITE_GITHUB:=seebye/}
                  DIST_SUBDIR=    ${GITHUB_PROJECT}# $NetBSD$

                  this can be simplified to the following,

                  # $NetBSD$
                  
                  DISTNAME=	ueberzug-18.1.9
                  CATEGORIES=	graphics
                  MASTER_SITES=	${MASTER_SITE_GITHUB:=seebye/}

                  Also, this might actually be more correct as a py-pkg.

                  • pfr replied to this.
                  • Jay likes this.