| @@ -1,22 +1,22 @@ | | | @@ -1,22 +1,22 @@ |
1 | /* $NetBSD: perform.c,v 1.99 2010/12/12 13:18:38 wiz Exp $ */ | | 1 | /* $NetBSD: perform.c,v 1.100 2011/08/05 07:04:28 agc Exp $ */ |
2 | #if HAVE_CONFIG_H | | 2 | #if HAVE_CONFIG_H |
3 | #include "config.h" | | 3 | #include "config.h" |
4 | #endif | | 4 | #endif |
5 | #include <nbcompat.h> | | 5 | #include <nbcompat.h> |
6 | #if HAVE_SYS_CDEFS_H | | 6 | #if HAVE_SYS_CDEFS_H |
7 | #include <sys/cdefs.h> | | 7 | #include <sys/cdefs.h> |
8 | #endif | | 8 | #endif |
9 | __RCSID("$NetBSD: perform.c,v 1.99 2010/12/12 13:18:38 wiz Exp $"); | | 9 | __RCSID("$NetBSD: perform.c,v 1.100 2011/08/05 07:04:28 agc Exp $"); |
10 | | | 10 | |
11 | /*- | | 11 | /*- |
12 | * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> | | 12 | * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> |
13 | * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org> | | 13 | * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org> |
14 | * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org> | | 14 | * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org> |
15 | * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg@NetBSD.org> | | 15 | * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg@NetBSD.org> |
16 | * Copyright (c) 2010 Thomas Klausner <wiz@NetBSD.org> | | 16 | * Copyright (c) 2010 Thomas Klausner <wiz@NetBSD.org> |
17 | * All rights reserved. | | 17 | * All rights reserved. |
18 | * | | 18 | * |
19 | * Redistribution and use in source and binary forms, with or without | | 19 | * Redistribution and use in source and binary forms, with or without |
20 | * modification, are permitted provided that the following conditions | | 20 | * modification, are permitted provided that the following conditions |
21 | * are met: | | 21 | * are met: |
22 | * | | 22 | * |
| @@ -372,26 +372,27 @@ dup_value(const char *line, const char * | | | @@ -372,26 +372,27 @@ dup_value(const char *line, const char * |
372 | } | | 372 | } |
373 | | | 373 | |
374 | static int | | 374 | static int |
375 | check_already_installed(struct pkg_task *pkg) | | 375 | check_already_installed(struct pkg_task *pkg) |
376 | { | | 376 | { |
377 | char *filename; | | 377 | char *filename; |
378 | int fd; | | 378 | int fd; |
379 | | | 379 | |
380 | filename = pkgdb_pkg_file(pkg->pkgname, CONTENTS_FNAME); | | 380 | filename = pkgdb_pkg_file(pkg->pkgname, CONTENTS_FNAME); |
381 | fd = open(filename, O_RDONLY); | | 381 | fd = open(filename, O_RDONLY); |
382 | free(filename); | | 382 | free(filename); |
383 | if (fd == -1) | | 383 | if (fd == -1) |
384 | return 1; | | 384 | return 1; |
| | | 385 | close(fd); |
385 | | | 386 | |
386 | if (ReplaceSame) { | | 387 | if (ReplaceSame) { |
387 | struct stat sb; | | 388 | struct stat sb; |
388 | | | 389 | |
389 | pkg->install_logdir_real = pkg->install_logdir; | | 390 | pkg->install_logdir_real = pkg->install_logdir; |
390 | pkg->install_logdir = xasprintf("%s.xxxxxx", pkg->install_logdir); | | 391 | pkg->install_logdir = xasprintf("%s.xxxxxx", pkg->install_logdir); |
391 | if (stat(pkg->install_logdir, &sb) == 0) { | | 392 | if (stat(pkg->install_logdir, &sb) == 0) { |
392 | warnx("package `%s' already has a temporary update " | | 393 | warnx("package `%s' already has a temporary update " |
393 | "directory `%s', remove it manually", | | 394 | "directory `%s', remove it manually", |
394 | pkg->pkgname, pkg->install_logdir); | | 395 | pkg->pkgname, pkg->install_logdir); |
395 | return -1; | | 396 | return -1; |
396 | } | | 397 | } |
397 | return 1; | | 398 | return 1; |
| @@ -401,27 +402,26 @@ check_already_installed(struct pkg_task | | | @@ -401,27 +402,26 @@ check_already_installed(struct pkg_task |
401 | return 1; | | 402 | return 1; |
402 | | | 403 | |
403 | /* We can only arrive here for explicitly requested packages. */ | | 404 | /* We can only arrive here for explicitly requested packages. */ |
404 | if (!Automatic && is_automatic_installed(pkg->pkgname)) { | | 405 | if (!Automatic && is_automatic_installed(pkg->pkgname)) { |
405 | if (Fake || | | 406 | if (Fake || |
406 | mark_as_automatic_installed(pkg->pkgname, 0) == 0) | | 407 | mark_as_automatic_installed(pkg->pkgname, 0) == 0) |
407 | warnx("package `%s' was already installed as " | | 408 | warnx("package `%s' was already installed as " |
408 | "dependency, now marked as installed " | | 409 | "dependency, now marked as installed " |
409 | "manually", pkg->pkgname); | | 410 | "manually", pkg->pkgname); |
410 | } else { | | 411 | } else { |
411 | warnx("package `%s' already recorded as installed", | | 412 | warnx("package `%s' already recorded as installed", |
412 | pkg->pkgname); | | 413 | pkg->pkgname); |
413 | } | | 414 | } |
414 | close(fd); | | | |
415 | return 0; | | 415 | return 0; |
416 | | | 416 | |
417 | } | | 417 | } |
418 | | | 418 | |
419 | static int | | 419 | static int |
420 | check_other_installed(struct pkg_task *pkg) | | 420 | check_other_installed(struct pkg_task *pkg) |
421 | { | | 421 | { |
422 | FILE *f, *f_pkg; | | 422 | FILE *f, *f_pkg; |
423 | size_t len; | | 423 | size_t len; |
424 | char *pkgbase, *iter, *filename; | | 424 | char *pkgbase, *iter, *filename; |
425 | package_t plist; | | 425 | package_t plist; |
426 | plist_t *p; | | 426 | plist_t *p; |
427 | int status; | | 427 | int status; |