6 opkg_package_t *find_pkg = NULL;
12 "Dependancies failed",
13 "Package already installed",
14 "Package not available",
16 "Package not installed",
17 "Signature check failed",
22 #define TEST_PACKAGE "aspell"
25 progress_callback (const opkg_progress_data_t *progress, void *data)
27 printf ("\r%s %3d%%", (char*) data, progress->percentage);
32 package_list_callback (opkg_package_t *pkg, void *data)
34 static install_count = 0;
35 static total_count = 0;
42 printf ("\rPackage count: %d Installed, %d Total Available", install_count, total_count);
47 /* store the first package to print out later */
51 opkg_package_free (pkg);
55 package_list_upgradable_callback (opkg_package_t *pkg, void *data)
57 printf ("%s - %s\n", pkg->name, pkg->version);
58 opkg_package_free (pkg);
62 print_package (opkg_package_t *pkg)
80 (pkg->installed ? "True" : "False")
91 err = opkg_update_package_lists (progress_callback, "Updating...");
92 printf ("\nopkg_update_package_lists returned %d (%s)\n", err, errors[err]);
94 opkg_list_packages (package_list_callback, NULL);
99 printf ("Finding package \"%s\"\n", find_pkg->name);
100 pkg = opkg_find_package (find_pkg->name, find_pkg->version, find_pkg->architecture, find_pkg->repository);
104 opkg_package_free (pkg);
107 printf ("Package \"%s\" not found!\n", find_pkg->name);
108 opkg_package_free (find_pkg);
111 printf ("No package available to test find_package.\n");
113 err = opkg_install_package (TEST_PACKAGE, progress_callback, "Installing...");
114 printf ("\nopkg_install_package returned %d (%s)\n", err, errors[err]);
116 err = opkg_upgrade_package (TEST_PACKAGE, progress_callback, "Upgrading...");
117 printf ("\nopkg_upgrade_package returned %d (%s)\n", err, errors[err]);
119 err = opkg_remove_package (TEST_PACKAGE, progress_callback, "Removing...");
120 printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]);
122 printf ("Listing upgradable packages...\n");
123 opkg_list_upgradable_packages (package_list_upgradable_callback, NULL);
125 err = opkg_upgrade_all (progress_callback, "Upgrading all...");
126 printf ("\nopkg_upgrade_all returned %d (%s)\n", err, errors[err]);
131 main (int argc, char **argv)
138 printf ("Usage: %s command\n"
140 "\tupdate - Update package lists\n"
141 "\tfind [package] - Print details of the specified package\n"
142 "\tinstall [package] - Install the specified package\n"
143 "\tupgrade [package] - Upgrade the specified package\n"
144 "\tlist upgrades - List the available upgrades\n"
145 "\tlist all - List all available packages\n"
146 "\tlist installed - List all the installed packages\n"
147 "\tremove [package] - Remove the specified package\n"
148 "\trping - Reposiroties ping, check the accessibility of repositories\n"
149 "\ttest - Run test script\n"
150 , basename (argv[0]));
156 opkg_set_option ("offline_root", "/tmp/");
158 opkg_re_read_config_files ();
163 pkg = opkg_find_package (argv[2], NULL, NULL, NULL);
167 opkg_package_free (pkg);
170 printf ("Package \"%s\" not found!\n", find_pkg->name);
171 opkg_package_free (pkg);
174 err = opkg_install_package (argv[1], progress_callback, "Installing...");
175 printf ("\nopkg_install_package returned %d (%s)\n", err, errors[err]);
179 if (strlen (argv[1]) < 4)
181 if (argv[1][3] == 'd')
183 err = opkg_update_package_lists (progress_callback, "Updating...");
184 printf ("\nopkg_update_package_lists returned %d (%s)\n", err, errors[err]);
191 err = opkg_upgrade_all (progress_callback, "Upgrading all...");
192 printf ("\nopkg_upgrade_all returned %d (%s)\n", err, errors[err]);
196 err = opkg_upgrade_package (argv[2], progress_callback, "Upgrading...");
197 printf ("\nopkg_upgrade_package returned %d (%s)\n", err, errors[err]);
205 printf ("Please specify one either all, installed or upgrades\n");
212 printf ("Listing upgradable packages...\n");
213 opkg_list_upgradable_packages (package_list_upgradable_callback, NULL);
216 printf ("Listing all packages...\n");
217 opkg_list_packages (package_list_callback, NULL);
221 printf ("Listing installed packages...\n");
224 printf ("Unknown list option \"%s\"", argv[2]);
230 if (argv[1][1] == 'e')
232 err = opkg_remove_package (argv[2], progress_callback, "Removing...");
233 printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]);
235 }else if (argv[1][1] == 'p')
237 err = opkg_repository_accessibility_check();
238 printf("\nopkg_repository_accessibility_check returned (%d)\n", err);
243 printf ("Unknown command \"%s\"\n", argv[1]);