Skip to content

Instantly share code, notes, and snippets.

@bored-engineer
Created January 29, 2012 01:18
Show Gist options
  • Select an option

  • Save bored-engineer/1696566 to your computer and use it in GitHub Desktop.

Select an option

Save bored-engineer/1696566 to your computer and use it in GitHub Desktop.
Test script to list available packages
//Require exec from child processes
var exec = require('child_process').exec;
//List the packages
exec("apt-get --just-print upgrade", function (error, stdout, stderr) {
//Package list
var packages = {}
//Split at each line
stdout = stdout.split("\n");
//for each line
stdout.forEach(function(value){
//If string starts with Inst
if( value.substring( 0 , 4 ) == "Inst" ){
//Split at each space
var value2 = value.split(" ");
//Add to packages list from id
packages[value2[1]] = {
"curVer": value2[2].substring(1, value2[2].length-1),
"nextVer": value2[3].substring(1)
};
}
});
console.log(packages);
});
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
cycript eu.heinelt.ifile
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Inst cycript [0.9.288-1] (0.9.332-1 Cydia/Telesphoreo:1.0r282/stable)
Inst eu.heinelt.ifile [1.6.1-1] (1.6.1-3 BigBoss:1.0/stable)
Conf cycript (0.9.332-1 Cydia/Telesphoreo:1.0r282/stable)
Conf eu.heinelt.ifile (1.6.1-3 BigBoss:1.0/stable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment