Search code examples
bsdpkgsrc

url2pkg returns "/opt/pkg/bin/url2pkg must be run from a package directory (.../pkgsrc/category/package)"


I'm on mac, and I'm trying to create a new package for pkgsrc. Every time I run url2pkg I get the message:

/opt/pkg/bin/url2pkg must be run from a package directory (.../pkgsrc/category/package). at /opt/pkg/bin/url2pkg line 517.

where do I need to run this from? It's not super clear to me. Do I need to make a pkgsrc directory?

I've tried creating new directories in root and also from /opt/pkg and I get this error in both places.


Solution

  • To create a package in pkgsrc, you usually do this:

    cd /usr/pkgsrc   # or wherever your installation of pkgsrc is
    cd $some_category
    
    mkdir mynewpackage
    cd mynewpackage
    
    url2pkg https://example.org/releases/mynewpackage-1.27.tar.gz
    

    The reason that url2pkg needs to be run in exactly this directory is that it cannot know the category of the package in advance. It also doesn’t assume that the basename from the URL is the package to be created. And, since you will be editing the Makefile anyway, it is only convenient when you start working in that directory from the beginning.