[CVS] RPM: rpm/tools/ .cvsignore Makefile.am augtool.c augtool.h
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 14-Jun-2009 18:13:21 Branch: HEAD Handle: 2009061416132100 Added files: rpm/tools augtool.c augtool.h Modified files: rpm/tools .cvsignore Makefile.am Log: - augeas: swipe a copy of augtool.c/internal.h for reworking. Summary: RevisionChanges Path 1.31+1 -0 rpm/tools/.cvsignore 2.127 +5 -2 rpm/tools/Makefile.am 2.1 +717 -0 rpm/tools/augtool.c 2.1 +525 -0 rpm/tools/augtool.h patch -p0 '@@ .' Index: rpm/tools/.cvsignore $ cvs diff -u -r1.30 -r1.31 .cvsignore --- rpm/tools/.cvsignore 13 May 2009 23:54:57 - 1.30 +++ rpm/tools/.cvsignore 14 Jun 2009 16:13:21 - 1.31 @@ -5,6 +5,7 @@ .libs *.gcda *.gcno +augtool convertdb1 db_tool debugedit @@ . patch -p0 '@@ .' Index: rpm/tools/Makefile.am $ cvs diff -u -r2.126 -r2.127 Makefile.am --- rpm/tools/Makefile.am 3 Jun 2009 09:20:58 - 2.126 +++ rpm/tools/Makefile.am 14 Jun 2009 16:13:21 - 2.127 @@ -18,9 +18,9 @@ @WITH_PCRE_CPPFLAGS@ \ @WITH_XAR_CPPFLAGS@ -EXTRA_DIST = hashtab.h +EXTRA_DIST = augtool.h hashtab.h -EXTRA_PROGRAMS = rpmkey debugedit +EXTRA_PROGRAMS = augtool debugedit rpmkey RPMMISC_LDADD_COMMON = \ $(top_builddir)/misc/librpmmisc.la \ @@ -50,6 +50,9 @@ rpmcmp rpmdeps @WITH_KEYUTILS_RPMKEY@ @WITH_LIBELF_DEBUGEDIT@ dist_man_MANS = rpmgrep.1 +augtool_SOURCES =augtool.c +augtool_LDADD = $(RPM_LDADD_COMMON) -lreadline + debugedit_SOURCES = debugedit.c hashtab.c debugedit_LDADD =$(RPM_LDADD_COMMON) @@ . patch -p0 '@@ .' Index: rpm/tools/augtool.c $ cvs diff -u -r0 -r2.1 augtool.c --- /dev/null 2009-06-14 18:11:00 +0200 +++ augtool.c 2009-06-14 18:13:21 +0200 @@ -0,0 +1,717 @@ +/* + * augtool.c: + * + * Copyright (C) 2007, 2008 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: David Lutterkort dlut...@redhat.com + */ + +#include config.h +#include augeas.h +#include augtool.h + +#include readline/readline.h +#include readline/history.h +#include argz.h +#include getopt.h +#include limits.h +#include ctype.h + +struct command { +const char *name; +int minargs; +int maxargs; +int(*handler) (char *args[]); +const char *synopsis; +const char *help; +}; + +static const struct command const commands[]; + +static augeas *aug = NULL; +static const char *const progname = augtool; +static unsigned int flags = AUG_NONE; +const char *root = NULL; +char *loadpath = NULL; + + +static char *cleanstr(char *path, const char sep) { +if (path == NULL || strlen(path) == 0) +return path; +char *e = path + strlen(path) - 1; +while (e = path (*e == sep || isspace(*e))) +*e-- = '\0'; +return path; +} + +static char *cleanpath(char *path) { +return cleanstr(path, SEP); +} + +/* + * Dup PATH and split it into a directory and basename. The returned value + * points to the copy of PATH. Adding strlen(PATH)+1 to it gives the + * basename. + * + * If PATH can not be split, returns NULL + */ +ATTRIBUTE_UNUSED +static char *pathsplit(const char *path) { +char *ppath = strdup(path); +char *pend = strrchr(ppath, SEP); + +if (pend == NULL || pend == ppath) { +free(ppath); +return NULL; +} +*pend = '\0'; +return
[CVS] RPM: rpm/tools/ Makefile.am augtool.c augtool.h
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 14-Jun-2009 19:09:13 Branch: HEAD Handle: 2009061417091300 Modified files: rpm/tools Makefile.am augtool.c Removed files: rpm/tools augtool.h Log: - augtool: merge augtool.h into augtool.c and eliminate. Summary: RevisionChanges Path 2.128 +1 -1 rpm/tools/Makefile.am 2.2 +101 -53rpm/tools/augtool.c 2.2 +0 -525rpm/tools/augtool.h patch -p0 '@@ .' Index: rpm/tools/Makefile.am $ cvs diff -u -r2.127 -r2.128 Makefile.am --- rpm/tools/Makefile.am 14 Jun 2009 16:13:21 - 2.127 +++ rpm/tools/Makefile.am 14 Jun 2009 17:09:13 - 2.128 @@ -18,7 +18,7 @@ @WITH_PCRE_CPPFLAGS@ \ @WITH_XAR_CPPFLAGS@ -EXTRA_DIST = augtool.h hashtab.h +EXTRA_DIST = hashtab.h EXTRA_PROGRAMS = augtool debugedit rpmkey @@ . patch -p0 '@@ .' Index: rpm/tools/augtool.c $ cvs diff -u -r2.1 -r2.2 augtool.c --- rpm/tools/augtool.c 14 Jun 2009 16:13:21 - 2.1 +++ rpm/tools/augtool.c 14 Jun 2009 17:09:13 - 2.2 @@ -20,16 +20,95 @@ * Author: David Lutterkort dlut...@redhat.com */ -#include config.h -#include augeas.h -#include augtool.h +#include system.h +#include augeas.h #include readline/readline.h #include readline/history.h #include argz.h #include getopt.h -#include limits.h -#include ctype.h + +#include debug.h + +/* = internal.h */ + +#if !defined(SEP) +#define SEP '/' +#endif + +#define DATADIR /usr/share + +/* Define: AUGEAS_LENS_DIR + * The default location for lens definitions */ +#define AUGEAS_LENS_DIR DATADIR /augeas/lenses + +/* The directory where we install lenses distribute with Augeas */ +#define AUGEAS_LENS_DIST_DIR DATADIR /augeas/lenses/dist + +/* Define: AUGEAS_ROOT_ENV + * The env var that points to the chroot holding files we may modify. + * Mostly useful for testing */ +#define AUGEAS_ROOT_ENV AUGEAS_ROOT + +/* Define: AUGEAS_FILES_TREE + * The root for actual file contents */ +#define AUGEAS_FILES_TREE /files + +/* Define: AUGEAS_META_TREE + * Augeas reports some information in this subtree */ +#define AUGEAS_META_TREE /augeas + +/* Define: AUGEAS_META_FILES + * Information about files */ +#define AUGEAS_META_FILES AUGEAS_META_TREE AUGEAS_FILES_TREE + +/* Define: AUGEAS_META_ROOT + * The root directory */ +#define AUGEAS_META_ROOT AUGEAS_META_TREE /root + +/* Define: AUGEAS_META_SAVE_MODE + * How we save files. One of 'backup', 'overwrite' or 'newfile' */ +#define AUGEAS_META_SAVE_MODE AUGEAS_META_TREE /save + +/* Define: AUGEAS_CLONE_IF_RENAME_FAILS + * Control what save does when renaming the temporary file to its final + * destination fails with EXDEV or EBUSY: when this tree node exists, copy + * the file contents. If it is not present, simply give up and report an + * error. */ +#define AUGEAS_COPY_IF_RENAME_FAILS \ +AUGEAS_META_SAVE_MODE /copy_if_rename_fails + +/* A hierarchy where we record certain 'events', e.g. which tree + * nodes actually gotsaved into files */ +#define AUGEAS_EVENTS AUGEAS_META_TREE /events + +#define AUGEAS_EVENTS_SAVED AUGEAS_EVENTS /saved + +/* Where to put information about parsing of path expressions */ +#define AUGEAS_META_PATHX AUGEAS_META_TREE /pathx + +/* Define: AUGEAS_LENS_ENV + * Name of env var that contains list of paths to search for additional + spec files */ +#define AUGEAS_LENS_ENV AUGEAS_LENS_LIB + +/* Define: MAX_ENV_SIZE + * Fairly arbitrary bound on the length of the path we + * accept from AUGEAS_SPEC_ENV */ +#define MAX_ENV_SIZE 4096 + +/* Define: PATH_SEP_CHAR + * Character separating paths in a list of paths */ +#define PATH_SEP_CHAR ':' + +/* Constants for setting the save mode via the augeas path at + * AUGEAS_META_SAVE_MODE */ +#define AUG_SAVE_BACKUP_TEXT backup +#define AUG_SAVE_NEWFILE_TEXT newfile +#define AUG_SAVE_NOOP_TEXT noop +#define AUG_SAVE_OVERWRITE_TEXT overwrite + +/* = */ struct command { const char *name; @@ -48,7 +127,6 @@ const char *root = NULL; char *loadpath = NULL; - static char *cleanstr(char *path, const char sep) { if (path == NULL || strlen(path) == 0) return path;
[CVS] RPM: rpm/tools/ augtool.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 14-Jun-2009 19:36:54 Branch: HEAD Handle: 2009061417365300 Modified files: rpm/tools augtool.c Log: - augtool: use the no brainer rpmaug wrapped methods instead. Summary: RevisionChanges Path 2.3 +135 -93rpm/tools/augtool.c patch -p0 '@@ .' Index: rpm/tools/augtool.c $ cvs diff -u -r2.2 -r2.3 augtool.c --- rpm/tools/augtool.c 14 Jun 2009 17:09:13 - 2.2 +++ rpm/tools/augtool.c 14 Jun 2009 17:36:53 - 2.3 @@ -22,12 +22,19 @@ #include system.h -#include augeas.h #include readline/readline.h #include readline/history.h #include argz.h #include getopt.h +#define _RPMIOB_INTERNAL +#include rpmiotypes.h +#include poptIO.h + +#include augeas.h +#define _RPMAUG_INTERNAL +#include rpmaug.h + #include debug.h /* = internal.h */ @@ -121,13 +128,16 @@ static const struct command const commands[]; -static augeas *aug = NULL; +/*...@unchecked@*/ +static rpmaug aug; + static const char *const progname = augtool; static unsigned int flags = AUG_NONE; const char *root = NULL; char *loadpath = NULL; -static char *cleanstr(char *path, const char sep) { +static char *cleanstr(char *path, const char sep) +{ if (path == NULL || strlen(path) == 0) return path; char *e = path + strlen(path) - 1; @@ -136,11 +146,13 @@ return path; } -static char *cleanpath(char *path) { +static char *cleanpath(char *path) +{ return cleanstr(path, SEP); } -static char *ls_pattern(const char *path) { +static char *ls_pattern(const char *path) +{ char *q; int r; @@ -153,18 +165,20 @@ return q; } -static int child_count(const char *path) { +static int child_count(const char *path) +{ char *q = ls_pattern(path); int cnt; if (q == NULL) return 0; -cnt = aug_match(aug, q, NULL); +cnt = rpmaugMatch(aug, q, NULL); free(q); return cnt; } -static int cmd_ls(char *args[]) { +static int cmd_ls(char *args[]) +{ int cnt; char *path = cleanpath(args[0]); char **paths; @@ -173,12 +187,12 @@ path = ls_pattern(path); if (path == NULL) return -1; -cnt = aug_match(aug, path, paths); +cnt = rpmaugMatch(aug, path, paths); for (i=0; i cnt; i++) { const char *val; const char *basnam = strrchr(paths[i], SEP); int dir = child_count(paths[i]); -aug_get(aug, paths[i], val); +rpmaugGet(aug, paths[i], val); basnam = (basnam == NULL) ? paths[i] : basnam + 1; if (val == NULL) val = (none); @@ -191,7 +205,8 @@ return 0; } -static int cmd_match(char *args[]) { +static int cmd_match(char *args[]) +{ int cnt; const char *pattern = cleanpath(args[0]); char **matches; @@ -199,7 +214,7 @@ int result = 0; int i; -cnt = aug_match(aug, pattern, matches); +cnt = rpmaugMatch(aug, pattern, matches); if (cnt 0) { printf( (error matching %s)\n, pattern); result = -1; @@ -212,7 +227,7 @@ for (i=0; i cnt; i++) { const char *val; -aug_get(aug, matches[i], val); +rpmaugGet(aug, matches[i], val); if (val == NULL) val = (none); if (filter) { @@ -229,49 +244,54 @@ return result; } -static int cmd_rm(char *args[]) { +static int cmd_rm(char *args[]) +{ int cnt; const char *path = cleanpath(args[0]); printf(rm : %s, path); -cnt = aug_rm(aug, path); +cnt = rpmaugRm(aug, path); printf( %d\n, cnt); return 0; } -static int cmd_mv(char *args[]) { +static int cmd_mv(char *args[]) +{ const char *src = cleanpath(args[0]); const char *dst = cleanpath(args[1]); int r; -r = aug_mv(aug, src, dst); +r = rpmaugMv(aug, src, dst); if (r == -1) printf(Failed\n); return r; } -static int cmd_set(char *args[]) { +static int cmd_set(char *args[]) +{ const char *path = cleanpath(args[0]); const char *val = args[1]; int r; -r = aug_set(aug, path, val); +r = rpmaugSet(aug, path, val); if (r == -1)
[CVS] RPM: rpm/ CHANGES rpm/lib/ rpmfc.c rpm/rpmio/ argv.c argv.h
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 14-Jun-2009 20:17:06 Branch: HEAD Handle: 2009061418170600 Modified files: rpm CHANGES rpm/lib rpmfc.c rpm/rpmio argv.c argv.h Log: - argv: add a separator character argument to argvJoin. Summary: RevisionChanges Path 1.3024 +1 -0 rpm/CHANGES 1.66+1 -1 rpm/lib/rpmfc.c 1.19+2 -2 rpm/rpmio/argv.c 1.15+2 -1 rpm/rpmio/argv.h patch -p0 '@@ .' Index: rpm/CHANGES $ cvs diff -u -r1.3023 -r1.3024 CHANGES --- rpm/CHANGES 13 Jun 2009 20:05:35 - 1.3023 +++ rpm/CHANGES 14 Jun 2009 18:17:06 - 1.3024 @@ -1,5 +1,6 @@ 5.2b1 - 5.3a1 +- jbj: argv: add a separator character argument to argvJoin. - jbj: augeas: add no brainer rpmaug wrappings onto augeas methods. - jbj: rpmbuild: fix: ensure dependency EVR strings have only 0 or 1 dashes. - jbj: augeas: add aug_init() and aug_close() calls to the rpmaug wrapper. @@ . patch -p0 '@@ .' Index: rpm/lib/rpmfc.c $ cvs diff -u -r1.65 -r1.66 rpmfc.c --- rpm/lib/rpmfc.c 11 Apr 2009 14:17:58 - 1.65 +++ rpm/lib/rpmfc.c 14 Jun 2009 18:17:06 - 1.66 @@ -206,7 +206,7 @@ (unsigned)child, (unsigned)reaped, status); if (failNonZero (!WIFEXITED(status) || WEXITSTATUS(status))) { - const char *cmd = argvJoin(argv); + const char *cmd = argvJoin(argv, ' '); int rc = (WIFEXITED(status) ? WEXITSTATUS(status) : -1); rpmlog(RPMLOG_ERR, _(Command \%s\ failed, exit(%d)\n), cmd, rc); @@ . patch -p0 '@@ .' Index: rpm/rpmio/argv.c $ cvs diff -u -r1.18 -r1.19 argv.c --- rpm/rpmio/argv.c 19 Feb 2009 18:54:42 - 1.18 +++ rpm/rpmio/argv.c 14 Jun 2009 18:17:06 - 1.19 @@ -263,7 +263,7 @@ /*...@=nullstate@*/ } -char * argvJoin(ARGV_t argv) +char * argvJoin(ARGV_t argv, char sep) { size_t nb = 0; int argc; @@ -280,7 +280,7 @@ *te = '\0'; for (argc = 0; argv[argc] != NULL; argc++) { if (argc != 0) - *te++ = ' '; + *te++ = sep; te = stpcpy(te, argv[argc]); } *te = '\0'; @@ . patch -p0 '@@ .' Index: rpm/rpmio/argv.h $ cvs diff -u -r1.14 -r1.15 argv.h --- rpm/rpmio/argv.h 1 Oct 2008 15:53:17 - 1.14 +++ rpm/rpmio/argv.h 14 Jun 2009 18:17:06 - 1.15 @@ -219,10 +219,11 @@ /** * Concatenate an argv array into a string. * @param argv argv array + * @param separg separator * @return concatenated string */ /*...@only@*/ -char * argvJoin(ARGV_t argv) +char * argvJoin(ARGV_t argv, char sep) /*...@*/; /** @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org