5 opkg_package_t *find_pkg = NULL;
8 progress_callback (opkg_t *opkg, const opkg_progress_data_t *progress, void *data)
10 printf ("\r%s %3d%%", (char*) data, progress->percentage);
15 package_list_callback (opkg_t *opkg, opkg_package_t *pkg, void *data)
17 static install_count = 0;
18 static total_count = 0;
25 printf ("\rPackage count: %d Installed, %d Total Available", install_count, total_count);
30 /* store the first package to print out later */
34 opkg_package_free (pkg);
38 package_list_upgradable_callback (opkg_t *opkg, opkg_package_t *pkg, void *data)
40 printf ("%s - %s\n", pkg->name, pkg->version);
44 print_package (opkg_package_t *pkg)
64 (pkg->installed ? "True" : "False")
69 main (int argc, char **argv)
77 opkg_set_option (opkg, "offline_root", "/tmp/");
79 opkg_re_read_config_files (opkg);
81 err = opkg_update_package_lists (opkg, progress_callback, "Updating...");
82 printf ("\nopkg_update_package_lists returned %d\n", err);
84 opkg_list_packages (opkg, package_list_callback, NULL);
89 printf ("Finding package \"%s\"\n", find_pkg->name);
90 pkg = opkg_find_package (opkg, find_pkg->name, find_pkg->version, find_pkg->architecture, find_pkg->repository);
94 opkg_package_free (find_pkg);
95 opkg_package_free (pkg);
98 printf ("Package \"%s\" not found!\n", find_pkg->name);
101 printf ("No package available to test find_package.\n");
103 err = opkg_install_package (opkg, "aspell", progress_callback, "Installing...");
104 printf ("\nopkg_install_package returned %d\n", err);
106 err = opkg_upgrade_package (opkg, "aspell", progress_callback, "Upgrading...");
107 printf ("\nopkg_upgrade_package returned %d\n", err);
109 err = opkg_remove_package (opkg, "aspell", progress_callback, "Removing...");
110 printf ("\nopkg_remove_package returned %d\n", err);
112 printf ("Listing upgradable packages...\n");
113 opkg_list_upgradable_packages (opkg, package_list_upgradable_callback, NULL);
115 err = opkg_upgrade_all (opkg, progress_callback, "Upgrading all...");
116 printf ("\nopkg_upgrade_all returned %d\n", err);