xbps-bin(8): if -f is set, remove files and configuration files even

if its hash doesn't match for the remove and purge targets respectively.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20100125070948-841kw2r4knz2793e
This commit is contained in:
Juan RP 2010-01-25 08:09:48 +01:00
parent 17d87b3559
commit 1c4d43306a
4 changed files with 34 additions and 14 deletions

4
NEWS
View File

@ -1,4 +1,8 @@
xbps-0.4 (2010-02-01): xbps-0.4 (2010-02-01):
* xbps-bin(8): enable -f option for the 'purge' and 'remove' targets.
If set, files will be removed even if its hash doesn't match for the
'remove' target, and configuration files for the 'purge' target.
* xbps-uhelper: the 'fetch' target now accepts an arbitrary number of * xbps-uhelper: the 'fetch' target now accepts an arbitrary number of
arguments, and sets default libfetch cache connection limits. arguments, and sets default libfetch cache connection limits.

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2008-2009 Juan Romero Pardines. * Copyright (c) 2008-2010 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -61,8 +61,8 @@ usage(void)
" -V\t\tPrints the xbps release version\n" " -V\t\tPrints the xbps release version\n"
" Options used by the install/(auto)remove/update targets:\n" " Options used by the install/(auto)remove/update targets:\n"
" -y\t\tAssume \"yes\" for all questions.\n" " -y\t\tAssume \"yes\" for all questions.\n"
" Options used by the reconfigure target:\n" " Options used by the purge/reconfigure/remove targets:\n"
" -f\t\tForce reconfiguration.\n" " -f\t\tForce reconfiguration or removal of files.\n"
"\n"); "\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -31,8 +31,10 @@ OPTIONS
it will become '/blah/cachedir'. it will become '/blah/cachedir'.
*-f*:: *-f*::
Used currently in the 'reconfigure' target. If set, package(s) will Used currently in the 'purge', 'reconfigure' and 'remove' targets.
be reconfigured regardless of its state. If set, package(s) will be reconfigured regardless of its state if working
with the 'reconfigure target, or to force removal of package files
even if its hash doesn't match in the 'purge' and 'remove' targets.
*-r* 'rootdir':: *-r* 'rootdir'::
Sets the 'root' directory. By default the root directory is Sets the 'root' directory. By default the root directory is
@ -96,7 +98,8 @@ Please note that all targets are *case insensitive*.
metadata directory ( /var/db/xbps/metadata/'pkgname' ) and will metadata directory ( /var/db/xbps/metadata/'pkgname' ) and will
remove configuration (if they were not modified by the user) and remove configuration (if they were not modified by the user) and
metadata files. The package will be fully removed from the system once metadata files. The package will be fully removed from the system once
it has been *purged*. it has been *purged*. If *-f* option is used, configuration files
that have been modified *WILL BE REMOVED, BEWARE WITH THIS!*.
*reconfigure 'pkgname' | 'all'*:: *reconfigure 'pkgname' | 'all'*::
Reconfigure an *unpacked* package. Packages in this state are not Reconfigure an *unpacked* package. Packages in this state are not
@ -113,7 +116,8 @@ Please note that all targets are *case insensitive*.
database. Configuration files, its metadata directory/files and database. Configuration files, its metadata directory/files and
its information in the package database are preserved. To fully remove its information in the package database are preserved. To fully remove
a package in *config-files* state, it must be *purged* with the a package in *config-files* state, it must be *purged* with the
*purge* command. *purge* command. If *-f* option is used, package files will be removed
even if its SHA256 hash doesn't match.
*show 'pkgname'*:: *show 'pkgname'*::
Shows information for installed package 'pkgname'. This will print Shows information for installed package 'pkgname'. This will print

View File

@ -42,7 +42,8 @@
* -# Its <b>pre-remove</b> target specified in the REMOVE script * -# Its <b>pre-remove</b> target specified in the REMOVE script
* will be executed. * will be executed.
* -# Its files, dirs and links will be removed. Modified files (not * -# Its files, dirs and links will be removed. Modified files (not
* matching its sha256 hash) will always be preserved. * matching its sha256 hash) are preserved, unless XBPS_FLAG_FORCE
* is set via xbps_set_flags().
* -# Its <b>post-remove</b> target specified in the REMOVE script * -# Its <b>post-remove</b> target specified in the REMOVE script
* will be executed. * will be executed.
* -# Its requiredby objects will be removed from the installed packages * -# Its requiredby objects will be removed from the installed packages
@ -123,13 +124,24 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
rv = 0; rv = 0;
continue; continue;
} else if (rv == ERANGE) { } else if (rv == ERANGE) {
if (flags & XBPS_FLAG_VERBOSE)
fprintf(stderr,
"WARNING: '%s' SHA256 mismatch, "
"preserving...\n", file);
rv = 0; rv = 0;
free(path); if (flags & XBPS_FLAG_VERBOSE) {
continue; if (flags & XBPS_FLAG_FORCE) {
fprintf(stderr,
"WARNING: '%s' SHA256 "
"mismatch, forcing "
"removal...\n", file);
} else {
fprintf(stderr,
"WARNING: '%s' SHA256 "
"mismatch, preserving...\n",
file);
}
}
if ((flags & XBPS_FLAG_FORCE) == 0) {
free(path);
continue;
}
} else if (rv != 0 && rv != ERANGE) { } else if (rv != 0 && rv != ERANGE) {
free(path); free(path);
break; break;