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