--- wikisrc/pkgsrc/intro_to_packaging.mdwn 2014/07/08 14:44:38 1.3 +++ wikisrc/pkgsrc/intro_to_packaging.mdwn 2016/02/14 15:40:03 1.9 @@ -13,9 +13,7 @@ listed below: ## pkgsrc tree You should have a copy of the pkgsrc tree sitting somewhere on your -disk, already bootstrapped, see this [blog -post](http://saveosx.org/pkgsrc-bootstrap/) on how to do this. - +disk, already bootstrapped. The tree contains a `Makefile`, a `README`, distfiles, packages, category directories containing the ports, the bootstrap directory and some documentation. @@ -92,7 +90,7 @@ long ago in pkgsrc-wip Makefile: -{% highlight make %} +[[!format make """ # [[!paste id=rcsid1]][[!paste id=rcsid2]] PKGNAME= osxinfo-0.1 @@ -113,12 +111,11 @@ WRKSRC= ${WRKDIR}/osxinfo-${GHCOMMIT} .include "../../databases/sqlite3/buildlink3.mk" .include "../../mk/bsd.pkg.mk" -{% endhighlight %} +"""]] DESCR: - Small and fast Mac OS X info program written in C - by Youri Mouton. + Small and fast Mac OS X info program written in C. PLIST: @@ -200,7 +197,7 @@ these targets, like The framework uses an `mk.conf` file, usually found in /etc. Here's how mine looks: -{% highlight make %} +[[!format make """ # Tue Oct 15 21:21:46 CEST 2013 .ifdef BSD_PKG_MK # begin pkgsrc settings @@ -232,7 +229,7 @@ PKG_DEVELOPER= yes SIGN_PACKAGES= gpg PKG_DEFAULT_OPTIONS+= -pulseaudio -x264 -imlib2-amd64 -dconf .endif # end pkgsrc settings -{% endhighlight %} +"""]] - I use `DISTDIR`, `PACKAGES`, `WRKOBJDIR` to move distfiles, packages and source files somewhere else to keep my pkgsrc tree @@ -269,8 +266,7 @@ PKG_DEFAULT_OPTIONS+= -pulseaudio - I disabled a few options so less ports would break, pulseaudio doesn't build on Mac OS X for example, neither do x264, dconf -Keep in mind that there are many other available options documented -in the official pkgsrc guide. +Keep in mind that there are many other available options. ## creating a simple port @@ -316,7 +312,7 @@ on the program's homepage. Here's how they look like at the moment: Makefile: -{% highlight make %} +[[!format make """ # [[!paste id=rcsid1]][[!paste id=rcsid2]] DISTNAME= 2bwm-0.1 @@ -329,7 +325,7 @@ COMMENT= Fast floating WM written LICENSE= isc .include "../../mk/bsd.pkg.mk" -{% endhighlight %} +"""]] distinfo: @@ -399,7 +395,7 @@ in our Makefile. Clean, build again, and add more dependencies until it passes the build stage. Here's how my Makefile ends up looking like: -{% highlight make %} +[[!format make """ # [[!paste id=rcsid1]][[!paste id=rcsid2]] DISTNAME= 2bwm-0.1 @@ -416,7 +412,7 @@ LICENSE= isc .include "../../x11/xcb-util-keysyms/buildlink3.mk" .include "../../x11/xcb-util/buildlink3.mk" .include "../../mk/bsd.pkg.mk" -{% endhighlight %} +"""]] #### install phase @@ -456,7 +452,7 @@ how 2bwm installs: From 2bwm's Makefile: -{% highlight make %} +[[!format make """ install: $(TARGETS) test -d $(DESTDIR)$(PREFIX)/bin || mkdir -p $(DESTDIR)$(PREFIX)/bin install -pm 755 2bwm $(DESTDIR)$(PREFIX)/bin @@ -464,7 +460,7 @@ install: $(TARGETS) test -d $(DESTDIR)$(MANPREFIX)/man1 || mkdir -p $(DESTDIR)$(MANPREFIX)/man1 install -pm 644 2bwm.man $(DESTDIR)$(MANPREFIX)/man1/2bwm.1 install -pm 644 hidden.man $(DESTDIR)$(MANPREFIX)/man1/hidden.1 -{% endhighlight %} +"""]] This looks fine since it installs in a `DESTDIR`/`PREFIX` but it sets @@ -554,14 +550,14 @@ You should be able to fix the prefix err the patching explained above thanks to the sed substitution framework. Here's how it looks like in my port Makefile: -{% highlight make %} +[[!format make """ SUBST_CLASSES+= makefile SUBST_STAGE.makefile= pre-build SUBST_MESSAGE.makefile= Fixing makefile SUBST_FILES.makefile= Makefile SUBST_SED.makefile= -e 's,/usr/local,${PREFIX},g' SUBST_SED.makefile+= -e 's,share/man,${PKGMANDIR},g' -{% endhighlight %} +"""]] As you can see, you can do multiple commands on multiple files, it is very useful for very small fixes like this. @@ -596,20 +592,13 @@ You can find the 2bwm port I submitted i ## pkgsrc and wip If you want to submit your port for others to use you can either -subscribe to pkgsrc-wip or ask a NetBSD developer to add it for you -which can be tough. Even though there are many IRC channels in which -you can find nice developers, you will have to take the time to get -to know them. The easiest way for beginners is to submit to pkgsrc-wip -so other people can review and test it first. +subscribe to pkgsrc-wip or ask a NetBSD developer to add it for you. pkgsrc-wip is hosted on [sourceforge](https://sourceforge.net/projects/pkgsrc-wip/) and you can easily get cvs access to it if you create an account on there and send an email to NetBSD developer `@wiz` (Thomas Klausner) -asking nicely for commit access. I got access fairly quickly and -he even fixed a port to show me how to do it properly. - -You can also send me an email or talk to me on IRC so I can submit it for you. +asking nicely for commit access. ## the options framework @@ -617,7 +606,7 @@ You can also send me an email or talk to You can create port options with the `options.mk` file, like for `wm/dwm` -{% highlight make %} +[[!format make """ # [[!paste id=rcsid1]][[!paste id=rcsid2]] PKG_OPTIONS_VAR= PKG_OPTIONS.dwm @@ -642,7 +631,7 @@ SUBST_FILES.options= config.mk SUBST_SED.options+= -e '/^XINERAMA/d' . include "../../x11/libX11/buildlink3.mk" .endif -{% endhighlight %} +"""]] This file should be included in the Makefile: @@ -680,22 +669,22 @@ packages available for testing. You will on the host system. I host my [packages](http://pkgsrc.saveosx.org/) on a FreeBSD server with a bootstrapped pkgsrc. -I use this `zsh` function to : +use this shell function to : -{% highlight bash %} +[[!format sh """ add () { # upload the package to remote server - scp $1 yrmt@saveosx.org:/usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/All/ 2> /dev/null + scp $1 youri@saveosx.org:/usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/All/ 2> /dev/null # update the package summary - ssh yrmt@saveosx.org 'cd /usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/All/; + ssh youri@saveosx.org 'cd /usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/All/; rm pkg_summary.gz; /usr/pkg/sbin/pkg_info -X *.tgz | gzip -9 > pkg_summary.gz' # pkgin update sudo pkgin update } -{% endhighlight %} +"""]] - upload a package - update the package summary, which is an archive containing @@ -722,8 +711,7 @@ add () { REQUIRES=/usr/pkg/lib/libsqlite3.0.dylib FILE_NAME=osxinfo-0.1.tgz FILE_SIZE=9710 - DESCRIPTION=Small and fast Mac OS X info program written in C - DESCRIPTION=by Youri Mouton. + DESCRIPTION=Small and fast Mac OS X info program written in C. DESCRIPTION= DESCRIPTION=Homepage: DESCRIPTION=http://github.com/yrmt/osxinfo @@ -735,9 +723,9 @@ add () { And this shell alias to upload all my built packages, but I still need to run `add()` mentionned above to update the pkg_summary -{% highlight bash %} -up='rsync -avhz --progress /pkgsrc/packages/ root@saveosx.org:/usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/' -{% endhighlight %} +[[!format sh """ +up='rsync -avhz --progress /pkgsrc/packages/ youri@saveosx.org:/usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/' +"""]] Then you should be able to set the url in repositories.conf to use your packages with pkgin. You can also install them directly with @@ -748,8 +736,7 @@ course. ## build all packages -Bulk building pkgsrc packages is a topic for another post, see -jperkin's excellent blog +see jperkin's excellent blog [posts](http://www.perkin.org.uk/posts/distributed-chrooted-pkgsrc-bulk-builds.html) about this. @@ -767,7 +754,7 @@ earlier like this: pkgsrc supports fetching archives from specific git commits on GitHub like this: -{% highlight make %} +[[!format make """ PKGNAME= 2bwm-0.1 CATEGORIES= wm GHCOMMIT= 52a097ca644eb571b22a135951c945fcca57a25c @@ -775,7 +762,7 @@ DISTNAME= ${GHCOMMIT} MASTER_SITES= https://github.com/venam/2bwm/archive/ DIST_SUBDIR= 2bwm WRKSRC= ${WRKDIR}/2bwm-${GHCOMMIT} -{% endhighlight %} +"""]] You can then easily update the git commit and the distinfo with it to update the program. @@ -786,24 +773,24 @@ You can do all Makefile operations direc like this: -{% highlight make %} +[[!format make """ post-extract: ${CHMOD} a-x ${WRKSRC}/elementary/apps/48/internet-mail.svg do-install: ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/share/icons cd ${WRKSRC} && pax -rw -pe . ${DESTDIR}${PREFIX}/share/icons/ -{% endhighlight %} +"""]] To install, but you can also build programs from the Makefile. This is what qt4-sqlite3 uses: -{% highlight make %} +[[!format make """ do-build: cd ${WRKSRC}/src/tools/bootstrap && env ${MAKE_ENV} ${GMAKE} cd ${WRKSRC}/src/tools/moc && env ${MAKE_ENV} ${GMAKE} cd ${WRKSRC}/src/plugins/sqldrivers/sqlite && env ${MAKE_ENV} ${GMAKE} -{% endhighlight %} +"""]] You can install the following type of files: @@ -848,21 +835,6 @@ make installed from the pkgsrc bootstrap - If you have a feeling a port is stuck in the building stage, disable make jobs in your mk.conf -- Please contribute here :) - - -## links -- [Jonathan Perkin's excellent blog](http://www.perkin.org.uk/) -- [NetBSD's very extensive pkgsrc guide](http://www.netbsd.org/docs/pkgsrc/) -- [NetBSD's pkgsrc wiki](http://wiki.netbsd.org/pkgsrc/) -- Other blog posts here :) - -## where to find me - -- yrmt@edgebsd.org -- irc.oftc.net - - `#saveosx` [[!cut id=rcsid1 text="$Net"]] [[!cut id=rcsid2 text="BSD$"]]