8 int opkg_state_changed;
9 pkg_t *find_pkg = NULL;
11 #define TEST_PACKAGE "aspell"
13 static void progress_callback(const opkg_progress_data_t * progress, void *data)
15 printf("\r%s %3d%%\n", (char *)data, progress->percentage);
19 static void list_pkg(pkg_t * pkg)
21 char *v = pkg_version_str_alloc(pkg);
22 printf("%s - %s\n", pkg->name, v);
26 static void package_list_installed_callback(pkg_t * pkg, void *data)
28 if (pkg->state_status == SS_INSTALLED)
32 static void package_list_callback(pkg_t * pkg, void *data)
34 static int install_count = 0;
35 static int total_count = 0;
37 if (pkg->state_status == SS_INSTALLED)
42 printf("\rPackage count: %d Installed, %d Total Available",
43 install_count, total_count);
47 /* store the first package to print out later */
52 static void package_list_upgradable_callback(pkg_t * pkg, void *data)
57 static void print_package(pkg_t * pkg)
59 char *v = pkg_version_str_alloc(pkg);
60 const char *tags = pkg_get_string(pkg, PKG_TAGS);
73 pkg_get_architecture(pkg),
74 pkg_get_string(pkg, PKG_DESCRIPTION),
76 (unsigned long) pkg_get_int(pkg, PKG_SIZE), pkg->state_status);
80 int main(int argc, char **argv)
86 printf("Usage: %s command\n"
88 "\tupdate - Update package lists\n"
89 "\tfind [package] - Print details of the specified package\n"
90 "\tinstall [package] - Install the specified package\n"
91 "\tupgrade [package] - Upgrade the specified package\n"
92 "\tlist upgrades - List the available upgrades\n"
93 "\tlist all - List all available packages\n"
94 "\tlist installed - List all the installed packages\n"
95 "\tremove [package] - Remove the specified package\n"
96 "\trping - Reposiroties ping, check the accessibility of repositories\n"
97 "\ttest - Run test script\n", basename(argv[0]));
101 setenv("OFFLINE_ROOT", "/tmp", 0);
104 printf("opkg_new() failed. This sucks.\n");
109 switch (argv[1][0]) {
111 pkg = opkg_find_package(argv[2], NULL, NULL, NULL);
115 printf("Package \"%s\" not found!\n", find_pkg->name);
119 opkg_install_package(argv[2], progress_callback,
121 printf("\nopkg_install_package returned %d\n", err);
125 if (argv[1][2] == 'd') {
127 opkg_update_package_lists(progress_callback,
129 printf("\nopkg_update_package_lists returned %d\n",
135 opkg_upgrade_all(progress_callback,
137 printf("\nopkg_upgrade_all returned %d\n", err);
140 opkg_upgrade_package(argv[2],
143 printf("\nopkg_upgrade_package returned %d\n",
152 ("Please specify one either all, installed or upgrades\n");
154 switch (argv[2][0]) {
156 printf("Listing upgradable packages...\n");
157 opkg_list_upgradable_packages
158 (package_list_upgradable_callback, NULL);
161 printf("Listing all packages...\n");
162 opkg_list_packages(package_list_callback, NULL);
166 printf("Listing installed packages...\n");
168 (package_list_installed_callback, NULL);
171 printf("Unknown list option \"%s\"\n", argv[2]);
177 if (argv[1][1] == 'e') {
179 opkg_remove_package(argv[2], progress_callback,
181 printf("\nopkg_remove_package returned %d\n", err);
183 } else if (argv[1][1] == 'p') {
184 err = opkg_repository_accessibility_check();
186 ("\nopkg_repository_accessibility_check returned (%d)\n",
192 printf("Unknown command \"%s\"\n", argv[1]);