5 opkg_package_t *find_pkg = NULL;
11 "Dependancies failed",
12 "Package already installed",
13 "Package not available",
15 "Package not installed",
16 "Signature check failed",
21 #define TEST_PACKAGE "aspell"
24 progress_callback (opkg_t *opkg, const opkg_progress_data_t *progress, void *data)
26 printf ("\r%s %3d%%", (char*) data, progress->percentage);
31 package_list_callback (opkg_t *opkg, opkg_package_t *pkg, void *data)
33 static install_count = 0;
34 static total_count = 0;
41 printf ("\rPackage count: %d Installed, %d Total Available", install_count, total_count);
46 /* store the first package to print out later */
50 opkg_package_free (pkg);
54 package_list_upgradable_callback (opkg_t *opkg, opkg_package_t *pkg, void *data)
56 printf ("%s - %s\n", pkg->name, pkg->version);
57 opkg_package_free (pkg);
61 print_package (opkg_package_t *pkg)
81 (pkg->installed ? "True" : "False")
86 main (int argc, char **argv)
94 opkg_set_option (opkg, "offline_root", "/tmp/");
96 opkg_re_read_config_files (opkg);
98 err = opkg_update_package_lists (opkg, progress_callback, "Updating...");
99 printf ("\nopkg_update_package_lists returned %d (%s)\n", err, errors[err]);
101 opkg_list_packages (opkg, package_list_callback, NULL);
106 printf ("Finding package \"%s\"\n", find_pkg->name);
107 pkg = opkg_find_package (opkg, find_pkg->name, find_pkg->version, find_pkg->architecture, find_pkg->repository);
111 opkg_package_free (pkg);
114 printf ("Package \"%s\" not found!\n", find_pkg->name);
115 opkg_package_free (find_pkg);
118 printf ("No package available to test find_package.\n");
120 err = opkg_install_package (opkg, TEST_PACKAGE, progress_callback, "Installing...");
121 printf ("\nopkg_install_package returned %d (%s)\n", err, errors[err]);
123 err = opkg_upgrade_package (opkg, TEST_PACKAGE, progress_callback, "Upgrading...");
124 printf ("\nopkg_upgrade_package returned %d (%s)\n", err, errors[err]);
126 err = opkg_remove_package (opkg, TEST_PACKAGE, progress_callback, "Removing...");
127 printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]);
129 printf ("Listing upgradable packages...\n");
130 opkg_list_upgradable_packages (opkg, package_list_upgradable_callback, NULL);
132 err = opkg_upgrade_all (opkg, progress_callback, "Upgrading all...");
133 printf ("\nopkg_upgrade_all returned %d (%s)\n", err, errors[err]);