Quote
1. First we need a backup of our list of installed packages before update/restore the firmware.
2. Use terminal or PuTTY. You have to be a root. Here is the magic command creating you backup list: “dpkg --get-selections > /private/var/MyPackages.list”
3. Transfer /private/var/MyPackages.list to your PC or MAC using your favorite application. WinSCP works fine for me.
4. Now you can restore/update the firmware. Jailbreak, activate and unlock. You will need Cydia installed for the next step.
5. Transfer MyPackages.list from your computer to the iPhone. Remember the directory you placed it. I’ll use /private/var.
6. SSH to your phone or use terminal. Make sure you are root.
7. Restore your packages selection using the following command “dpkg --set-selections < /private/var/MyPackages.list”
8. Make sure the APT is up to date. “apt-get update”
9. Install selected packages /from your backup list/. “apt-get dselect-upgrade” will make it happen.
10. Restart the springboard and you are all set.
Source