Changeset 4528
- Timestamp:
- 07/16/08 10:37:12 (5 years ago)
- Location:
- trunk/src/target/opkg
- Files:
-
- 3 edited
-
libopkg/opkg.c (modified) (1 diff)
-
libopkg/opkg.h (modified) (1 diff)
-
tests/libopkg_test.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/opkg/libopkg/opkg.c
r4473 r4528 1009 1009 return package; 1010 1010 } 1011 1012 #include <curl/curl.h> 1013 /** 1014 * @brief Check the accessibility of repositories. It will try to access the repository to check if the respository is accessible throught current network status. 1015 * @param opkg The opkg_t 1016 * @return return how many repositories cannot access. 0 means all okay. 1017 */ 1018 int opkg_repository_accessibility_check(opkg_t *opkg) 1019 { 1020 pkg_src_list_elt_t *iter; 1021 str_list_elt_t *iter1; 1022 str_list_t *src; 1023 int repositories=0; 1024 int ret=0; 1025 int err; 1026 char *repo_ptr; 1027 char *stmp; 1028 opkg_assert(opkg != NULL); 1029 1030 src = str_list_alloc(); 1031 1032 for (iter = opkg->conf->pkg_src_list.head; iter; iter = iter->next) 1033 { 1034 if (strstr(iter->data->value, "://") && 1035 index(strstr(iter->data->value, "://") + 3, '/')) 1036 stmp = strndup(iter->data->value, 1037 (index(strstr(iter->data->value, "://") + 3, '/') - iter->data->value)*sizeof(char)); 1038 1039 else 1040 stmp = strdup(iter->data->value); 1041 1042 for (iter1 = src->head; iter1; iter1 = iter1->next) 1043 { 1044 if (strstr(iter1->data, stmp)) 1045 break; 1046 } 1047 if (iter1) 1048 continue; 1049 1050 sprintf_alloc(&repo_ptr, "%s/index.html",stmp); 1051 free(stmp); 1052 1053 str_list_append(src, repo_ptr); 1054 repositories++; 1055 } 1056 while (repositories > 0) 1057 { 1058 iter1 = str_list_pop(src); 1059 repositories--; 1060 1061 err = opkg_download(opkg->conf, iter1->data, "/dev/null", NULL, NULL); 1062 if (!(err == CURLE_OK || 1063 err == CURLE_HTTP_RETURNED_ERROR || 1064 err == CURLE_FILE_COULDNT_READ_FILE || 1065 err == CURLE_REMOTE_FILE_NOT_FOUND || 1066 err == CURLE_TFTP_NOTFOUND 1067 )) { 1068 ret++; 1069 } 1070 str_list_elt_deinit(iter1); 1071 free(iter1); 1072 } 1073 free(src); 1074 return ret; 1075 } -
trunk/src/target/opkg/libopkg/opkg.h
r4458 r4528 86 86 opkg_package_t* opkg_find_package (opkg_t *opkg, const char *name, const char *version, const char *architecture, const char *repository); 87 87 88 int opkg_repository_accessibility_check(opkg_t *opkg); 88 89 89 90 #endif /* OPKG_H */ -
trunk/src/target/opkg/tests/libopkg_test.c
r4461 r4528 149 149 "\tlist installed - List all the installed packages\n" 150 150 "\tremove [package] - Remove the specified package\n" 151 "\trping - Reposiroties ping, check the accessibility of repositories\n" 151 152 "\ttest - Run test script\n" 152 153 , basename (argv[0])); … … 230 231 231 232 case 'r': 232 err = opkg_remove_package (opkg, argv[2], progress_callback, "Removing..."); 233 printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]); 234 break; 233 if (argv[1][1] == 'e') 234 { 235 err = opkg_remove_package (opkg, argv[2], progress_callback, "Removing..."); 236 printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]); 237 break; 238 }else if (argv[1][1] == 'p') 239 { 240 err = opkg_repository_accessibility_check(opkg); 241 printf("\nopkg_repository_accessibility_check returned (%d)\n", err); 242 break; 243 } 235 244 236 245 default:
Note: See TracChangeset
for help on using the changeset viewer.
