Clint Pachl writes in with this walk through on how to assemble your own port...
A great example of a simple port that consists of a shell script (and a man page) is sysutils/mergemaster.
First, create the actual data structure (i.e. distribution files) for the package.
Then tar and compress the distribution into the distfiles directory, which
will bypass the remote fetch during port make.
$ mkdir -p ~/myscripts/myscripts-1.0
$ cd ~/myscripts/myscripts-1.0
$ mkdir -p bin share/myscripts
$ echo 'Docs for myscripts.' > share/myscripts/README
$ cat << EOF > bin/myscript1
> #!/bin/sh
> echo 'this is myscript1'
> EOF
$ cat << EOF > bin/myscript2
> #!/bin/sh
> echo 'this is myscript2'
> EOF
$ cd ..
$ tar czf /usr/ports/distfiles/myscripts-1.0.tar.gz myscripts-1.0
Make a directory under which you can maintain your local ports.
$ mkdir -p /usr/ports/mystuff/misc
$ cd /usr/ports/mystuff/misc
Make a package directory that will resemble your package name.
$ mkdir myscripts
$ cd myscripts
Create the port's Makefile using the port system template. When
finished, it should look similar to the following:
$ cp /usr/ports/infrastructure/templates/Makefile.template Makefile
$ vi Makefile
$ cat Makefile
# port/package comment, name, category, and maintainer.
COMMENT= extremely minimal porting example
DISTNAME= myscripts-1.0
CATEGORIES= misc
MAINTAINER= Clint Pachl <pachl@ecentryx.com>
# Mandatory licensing variables.
PERMIT_PACKAGE_CDROM= NO
PERMIT_PACKAGE_FTP= NO
PERMIT_DISTFILES_CDROM= NO
PERMIT_DISTFILES_FTP= NO
# Don't build or run regress tests; specify all architectures.
NO_BUILD= Yes
NO_REGRESS= Yes
PKG_ARCH= *
# Install myscripts under /usr/local/.
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/bin/* ${PREFIX}/bin/
${INSTALL_DATA_DIR} ${PREFIX}/share/myscripts/
${INSTALL_DATA} ${WRKSRC}/share/myscripts/* ${PREFIX}/share/myscripts/
# Include the BSD port system.
.include <bsd.port.mk>
Create the distinfo file, which contains hash digests of the distribution. At
this point, try to fake install the port to make sure everything works. The
fake target will fetch, verify checksum, extract, patch, configure, build, and
fake install the distfile under the working directory.
$ make makesum
$ make fake
The description and packing list files are prerequisites to creating a
package. The description file is a long description of the package, as opposed
to the short comment in the port's Makefile. The plist target generates a
default packing list derived from the fake install.
$ mkdir pkg
$ echo 'This is the myscripts package example.' > pkg/DESCR
$ make plist
Finally, create the myscripts package under /usr/ports/packages. To install
the package, run either make install or pkg_add(1). Test the install by verifying
that the scripts are installed in your PATH and are executable.
$ make package
$ make install
$ myscript1 && myscript2
$ pkg_info myscripts
$ sudo pkg_delete myscripts
For more info, check out ports(7); pay attention to the URLs and other man pages mentioned in the "SEE ALSO" section.
Thanks to Marc Espie and friends for a great porting/packaging system.
And as always, if you make a port of something that you think may be useful to other OpenBSD users, please test it on current and submit it to ports@.
Keep in mind that messy or broken ports are going to be easily discarded so take your time and get it right the first time.