Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=2db1cc5675366c88e3531b04c756768b59f1e953
commit 2db1cc5675366c88e3531b04c756768b59f1e953 Author: Lord Fener <[email protected]> Date: Sun May 1 15:04:03 2011 +0200 Pacman fsck I made a patch for pacman to add the option to check if the files of a package are still were they should be, diff --git a/src/pacman-g2/conf.h b/src/pacman-g2/conf.h index 2a36a12..89a306c 100644 --- a/src/pacman-g2/conf.h +++ b/src/pacman-g2/conf.h @@ -46,6 +46,7 @@ typedef struct __config_t { unsigned short op_q_search; unsigned short op_q_changelog; unsigned short op_q_test; + unsigned short op_q_fsck; unsigned short op_s_clean; unsigned short op_s_dependsonly; unsigned short op_s_downloadonly; diff --git a/src/pacman-g2/package.c b/src/pacman-g2/package.c index b2412dc..3b34a1f 100644 --- a/src/pacman-g2/package.c +++ b/src/pacman-g2/package.c @@ -25,6 +25,7 @@ #include <limits.h> #include <sys/stat.h> #include <libintl.h> +#include <errno.h> #include <pacman.h> /* pacman-g2 */ @@ -202,4 +203,26 @@ void dump_pkg_changelog(char *clfile, char *pkgname) return; } } + +/* check if the package's files are still were they should be */ +void pkg_fsck(PM_PKG *pkg){ + char *pkgname, path[PATH_MAX]; + PM_LIST *i, *pkgfiles; + + pkgname = pacman_pkg_getinfo(pkg, PM_PKG_NAME); + pkgfiles = pacman_pkg_getinfo(pkg, PM_PKG_FILES); + + /* maybe this can be used also to get more information about files */ + struct stat buf; + + for(i = pkgfiles; i; i = pacman_list_next(i)) { + snprintf(path, PATH_MAX, "/%s", (char *)pacman_list_getdata(i)); + if(lstat(path, &buf) == -1) { + fprintf(stdout, "%s %s\t%s.\n", pkgname, path, strerror(errno)); + } + } + + fflush(stdout); +} + /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman-g2/package.h b/src/pacman-g2/package.h index 494ac8b..e8215b7 100644 --- a/src/pacman-g2/package.h +++ b/src/pacman-g2/package.h @@ -26,6 +26,7 @@ void dump_pkg_sync(PM_PKG *pkg, char *treename); void dump_pkg_files(PM_PKG *pkg); void dump_pkg_changelog(char *clfile, char *pkgname); +void pkg_fsck(PM_PKG *pkg); #define FREEPKG(p) { pacman_pkg_free(p); p = NULL; } diff --git a/src/pacman-g2/pacman-g2.c b/src/pacman-g2/pacman-g2.c index 6ed46e0..1e12616 100644 --- a/src/pacman-g2/pacman-g2.c +++ b/src/pacman-g2/pacman-g2.c @@ -148,6 +148,7 @@ static void usage(int op, char *myname) printf(_(" as a dependency\n")); printf(_(" -e, --orphans list all packages that were installed as a dependency\n")); printf(_(" and are not required by any other packages\n")); + printf(_(" -f, --fsck check the integrity of packages' files\n")); printf(_(" -g, --groups view all members of a package group\n")); printf(_(" -i, --info view package information\n")); printf(_(" -l, --list list the contents of the queried package\n")); @@ -272,6 +273,7 @@ static int parseargs(int argc, char *argv[]) {"dependsonly",no_argument, 0, 'e'}, {"orphans", no_argument, 0, 'e'}, {"force", no_argument, 0, 'f'}, + {"fsck", no_argument, 0, 'f'}, {"groups", no_argument, 0, 'g'}, {"help", no_argument, 0, 'h'}, {"info", no_argument, 0, 'i'}, @@ -362,7 +364,7 @@ static int parseargs(int argc, char *argv[]) break; case 'd': config->flags |= PM_TRANS_FLAG_NODEPS; config->op_q_orphans_deps = 1; break; case 'e': config->op_q_orphans = 1; config->flags |= PM_TRANS_FLAG_DEPENDSONLY; break; - case 'f': config->flags |= PM_TRANS_FLAG_FORCE; break; + case 'f': config->flags |= PM_TRANS_FLAG_FORCE; config->op_q_fsck = 1; break; case 'g': config->group++; break; case 'h': config->help = 1; break; case 'i': diff --git a/src/pacman-g2/query.c b/src/pacman-g2/query.c index 52a290c..c5483ee 100644 --- a/src/pacman-g2/query.c +++ b/src/pacman-g2/query.c @@ -195,7 +195,7 @@ int querypkg(list_t *targets) pkgname = pacman_pkg_getinfo(tmpp, PM_PKG_NAME); pkgver = pacman_pkg_getinfo(tmpp, PM_PKG_VERSION); - if(config->op_q_orphans || config->op_q_foreign) { + if(config->op_q_orphans || config->op_q_foreign || config->op_q_fsck) { info = pacman_db_readpkg(db_local, pkgname); if(info == NULL) { /* something weird happened */ @@ -236,6 +236,9 @@ int querypkg(list_t *targets) MSG(NL, "%s %s\n", pkgname, pkgver); } } + if(config->op_q_fsck) { + pkg_fsck(tmpp); + } } else { MSG(NL, "%s %s\n", pkgname, pkgver); } @@ -254,7 +257,7 @@ int querypkg(list_t *targets) } /* find a target */ - if(config->op_q_changelog || config->op_q_info || config->op_q_list) { + if(config->op_q_changelog || config->op_q_info || config->op_q_list || config->op_q_fsck) { if(config->op_q_changelog) { char *dbpath, changelog[PATH_MAX]; pacman_get_option(PM_OPT_DBPATH, (long *)&dbpath); @@ -271,6 +274,9 @@ int querypkg(list_t *targets) if(config->op_q_list) { dump_pkg_files(info); } + if(config->op_q_fsck) { + pkg_fsck(info); + } } else { char *pkgname = pacman_pkg_getinfo(info, PM_PKG_NAME); char *pkgver = pacman_pkg_getinfo(info, PM_PKG_VERSION); _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
