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 (opkg_t
*opkg
, const opkg_progress_data_t
*progress
, void *data
)
27 printf ("\r%s %3d%%", (char*) data
, progress
->percentage
);
32 package_list_callback (opkg_t
*opkg
, 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_t
*opkg
, 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
)
82 (pkg
->installed
? "True" : "False")
88 opkg_test (opkg_t
*opkg
)
93 err
= opkg_update_package_lists (opkg
, progress_callback
, "Updating...");
94 printf ("\nopkg_update_package_lists returned %d (%s)\n", err
, errors
[err
]);
96 opkg_list_packages (opkg
, package_list_callback
, NULL
);
101 printf ("Finding package \"%s\"\n", find_pkg
->name
);
102 pkg
= opkg_find_package (opkg
, find_pkg
->name
, find_pkg
->version
, find_pkg
->architecture
, find_pkg
->repository
);
106 opkg_package_free (pkg
);
109 printf ("Package \"%s\" not found!\n", find_pkg
->name
);
110 opkg_package_free (find_pkg
);
113 printf ("No package available to test find_package.\n");
115 err
= opkg_install_package (opkg
, TEST_PACKAGE
, progress_callback
, "Installing...");
116 printf ("\nopkg_install_package returned %d (%s)\n", err
, errors
[err
]);
118 err
= opkg_upgrade_package (opkg
, TEST_PACKAGE
, progress_callback
, "Upgrading...");
119 printf ("\nopkg_upgrade_package returned %d (%s)\n", err
, errors
[err
]);
121 err
= opkg_remove_package (opkg
, TEST_PACKAGE
, progress_callback
, "Removing...");
122 printf ("\nopkg_remove_package returned %d (%s)\n", err
, errors
[err
]);
124 printf ("Listing upgradable packages...\n");
125 opkg_list_upgradable_packages (opkg
, package_list_upgradable_callback
, NULL
);
127 err
= opkg_upgrade_all (opkg
, progress_callback
, "Upgrading all...");
128 printf ("\nopkg_upgrade_all returned %d (%s)\n", err
, errors
[err
]);
133 main (int argc
, char **argv
)
141 printf ("Usage: %s command\n"
143 "\tupdate - Update package lists\n"
144 "\tfind [package] - Print details of the specified package\n"
145 "\tinstall [package] - Install the specified package\n"
146 "\tupgrade [package] - Upgrade the specified package\n"
147 "\tlist upgrades - List the available upgrades\n"
148 "\tlist all - List all available packages\n"
149 "\tlist installed - List all the installed packages\n"
150 "\tremove [package] - Remove the specified package\n"
151 "\trping - Reposiroties ping, check the accessibility of repositories\n"
152 "\ttest - Run test script\n"
153 , basename (argv
[0]));
159 opkg_set_option (opkg
, "offline_root", "/tmp/");
161 opkg_re_read_config_files (opkg
);
166 pkg
= opkg_find_package (opkg
, argv
[2], NULL
, NULL
, NULL
);
170 opkg_package_free (pkg
);
173 printf ("Package \"%s\" not found!\n", find_pkg
->name
);
174 opkg_package_free (pkg
);
177 err
= opkg_install_package (opkg
, argv
[1], progress_callback
, "Installing...");
178 printf ("\nopkg_install_package returned %d (%s)\n", err
, errors
[err
]);
182 if (strlen (argv
[1]) < 4)
184 if (argv
[1][3] == 'd')
186 err
= opkg_update_package_lists (opkg
, progress_callback
, "Updating...");
187 printf ("\nopkg_update_package_lists returned %d (%s)\n", err
, errors
[err
]);
194 err
= opkg_upgrade_all (opkg
, progress_callback
, "Upgrading all...");
195 printf ("\nopkg_upgrade_all returned %d (%s)\n", err
, errors
[err
]);
199 err
= opkg_upgrade_package (opkg
, argv
[2], progress_callback
, "Upgrading...");
200 printf ("\nopkg_upgrade_package returned %d (%s)\n", err
, errors
[err
]);
208 printf ("Please specify one either all, installed or upgrades\n");
215 printf ("Listing upgradable packages...\n");
216 opkg_list_upgradable_packages (opkg
, package_list_upgradable_callback
, NULL
);
219 printf ("Listing all packages...\n");
220 opkg_list_packages (opkg
, package_list_callback
, NULL
);
224 printf ("Listing installed packages...\n");
227 printf ("Unknown list option \"%s\"", argv
[2]);
233 if (argv
[1][1] == 'e')
235 err
= opkg_remove_package (opkg
, argv
[2], progress_callback
, "Removing...");
236 printf ("\nopkg_remove_package returned %d (%s)\n", err
, errors
[err
]);
238 }else if (argv
[1][1] == 'p')
240 err
= opkg_repository_accessibility_check(opkg
);
241 printf("\nopkg_repository_accessibility_check returned (%d)\n", err
);
246 printf ("Unknown command \"%s\"\n", argv
[1]);