Difference between revisions of "PBI Module Builder Guide/9.2"

From PC-BSD Wiki
Jump to: navigation, search
(Testing the PBI)
(29 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== PBI Module Builder Guide ==
+
<noinclude>{{NavHeader|back=Test PBIs|forward=Purchase PC-BSD® Swag|custompagename=Create PBIs}}</noinclude>
  
This guide is intended to help explain how modify and create new modules for building PBI files via the PBI Builder Software.
+
PC-BSD® provides a unique file format known as a PBI (push button installer). PBI files end with the ''.pbi'' extension and are self-contained installation programs. This means that even novice users can safely install and uninstall PBIs without inadvertently overwriting or deleting files needed by the operating system or other applications.
  
=== Getting a Module ===
+
A PBI file includes all the runtime and library dependencies required by the application. This means that a PBI is a large file, but this does not necessarily mean that the installed PBI will be that large. During installation, the PBI system compares the currently installed libraries and files with the ones contained within the PBI file and only installs the ones that are not already installed on the system. A hash database is used to eliminate dependency problems while allowing the computer to share libraries between different programs.
  
When starting the process of creating a [http://www.rushessay.com custom essay] and new module for the PBI Builder, it is often easiest to begin by downloading an existing module from SVN, and modifying it to suit your programs needs, or by downloading a template and adapting it.
+
Once a PBI is created, it can be installed using the graphical [[Using AppCafe® | AppCafe®]] utility or from the command line using [[PBI Manager]].
  
Modules currently in the PC-BSD Subversion repo can be browsed via the [http://trac.pcbsd.org/browser/pbibuild/modules web]
+
In order to create a PBI, the software must already be ported to FreeBSD. The easiest way to confirm whether or not a FreeBSD port exists is to search for the software at {{citelink|url=http://www.freshports.org|txt=FreshPorts.org}}. If a port does not exist, you can issue a port request at the PC-BSD® Port Requests forum using {{citelink|url=http://forums.pcbsd.org/showthread.php?t=13743|txt=these instructions}}. Alternately, if you have ported software before, the {{citelink|fbsdph||txt=Porters Handbook}} contains detailed instructions for porting software to FreeBSD.
  
To download a specific module, use the following commands, replacing "firefox" with the specific module you intend to checkout.
+
Creating a PBI from an existing FreeBSD port is a mostly automated process that does not require development skills. Some ports are effortless to convert while more complex ports may require some thought and simple scripting. Two utilities are available for converting a FreeBSD port into a PBI:
 +
# '''EasyPBI:''' provides a graphical interface and is available in Control Panel. See the [[Using EasyPBI | EasyPBI ]] section of the Handbook for instructions on how to use this utility.<br>
 +
# '''pbi_makeport:''' provides a command line utility.
  
# cd /pbi-build/modules
+
This section explains the components of a PBI module, demonstrates how to use the '''pbi_makeport''' utility, and provides some troubleshooting tips.
# svn co svn://svn.pcbsd.org/pbibuild/modules/webbrowsers/firefox webbrowsers/firefox
+
  
If you wish to start with a blank module template, you may download by using these commands:
+
'''NOTE:''' before creating a PBI, check to see if one exists using the instructions in [[Submit PBI Requests]]. If you decide that you prefer to request a PBI that you need rather than to create one, that page also contains instructions for submitting a PBI request.
  
# cd /pbi-build/modules
+
=== PBI Module Components ===
# fetch http://www.pcbsd.org/files/templates/module-template.tgz
+
# tar xvzf module-template.tgz
+
  
=== Module Structure ===
+
This section describes the various components that comprise a PBI module. A PBI module is simply a collection of files which controls the contents of the PBI.
  
A proper module will contain several files and directories:
+
When creating a PBI module, create a directory on your computer to hold the module's components. For example, if you are creating a PBI module for firefox, create the directory as the superuser using this command:
  
'''Required files / directories'''
+
{{txtbox|box=<br>'''mkdir -p /usr/local/my_pbis/www/firefox'''<br><br>}}
  
{|
+
As you create the subdirectories and files needed by the PBI module, save them to that directory. This directory is referred to as ''%%PBI_APPDIR%%''. The rest of this section assumes that you are the superuser.
| '''pbi.conf'''  
+
 
| -
+
==== LICENSE File ====
| The main configuration file for the module.
+
 
|-
+
If the application requires the user to read a license agreement, save that license as a file named ''LICENSE'' in your ''%%PBI_APPDIR%%''. This file is optional unless the underlying port is restricted and requires the user to accept a license in order to install and use the software.
| '''copy-files'''  
+
 
| - 
+
==== pbi.conf ====
| Listing of the files / directories you wish to copy from the pbisandbox environment to your finished PBI file.
+
 
|-
+
The ''pbi.conf'' file is mandatory. It is a simple shell script that contains the information needed to build the PBI. Typically this file requires you to modify a few simple variables, such as the name of the program, its location in the ports tree, and the name of its icon. Sometimes you will need to set a few additional variables in order to make sure that required dependencies are included in the PBI. If you get stuck when creating your own ''pbi.conf'', you can view the ''pbi.conf'' file for every PBI module in {{citelink|url=http://trac.pcbsd.org/browser#pbi/modules|txt=the PC-BSD® trac repository}}.
| '''kmenu-dir'''  
+
 
| -  
+
Here is an example of the ''pbi.conf'' file for firefox. When creating your file, modify the text in red to meet the needs of the PBI.
| Directory of configuration entries for the K menu.
+
{{txtbox|box=
|-
+
{{pound}}!/bin/sh<br>
| '''overlay-dir'''
+
{{pound}} PBI Build Configuration<br>
| -
+
{{pound}} Place over-rides and settings here<br>
| Directory of contents to be applied to base PBI directory. Icons, PBI setup scripts, and most other files not added via copy-files are placed here.
+
{{pound}}<br>
|}
+
{{pound}} XDG Desktop Menu Spec:<br>
 +
{{pound}} {{http}}standards.freedesktop.org/menu-spec/menu-spec-1.0.html<br>
 +
<nowiki>##############################################################################</nowiki>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 +
{{pound}} Program Name<br>
 +
PBI_PROGNAME={{redtxt|txt="Firefox"}}<br>
 +
 
 +
{{pound}} Program Website<br>
 +
PBI_PROGWEB={{redtxt|txt="{{http}}www.mozilla.com"}}<br>
 +
 
 +
{{pound}} Program Author / Vendor<br>
 +
PBI_PROGAUTHOR={{redtxt|txt="The Mozilla Foundation"}}<br>
 +
 
 +
{{pound}} Default Icon (Relative to %%PBI_APPDIR%% or resources/)<br>
 +
PBI_PROGICON={{redtxt|txt="share/pixmaps/FireFox-128.png"}}<br>
 +
 
 +
{{pound}} The target port we are building<br>
 +
PBI_MAKEPORT={{redtxt|txt="www/firefox"}}<br>
 +
 
 +
{{pound}} Additional options for make.conf<br>
 +
{{redtxt|txt=PBI_MAKEOPTS="PACKAGE_BUILDING=Y}}<br>
 +
{{redtxt|txt=WITH_CUPS=yes}}<br>
 +
{{redtxt|txt=WITH_GECKO=libxul"}}<br>
 +
 
 +
{{pound}} Ports to build before / after<br>
 +
PBI_MKPORTBEFORE={{redtxt|txt=""}}<br>
 +
PBI_MKPORTAFTER={{redtxt|txt="audio/esound x11-fonts/dejavu x11-themes/qtcurve-gtk2  devel/gconf2 x11/libXScrnSaver www/gecko-mediaplayer www/firefox-i18n"}}<br>
 +
 
 +
{{pound}} do not include the PBI_BUILDKEY or PBI_AB_PRIORITY options<br>
 +
{{pound}} as the correct values will be added for you when the PBI is added to the build server<br>
 +
PBI_BUILDKEY="06"<br>
 +
PBI_AB_PRIORITY="50"<br>
 +
 
 +
export PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_PROGICON PBI_MAKEPORT PBI_MAKEOPTS PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_BUILDKEY PBI_AB_PRIORITY}}
  
 +
Table 11.7a describes the most commonly used variables. When creating your ''pbi.conf'' file, refer to the FreeBSD port's ''Makefile'' and ''pkg-descr'' to determine which values to use.
  
'''Optional Files used on a per-need basis'''
+
'''Table 11.7a: Commonly Used pbi.conf Variables'''
  
{|
+
{{Tbl-init}}
| '''build.sh'''
+
{{Tbl-title|width=15%|'''Variable'''}} 
| -  
+
{{Tbl-title|width=85%|'''Description'''}}
| Script to run after the port make and copy-files are processed.
+
 
|-
 
|-
| '''preportmake.sh'''  
+
{{Tbl-line|bg=ff|align=left|'''PBI_PROGNAME<nowiki>=</nowiki>'''}}
| -  
+
{{Tbl-line|bg=ff|align=left|mandatory; should be the same value as PORTNAME<nowiki>=</nowiki> in the port's ''Makefile'', but capitalized}}
| Script to run in pbisandbox prior to the port make being executed.  
+
|-
 +
{{Tbl-line|align=left|'''PBI_PROGWEB<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|mandatory unless does not exist; should be the same value as WWW<nowiki>=</nowiki> in the port's ''pkg-descr''}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_PROGAUTHOR<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|mandatory; often found in the port's ''pkg-descr'' or at the website for the application}}
 +
|-
 +
{{Tbl-line|align=left|'''PBI_PROGICON<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|mandatory path, relative to ''%%PBI_APPDIR%%'', to application icon file in ''.png'' format}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_PROGREVISION<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|bump up a PBI's revision number; useful when rebuilding a port with new PBI specific options}}
 +
|-
 +
{{Tbl-line|align=left|'''PBI_MAKEPORT<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|mandatory; the path to the port within ''/usr/ports/''}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_MAKEOPTS<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|optional; set this to the options that you want saved to ''make.conf'' for the port building process (e.g. WITH_CUPS<nowiki>=</nowiki>YES)}}
 +
|-
 +
{{Tbl-line|align=left|'''PBI_MKPORTBEFORE<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|optional; port(s) to build before building the PBI}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_MKPORTAFTER<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|optional; port(s) to build after building the PBI}}
 +
|-
 +
{{Tbl-line|align=left|'''PBI_BUILDKEY<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|should not be included; this variable is used on the PBI build server to force the rebuild of a PBI that has failed to build}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_REQUIRESROOT<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|set to to YES to require this app to be installed as root; default is NO which allows it to be installed as a regular user }}
 +
|-
 +
{{Tbl-line|align=left|'''PBI_EXCLUDELIST<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|list of files or directories to exclude from the final archive, such as ''./include'' or ''./share''}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_AB_PRIORITY<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|may be set by build server administrator; a higher number indicates a greater priority and will be built before lower priority PBIs}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_AB_NOTMPFS<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|set to YES to disable using tmpfs when doing auto-builds on a server}}
 +
|-
 +
{{Tbl-line|align=left|'''PBI_HASH_EXCLUDES<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|set to a space delimited list of files to exclude from merging into the shared hash-dir}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''export'''}}
 +
{{Tbl-line|bg=ff|align=left|mandatory; followed by a list of all of the variables that will be included when the PBI is built}}
 
|-
 
|-
| '''mime-dir'''     
 
| -
 
| Directory of mime entries for your PBI.
 
 
|}
 
|}
  
 +
==== external-links ====
  
==== The pbi.conf file ====
+
The optional ''external-links'' file contains a list of targets to link into the system's LOCALBASE at PBI installation time. This is useful for placing binaries and files in the user's PATH. This file is usually not needed as most binaries and files are auto-detected and automatically placed in the LOCALBASE.
  
This file is the first thing you read for each module.
+
Example 11.7a shows an example usage:
The available variables are explained with the example of "FireFox" below:
+
  
# Program Name
+
'''Example 11.7a: Example external-links File'''
# The name of the PBI file being built
+
PROGNAME="Firefox"
+
+
# Program Website
+
# Website of the program the module is building
+
PROGWEB="http://www.mozilla.com"
+
 
   
 
   
# Program Author
+
{{txtbox|box={{pound}} Files to be Sym-Linked into the default LOCALBASE<br>
# Who created / maintains the program being built
+
{{pound}} One per-line, relative to %%PBI_APPDIR%% and LOCALBASE<br>
PROGAUTHOR="The Mozilla Foundation"
+
{{pound}} Defaults to keeping any existing files in LOCALBASE<br>
+
# Default Icon
+
# Relative to overlay-dir, the main icon you want to show up for this PBI
+
PROGICON="share/pixmaps/FireFox-128.png"
+
+
# Port we want to build
+
# The port the server will track to determine when it's time for a rebuild
+
PBIPORT="/usr/ports/www/firefox/"
+
+
# Set to "Auto or NONE" to have the PBI creator auto-populate libs or not
+
# This allows you to also use the autolibs/ directory in your overlay-dir as a location for extra
+
# library files
+
PROGLIBS="Auto"
+
+
# PBI Update URL set to "" or the http:// URL of update checker
+
# Leave this as update.pbidir.com normally
+
PBIUPDATE="http://update.pbidir.com"
+
+
# Other Ports we need built
+
# One per line, any additional ports that need to be built for this PBI
+
OTHERPORT=""
+
+
# Enter your custom make options here
+
# Options that will be put into the make.conf for the build of this port
+
MAKEOPTS=""
+
+
# FBSD7BASE - (7.1 or 7.2)
+
# This variable can be used to set the specific version of FreeBSD this port needs to be compiled
+
# under. Use this is a port is known to not build / work when compiled on FreeBSD 7.0 (the default)
+
FBSD7BASE="7.2"; export FBSD7BASE
+
+
# This option determines if the pbi-builder will auto-copy files from the target port
+
# Can be set to YES/NO/FULL
+
# YES - Copy only target port files automatically
+
# No - Don't copy any target port files (will need to use copy-files config instead)
+
# FULL - Copy target port files, and recursive dependency files as well (Makes very large PBI)
+
PBIAUTOPOPULATE="YES" ; export PBIAUTOPOPULATE
+
+
# Can be set to OFF/NO to disable copying all files from ports made with the OTHERPORT variable
+
# Leaving this unset will have the builder auto-copy all files from OTHERPORT targets
+
PBIAUTOPOPULATE_OTHERPORT="" ; export PBIAUTOPOPULATE_OTHERPORT
+
+
# Set this variable to any target ports you want to autopopulate files from, in addition to
+
# the main target port
+
# List additional ports one-per-line
+
PBIAUTOPOPULATE_PORTS="/usr/ports/www/mplayer-plugin/" ; export PBIAUTOPOPULATE_PORTS
+
+
# By default the PBI will remove any xorg-fonts, and create a sym-link to the the users system fonts
+
# Setting this to YES keeps the PBIs internal fonts and doesn't create a link
+
# PBIDISABLEFONTLINK="" ; export PBIDISABLEFONTLINK
+
+
# By default the libGL* libraries will be removed from a PBI in order to use the systems libGL
+
# Set this to YES to keep the PBIs libGL* libraries, and not use the system's
+
# PBIKEEPGL="" ; export PBIKEEPGL
+
+
# By default we prune any include/ files used for building,
+
# Set this to NO to keep any include/ directories in the resulting PBI
+
# PBIPRUNEINCLUDE="" ; export PBIPRUNEINCLUDE
+
+
# By default we prune the python files used for building,
+
# Set this to NO to keep any python files in the resulting PBI
+
# PBIPRUNEPYTHON="" ; export PBIPRUNEPYTHON
+
+
# By default we prune any perl files used for building,
+
# Set this to NO to keep any perl files in the resulting PBI
+
# PBIPRUNEPERL="" ; export PBIPRUNEPERL
+
+
# By default we prune any doc files (such as man, info, share/doc)
+
# Set this to NO to keep any doc files in the resulting PBI
+
# PBIPRUNEDOC="" ; export PBIPRUNEDOC
+
+
# Build Key - Change this to anything else to trigger a rebuild
+
#          - The rebuild will take place even if port is still the same ver
+
BUILDKEY="01"
+
  
==== The copy-files configuration ====
 
  
This file is very straight forward, simply list the files you want to copy from the installed port, and where they should go in your PBI directory structure. The first argument should be the file/directory you wish to copy, and the 2nd argument will be the directory within the PBI it needs to be copied to.  
+
{{pound}} TARGET{{tabstop}}&nbsp;&nbsp;&nbsp;{{tabstop}}LINK IN LOCALBASE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ACTION<br>
 +
{{pound}}etc/rc.d/servfoo{{tabstop}}etc/rc.d/servfoo{{tabstop}}keep<br>
 +
{{pound}}include/libfoo.h{{tabstop}}include/libfoo.h{{tabstop}}replace<br>
 +
{{pound}}etc/rc.d/servfoo{{tabstop}}etc/rc.d/servfoo{{tabstop}}keep<br>
 +
bin/firefox3{{tabstop}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bin/firefox3{{tabstop}}&nbsp;&nbsp;&nbsp;&nbsp;binary,nocrash}}
  
Example copy-files from FileZilla:
+
The flags in the "ACTION" column are as follows:
  
/usr/local/bin/filezilla bin/
+
* '''keep''': if this file already exists in LOCALBASE, do not overwrite it
/usr/local/bin/fzsftp bin/
+
/usr/local/bin/gst-* bin/
+
/usr/local/bin/wxrc* bin/
+
/usr/local/bin/wxgtk2* bin/
+
/usr/local/share/filezilla share/filezilla
+
  
==== The preportmake.sh script ====
+
* '''replace''': replace this file in LOCALBASE if it exists
  
This script, if it present is run right before starting the "make install" of your port. This allows you to make modifications to the pbisandbox environment or to the port building source itself. Normally this won't be
+
* '''binary''': this file is an executable
necessary, unless working with a very tricky program to get compiled.
+
  
Example:
+
* '''nocrash''': used for binary files; do not display crash handler if program exits with non-0 status
  
#!/bin/sh
+
* '''linux''': used for binary files; indicates that this is a Linux application, and needs to be run with Linux compat
# Script to grab the java files and place them in the right directory
+
# before starting the build
+
+
cd /usr/ports/distfiles
+
+
fetch ftp://ftp.pcbsd.org/pub/autobuildpkgs/javapack.tbz
+
tar xvjf javapack.tbz
+
+
cd /usr/ports/java/jdk16/
+
echo "#!/bin/sh
+
exit 0" > /usr/ports/java/jdk16/files/license.sh
+
+
cd /usr/ports/devel/automake15
+
make install clean
+
  
==== The build.sh script ====
+
==== resources/ ====
  
Below is the example of the build.sh script, which runs after all the files have been copied to your PBI directory. This allows you to make mods to specific things for your PBI to work properly. In this example we modify the uninstall script to use the right version.
+
The ''resources/'' directory can contain extra files you wish copied into the PBI application directory. This is often the best place for icons and other files not included with a port.
  
#!/bin/sh
+
==== scripts/ ====
# PBI building script
+
# This will run after your port build is complete
+
# Build your PBI here, and exit 0 on success, or exit 1 on failure.
+
##############################################################################
+
# Available Variables
+
#    PBIDIR = The location of where you can populate your PBI directory
+
# MODULEDIR = The location of the module directory for this PBI
+
#  PORTVER = Version number of the port we used to build
+
##############################################################################
+
+
# Save the right version number in the removepbi.sh script
+
sed -e "s,CHANGEME,Firefox${PORTVER},g" ${PBIDIR}/scripts/removepbi.sh > /tmp/removepbi.sh
+
mv /tmp/removepbi.sh ${PBIDIR}/scripts/removepbi.sh
+
chmod 755 ${PBIDIR}/scripts/removepbi.sh
+
  
==== The kmenu-dir directory ====
+
This directory can contain the following scripts:
  
In this directory you may make any number of files, which contain the .pbc configuration for your kmenu icons. This defines where you would like icons created for your users desktop
+
* '''post-install.sh''': script run immediately after the extraction of PBI contents to disk
  
Example of kmenu-dir/firefox file:
+
* '''post-portmake.sh''': script run during building of the PBI file, after the port compile is finished
  
ExePath: bin/firefox
+
* '''pre-portmake.sh''': script run during building of the PBI file, prior to the port compile
ExeIcon: share/pixmaps/FireFox-128.png
+
ExeDescr: FireFox
+
ExeNoDesktop: 0
+
ExeNoMenu: 0
+
ExeNoCrashHandler: 0
+
ExeRunRoot: 0
+
ExeRunShell: 0
+
ExeNotify: 1
+
ExeLink: 0
+
ExeWebLink: 0
+
ExeTaskbar: 0
+
ExeOwndir: 1
+
ExeKdeCat: Internet
+
  
Line-By-Line description of each entry:
+
* '''pre-install.sh''': script run before installation of the PBI; return non-0 to halt installation
----
+
  
'''ExePath''': bin/firefox
+
* '''pre-remove.sh''': script run before deletion of the PBI file
  
This line indicates the binary / script we want this icon to run when the user clicks it. This is relative to the PBI directory, so we use bin/firefox
+
Table 11.7b summarizes the variables that may be used in these scripts:
  
'''ExeIcon''': share/pixmaps/FireFox-128.png
+
'''Table 11.7b Supported Variables
  
This is the icon you want to show up for this program, again it is relative to the PBI directory
+
{{Tbl-init}}
 +
{{Tbl-title|width=15%|'''Variable'''}}
 +
{{Tbl-title|width=85%|'''Description'''}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_PROGNAME<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|mandatory; should be the same value as PORTNAME<nowiki>=</nowiki> in the port's ''Makefile'', but capitalized}}
 +
|-
 +
{{Tbl-line|align=left|'''PBI_PROGDIRNAME<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|name of the subdirectory that is created for the PBI in ''/usr/pbi/'' (e.g. "firefox-amd64" for the 64-bit Firefox PBI)}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_PROGDIRPATH<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|full path to the PBI install directory (e.g. ''/usr/pbi/firefox-amd64/'' for the 64-bit Firefox PBI)}}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_PROGVERSION<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|version of the program - should be the same value as the DISTVERSION in the port's Makefile }}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_RCDIR<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|location of ''rc.d/'' directory used by PBIs, usually ''/usr/local/etc/rc.d'' }}
 +
|-
 +
{{Tbl-line|align=left|'''SYS_LOCALBASE<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|align=left|LOCALBASE of the default system, typically ''/usr/local'' }}
 +
|-
 +
{{Tbl-line|bg=ff|align=left|'''PBI_FAKEBIN_DIR<nowiki>=</nowiki>'''}}
 +
{{Tbl-line|bg=ff|align=left|the binary wrapper directory, typically ''/usr/pbi/<pbidir>/.sbin/'' }}
 +
|-
 +
|}
  
'''ExeDescr''': FireFox
+
==== xdg-menu/ and xdg-desktop/ ====
  
This would be the name of the icon in the kmenu or on the users desktop.
+
The ''xdg-menu/'' and ''xdg-desktop/'' directories can be used to supply menu and desktop icons, respectively. The file that you place in these directories should be in the format ''pbiname.desktop''. Example 11.7b shows the ''firefox.desktop'' files for the firefox PBI:
  
'''ExeNoDesktop''': 0
+
'''Example 11.7b: firefox.desktop File'''
  
This allows you to disable creating a desktop icon for this entry. Set it to '0' if you want a desktop icon, or '1' if you don't wish an icon.
+
{{txtbox|box='''more xdg-menu/firefox.desktop'''<br>
 
+
{{pound}}!/usr/bin/env xdg-open<br>
'''ExeNoMenu''': 0
+
[Desktop Entry]<br>
 
+
Value=1.0<br>
This allows you to disable creating a kmenu icon for this entry. Set it to '0' if you want a kmenu icon, or '1' if you don't wish an icon.
+
Type=Application<br>
 +
Name=FireFox<br>
 +
GenericName=FireFox<br>
 +
Exec=%%PBI_EXEDIR%%/firefox %U<br>
 +
Path=%%PBI_APPDIR%%<br>
 +
Icon=%%PBI_APPDIR%%/share/pixmaps/FireFox-128.png<br>
 +
StartupNotify=true<br>
 +
Categories=Network;<br>
 +
 +
'''more xdg-desktop/firefox.desktop'''<br>
 +
{{pound}}!/usr/bin/env xdg-open<br>
 +
[Desktop Entry]<br>
 +
Value=1.0<br>
 +
Type=Application<br>
 +
Name=FireFox<br>
 +
GenericName=FireFox<br>
 +
Exec=%%PBI_EXEDIR%%/firefox %U<br>
 +
Path=%%PBI_APPDIR%%<br>
 +
Icon=%%PBI_APPDIR%%/share/pixmaps/FireFox-128.png<br>
 +
StartupNotify=true}}
  
'''ExeNoCrashHandler''': 0
+
%%PBI_EXEDIR%% should reference the PBI's executable and any required switches.
  
This option enables / disables the usage of the PC-BSD CrashHandler program. This dialog warns the user that the application has crashed if it returns status non-zero (0), and provides the option to save the output of stdout and stderr from the application. Setting this to "1" disables the CrashHandler helper, which is useful for programs which normally return non-0, such as Window Managers and various apps.
+
For more details on the XDG menu specifications, please refer to the {{citelink|url=http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html|txt=freedesktop specifications}}.
  
'''ExeRunRoot''': 0
+
==== xdg-mime/ ====
  
This indicates if you want your program to be run as "root" when the user clicks it. Set it to '0' to run as a regular user, or '1' to run kdesu and switch to "root" Set this to '0'
+
The ''xdg-mime/'' directory is used to register file associations according to the {{citelink|url=http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html|txt=freedesktop MIME specs}}. This requires the creation of an XML file. The example shown in Figure 11.7c adds the MIME information for gimp, so that it can be available as an application choice in a web browser:
  
'''ExeRunShell''': 0
+
'''Example 11.7c: Gimp MIME Info'''
  
This indicates if you want your program to be executed in a konsole session, which may be useful for command-line applications. Set it to '0' if you dont want it to run in konsole, or set it to '1' if you do.
+
{{txtbox|width=58%|box='''more xdg-mime/gimp-xdg.xml'''<br>
 +
<?xml version="1.0"?><br>
 +
<mime-info xmlns='{{http}}//www.freedesktop.org/standards/shared-mime-info'><br>
 +
&nbsp;<mime-type type="application/x-gimp"><br>
 +
&nbsp;&nbsp;<comment>Gimp File</comment><br>
 +
&nbsp;&nbsp;&nbsp;<glob weight="100" pattern="*.xcf"/><br>
 +
&nbsp;&nbsp;&nbsp;<glob weight="100" pattern="*.XCF"/><br>
 +
&nbsp;</mime-type><br>
 +
</mime-info><br>}}
  
'''ExeNotify''': 1
+
=== Creating a New PBI with '''pbi_makeport''' ===
  
This indicates if you want to enable launch feedback in KDE, which is the bouncing icon, showing that the program is loading. Set it to '0' to disable launch feedback, or set it to '1' if you want this enabled. Normally it is
+
Once you have created the files needed by your PBI module, use the built-in [[PBI Manager#pbi makeport(1)|'''pbi_makeport''']] command to convert the FreeBSD port to a PBI module.
best to leave this enabled.
+
  
'''ExeLink''': 0
+
Before attempting to build the PBI, make sure that the FreeBSD ports collection is installed. If ''/usr/ports/'' does not exist or is empty, the ports collection is not installed. To install the ports collection either use [[Control Panel]] ➜ [[System Manager]] ➜ [[System Manager#Install FreeBSD Source and Ports|Tasks]] ➜ Fetch Ports Tree or type '''portsnap fetch extract'''.
  
This is used to indicate if the ExePath variable was set to a local file / document you want opened with konqueror insetead of just being "run". This is useful for README type documents. Set this to '1' if you want your document opened with konq, or '0' to just run it as normal.
+
To build the PBI, make sure that you are in ''%%PBI_APPDIR%%'' then specify where to place the built PBI and the port to build the PBI from, as seen in this example:
  
'''ExeWebLink''': 0
+
{{txtbox|box='''pbi_makeport -o /usr/local/my_pbis archivers/cabextract'''<br>
 +
Fetching FreeBSD chroot environment... This may take a while...<br>
 +
<snip build output><br>
 +
===>  Compressing manual pages for cabextract-1.4<br>
 +
===>  Registering installation for cabextract-1.4<br>
 +
===>  Cleaning for cabextract-1.4<br>
 +
Checking for Linux libraries to copy...<br>
 +
Creating PBI: cabextract-1.4<br>
 +
Creating Stage Dir: /usr/pbi/cabextract-amd64/.stagedir<br>
 +
Creating external link entries...<br>
 +
Creating xdg scripts...<br>
 +
Creating install script...<br>
 +
Creating deinstall script...<br>
 +
Creating hash list...<br>
 +
Creating compressed archive...<br>
 +
Created PBI: /pbiout/cabextract-1.4-amd64.pbi<br>
 +
Cleaning /usr/pbi/cabextract-amd64<br>
 +
Cleaning /usr/pbi/cabextract-amd64.chroot}}
  
This is similar to above, and instead indicates that the ExePath being opened is actual a web URL. Set this to '1' to open it the ExePath with Konq, or '0' to just run it as normal.
+
The first time you run the '''pbi_makeport''' command, a clean chroot environment will automatically download and install. This chroot environment will be used for all PBI builds. If the filesystem is UFS, installing the chroot may take a few minutes. If the filesystem is ZFS and you accepted the default ZFS layout (which includes ''/usr/pbi/''), installing the chroot should happen almost instantaneously.
  
'''ExeTaskbar''': 0
+
'''NOTE:''' each time you run '''pbi_makeport''', it cleans up its environment, including all of the files that it downloaded and built. Since you may have to rebuild your PBI after testing it, you can save re-downloading and re-building all of these files again by including the '''--pkgdir <dir>''' option. You can manually remove that directory when you are finished if you need to save disk space.
  
This indicates if you want this application icon added to the taskbar. Set it to '1' to add it, or '0' to leave it disabled. (THIS FEATURE IS CURRENTLY UNAVAILABLE, BUT WILL BE ADDED DOWN THE ROAD)
+
FreeBSD ports may contain build dependencies, runtime dependencies, and required libraries. When building a PBI, '''pbi_makeport''' automatically compiles all of the required dependencies. When the build is finished, it prunes the build dependencies before packaging the PBI file, leaving only the runtime packages and libraries that are required for the program to work. This means that any files which are included in the PBI are necessary for the program to run, and manually removing them will cause the program to fail.
  
'''ExeOwndir''': 1
+
After the PBI build has finished, two files should be created in the specified directory: the PBI itself and its SHA256 checksum.
  
This option is used to specify where you want your Kmenu icon to be placed, and may be set to 0, 1, 2
+
{{txtbox|box='''ls /usr/local/my_pbis'''<br>
0 = Place kmenu icon directory in top level.
+
cabextract-1.4-amd64.pbi        cabextract-1.4-amd64.pbi.sha256}}
    I.E. Kmenu -> Firefox -> Firefox
+
1 = Place kmenu icon in its own directory in the sub category indicated by ExeKdeCat:
+
    I.E.  Kmenu -> Internet -> Firefox -> Firefox
+
2 = Place kmenu icon directly in the sub category indicated by ExeKdeCat: 
+
    I.E. Kmenu -> Internet -> Firefox
+
  
'''ExeKdeCat''': Internet
+
Use the '''pbi_add''' command to verify the information about the PBI.
  
This allows you to choose a kmenu sub-directory to place your icons / directory into, when ExeOwnDir is set to 1 or 2.  
+
{{txtbox|width=58%|box='''pbi_add -i /usr/local/my_pbis/cabextract-1.4-amd64.pbi'''<br>
Available options are:
+
PBI Information for: cabextract-1.4-amd64<br>
  ExeKdeCat: Development
+
<nowiki>-----------------------------------------------------</nowiki><br>
  ExeKdeCat: Editors
+
Name: cabextract<br>
  ExeKdeCat: Edutainment/Languages
+
RootInstall: NO<br>
  ExeKdeCat: Edutainment/Math
+
Version: 1.4<br>
  ExeKdeCat: Edutainment/Misc
+
Built: 20120829 144309<br>
  ExeKdeCat: Edutainment/Science
+
Prefix: /usr/pbi/cabextract-amd64<br>
  ExeKdeCat: Edutainment/Teaching
+
Author:<br>
  ExeKdeCat: Games/Arcade
+
Website:<br>
  ExeKdeCat: Games/Board
+
Arch: amd64<br>
  ExeKdeCat: Games/Card
+
FbsdVer: 9.1-RELEASE<br>
  ExeKdeCat: Games/Kidsgames
+
CreatorVer: 1.0<br>
  ExeKdeCat: Games/TacticStrategy
+
ArchiveCount: 498<br>
  ExeKdeCat: Games
+
ArchiveSum: b75ef8fe699bfed50ad28b058f26af3e685915b5c2330951e2802f891a5b4a85<br>
  ExeKdeCat: Graphics
+
Signature: Not Signed<br>
  ExeKdeCat: Internet
+
AutoUpdate: NO}}
  ExeKdeCat: Multimedia
+
  ExeKdeCat: Office
+
  ExeKdeCat: System
+
  ExeKdeCat: Toys
+
  ExeKdeCat: Utilities
+
  
==== The mime-dir directory ====
+
=== Testing the PBI ===
  
This directory allows to you specify mime types for your applications defined in the kmenu-dir entries.
+
Once your PBI has built, test the PBI to ensure that it installs and that the application works.
  
Example of mime-dir/exe file:
+
As the superuser, use the '''pbi_add''' command with the '''--no-checksig''' option:
  
MimeExt: *.exe; *.EXE
+
{{txtbox|box=<br>'''pbi_add --no-checksig /path_to_pbi'''<br><br>}}
MimeIcon: win_apps.png
+
MimeProg: 0
+
  
The only catch to this is to note that the "MimeProg: 0" is a pointer to a file in the kmenu-dir structure. In this case you would have to ensure that the application you want to open .exe files gets added first to the template
+
Once installed, start the application from the command line to determine if there are any error messages at application launch. When testing the executable, use the one located in ''/usr/pbi/(pbi-name)/bin/'' so all the linking will be properly set up. Otherwise you can get some interesting errors about missing files.
the server creates. Files in the kmenu-dir are added in the order of a "ls" listing, so if you have a wine-exe entry, you may wish to rename it to 00wine-exe to ensure it is added first, which would make this MimeProg: 0
+
entry work with it.
+
  
If you have more than 1 mime-type, you would then increment the MimeProg: 0 number to MimeProg: 1, MimeProg: 2, and so forth. Then you would do the same with your kmenu-dir entries, such as 00wine-exe, 01wine-bat, 02wine-msi
+
If the executable does not start the application, the executable may actually be a wrapper script rather than a binary file. If so, check the first line of the script to make sure that it is using the right path for the scripting language. For example, ''#!/bin/python'' is an incorrect path which should be changed to ''#!/usr/pbi/(pbi-name)/bin/python''.
  
==== The overlay-dir directory ====
+
The suggested path works because each program is packaged with the proper version of the language it uses and you want to make sure it uses that one. This is usually accomplished by putting a quick '''sed''' line in the ''post-install.sh'' script to fix the first line as seen in the post install script for {{citelink|url=http://trac.pcbsd.org/browser/pbi/modules/games/fretsonfire/scripts/post-install.sh?rev=13019|txt=frets on fire}}.
  
This folder contains any of the files you wish placed into your PBI program directory. Here is an example from firefox:
+
If the application starts and it is a GUI application, go through the various menus to see if they produce any errors.
  
leftside.png
+
If you encounter any error messages in either starting or using the application, record them. If the fix for resolving the error messages is not clear to you, send the error report the {{citelink|url=http://lists.pcbsd.org/mailman/listinfo/pbi-dev|txt=pbi-dev mailing list}}.
PBI.FirstRun.sh        autolibs                lib
+
PBI.RemoveScript.sh    bin                    scripts
+
PBI.SetupScript.sh      header.png              share
+
  
In this example you see we have added our PBI.* setup scripts, and the custom graphics we want for the PBI installer. You may also create directories that will be populated with the copy-files configuration, such as share/ or others you may need.
+
If your PBI works and you would like to submit its module to be included on the build server, compress it after '''cd'''ing into your module directory (%%PBI_APPDIR%%):
  
== Getting Help ==
+
{{txtbox|box=<br>'''tar czvf ~/your_pbi_name.tar.gz .'''<br><br>}}
  
To submit a new module, bugfix, or simply ask a question please contact us via the [http://lists.pcbsd.org/mailman/listinfo/pbi-dev PBI Developers mailing list]
+
This will create a compressed tarball named ''your_pbi_name.tar.gz'' in your home directory. Send this file to the {{citelink|url=http://lists.pcbsd.org/mailman/listinfo/pbi-dev|txt=pbi-dev mailing list}}.
  
Oh! That's great! Thank you for post! Awesome!And one more thing:If you will have some free time, you can find many goods for yourself here - That's just about [http://customessayorder.com/custom-essay.php essay writing]
+
<noinclude>{{refheading}}</noinclude>
 +
<noinclude>
 +
[[category:handbook]]
 +
[[category:Supporting PC-BSD®]]
 +
[[category:PBI Module Builder Guide]]
 +
[[category:Create PBIs]]
 +
</noinclude>

Revision as of 16:35, 15 February 2013

(Sorry for the inconvenience)

Contents

PC-BSD® provides a unique file format known as a PBI (push button installer). PBI files end with the .pbi extension and are self-contained installation programs. This means that even novice users can safely install and uninstall PBIs without inadvertently overwriting or deleting files needed by the operating system or other applications.

A PBI file includes all the runtime and library dependencies required by the application. This means that a PBI is a large file, but this does not necessarily mean that the installed PBI will be that large. During installation, the PBI system compares the currently installed libraries and files with the ones contained within the PBI file and only installs the ones that are not already installed on the system. A hash database is used to eliminate dependency problems while allowing the computer to share libraries between different programs.

Once a PBI is created, it can be installed using the graphical AppCafe® utility or from the command line using PBI Manager.

In order to create a PBI, the software must already be ported to FreeBSD. The easiest way to confirm whether or not a FreeBSD port exists is to search for the software at FreshPorts.org[1]. If a port does not exist, you can issue a port request at the PC-BSD® Port Requests forum using these instructions[2]. Alternately, if you have ported software before, the Porters Handbook[3] contains detailed instructions for porting software to FreeBSD.

Creating a PBI from an existing FreeBSD port is a mostly automated process that does not require development skills. Some ports are effortless to convert while more complex ports may require some thought and simple scripting. Two utilities are available for converting a FreeBSD port into a PBI:

  1. EasyPBI: provides a graphical interface and is available in Control Panel. See the EasyPBI section of the Handbook for instructions on how to use this utility.
  2. pbi_makeport: provides a command line utility.

This section explains the components of a PBI module, demonstrates how to use the pbi_makeport utility, and provides some troubleshooting tips.

NOTE: before creating a PBI, check to see if one exists using the instructions in Submit PBI Requests. If you decide that you prefer to request a PBI that you need rather than to create one, that page also contains instructions for submitting a PBI request.

PBI Module Components

This section describes the various components that comprise a PBI module. A PBI module is simply a collection of files which controls the contents of the PBI.

When creating a PBI module, create a directory on your computer to hold the module's components. For example, if you are creating a PBI module for firefox, create the directory as the superuser using this command:


mkdir -p /usr/local/my_pbis/www/firefox

As you create the subdirectories and files needed by the PBI module, save them to that directory. This directory is referred to as %%PBI_APPDIR%%. The rest of this section assumes that you are the superuser.

LICENSE File

If the application requires the user to read a license agreement, save that license as a file named LICENSE in your %%PBI_APPDIR%%. This file is optional unless the underlying port is restricted and requires the user to accept a license in order to install and use the software.

pbi.conf

The pbi.conf file is mandatory. It is a simple shell script that contains the information needed to build the PBI. Typically this file requires you to modify a few simple variables, such as the name of the program, its location in the ports tree, and the name of its icon. Sometimes you will need to set a few additional variables in order to make sure that required dependencies are included in the PBI. If you get stuck when creating your own pbi.conf, you can view the pbi.conf file for every PBI module in the PC-BSD® trac repository[4].

Here is an example of the pbi.conf file for firefox. When creating your file, modify the text in red to meet the needs of the PBI.

#!/bin/sh

# PBI Build Configuration
# Place over-rides and settings here
#
# XDG Desktop Menu Spec:
# http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html
##############################################################################          # Program Name
PBI_PROGNAME="Firefox"

# Program Website
PBI_PROGWEB="http://www.mozilla.com"

# Program Author / Vendor
PBI_PROGAUTHOR="The Mozilla Foundation"

# Default Icon (Relative to %%PBI_APPDIR%% or resources/)
PBI_PROGICON="share/pixmaps/FireFox-128.png"

# The target port we are building
PBI_MAKEPORT="www/firefox"

# Additional options for make.conf
PBI_MAKEOPTS="PACKAGE_BUILDING=Y
WITH_CUPS=yes
WITH_GECKO=libxul"

# Ports to build before / after
PBI_MKPORTBEFORE=""
PBI_MKPORTAFTER="audio/esound x11-fonts/dejavu x11-themes/qtcurve-gtk2 devel/gconf2 x11/libXScrnSaver www/gecko-mediaplayer www/firefox-i18n"

# do not include the PBI_BUILDKEY or PBI_AB_PRIORITY options
# as the correct values will be added for you when the PBI is added to the build server
PBI_BUILDKEY="06"
PBI_AB_PRIORITY="50"

export PBI_PROGNAME PBI_PROGWEB PBI_PROGAUTHOR PBI_PROGICON PBI_MAKEPORT PBI_MAKEOPTS PBI_MKPORTBEFORE PBI_MKPORTAFTER PBI_BUILDKEY PBI_AB_PRIORITY

Table 11.7a describes the most commonly used variables. When creating your pbi.conf file, refer to the FreeBSD port's Makefile and pkg-descr to determine which values to use.

Table 11.7a: Commonly Used pbi.conf Variables

Variable Description
PBI_PROGNAME= mandatory; should be the same value as PORTNAME= in the port's Makefile, but capitalized
PBI_PROGWEB= mandatory unless does not exist; should be the same value as WWW= in the port's pkg-descr
PBI_PROGAUTHOR= mandatory; often found in the port's pkg-descr or at the website for the application
PBI_PROGICON= mandatory path, relative to %%PBI_APPDIR%%, to application icon file in .png format
PBI_PROGREVISION= bump up a PBI's revision number; useful when rebuilding a port with new PBI specific options
PBI_MAKEPORT= mandatory; the path to the port within /usr/ports/
PBI_MAKEOPTS= optional; set this to the options that you want saved to make.conf for the port building process (e.g. WITH_CUPS=YES)
PBI_MKPORTBEFORE= optional; port(s) to build before building the PBI
PBI_MKPORTAFTER= optional; port(s) to build after building the PBI
PBI_BUILDKEY= should not be included; this variable is used on the PBI build server to force the rebuild of a PBI that has failed to build
PBI_REQUIRESROOT= set to to YES to require this app to be installed as root; default is NO which allows it to be installed as a regular user
PBI_EXCLUDELIST= list of files or directories to exclude from the final archive, such as ./include or ./share
PBI_AB_PRIORITY= may be set by build server administrator; a higher number indicates a greater priority and will be built before lower priority PBIs
PBI_AB_NOTMPFS= set to YES to disable using tmpfs when doing auto-builds on a server
PBI_HASH_EXCLUDES= set to a space delimited list of files to exclude from merging into the shared hash-dir
export mandatory; followed by a list of all of the variables that will be included when the PBI is built

external-links

The optional external-links file contains a list of targets to link into the system's LOCALBASE at PBI installation time. This is useful for placing binaries and files in the user's PATH. This file is usually not needed as most binaries and files are auto-detected and automatically placed in the LOCALBASE.

Example 11.7a shows an example usage:

Example 11.7a: Example external-links File

# Files to be Sym-Linked into the default LOCALBASE

# One per-line, relative to %%PBI_APPDIR%% and LOCALBASE
# Defaults to keeping any existing files in LOCALBASE


# TARGET   LINK IN LOCALBASE     ACTION
#etc/rc.d/servfooetc/rc.d/servfookeep
#include/libfoo.hinclude/libfoo.hreplace
#etc/rc.d/servfooetc/rc.d/servfookeep

bin/firefox3     bin/firefox3    binary,nocrash

The flags in the "ACTION" column are as follows:

  • keep: if this file already exists in LOCALBASE, do not overwrite it
  • replace: replace this file in LOCALBASE if it exists
  • binary: this file is an executable
  • nocrash: used for binary files; do not display crash handler if program exits with non-0 status
  • linux: used for binary files; indicates that this is a Linux application, and needs to be run with Linux compat

resources/

The resources/ directory can contain extra files you wish copied into the PBI application directory. This is often the best place for icons and other files not included with a port.

scripts/

This directory can contain the following scripts:

  • post-install.sh: script run immediately after the extraction of PBI contents to disk
  • post-portmake.sh: script run during building of the PBI file, after the port compile is finished
  • pre-portmake.sh: script run during building of the PBI file, prior to the port compile
  • pre-install.sh: script run before installation of the PBI; return non-0 to halt installation
  • pre-remove.sh: script run before deletion of the PBI file

Table 11.7b summarizes the variables that may be used in these scripts:

Table 11.7b Supported Variables

Variable Description
PBI_PROGNAME= mandatory; should be the same value as PORTNAME= in the port's Makefile, but capitalized
PBI_PROGDIRNAME= name of the subdirectory that is created for the PBI in /usr/pbi/ (e.g. "firefox-amd64" for the 64-bit Firefox PBI)
PBI_PROGDIRPATH= full path to the PBI install directory (e.g. /usr/pbi/firefox-amd64/ for the 64-bit Firefox PBI)
PBI_PROGVERSION= version of the program - should be the same value as the DISTVERSION in the port's Makefile
PBI_RCDIR= location of rc.d/ directory used by PBIs, usually /usr/local/etc/rc.d
SYS_LOCALBASE= LOCALBASE of the default system, typically /usr/local
PBI_FAKEBIN_DIR= the binary wrapper directory, typically /usr/pbi/<pbidir>/.sbin/

xdg-menu/ and xdg-desktop/

The xdg-menu/ and xdg-desktop/ directories can be used to supply menu and desktop icons, respectively. The file that you place in these directories should be in the format pbiname.desktop. Example 11.7b shows the firefox.desktop files for the firefox PBI:

Example 11.7b: firefox.desktop File

more xdg-menu/firefox.desktop

#!/usr/bin/env xdg-open
[Desktop Entry]
Value=1.0
Type=Application
Name=FireFox
GenericName=FireFox
Exec=%%PBI_EXEDIR%%/firefox %U
Path=%%PBI_APPDIR%%
Icon=%%PBI_APPDIR%%/share/pixmaps/FireFox-128.png
StartupNotify=true
Categories=Network;

more xdg-desktop/firefox.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Value=1.0
Type=Application
Name=FireFox
GenericName=FireFox
Exec=%%PBI_EXEDIR%%/firefox %U
Path=%%PBI_APPDIR%%
Icon=%%PBI_APPDIR%%/share/pixmaps/FireFox-128.png

StartupNotify=true

%%PBI_EXEDIR%% should reference the PBI's executable and any required switches.

For more details on the XDG menu specifications, please refer to the freedesktop specifications[5].

xdg-mime/

The xdg-mime/ directory is used to register file associations according to the freedesktop MIME specs[6]. This requires the creation of an XML file. The example shown in Figure 11.7c adds the MIME information for gimp, so that it can be available as an application choice in a web browser:

Example 11.7c: Gimp MIME Info

more xdg-mime/gimp-xdg.xml

<?xml version="1.0"?>
<mime-info xmlns='http:////www.freedesktop.org/standards/shared-mime-info'>
 <mime-type type="application/x-gimp">
  <comment>Gimp File</comment>
   <glob weight="100" pattern="*.xcf"/>
   <glob weight="100" pattern="*.XCF"/>
 </mime-type>

</mime-info>

Creating a New PBI with pbi_makeport

Once you have created the files needed by your PBI module, use the built-in pbi_makeport command to convert the FreeBSD port to a PBI module.

Before attempting to build the PBI, make sure that the FreeBSD ports collection is installed. If /usr/ports/ does not exist or is empty, the ports collection is not installed. To install the ports collection either use Control PanelSystem ManagerTasks ➜ Fetch Ports Tree or type portsnap fetch extract.

To build the PBI, make sure that you are in %%PBI_APPDIR%% then specify where to place the built PBI and the port to build the PBI from, as seen in this example:

pbi_makeport -o /usr/local/my_pbis archivers/cabextract

Fetching FreeBSD chroot environment... This may take a while...
<snip build output>
===> Compressing manual pages for cabextract-1.4
===> Registering installation for cabextract-1.4
===> Cleaning for cabextract-1.4
Checking for Linux libraries to copy...
Creating PBI: cabextract-1.4
Creating Stage Dir: /usr/pbi/cabextract-amd64/.stagedir
Creating external link entries...
Creating xdg scripts...
Creating install script...
Creating deinstall script...
Creating hash list...
Creating compressed archive...
Created PBI: /pbiout/cabextract-1.4-amd64.pbi
Cleaning /usr/pbi/cabextract-amd64

Cleaning /usr/pbi/cabextract-amd64.chroot

The first time you run the pbi_makeport command, a clean chroot environment will automatically download and install. This chroot environment will be used for all PBI builds. If the filesystem is UFS, installing the chroot may take a few minutes. If the filesystem is ZFS and you accepted the default ZFS layout (which includes /usr/pbi/), installing the chroot should happen almost instantaneously.

NOTE: each time you run pbi_makeport, it cleans up its environment, including all of the files that it downloaded and built. Since you may have to rebuild your PBI after testing it, you can save re-downloading and re-building all of these files again by including the --pkgdir <dir> option. You can manually remove that directory when you are finished if you need to save disk space.

FreeBSD ports may contain build dependencies, runtime dependencies, and required libraries. When building a PBI, pbi_makeport automatically compiles all of the required dependencies. When the build is finished, it prunes the build dependencies before packaging the PBI file, leaving only the runtime packages and libraries that are required for the program to work. This means that any files which are included in the PBI are necessary for the program to run, and manually removing them will cause the program to fail.

After the PBI build has finished, two files should be created in the specified directory: the PBI itself and its SHA256 checksum.

ls /usr/local/my_pbis
cabextract-1.4-amd64.pbi cabextract-1.4-amd64.pbi.sha256

Use the pbi_add command to verify the information about the PBI.

pbi_add -i /usr/local/my_pbis/cabextract-1.4-amd64.pbi

PBI Information for: cabextract-1.4-amd64
-----------------------------------------------------
Name: cabextract
RootInstall: NO
Version: 1.4
Built: 20120829 144309
Prefix: /usr/pbi/cabextract-amd64
Author:
Website:
Arch: amd64
FbsdVer: 9.1-RELEASE
CreatorVer: 1.0
ArchiveCount: 498
ArchiveSum: b75ef8fe699bfed50ad28b058f26af3e685915b5c2330951e2802f891a5b4a85
Signature: Not Signed

AutoUpdate: NO

Testing the PBI

Once your PBI has built, test the PBI to ensure that it installs and that the application works.

As the superuser, use the pbi_add command with the --no-checksig option:


pbi_add --no-checksig /path_to_pbi

Once installed, start the application from the command line to determine if there are any error messages at application launch. When testing the executable, use the one located in /usr/pbi/(pbi-name)/bin/ so all the linking will be properly set up. Otherwise you can get some interesting errors about missing files.

If the executable does not start the application, the executable may actually be a wrapper script rather than a binary file. If so, check the first line of the script to make sure that it is using the right path for the scripting language. For example, #!/bin/python is an incorrect path which should be changed to #!/usr/pbi/(pbi-name)/bin/python.

The suggested path works because each program is packaged with the proper version of the language it uses and you want to make sure it uses that one. This is usually accomplished by putting a quick sed line in the post-install.sh script to fix the first line as seen in the post install script for frets on fire[7].

If the application starts and it is a GUI application, go through the various menus to see if they produce any errors.

If you encounter any error messages in either starting or using the application, record them. If the fix for resolving the error messages is not clear to you, send the error report the pbi-dev mailing list[8].

If your PBI works and you would like to submit its module to be included on the build server, compress it after cding into your module directory (%%PBI_APPDIR%%):


tar czvf ~/your_pbi_name.tar.gz .

This will create a compressed tarball named your_pbi_name.tar.gz in your home directory. Send this file to the pbi-dev mailing list[8].

References


  1. http://www.freshports.org
  2. http://forums.pcbsd.org/showthread.php?t=13743
  3. http://www.freebsd.org/doc/en/books/porters-handbook/
  4. http://trac.pcbsd.org/browser#pbi/modules
  5. http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html
  6. http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
  7. http://trac.pcbsd.org/browser/pbi/modules/games/fretsonfire/scripts/post-install.sh?rev=13019
  8. 8.0 8.1 http://lists.pcbsd.org/mailman/listinfo/pbi-dev