First let's find a possible candidate to package... http://nyancat.dakko.us/ Ok, it's seem that it uses GitHub, let's go to the Git repository and look at the `Releases' page: https://github.com/klange/nyancat/releases Allright! Let's try to grab the source directly via url2pkg: $ cd pkgsrc/local/ $ mkdir nyancat $ cd nyancat $ url2pkg 'https://github.com/klange/nyancat/archive/1.5.1.tar.gz' Now we can see the following via our favourite ${EDITOR}: # $NetBSD$ GITHUB_PROJECT= nyancat DISTNAME= 1.5.1 CATEGORIES= local MASTER_SITES= ${MASTER_SITE_GITHUB:=klange/} DIST_SUBDIR= ${GITHUB_PROJECT} MAINTAINER= pkgsrc-users@NetBSD.org HOMEPAGE= https://github.com/klange/nyancat/ COMMENT= TODO: Short description of the package #LICENSE= # TODO: (see mk/license.mk) # url2pkg-marker (please do not remove this line.) .include "../../mk/bsd.pkg.mk" ...after we exit from the ${EDITOR} we can see: url2pkg> Running "make distinfo" ... => Bootstrap dependency digest>=20010302: found digest-20160304 WARNING: [license.mk] Every package should define a LICENSE. => Fetching nyancat-1.5.1.tar.gz Requesting https://github.com/klange/nyancat/archive/1.5.1.tar.gz Redirected to https://codeload.github.com/klange/nyancat/tar.gz/1.5.1 Requesting https://codeload.github.com/klange/nyancat/tar.gz/1.5.1 15124 141.59 KiB/s 15124 bytes retrieved in 00:00 (141.42 KiB/s) url2pkg> Running "make extract" ... => Bootstrap dependency digest>=20010302: found digest-20160304 WARNING: [license.mk] Every package should define a LICENSE. => Checksum SHA1 OK for nyancat-1.5.1.tar.gz => Checksum RMD160 OK for nyancat-1.5.1.tar.gz => Checksum SHA512 OK for nyancat-1.5.1.tar.gz ===> Installing dependencies for nyancat-1.5.1 => Tool dependency checkperms>=1.1: found checkperms-1.11nb1 ===> Overriding tools for nyancat-1.5.1 ===> Extracting for nyancat-1.5.1 tar: Global extended headers posix ustar archive. Extracting as plain files. Following files might be in the wrong directory or have wrong attributes. url2pkg> Adjusting the Makefile. Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done! Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-) ...and relooking at the Makefile we can now do some improvements and simplifications: # $NetBSD$ DISTNAME= nyancat-1.5.1 CATEGORIES= games MASTER_SITES= ${MASTER_SITE_GITHUB:=klange/} MAINTAINER= pkgsrc-users@NetBSD.org HOMEPAGE= https://github.com/klange/nyancat/ COMMENT= Nyancat in your terminal, rendered through ANSI escape sequences LICENSE= modified-bsd .include "../../mk/bsd.pkg.mk" ...and add a DESCRiption: $ echo "Nyancat in your terminal, rendered through ANSI escape sequences." > DESCR Let's try to build it!: $ make => Bootstrap dependency digest>=20010302: found digest-20160304 => Checksum SHA1 OK for nyancat-1.5.1.tar.gz => Checksum RMD160 OK for nyancat-1.5.1.tar.gz => Checksum SHA512 OK for nyancat-1.5.1.tar.gz ===> Installing dependencies for nyancat-1.5.1 => Tool dependency checkperms>=1.1: found checkperms-1.11nb1 ===> Overriding tools for nyancat-1.5.1 ===> Extracting for nyancat-1.5.1 tar: Global extended headers posix ustar archive. Extracting as plain files. Following files might be in the wrong directory or have wrong attributes. ===> Patching for nyancat-1.5.1 ===> Creating toolchain wrappers for nyancat-1.5.1 ===> Configuring for nyancat-1.5.1 => Checking for portability problems in extracted files ===> Building for nyancat-1.5.1 --- all --- cd src && /usr/bin/make all --- nyancat.o --- gcc -O2 -c nyancat.c --- nyancat --- gcc -O2 -Wl,-R/usr/pkg/lib nyancat.o -o nyancat => Unwrapping files-to-be-installed. Ok, it seems that everything properly built, let's try to install it!: $ make install => Bootstrap dependency digest>=20010302: found digest-20160304 ===> Installing for nyancat-1.5.1 => Generating pre-install file lists cd src && /usr/bin/make all install src/nyancat /usr/bin/nyancat install: /usr/bin/nyancat: open: Permission denied *** Error code 1 Stop. make: stopped in /tmp/pkgsrc/local/nyancat/work/nyancat-1.5.1 *** Error code 1 Stop. make[1]: stopped in /usr/pkgsrc/local/nyancat *** Error code 1 Stop. make: stopped in /usr/pkgsrc/local/nyancat Whoops! The package doesn't seem to properly support DESTDIR, probably something wrong is missing on the upstream Makefile, let's give it a look to it via pkgvi: $ pkgvi /tmp/pkgsrc/local/nyancat/work/nyancat-1.5.1/Makefile Indeed we can see: install: all install src/nyancat /usr/bin/${package} gzip -9 -c < nyancat.1 > /usr/share/man/man1/nyancat.1.gz Let's fix it (trying to make this change also upstreamable), we change the previous install target to: [...] install: all ${INSTALL_PROGRAM} src/nyancat ${DESTDIR}${PREFIX}/bin/${package} ${INSTALL_MAN} nyancat.1 ${DESTDIR}${MANDIR}/man1/nyancat.1 ...and on the top: [...] distdir = $(tarname)-$(version) PREFIX?= /usr MANDIR?= ${PREFIX}/share/man INSTALL_PROGRAM?= install -m 755 INSTALL_MAN?= install -m 644 [...] ...and when we exit we can read: pkgvi: File was modified. For a diff, type: pkgdiff "/tmp/pkgsrc/local/nyancat/work/nyancat-1.5.1/Makefile" We can now generate the patches via mkpatches: $ mkpatches $ mkpatches -c Add a little comment to the patch and generate the corresponding checksum for distinfo: $ make mps Ok, now we still need to make some little adjustements to Makefile: $ $EDITOR Makefile [...] LICENSE= modified-bsd MAKE_ENV+= INSTALL_PROGRAM=${INSTALL_PROGRAM:Q} MAKE_ENV+= INSTALL_MAN=${INSTALL_MAN:Q} MAKE_ENV+= MANDIR="${PREFIX}/${PKGMANDIR}" INSTALLATION_DIRS= bin ${PKGMANDIR}/man1 .include "../../mk/bsd.pkg.mk" Let's clean it and try again to (re)install it: $ make clean ===> Cleaning for nyancat-1.5.1 $ make install => Bootstrap dependency digest>=20010302: found digest-20160304 => Checksum SHA1 OK for nyancat-1.5.1.tar.gz => Checksum RMD160 OK for nyancat-1.5.1.tar.gz => Checksum SHA512 OK for nyancat-1.5.1.tar.gz ===> Installing dependencies for nyancat-1.5.1 => Tool dependency checkperms>=1.1: found checkperms-1.11nb1 ===> Overriding tools for nyancat-1.5.1 ===> Extracting for nyancat-1.5.1 tar: Global extended headers posix ustar archive. Extracting as plain files. Following files might be in the wrong directory or have wrong attributes. ===> Patching for nyancat-1.5.1 => Applying pkgsrc patches for nyancat-1.5.1 => Verifying /usr/pkgsrc/local/nyancat/patches/patch-Makefile => Applying pkgsrc patch /usr/pkgsrc/local/nyancat/patches/patch-Makefile Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |$NetBSD$ | |Honor DESTDIR and properly install the program and man page. | |--- Makefile.orig 2015-11-24 05:05:00.000000000 +0000 |+++ Makefile -------------------------- Patching file Makefile using Plan A... Hunk #1 succeeded at 3. Hunk #2 succeeded at 39. done ===> Creating toolchain wrappers for nyancat-1.5.1 ===> Configuring for nyancat-1.5.1 => Checking for portability problems in extracted files ===> Building for nyancat-1.5.1 --- all --- cd src && /usr/bin/make all --- nyancat.o --- gcc -O2 -c nyancat.c --- nyancat --- gcc -O2 -Wl,-R/usr/pkg/lib nyancat.o -o nyancat => Unwrapping files-to-be-installed. ===> Installing for nyancat-1.5.1 => Generating pre-install file lists => Creating installation directories cd src && /usr/bin/make all /usr/bin/install -c -s -o leot -g users -m 755 src/nyancat /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/bin/nyancat /usr/bin/install -c -o leot -g users -m 644 nyancat.1 /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/man/man1/nyancat.1 => Automatic manual page handling => Generating post-install file lists => Checking file-check results for nyancat-1.5.1 ERROR: ************************************************************ ERROR: The following files are in /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg but not in the PLIST: ERROR: /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/bin/nyancat ERROR: /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/man/man1/nyancat.1 *** Error code 1 Stop. make[1]: stopped in /usr/pkgsrc/local/nyancat *** Error code 1 Stop. make: stopped in /usr/pkgsrc/local/nyancat OK! We've got the above error because the PLIST is still not populated: $ make print-PLIST >PLIST $ cat PLIST @comment $NetBSD$ bin/nyancat man/man1/nyancat.1 Let's try again to install it (in order to not rebuild it again we can use the `install-clean' target): $ make install-clean $ make install => Bootstrap dependency digest>=20010302: found digest-20160304 ===> Installing for nyancat-1.5.1 => Generating pre-install file lists => Creating installation directories cd src && /usr/bin/make all /usr/bin/install -c -s -o leot -g users -m 755 src/nyancat /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/bin/nyancat /usr/bin/install -c -o leot -g users -m 644 nyancat.1 /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/man/man1/nyancat.1 => Automatic manual page handling => Generating post-install file lists => Checking file-check results for nyancat-1.5.1 => Checking for non-existent script interpreters in nyancat-1.5.1 => Checking file permissions in nyancat-1.5.1 => Checking for missing run-time search paths in nyancat-1.5.1 => Checking for work-directory references in nyancat-1.5.1 => Creating binary package /tmp/pkgsrc/local/nyancat/work/.packages/nyancat-1.5.1.tgz => Becoming ``root'' to make su-real-package-install (/usr/pkg/bin/sudo) ===> Installing binary package of nyancat-1.5.1 ===> Installing for nyancat-1.5.1 => Generating pre-install file lists => Creating installation directories cd src && /usr/bin/make all /usr/bin/install -c -s -o leot -g users -m 755 src/nyancat /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/bin/nyancat /usr/bin/install -c -o leot -g users -m 644 nyancat.1 /tmp/pkgsrc/local/nyancat/work/.destdir/usr/pkg/man/man1/nyancat.1 => Automatic manual page handling => Generating post-install file lists => Checking file-check results for nyancat-1.5.1 => Checking for non-existent script interpreters in nyancat-1.5.1 => Checking file permissions in nyancat-1.5.1 => Checking for missing run-time search paths in nyancat-1.5.1 => Checking for work-directory references in nyancat-1.5.1 => Creating binary package /tmp/pkgsrc/local/nyancat/work/.packages/nyancat-1.5.1.tgz => Becoming ``root'' to make su-real-package-install (/usr/pkg/bin/sudo) ===> Installing binary package of nyancat-1.5.1 => Dropping ``root'' privileges. Finally it seems to be correctly installed and we can try it: $ nyancat