PDA

View Full Version : How-to: Integration Of PBI and Ports


youlle
08-16-2005, 07:03 PM
I have spent a while thinking about how ports actually works and how PBI works and came to the conclusion that integration is possible. You should note however I have not tested this method myself, but it should work without hitch excepyt maybe the actually PBI Library declaration in the PBI creator.

Glossary:

[app] == To be replaced with name of application you are creating PBI for.
[app]_p-pbi == [app] with the suffix "_p-pbi" _p-pbi stands for Ports-PBI. NOTE: Reason for doing this is to prevent contaminating the Ports tree, so this is vital

INTEGRATION HOW-TO BEGIN

[1] create the following files structure in an empty folder say "/home/andrew/pbi/[app]/"
./MyPrograms/[app]
./MyPrograms/[app]/lib
./lib
./man
./bin
./sbin


Now you may be wondering why do this? well its all part of the ports integration. now to setup the PBI.

[2] Download a pre-compiled binary from ftp://ftp.freebsd.org/pub/FreeBSD/ports ... 6-current/ (ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-current/) or ftp://ftp.freebsd.org/pub/FreeBSD/relea ... /packages/ (ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/5.4-RELEASE/packages/)

Now extract the contents of the archieve to /home/andrew/pbi/[app]/

This is the layout of the P-PBI (Ports-PBI)

[3] Now copy the contents of ./bin (and / or) ./sbin into ./MyPrograms/[app].

[4] Open Konsole and type the following:
cd /home/andrew/pbi/[app]/MyPrograms/[app]
ldd [binary name here]This should list all libraries required by the application and their locations, copy these libraries into ./MyPrograms/[app]/lib

[5] Now we have to create the Ports specific files pkg_descr and pkg_plist; first pkg_descr:

Open Kedit and type:
This is a port of [app]
:
(etc.)

WWW: [app website here]

- [your name]
[email address here]

Save that file as /home/andrew/pbi/[app]/pkg_descr now for pkg_plist:

Open Konsole and type:
cd /home/andrew/pbi/[app]/
ls >> pkg_1
cd MyPrograms/[app]
ls >> pkg_1
cd lib
ls >> pkg_1
cd ../../..
cd lib
The lists the files in each folder and places the filenames into a file called pkg_1, open each one of these and copy the contents into a new file in Kedit e.g.:

MyPrograms/[app]/dave.jpg
MyPrograms/[app]/bob
MyPrograms[app]/lib/taxx.so.4
lib/dave.lib
@drrm /MyPrograms/[app]

You do how ever have to manually enter the folder names before the file name, as shown above otherwise the P-PBI will not work.
The @drrm part of the pkg_plist file is to tell ports it can remove the directory if all files are un-installed.

Now save this file as /home/andrew/pbi/[app]/pkg_plist

[6] Create the Archieve "[app]_p-pbi.tbz" (tar bzip) and place the entire contents of /home/andrew/pbi/[app] into it except for pkg_descr and pkg_plist.

7 Make a Directory called pkg inside /home/andrew/pbi/[app]/MyPrograms/[app] and now Copy [app]_p-pbi.tbz into ./pkg

8 Copy both pkg_descr and pkg_plist into ./pkg aswell.

[9] Time to create the Script which will prepare Ports for the P-PBI; Open Kedit and type the following:

#Ports PBI Integration System, Preperation Script (C)2005 Andrew Youll

cd /usr/ports/[category name]/
mkdir [app]_p-pbi
cd /usr/local/MyPrograms/${1}
cp pkg_descr /usr/ports/[category name]/[app]_p-pbi
cp pkg_plist /usr/ports/[category name]/[app]_p-pbi
cp [app]_p-pbi.tbz /usr/ports/distfiles
Save this file as p-pbi.prepare.sh

Make this script file executable via the properties dialogue

10 Time to create the general installation script:

#Ports PBI Integration System, Installation Script (C)2005 Andrew Youll

./[app]_p-pbi.prepare.sh
pkg_add [app]_p-pbi


save this as PBI.SetupScript.sh and make this executable in the same way as we did with the previous script.

11 Now to create the removal script:

#Ports PBI Integration System, Un-installation Script (C)2005 Andrew Youll

pkg_delete [app]_p-pbi


save this as PBI.RemoveScript.sh and make executable as well.

12 Copy both PBI.SetupScript.sh and PBI.RemoveScript.sh into the folder ./pkg in /home/andrew/pbi/[app]/MyPrograms/[app] folder.

13 Now Create the PBI using the PBI Creator, entering all relivant information about version etc, and setting "package directory" as: /home/andrew/pbi/[app]/MyPrograms/[app]/pkg.

select "specific lib directory" and enter /usr/local/MyPrograms/${1}/lib.

add any executables to the executables list in the next screen, and then any mime-types, then click create, you should now have a PBI ready to test.

[/code]

yakman
08-17-2005, 09:17 PM
I asked at the Nottingham LUG mailing list for help with a copy script for ldd
I got the following replies, of course the commands are based on linux, but perhaps some one knows how to format these for pcbsd?

ldd digikam | grep '=>' | grep -v 'not found' | awk '{print $3}' | xargs -i cp {} /path/to/dest/lib

ldd digikam | grep '(' | awk '{ print $(NF-1) }' | grep -v -e '=' -e 'not found' | xargs -i cp -p {} /path/to/dest/lib

ldd PROGRAM | awk '$3~/^\//{print $3}' | xargs cp --target-directory=~/HERE[/code]

cyrix
08-19-2005, 04:13 PM
This one works good.

ldd /path/to/program/binary | grep -o -e "[[:space:]]\/[a-z0-9\/.]*" | xargs -J REPLACE cp REPLACE /dir/where/to/place/lib

yakman
08-19-2005, 07:25 PM
thanks Cyrix, I needed to fiddle slightly to include libs with -_ ++ in the filename, but it worked a treat
ldd digikam | grep -o -e "[[:space:]]\/[a-z0-9++-_\/.]*" | xargs -J REPLACE cp REPLACE lib/
The list below is he output for digikam that i have checked line by line. An x at the line start means the script picked it up:
x libdigikam.so.0 => /usr/local/lib/libdigikam.so.0 (0x28082000)
x libgdbm.so.3 => /usr/local/lib/libgdbm.so.3 (0x28233000)
x libkipi.so.0 => /usr/local/lib/libkipi.so.0 (0x28239000)
x libtiff.so.4 => /usr/local/lib/libtiff.so.4 (0x28272000)
x libkdeprint.so.6 => /usr/local/lib/libkdeprint.so.6 (0x282be000)
x libkparts.so.3 => /usr/local/lib/libkparts.so.3 (0x2838e000)
x libkio.so.6 => /usr/local/lib/libkio.so.6 (0x283d5000)
x libkdesu.so.6 => /usr/local/lib/libkdesu.so.6 (0x286f7000)
x libkwalletclient.so.1 => /usr/local/lib/libkwalletclient.so.1 (0x2870f000)
x libfam.so.0 => /usr/local/lib/libfam.so.0 (0x28720000)
x libstdc++.so.4 => /usr/lib/libstdc++.so.4 (0x28727000)
x libImlib2.so.3 => /usr/local/lib/libImlib2.so.3 (0x287f9000)
x libfreetype.so.9 => /usr/local/lib/libfreetype.so.9 (0x28857000)
x libkexif.so.1 => /usr/local/lib/libkexif.so.1 (0x288bb000)
x libkdeui.so.6 => /usr/local/lib/libkdeui.so.6 (0x288cf000)
x libkdecore.so.6 => /usr/local/lib/libkdecore.so.6 (0x28b8d000)
x libDCOP.so.6 => /usr/local/lib/libDCOP.so.6 (0x28dcb000)
x libutil.so.4 => /lib/libutil.so.4 (0x28dff000)
x libart_lgpl_2.so.5 => /usr/local/lib/libart_lgpl_2.so.5 (0x28e0b000)
x libidn.so.16 => /usr/local/lib/libidn.so.16 (0x28e1f000)
x libkdefx.so.6 => /usr/local/lib/libkdefx.so.6 (0x28e4e000)
x libqt-mt.so.3 => /usr/X11R6/lib/libqt-mt.so.3 (0x28e78000)
x libpng.so.5 => /usr/local/lib/libpng.so.5 (0x29552000)
x libz.so.2 => /lib/libz.so.2 (0x29575000)
x libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x29585000)
x libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x29592000)
x libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x29651000)
x libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x29659000)
x libXrender.so.1 => /usr/X11R6/lib/libXrender.so.1 (0x29670000)
>>>> libexif.so.10 => not found (0x0)
x libgphoto2.so.2 => /usr/local/lib/libgphoto2.so.2 (0x29678000)
x libgphoto2_port.so.5 => /usr/local/lib/libgphoto2_port.so.5 (0x296f1000)
x libjpeg.so.9 => /usr/local/lib/libjpeg.so.9 (0x296f8000)
x libm.so.3 => /lib/libm.so.3 (0x29715000)
x libpthread.so.1 => /lib/libpthread.so.1 (0x29730000)
x libc.so.5 => /lib/libc.so.5 (0x29754000)
x libexif.so.12 => /usr/local/lib/libexif.so.12 (0x2982e000)
repeated libjpeg.so.9 => /lib/libjpeg.so.9 (0x2984d000)
x libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x2986a000)
x libaudio.so.2 => /usr/X11R6/lib/libaudio.so.2 (0x29957000)
x libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x2996b000)
x libmng.so.1 => /usr/local/lib/libmng.so.1 (0x299b4000)
x libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x29a0b000)
x libXrandr.so.2 => /usr/X11R6/lib/libXrandr.so.2 (0x29a13000)
x libXcursor.so.1 => /usr/X11R6/lib/libXcursor.so.1 (0x29a17000)
x libXinerama.so.1 => /usr/X11R6/lib/libXinerama.so.1 (0x29a20000)
x libXft.so.2 => /usr/X11R6/lib/libXft.so.2 (0x29a23000)
x libfontconfig.so.1 => /usr/X11R6/lib/libfontconfig.so.1 (0x29a34000)
x libintl.so.6 => /usr/local/lib/libintl.so.6 (0x29a5a000)
x liblcms.so.1 => /lib/liblcms.so.1 (0x29a63000)
x libexpat.so.5 => /usr/local/lib/libexpat.so.5 (0x29a8e000)