Basics of creating .debs for iOS

This was originally posted at iFans.


A .deb is a Debian package. They're used in Cydia and contain files and commands to install things. This guide will cover the very basics of constructing and compiling .debs.

[IMG]There are 2 main parts to a .deb: a DEBIAN directory in the root folder, which is required; and then all the files that are going to be installed, in a directory tree matching the locations of where each file should go. To the right is an example of a .deb directory tree. The first "BF2" folder is the root of the .deb and the second is the Zeppelin theme with icons in it.
The DEBIAN folder contains various files, each without an extension. Each of these files MUST contain a blank line at the end. Here's some descriptions of files that can be created in the DEBIAN folder:

  • control is the only required file. It contains information like the author's name, the package name, etc. in this fashion:
    Package: com.package.address
    Name: Package name
    Version: 0.1
    Architecture: iphoneos-arm
    Description: This is a package!
    Maintainer: Name <email@address.com>
    Author: Name<email@address.com>

    The "Architecture" line MUST always be "iphoneos-arm." Other lines can include "Depends" in which a package or other requirement can be named that must be installed/met, like "winterboard" (package address) or "firmware(>= 5.0)" .
  • preinst means "pre-installation." It will perform commands before the package is installed. For example, this command would say "Starting the installation!":
    #!/bin/bash
    echo "Starting the installation!"

    exit 0

    It must always begin with "#!/bin/bash" and end with "exit 0". Other terminal commands, such as deleting or moving files around, can be put in this file as well.
  • postinst means "post-installation." It will perform commands after the package is installed, and has the same rules as the preinst file.
  • prerm means "pre-removal" and postrm means "post-removal." They're pretty straightforward and have the same rules as pre/postinst
As for the other folders, it's up to you. Unless you want to create folders when installing your .deb, the files must match with ones found in the root of the device you're installing on. For example, in the picture above, the "Library" and "Zeppelin" folders already exist within the iPhone (if Zeppelin is installed). The "BF2" folder is what is new (doesn't already exist), and it contains the icons for Zeppelin.
Once you've constructed your .deb directory tree with a DEBIAN folder with at least a control file inside, and other folders and files you want to install, it's time to compile your .deb. This part requires
  • A jailbroken iPhone, iPod Touch, or iPad
  • Mobile Terminal OR iFunBox w/ OpenSSH installed on iDevice OR WinSCP w/ OpenSSH installed on iDevice OR another SSH client that has a terminal feature
The first step is to get your .deb directory tree somewhere in the file system of your iDevice, either through SSH or actually creating it all on your iDevice with something like iFile. Each method is just about the same thing: execute this line of code in a terminal: 
dpkg -b /Location/of/root/deb/directory
You'll obviously have to sub in the path to your .deb directory.
  • For Mobile Terminal: simply execute the code
  • For iFunBox: make sure OpenSSH is installed and enabled on your iDevice and that your iDevice is connected to your computer, then in iFunBox there should be a SSH Terminal under your iDevice. In that, execute the code
  • For WinSCP: make sure OpenSSH is installed and enabled on your iDevice. Connect to your iDevice and press Ctrl+T. Click OK on the popup and then execute the code
  • For other SSH clients: I don't know them all, so try to find a terminal feature. If you can't find one, try another method.
Your compiled .deb should appear in the same directory as the root directory of the .deb, with the same name as the root directory. If all has been done correctly, you should have a .deb! 
Feel free to post comments/questions.

No comments:

Post a Comment