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.

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 [[Using AppCafe® | 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 {{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.

−

−

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.

−

−

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 ===

=== PBI Module Components ===

Line 23:

Line 9:

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:

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:

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.

+

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 ====

==== LICENSE File ====

Line 33:

Line 19:

==== pbi.conf ====

==== 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 {{citelink|url=http://trac.pcbsd.org/browser#pbi/modules|txt=the PC-BSD® trac repository}}.

+

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=https://github.com/pcbsd/pbi/tree/master/modules|txt=the PC-BSD® repository}}.

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.

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.

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.

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.

+

{{note|icon64=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.

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.

Line 296:

Line 278:

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

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

−

{{txtbox|box='''ls /usr/local/my_pbis'''<br>

+

{{txtbox|pre|box='''ls /usr/local/my_pbis'''

cabextract-1.4-amd64.pbi cabextract-1.4-amd64.pbi.sha256}}

cabextract-1.4-amd64.pbi cabextract-1.4-amd64.pbi.sha256}}

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

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

Once the process completes and a PBI is built successfully, it is very important to [[create PBIs#test the PBI|test the PBI]], especially if the intent is to submit it for inclusion in AppCafe. Even quality control for your own sake is good because it will aid in learning the PBI build process. It will be easier to make corrections while everything is still fresh in your mind and little else has changed.

−

+

−

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:

+

−

+

−

{{txtbox|box=<br>'''pbi_add --no-checksig /path_to_pbi'''<br><br>}}

+

−

+

−

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 {{citelink|url=http://trac.pcbsd.org/browser/pbi/modules/games/fretsonfire/scripts/post-install.sh?rev=13019|txt=frets on fire}}.

+

−

+

−

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 {{citelink|url=http://lists.pcbsd.org/mailman/listinfo/pbi-dev|txt=pbi-dev mailing list}}.

+

−

+

−

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%%):

+

−

+

−

{{txtbox|box=<br>'''tar czvf ~/your_pbi_name.tar.gz .'''<br><br>}}

+

−

+

−

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}}.

+

−

<noinclude>{{refheading}}</noinclude>

−

<noinclude>{{GroupListHeading|group=tables}}</noinclude>

<noinclude>

<noinclude>

+

{{refheading}}

+

{{GroupListHeading|group=tables}}

[[category:handbook]]

[[category:handbook]]

[[category:Supporting PC-BSD®]]

[[category:Supporting PC-BSD®]]

Revision as of 13:56, 8 August 2013

PBI Module Builder GuideProtection (edit): Edited by: Tigersharke

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.

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® repository[1].

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.

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

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:

xdg-mime/

The xdg-mime/ directory is used to register file associations according to the freedesktop MIME specs[3]. 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:

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 Panel ➜ System Manager ➜ Tasks ➜ 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:

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.

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.

Once the process completes and a PBI is built successfully, it is very important to test the PBI, especially if the intent is to submit it for inclusion in AppCafe. Even quality control for your own sake is good because it will aid in learning the PBI build process. It will be easier to make corrections while everything is still fresh in your mind and little else has changed.