Diff for /wikisrc/pkgsrc/intro_to_packaging.mdwn between versions 1.2 and 1.6

version 1.2, 2014/07/08 14:35:33 version 1.6, 2014/07/09 12:34:13
Line 13  listed below: Line 13  listed below:
 ## pkgsrc tree  ## pkgsrc tree
   
 You should have a copy of the pkgsrc tree sitting somewhere on your  You should have a copy of the pkgsrc tree sitting somewhere on your
 disk, already bootstrapped, see this [blog  disk, already bootstrapped.
 post](http://saveosx.org/pkgsrc-bootstrap/) on how to do this.  
   
 The tree contains a `Makefile`, a `README`, distfiles, packages,  The tree contains a `Makefile`, a `README`, distfiles, packages,
 category directories containing the ports, the bootstrap directory  category directories containing the ports, the bootstrap directory
 and some documentation.  and some documentation.
Line 92  long ago in pkgsrc-wip Line 90  long ago in pkgsrc-wip
   
 Makefile:  Makefile:
                   
 {% highlight make %}  [[!format make """
 # [[!paste id=rcsid]]  # [[!paste id=rcsid1]][[!paste id=rcsid2]]
   
 PKGNAME=      osxinfo-0.1  PKGNAME=      osxinfo-0.1
 CATEGORIES=   misc  CATEGORIES=   misc
Line 113  WRKSRC= ${WRKDIR}/osxinfo-${GHCOMMIT} Line 111  WRKSRC= ${WRKDIR}/osxinfo-${GHCOMMIT}
   
 .include "../../databases/sqlite3/buildlink3.mk"  .include "../../databases/sqlite3/buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"  .include "../../mk/bsd.pkg.mk"
 {% endhighlight %}  """]]
   
 DESCR:  DESCR:
                   
Line 123  DESCR: Line 121  DESCR:
   
 PLIST:  PLIST:
                   
         @comment [[!paste id=rcsid]]          @comment [[!paste id=rcsid1]][[!paste id=rcsid2]]
         bin/osxinfo          bin/osxinfo
   
 distinfo:  distinfo:
   
         [[!paste id=rcsid]]          [[!paste id=rcsid1]][[!paste id=rcsid2]]
   
         SHA1 (osxinfo/de74b8960f27844f7b264697d124411f81a1eab6.tar.gz) = 83a2838ad95ff73255bea7f496a8cc9aaa4e17ca          SHA1 (osxinfo/de74b8960f27844f7b264697d124411f81a1eab6.tar.gz) = 83a2838ad95ff73255bea7f496a8cc9aaa4e17ca
         RMD160 (osxinfo/de74b8960f27844f7b264697d124411f81a1eab6.tar.gz) = 9102eb2a938be38c4adf8cfbf781c04d0844d09a          RMD160 (osxinfo/de74b8960f27844f7b264697d124411f81a1eab6.tar.gz) = 9102eb2a938be38c4adf8cfbf781c04d0844d09a
Line 200  these targets, like Line 198  these targets, like
 The framework uses an `mk.conf` file, usually found in /etc. Here's  The framework uses an `mk.conf` file, usually found in /etc. Here's
 how mine looks:  how mine looks:
   
 {% highlight make %}  [[!format make """
 # Tue Oct 15 21:21:46 CEST 2013  # Tue Oct 15 21:21:46 CEST 2013
   
 .ifdef BSD_PKG_MK          # begin pkgsrc settings  .ifdef BSD_PKG_MK          # begin pkgsrc settings
Line 232  PKG_DEVELOPER=             yes Line 230  PKG_DEVELOPER=             yes
 SIGN_PACKAGES=             gpg  SIGN_PACKAGES=             gpg
 PKG_DEFAULT_OPTIONS+=      -pulseaudio -x264 -imlib2-amd64 -dconf  PKG_DEFAULT_OPTIONS+=      -pulseaudio -x264 -imlib2-amd64 -dconf
 .endif                     # end pkgsrc settings  .endif                     # end pkgsrc settings
 {% endhighlight %}  """]]
   
 - I use `DISTDIR`, `PACKAGES`, `WRKOBJDIR` to move distfiles,  - I use `DISTDIR`, `PACKAGES`, `WRKOBJDIR` to move distfiles,
   packages and source files somewhere else to keep my pkgsrc tree    packages and source files somewhere else to keep my pkgsrc tree
Line 269  PKG_DEFAULT_OPTIONS+=      -pulseaudio - Line 267  PKG_DEFAULT_OPTIONS+=      -pulseaudio -
   I disabled a few options so less ports would break, 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    doesn't build on Mac OS X for example, neither do x264, dconf
   
 Keep in mind that there are many other available options documented  Keep in mind that there are many other available options.
 in the official pkgsrc guide.  
   
   
 ## creating a simple port  ## creating a simple port
Line 316  on the program's homepage. Line 313  on the program's homepage.
 Here's how they look like at the moment:  Here's how they look like at the moment:
                   
 Makefile:  Makefile:
 {% highlight make %}  [[!format make """
 # [[!paste id=rcsid]]  # [[!paste id=rcsid1]][[!paste id=rcsid2]]
   
 DISTNAME=       2bwm-0.1  DISTNAME=       2bwm-0.1
 CATEGORIES=     wm  CATEGORIES=     wm
Line 329  COMMENT=        Fast floating WM written Line 326  COMMENT=        Fast floating WM written
 LICENSE=        isc  LICENSE=        isc
   
 .include "../../mk/bsd.pkg.mk"  .include "../../mk/bsd.pkg.mk"
 {% endhighlight %}  """]]
   
 distinfo:  distinfo:
   
                   
         [[!paste id=rcsid]]          [[!paste id=rcsid1]][[!paste id=rcsid2]]
   
         SHA1 (2bwm-0.1.tar.gz) = e83c862dc1d9aa198aae472eeca274e5d98df0ad          SHA1 (2bwm-0.1.tar.gz) = e83c862dc1d9aa198aae472eeca274e5d98df0ad
         RMD160 (2bwm-0.1.tar.gz) = d9a93a7d7ae7183f5921f9ad76abeb1401184ef9          RMD160 (2bwm-0.1.tar.gz) = d9a93a7d7ae7183f5921f9ad76abeb1401184ef9
Line 399  in our Makefile. Line 396  in our Makefile.
 Clean, build again, and add more dependencies until it passes the  Clean, build again, and add more dependencies until it passes the
 build stage. Here's how my Makefile ends up looking like:  build stage. Here's how my Makefile ends up looking like:
   
 {% highlight make %}  [[!format make """
 # [[!paste id=rcsid]]  # [[!paste id=rcsid1]][[!paste id=rcsid2]]
   
 DISTNAME=       2bwm-0.1  DISTNAME=       2bwm-0.1
 CATEGORIES=     wm  CATEGORIES=     wm
Line 416  LICENSE=        isc Line 413  LICENSE=        isc
 .include "../../x11/xcb-util-keysyms/buildlink3.mk"  .include "../../x11/xcb-util-keysyms/buildlink3.mk"
 .include "../../x11/xcb-util/buildlink3.mk"  .include "../../x11/xcb-util/buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"  .include "../../mk/bsd.pkg.mk"
 {% endhighlight %}  """]]
   
   
 #### install phase  #### install phase
Line 456  how 2bwm installs: Line 453  how 2bwm installs:
   
 From 2bwm's Makefile:  From 2bwm's Makefile:
   
 {% highlight make %}  [[!format make """
 install: $(TARGETS)  install: $(TARGETS)
         test -d $(DESTDIR)$(PREFIX)/bin || mkdir -p $(DESTDIR)$(PREFIX)/bin          test -d $(DESTDIR)$(PREFIX)/bin || mkdir -p $(DESTDIR)$(PREFIX)/bin
         install -pm 755 2bwm $(DESTDIR)$(PREFIX)/bin          install -pm 755 2bwm $(DESTDIR)$(PREFIX)/bin
Line 464  install: $(TARGETS) Line 461  install: $(TARGETS)
         test -d $(DESTDIR)$(MANPREFIX)/man1 || mkdir -p $(DESTDIR)$(MANPREFIX)/man1          test -d $(DESTDIR)$(MANPREFIX)/man1 || mkdir -p $(DESTDIR)$(MANPREFIX)/man1
         install -pm 644 2bwm.man $(DESTDIR)$(MANPREFIX)/man1/2bwm.1          install -pm 644 2bwm.man $(DESTDIR)$(MANPREFIX)/man1/2bwm.1
         install -pm 644 hidden.man $(DESTDIR)$(MANPREFIX)/man1/hidden.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  This looks fine since it installs in a `DESTDIR`/`PREFIX` but it sets
   
Line 539  you should get this new line: Line 536  you should get this new line:
                   
         containing:          containing:
   
                 @comment [[!paste id=rcsid]]                  @comment [[!paste id=rcsid1]][[!paste id=rcsid2]]
                 bin/2bwm                  bin/2bwm
                 bin/hidden                  bin/hidden
   
Line 554  You should be able to fix the prefix err Line 551  You should be able to fix the prefix err
 the patching explained above thanks to the sed substitution framework.  the patching explained above thanks to the sed substitution framework.
 Here's how it looks like in my port Makefile:  Here's how it looks like in my port Makefile:
   
 {% highlight make %}  [[!format make """
 SUBST_CLASSES+=         makefile  SUBST_CLASSES+=         makefile
 SUBST_STAGE.makefile=   pre-build  SUBST_STAGE.makefile=   pre-build
 SUBST_MESSAGE.makefile= Fixing makefile  SUBST_MESSAGE.makefile= Fixing makefile
 SUBST_FILES.makefile=   Makefile  SUBST_FILES.makefile=   Makefile
 SUBST_SED.makefile=     -e 's,/usr/local,${PREFIX},g'  SUBST_SED.makefile=     -e 's,/usr/local,${PREFIX},g'
 SUBST_SED.makefile+=    -e 's,share/man,${PKGMANDIR},g'  SUBST_SED.makefile+=    -e 's,share/man,${PKGMANDIR},g'
 {% endhighlight %}  """]]
   
 As you can see, you can do multiple commands on multiple files, it  As you can see, you can do multiple commands on multiple files, it
 is very useful for very small fixes like this.  is very useful for very small fixes like this.
Line 596  You can find the 2bwm port I submitted i Line 593  You can find the 2bwm port I submitted i
 ## pkgsrc and wip  ## pkgsrc and wip
   
 If you want to submit your port for others to use you can either  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  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.  
   
 pkgsrc-wip is hosted on  pkgsrc-wip is hosted on
 [sourceforge](https://sourceforge.net/projects/pkgsrc-wip/) and you  [sourceforge](https://sourceforge.net/projects/pkgsrc-wip/) and you
 can easily get cvs access to it if you create an account on there  can easily get cvs access to it if you create an account on there
 and send an email to NetBSD developer `@wiz` (Thomas Klausner)  and send an email to NetBSD developer `@wiz` (Thomas Klausner)
 asking nicely for commit access. I got access fairly quickly and  asking nicely for commit access.
 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.  
   
   
 ## the options framework  ## the options framework
Line 617  You can also send me an email or talk to Line 607  You can also send me an email or talk to
 You can create port options with the `options.mk` file, like for `wm/dwm`  You can create port options with the `options.mk` file, like for `wm/dwm`
   
                   
 {% highlight make %}  [[!format make """
 # [[!paste id=rcsid]]  # [[!paste id=rcsid1]][[!paste id=rcsid2]]
   
 PKG_OPTIONS_VAR=                        PKG_OPTIONS.dwm  PKG_OPTIONS_VAR=                        PKG_OPTIONS.dwm
 PKG_SUPPORTED_OPTIONS=  xinerama  PKG_SUPPORTED_OPTIONS=  xinerama
Line 642  SUBST_FILES.options=    config.mk Line 632  SUBST_FILES.options=    config.mk
 SUBST_SED.options+=     -e '/^XINERAMA/d'  SUBST_SED.options+=     -e '/^XINERAMA/d'
 .  include "../../x11/libX11/buildlink3.mk"  .  include "../../x11/libX11/buildlink3.mk"
 .endif  .endif
 {% endhighlight %}  """]]
   
 This file should be included in the Makefile:  This file should be included in the Makefile:
   
Line 680  packages available for testing. You will Line 670  packages available for testing. You will
 on the host system. I host my [packages](http://pkgsrc.saveosx.org/)  on the host system. I host my [packages](http://pkgsrc.saveosx.org/)
 on a FreeBSD server with a bootstrapped pkgsrc.  on a FreeBSD server with a bootstrapped pkgsrc.
   
 I use this `zsh` function to :  use this `zsh` function to :
   
 {% highlight bash %}  [[!format bash """
 add () {  add () {
         # upload the package to remote server          # 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 yrmt@saveosx.org:/usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/All/ 2> /dev/null
Line 695  add () { Line 685  add () {
         # pkgin update          # pkgin update
         sudo pkgin update          sudo pkgin update
 }  }
 {% endhighlight %}  """]]
   
 - upload a package  - upload a package
 - update the package summary, which is an archive containing  - update the package summary, which is an archive containing
Line 735  add () { Line 725  add () {
 And this shell alias to upload all my built packages, but I still  And this shell alias to upload all my built packages, but I still
 need to run `add()` mentionned above to update the pkg_summary  need to run `add()` mentionned above to update the pkg_summary
   
 {% highlight bash %}  [[!format bash """
 up='rsync -avhz --progress /pkgsrc/packages/ root@saveosx.org:/usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/'  up='rsync -avhz --progress /pkgsrc/packages/ root@saveosx.org:/usr/local/www/saveosx/packages/Darwin/2013Q4/x86_64/'
 {% endhighlight %}  """]]
   
 Then you should be able to set the url in repositories.conf to use  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  your packages with pkgin. You can also install them directly with
Line 748  course. Line 738  course.
   
 ## build all packages  ## build all packages
   
 Bulk building pkgsrc packages is a topic for another post, see  see jperkin's excellent blog
 jperkin's excellent blog  
 [posts](http://www.perkin.org.uk/posts/distributed-chrooted-pkgsrc-bulk-builds.html)  [posts](http://www.perkin.org.uk/posts/distributed-chrooted-pkgsrc-bulk-builds.html)
 about this.  about this.
   
Line 767  earlier like this: Line 756  earlier like this:
   
 pkgsrc supports fetching archives from specific git commits on  pkgsrc supports fetching archives from specific git commits on
 GitHub like this:  GitHub like this:
 {% highlight make %}  [[!format make """
 PKGNAME=           2bwm-0.1  PKGNAME=           2bwm-0.1
 CATEGORIES=        wm  CATEGORIES=        wm
 GHCOMMIT=          52a097ca644eb571b22a135951c945fcca57a25c  GHCOMMIT=          52a097ca644eb571b22a135951c945fcca57a25c
Line 775  DISTNAME=          ${GHCOMMIT} Line 764  DISTNAME=          ${GHCOMMIT}
 MASTER_SITES=      https://github.com/venam/2bwm/archive/  MASTER_SITES=      https://github.com/venam/2bwm/archive/
 DIST_SUBDIR=       2bwm  DIST_SUBDIR=       2bwm
 WRKSRC=            ${WRKDIR}/2bwm-${GHCOMMIT}  WRKSRC=            ${WRKDIR}/2bwm-${GHCOMMIT}
 {% endhighlight %}  """]]
   
 You can then easily update the git commit and the distinfo with it  You can then easily update the git commit and the distinfo with it
 to update the program.  to update the program.
Line 786  You can do all Makefile operations direc Line 775  You can do all Makefile operations direc
 like this:  like this:
   
   
 {% highlight make %}  [[!format make """
 post-extract:  post-extract:
         ${CHMOD} a-x ${WRKSRC}/elementary/apps/48/internet-mail.svg          ${CHMOD} a-x ${WRKSRC}/elementary/apps/48/internet-mail.svg
   
 do-install:  do-install:
         ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/share/icons          ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/share/icons
         cd ${WRKSRC} && pax -rw -pe . ${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  To install, but you can also build programs from the Makefile. This
 is what qt4-sqlite3 uses:  is what qt4-sqlite3 uses:
   
 {% highlight make %}  [[!format make """
 do-build:  do-build:
         cd ${WRKSRC}/src/tools/bootstrap && env ${MAKE_ENV} ${GMAKE}          cd ${WRKSRC}/src/tools/bootstrap && env ${MAKE_ENV} ${GMAKE}
         cd ${WRKSRC}/src/tools/moc && env ${MAKE_ENV} ${GMAKE}          cd ${WRKSRC}/src/tools/moc && env ${MAKE_ENV} ${GMAKE}
         cd ${WRKSRC}/src/plugins/sqldrivers/sqlite && env ${MAKE_ENV} ${GMAKE}          cd ${WRKSRC}/src/plugins/sqldrivers/sqlite && env ${MAKE_ENV} ${GMAKE}
 {% endhighlight %}  """]]
   
   
 You can install the following type of files:  You can install the following type of files:
Line 848  make installed from the pkgsrc bootstrap Line 837  make installed from the pkgsrc bootstrap
 - If you have a feeling a port is stuck in the building stage,  - If you have a feeling a port is stuck in the building stage,
   disable make jobs in your mk.conf    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=rcsid text="\$NetBSD$"]]  [[!cut id=rcsid1 text="$Net"]]
   [[!cut id=rcsid2 text="BSD$"]]
 [[!meta title="An introduction to packaging"]]  [[!meta title="An introduction to packaging"]]
 [[!meta author="Youri Mouton"]]  [[!meta author="Youri Mouton"]]

Removed from v.1.2  
changed lines
  Added in v.1.6


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb