The question came up in a support request, but is probably interesting enough to blog about: “How do I write a script to copy apps from Raccoon‘s own repository to some place else?”
First of all, don’t bother with trying to extract anything from Raccoon’s repository using shell or python scripts. There’s a Java API for that! In order to access it, all you need to do is to include the application’s JAR file in your classpath. The code below is a quick and dirty example for listing the contents of a respository on the terminal.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import de.onyxbits.raccoon.db.DatabaseManager; import de.onyxbits.raccoon.repo.AndroidAppDao; import de.onyxbits.raccoon.repo.AndroidApp; import de.onyxbits.raccoon.repo.Layout; import de.onyxbits.raccoon.repo.AppInstallerNode; import java.util.List; public class Lister { public static void main(String args[]) throws Exception { DatabaseManager manager = new DatabaseManager(Layout.DEFAULT.databaseDir); AndroidAppDao dao = manager.get(AndroidAppDao.class); List<AndroidApp> apps = dao.list(); AppInstallerNode ain = null; for(AndroidApp app: apps) { dao.details(app); // Optional int vc = app.getVersionCode(); String pn = app.getPackageName(); ain = new AppInstallerNode(Layout.DEFAULT,pn,vc); System.out.println(app.getName()+"\t\t"+ain.resolve()); } manager.shutdown(); } } |
Caveat: the database can only be opened by one process at a time. It is not possible to run the the code above and Raccoon at the same time.