Step 6: Create the PBI
PC-BSD provides a GUI tool, the Package Creator, which turns the contents of your staging area's bin/ directory into a PBI. Simply double-click on the downloaded file to install the Package Creator. By default, it will place an icon on the desktop and an entry into the Programs menu.
Open up the Package Creator and fill in the first screen with your details:
Package Name: Digikam Package Version: -0.7.2 Author: Gilles Caulier Website: http://www.digikam.org/
Note: The FreshPorts description for your application should include the URL to the application's website. The name of the primary author of the application is usually somewhere at the website for the application.
In the next screen, you can keep the default No for Display License unless the PBI requires otherwise.
In the next screen, browse the Package Directory and select your bin directory:
Under Library Support, select Specify Library Directory, click on the Browse button, and double-click on lib/.
In the next screen, click on Default Program Icon and select your PNG.
Click on Add under Package Executables and type in the program name. Click on the Browse button for Program Executable and select the executable. (In my case it was digikam).
Some programs (for example, Ethereal) need superuser access in order to run. Digikam does not, so I didn't select that option. Click on Save, and then on Next when finished.
Some programs require Mime Types, which you can add in the next screen. (Digikam does not.) The program will then create your PBI--it may take a few minutes, depending on the size of the tarball and the number of libraries. It will tell you when it finishes, and it will place the PBI in that user account's home directory. If you like, click on the Save preset button, which will save all the details to a .pbc file. That can save you some typing the next time you create a PBI.
Step 7: Test the PBI
It's important to test that your PBI successfully installs and uninstalls and that the program works with all its features.
I like to move the PBI to the Desktop so I can double-click on it:
# mv ~dru/Digikam-0.7.2-PV.pbi ~dru/Desktop/
Now leave the superuser account so you're acting as a regular user, and double-check that the application is not currently installed:
# exit % pkg_info | grep digikam %
Double-click on the PBI and see what happens. It should prompt you for the superuser password; click on Next twice and then on Finish. You should now have an icon for your application on the desktop. Double-click on it to launch the application, and try all its features to make sure they work.
Once you've confirmed that the application works, double-check that your uninstall script works:
Go to Computer -> PC-BSD Settings -> Remove Programs and remove your program. When that finishes, make sure there is no longer a directory for your application in /usr/local/MyPrograms/.
When Things Don't Work
If you get an error when you launch your program, double-check the contents of the subdirectory for your application under /usr/local/MyPrograms/. If you're missing subdirectories or files, check for a typo in your install script that prevented the tarball from untarring. Likewise, if your application directory remains after uninstalling the program, you have a typo in your uninstall script.
If all the files seem to be there, you may have inadvertently missed running lib.sh on one of the executables and therefore have some missing libraries. Review your history, and if you find your error, add the missing libraries, regenerate a PBI, and test again.
Sometimes the application will launch but features will be missing. In the example of Digikam, the initial splash screen was missing, as were most of the menus. That happens when an application shares files with existing applications such as KDE. To find those files, I checked out the package list for Digikam online.
It was the share files I missed. Because I don't want to interfere with existing applications or copy files outside the self-contained application directory, I used symbolic links. I like to add links one at a time at the command line and relaunch the application to see what happens. Once I knew which symbolic links added the missing features, I added them to PBI.SetupScript.sh and regenerated the PBI. In the case of Digikam, the following links added the missing features. (On the command line, replace
$1 with the name of the directory, as
$1 will work only in the script.)
% ln -s /usr/local/MyPrograms/$1/applications/kde/showfoto.desktop \ /usr/local/share/applications/kde % ln -s /usr/local/MyPrograms/$1/share/applnk/Graphics/digikam.desktop \ /usr/local/share/applnk/Graphics % ln -s /usr/local/MyPrograms/$1/share/apps/digikam/ \ /usr/local/share/apps/digikam % ln -s /usr/local/MyPrograms/$1/share/icons/hicolor/ \ /usr/local/share/icons/hicolor
Note: don't forget the trailing
/ when creating directory symbolic links.
Finally, if your application relies on GTK+ or Pango, follow the directions on the GTK+ and Pango PBI packaging page.