7 pkg_t *find_pkg = NULL;
13 "Dependancies failed",
14 "Package already installed",
15 "Package not available",
17 "Package not installed",
18 "Signature check failed",
23 #define TEST_PACKAGE "aspell"
26 progress_callback (const opkg_progress_data_t *progress, void *data)
28 printf ("\r%s %3d%%", (char*) data, progress->percentage);
33 package_list_callback (pkg_t *pkg, void *data)
35 static int install_count = 0;
36 static int total_count = 0;
38 if (pkg->state_status == SS_INSTALLED)
43 printf ("\rPackage count: %d Installed, %d Total Available", install_count, total_count);
48 /* store the first package to print out later */
54 package_list_upgradable_callback (pkg_t *pkg, void *data)
56 printf ("%s - %s\n", pkg->name, pkg->version);
60 print_package (pkg_t *pkg)
89 err = opkg_update_package_lists (progress_callback, "Updating...");
90 printf ("\nopkg_update_package_lists returned %d (%s)\n", err, errors[err]);
92 opkg_list_packages (package_list_callback, NULL);
97 printf ("Finding package \"%s\"\n", find_pkg->name);
98 pkg = opkg_find_package (find_pkg->name, find_pkg->version, find_pkg->architecture, find_pkg->src->name);
104 printf ("Package \"%s\" not found!\n", find_pkg->name);
107 printf ("No package available to test find_package.\n");
109 err = opkg_install_package (TEST_PACKAGE, progress_callback, "Installing...");
110 printf ("\nopkg_install_package returned %d (%s)\n", err, errors[err]);
112 err = opkg_upgrade_package (TEST_PACKAGE, progress_callback, "Upgrading...");
113 printf ("\nopkg_upgrade_package returned %d (%s)\n", err, errors[err]);
115 err = opkg_remove_package (TEST_PACKAGE, progress_callback, "Removing...");
116 printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]);
118 printf ("Listing upgradable packages...\n");
119 opkg_list_upgradable_packages (package_list_upgradable_callback, NULL);
121 err = opkg_upgrade_all (progress_callback, "Upgrading all...");
122 printf ("\nopkg_upgrade_all returned %d (%s)\n", err, errors[err]);
127 main (int argc, char **argv)
134 printf ("Usage: %s command\n"
136 "\tupdate - Update package lists\n"
137 "\tfind [package] - Print details of the specified package\n"
138 "\tinstall [package] - Install the specified package\n"
139 "\tupgrade [package] - Upgrade the specified package\n"
140 "\tlist upgrades - List the available upgrades\n"
141 "\tlist all - List all available packages\n"
142 "\tlist installed - List all the installed packages\n"
143 "\tremove [package] - Remove the specified package\n"
144 "\trping - Reposiroties ping, check the accessibility of repositories\n"
145 "\ttest - Run test script\n"
146 , basename (argv[0]));
150 setenv("OFFLINE_ROOT", "/tmp", 0);
153 printf("opkg_new() failed. This sucks.\n");
161 pkg = opkg_find_package (argv[2], NULL, NULL, NULL);
167 printf ("Package \"%s\" not found!\n", find_pkg->name);
170 err = opkg_install_package (argv[1], progress_callback, "Installing...");
171 printf ("\nopkg_install_package returned %d (%s)\n", err, errors[err]);
175 if (argv[1][2] == 'd')
177 err = opkg_update_package_lists (progress_callback, "Updating...");
178 printf ("\nopkg_update_package_lists returned %d (%s)\n", err, errors[err]);
185 err = opkg_upgrade_all (progress_callback, "Upgrading all...");
186 printf ("\nopkg_upgrade_all returned %d (%s)\n", err, errors[err]);
190 err = opkg_upgrade_package (argv[2], progress_callback, "Upgrading...");
191 printf ("\nopkg_upgrade_package returned %d (%s)\n", err, errors[err]);
199 printf ("Please specify one either all, installed or upgrades\n");
206 printf ("Listing upgradable packages...\n");
207 opkg_list_upgradable_packages (package_list_upgradable_callback, NULL);
210 printf ("Listing all packages...\n");
211 opkg_list_packages (package_list_callback, NULL);
215 printf ("Listing installed packages...\n");
218 printf ("Unknown list option \"%s\"", argv[2]);
224 if (argv[1][1] == 'e')
226 err = opkg_remove_package (argv[2], progress_callback, "Removing...");
227 printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]);
229 }else if (argv[1][1] == 'p')
231 err = opkg_repository_accessibility_check();
232 printf("\nopkg_repository_accessibility_check returned (%d)\n", err);
237 printf ("Unknown command \"%s\"\n", argv[1]);