Solved use of git & porters handbook

Could someone be so nice to add to the porters handbook a list of , A relevant books, B relevant internet links, with additional explaining information, which is nice to have while reading the porters handbook ,or porting software ?
[E.g. i think of K&R , the C Programming Language]
 
Let's say i found a simple git repository which does not have at current a port or maintainer in freebsd.
But i can make it work in freebsd without even the need for patches.
Which are the steps i need to follow to become a maintainer of this simple software.
For instance i found i use git for the kernel or compiling ports.
But when i compile ports no git is used.
So there is a standard way of working in freebsd , how packages are build etc ...
It's a learning curve and there are some steps to overcome ... Which is normal.
So, first things first, i think it is a good idea if i learn something more about gnu build tools.
Because if i'm correct alot is in makefiles or make-scripts.
 

One of the FreeBSD higher ups had a great post about all the tools and time to do this and I can't remember who and I can't find the link but I'm going to spend some time looking for it.

EDIT: I thought it was Warner Losh, and it might have been, but I couldn't find it on his personal page.
 
Which are the steps i need to follow to become a maintainer of this simple software.
Make the port, set the MAINTAINER to your email address. Submit said port to BugZilla (preferably sign up with the same email account you used as the MAINTAINER). Wait. If you haven't heard from a committer in say 1 or 2 weeks, send a ping to the ports@ mailing list asking if a committer could have a look at it.

But when i compile ports no git is used.
That depends on the port itself, some ports are downloaded from GitHub for example. There are some special variables you need to set in the port's Makefile, those will take care of the download. You don't have to know the details, just how to use it.

So there is a standard way of working in freebsd , how packages are build etc ...
Yes, it starts with a port. No port, no package. If your port is good the packages will follow from that. Ports build packages.
 
Is it allowed to do a git clone in the fetch fase of a Makefile of a port ?
I.e.
Makefile:
Code:
PORTNAME=    alain
PORTVERSION=    1
CATEGORIES=    lang
MASTER_SITES=    Todo
MAINTAINER=    devosalain@ymail.com
COMMENT=    Todo
LICENSE=    BSD2CLAUSE
NO_ARCH=    YES
NO_BUILD=    YES
PLIST_FILES=    sbin/${PORTNAME}
fetch:
    echo "begin-fetch"
    git clone X Y                          <------------------------------------------- Clone in the work directory , seems not to work. Did i miss something ?
    echo "end-fetch"
build:
do-install:
    echo "do-install"
    ${INSTALL_SCRIPT} ${WRKSRC}/alain.sh \
    ${STAGEDIR}${PREFIX}/sbin/${PORTNAME}
.include <bsd.port.mk>
 
It seems to me (I could be wrong) that you are trying to fetch something from the Github. If that's the case, look up the USE_GITHUB in the Porters Handbook. Also, some distributed source from Github have tarball, some rely on on-the-fly operation, and finally for some you have use commit id. All are documented in the Porter Handbook.
 
I'm in the process of learning the freebsd way of things.
I ended up with a makefile which works but looks a bit ugly.
Code:
PORTNAME=    alain 
PORTVERSION=    1 
CATEGORIES=    lang 
MASTER_SITES=    Todo 
MAINTAINER=    devosalain@ymail.com 
COMMENT=    Todo 
LICENSE=    BSD2CLAUSE 
NO_ARCH=    YES 
PLIST_FILES=    sbin/${PORTNAME} 
fetch: 
    echo "begin-fetch" 
    /bin/rm -fR /usr/ports/lang/alain/work 
    /bin/rm -fR /usr/ports/lang/alain/work2 
    mkdir -p   /usr/ports/lang/alain/work2 
    cd    /usr/ports/lang/alain/work2 && rm -vfR helloworld 
    cd    /usr/ports/lang/alain/work2 && /usr/local/bin/git clone https://gitlab.com/alaindevos/helloworld 
    echo "end-fetch" 
build:   
    cd /usr/ports/lang/alain/work2/helloworld && cc helloworld.c 
 
do-install: 
    echo "do-install" 
    ${INSTALL_SCRIPT} ${WRKSRC}/alain.sh \ 
    ${STAGEDIR}${PREFIX}/sbin/${PORTNAME} 
.include <bsd.port.m
 
That worked. Here is the Makefile of a working "test" port /usr/ports/sysutils/olsblk
Code:
USE_GITLAB=    yes
GL_ACCOUNT=    alaindevos
GL_PROJECT=    olsblk
GL_COMMIT=99caec9fd6f1d012c3d816fddd679129ebb866be
PORTNAME=    olsblk
PORTVERSION=    1
CATEGORIES=    sysutils
MASTER_SITES=    BlaBla
MAINTAINER=    devosalain@ymail.com
COMMENT=    Lists information about block devices in the system, Vermadens script converted to Ocaml
LICENSE=    BSD2CLAUSE
NO_ARCH=    YES
NO_BUILD=    YES
BUILD_DEPENDS=    ocaml:lang/ocaml
PLIST_FILES=    sbin/${PORTNAME}
do-fetch:
    tar cvf /usr/ports/distfiles/olsblk-1.tar.gz /dev/null
build:
    mkdir -p /usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT}
    cd       /usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT} && ./compile
    cd       /usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT} && mv ./a.out olsblk
do-install:
    ${INSTALL_SCRIPT} \
             /usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT}/olsblk \
    ${STAGEDIR}${PREFIX}/sbin/${PORTNAME}
.include <bsd.port.mk>
 
Code:
NO_ARCH=    YES
The executable you're building doesn't depend on the architecture? It's not a script, it's being compiled. That makes it architecture dependent.

Code:
NO_BUILD=    YES
BUILD_DEPENDS=    ocaml:lang/ocaml
Doesn't add up. You told the port not to build anything (NO_BUILD), yet you have a build dependency on a compiler.

Code:
do-fetch:
    tar cvf /usr/ports/distfiles/olsblk-1.tar.gz /dev/null
Don't do this. The archive is automatically extracted in the work/ directory.
Code:
build:
    mkdir -p /usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT}
    cd       /usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT} && ./compile
    cd       /usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT} && mv ./a.out olsblk
Don't do this either.

Code:
do-install: ${INSTALL_SCRIPT} \ 
/usr/ports/sysutils/olsblk/work/olsblk-${GL_COMMIT}/olsblk \ 
${STAGEDIR}${PREFIX}/sbin/${PORTNAME}
Never refer to the ports tree directly. What if I have my ports tree in /some/where/else? Then this is going to fail.
 
with these modifications,
Code:
PORTNAME=   olsblk
PORTVERSION=    1
CATEGORIES= sysutils
MASTER_SITES="https://gitlab.com/alaindevos/empty/-/raw/main/olsblk-1.tar.gz"

MAINTAINER= devosalain@ymail.com
COMMENT=    Lists block devices cfr lsblk

LICENSE=    BSD2CLAUSE

BUILD_DEPENDS=  ocaml:lang/ocaml

USE_GITLAB= yes
GL_ACCOUNT= alaindevos
GL_PROJECT= olsblk
GL_COMMIT=99caec9fd6f1d012c3d816fddd679129ebb866be
PLIST_FILES=    sbin/${PORTNAME}
do-build:
    cd ${WRKSRC} && ./compile && ${MV} ./a.out olsblk
do-install:
    ${INSTALL_SCRIPT} ${WRKSRC}/olsblk \
    ${STAGEDIR}${PREFIX}/sbin/${PORTNAME}
.include <bsd.port.mk>
 
Much, much better. Remove MASTER_SITES though, the GL_* variables will automatically create a proper URL for Gitlab. And NO_ARCH should be removed too (the executable you're installing is architecture dependent). You do need to fix the order of the variables (PORTNAME, etc. need to be at the top). That order is standardized, ports-mgmt/portlint is useful for this.

And I think you can automate the build step too, but I would need to look that up. There might already be something in place specifically for OCAML. I always try to find a different port that has a similar build so I can use it as an example.
 
Seems to me what is needed is a port creation wizard that asks a bunch of questions and creates a makefile for a new port and allows you to interactively test it and refine it. As a stretch goal, it should also handle updating a port. It can also provide help/explanations at each step. Seems to me the amount of bookkeeping has grown over the years but basically it is not very complicated. You can't automate everything but this would reduce a lot of grunge work. May be I should propose this for the next GSOC!
 
Here portlint -A only gives:
make: don't know how to make check-license. Stop
FATAL: Makefile: Failed to validate port LICENSE 'BSD2CLAUSE' with ``make check-license''
1 fatal error and 0 warnings found.
 
Back
Top