clacker
Group: Members
Posts: 570
Joined: June 2004 |
|
Posted: Mar. 18 2005,03:42 |
|
OK here's how I make my packages, using R as an example.
First, you need to decide what exactly you want to have as your package and make sure that you really want to spend the time making it. Is it available as a package on debian? Is source code available?
Then you need to choose between making a *.dsl, a *.tar.gz, or a *.uci. A *.dsl is nice because it's (in general) much easier to make. You can use cbagger's deb2dsl script (which is easy) or try using the find command to get the package built. If you want a tar.gz or uci, all files must be in the /home/dsl, /tmp/mydsl.menu, or /opt directories. It's safe and very easy to uninstall. If you make a uci, uninstallation happens with the mydsl button in emelfm, which is cool. If your program writes to its directory in /opt, you can make a tar.gz but you can't make a uci. If your program requires other directories, you need to make a dsl instead of a tar.gz.
For this package, you wanted a tar.gz. So you get the source code (this came from gnu.org). That usually means compiling. I always use a liveCD, so I needed to download all of the required compilers and libraries. You need to install gcc, g++, and make (which means you can use the gcc1.dsl package from the repository). If you try that here, you see that you also needed f77 (or the g77 GNU fortran compiler).
I had to load the dsl-dpkg.dsl package, change /etc/apt/sources.list to unstable, and run apt-get update. Then I ran apt-get install make gcc g77 gpp g++ which got the compilers I needed.
Most programs require libraries to compile. You can guess which ones, or you can try running the configure command to see where it complains. Untar you source using tar -xzvf packagename.tar.gz and cd to that directory. Most programs compile using three commands:
./configure make make install
so when you type ./configure from the source directory, what does it tell yo uyou need? In this case (as you pointed out) we need to load some more packages. The whatever-dev deb packages are develepoment libraries for whatever libraries. Using apt-get, you get both the base library and what you need to compile a program to use that library. We need to apt-get:
libncurses5-dev linreadline4-dev xlibs-dev
xlibs-dev is a big one. Most anything in X requires this package. ./configure doesn't complain that it's not there because it can compile without it, but R is much better with graphics and plotting. When you apt-get xlibs-dev, your going to get some errors. You need to then run dpkg -i --force-overwrite *.deb on and debs that wouldn't load, then run apt-get install -f to make sure it's all OK.
Now lets try configuring again. When you want to make a tar.gz, you want all the files under the /opt directory. This is why you want to use the --prefix=/opt/R switch. So you try:
./configure --prefix=/opt/R make make install
Now try running your program by typing /opt/R/bin/R and it should run fine. If it's all working good, make a temp directory and a temp/opt directory and copy /opt/R into it.
mkdir temp mkdir temp/opt mkdir temp/tmp mkdir temp/tmp/mydsl.menu cp -rP /opt/R temp/opt/R
I load gnu-utils.dsl and use the find commad to make a list of the files
cd temp find opt/ -not -type 'd' > files
Then I edit my menu. it need to have the same name as your directory in /opt, and the same name as you final package. it needs to be placed into the tmp/mydsl.menu directory. mine contained [ exec ] ( R ) { rxvt -rv -T "R" -e /opt/R/bin/R} chmod this file 644. Add the menu file name and path to the file you got from find.
One word of advice I can give you is if you spend the time downloading those debian libraries, save then somewhere. They are all located in /var/cache/apt/archives/*.deb. You never know, we might need them later.
Make your tar.gz file using tar -czvf R.tar.gz --numeric-owner --no-recursion -T files. Save it somewhere and reboot. Try to load it. it didn't work (a window flashed open then closed). Open an xterminal and type in /opt/R/bin/R by hand. You can see that the library it can't find is libg2c.so.0. If you don't happen to know which package this was in, look at the debian web site, you can search for packages that contain files in the packages section. Reload that package and be glad you saved it's deb file so you don't need to download it again. Use dpkg (you see it also requires gcc-3.3-base so load that too). Now try running R from the menu and it works!
Great, but how do you add those libraries to your package? Well, first I had to find what those files were. Here I used deb2dsl on just the two deb files I needed to reload. Put those two files in a directory by themselves, and run deb2dsl from that directory. It makes a dsl file in /home/dsl/, use tar -tzf newdsl.dsl >files to get a list of the new files. Look at them and only two of them are really important: libg2c.so.0 and libg2c.0.0.0. Since there is a lib directory in /opt/R/lib/R/lib that already has a .so file that R can find, let's toss our new libraries in there and repackage the tar.gz. basically, I made a temp directory, unpacked R.tar.gz into it, got a files list of R.tar.gz, added the news files to opt/R/lib/R/lib, and added the files to the file list. Then I retarred and rebooted.
Low and behold it works. That's what I did. I hope the rambling and babling helps you make other neat packages.
|