Rev 5729 | Rev 5737 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5729 | Rev 5731 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | #include "package.h" |
10 | #include "package.h" |
11 | #include "http.h" |
11 | #include "http.h" |
Line 12... | Line 12... | ||
12 | 12 | ||
Line -... | Line 13... | ||
- | 13 | #define BUFFSIZE (64*1024) |
|
Line 13... | Line 14... | ||
13 | #define BUFFSIZE (64*1024) |
14 | |
14 | 15 | char conbuf[256]; |
|
15 | 16 | ||
16 | char *make_url(const char *name) |
17 | char *make_url(const char *name) |
Line 88... | Line 89... | ||
88 | if(tail) |
89 | if(tail) |
89 | { |
90 | { |
90 | memcpy(buf, http->content_ptr+count, tail); |
91 | memcpy(buf, http->content_ptr+count, tail); |
91 | offset = tail; |
92 | offset = tail; |
92 | } |
93 | } |
- | 94 | ||
- | 95 | sprintf(conbuf, "%d bytes loaded\r", http->content_received); |
|
- | 96 | con_write_asciiz(conbuf); |
|
- | 97 | ||
93 | } |
98 | } |
94 | received = http->content_received; |
99 | received = http->content_received; |
95 | } |
100 | } |
96 | else break; |
101 | else break; |
Line 116... | Line 121... | ||
116 | err_get: |
121 | err_get: |
117 | printf("HTTP GET failed\n"); |
122 | printf("HTTP GET failed\n"); |
118 | return received; |
123 | return received; |
119 | } |
124 | } |
Line 120... | Line -... | ||
120 | - | ||
121 | 125 | ||
122 | int main(int argc, char *argv[]) |
126 | int main(int argc, char *argv[]) |
123 | { |
127 | { |
124 | int count; |
128 | int count; |
125 | char *cache_path; |
129 | char *cache_path; |
Line 126... | Line 130... | ||
126 | char *tmp_path; |
130 | char *tmp_path; |
127 | 131 | ||
Line -... | Line 132... | ||
- | 132 | if(http_init()) |
|
- | 133 | goto err_init; |
|
128 | if(http_init()) |
134 | |
Line 129... | Line 135... | ||
129 | goto err_init; |
135 | con_init(80, 25, 80, 250, "Kolibri package manager"); |
Line 130... | Line 136... | ||
130 | 136 | ||
Line 148... | Line 154... | ||
148 | 154 | ||
149 | if(!list_empty(&download_list)) |
155 | if(!list_empty(&download_list)) |
Line 150... | Line 156... | ||
150 | remove_missing_packages(&install_list, &download_list); |
156 | remove_missing_packages(&install_list, &download_list); |
- | 157 | ||
151 | 158 | list_for_each_entry(pkg, &install_list, list) |
|
- | 159 | { |
|
- | 160 | sprintf(conbuf,"install package %s-%s\n", pkg->name, pkg->version); |
|
Line 152... | Line 161... | ||
152 | list_for_each_entry(pkg, &install_list, list) |
161 | con_write_asciiz(conbuf); |
Line 153... | Line 162... | ||
153 | printf("install package %s-%s\n", pkg->name, pkg->version); |
162 | }; |
154 | 163 | ||
155 | set_cwd("/tmp0/1"); |
164 | set_cwd("/tmp0/1"); |
- | 165 | ||
- | 166 | do_install(&install_list); |
|
Line 156... | Line 167... | ||
156 | 167 | }; |
|
Line 157... | Line 168... | ||
157 | do_install(&install_list); |
168 | } |
158 | }; |
169 | |
Line 224... | Line 235... | ||
224 | char *cache_path; |
235 | char *cache_path; |
225 | int count; |
236 | int count; |
Line 226... | Line 237... | ||
226 | 237 | ||
227 | list_for_each_entry_safe(pkg, tmp, download_list, list) |
238 | list_for_each_entry_safe(pkg, tmp, download_list, list) |
228 | { |
239 | { |
- | 240 | sprintf(conbuf,"package %s-%s\n", pkg->name, pkg->version); |
|
229 | printf("package %s-%s\n", pkg->name, pkg->version); |
241 | con_write_asciiz(conbuf); |
230 | cache_path = make_cache_path(pkg->filename); |
242 | cache_path = make_cache_path(pkg->filename); |
231 | count = http_load_file(cache_path, make_url(pkg->filename)); |
243 | count = http_load_file(cache_path, make_url(pkg->filename)); |
- | 244 | sprintf(conbuf,"%s %d bytes loaded\n",cache_path, count); |
|
232 | printf("%s loaded %d bytes\n",cache_path, count); |
245 | con_write_asciiz(conbuf); |
233 | if( !test_archive(cache_path)) |
246 | if( !test_archive(cache_path)) |
234 | list_del_pkg(pkg); |
247 | list_del_pkg(pkg); |
235 | else |
248 | else |
236 | unlink(cache_path); |
249 | unlink(cache_path); |
Line 245... | Line 258... | ||
245 | { |
258 | { |
246 | list_for_each_entry_safe(ipkg, itmp, install, list) |
259 | list_for_each_entry_safe(ipkg, itmp, install, list) |
247 | { |
260 | { |
248 | if(ipkg->id == mpkg->id) |
261 | if(ipkg->id == mpkg->id) |
249 | { |
262 | { |
250 | printf("skip missing package %s-%s\n", ipkg->name, ipkg->version); |
263 | sprintf(conbuf,"skip missing package %s-%s\n", ipkg->name, ipkg->version); |
- | 264 | con_write_asciiz(conbuf); |
|
251 | list_del_pkg(ipkg); |
265 | list_del_pkg(ipkg); |
252 | }; |
266 | }; |
253 | } |
267 | } |
254 | list_del_pkg(mpkg); |
268 | list_del_pkg(mpkg); |
255 | }; |
269 | }; |