opkg_remove: avoid remove pkg repeatly with option --force-removal-of-dependent-packages
[project/opkg-lede.git] / libopkg / opkg_conf.c
1 /* opkg_conf.c - the opkg package management system
2
3 Copyright (C) 2009 Ubiq Technologies <graham.gower@gmail.com>
4
5 Carl D. Worth
6 Copyright (C) 2001 University of Southern California
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
12
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17 */
18
19 #include <stdio.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <fcntl.h>
23 #include <glob.h>
24 #include <unistd.h>
25
26 #include "opkg_conf.h"
27 #include "pkg_vec.h"
28 #include "pkg.h"
29 #include "xregex.h"
30 #include "sprintf_alloc.h"
31 #include "opkg_message.h"
32 #include "file_util.h"
33 #include "opkg_defines.h"
34 #include "libbb/libbb.h"
35
36 static int lock_fd;
37 static char *lock_file = NULL;
38
39 static opkg_conf_t _conf;
40 opkg_conf_t *conf = &_conf;
41
42 /*
43 * Config file options
44 */
45 opkg_option_t options[] = {
46 {"cache", OPKG_OPT_TYPE_STRING, &_conf.cache},
47 {"force_defaults", OPKG_OPT_TYPE_BOOL, &_conf.force_defaults},
48 {"force_maintainer", OPKG_OPT_TYPE_BOOL, &_conf.force_maintainer},
49 {"force_depends", OPKG_OPT_TYPE_BOOL, &_conf.force_depends},
50 {"force_overwrite", OPKG_OPT_TYPE_BOOL, &_conf.force_overwrite},
51 {"force_downgrade", OPKG_OPT_TYPE_BOOL, &_conf.force_downgrade},
52 {"force_reinstall", OPKG_OPT_TYPE_BOOL, &_conf.force_reinstall},
53 {"force_space", OPKG_OPT_TYPE_BOOL, &_conf.force_space},
54 {"force_postinstall", OPKG_OPT_TYPE_BOOL, &_conf.force_postinstall},
55 {"force_checksum", OPKG_OPT_TYPE_BOOL, &_conf.force_checksum},
56 {"check_signature", OPKG_OPT_TYPE_BOOL, &_conf.check_signature},
57 {"no_check_certificate", OPKG_OPT_TYPE_BOOL, &_conf.no_check_certificate},
58 {"ftp_proxy", OPKG_OPT_TYPE_STRING, &_conf.ftp_proxy},
59 {"http_proxy", OPKG_OPT_TYPE_STRING, &_conf.http_proxy},
60 {"http_timeout", OPKG_OPT_TYPE_STRING, &_conf.http_timeout},
61 {"no_proxy", OPKG_OPT_TYPE_STRING, &_conf.no_proxy},
62 {"test", OPKG_OPT_TYPE_BOOL, &_conf.noaction},
63 {"noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction},
64 {"download_only", OPKG_OPT_TYPE_BOOL, &_conf.download_only},
65 {"nodeps", OPKG_OPT_TYPE_BOOL, &_conf.nodeps},
66 {"nocase", OPKG_OPT_TYPE_BOOL, &_conf.nocase},
67 {"offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root},
68 {"overlay_root", OPKG_OPT_TYPE_STRING, &_conf.overlay_root},
69 {"proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd},
70 {"proxy_user", OPKG_OPT_TYPE_STRING, &_conf.proxy_user},
71 {"query-all", OPKG_OPT_TYPE_BOOL, &_conf.query_all},
72 {"size", OPKG_OPT_TYPE_BOOL, &_conf.size},
73 {"strip_abi", OPKG_OPT_TYPE_BOOL, &_conf.strip_abi},
74 {"tmp_dir", OPKG_OPT_TYPE_STRING, &_conf.tmp_dir},
75 {"verbosity", OPKG_OPT_TYPE_INT, &_conf.verbosity},
76 {"verify_program", OPKG_OPT_TYPE_STRING, &_conf.verify_program},
77 {NULL, 0, NULL}
78 };
79
80 static int resolve_pkg_dest_list(void)
81 {
82 nv_pair_list_elt_t *iter;
83 nv_pair_t *nv_pair;
84 pkg_dest_t *dest;
85 char *root_dir;
86
87 for (iter = nv_pair_list_first(&conf->tmp_dest_list); iter;
88 iter = nv_pair_list_next(&conf->tmp_dest_list, iter)) {
89 nv_pair = (nv_pair_t *) iter->data;
90
91 if (conf->offline_root) {
92 sprintf_alloc(&root_dir, "%s%s", conf->offline_root,
93 nv_pair->value);
94 } else {
95 root_dir = xstrdup(nv_pair->value);
96 }
97
98 dest =
99 pkg_dest_list_append(&conf->pkg_dest_list, nv_pair->name,
100 root_dir, conf->lists_dir);
101 free(root_dir);
102
103 if (conf->default_dest == NULL)
104 conf->default_dest = dest;
105
106 if (conf->dest_str && !strcmp(dest->name, conf->dest_str)) {
107 conf->default_dest = dest;
108 conf->restrict_to_default_dest = 1;
109 }
110 }
111
112 if (conf->dest_str && !conf->restrict_to_default_dest) {
113 opkg_msg(ERROR, "Unknown dest name: `%s'.\n", conf->dest_str);
114 return -1;
115 }
116
117 return 0;
118 }
119
120 static int opkg_conf_set_option(const char *name, const char *value)
121 {
122 int i = 0;
123
124 while (options[i].name) {
125 if (strcmp(options[i].name, name) == 0) {
126 switch (options[i].type) {
127 case OPKG_OPT_TYPE_BOOL:
128 if (*(int *)options[i].value) {
129 opkg_msg(ERROR,
130 "Duplicate boolean option %s, "
131 "leaving this option on.\n",
132 name);
133 return 0;
134 }
135 *((int *const)options[i].value) = 1;
136 return 0;
137 case OPKG_OPT_TYPE_INT:
138 if (value) {
139 if (*(int *)options[i].value) {
140 opkg_msg(ERROR,
141 "Duplicate option %s, "
142 "using first seen value \"%d\".\n",
143 name,
144 *((int *)options[i].
145 value));
146 return 0;
147 }
148 *((int *const)options[i].value) =
149 atoi(value);
150 return 0;
151 } else {
152 opkg_msg(ERROR,
153 "Option %s needs an argument\n",
154 name);
155 return -1;
156 }
157 case OPKG_OPT_TYPE_STRING:
158 if (value) {
159 if (*(char **)options[i].value) {
160 opkg_msg(ERROR,
161 "Duplicate option %s, "
162 "using first seen value \"%s\".\n",
163 name,
164 *((char **)options[i].
165 value));
166 return 0;
167 }
168 *((char **const)options[i].value) =
169 xstrdup(value);
170 return 0;
171 } else {
172 opkg_msg(ERROR,
173 "Option %s needs an argument\n",
174 name);
175 return -1;
176 }
177 }
178 }
179 i++;
180 }
181
182 opkg_msg(ERROR, "Unrecognized option: %s=%s\n", name, value);
183 return -1;
184 }
185
186 static int
187 opkg_conf_parse_file(const char *filename,
188 pkg_src_list_t * pkg_src_list)
189 {
190 int line_num = 0;
191 int err = 0;
192 FILE *file;
193 regex_t valid_line_re, comment_re;
194 #define regmatch_size 14
195 regmatch_t regmatch[regmatch_size];
196
197 file = fopen(filename, "r");
198 if (file == NULL) {
199 opkg_perror(ERROR, "Failed to open %s", filename);
200 err = -1;
201 goto err0;
202 }
203
204 opkg_msg(INFO, "Loading conf file %s.\n", filename);
205
206 err = xregcomp(&comment_re,
207 "^[[:space:]]*(#.*|[[:space:]]*)$", REG_EXTENDED);
208 if (err)
209 goto err1;
210
211 err = xregcomp(&valid_line_re,
212 "^[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))"
213 "[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))"
214 "[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))"
215 "([[:space:]]+([^[:space:]]+))?([[:space:]]+(.*))?[[:space:]]*$",
216 REG_EXTENDED);
217 if (err)
218 goto err2;
219
220 while (1) {
221 char *line;
222 char *type, *name, *value;
223
224 line_num++;
225
226 line = file_read_line_alloc(file);
227 if (line == NULL)
228 break;
229
230 if (regexec(&comment_re, line, 0, 0, 0) == 0)
231 goto NEXT_LINE;
232
233 if (regexec(&valid_line_re, line, regmatch_size, regmatch, 0) ==
234 REG_NOMATCH) {
235 opkg_msg(ERROR, "%s:%d: Ignoring invalid line: `%s'\n",
236 filename, line_num, line);
237 goto NEXT_LINE;
238 }
239
240 /* This has to be so ugly to deal with optional quotation marks */
241 if (regmatch[2].rm_so > 0) {
242 type = xstrndup(line + regmatch[2].rm_so,
243 regmatch[2].rm_eo - regmatch[2].rm_so);
244 } else {
245 type = xstrndup(line + regmatch[3].rm_so,
246 regmatch[3].rm_eo - regmatch[3].rm_so);
247 }
248
249 if (regmatch[5].rm_so > 0) {
250 name = xstrndup(line + regmatch[5].rm_so,
251 regmatch[5].rm_eo - regmatch[5].rm_so);
252 } else {
253 name = xstrndup(line + regmatch[6].rm_so,
254 regmatch[6].rm_eo - regmatch[6].rm_so);
255 }
256
257 if (regmatch[8].rm_so > 0) {
258 value = xstrndup(line + regmatch[8].rm_so,
259 regmatch[8].rm_eo - regmatch[8].rm_so);
260 } else {
261 value = xstrndup(line + regmatch[9].rm_so,
262 regmatch[9].rm_eo - regmatch[9].rm_so);
263 }
264
265 if (regmatch[13].rm_so != regmatch[13].rm_eo
266 && strncmp(type, "dist", 4) != 0) {
267 opkg_msg(ERROR,
268 "%s:%d: Ignoring config line with trailing garbage: `%s'\n",
269 filename, line_num, line);
270 } else {
271
272 /* We use the conf->tmp_dest_list below instead of
273 conf->pkg_dest_list because we might encounter an
274 offline_root option later and that would invalidate the
275 directories we would have computed in
276 pkg_dest_list_init. (We do a similar thing with
277 tmp_src_nv_pair_list for sake of symmetry.) */
278 if (strcmp(type, "option") == 0) {
279 opkg_conf_set_option(name, value);
280 } else if (strcmp(type, "src") == 0) {
281 if (!nv_pair_list_find
282 ((nv_pair_list_t *) pkg_src_list, name)) {
283 pkg_src_list_append(pkg_src_list, name,
284 value, 0);
285 } else {
286 opkg_msg(ERROR,
287 "Duplicate src declaration (%s %s). "
288 "Skipping.\n", name, value);
289 }
290 } else if (strcmp(type, "src/gz") == 0) {
291 if (!nv_pair_list_find
292 ((nv_pair_list_t *) pkg_src_list, name)) {
293 pkg_src_list_append(pkg_src_list, name,
294 value, 1);
295 } else {
296 opkg_msg(ERROR,
297 "Duplicate src declaration (%s %s). "
298 "Skipping.\n", name, value);
299 }
300 } else if (strcmp(type, "dest") == 0) {
301 nv_pair_list_append(&conf->tmp_dest_list, name,
302 value);
303 } else if (strcmp(type, "lists_dir") == 0) {
304 conf->lists_dir = xstrdup(value);
305 } else if (strcmp(type, "arch") == 0) {
306 opkg_msg(INFO,
307 "Supported arch %s priority (%s)\n",
308 name, value);
309 if (!value) {
310 opkg_msg(NOTICE,
311 "No priority given for architecture %s,"
312 "defaulting to 10\n", name);
313 value = xstrdup("10");
314 }
315 nv_pair_list_append(&conf->arch_list, name,
316 value);
317 } else {
318 opkg_msg(ERROR,
319 "%s:%d: Ignoring invalid line: `%s'\n",
320 filename, line_num, line);
321 }
322
323 }
324
325 free(type);
326 free(name);
327 free(value);
328
329 NEXT_LINE:
330 free(line);
331 }
332
333 regfree(&valid_line_re);
334 err2:
335 regfree(&comment_re);
336 err1:
337 if (fclose(file) == EOF) {
338 opkg_perror(ERROR, "Couldn't close %s", filename);
339 err = -1;
340 }
341 err0:
342 return err;
343 }
344
345 int opkg_conf_write_status_files(void)
346 {
347 pkg_dest_list_elt_t *iter;
348 pkg_dest_t *dest;
349 pkg_vec_t *all;
350 pkg_t *pkg;
351 int i, ret = 0;
352
353 if (conf->noaction)
354 return 0;
355
356 list_for_each_entry(iter, &conf->pkg_dest_list.head, node) {
357 dest = (pkg_dest_t *) iter->data;
358
359 dest->status_fp = fopen(dest->status_file_name, "w");
360 if (dest->status_fp == NULL && errno != EROFS) {
361 opkg_perror(ERROR, "Can't open status file %s",
362 dest->status_file_name);
363 ret = -1;
364 }
365 }
366
367 all = pkg_vec_alloc();
368 pkg_hash_fetch_available(all);
369
370 for (i = 0; i < all->len; i++) {
371 pkg = all->pkgs[i];
372 /* We don't need most uninstalled packages in the status file */
373 if (pkg->state_status == SS_NOT_INSTALLED
374 && (pkg->state_want == SW_UNKNOWN
375 || (pkg->state_want == SW_DEINSTALL
376 && pkg->state_flag != SF_HOLD)
377 || pkg->state_want == SW_PURGE)) {
378 continue;
379 }
380 if (pkg->dest == NULL) {
381 opkg_msg(ERROR,
382 "Internal error: package %s has a NULL dest\n",
383 pkg->name);
384 continue;
385 }
386 if (pkg->dest->status_fp)
387 pkg_print_status(pkg, pkg->dest->status_fp);
388 }
389
390 pkg_vec_free(all);
391
392 list_for_each_entry(iter, &conf->pkg_dest_list.head, node) {
393 dest = (pkg_dest_t *) iter->data;
394 if (dest->status_fp && fclose(dest->status_fp) == EOF) {
395 opkg_perror(ERROR, "Couldn't close %s",
396 dest->status_file_name);
397 ret = -1;
398 }
399 }
400
401 return ret;
402 }
403
404 char *root_filename_alloc(char *filename)
405 {
406 char *root_filename;
407 sprintf_alloc(&root_filename, "%s%s",
408 (conf->offline_root ? conf->offline_root : ""), filename);
409 return root_filename;
410 }
411
412 static int glob_errfunc(const char *epath, int eerrno)
413 {
414 if (eerrno == ENOENT)
415 /* If leading dir does not exist, we get GLOB_NOMATCH. */
416 return 0;
417
418 opkg_msg(ERROR, "glob failed for %s: %s\n", epath, strerror(eerrno));
419 return 0;
420 }
421
422 int opkg_conf_init(void)
423 {
424 pkg_src_list_init(&conf->pkg_src_list);
425 pkg_dest_list_init(&conf->pkg_dest_list);
426 pkg_dest_list_init(&conf->tmp_dest_list);
427 nv_pair_list_init(&conf->arch_list);
428
429 return 0;
430 }
431
432 int opkg_conf_load(void)
433 {
434 int i, glob_ret;
435 char *tmp, *tmp_dir_base, **tmp_val;
436 glob_t globbuf;
437 char *etc_opkg_conf_pattern;
438
439 conf->restrict_to_default_dest = 0;
440 conf->default_dest = NULL;
441
442 if (!conf->offline_root)
443 conf->offline_root = xstrdup(getenv("OFFLINE_ROOT"));
444
445 if (conf->conf_file) {
446 struct stat st;
447 if (stat(conf->conf_file, &st) == -1) {
448 opkg_perror(ERROR, "Couldn't stat %s", conf->conf_file);
449 goto err0;
450 }
451 if (opkg_conf_parse_file(conf->conf_file,
452 &conf->pkg_src_list))
453 goto err1;
454 }
455
456 if (conf->offline_root)
457 sprintf_alloc(&etc_opkg_conf_pattern, "%s/etc/opkg/*.conf",
458 conf->offline_root);
459 else {
460 const char *conf_file_dir = getenv("OPKG_CONF_DIR");
461 if (conf_file_dir == NULL)
462 conf_file_dir = OPKG_CONF_DEFAULT_CONF_FILE_DIR;
463 sprintf_alloc(&etc_opkg_conf_pattern, "%s/*.conf",
464 conf_file_dir);
465 }
466
467 memset(&globbuf, 0, sizeof(globbuf));
468 glob_ret = glob(etc_opkg_conf_pattern, 0, glob_errfunc, &globbuf);
469 if (glob_ret && glob_ret != GLOB_NOMATCH) {
470 free(etc_opkg_conf_pattern);
471 globfree(&globbuf);
472 goto err1;
473 }
474
475 free(etc_opkg_conf_pattern);
476
477 for (i = 0; i < globbuf.gl_pathc; i++) {
478 if (globbuf.gl_pathv[i])
479 if (conf->conf_file &&
480 !strcmp(conf->conf_file, globbuf.gl_pathv[i]))
481 continue;
482 if (opkg_conf_parse_file(globbuf.gl_pathv[i],
483 &conf->pkg_src_list) < 0) {
484 globfree(&globbuf);
485 goto err1;
486 }
487 }
488
489 globfree(&globbuf);
490
491 if (conf->offline_root)
492 sprintf_alloc(&lock_file, "%s/%s", conf->offline_root,
493 OPKGLOCKFILE);
494 else
495 sprintf_alloc(&lock_file, "%s", OPKGLOCKFILE);
496
497 lock_fd = creat(lock_file, S_IRUSR | S_IWUSR | S_IRGRP);
498 if (lock_fd == -1) {
499 opkg_perror(ERROR, "Could not create lock file %s", lock_file);
500 goto err2;
501 }
502
503 if (lockf(lock_fd, F_TLOCK, (off_t) 0) == -1) {
504 opkg_perror(ERROR, "Could not lock %s", lock_file);
505 if (close(lock_fd) == -1)
506 opkg_perror(ERROR, "Couldn't close descriptor %d (%s)",
507 lock_fd, lock_file);
508 lock_fd = -1;
509 goto err2;
510 }
511
512 if (conf->tmp_dir)
513 tmp_dir_base = conf->tmp_dir;
514 else
515 tmp_dir_base = getenv("TMPDIR");
516
517 sprintf_alloc(&tmp, "%s/%s",
518 tmp_dir_base ? tmp_dir_base :
519 OPKG_CONF_DEFAULT_TMP_DIR_BASE, OPKG_CONF_TMP_DIR_SUFFIX);
520 if (conf->tmp_dir)
521 free(conf->tmp_dir);
522 conf->tmp_dir = mkdtemp(tmp);
523 if (conf->tmp_dir == NULL) {
524 opkg_perror(ERROR, "Creating temp dir %s failed", tmp);
525 goto err3;
526 }
527
528 pkg_hash_init();
529 hash_table_init("file-hash", &conf->file_hash,
530 OPKG_CONF_DEFAULT_HASH_LEN);
531 hash_table_init("obs-file-hash", &conf->obs_file_hash,
532 OPKG_CONF_DEFAULT_HASH_LEN / 16);
533
534 if (conf->lists_dir == NULL)
535 conf->lists_dir = xstrdup(OPKG_CONF_LISTS_DIR);
536
537 if (conf->verify_program == NULL)
538 conf->verify_program = xstrdup(OPKG_CONF_DEFAULT_VERIFY_PROGRAM);
539
540 if (conf->offline_root) {
541 sprintf_alloc(&tmp, "%s/%s", conf->offline_root,
542 conf->lists_dir);
543 free(conf->lists_dir);
544 conf->lists_dir = tmp;
545 }
546
547 /* if no architectures were defined, then default all, noarch, and host architecture */
548 if (nv_pair_list_empty(&conf->arch_list)) {
549 nv_pair_list_append(&conf->arch_list, "all", "1");
550 nv_pair_list_append(&conf->arch_list, "noarch", "1");
551 nv_pair_list_append(&conf->arch_list, HOST_CPU_STR, "10");
552 }
553
554 /* Even if there is no conf file, we'll need at least one dest. */
555 if (nv_pair_list_empty(&conf->tmp_dest_list)) {
556 nv_pair_list_append(&conf->tmp_dest_list,
557 OPKG_CONF_DEFAULT_DEST_NAME,
558 OPKG_CONF_DEFAULT_DEST_ROOT_DIR);
559 }
560
561 if (resolve_pkg_dest_list())
562 goto err4;
563
564 nv_pair_list_deinit(&conf->tmp_dest_list);
565
566 return 0;
567
568 err4:
569 free(conf->lists_dir);
570
571 pkg_hash_deinit();
572 hash_table_deinit(&conf->file_hash);
573 hash_table_deinit(&conf->obs_file_hash);
574
575 if (rmdir(conf->tmp_dir) == -1)
576 opkg_perror(ERROR, "Couldn't remove dir %s", conf->tmp_dir);
577 err3:
578 if (lockf(lock_fd, F_ULOCK, (off_t) 0) == -1)
579 opkg_perror(ERROR, "Couldn't unlock %s", lock_file);
580
581 if (close(lock_fd) == -1)
582 opkg_perror(ERROR, "Couldn't close descriptor %d (%s)",
583 lock_fd, lock_file);
584 if (unlink(lock_file) == -1)
585 opkg_perror(ERROR, "Couldn't unlink %s", lock_file);
586 err2:
587 if (lock_file) {
588 free(lock_file);
589 lock_file = NULL;
590 }
591 err1:
592 pkg_src_list_deinit(&conf->pkg_src_list);
593 pkg_dest_list_deinit(&conf->pkg_dest_list);
594 nv_pair_list_deinit(&conf->arch_list);
595
596 for (i = 0; options[i].name; i++) {
597 if (options[i].type == OPKG_OPT_TYPE_STRING) {
598 tmp_val = (char **)options[i].value;
599 if (*tmp_val) {
600 free(*tmp_val);
601 *tmp_val = NULL;
602 }
603 }
604 }
605 err0:
606 nv_pair_list_deinit(&conf->tmp_dest_list);
607 if (conf->dest_str)
608 free(conf->dest_str);
609 if (conf->conf_file)
610 free(conf->conf_file);
611
612 return -1;
613 }
614
615 void opkg_conf_deinit(void)
616 {
617 int i;
618 char **tmp;
619
620 if (conf->tmp_dir)
621 rm_r(conf->tmp_dir);
622
623 if (conf->lists_dir)
624 free(conf->lists_dir);
625
626 if (conf->dest_str)
627 free(conf->dest_str);
628
629 if (conf->conf_file)
630 free(conf->conf_file);
631
632 pkg_src_list_deinit(&conf->pkg_src_list);
633 pkg_dest_list_deinit(&conf->pkg_dest_list);
634 nv_pair_list_deinit(&conf->arch_list);
635
636 for (i = 0; options[i].name; i++) {
637 if (options[i].type == OPKG_OPT_TYPE_STRING) {
638 tmp = (char **)options[i].value;
639 if (*tmp) {
640 free(*tmp);
641 *tmp = NULL;
642 }
643 }
644 }
645
646 if (conf->verbosity >= DEBUG) {
647 hash_print_stats(&conf->pkg_hash);
648 hash_print_stats(&conf->file_hash);
649 hash_print_stats(&conf->obs_file_hash);
650 }
651
652 pkg_hash_deinit();
653 hash_table_deinit(&conf->file_hash);
654 hash_table_deinit(&conf->obs_file_hash);
655
656 if (lock_fd != -1) {
657 if (lockf(lock_fd, F_ULOCK, (off_t) 0) == -1)
658 opkg_perror(ERROR, "Couldn't unlock %s", lock_file);
659
660 if (close(lock_fd) == -1)
661 opkg_perror(ERROR, "Couldn't close descriptor %d (%s)",
662 lock_fd, lock_file);
663
664 }
665
666 if (lock_file) {
667 if (unlink(lock_file) == -1)
668 opkg_perror(ERROR, "Couldn't unlink %s", lock_file);
669
670 free(lock_file);
671 }
672 }