If you have problems installing Fink...
(Root) install/uninstall-time scripting in Cydia (DEB files)
Right at the beginning, I told you
Note that the tutorial contains a mistake: prerm
BTW, speaking of the previously-mentioned tutorial, it'll become very handy for you if you try to create your DEB files on a desktop computer where, for some reason, you in no way can run pkg-deb to create the DEB file from your resources (control file + the app itself and the two optional pre/post inst/rm files) – for example, on Windows desktops.
Now, let's take a look at how the new code works, making use the new information on these script files. I make use of both an installation- and a uninstallation-time scripting support. In the former, I run the code that, so far, has been executed by the app delegate (with wired-in root password). The pre/postinst (that is, the script that is executed right before/after the DEB file has been installed; there's no difference in which of the two you use) file looks the following:
chmod o+w /System/Library/Frameworks/AVFoundation.framework/N90/AVCaptureSession.plist
chmod o+w /System/Library/Frameworks/AVFoundation.framework/N90/
chmod o+w /System/Library/PrivateFrameworks/Celestial.framework/N90/AVCapture.plist
chmod o+w /System/Library/PrivateFrameworks/Celestial.framework/N90/
#!/bin/bash
chmod o-w /System/Library/Frameworks/AVFoundation.framework/N90/AVCaptureSession.plist
chmod o-w /System/Library/Frameworks/AVFoundation.framework/N90/
chmod o-w /System/Library/PrivateFrameworks/Celestial.framework/N90/AVCapture.plist
chmod o-w /System/Library/PrivateFrameworks/Celestial.framework/N90/
if [ -d /var/mobile/Library/ip4-VideoCameraPlus ]; then
rm -r /var/mobile/Library/ip4-VideoCameraPlus
fi
In the uninstaller, I set back the original permissions of the system files and get rid of all my document files, including the directory itself, by a conditional(!) rm -r. (Remember: unlike AppStore / Xcode apps' Documents
Why the conditional rm -r, you may ask. Well, it's easy: if you try to delete a non-existing directory (or files) from a Debian package script like these, you get a nasty error:
(screenshot from the 3G S version)
Attempting to delete an empty directory / non-existing files is all too easy in our case. As I've already pointed out, it's not the install-time scripts that create the docs dir, but the application itself when it's run for the first time. However, if the user decides not to keep the app and deletes it right after the installation, the uninstall script will report the above error.
However, if this happens in postrm
This only happens with the postrm script, never with prerm. To fix uninstallable apps, don't even try do anything (e.g., to removing the repository) inside Cydia to get rid of the package. You'll need to go to /var/lib/dpkg/info
Of course, you'll always want to avoid situations like this and try to handle all possible situations (for example, the user not running the app at all) and using conditionals with operations (like the “rm” above) that, otherwise, would make it impossible to (un)install an app. And keep in mind: if you have the slightest doubt any command in your cleanup script may fail, always make it post-removal so that users will still be able to get rid of the app and won't need to mess around in /var/lib/dpkg/info/.
Using these files means I could finally get rid of all fragile (again, what if the user changes his/her password?) system() calls in the app delegate.
Note that I could have created the /var/mobile/Library/ip4-VideoCameraPlus directory from the installation-time script too in order to remove programmatic directory creation in the app delegate. However, as “/var/mobile
a.)
Note that some iDevice accessor apps even have dedicated support to copy DEB files to /var/root/Media/Cydia/AutoInstall; for example, the Windows-only i-FunBox (see “Cydia App Install” in the left, Folder View pane - click it and just drop the DEB file(s) in the right pane).
If you don't want to wait for the device to reboot, another choice is using iFile right on the device. Just copy the DEB file anywhere on the phone, navigate to the file in iFile, tap the DEB file and select “Installer
Again, what's the point in all this? When you develop for Cydia, there can be cases when simply deploying from under Xcode won't be sufficient. An example is testing and fine-tuning before/after Cydia / DEB scripts (which, of course, can't be done from inside an Xcode project) or just accessing resources that an app deployed by Xcode is just unable to access, no matter what you do, what permissions you grant to these files / their directories. Examples of these are /var/wireless/Library/CallHistory/call_history.db
Finally, note how much easier it is to deploy and install DEB files this way. Should you stick with the Cydia way, it'd require a lot more work to deploy your stuff on your iPhone than via a simple file copier + iFile + Respring. Just to recap:
Common you'll always need to do (assuming you've already built up the source directory with the native ARM app bundle in Applications and at least the control file in DEBIAN; here, I assume that the app name's ip4vcamplus):
dpkg-deb[-fat] -b ip4vcamplus
… to create the DEB file (generally, if you leave open the terminal window, just an Up to redisplay the previous command and Enter).
1, md5 ip4vcamplus.deb
2, Enter the size and the md5 sum into the Packages
3, recompress it with gzip (gzip -f Packages
5, [re]install the app from Cydia.
With iFile, you don't need to any of the previous steps: just drop the output DEB of dpkg-deb[-fat] and tap on it from inside iFile, select Installer
Finally, again, don't forget that you don't even need iFile if you have a (remote) terminal; then, just use dpkg -i filename.deb
Signing with ldid
Finally, if you plan to submit your app to an “official” Cydia repo, you'll want to follow THIS
Hope you find this information helpful!
Yet another thing...
I've uploaded the new iPhone 4 / 3GS-specific app version (1.5 / 1.7, respectively) in Cydia. The iP3GS / iP4 sources are HERE and HERE
The major change is, as you may have already guessed based on the article so far, that I've moved permission setting in an install-time script (and the docs directory removal into uninstall-time one). Now, it doesn't require the root password to be “alpine” as these scripts are run as “root”, not as “mobile” (the restricted user Cydia apps are run). With uninstall-time directory deletion, I've also eliminated the need to manually tap the “Restore Original Configuration