|
|
Zaurus 中文论坛 - 手持linux设备专用 |
 |
View previous topic :: View next topic |
Author |
Message |
goodstyle
Joined: 27 Oct 2005 Posts: 393
小企鹅: 238
|
Posted: 2005-Dec-12 Mon, pm1:05 |
|
Post subject: [分享]How to create IPK files (Zaurus) |
|
Create IPK Files (Zaurus)
iPKG the Itsy Package Management System
Introduction
Package Manager on OpenZaurus
iPKG is a lightweight package management system for devices such as the Sharp Zaurus PDA the iPAQ. It is similar to RPMs and DPKGs. In fact the iPKG is based on the Debian package management system.
Using the “Packages” (OpenZaurus) or the “Add Remove Software” (Sharp ROM) programs you can install, uninstall and upgrade software. The whole of the installation process and dependency issues are all taken care of making iPKG the ideal way for developers to distribute their software.
This tutorial will explain how to create your own .ipk file for a simple Java application.
For more information on iPKG please see http://www.handhelds.org/z/wiki/iPKG.
Inside an IPK file
So, what’s inside a .ipk file then? Lets have a look…
A .ipk file is essentially a .tar.gz file containing two other .tar.gz files and an optional file called debian-binary. If we examine the contents of qpe-terminal_1.5.0-2_arm.ipk, the terminal program for the Sharp ROM, we see:
c:\Temp>tar tzf qpe-terminal_1.5.0-2_arm.ipk
./debian-binary
./control.tar.gz
./data.tar.gz
For those wondering how I am using tar under windows I’m using Cygwin which gives you a Linux like environment under Windows. Anyway, as we can see the terminal ipk file contains three files.
* debian-binary - This file is optional and ignored by iPKG. It is there for comparability with the Debian package system. This file contains a single line containing “2.0″ (without the quotes).
* control.tar.gz - This archive contains a file describing the package (name, version, author, dependencies, etc.), and several optional installation scripts.
* data.tar.gz - This archive contains the actual files that make up your program and the contents is extracted to / when installed.
Now lets have a look inside each of those three files:
c:\Temp>cat debian-binary
2.0
c:\Temp>tar tzf control.tar.gz
./control
c:\Temp>tar tzf data.tar.gz
./opt/
./opt/QtPalmtop/
./opt/QtPalmtop/bin/
./opt/QtPalmtop/bin/embeddedkonsole
./opt/QtPalmtop/apps/
./opt/QtPalmtop/apps/Applications/
./opt/QtPalmtop/apps/Applications/embeddedkonsole.desktop
./opt/QtPalmtop/pics/
./opt/QtPalmtop/pics/konsole/
./opt/QtPalmtop/pics/konsole/down.png
./opt/QtPalmtop/pics/konsole/enter.png
./opt/QtPalmtop/pics/konsole/space.png
./opt/QtPalmtop/pics/konsole/tab.png
./opt/QtPalmtop/pics/konsole/up.png
./opt/QtPalmtop/etc/
./opt/QtPalmtop/etc/keytabs/
./opt/QtPalmtop/etc/keytabs/linux.keytab
./opt/QtPalmtop/etc/keytabs/vt100.keytab
As we can see, the data.tar.gz archive contains a complete file structure of all the files needed by the terminal program. These contain the actual executable file itself, some icons, a .desktop file, and some keyboard layouts specifically for the terminal program. More on files a bit later.
One last file we need to look at is the control file in control.tar.gz. This file contains meta information about the package itself, such as the package name, author, creation date, dependencies, size, etc.
c:\Temp>cat control
Package: qpe-terminal
Installed-Size: 196k
Filename: ./qpe-terminal_1.5.0-2_arm.ipk
Version: 1.5.0-2
Depends: qpe-base (1.5.0), ptydevs
Priority: optional
Section: qpe
Maintainer: Warwick Allison
Architecture: arm
Description: shell terminal
The terminal for the Qtopia.
The IPK file structure
In the last section we pulled apart the IPK file for QPE Terminal (the terminal program for the original Sharp Zaurus ROM). We saw that an IPK file was actually a .tar.gz file containing two more .tar.gz files and an optional called debian-binary.
In this section I just want to have a look at the control.tar.gz archive in a bit more detail and have a look at the optional installation scripts that you can use.
control.tar.gz
In the last section we saw that this archive contained a file called control which contained meta information about the package. This file is mandatory, but there are also a few more optional files that weren’t used. These are the pre and post installation scripts, and pre and post uninstallation scripts. There is also one other file called conffiles that can contain a list of configuration files used by your program that should not be overwritten when your package is upgraded.
* preinst - Pre-installation (before the actual program files are extracted).
* postinst - Post-installation (after the program files have been extracted).
* prerm - Pre-uninstallation (before your files are removed).
* postrm - Post-uninstallation (after your files have been removed).
* conffiles - List of configuration files not to be overwritten during an upgrade.
data.tar.gz
As mentioned earlier this archive contains the files used by your application. If your application is graphical you should include the necessary files to add an icon to the desktop. These consist of a .desktop file, a .png file to be used for the icon, and shell script to launch your application. These files will be described in more detail later.
Overall Structure
So the overall structure of an ipk file is:
my-package_1.0_arm.ipk
|—– debian.binary (optional)
|
|——control.tar.gz
| |—– control
| |—– conffiles (optional)
| |—– preinst (optional)
| |—– postinst (optional)
| |—– prerm (optional)
| |—– postrm (optional)
|
|—– data.tar.gz (this archive contains your own files)
|—– /home/QtPalmtop/apps/Jeode/myapp.desktop
|—– /home/QtPalmtop/bin/runmyapp
|—– /home/QtPalmtop/java/myapp.jar
|—– /home/QtPalmtop/pics/myapp.png
Rolling your own IPK file
Lets assume we have created a simple graphical Java “Hello World” application, such as the one in the Code Bytes section. So, to start with we have the following files:
C:\Temp\iPKG\HelloWorld>ll
total 6
-rw-r–r– 1 David None 972 Apr 1 00:10 HelloWorld$1.class
-rw-r–r– 1 David None 713 Apr 1 00:10 HelloWorld$2.class
-rw-r–r– 1 David None 1619 Apr 1 00:10 HelloWorld.class
-rw-r–r– 1 David None 1903 Apr 1 00:10 HelloWorld.java
To make this tidy lets put all the .class files into a single jar:
jar cvf HelloWorld.jar *.class
Create a folder called “ipkg” and inside here create two subfolders called “control” and “data”.
Directory structure mkdir ipkg
mkdir ipkg/control
mkdir ipkg/data
Now is a good time to create the directory structure for where our files will be located on the Zaurus. So create the following directories:
mkdir ipkg/data/home
mkdir ipkg/data/home/QtPalmtop
mkdir ipkg/data/home/QtPalmtop/apps
mkdir ipkg/data/home/QtPalmtop/apps/Jeode
mkdir ipkg/data/home/QtPalmtop/bin
mkdir ipkg/data/home/QtPalmtop/java
mkdir ipkg/data/home/QtPalmtop/pics
(Remember to use \’s on Windows and /’s on Linux!)
Now we have the directory structure sorted lets put some files in it! The first thing you can do is copy the jar file into ipkg/data/home/QtPalmtop/java:
cp HelloWorld.jar ./ipkg/data/home/QtPalmtop/java
Now create the shell script that will launch our Java application.
#!/bin/sh
cd $QPEDIR/java
$QPEDIR/bin/evm -Xnoprogress -XappName=$0 -cp $QPEDIR/java/HelloWorld.jar HelloWorld
This needs to be saved as ipkg/data/home/QtPalmtop/bin/runhelloworld (Note that the file does not have an extension!). Also, you need to make sure this script has execute permissions. If you are using Windows, well then don’t (ok, you’ll probably need to create a post-installation script to set the permissions on the Zaurus)! If you are using Linux you can make the file executable by typing:
chmod a+x runhelloworld
Next, create the .desktop file that will create the icon on your Zaurus:
[Desktop Entry]
Comment=helloworld
Exec=runhelloworld
Icon=HelloWorld
Type=Application
Name=HelloWorld
CanFastLoad=0
This file needs to be saved as ipkg/data/home/QtPalmtop/apps/Jeode/helloworld.desktop.
Icon Of course there’s no point creating a file to display an icon if we don’t actually have an icon to display. We need to create a 37×37 PNG file and place it in ipkg/data/home/QtPalmtop/pics. Call the file HelloWorld.png.
That’s all your the files needed for your application sorted. Now we need to create the control file:
Package: java-HelloWorld
Priority: optional
Section: extras
Version: 1.0
Architecture: arm
Maintainer: uk_dave
Depends:
Description: A graphical HelloWorld program.
Save this file as ipkg/control/control (Note that this file has no extension).
The last thing to do before we package everything up is create the debian-binary file. This file simply contains “2.0″ (without the quotes). Save it as ipkg/debian-binary (Note that there is no extension on the file again).
If you’ve done everything like I’ve told you we should now be ready to package everything up! First we are going to create the .tar.gz for the control and data folders, and then we are going to put those two files into another .tar.gz file which we are going to rename to a .ipk file.
c:\Temp\iPKG\HelloWorld>cd ipkg
c:\Temp\iPKG\HelloWorld\ipkg>cd control
c:\Temp\iPKG\HelloWorld\ipkg\control>tar cfz ../control.tar ./control
c:\Temp\iPKG\HelloWorld\ipkg\control>cd ..
c:\Temp\iPKG\HelloWorld\ipkg>cd data
c:\Temp\iPKG\HelloWorld\ipkg\data>tar cfz ../data.tar.gz ./*
c:\Temp\iPKG\HelloWorld\ipkg\data>cd ..
c:\Temp\iPKG\HelloWorld\ipkg>tar cfz helloworld.tar.gz ./debian-binary ./control.tar.gz ./data.tar.gz
c:\Temp\iPKG\HelloWorld\ipkg>mv helloworld.tar.gz java-HelloWorld_1.0_arm.ipk
c:\Temp\iPKG\HelloWorld\ipkg>rm control.tar.gz
c:\Temp\iPKG\HelloWorld\ipkg>rm data.tar.gz
And that’s all there is to it! You simply need to transfer your newly created ipk file to you Zaurus and install it! I have created a zip archive with all these files for you to have a look at. |
|
Back to top |
|
badog 论坛管理员
Joined: 01 Nov 2006 Posts: 1021
小企鹅: 6575
|
Posted: 2005-Dec-12 Mon, pm6:14 |
|
Post subject: |
|
翻译出来,就置顶 |
|
Back to top |
|
goodstyle
Joined: 27 Oct 2005 Posts: 393
小企鹅: 238
|
Posted: 2005-Dec-13 Tue, am10:00 |
|
Post subject: |
|
大家好好练练英文啊!我没Linux基础,看的一知半解!
找这个可不容易了!  |
|
Back to top |
|
hjtpal
Joined: 23 Jan 2006 Posts: 6
小企鹅: 0
|
Posted: 2006-Apr-16 Sun, pm10:28 |
|
Post subject: |
|
哈,我试试看了。下周翻译出来 |
|
Back to top |
|
badog 论坛管理员
Joined: 01 Nov 2006 Posts: 1021
小企鹅: 6575
|
Posted: 2006-Apr-16 Sun, pm10:35 |
|
Post subject: |
|
等 高手 |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|
 |
[ 页面生成时间: 秒 ] :: [ 次查询 ] :: [ ]
|
 |
Powered by phpBB © 2001, 2002 phpBB Group
iCGstation v1.0 Template By Ray © 2003, 2004 iOptional
|
 |
|
|
|
|