Skip to content

Instantly share code, notes, and snippets.

@daviddpd
Last active May 27, 2022 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddpd/d91e0a6e852e5d11776f8e3f553a184a to your computer and use it in GitHub Desktop.
Save daviddpd/d91e0a6e852e5d11776f8e3f553a184a to your computer and use it in GitHub Desktop.
FreeBSD Creating a Custom Port Notes

FreeBSD Creating a Custom Port Notes

Symlink - example from perl

${LN} -sf perl ${STAGEDIR}${PREFIX}/bin/perl${PERL_VERSION}

Also add should be added to plist

bin/perl%%PERL_VERSION%%

A Skeleton / Example of a Meta Port

This is a meta-port - it installs no files, just depends on other ports/packages. In this case, installing this port/package will require/install : binutils, apache24, bash, beadm, and colordiff

# General Meta Package - 

PORTNAME=	generic-meta
PORTVERSION=	1.0.0
PORTREVISION=	1
CATEGORIES=	misc
MASTER_SITES=	# none
DISTFILES=	# none

MAINTAINER=	dpd@dpdtech.com
COMMENT=	Generic Meta-Port/Meta-Package

LICENSE=	BSD2CLAUSE

NO_ARCH=	yes
NO_BUILD=	yes
NO_INSTALL= yes
NO_TEST=    yes

RUN_DEPENDS=\
		binutils>=2.37_2,1:${PORTSDIR}/devel/binutils \
		apache24>=2.4.52:${PORTSDIR}/www/apache24 \
		bash>=5.1.16:${PORTSDIR}/shells/bash \
		beadm>=1.3.2:${PORTSDIR}/sysutils/beadm \
		colordiff>=1.0.20:${PORTSDIR}/textproc/colordiff

pre-build:
	${MKDIR} ${WRKDIR}/${PORTDIRNAME}-${PORTVERSION}

.include <bsd.port.mk>

RFC: Generate RUN_DEPENDS from installed system

RFC: There appears to be no good way to generate RUN_DEPENDS from and installed system ... or is there ? Seems like there should be a way built into pkgNG that allows to grab just the version ... but there doesn't seem to be

#!perl

use strict;
use warnings;

my $PKGS=`pkg info -o -a`;

foreach my $l (split (/\n/, $PKGS) ) {
	my ($pkg, $origin) = split(/\s+/, $l);
	my @v = split (/-/, $pkg);
# The Format :
#	binutils>=2.37_2,1:${PORTSDIR}/devel/binutils \
	my $version = $v[-1];
	$pkg =~ s/-${version}$//g;
	printf ("%s>=%s:\${PORTSDIR}/%s \\\n", $pkg, $v[-1], $origin);

}

${FILESDIR}

A few handy varibles ... that are not always obvious what they are

PORTSDIR=/usr/port
MASTERDIR=${PORTSDIR}/misc/myPortExample
FILESDIR=${MASTERDIR}/files
PATCHDIR=${MASTERDIR}/files

SHEBANG

More later on what the heck uses shebang does ... but a stub ...

NOTE: SHEBANG_FILES is relative to ${WRKSRC} or ${FILESDIR} ... not ${STAGEDIR}${PREFIX}

USES=       shebangfix
SHEBANG_FILES=  sys-scripts/facts.sh
PLIST_FILES=    bin/facts.sh

do-install:
	${INSTALL_SCRIPT} ${WRKSRC}/sys-scripts/facts.sh ${STAGEDIR}${PREFIX}/bin/facts.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment