2 ===================================================================
3 RCS file: rpm/CHANGES,v
4 retrieving revision 1.1130.2.23
5 retrieving revision 1.1130.2.27
6 diff -u -u -r1.1130.2.23 -r1.1130.2.27
7 --- rpm/CHANGES 17 Sep 2002 15:18:23 -0000 1.1130.2.23
8 +++ rpm/CHANGES 6 Nov 2002 17:28:19 -0000 1.1130.2.27
10 - fix: register SIGCHLD handler before forking (#73134).
11 - better diagnostics on failed header parsing.
14 + - fix: make sure that psm->child pid is set before SIGCHLD is handled.
15 + - fix: use size_t consistently, avoid segfault on ia64.
16 + - use %%{_lib} for libraries.
17 + - fix: permit build with --disable-nls (#76258).
18 + - backport db-4.1.17 changes.
19 + - add _noDirTokens macro for 6x builds.
22 - solaris: translate i86pc to i386 (#57182).
24 ===================================================================
25 RCS file: rpm/autogen.sh,v
26 retrieving revision 2.39
27 retrieving revision 2.39.2.1
28 diff -u -u -r2.39 -r2.39.2.1
29 --- rpm/autogen.sh 8 Aug 2002 22:20:26 -0000 2.39
30 +++ rpm/autogen.sh 25 Oct 2002 17:31:37 -0000 2.39.2.1
34 LTV="libtoolize (GNU libtool) 1.4.2"
35 -ACV="autoconf (GNU Autoconf) 2.53"
36 +ACV="autoconf (GNU Autoconf) 2.54"
37 AMV="automake (GNU automake) 1.6.3"
39 This script documents the versions of the tools I'm using to build rpm:
45 Simply edit this script to change the libtool/autoconf/automake versions
46 checked if you need to, as rpm should build (and has built) with all
47 recent versions of libtool/autoconf/automake.
49 ===================================================================
50 RCS file: rpm/configure.ac,v
51 retrieving revision 2.6.2.2
52 retrieving revision 2.6.2.3
53 diff -u -u -r2.6.2.2 -r2.6.2.3
54 --- rpm/configure.ac 22 Aug 2002 19:18:56 -0000 2.6.2.2
55 +++ rpm/configure.ac 9 Oct 2002 19:05:38 -0000 2.6.2.3
57 dnl Determine the canonical arch-vendor-os for the build machine
58 case "${build_cpu}" in
59 *86) RPMCANONARCH=i386 ;;
60 +x86_64*) RPMCANONARCH=x86_64 ;;
61 alpha*) RPMCANONARCH=alpha ;;
62 sparc*) RPMCANONARCH=sparc ;;
63 ia64*) RPMCANONARCH=ia64 ;;
64 Index: installplatform
65 ===================================================================
66 RCS file: rpm/installplatform,v
67 retrieving revision 2.34
68 retrieving revision 2.34.2.2
69 diff -u -u -r2.34 -r2.34.2.2
70 --- rpm/installplatform 30 Jul 2002 17:07:39 -0000 2.34
71 +++ rpm/installplatform 11 Oct 2002 17:23:27 -0000 2.34.2.2
73 alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;;
74 sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
75 powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6]\|$\)_ppc64\1_' ;;
76 + s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;;
81 sparc-linux) MULTILIBNO=1 ;;
82 sparcv9-linux) MULTILIBNO=1 ;;
83 sparc64-linux) ARCH_INSTALL_POST=${pkglibdir}/brp-sparc64-linux; LIB=lib64; MULTILIBNO=2 ;;
84 + s390-linux) MULTILIBNO=1 ;;
85 + s390x-linux) LIB=lib64; MULTILIBNO=2 ;;
86 + ppc-linux) MULTILIBNO=1 ;;
87 + ppc64-linux) LIB=lib64; MULTILIBNO=2 ;;
88 + i?86-linux|athlon-linux) MULTILIBNO=1 ;;
89 + x86_64-linux) LIB=lib64; MULTILIBNO=2 ;;
92 if [ -n "$MULTILIBNO" ]; then
94 ===================================================================
95 RCS file: rpm/rpmqv.c,v
96 retrieving revision 1.98
97 retrieving revision 1.98.2.2
98 diff -u -u -r1.98 -r1.98.2.2
99 --- rpm/rpmqv.c 6 Aug 2002 01:41:46 -0000 1.98
100 +++ rpm/rpmqv.c 6 Nov 2002 17:28:19 -0000 1.98.2.2
102 freeSpecVec = freeSpec;
105 +#if defined(ENABLE_NLS)
106 /* set up the correct locale */
107 (void) setlocale(LC_ALL, "" );
111 bindtextdomain(PACKAGE, LOCALEDIR);
115 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
121 + _noDirTokens = rpmExpandNumeric("%{?_noDirTokens}");
124 (void) rpmtsSetRootDir(ts, rpmcliRootDir);
126 Index: beecrypt/base64.c
127 ===================================================================
128 RCS file: rpm/beecrypt/base64.c,v
129 retrieving revision 1.20
130 retrieving revision 1.20.2.1
131 diff -u -u -r1.20 -r1.20.2.1
132 --- rpm/beecrypt/base64.c 2 Jul 2002 23:54:35 -0000 1.20
133 +++ rpm/beecrypt/base64.c 9 Oct 2002 19:05:39 -0000 1.20.2.1
137 /*@-internalglobs -modfilesys @*/
138 -char * b64encode (const void * data, int ns)
139 +char * b64encode (const void * data, size_t ns)
141 static char b64enc[] =
142 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
151 fprintf(stderr, "%7u %02x %02x %02x -> %02x %02x %02x %02x\n",
153 #define CRC24_POLY 0x1864cfbL
156 -char * b64crc (const unsigned char * data, int ns)
157 +char * b64crc (const unsigned char * data, size_t ns)
159 const unsigned char *s = data;
160 uint32 crc = CRC24_INIT;
163 /*@-internalglobs -modfilesys @*/
165 -int b64decode (const char * s, void ** datap, int *lenp)
166 +int b64decode (const char * s, void ** datap, size_t *lenp)
168 unsigned char b64dec[256];
169 const unsigned char *t;
170 Index: beecrypt/base64.h
171 ===================================================================
172 RCS file: rpm/beecrypt/base64.h,v
173 retrieving revision 1.14
174 retrieving revision 1.14.2.2
175 diff -u -u -r1.14 -r1.14.2.2
176 --- rpm/beecrypt/base64.h 13 May 2002 22:45:31 -0000 1.14
177 +++ rpm/beecrypt/base64.h 6 Nov 2002 17:28:19 -0000 1.14.2.2
179 * @return (malloc'd) base64 string
181 BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
182 -char * b64encode (const void * data, int ns)
183 +char * b64encode (const void * data, size_t ns)
187 * Encode crc of binary input data into 5 bytes of base64 output.
188 * @param data binary data
189 - * @param ns crc of data
190 + * @param ns no. bytes of binary data
191 * @return (malloc'd) base64 string
193 BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
194 -char * b64crc (const unsigned char * data, int ns)
195 +char * b64crc (const unsigned char * data, size_t ns)
200 * @return 0 on success, 1: s == NULL, 2: bad length, 3: bad char
202 BEECRYPTAPI /*@unused@*/
203 -int b64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ int *lenp)
204 +int b64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ size_t *lenp)
205 /*@modifies *datap, *lenp @*/;
209 ===================================================================
210 RCS file: rpm/db3/configure,v
211 retrieving revision 1.20
212 retrieving revision 1.20.2.1
213 diff -u -u -r1.20 -r1.20.2.1
214 --- rpm/db3/configure 30 Jul 2002 16:39:09 -0000 1.20
215 +++ rpm/db3/configure 6 Nov 2002 17:28:20 -0000 1.20.2.1
220 -# XXX hacks to get db-3.3.4 to configure properly
221 -#ln -sf ../dist $db_dist/../db/dist
222 -#ln -sf ../dist $db_dist
224 # XXX edit CFLAGS= ... out of invocation args ???
225 ARGS="`echo $* | sed -e 's% [^ ]*CFLAGS=[^ ]*%%' -e 's% -[^-][^ ]*%%g' -e 's%--cache-file=.*$%%'`"
228 --enable-shared --enable-static --enable-rpc \
229 --with-uniquename=_rpmdb --srcdir=$db_dist
231 -# XXX hack to get db-3.3.4 to configure properly
232 -#rm -f $db_dist/../db/dist $db_dist/dist
234 mv Makefile Makefile.orig
235 -cat Makefile.orig | sed -e 's/ -g$/ -g -O2/' -e '/^install:/c\
236 +cat Makefile.orig | sed -e '/^install[:-]/c\
239 @echo $(OBJS) $(C_OBJS) \
241 distdir install check:\
243 -db3_install: all install_setip' > Makefile
244 +db4_install: all install_setip' > Makefile
247 cat db.h.orig | sed \
250 -e '/^#define db_create/i\
251 /*@-declundef -noparams -fcnuse@*/' \
252 - -e '/^#define db_xa_switch/a\
253 + -e '/^int txn_commit __P((/a\
254 /*@=declundef =noparams =fcnuse =fielduse =enummemuse =typeuse @*/' > db.h
256 # Generate manifest for rpmdb.
258 ===================================================================
259 RCS file: rpm/lib/formats.c,v
260 retrieving revision 2.71.2.1
261 retrieving revision 2.71.2.2
262 diff -u -u -r2.71.2.1 -r2.71.2.2
263 --- rpm/lib/formats.c 19 Aug 2002 22:21:20 -0000 2.71.2.1
264 +++ rpm/lib/formats.c 9 Oct 2002 19:05:39 -0000 2.71.2.2
279 - int nt = ((element + 2) / 3) * 4;
280 + size_t nt = ((element + 2) / 3) * 4;
285 ===================================================================
286 RCS file: rpm/lib/package.c,v
287 retrieving revision 2.112.2.10
288 retrieving revision 2.112.2.11
289 diff -u -u -r2.112.2.10 -r2.112.2.11
290 --- rpm/lib/package.c 17 Sep 2002 15:18:23 -0000 2.112.2.10
291 +++ rpm/lib/package.c 9 Oct 2002 19:05:39 -0000 2.112.2.11
293 if (uc > 0 && pvlen != uc) {
294 (void) snprintf(buf, sizeof(buf),
295 _("blob size(%d): BAD, 8 + 16 * il(%d) + dl(%d)\n"),
297 + (int)uc, (int)il, (int)dl);
302 memset(block, 0, sizeof(block));
303 if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {
304 (void) snprintf(buf, sizeof(buf),
305 - _("hdr size(%d): BAD, read returned %d\n"), sizeof(block), xx);
306 + _("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
309 if (memcmp(block, header_magic, sizeof(header_magic))) {
311 ===================================================================
312 RCS file: rpm/lib/poptALL.c,v
313 retrieving revision 2.10.2.2
314 retrieving revision 2.10.2.3
315 diff -u -u -r2.10.2.2 -r2.10.2.3
316 --- rpm/lib/poptALL.c 27 Aug 2002 20:42:17 -0000 2.10.2.2
317 +++ rpm/lib/poptALL.c 25 Oct 2002 17:31:37 -0000 2.10.2.3
322 -#if !defined(__LCLINT__)
323 +#if defined(ENABLE_NLS)
324 (void) setlocale(LC_ALL, "" );
327 +#define LOCALEDIR "/usr/share/locale"
329 (void) bindtextdomain(PACKAGE, LOCALEDIR);
330 (void) textdomain(PACKAGE);
333 ===================================================================
334 RCS file: rpm/lib/psm.c,v
335 retrieving revision 2.126.2.7
336 retrieving revision 2.126.2.9
337 diff -u -u -r2.126.2.7 -r2.126.2.9
338 --- rpm/lib/psm.c 17 Sep 2002 15:18:23 -0000 2.126.2.7
339 +++ rpm/lib/psm.c 9 Oct 2002 19:05:39 -0000 2.126.2.9
340 @@ -695,15 +695,19 @@
341 (void) sigaddset(&caught, signum);
345 - pid_t reaped = waitpid(0, &status, WNOHANG);
349 - for (i = 0; i < psmtbl.npsms; i++) {
350 - rpmpsm psm = psmtbl.psms[i];
351 - if (psm->child != reaped)
352 - /*@innercontinue@*/ continue;
355 + pid_t reaped = waitpid(0, &status, WNOHANG);
359 + /*@innerbreak@*/ break;
362 + for (i = 0; i < psmtbl.npsms; i++) {
363 + rpmpsm psm = psmtbl.psms[i];
364 + if (psm->child != reaped)
365 + /*@innercontinue@*/ continue;
369 @@ -712,11 +716,12 @@
373 - psm->reaped = reaped;
374 - psm->status = status;
375 - /*@innerbreak@*/ break;
376 + psm->reaped = reaped;
377 + psm->status = status;
378 + /*@innerbreak@*/ break;
381 - } /*@switchbreak@*/ break;
382 + /*@switchbreak@*/ break;
384 /*@switchbreak@*/ break;
390 - * Fork a new process.
391 - * @param psm package state machine data
392 - * @return fork(2) pid
394 -static pid_t psmFork(rpmpsm psm)
395 - /*@globals fileSystem, internalState @*/
396 - /*@modifies fileSystem, internalState @*/
400 - if ((pid = fork()) != 0) {
403 -fprintf(stderr, " Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, pid);
410 * Register a child reaper, then fork a child.
411 * @param psm package state machine data
412 * @return fork(2) pid
415 empty = psmtbl.npsms++;
418 if (psmtbl.psms) /* XXX can't happen */
419 psmtbl.psms[empty] = rpmpsmLink(psm, "psmRegister");
421 @@ -844,15 +828,24 @@
424 (void) enableSignal(SIGCHLD);
427 + if ((psm->child = fork()) != 0) {
430 +fprintf(stderr, " Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
434 (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
436 - return psmFork(psm);
441 * Unregister a child reaper.
443 -static int psmUnregister(rpmpsm psm, pid_t child)
444 +static int psmWaitUnregister(rpmpsm psm, pid_t child)
445 /*@globals psmtbl, fileSystem, internalState @*/
446 /*@modifies psmtbl, fileSystem, internalState @*/
449 (void) sigfillset(&newMask); /* block all signals */
450 (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
453 + while (psm->reaped != psm->child) {
454 + (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
455 + sleep(1); /* XXX sleep guarantees loop traversal. */
456 + (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
462 +fprintf(stderr, " Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
466 for (i = 0; i < psmtbl.npsms; i++) {
467 if (psmtbl.psms[i] == NULL)
472 - * Return reaped pid safely (i.e. with signals blocked).
473 - * @param psm package state machine data
476 -static inline pid_t psmGetReaped(rpmpsm psm)
477 - /*@globals fileSystem @*/
478 - /*@modifies fileSystem @*/
480 - sigset_t newMask, oldMask;
483 - (void) sigfillset(&newMask); /* block all signals */
484 - (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
485 - reaped = psm->reaped;
486 - (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
491 * Wait for child process to be reaped.
492 * @param psm package state machine data
495 /*@modifies psm, fileSystem, internalState @*/
499 - while (psmGetReaped(psm) == 0)
504 -fprintf(stderr, " Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
506 - (void) psmUnregister(psm, psm->child);
507 + (void) psmWaitUnregister(psm, psm->child);
510 psm->reaped = waitpid(psm->child, &psm->status, 0);
514 const char *n, *v, *r;
517 if (progArgv == NULL && script == NULL)
519 @@ -1119,8 +1097,7 @@
520 if (out == NULL) return RPMRC_FAIL; /* XXX can't happen */
523 - pid = psmRegisterFork(psm);
525 + (void) psmRegisterFork(psm);
526 if (psm->child == 0) {
527 const char * rootDir;
530 ===================================================================
531 RCS file: rpm/lib/query.c,v
532 retrieving revision 2.138.2.8
533 retrieving revision 2.138.2.9
534 diff -u -u -r2.138.2.8 -r2.138.2.9
535 --- rpm/lib/query.c 17 Sep 2002 15:18:23 -0000 2.138.2.8
536 +++ rpm/lib/query.c 9 Oct 2002 19:05:39 -0000 2.138.2.9
540 if (qva->qva_flags & QUERY_FOR_DUMPFILES) {
541 - sprintf(te, "%s %d %d %s 0%o ", fn, fsize, fmtime, fmd5, fmode);
542 + sprintf(te, "%s %d %d %s 0%o ", fn, (int)fsize, fmtime, fmd5, fmode);
545 if (fuser && fgroup) {
547 ===================================================================
548 RCS file: rpm/lib/rpmcli.h,v
549 retrieving revision 2.47.2.2
550 retrieving revision 2.47.2.3
551 diff -u -u -r2.47.2.2 -r2.47.2.3
552 --- rpm/lib/rpmcli.h 17 Sep 2002 15:18:24 -0000 2.47.2.2
553 +++ rpm/lib/rpmcli.h 9 Oct 2002 19:05:39 -0000 2.47.2.3
555 * @param argv array of package file names (NULL terminated)
556 * @return 0 on success
558 -int rpmErase(rpmts ts, const struct rpmInstallArguments_s * ia,
559 +int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
560 /*@null@*/ const char ** argv)
561 /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
562 /*@modifies ts, ia, rpmGlobalMacroContext,
564 ===================================================================
565 RCS file: rpm/lib/rpmds.h,v
566 retrieving revision 2.36
567 retrieving revision 2.36.2.1
568 diff -u -u -r2.36 -r2.36.2.1
569 --- rpm/lib/rpmds.h 3 Aug 2002 22:31:39 -0000 2.36
570 +++ rpm/lib/rpmds.h 6 Nov 2002 17:28:20 -0000 2.36.2.1
573 * Set "Don't promote Epoch:" flag.
574 * @param ds dependency set
575 + * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
576 * @return previous "Don't promote Epoch:" flag
578 int rpmdsSetNoPromote(/*@null@*/ rpmds ds, int nopromote)
579 Index: lib/rpminstall.c
580 ===================================================================
581 RCS file: rpm/lib/rpminstall.c,v
582 retrieving revision 1.118.2.5
583 retrieving revision 1.118.2.6
584 diff -u -u -r1.118.2.5 -r1.118.2.6
585 --- rpm/lib/rpminstall.c 31 Aug 2002 22:30:22 -0000 1.118.2.5
586 +++ rpm/lib/rpminstall.c 9 Oct 2002 19:05:39 -0000 1.118.2.6
591 -int rpmErase(rpmts ts,
592 - const struct rpmInstallArguments_s * ia,
593 +int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
597 Index: lib/signature.c
598 ===================================================================
599 RCS file: rpm/lib/signature.c,v
600 retrieving revision 2.139.2.7
601 retrieving revision 2.139.2.8
602 diff -u -u -r2.139.2.7 -r2.139.2.8
603 --- rpm/lib/signature.c 17 Sep 2002 15:18:24 -0000 2.139.2.7
604 +++ rpm/lib/signature.c 9 Oct 2002 19:05:39 -0000 2.139.2.8
606 memset(block, 0, sizeof(block));
607 if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {
608 (void) snprintf(buf, sizeof(buf),
609 - _("sigh size(%d): BAD, read returned %d\n"), sizeof(block), xx);
610 + _("sigh size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
613 if (memcmp(block, header_magic, sizeof(header_magic))) {
615 dataStart = (unsigned char *) (pe + il);
616 if ((xx = timedRead(fd, (char *)pe, nb)) != nb) {
617 (void) snprintf(buf, sizeof(buf),
618 - _("sigh blob(%d): BAD, read returned %d\n"), nb, xx);
619 + _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx);
623 @@ -985,11 +985,11 @@
624 if (size != dig->nbytes) {
626 t = stpcpy(t, rpmSigString(res));
627 - sprintf(t, " Expected(%d) != (%d)\n", size, dig->nbytes);
628 + sprintf(t, " Expected(%d) != (%d)\n", (int)size, (int)dig->nbytes);
631 t = stpcpy(t, rpmSigString(res));
632 - sprintf(t, " (%d)", dig->nbytes);
633 + sprintf(t, " (%d)", (int)dig->nbytes);
637 Index: lib/transaction.c
638 ===================================================================
639 RCS file: rpm/lib/transaction.c,v
640 retrieving revision 1.274.2.6
641 retrieving revision 1.274.2.7
642 diff -u -u -r1.274.2.6 -r1.274.2.7
643 --- rpm/lib/transaction.c 31 Aug 2002 22:30:22 -0000 1.274.2.6
644 +++ rpm/lib/transaction.c 25 Oct 2002 17:31:38 -0000 1.274.2.7
645 @@ -1018,7 +1018,7 @@
649 -rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elments\n"), rpmtsNElements(ts));
650 +rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elements\n"), rpmtsNElements(ts));
651 ps = rpmtsProblems(ts);
652 /* The ordering doesn't matter here */
654 Index: python/_rpmdb.c
655 ===================================================================
656 RCS file: rpm/python/_rpmdb.c,v
657 retrieving revision 1.4
658 retrieving revision 1.4.2.1
659 diff -u -u -r1.4 -r1.4.2.1
660 --- rpm/python/_rpmdb.c 7 Jun 2002 13:12:34 -0000 1.4
661 +++ rpm/python/_rpmdb.c 6 Nov 2002 16:47:02 -0000 1.4.2.1
663 /* 40 = 4.0, 33 = 3.3; this will break if the second number is > 9 */
664 #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR)
666 -#define PY_BSDDB_VERSION "3.3.1"
667 +#define PY_BSDDB_VERSION "3.4.2"
669 -static char *rcs_id = "$Id$";
670 +static char *rcs_id = "$Id$";
676 case 0: /* successful, no error */ break;
680 #if INCOMPLETE_IS_WARNING
681 strcpy(errTxt, db_strerror(err));
683 errObj = DBIncompleteError;
688 case DB_KEYEMPTY: errObj = DBKeyEmptyError; break;
689 case DB_KEYEXIST: errObj = DBKeyExistError; break;
690 @@ -1023,12 +1025,29 @@
691 secondaryDB->associateCallback = callback;
692 secondaryDB->primaryDBType = _DB_get_type(self);
695 + /* PyEval_InitThreads is called here due to a quirk in python 1.5
696 + * - 2.2.1 (at least) according to Russell Williamson <merel@wt.net>:
697 + * The global interepreter lock is not initialized until the first
698 + * thread is created using thread.start_new_thread() or fork() is
699 + * called. that would cause the ALLOW_THREADS here to segfault due
700 + * to a null pointer reference if no threads or child processes
701 + * have been created. This works around that and is a no-op if
702 + * threads have already been initialized.
703 + * (see pybsddb-users mailing list post on 2002-08-07)
705 + PyEval_InitThreads();
706 MYDB_BEGIN_ALLOW_THREADS;
708 + err = self->db->associate(self->db, NULL,
710 + _db_associateCallback,
713 err = self->db->associate(self->db,
715 _db_associateCallback,
718 MYDB_END_ALLOW_THREADS;
721 @@ -1498,7 +1517,11 @@
724 MYDB_BEGIN_ALLOW_THREADS;
726 + err = self->db->open(self->db, NULL, filename, dbname, type, flags, mode);
728 err = self->db->open(self->db, filename, dbname, type, flags, mode);
730 MYDB_END_ALLOW_THREADS;
731 if (makeDBError(err)) {
733 @@ -1851,7 +1874,9 @@
734 MAKE_HASH_ENTRY(nkeys);
735 MAKE_HASH_ENTRY(ndata);
736 MAKE_HASH_ENTRY(pagesize);
738 MAKE_HASH_ENTRY(nelem);
740 MAKE_HASH_ENTRY(ffactor);
741 MAKE_HASH_ENTRY(buckets);
742 MAKE_HASH_ENTRY(free);
743 @@ -1896,7 +1921,7 @@
744 MAKE_QUEUE_ENTRY(re_len);
745 MAKE_QUEUE_ENTRY(re_pad);
746 MAKE_QUEUE_ENTRY(pgfree);
747 -#if (DBVER >= 31) && (DBVER < 40)
749 MAKE_QUEUE_ENTRY(start);
751 MAKE_QUEUE_ENTRY(first_recno);
752 @@ -2334,8 +2359,6 @@
753 if (!PyArg_ParseTuple(args, ":close"))
756 - CHECK_CURSOR_NOT_CLOSED(self);
758 if (self->dbc != NULL) {
759 MYDB_BEGIN_ALLOW_THREADS;
760 err = self->dbc->c_close(self->dbc);
761 @@ -2424,7 +2447,7 @@
763 DBC_get(DBCursorObject* self, PyObject* args, PyObject *kwargs)
767 PyObject* keyobj = NULL;
768 PyObject* dataobj = NULL;
769 PyObject* retval = NULL;
770 @@ -3309,7 +3332,7 @@
775 + u_int32_t flags = 0;
777 if (!PyArg_ParseTuple(args, "|i:lock_stat", &flags))
779 @@ -3337,7 +3360,9 @@
781 #define MAKE_ENTRY(name) _addIntToDict(d, #name, sp->st_##name)
788 MAKE_ENTRY(maxlocks);
789 @@ -3421,7 +3446,7 @@
796 if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags))
798 @@ -4116,7 +4141,9 @@
799 ADD_INT(d, DB_APPEND);
800 ADD_INT(d, DB_BEFORE);
801 ADD_INT(d, DB_CACHED_COUNTS);
803 ADD_INT(d, DB_CHECKPOINT);
806 ADD_INT(d, DB_COMMIT);
808 @@ -4124,7 +4151,9 @@
810 ADD_INT(d, DB_CONSUME_WAIT);
813 ADD_INT(d, DB_CURLSN);
815 ADD_INT(d, DB_CURRENT);
817 ADD_INT(d, DB_FAST_STAT);
818 @@ -4164,7 +4193,9 @@
819 ADD_INT(d, DB_DONOTINDEX);
823 ADD_INT(d, DB_INCOMPLETE);
825 ADD_INT(d, DB_KEYEMPTY);
826 ADD_INT(d, DB_KEYEXIST);
827 ADD_INT(d, DB_LOCK_DEADLOCK);
828 Index: python/header-py.c
829 ===================================================================
830 RCS file: rpm/python/header-py.c,v
831 retrieving revision 1.20
832 retrieving revision 1.20.2.1
833 diff -u -u -r1.20 -r1.20.2.1
834 --- rpm/python/header-py.c 7 Aug 2002 23:19:10 -0000 1.20
835 +++ rpm/python/header-py.c 15 Oct 2002 19:03:22 -0000 1.20.2.1
837 return rpmVersionCompare(a->h, b->h);
840 +static long hdr_hash(hdrObject *h)
847 /*@unchecked@*/ /*@observer@*/
849 0, /* tp_as_number */
850 0, /* tp_as_sequence */
851 &hdr_as_mapping, /* tp_as_mapping */
853 + hdr_hash, /* tp_hash */
857 Index: python/rpmdb/__init__.py
858 ===================================================================
859 RCS file: rpm/python/rpmdb/__init__.py,v
860 retrieving revision 1.2
861 retrieving revision 1.2.2.1
862 diff -u -u -r1.2 -r1.2.2.1
863 --- rpm/python/rpmdb/__init__.py 3 Jun 2002 20:44:08 -0000 1.2
864 +++ rpm/python/rpmdb/__init__.py 6 Nov 2002 16:47:02 -0000 1.2.2.1
866 flags = _checkflag(flag)
869 - if cachesize is not None: d.set_cachesize(cachesize)
870 + if cachesize is not None: d.set_cachesize(0, cachesize)
871 if pgsize is not None: d.set_pagesize(pgsize)
872 if lorder is not None: d.set_lorder(lorder)
873 if ffactor is not None: d.set_h_ffactor(ffactor)
876 flags = _checkflag(flag)
878 - if cachesize is not None: d.set_cachesize(cachesize)
879 + if cachesize is not None: d.set_cachesize(0, cachesize)
880 if pgsize is not None: d.set_pagesize(pgsize)
881 if lorder is not None: d.set_lorder(lorder)
885 flags = _checkflag(flag)
887 - if cachesize is not None: d.set_cachesize(cachesize)
888 + if cachesize is not None: d.set_cachesize(0, cachesize)
889 if pgsize is not None: d.set_pagesize(pgsize)
890 if lorder is not None: d.set_lorder(lorder)
892 Index: python/rpmdb/dbshelve.py
893 ===================================================================
894 RCS file: rpm/python/rpmdb/dbshelve.py,v
895 retrieving revision 1.2
896 retrieving revision 1.2.2.1
897 diff -u -u -r1.2 -r1.2.2.1
898 --- rpm/python/rpmdb/dbshelve.py 5 Jun 2002 20:28:03 -0000 1.2
899 +++ rpm/python/rpmdb/dbshelve.py 6 Nov 2002 16:47:02 -0000 1.2.2.1
901 if type(flags) == type(''):
904 - flags = db.DB_READONLY
905 + flags = db.DB_RDONLY
909 Index: python/rpmdb/dbtables.py
910 ===================================================================
911 RCS file: rpm/python/rpmdb/dbtables.py,v
912 retrieving revision 1.1
913 retrieving revision 1.1.2.1
914 diff -u -u -r1.1 -r1.1.2.1
915 --- rpm/python/rpmdb/dbtables.py 3 Jun 2002 20:44:08 -0000 1.1
916 +++ rpm/python/rpmdb/dbtables.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
918 #-----------------------------------------------------------------------
920 # Copyright (C) 2000, 2001 by Autonomous Zone Industries
921 +# Copyright (C) 2002 Gregory P. Smith
923 # License: This is free software. You may use this software for any
924 # purpose including modification/redistribution, so long as
926 def __call__(self, s):
927 return s[:len(self.prefix)] == self.prefix
929 +class PostfixCond(Cond):
930 + """Acts as a condition function for matching a string postfix"""
931 + def __init__(self, postfix):
932 + self.postfix = postfix
933 + def __call__(self, s):
934 + return s[-len(self.postfix):] == self.postfix
936 class LikeCond(Cond):
938 Acts as a function that will match using an SQL 'LIKE' style
939 @@ -523,17 +531,10 @@
940 # if no condition was specified or the condition
941 # succeeds, add row to our match list.
942 if not condition or condition(data) :
943 - # only create new entries in matcing_rowids on
944 - # the first pass, otherwise reject the
945 - # rowid as it must not have matched
946 - # the previous passes
947 - if column_num == 0 :
948 - if not matching_rowids.has_key(rowid) :
949 - matching_rowids[rowid] = {}
950 - if savethiscolumndata :
951 - matching_rowids[rowid][column] = data
953 - rejected_rowids[rowid] = rowid
954 + if not matching_rowids.has_key(rowid) :
955 + matching_rowids[rowid] = {}
956 + if savethiscolumndata :
957 + matching_rowids[rowid][column] = data
959 if matching_rowids.has_key(rowid) :
960 del matching_rowids[rowid]
961 Index: python/rpmdb/dbutils.py
962 ===================================================================
963 RCS file: rpm/python/rpmdb/dbutils.py,v
964 retrieving revision 1.1
965 retrieving revision 1.1.2.1
966 diff -u -u -r1.1 -r1.1.2.1
967 --- rpm/python/rpmdb/dbutils.py 3 Jun 2002 20:44:08 -0000 1.1
968 +++ rpm/python/rpmdb/dbutils.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
970 #------------------------------------------------------------------------
972 -# In my performance tests, using this (as in dbtest.py test4) is
973 -# slightly slower than simply compiling _db.c with MYDB_THREAD
974 -# undefined to prevent multithreading support in the C module.
975 -# Using NoDeadlockDb also prevent deadlocks from mutliple processes
976 -# accessing the same database.
978 # Copyright (C) 2000 Autonomous Zone Industries
980 # License: This is free software. You may use this software for any
982 # Author: Gregory P. Smith <greg@electricrain.com>
984 # Note: I don't know how useful this is in reality since when a
985 -# DBDeadlockError happens the current transaction is supposed to be
986 +# DBLockDeadlockError happens the current transaction is supposed to be
987 # aborted. If it doesn't then when the operation is attempted again
988 # the deadlock is still happening...
994 -_deadlock_MinSleepTime = 1.0/64 # always sleep at least N seconds between retrys
995 -_deadlock_MaxSleepTime = 1.0 # never sleep more than N seconds between retrys
996 +_deadlock_MinSleepTime = 1.0/64 # always sleep at least N seconds between retrys
997 +_deadlock_MaxSleepTime = 3.14159 # never sleep more than N seconds between retrys
999 +_deadlock_VerboseFile = None # Assign a file object to this for a "sleeping"
1000 + # message to be written to it each retry
1002 def DeadlockWrap(function, *_args, **_kwargs):
1003 """DeadlockWrap(function, *_args, **_kwargs) - automatically retries
1004 function in case of a database deadlock.
1006 - This is a DeadlockWrapper method which DB calls can be made using to
1007 - preform infinite retrys with sleeps in between when a DBLockDeadlockError
1008 - exception is raised in a database call:
1009 + This is a function intended to be used to wrap database calls such
1010 + that they perform retrys with exponentially backing off sleeps in
1011 + between when a DBLockDeadlockError exception is raised.
1013 + A 'max_retries' parameter may optionally be passed to prevent it
1014 + from retrying forever (in which case the exception will be reraised).
1018 DeadlockWrap(d.put, "foo", data="bar") # set key "foo" to "bar"
1020 sleeptime = _deadlock_MinSleepTime
1022 + max_retries = _kwargs.get('max_retries', -1)
1023 + if _kwargs.has_key('max_retries'):
1024 + del _kwargs['max_retries']
1027 return apply(function, _args, _kwargs)
1028 except _db.DBLockDeadlockError:
1029 - print 'DeadlockWrap sleeping ', sleeptime
1030 + if _deadlock_VerboseFile:
1031 + _deadlock_VerboseFile.write('dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
1033 # exponential backoff in the sleep time
1034 sleeptime = sleeptime * 2
1035 if sleeptime > _deadlock_MaxSleepTime :
1036 sleeptime = _deadlock_MaxSleepTime
1037 + max_retries = max_retries - 1
1038 + if max_retries == -1:
1042 #------------------------------------------------------------------------
1043 Index: python/test/test_dbshelve.py
1044 ===================================================================
1045 RCS file: rpm/python/test/test_dbshelve.py,v
1046 retrieving revision 1.1
1047 retrieving revision 1.1.2.1
1048 diff -u -u -r1.1 -r1.1.2.1
1049 --- rpm/python/test/test_dbshelve.py 3 Jun 2002 20:44:08 -0000 1.1
1050 +++ rpm/python/test/test_dbshelve.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
1054 class HashShelveTestCase(BasicShelveTestCase):
1055 - dbtype = db.DB_BTREE
1056 + dbtype = db.DB_HASH
1057 dbflags = db.DB_CREATE
1063 class ThreadHashShelveTestCase(BasicShelveTestCase):
1064 - dbtype = db.DB_BTREE
1065 + dbtype = db.DB_HASH
1066 dbflags = db.DB_CREATE | db.DB_THREAD
1071 class EnvHashShelveTestCase(BasicEnvShelveTestCase):
1073 - dbtype = db.DB_BTREE
1074 + dbtype = db.DB_HASH
1075 dbflags = db.DB_CREATE
1080 class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase):
1081 envflags = db.DB_THREAD
1082 - dbtype = db.DB_BTREE
1083 + dbtype = db.DB_HASH
1084 dbflags = db.DB_CREATE | db.DB_THREAD
1087 Index: python/test/test_dbtables.py
1088 ===================================================================
1089 RCS file: rpm/python/test/test_dbtables.py,v
1090 retrieving revision 1.1
1091 retrieving revision 1.1.2.1
1092 diff -u -u -r1.1 -r1.1.2.1
1093 --- rpm/python/test/test_dbtables.py 3 Jun 2002 20:44:08 -0000 1.1
1094 +++ rpm/python/test/test_dbtables.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
1096 #-----------------------------------------------------------------------
1098 # Copyright (C) 2000, 2001 by Autonomous Zone Industries
1099 +# Copyright (C) 2002 Gregory P. Smith
1103 @@ -157,6 +158,40 @@
1104 conditions={'c': lambda c: c == 'meep'})
1105 assert len(values) == 1
1106 assert values[0]['b'] == "bad"
1109 + def test04_MultiCondSelect(self):
1110 + tabname = "test04_MultiCondSelect"
1112 + self.tdb.Drop(tabname)
1113 + except dbtables.TableDBError:
1115 + self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
1118 + self.tdb.Insert(tabname, {'a': "", 'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1), 'f': "Zero"})
1120 + except dbtables.TableDBError:
1123 + self.tdb.Insert(tabname, {'a': "A", 'b': "B", 'c': "C", 'd': "D", 'e': "E"})
1124 + self.tdb.Insert(tabname, {'a': "-A", 'b': "-B", 'c': "-C", 'd': "-D", 'e': "-E"})
1125 + self.tdb.Insert(tabname, {'a': "A-", 'b': "B-", 'c': "C-", 'd': "D-", 'e': "E-"})
1128 + self.tdb._db_print()
1130 + # This select should return 0 rows. it is designed to test
1131 + # the bug identified and fixed in sourceforge bug # 590449
1132 + # (Big Thanks to "Rob Tillotson (n9mtb)" for tracking this down
1133 + # and supplying a fix!! This one caused many headaches to say
1135 + values = self.tdb.Select(tabname, ['b', 'a', 'd'],
1136 + conditions={'e': dbtables.ExactCond('E'),
1137 + 'a': dbtables.ExactCond('A'),
1138 + 'd': dbtables.PrefixCond('-')
1140 + assert len(values) == 0, values
1143 def test_CreateOrExtend(self):
1144 Index: python/test/test_thread.py
1145 ===================================================================
1146 RCS file: rpm/python/test/test_thread.py,v
1147 retrieving revision 1.1
1148 retrieving revision 1.1.2.1
1149 diff -u -u -r1.1 -r1.1.2.1
1150 --- rpm/python/test/test_thread.py 3 Jun 2002 20:44:08 -0000 1.1
1151 +++ rpm/python/test/test_thread.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
1154 from test_all import verbose
1156 -from rpmdb import db
1157 +from rpmdb import db, dbutils
1160 #----------------------------------------------------------------------
1166 + dbutils._deadlock_VerboseFile = sys.stdout
1168 homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
1169 self.homeDir = homeDir
1170 try: os.mkdir(homeDir)
1173 for x in range(start, stop):
1175 - d.put(key, self.makeData(key))
1176 + dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
1177 if verbose and x % 100 == 0:
1178 print "%s: records %d - %d finished" % (name, start, x)
1181 # create a bunch of records
1182 for x in xrange(start, stop):
1184 - d.put(key, self.makeData(key))
1185 + dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
1187 if verbose and x % 100 == 0:
1188 print "%s: records %d - %d finished" % (name, start, x)
1189 @@ -221,12 +224,12 @@
1190 if random() <= 0.05:
1191 for y in xrange(start, x):
1194 + data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
1195 assert data == self.makeData(key)
1200 + dbutils.DeadlockWrap(d.sync, max_retries=12)
1201 except db.DBIncompleteError, val:
1203 print "could not complete sync()..."
1204 @@ -234,12 +237,12 @@
1205 # read them back, deleting a few
1206 for x in xrange(start, stop):
1209 + data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
1210 if verbose and x % 100 == 0:
1211 print "%s: fetched record (%s, %s)" % (name, key, data)
1212 - assert data == self.makeData(key)
1213 + assert data == self.makeData(key), (key, data, self.makeData(key))
1214 if random() <= 0.10:
1216 + dbutils.DeadlockWrap(d.delete, key, max_retries=12)
1218 print "%s: deleted record %s" % (name, key)
1223 class HashSimpleThreaded(SimpleThreadedBase):
1224 - dbtype = db.DB_BTREE
1225 + dbtype = db.DB_HASH
1228 #----------------------------------------------------------------------
1230 ===================================================================
1231 RCS file: rpm/rpmdb/db3.c,v
1232 retrieving revision 1.45
1233 retrieving revision 1.45.2.1
1234 diff -u -u -r1.45 -r1.45.2.1
1235 --- rpm/rpmdb/db3.c 13 Aug 2002 20:42:39 -0000 1.45
1236 +++ rpm/rpmdb/db3.c 6 Nov 2002 17:29:34 -0000 1.45.2.1
1237 @@ -266,11 +266,22 @@
1240 /*@-noeffectuncon@*/ /* FIX: annotate db3 methods */
1242 + /* 4.1: dbenv->set_app_dispatch(???) */
1243 + /* 4.1: dbenv->set_alloc(???) */
1244 + /* 4.1: dbenv->set_data_dir(???) */
1245 + /* 4.1: dbenv->set_encrypt(???) */
1247 dbenv->set_errcall(dbenv, rpmdb->db_errcall);
1248 dbenv->set_errfile(dbenv, rpmdb->db_errfile);
1249 dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
1250 /*@=noeffectuncon@*/
1252 + /* 4.1: dbenv->set_feedback(???) */
1253 + /* 4.1: dbenv->set_flags(???) */
1255 /* dbenv->set_paniccall(???) */
1257 xx = dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
1258 (dbi->dbi_verbose & DB_VERB_CHKPOINT));
1259 xx = dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
1260 @@ -279,16 +290,35 @@
1261 (dbi->dbi_verbose & DB_VERB_RECOVERY));
1262 xx = dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
1263 (dbi->dbi_verbose & DB_VERB_WAITSFOR));
1264 - /* dbenv->set_lg_max(???) */
1266 /* dbenv->set_lk_conflicts(???) */
1267 /* dbenv->set_lk_detect(???) */
1268 - /* dbenv->set_lk_max(???) */
1269 - xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mp_mmapsize);
1270 - xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
1271 - xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_mp_size, 0);
1272 - xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
1273 + /* 4.1: dbenv->set_lk_max_lockers(???) */
1274 + /* 4.1: dbenv->set_lk_max_locks(???) */
1275 + /* 4.1: dbenv->set_lk_max_objects(???) */
1277 + /* 4.1: dbenv->set_lg_bsize(???) */
1278 + /* 4.1: dbenv->set_lg_dir(???) */
1279 + /* 4.1: dbenv->set_lg_max(???) */
1280 + /* 4.1: dbenv->set_lg_regionmax(???) */
1282 + if (dbi->dbi_mmapsize) {
1283 + xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mmapsize);
1284 + xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
1286 + if (dbi->dbi_cachesize) {
1287 + xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_cachesize, 0);
1288 + xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
1291 + /* 4.1 dbenv->set_timeout(???) */
1292 /* dbenv->set_tx_max(???) */
1293 + /* 4.1: dbenv->set_tx_timestamp(???) */
1294 /* dbenv->set_tx_recover(???) */
1296 + /* dbenv->set_rep_transport(???) */
1297 + /* dbenv->set_rep_limit(???) */
1299 if (dbi->dbi_no_fsync) {
1300 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0) || (DB_VERSION_MAJOR == 4)
1301 xx = db_env_set_func_fsync(db3_fsync_disable);
1302 @@ -366,7 +396,11 @@
1304 rc = db->sync(db, flags);
1305 /* XXX DB_INCOMPLETE is returned occaisionally with multiple access. */
1306 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1307 + _printit = _debug;
1309 _printit = (rc == DB_INCOMPLETE ? 0 : _debug);
1311 rc = cvtdberr(dbi, "db->sync", rc, _printit);
1314 @@ -599,10 +633,17 @@
1316 DB * db = dbi->dbi_db;
1317 DB * secondary = dbisecondary->dbi_db;
1318 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1319 + DB_TXN * txnid = NULL;
1323 /*@-moduncon@*/ /* FIX: annotate db3 methods */
1324 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1325 + rc = db->associate(db, txnid, secondary, callback, flags);
1327 rc = db->associate(db, secondary, callback, flags);
1330 rc = cvtdberr(dbi, "db->associate", rc, _debug);
1335 DB_ENV * dbenv = NULL;
1336 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1337 + DB_TXN * txnid = NULL;
1342 @@ -981,18 +1025,7 @@
1344 rc = cvtdberr(dbi, "db_create", rc, _debug);
1345 if (rc == 0 && db != NULL) {
1346 - if (rc == 0 && dbi->dbi_lorder) {
1347 - rc = db->set_lorder(db, dbi->dbi_lorder);
1348 - rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
1350 - if (rc == 0 && dbi->dbi_cachesize) {
1351 - rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
1352 - rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
1354 - if (rc == 0 && dbi->dbi_pagesize) {
1355 - rc = db->set_pagesize(db, dbi->dbi_pagesize);
1356 - rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
1359 /* XXX 3.3.4 change. */
1360 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3) || (DB_VERSION_MAJOR == 4)
1362 @@ -1008,6 +1041,27 @@
1363 rc = cvtdberr(dbi, "db->set_malloc", rc, _debug);
1367 +/* 4.1: db->set_cache_priority(???) */
1368 + if (rc == 0 && !dbi->dbi_use_dbenv && dbi->dbi_cachesize) {
1369 + rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
1370 + rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
1372 +/* 4.1: db->set_encrypt(???) */
1373 +/* 4.1: db->set_errcall(dbenv, rpmdb->db_errcall); */
1374 +/* 4.1: db->set_errfile(dbenv, rpmdb->db_errfile); */
1375 +/* 4.1: db->set_errpfx(dbenv, rpmdb->db_errpfx); */
1376 + /* 4.1: db->set_feedback(???) */
1378 + if (rc == 0 && dbi->dbi_lorder) {
1379 + rc = db->set_lorder(db, dbi->dbi_lorder);
1380 + rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
1382 + if (rc == 0 && dbi->dbi_pagesize) {
1383 + rc = db->set_pagesize(db, dbi->dbi_pagesize);
1384 + rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
1386 + /* 4.1: db->set_paniccall(???) */
1387 if (rc == 0 && oflags & DB_CREATE) {
1388 switch(dbi->dbi_type) {
1390 @@ -1042,6 +1096,7 @@
1394 +/* 4.1: db->set_append_recno(???) */
1395 if (dbi->dbi_bt_flags) {
1396 rc = db->set_flags(db, dbi->dbi_bt_flags);
1397 rc = cvtdberr(dbi, "db->set_bt_flags", rc, _debug);
1398 @@ -1073,6 +1128,7 @@
1401 if (dbi->dbi_re_delim) {
1402 +/* 4.1: db->set_append_recno(???) */
1403 rc = db->set_re_delim(db, dbi->dbi_re_delim);
1404 rc = cvtdberr(dbi, "db->set_re_selim", rc, _debug);
1406 @@ -1124,8 +1180,13 @@
1407 ? dbfullpath : dbfile;
1410 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1411 + rc = db->open(db, txnid, dbpath, dbsubfile,
1412 + dbi->dbi_type, oflags, dbi->dbi_perms);
1414 rc = db->open(db, dbpath, dbsubfile,
1415 dbi->dbi_type, oflags, dbi->dbi_perms);
1418 if (rc == 0 && dbi->dbi_type == DB_UNKNOWN) {
1419 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3 && DB_VERSION_PATCH == 11) \
1420 Index: rpmdb/dbconfig.c
1421 ===================================================================
1422 RCS file: rpm/rpmdb/dbconfig.c,v
1423 retrieving revision 1.33
1424 retrieving revision 1.33.2.1
1425 diff -u -u -r1.33 -r1.33.2.1
1426 --- rpm/rpmdb/dbconfig.c 3 Aug 2002 22:31:39 -0000 1.33
1427 +++ rpm/rpmdb/dbconfig.c 6 Nov 2002 17:29:34 -0000 1.33.2.1
1428 @@ -190,9 +190,11 @@
1429 { "lorder", 0,POPT_ARG_INT, &db3dbi.dbi_lorder, 0,
1432 - { "mp_mmapsize", 0,POPT_ARG_INT, &db3dbi.dbi_mp_mmapsize, 0,
1433 + { "mmapsize", 0,POPT_ARG_INT, &db3dbi.dbi_mmapsize, 0,
1435 - { "mp_size", 0,POPT_ARG_INT, &db3dbi.dbi_mp_size, 0,
1436 + { "mp_mmapsize", 0,POPT_ARG_INT, &db3dbi.dbi_mmapsize, 0,
1438 + { "mp_size", 0,POPT_ARG_INT, &db3dbi.dbi_cachesize, 0,
1440 { "pagesize", 0,POPT_ARG_INT, &db3dbi.dbi_pagesize, 0,
1443 /** @todo Set a reasonable "last gasp" default db config. */
1444 /*@observer@*/ /*@unchecked@*/
1445 static const char *db3_config_default =
1446 - "db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:mp_size=512Kb:pagesize=512:perms=0644";
1447 + "db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:cachesize=512Kb:pagesize=512:perms=0644";
1450 dbiIndex db3New(rpmdb rpmdb, rpmTag rpmtag)
1452 if (!dbi->dbi_use_dbenv) { /* db3 dbenv is always used now. */
1453 dbi->dbi_use_dbenv = 1;
1454 dbi->dbi_eflags |= (DB_INIT_MPOOL|DB_JOINENV);
1455 - dbi->dbi_mp_mmapsize = 16 * 1024 * 1024;
1456 - dbi->dbi_mp_size = 1 * 1024 * 1024;
1457 + dbi->dbi_mmapsize = 16 * 1024 * 1024;
1458 + dbi->dbi_cachesize = 1 * 1024 * 1024;
1461 if ((dbi->dbi_bt_flags | dbi->dbi_h_flags) & DB_DUP)
1462 Index: rpmdb/header.c
1463 ===================================================================
1464 RCS file: rpm/rpmdb/header.c,v
1465 retrieving revision 1.17.2.11
1466 retrieving revision 1.17.2.12
1467 diff -u -u -r1.17.2.11 -r1.17.2.12
1468 --- rpm/rpmdb/header.c 17 Sep 2002 15:19:45 -0000 1.17.2.11
1469 +++ rpm/rpmdb/header.c 6 Nov 2002 17:29:34 -0000 1.17.2.12
1470 @@ -2825,6 +2825,7 @@
1476 case RPM_STRING_ARRAY_TYPE:
1477 strarray = (const char **)data;
1478 Index: rpmdb/header.h
1479 ===================================================================
1480 RCS file: rpm/rpmdb/header.h,v
1481 retrieving revision 1.6
1482 retrieving revision 1.6.2.1
1483 diff -u -u -r1.6 -r1.6.2.1
1484 --- rpm/rpmdb/header.h 13 Jul 2002 19:10:02 -0000 1.6
1485 +++ rpm/rpmdb/header.h 6 Nov 2002 17:29:34 -0000 1.6.2.1
1487 /* RPM - Copyright (C) 1995-2001 Red Hat Software */
1498 #if !defined(__HEADER_PROTOTYPES__)
1499 -#include <hdrinline.h>
1500 +#include "hdrinline.h"
1504 Index: rpmdb/rpmdb.h
1505 ===================================================================
1506 RCS file: rpm/rpmdb/rpmdb.h,v
1507 retrieving revision 1.46.2.2
1508 retrieving revision 1.46.2.3
1509 diff -u -u -r1.46.2.2 -r1.46.2.3
1510 --- rpm/rpmdb/rpmdb.h 17 Sep 2002 15:19:46 -0000 1.46.2.2
1511 +++ rpm/rpmdb/rpmdb.h 6 Nov 2002 17:29:34 -0000 1.46.2.3
1516 -#include <rpmlib.h>
1518 +#include "rpmlib.h"
1524 int dbi_region_init;
1526 /* mpool sub-system parameters */
1527 - int dbi_mp_mmapsize; /*!< (10Mb) */
1528 - int dbi_mp_size; /*!< (128Kb) */
1529 + int dbi_mmapsize; /*!< (10Mb) */
1530 + int dbi_cachesize; /*!< (128Kb) */
1531 /* lock sub-system parameters */
1532 unsigned int dbi_lk_max;
1533 unsigned int dbi_lk_detect;
1535 /*@modifies fileSystem @*/;
1537 /* dbinfo parameters */
1538 - int dbi_cachesize; /*!< */
1539 int dbi_pagesize; /*!< (fs blksize) */
1540 /*@unused@*/ /*@null@*/
1541 void * (*dbi_malloc) (size_t nbytes)
1542 Index: rpmio/rpmlog.c
1543 ===================================================================
1544 RCS file: rpm/rpmio/rpmlog.c,v
1545 retrieving revision 2.27
1546 retrieving revision 2.27.2.1
1547 diff -u -u -r2.27 -r2.27.2.1
1548 --- rpm/rpmio/rpmlog.c 2 Jul 2002 23:54:38 -0000 2.27
1549 +++ rpm/rpmio/rpmlog.c 20 Sep 2002 16:33:49 -0000 2.27.2.1
1551 else /* glibc 2.0 */
1553 msgbuf = xrealloc(msgbuf, msgnb);
1556 msgbuf[msgnb - 1] = '\0';
1558 Index: rpmio/rpmrpc.c
1559 ===================================================================
1560 RCS file: rpm/rpmio/rpmrpc.c,v
1561 retrieving revision 2.27.2.2
1562 retrieving revision 2.27.2.3
1563 diff -u -u -r2.27.2.2 -r2.27.2.3
1564 --- rpm/rpmio/rpmrpc.c 17 Sep 2002 15:19:46 -0000 2.27.2.2
1565 +++ rpm/rpmio/rpmrpc.c 9 Oct 2002 19:06:24 -0000 2.27.2.3
1566 @@ -1023,7 +1023,7 @@
1567 (unsigned)st->st_dev,
1568 (unsigned)st->st_ino,
1571 + (unsigned)st->st_nlink,
1574 (unsigned)st->st_rdev,
1575 Index: tools/sections.c
1576 ===================================================================
1577 RCS file: rpm/tools/sections.c,v
1578 retrieving revision 1.1.2.2
1579 retrieving revision 1.1.2.4
1580 diff -u -u -r1.1.2.2 -r1.1.2.4
1581 --- rpm/tools/sections.c 22 Aug 2002 19:19:47 -0000 1.1.2.2
1582 +++ rpm/tools/sections.c 9 Oct 2002 19:06:24 -0000 1.1.2.4
1583 @@ -24,38 +24,168 @@
1587 - Elf32_Off orig_e_shoff;
1588 - Elf32_Off n_sections;
1589 + Elf64_Off orig_e_shoff;
1590 + Elf64_Off n_sections;
1591 UnstripInfoSection64 sections[1];
1595 +elf_32_to_file (uint32_t x, int file_is_little_endian)
1597 + volatile uint32_t out;
1598 + unsigned char *outbytes;
1600 + outbytes = (unsigned char *)&out;
1601 + if (file_is_little_endian)
1603 + outbytes[0] = (x >> 0) & 0xff;
1604 + outbytes[1] = (x >> 8) & 0xff;
1605 + outbytes[2] = (x >> 16) & 0xff;
1606 + outbytes[3] = (x >> 24) & 0xff;
1608 + else /* big endian */
1610 + outbytes[0] = (x >> 24) & 0xff;
1611 + outbytes[1] = (x >> 16) & 0xff;
1612 + outbytes[2] = (x >> 8) & 0xff;
1613 + outbytes[3] = (x >> 0) & 0xff;
1620 +elf_64_to_file (uint64_t x, int file_is_little_endian)
1622 + volatile uint64_t out;
1623 + unsigned char *outbytes;
1626 + outbytes = (unsigned char *)&out;
1627 + if (file_is_little_endian)
1629 + for (i = 0; i < 8; i++)
1630 + outbytes[i] = (x >> (8*i)) & 0xff;
1632 + else /* big endian */
1634 + for (i = 0; i < 8; i++)
1635 + outbytes[7-i] = (x >> (8*i)) & 0xff;
1642 word32_to_file (Elf32_Word x, Elf *elf)
1644 - /* FIXME: implement */
1646 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1647 + return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1651 off32_to_file (Elf32_Off x, Elf *elf)
1653 - /* FIXME: implement */
1655 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1656 + return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1660 +word64_to_file (Elf64_Word x, Elf *elf)
1662 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1663 + return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1667 +off64_to_file (Elf64_Off x, Elf *elf)
1669 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1670 + return elf_64_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1674 +elf_32_from_file (uint32_t x, int file_is_little_endian)
1676 + unsigned char *inbytes;
1678 + inbytes = (unsigned char *)&x;
1679 + if (file_is_little_endian)
1682 + (inbytes[0] << 0) |
1683 + (inbytes[1] << 8) |
1684 + (inbytes[2] << 16) |
1685 + (inbytes[3] << 24);
1687 + else /* big endian */
1690 + (inbytes[0] << 24) |
1691 + (inbytes[1] << 16) |
1692 + (inbytes[2] << 8) |
1693 + (inbytes[3] << 0);
1698 +elf_64_from_file (uint64_t x, int file_is_little_endian)
1700 + unsigned char *inbytes;
1702 + inbytes = (unsigned char *)&x;
1703 + if (file_is_little_endian)
1706 + ((uint64_t)inbytes[0] << 0) |
1707 + ((uint64_t)inbytes[1] << 8) |
1708 + ((uint64_t)inbytes[2] << 16) |
1709 + ((uint64_t)inbytes[3] << 24) |
1710 + ((uint64_t)inbytes[4] << 32) |
1711 + ((uint64_t)inbytes[5] << 40) |
1712 + ((uint64_t)inbytes[6] << 48) |
1713 + ((uint64_t)inbytes[7] << 56);
1715 + else /* big endian */
1718 + ((uint64_t)inbytes[0] << 56) |
1719 + ((uint64_t)inbytes[1] << 48) |
1720 + ((uint64_t)inbytes[2] << 40) |
1721 + ((uint64_t)inbytes[3] << 32) |
1722 + ((uint64_t)inbytes[4] << 24) |
1723 + ((uint64_t)inbytes[5] << 16) |
1724 + ((uint64_t)inbytes[6] << 8) |
1725 + ((uint64_t)inbytes[7] << 0);
1730 word32_from_file (Elf32_Word x, Elf *elf)
1732 - /* FIXME: implement */
1734 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1735 + return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1739 off32_from_file (Elf32_Off x, Elf *elf)
1741 - /* FIXME: implement */
1743 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1744 + return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1748 +word64_from_file (Elf64_Word x, Elf *elf)
1750 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1751 + return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1755 +off64_from_file (Elf64_Off x, Elf *elf)
1757 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1758 + return elf_64_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1766 + UnstripInfo64 *info64;
1772 + /* orig_e_shoff */ sizeof (Elf64_Off) +
1773 + /* n_sections */ sizeof (Elf64_Off) +
1774 + /* sections */ info->n_sections * sizeof (UnstripInfoSection64);
1776 + data->d_buf = calloc (1, data->d_size);
1778 + info64 = (UnstripInfo64 *) data->d_buf;
1780 + info64->orig_e_shoff = off64_to_file (info->orig_e_shoff, elf);
1781 + info64->n_sections = off64_to_file (info->n_sections, elf);
1783 + for (i = 0; i < info->n_sections; i++)
1785 + info64->sections[i].debug_section = word64_to_file (info->sections[i].debug_section, elf);
1786 + info64->sections[i].name = word64_to_file (info->sections[i].name, elf);
1787 + info64->sections[i].orig_offset = off64_to_file (info->sections[i].orig_offset, elf);
1792 @@ -101,14 +253,21 @@
1798 data->d_type = ELF_T_BYTE;
1801 - /* FIXME: use right version */
1802 - unstrip_info_to_data32 (info, elf, data);
1803 + gelf_getehdr (elf, &ehdr);
1804 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1805 + unstrip_info_to_data32 (info, elf, data);
1806 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1807 + unstrip_info_to_data64 (info, elf, data);
1809 + fprintf (stderr, "Warning. unsupported elf class\n");
1814 unstrip_info_from_data32 (UnstripInfo *info,
1817 @@ -130,23 +289,49 @@
1822 +unstrip_info_from_data64 (UnstripInfo *info,
1826 + UnstripInfo64 *info64;
1829 + info64 = (UnstripInfo64 *) data->d_buf;
1831 + info->orig_e_shoff = off64_from_file (info64->orig_e_shoff, elf);
1832 + info->n_sections = off64_from_file (info64->n_sections, elf);
1834 + info->sections = calloc (info->n_sections, sizeof (UnstripInfoSection));
1835 + for (i = 0; i < info->n_sections; i++)
1837 + info->sections[i].debug_section = word64_from_file (info64->sections[i].debug_section, elf);
1838 + info->sections[i].name = word64_from_file (info64->sections[i].name, elf);
1839 + info->sections[i].orig_offset = off64_from_file (info64->sections[i].orig_offset, elf);
1844 unstrip_info_from_data (Elf *elf,
1851 info = malloc (sizeof (UnstripInfo));
1853 - /* FIXME: use right version */
1854 - unstrip_info_from_data32 (info,
1857 + gelf_getehdr (elf, &ehdr);
1858 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1859 + unstrip_info_from_data32 (info, elf, data);
1860 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1861 + unstrip_info_from_data64 (info, elf, data);
1863 + fprintf (stderr, "Warning. unsupported elf class\n");
1870 debug_link_to_data32 (DebugLink *debuglink,
1872 @@ -166,23 +351,53 @@
1873 data->d_buf = calloc (1, data->d_size);
1875 strcpy (data->d_buf, debuglink->filename);
1876 - p = data->d_buf + namelen_aligned;
1877 + p = ((char *)data->d_buf) + namelen_aligned;
1879 *(Elf32_Word *)p = word32_to_file (debuglink->checksum, elf);
1880 - p += sizeof (Elf32_Word);
1884 +debug_link_to_data64 (DebugLink *debuglink,
1888 + size_t namelen_aligned;
1891 + data->d_align = 4;
1893 + namelen_aligned = align_up (strlen(debuglink->filename) + 1, 4);
1896 + /* name */ namelen_aligned +
1897 + /* checksum */ sizeof (Elf64_Word);
1899 + data->d_buf = calloc (1, data->d_size);
1901 + strcpy (data->d_buf, debuglink->filename);
1902 + p = ((char *)data->d_buf) + namelen_aligned;
1904 + *(Elf64_Word *)p = word64_to_file (debuglink->checksum, elf);
1908 debug_link_to_data (DebugLink *debuglink, Elf *elf, Elf_Data *data)
1912 data->d_type = ELF_T_BYTE;
1915 - /* FIXME: use right version */
1916 - debug_link_to_data32 (debuglink, elf, data);
1917 + gelf_getehdr (elf, &ehdr);
1918 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1919 + debug_link_to_data32 (debuglink, elf, data);
1920 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1921 + debug_link_to_data64 (debuglink, elf, data);
1923 + fprintf (stderr, "Warning. unsupported elf class\n");
1928 debug_link_from_data32 (DebugLink *debuglink,
1931 @@ -194,24 +409,44 @@
1933 namelen_aligned = align_up (strlen (debuglink->filename) + 1, 4);
1935 - p = data->d_buf + namelen_aligned;
1936 + p = ((char *)data->d_buf) + namelen_aligned;
1938 debuglink->checksum = word32_from_file (*(Elf32_Word *)p, elf);
1939 - p += sizeof (Elf32_Word);
1943 +debug_link_from_data64 (DebugLink *debuglink,
1947 + size_t namelen_aligned;
1950 + debuglink->filename = strdup (data->d_buf);
1952 + namelen_aligned = align_up (strlen (debuglink->filename) + 1, 4);
1954 + p = ((char *)data->d_buf) + namelen_aligned;
1956 + debuglink->checksum = word64_from_file (*(Elf64_Word *)p, elf);
1961 debug_link_from_data (Elf *elf, Elf_Data *data)
1964 DebugLink *debuglink;
1966 debuglink = malloc (sizeof (DebugLink));
1968 - /* FIXME: use right version */
1969 - debug_link_from_data32 (debuglink,
1972 + gelf_getehdr (elf, &ehdr);
1973 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1974 + debug_link_from_data32 (debuglink, elf, data);
1975 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1976 + debug_link_from_data64 (debuglink, elf, data);
1978 + fprintf (stderr, "Warning. unsupported elf class\n");
1982 Index: tools/striptofile.c
1983 ===================================================================
1984 RCS file: rpm/tools/striptofile.c,v
1985 retrieving revision 1.1.2.2
1986 retrieving revision 1.1.2.4
1987 diff -u -u -r1.1.2.2 -r1.1.2.4
1988 --- rpm/tools/striptofile.c 22 Aug 2002 19:19:47 -0000 1.1.2.2
1989 +++ rpm/tools/striptofile.c 9 Oct 2002 19:06:24 -0000 1.1.2.4
1991 int keep_all_section_headers = 1;
1992 int add_unstrip_info = 0;
1995 +#if defined(NhUNUSED)
1997 copy_to_file(Elf *elf, Elf *out_elf)
2008 strip_to_file(Elf *elf, Elf *out_elf, DebugLink *debuglink)
2013 int changed_offsets;
2014 GElf_Off last_offset;
2015 - int i, debuglink_name;
2017 + int debuglink_name = 0;
2019 elf_flagelf (out_elf, ELF_C_SET, ELF_F_LAYOUT);
2022 /* Update section header stringtab ref */
2023 gelf_getehdr (out_elf, &out_ehdr);
2024 out_ehdr.e_shstrndx = section_map[out_ehdr.e_shstrndx];
2025 - out_ehdr.e_shoff = align_up (last_offset, 4);
2026 + out_ehdr.e_shoff = align_up (last_offset, 8);
2027 gelf_update_ehdr(out_elf, &out_ehdr);
2029 /* Update section header links */
2036 copy_debuginfo_to_file(Elf *elf, Elf *out_elf)
2040 unsigned char *section_strtab;
2043 - int unstripinfo_name;
2044 + int unstripinfo_name = 0;
2046 info = malloc (sizeof (UnstripInfo));
2051 const char *origname;
2052 + char *origname_base;
2053 char *debugname, *strippedname;
2054 DebugLink *debuglink;
2055 poptContext optCon; /* context for parsing command-line options */
2056 @@ -433,14 +437,13 @@
2061 - const char * bn = strrchr(origname, '/');
2062 - if ((bn = strrchr(origname, '/')) != NULL)
2066 - debugname = strconcat (output_dir, "/", bn, ".debug", NULL);
2070 + origname_base = path_basename (origname);
2071 + debugname = strconcat (output_dir, "/", origname_base, ".debug", NULL);
2072 + free (origname_base);
2075 debugname = strconcat (origname, ".debug", NULL);
2077 strippedname = strconcat (origname, ".XXXXXX", NULL);
2078 Index: tools/unstripfile.c
2079 ===================================================================
2080 RCS file: rpm/tools/unstripfile.c,v
2081 retrieving revision 1.1.2.2
2082 retrieving revision 1.1.2.3
2083 diff -u -u -r1.1.2.2 -r1.1.2.3
2084 --- rpm/tools/unstripfile.c 22 Aug 2002 19:19:47 -0000 1.1.2.2
2085 +++ rpm/tools/unstripfile.c 9 Oct 2002 19:06:24 -0000 1.1.2.3
2092 read_debuglink (Elf *elf)
2101 find_section (Elf *elf, const unsigned char *name, const unsigned char *strtab)
2110 find_in_strtab (char *name, char *strtab, size_t strtab_len)
2119 unstrip_file (Elf *elf, Elf *debug_elf, Elf *out_elf)
2122 Index: tools/utils.c
2123 ===================================================================
2124 RCS file: rpm/tools/utils.c,v
2125 retrieving revision 1.1.2.3
2126 retrieving revision 1.1.2.4
2127 diff -u -u -r1.1.2.3 -r1.1.2.4
2128 --- rpm/tools/utils.c 4 Sep 2002 18:13:35 -0000 1.1.2.3
2129 +++ rpm/tools/utils.c 9 Oct 2002 19:06:24 -0000 1.1.2.4
2136 my_stpcpy (char *dest,
2143 -unsigned int crc32 (unsigned int crc, unsigned char *buf, size_t len)
2144 +static unsigned int crc32 (unsigned int crc, unsigned char *buf, size_t len)
2148 Index: xmlspec/Makefile
2149 ===================================================================
2150 RCS file: rpm/xmlspec/Makefile,v
2151 retrieving revision 1.5.2.2
2152 retrieving revision 1.5.2.3
2153 diff -u -u -r1.5.2.2 -r1.5.2.3
2154 --- rpm/xmlspec/Makefile 28 Aug 2002 10:53:03 -0000 1.5.2.2
2155 +++ rpm/xmlspec/Makefile 10 Oct 2002 22:47:59 -0000 1.5.2.3
2157 CFLAGS = -O2 -Wall -Wpointer-arith -Wno-char-subscripts
2158 INCDIR = -I. -I.. -I../build -I../lib -I../misc -I../popt -I../rpmdb -I../rpmio
2160 -DESTDIR = /usr/local
2165 XMLBUILD = rpmxmlbuild
2166 XMLBUILD_SRC = rpmxmlbuild.c
2168 LIBS = $(XMLLIB) $(RPMDIR)/build/.libs/librpmbuild.a \
2169 $(RPMDIR)/lib/.libs/librpm.a $(RPMDIR)/rpmdb/.libs/librpmdb.a \
2170 $(RPMDIR)/rpmio/.libs/librpmio.a $(RPMDIR)/popt/.libs/libpopt.a \
2171 + $(RPMDIR)/libelf/lib/.libs/libelf.a \
2173 LIBDIR = -L. -L$(RPMDIR)/.libs -L/usr/lib
2176 $(STRIP) $(XMLBUILD)
2179 - @(cp $(XMLBUILD) $(DESTDIR)/bin)
2180 - @(cp $(XMLLIB) $(DESTDIR)/lib)
2181 - @(cp $(XMLLIB_H) $(DESTDIR)/include)
2182 + @(install -m 755 $(XMLBUILD) $(DESTDIR)$(prefix)/bin)
2183 + @(install -m 644 $(XMLLIB) $(DESTDIR)$(prefix)/lib)
2184 + @(install -m 644 $(XMLLIB_H) $(DESTDIR)$(prefix)/include/rpm)
2186 $(XMLLIB): $(XMLLIB_OBJ)
2187 $(AR) $(ARFLAGS) $(XMLLIB) $(XMLLIB_OBJ)
2188 Index: xmlspec/XMLAttrs.cpp
2189 ===================================================================
2190 RCS file: xmlspec/XMLAttrs.cpp
2191 diff -N xmlspec/XMLAttrs.cpp
2192 --- /dev/null 1 Jan 1970 00:00:00 -0000
2193 +++ rpm/xmlspec/XMLAttrs.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
2195 +// standard C++ includes
2198 +// standard includes
2199 +#include <string.h>
2202 +#include "XMLAttrs.h"
2203 +#include "XMLMisc.h"
2204 +#include "XMLSpec.h"
2206 +using namespace std;
2208 +XMLAttr::XMLAttr(const char* szName,
2209 + const char* szValue)
2213 + m_sName.assign(szName);
2215 + m_sValue.assign(szValue);
2218 +XMLAttr::XMLAttr(const XMLAttr& rAttr)
2221 + m_sName.assign(rAttr.m_sName);
2222 + m_sValue.assign(rAttr.m_sValue);
2225 +XMLAttr::~XMLAttr()
2229 +XMLAttr XMLAttr::operator=(XMLAttr attr)
2231 + m_sName.assign(attr.m_sName);
2232 + m_sValue.assign(attr.m_sValue);
2235 +XMLAttrs::XMLAttrs(const char** szAttrs)
2238 + for (int i = 0; szAttrs && szAttrs[i]; i += 2) {
2239 + XMLAttr attr(szAttrs[i], szAttrs[i+1]);
2240 + m_vAttrs.push_back(attr);
2244 +XMLAttrs::XMLAttrs(const XMLAttrs& rAttrs)
2247 + m_vAttrs = rAttrs.m_vAttrs;
2250 +XMLAttrs::~XMLAttrs()
2254 +bool validateAttr(structValidAttrs& rAttr,
2255 + const char* szValue)
2257 + switch (rAttr.m_nType) {
2258 + case XATTRTYPE_STRING:
2259 + return findStr(rAttr.m_szaMatches, szValue) != -1 ? true : false;
2261 + case XATTRTYPE_INTEGER:
2262 + return isInteger(szValue);
2264 + case XATTRTYPE_BOOL:
2265 + return isBool(szValue);
2267 + case XATTRTYPE_DATE:
2268 + return isDate(szValue);
2270 + case XATTRTYPE_MAIL:
2271 + return isEmail(szValue);
2273 + case XATTRTYPE_NONE:
2281 +static char* szaTypeDesc[] = { "string",
2283 + "bool [Values: true|false]",
2284 + "date [Format: DDD MMM DD YYYY]",
2287 +bool XMLAttrs::validate(structValidAttrs* paValids,
2290 + // nothing found at present
2291 + for (unsigned int i = 0; paValids[i].m_nValue != XATTR_END; i++)
2292 + paValids[i].m_bFound = false;
2294 + // test everything we have
2295 + for (unsigned int i = 0; i < num(); i++) {
2296 + bool bInvalid = true;
2297 + for (unsigned int j = 0; paValids[j].m_nValue != XATTR_END; j++) {
2298 + if (strcasecmp(paValids[j].m_szName, get(i).getName()) == 0) {
2299 + paValids[j].m_bFound = true;
2300 + if (!validateAttr(paValids[j], get(i).asString())) {
2302 + sprintf(szTmp, "Attribute value '%s' is not a valid %s.",
2303 + get(i).asString(), szaTypeDesc[paValids[j].m_nType]);
2304 + pError->setError(szTmp);
2314 + sprintf(szTmp, "Unknown attribute '%s'", get(i).getName());
2315 + pError->setWarning(szTmp);
2319 + // see if we have mandator tags that are not there
2320 + for (unsigned int i = 0; paValids[i].m_nValue != XATTR_END; i++) {
2321 + if (paValids[i].m_bMandatory && !paValids[i].m_bFound) {
2323 + sprintf(szTmp, "Mandatory attribute '%s' not found",
2324 + paValids[i].m_szName);
2325 + pError->setError(szTmp);
2330 + // if we got this far, everything is ok
2334 +unsigned int getPos(const char* szName,
2338 + for (unsigned int i = 0; i < pAttrs->num(); i++) {
2339 + if (strcasecmp(szName, pAttrs->get(i).getName()) == 0)
2346 +const char* XMLAttrs::asString(const char* szName)
2348 + unsigned int nPos = getPos(szName, this);
2349 + return (nPos == XATTR_END) ? NULL : get(nPos).asString();
2352 +unsigned int XMLAttrs::asInteger(const char* szName)
2354 + unsigned int nPos = getPos(szName, this);
2355 + return (nPos == XATTR_END) ? 0 : get(nPos).asInteger();
2358 +bool XMLAttrs::asBool(const char* szName)
2360 + unsigned int nPos = getPos(szName, this);
2361 + return (nPos == XATTR_END) ? true : get(nPos).asBool();
2363 Index: xmlspec/XMLAttrs.h
2364 ===================================================================
2365 RCS file: xmlspec/XMLAttrs.h
2366 diff -N xmlspec/XMLAttrs.h
2367 --- /dev/null 1 Jan 1970 00:00:00 -0000
2368 +++ rpm/xmlspec/XMLAttrs.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
2370 +#ifndef _H_XMLATTRS_
2371 +#define _H_XMLATTRS_
2373 +// standard C++ includes
2377 +// standard C includes
2378 +#include <string.h>
2381 +#include "XMLBase.h"
2383 +using namespace std;
2385 +// definition for the end of the attributes
2386 +#define XATTR_END 0xFFFF
2387 +#define XATTR_NUM_VALSTR 5
2391 + XATTRTYPE_STRING = 0,
2392 + XATTRTYPE_INTEGER,
2396 + XATTRTYPE_NONE = XATTR_END
2399 +struct structValidAttrs
2401 + unsigned int m_nValue;
2402 + bool m_bMandatory;
2405 + unsigned int m_nType;
2406 + char* m_szaMatches[XATTR_NUM_VALSTR+1];
2409 +// forward class definitions
2412 +class XMLAttr : public XMLBase
2415 +// contructors/destructor
2419 + * Default constructor
2421 + * @param szName The name of the attribute
2422 + * @param szValue The attribute value
2425 + XMLAttr(const char* szName,
2426 + const char* szValue);
2429 + * Copy constructor
2431 + * @param rAttr Reference to the attribute to copy
2434 + XMLAttr(const XMLAttr& rAttr);
2449 + * Assignment operator
2451 + * @param attr The attribute to copy
2452 + * @return the assigned obkect
2454 + XMLAttr operator=(XMLAttr attr);
2457 +// get/set functions
2461 + * Returns the attribute name
2464 + * @return string containing the attribute name
2466 + const char* getName()
2468 + return m_sName.c_str();
2472 + * Returns the attribute value (as string)
2475 + * @return string containing the attribute value
2477 + const char* asString()
2479 + return m_sValue.c_str();
2483 + * Returns the attribute value (as integer)
2486 + * @return the attribute as an integer
2488 + unsigned int asInteger()
2490 + return atoi(m_sValue.c_str());
2494 + * Returns the attribute value as a boolean
2497 + * @return true if set, false otherwise
2501 + bool isSet = true;
2502 + if (strcasecmp(m_sValue.c_str(), "no") == 0 ||
2503 + strcasecmp(m_sValue.c_str(), "0") == 0 ||
2504 + strcasecmp(m_sValue.c_str(), "false") == 0)
2510 +// member variables
2517 +class XMLAttrs : public XMLBase
2520 +// constructors/destructor
2524 + * The default attribute constructor
2526 + * @param szAttrs Pointer to an array of attributes, terminated by NULL
2529 + XMLAttrs(const char** szAttrs);
2532 + * Copy constructor
2534 + * @param rAttrs The attribute object to copy
2537 + XMLAttrs(const XMLAttrs& rAttrs);
2540 + * The default destructor
2548 +// member functions
2552 + * Validates an attribute object against the valid attributes. This
2553 + * checks for mandatory attributes (error) as well as unexpected
2554 + * attributes. (warnings)
2556 + * @param paValids Pointer to the array of valid attributes
2557 + * @param pError The class in which we will set the errors
2558 + * and/or warnings.
2559 + * @return true on valid attributes, false otherwise
2561 + bool validate(structValidAttrs* paValids,
2565 +// member variables get/set functions
2569 + * Gets the number of attributes contained in this object
2572 + * @returns The number of attributes
2574 + unsigned int num()
2576 + return m_vAttrs.size();
2580 + * Returns a specific attribute by number
2582 + * @param nNum The number of the attribute to return
2583 + * @return The attribute or NULL if it doesn't exist
2585 + XMLAttr& get(unsigned int nNum)
2587 + return m_vAttrs[nNum];
2591 + * Returns the attribute as specified by the name
2593 + * @param szName The name of the attribute whose value we are
2595 + * @return The attribute as a string
2597 + const char* asString(const char* szName);
2600 + * Returns the attribute as specified by the name
2602 + * @param szName The name of the attribute whose value we are
2604 + * @return The attribute as an integer
2606 + unsigned int asInteger(const char* szName);
2609 + * Returns the attribute as specified by the name
2611 + * @param szName The name of the attribute whose value we are
2613 + * @return The attribute as a bool
2615 + bool asBool(const char* szName);
2618 +// protected data members
2621 + vector<XMLAttr> m_vAttrs;
2625 Index: xmlspec/XMLBase.h
2626 ===================================================================
2627 RCS file: xmlspec/XMLBase.h
2628 diff -N xmlspec/XMLBase.h
2629 --- /dev/null 1 Jan 1970 00:00:00 -0000
2630 +++ rpm/xmlspec/XMLBase.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
2632 +#ifndef _H_XMLBASE_
2633 +#define _H_XMLBASE_
2635 +// standard C++ includes
2638 +// standard include
2641 +using namespace std;
2646 +// constructors/destructor methods
2650 + * Default class constructor
2657 + m_bHasError = false;
2658 + m_bHasWarning = false;
2662 + * Default class destructor
2672 +// member variable get and set functions
2676 + * Tests if the object has an error set.
2679 + * @return true if we have an error, false otherwise
2683 + return m_bHasError;
2687 + * Sets the error message that can be retrieved from this
2690 + * @param szError The error string
2693 + void setError(const char* szError = NULL)
2696 + m_bHasError = true;
2697 + m_sError.assign(szError);
2700 + m_bHasError = false;
2704 + * Returns the currently set error value
2707 + * @return pointer to the error string
2709 + const char* getError()
2711 + m_bHasError = false;
2712 + return m_sError.c_str();
2716 + * Tests if the object has a warning set.
2719 + * @return true if we have a warning, false otherwise
2723 + return m_bHasWarning;
2727 + * Sets the warning message that can be retrieved from this
2730 + * @param szWarning The warning string
2733 + void setWarning(const char* szWarning = NULL)
2736 + m_bHasWarning = true;
2737 + m_sWarning.assign(szWarning);
2740 + m_bHasWarning = false;
2744 + * Returns the currently set warning value
2747 + * @return pointer to the warning string
2749 + const char* getWarning()
2751 + m_bHasWarning = false;
2752 + return m_sWarning.c_str();
2756 +// protected internal variables
2761 + bool m_bHasWarning;
2762 + string m_sWarning;
2766 Index: xmlspec/XMLChangelog.cpp
2767 ===================================================================
2768 RCS file: xmlspec/XMLChangelog.cpp
2769 diff -N xmlspec/XMLChangelog.cpp
2770 --- /dev/null 1 Jan 1970 00:00:00 -0000
2771 +++ rpm/xmlspec/XMLChangelog.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
2773 +// standard C++ includes
2777 +#include "XMLChangelog.h"
2778 +#include "XMLMisc.h"
2779 +#include "XMLRPMWrap.h"
2780 +#include "XMLSpec.h"
2782 +using namespace std;
2784 +bool XMLChangelogEntry::parseCreate(XMLAttrs* pAttrs,
2785 + const char* szChange,
2790 + XMLChangelogEntry change(szChange);
2791 + pSpec->getChangelog().lastDate().addEntry(change);
2795 +bool XMLChangelogEntry::structCreate(const char* szEntries,
2798 + if (!pXSpec || !szEntries)
2800 + char* szIn = (char*)szEntries;
2801 + char* szOut = NULL;
2804 + while (nLen != 0) {
2805 + szOut = splitStr(szIn, '\n', nLen);
2806 + if (strncmp(szIn, "- ", 2) == 0) {
2809 + if (sChange.length()) {
2810 + XMLChangelogEntry change(sChange.c_str());
2811 + pXSpec->getChangelog().lastDate().addEntry(change);
2813 + sChange.assign("");
2815 + sChange.append(szIn, nLen);
2818 + if (sChange.length()) {
2819 + XMLChangelogEntry change(sChange.c_str());
2820 + pXSpec->getChangelog().lastDate().addEntry(change);
2825 +XMLChangelogEntry::XMLChangelogEntry(const char* szChange)
2828 + m_sChange.assign(szChange);
2831 +XMLChangelogEntry::XMLChangelogEntry(const XMLChangelogEntry& rEntry)
2834 + m_sChange.assign(rEntry.m_sChange);
2837 +XMLChangelogEntry::~XMLChangelogEntry()
2841 +void XMLChangelogEntry::toSpecFile(ostream& rOut)
2843 + rOut << endl << "- " << getChange();
2846 +void XMLChangelogEntry::toXMLFile(ostream& rOut)
2848 + rOut << endl << "\t\t\t<change>" << getChange() << "</change>";
2851 +// attribute structure for XMLChangelogDate
2852 +structValidAttrs g_paChangelogDateAttrs[] =
2854 + {0x0000, true, false, "date", XATTRTYPE_DATE, {NULL}},
2855 + {0x0001, true, false, "author", XATTRTYPE_STRING, {"*", NULL}},
2856 + {0x0002, false, false, "author-email", XATTRTYPE_MAIL, {NULL}},
2857 + {0x0003, false, false, "version", XATTRTYPE_STRING, {"*", NULL}},
2858 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
2861 +bool XMLChangelogDate::parseCreate(XMLAttrs* pAttrs,
2864 + // validate our attributes
2865 + if (!pAttrs->validate(g_paChangelogDateAttrs, (XMLBase*)pSpec))
2868 + XMLChangelogDate date(pAttrs->asString("date"),
2869 + pAttrs->asString("author"),
2870 + pAttrs->asString("author-email"),
2871 + pAttrs->asString("version"));
2872 + pSpec->getChangelog().addDate(date);
2876 +bool XMLChangelogDate::structCreate(const char* szDate,
2877 + const char* szName,
2878 + const char* szEntries,
2881 + if (!szDate || !szName || !szEntries || ! pXSpec)
2883 + time_t tTime = (time_t)(atol(szDate)) - timezone;
2884 + struct tm *sTime = gmtime(&tTime);
2885 + sTime->tm_year += 1900;
2887 + sprintf(szTmp,"%s %s %d %d", g_szaDays[sTime->tm_wday],
2888 + g_szaMonths[sTime->tm_mon],
2889 + sTime->tm_mday, sTime->tm_year);
2890 + XMLChangelogDate date(szTmp, szName, NULL, NULL);
2891 + pXSpec->getChangelog().addDate(date);
2892 + XMLChangelogEntry::structCreate(szEntries, pXSpec);
2896 +XMLChangelogDate::XMLChangelogDate(const char* szDate,
2897 + const char* szAuthor,
2898 + const char* szEmail,
2899 + const char* szVersion)
2903 + m_sDate.assign(szDate);
2905 + m_sAuthor.assign(szAuthor);
2907 + m_sEmail.assign(szEmail);
2909 + m_sVersion.assign(szVersion);
2912 +XMLChangelogDate::XMLChangelogDate(const XMLChangelogDate& rDate)
2915 + m_sDate.assign(rDate.m_sDate);
2916 + m_sAuthor.assign(rDate.m_sAuthor);
2917 + m_sEmail.assign(rDate.m_sEmail);
2918 + m_sVersion.assign(rDate.m_sVersion);
2919 + m_vEntries = rDate.m_vEntries;
2922 +XMLChangelogDate::~XMLChangelogDate()
2926 +void XMLChangelogDate::toSpecFile(ostream& rOut)
2928 + rOut << endl << "* " << getDate() << " " << getAuthor();
2930 + rOut << " <" << getEmail() << ">";
2932 + rOut << " " << getVersion();
2933 + for (unsigned int i = 0; i < numEntries(); i++)
2934 + getEntry(i).toSpecFile(rOut);
2938 +void XMLChangelogDate::toXMLFile(ostream& rOut)
2940 + rOut << endl << "\t\t<changes date=\"" << getDate() << "\"";
2941 + rOut << endl << "\t\t author=\"" << getAuthor() << "\"";
2943 + rOut << endl << "\t\t author-email=\"" << getEmail() << "\"";
2945 + rOut << endl << "\t\t version=\"" << getVersion() << "\"";
2947 + for (unsigned int i = 0; i < numEntries(); i++)
2948 + getEntry(i).toXMLFile(rOut);
2949 + rOut << endl << "\t\t</changes>";
2952 +bool XMLChangelog::structCreate(Spec pSpec,
2955 + if (!pXSpec || !pSpec || !pSpec->packages || !pSpec->packages->header)
2957 + // FIXME: it looks like RPM only stores the tomost date in the
2958 + // spec file so we are only allowed to get that one instead of an
2959 + // array of time_t's
2961 + t_StrVector svChanges;
2962 + t_StrVector svNames;
2963 + getRPMHeader(pSpec->packages->header, RPMTAG_CHANGELOGTIME, sDates);
2964 + getRPMHeaderArray(pSpec->packages->header, RPMTAG_CHANGELOGNAME, svNames);
2965 + getRPMHeaderArray(pSpec->packages->header, RPMTAG_CHANGELOGTEXT, svChanges);
2966 + for (unsigned int i = 0; i < svNames.size(); i++)
2967 + XMLChangelogDate::structCreate(sDates.c_str(), svNames[i].c_str(),
2968 + svChanges[i].c_str(), pXSpec);
2972 +XMLChangelog::XMLChangelog()
2977 +XMLChangelog::XMLChangelog(const XMLChangelog& rChangelog)
2980 + m_vDates = rChangelog.m_vDates;
2983 +XMLChangelog::~XMLChangelog()
2987 +void XMLChangelog::toSpecFile(ostream& rOut)
2990 + rOut << endl << "%changelog";
2991 + for (unsigned int i = 0; i < numDates(); i++)
2992 + getDate(i).toSpecFile(rOut);
2997 +void XMLChangelog::toXMLFile(ostream& rOut)
3000 + rOut << endl << "\t<changelog>";
3001 + for (unsigned int i = 0; i < numDates(); i++)
3002 + getDate(i).toXMLFile(rOut);
3003 + rOut << endl << "\t</changelog>";
3007 +void XMLChangelog::toRPMStruct(Spec spec)
3010 Index: xmlspec/XMLChangelog.h
3011 ===================================================================
3012 RCS file: xmlspec/XMLChangelog.h
3013 diff -N xmlspec/XMLChangelog.h
3014 --- /dev/null 1 Jan 1970 00:00:00 -0000
3015 +++ rpm/xmlspec/XMLChangelog.h 28 Aug 2002 10:52:43 -0000 1.3.2.1
3017 +#ifndef _H_XMLCHANGELOG_
3018 +#define _H_XMLCHANGELOG_
3020 +// standard C++ includes
3021 +#include <iostream>
3025 +// standard includes
3029 +#include "XMLAttrs.h"
3030 +#include "XMLBase.h"
3033 +#include <rpmbuild.h>
3035 +// forward class definitions
3037 +class XMLChangelog;
3039 +using namespace std;
3041 +class XMLChangelogEntry : public XMLBase
3044 +// factory functions
3048 + * Adds a changelog entry
3050 + * @param pAttrs The XML attributes
3051 + * @param szEntry The entry to create
3052 + * @param pSpec Pointer to our spec
3053 + * @return true on success, false othersise
3055 + static bool parseCreate(XMLAttrs* pAttrs,
3056 + const char* szEntry,
3061 + * Creates changelog entries from the data provided to us by RPM
3062 + * @param szEntries The netries we are to evaluate
3063 + * @param pXSpec pointer to the XML spec we are working with
3064 + * @return true on success,. false otherwise
3066 + static bool structCreate(const char* szEntries,
3070 +// constructors/destructor
3074 + * Default contructor
3076 + * @param szChange The change entry
3079 + XMLChangelogEntry(const char* szChange);
3082 + * Copy constructor
3084 + * @param rEntry Reference to the entry to copy
3087 + XMLChangelogEntry(const XMLChangelogEntry& rEntry);
3095 + ~XMLChangelogEntry();
3098 +// member functions
3102 + * Outputs the object into a spec file
3104 + * @param rOut Reference to our output stream
3107 + void toSpecFile(ostream& rOut);
3110 + * Outputs the object into an XML spec file
3112 + * @param rOut Reference to our output stream
3115 + void toXMLFile(ostream& rOut);
3118 +// member variable get/set functions
3122 + * Returns the enrty
3125 + * @return string containing the entry
3127 + const char* getChange()
3129 + return m_sChange.c_str();
3133 +// member variables
3139 +class XMLChangelogDate : public XMLBase
3142 +// factory functions
3146 + * Creates a XMLChangelogDate object
3148 + * @param pAttrs The XML attributes
3149 + * @param pSpec The spec to add this object to
3150 + * @return true on success, false otherwise
3152 + static bool parseCreate(XMLAttrs* pAttrs,
3156 + * Creates an XMLChangelogDate object from the information provided to
3159 + * @param szDate The date to generate this for
3160 + * @param szEntries The entries to add to this date
3161 + * @param pXSpec The XML spec we are working with
3162 + * @return true on success, false otherwise
3164 + static bool structCreate(const char* szDate,
3165 + const char* szName,
3166 + const char* szEntries,
3170 +// constructors/destructor
3174 + * Default contructor
3176 + * @param szDate The date
3177 + * @param szAuthor The author
3178 + * @param szEmail The author's email
3179 + * @param szVersion The version in which this change was made
3182 + XMLChangelogDate(const char* szDate,
3183 + const char* szAuthor,
3184 + const char* szEmail,
3185 + const char* szVersion);
3190 + * @param rDate Reference to the date object to copy
3193 + XMLChangelogDate(const XMLChangelogDate& rDate);
3201 + ~XMLChangelogDate();
3204 +// public member functions
3208 + * Outputs the object into a spec file
3210 + * @param rOut Reference to our output stream
3213 + void toSpecFile(ostream& rOut);
3216 + * Outputs the object into an XML spec file
3218 + * @param rOut Reference to our output stream
3221 + void toXMLFile(ostream& rOut);
3224 +// member variables get/set functions
3228 + * Returns the date for the group of entries
3231 + * @return string representation of the date
3233 + const char* getDate()
3235 + return m_sDate.c_str();
3239 + * Checks for an author
3242 + * @return true if we have an author, false otherwise
3246 + return m_sAuthor.length() ? true : false;
3250 + * Returns the author's name
3253 + * @return string containing the author's name
3255 + const char* getAuthor()
3257 + return m_sAuthor.c_str();
3261 + * Checks if we have an email address for the author
3264 + * @return true if we hava an email, false otherwise
3268 + return m_sEmail.length() ? true : false;
3272 + * Returns the author's email addresse
3275 + * @return a string containing the author's email address
3277 + const char* getEmail()
3279 + return m_sEmail.c_str();
3283 + * Checks if we have a change version
3286 + * @return true if we have a version, false otherwise
3290 + return m_sVersion.length() ? true : false;
3294 + * Gets the change version
3297 + * @return string containing the version
3299 + const char* getVersion()
3301 + return m_sVersion.c_str();
3305 + * Returns the number of entries for this date
3308 + * @return the number of entries
3310 + unsigned int numEntries()
3312 + return m_vEntries.size();
3316 + * Returns a specific entry
3318 + * @param nNum The number of the entry to return
3319 + * @return the enrty
3321 + XMLChangelogEntry& getEntry(unsigned int nNum)
3323 + return m_vEntries[nNum];
3327 + * Adds an entry for this date
3329 + * @param szEntry The entry to add
3332 + void addEntry(XMLChangelogEntry& rEntry)
3334 + m_vEntries.push_back(rEntry);
3338 +// member variables
3344 + string m_sVersion;
3345 + vector<XMLChangelogEntry> m_vEntries;
3348 +class XMLChangelog : public XMLBase
3351 +// static factory functions
3355 + * Creates changelog objects from an RPM Spec structure
3357 + * @param pSpec Pointer to the RPM spec
3358 + * @param pXSpec pointer to the XMLSpec object to populate
3359 + * @return true on success, false otherwise
3361 + static bool structCreate(Spec pSpec,
3365 +// constructors/destructor
3369 + * Default constructor
3377 + * Copy constructor
3379 + * @param rChangelog The object to copy
3382 + XMLChangelog(const XMLChangelog& rChangelog);
3393 +// public member functions
3397 + * Converts the object into a spec file
3399 + * @param rOut Reference to the output stream
3402 + void toSpecFile(ostream& rOut);
3405 + * Converts the object into an xML spec
3407 + * @param rOut Reference to the output stream
3410 + void toXMLFile(ostream& rOut);
3413 + * Converts the object into an RPM structure
3415 + * @param spec RPM structure
3418 + void toRPMStruct(Spec spec);
3420 +// variable get/set functions
3424 + * Adds a date to the changelog
3426 + * @param rDate The date to add
3429 + void addDate(XMLChangelogDate& rDate)
3431 + m_vDates.push_back(rDate);
3435 + * Returns the number of dates in the changelog
3438 + * @return the number of dates
3440 + unsigned int numDates()
3442 + return m_vDates.size();
3446 + * Gets a specific date
3448 + * @param nNum The entry number
3449 + * @return The requated date
3451 + XMLChangelogDate& getDate(unsigned int nNum)
3453 + return m_vDates[nNum];
3457 + * Gets the last date we have added
3460 + * @return the last date
3462 + XMLChangelogDate& lastDate()
3464 + return m_vDates[numDates()-1];
3468 +// member variables
3471 + vector<XMLChangelogDate> m_vDates;
3475 Index: xmlspec/XMLFiles.cpp
3476 ===================================================================
3477 RCS file: xmlspec/XMLFiles.cpp
3478 diff -N xmlspec/XMLFiles.cpp
3479 --- /dev/null 1 Jan 1970 00:00:00 -0000
3480 +++ rpm/xmlspec/XMLFiles.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
3482 +// standard includes
3486 +#include "XMLAttrs.h"
3487 +#include "XMLFiles.h"
3488 +#include "XMLPackage.h"
3489 +#include "XMLSpec.h"
3492 +#include <rpmlib.h>
3493 +#include <stringbuf.h>
3495 +using namespace std;
3497 +// attribute structure for XMLFile
3498 +structValidAttrs g_paFileAttrs[] =
3500 + {0x0000, false, false, "mode", XATTRTYPE_INTEGER, {NULL}},
3501 + {0x0001, false, false, "group", XATTRTYPE_STRING, {"*", NULL}},
3502 + {0x0002, false, false, "user", XATTRTYPE_STRING, {"*", NULL}},
3503 + {0x0003, false, false, "config", XATTRTYPE_STRING, {"noreplace",
3505 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
3508 +bool XMLFile::parseCreate(XMLAttrs* pAttrs,
3509 + const char* szPath,
3512 + // validate the attributes
3513 + if (!pSpec || !pAttrs->validate(g_paFileAttrs, (XMLBase*)pSpec))
3516 + // create and return
3517 + XMLFile file(pAttrs->asString("mode"), pAttrs->asString("user"),
3518 + pAttrs->asString("group"), pAttrs->asString("config"), szPath);
3519 + pSpec->lastPackage().getFiles().addFile(file);
3523 +XMLFile::XMLFile(const char* szMode,
3524 + const char* szOwner,
3525 + const char* szGroup,
3526 + const char* szConfig,
3527 + const char* szPath)
3531 + m_sMode.assign(szMode);
3533 + m_sOwner.assign(szOwner);
3535 + m_sGroup.assign(szGroup);
3537 + m_sConfig.assign(szConfig);
3539 + m_sPath.assign(szPath);
3542 +XMLFile::XMLFile(const XMLFile& rFile)
3545 + setMode(rFile.m_sMode.c_str());
3546 + setOwner(rFile.m_sOwner.c_str());
3547 + setGroup(rFile.m_sGroup.c_str());
3548 + setConfig(rFile.m_sConfig.c_str());
3549 + setPath(rFile.m_sPath.c_str());
3552 +XMLFile::~XMLFile()
3556 +XMLFile XMLFile::operator=(XMLFile file)
3558 + setMode(file.m_sMode.c_str());
3559 + setOwner(file.m_sOwner.c_str());
3560 + setGroup(file.m_sGroup.c_str());
3561 + setConfig(file.m_sConfig.c_str());
3562 + setPath(file.m_sPath.c_str());
3565 +void XMLFile::toSpecFile(ostream& rOut)
3567 + if (hasMode() || hasOwner() || hasGroup()) {
3569 + rOut << (hasMode() ? getMode() : "-");
3570 + rOut << "," << (hasOwner() ? getOwner() : "-");
3571 + rOut << "," << (hasGroup() ? getGroup() : "-");
3574 + if (hasConfig()) {
3575 + rOut << "%config(" << getConfig() << ") ";
3577 + rOut << getPath() << endl;
3580 +void XMLFile::toXMLFile(ostream& rOut)
3582 + rOut << endl << "\t\t\t<file";
3584 + rOut << " mode=\"" << getMode() << "\"";
3586 + rOut << " user=\"" << getOwner() << "\"";
3588 + rOut << " group=\"" << getGroup() << "\"";
3590 + rOut << " config=\"" << getConfig() << "\"";
3592 + rOut << getPath() << "</file>";
3595 +// attribute structure for XMLFiles
3596 +structValidAttrs g_paFilesAttrs[] =
3598 + {0x0000, false, false, "mode", XATTRTYPE_INTEGER, {NULL}},
3599 + {0x0001, false, false, "group", XATTRTYPE_STRING, {"*", NULL}},
3600 + {0x0002, false, false, "user", XATTRTYPE_STRING, {"*", NULL}},
3601 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
3604 +bool XMLFiles::parseCreate(XMLAttrs* pAttrs,
3607 + if (!pSpec || !pAttrs->validate(g_paFilesAttrs, (XMLBase*)pSpec))
3609 + pSpec->lastPackage().getFiles().setDefMode(pAttrs->asString("mode"));
3610 + pSpec->lastPackage().getFiles().setDefOwner(pAttrs->asString("user"));
3611 + pSpec->lastPackage().getFiles().setDefGroup(pAttrs->asString("group"));
3615 +bool XMLFiles::structCreate(PackageStruct* pPackage,
3619 + if (!pXSpec || !pSpec || !pPackage || !pPackage->fileList)
3624 +XMLFiles::XMLFiles()
3629 +XMLFiles::XMLFiles(const XMLFiles& rFiles)
3632 + setDefMode(rFiles.m_sMode.c_str());
3633 + setDefOwner(rFiles.m_sOwner.c_str());
3634 + setDefGroup(rFiles.m_sGroup.c_str());
3635 + m_vFiles = rFiles.m_vFiles;
3638 +XMLFiles::~XMLFiles()
3642 +XMLFiles XMLFiles::operator=(XMLFiles files)
3644 + setDefMode(files.m_sMode.c_str());
3645 + setDefOwner(files.m_sOwner.c_str());
3646 + setDefGroup(files.m_sGroup.c_str());
3647 + m_vFiles = files.m_vFiles;
3651 +void XMLFiles::toSpecFile(ostream& rOut)
3654 + if (hasDefMode() || hasDefOwner() || hasDefGroup()) {
3655 + rOut << "%defattr(";
3656 + rOut << (hasDefMode() ? getDefMode() : "-");
3657 + rOut << "," << (hasDefOwner() ? getDefOwner() : "-");
3658 + rOut << "," << (hasDefGroup() ? getDefGroup() : "-");
3659 + rOut << ")" << endl;
3661 + for (unsigned int i = 0; i < numFiles(); i++)
3662 + getFile(i).toSpecFile(rOut);
3666 +void XMLFiles::toXMLFile(ostream& rOut)
3669 + rOut << endl << "\t\t<files";
3671 + rOut << " mode=\"" << getDefMode() << "\"";
3672 + if (hasDefOwner())
3673 + rOut << " user=\"" << getDefOwner() << "\"";
3674 + if (hasDefGroup())
3675 + rOut << " group=\"" << getDefGroup() << "\"";
3677 + for (unsigned int i = 0; i < numFiles(); i++)
3678 + getFile(i).toXMLFile(rOut);
3679 + rOut << endl << "\t\t</files>";
3682 Index: xmlspec/XMLFiles.h
3683 ===================================================================
3684 RCS file: xmlspec/XMLFiles.h
3685 diff -N xmlspec/XMLFiles.h
3686 --- /dev/null 1 Jan 1970 00:00:00 -0000
3687 +++ rpm/xmlspec/XMLFiles.h 28 Aug 2002 10:52:43 -0000 1.3.2.1
3689 +#ifndef _H_XMLFILES_
3690 +#define _H_XMLFILES_
3692 +// standard C++ includes
3693 +#include <iostream>
3697 +// standard includes
3701 +#include "XMLAttrs.h"
3702 +#include "XMLBase.h"
3705 +#include <rpmbuild.h>
3707 +// forward class definitions
3712 +using namespace std;
3715 +class XMLFile : public XMLBase
3718 +// object creation static functions
3722 + * Creates a file object and add it to the correct XMLFiles
3725 + * @param pAttrs The attributes in the XML tag
3726 + * @param szPath The file path
3727 + * @param pSpec The spec to which these files belong
3728 + * @return true on success, false otherwise
3730 + static bool parseCreate(XMLAttrs* pAttrs,
3731 + const char* szPath,
3735 +// constructors/destructor
3739 + * Default contructor
3741 + * @param szMode The file's mode (NULL if default)
3742 + * @param szOwner The file's owner (NULL if default)
3743 + * @param szGroup The file's group (NULL if default)
3744 + * @param szConfig The configuration parameter
3745 + * @param szPath The file path
3748 + XMLFile(const char* szMode,
3749 + const char* szUser,
3750 + const char* szGroup,
3751 + const char* szConfig,
3752 + const char* szPath);
3755 + * Copy constructire
3757 + * @param rFile Reference to the object to copy
3760 + XMLFile(const XMLFile& rFile);
3763 + * Default destructor
3775 + * Assignment operator
3777 + * @param file The file that we wish to copy
3778 + * @return a copy of the original
3780 + XMLFile operator=(XMLFile file);
3783 +// member functions
3787 + * Outputs the obkect to an RPM spec file
3789 + * @param rOut Reference to the output stream
3792 + void toSpecFile(ostream& rOut);
3795 + * Outputs the object to an XML spec file
3797 + * @param rOut Reference to the output stream
3800 + void toXMLFile(ostream& rOut);
3803 +// member variable get/set functions
3807 + * Returns the file path
3810 + * @return string containing the path
3812 + const char* getPath()
3814 + return m_sPath.c_str();
3818 + * Sets the file path
3820 + * @param szPath The path to set
3823 + void setPath(const char* szPath)
3826 + m_sPath.assign(szPath);
3830 + * Checks for a file mode
3833 + * @return true if we have one, false otherwise
3837 + return m_sMode.length() ? true : false;
3841 + * Returns the file mode
3844 + * @return the mode string
3846 + const char* getMode()
3848 + return m_sMode.c_str();
3852 + * Sets the file mode
3854 + * @param szMode The mode to set
3857 + void setMode(const char* szMode)
3860 + m_sMode.assign(szMode);
3864 + * Checks if we have a file owner
3867 + * @return true if we have an owner, false otherwise
3871 + return m_sOwner.length() ? true : false;
3875 + * Returns the file owner
3878 + * @return the owner as a string
3880 + const char* getOwner()
3882 + return m_sOwner.c_str();
3886 + * Sets the file owner
3888 + * @param szOwner The file owner
3891 + void setOwner(const char* szOwner)
3894 + m_sOwner.assign(szOwner);
3898 + * Checks for a file group
3901 + * @return true if we have a group, false otherwise
3905 + return m_sGroup.length() ? true : false;
3909 + * Returns the file group
3912 + * @return string containing the group
3914 + const char* getGroup()
3916 + return m_sGroup.c_str();
3920 + * Sets the file group
3922 + * @param szGroup The group to set
3925 + void setGroup(const char* szGroup)
3928 + m_sGroup.assign(szGroup);
3932 + * Checks for config directives
3935 + * @return true if we have one, false otherwise
3939 + return m_sConfig.length() ? true : false;
3943 + * Returns the config attribute
3946 + * @return the sttribute string
3948 + const char* getConfig()
3950 + return m_sConfig.c_str();
3954 + * Sets the config attribute
3956 + * @param szConfig The configuration
3959 + void setConfig(const char* szConfig)
3962 + m_sConfig.assign(szConfig);
3966 +// member variables
3977 +class XMLFiles : public XMLBase
3980 +// object creation static functions
3984 + * Creates an object as parsed from an XML spec
3986 + * @param pAttrs XML atrtributes to use
3987 + * @param pSpec The spec to which we are adding this object to
3988 + * @return true on success, false otherwise
3990 + static bool parseCreate(XMLAttrs* pAttrs,
3994 + * Creates file objects from an RPM Spec structure
3996 + * @param pPackage Pointer to the package
3997 + * @param pSpec Pointer to the RPM spec
3998 + * @param pXSpec pointer to the XMLSpec object to populate
3999 + * @return true on success, false otherwise
4001 + static bool structCreate(PackageStruct* pPackage,
4006 +// constructors/destructor
4010 + * Default constructor
4018 + * Copy constructor
4020 + * @param rFiles Reference to the object to copy
4023 + XMLFiles(const XMLFiles& rFiles);
4034 +// member functions
4038 + * Converts the object into an RPM spec
4040 + * @param rOut Output stream
4043 + void toSpecFile(ostream& rOut);
4046 + * Converts the object into an XML spec
4048 + * @param rOut Output stream
4051 + void toXMLFile(ostream& rOut);
4058 + * Assignment operator
4060 + * @param files XMLFiles object to copy
4061 + * @return copied object
4063 + XMLFiles operator=(XMLFiles files);
4066 +// member variable get/set functions
4070 + * Adds a file to our file list
4072 + * @param rFile File to add
4075 + void addFile(XMLFile& rFile)
4077 + m_vFiles.push_back(rFile);
4081 + * Returns the number of files in our list
4086 + unsigned int numFiles()
4088 + return m_vFiles.size();
4092 + * Returns a specific file
4094 + * @param nNum Number of the file to return
4095 + * @return the file object
4097 + XMLFile& getFile(unsigned int nNum)
4099 + return m_vFiles[nNum];
4103 + * Checks for a default mode
4106 + * @return true if we have a default mode, false otherwise
4110 + return m_sMode.length() ? true : false;
4114 + * Sets the default mode
4116 + * @param szMode The mode value
4119 + void setDefMode(const char* szMode)
4122 + m_sMode.assign(szMode);
4126 + * Returns the default mode
4129 + * @return string containing the mode
4131 + const char* getDefMode()
4133 + return m_sMode.c_str();
4137 + * Check if we have a default owner
4140 + * @return true if we have an owner, false otherwise
4142 + bool hasDefOwner()
4144 + return m_sOwner.length() ? true : false;
4148 + * Sets the default owner
4150 + * @param szOwner The owner
4153 + void setDefOwner(const char* szOwner)
4156 + m_sOwner.assign(szOwner);
4160 + * Returns the default owner
4163 + * @return the owner string
4165 + const char* getDefOwner()
4167 + return m_sOwner.c_str();
4171 + * Checks if we have a default group
4174 + * @return true if we have an owner, false otherwise
4176 + bool hasDefGroup()
4178 + return m_sGroup.length() ? true : false;
4182 + * Sets the default group
4184 + * @param szGroup The group to set
4187 + void setDefGroup(const char* szGroup)
4190 + m_sGroup.assign(szGroup);
4194 + * Gets the default group
4197 + * @return string representation of the group
4199 + const char* getDefGroup()
4201 + return m_sGroup.c_str();
4205 +// member variables
4211 + vector<XMLFile> m_vFiles;
4215 Index: xmlspec/XMLMacro.cpp
4216 ===================================================================
4217 RCS file: xmlspec/XMLMacro.cpp
4218 diff -N xmlspec/XMLMacro.cpp
4219 --- /dev/null 1 Jan 1970 00:00:00 -0000
4220 +++ rpm/xmlspec/XMLMacro.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
4223 +#include "XMLMacro.h"
4224 +#include "XMLSpec.h"
4226 +using namespace std;
4228 +// attribute structure for XMLMacro
4229 +structValidAttrs g_paMacroAttrs[] =
4231 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
4232 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4235 +bool XMLMacro::parseCreate(XMLAttrs* pAttrs,
4236 + const char* szMacro,
4239 + if (!pSpec || !szMacro || !pAttrs->validate(g_paMacroAttrs, (XMLBase*)pAttrs))
4241 + XMLMacro macro(pAttrs->asString("name"), szMacro);
4242 + pSpec->addXMacro(macro);
4246 +XMLMacro::XMLMacro(const char* szName,
4247 + const char* szMacro)
4251 + m_sName.assign(szName);
4253 + m_sValue.assign(szMacro);
4256 +XMLMacro::XMLMacro(const XMLMacro& rMacro)
4259 + m_sName.assign(rMacro.m_sName);
4260 + m_sValue.assign(rMacro.m_sValue);
4263 +XMLMacro::~XMLMacro()
4267 +XMLMacro XMLMacro::operator=(XMLMacro macro)
4269 + m_sName.assign(macro.m_sName);
4270 + m_sValue.assign(macro.m_sValue);
4273 +void XMLMacro::toSpecFile(ostream& rOut)
4275 + rOut << "%define " << getName() << " " << getValue() << endl;
4278 +void XMLMacro::toXMLFile(ostream& rOut)
4280 + rOut << endl << "\t<macro name=\"" << getName() << "\">";
4281 + rOut << getValue() << "</macro>";
4283 Index: xmlspec/XMLMacro.h
4284 ===================================================================
4285 RCS file: xmlspec/XMLMacro.h
4286 diff -N xmlspec/XMLMacro.h
4287 --- /dev/null 1 Jan 1970 00:00:00 -0000
4288 +++ rpm/xmlspec/XMLMacro.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
4290 +#ifndef _H_XMLMACRO_
4291 +#define _H_XMLMACRO_
4293 +// standard C++ includes
4294 +#include <iostream>
4298 +#include "XMLAttrs.h"
4300 +// forward class definitions
4303 +using namespace std;
4306 +class XMLMacro : public XMLBase
4309 +// factory functions
4313 + * Creates an XMLMacro object
4315 + * @param pAttrs XML tag attributes
4316 + * @param szMacro The macro contents
4317 + * @param pSpec the spec to add the macro to
4318 + * @return true on success, false otherwise
4320 + static bool parseCreate(XMLAttrs* pAttrs,
4321 + const char* szMacro,
4325 +// constructors/destructor
4329 + * Default constructor
4331 + * @param szName The name of the macro
4332 + * @param szMacro The expanded macro
4335 + XMLMacro(const char* szName,
4336 + const char* szMacro);
4339 + * Copy constructor
4341 + * @param rMacro the macro to copy
4344 + XMLMacro(const XMLMacro& rMacro);
4359 + * Assignment operator
4361 + * @param macro The macro to copy
4362 + * @return our copied object
4364 + XMLMacro operator=(XMLMacro macro);
4367 +// member functions
4371 + * Outputs the macro into an RPM spec
4373 + * @param rOut Output stream
4376 + void toSpecFile(ostream& rOut);
4379 + * Outputs the macro into an XML spec
4381 + * @param rOut Output stream
4384 + void toXMLFile(ostream& rOut);
4387 +// member get/set functions
4391 + * Gets the macro name
4394 + * @return string containing the macro name
4396 + const char* getName()
4398 + return m_sName.c_str();
4402 + * Gets tha macro value
4405 + * @return string contatining the macro value
4407 + const char* getValue()
4409 + return m_sValue.c_str();
4413 +// member variables
4421 Index: xmlspec/XMLMirror.cpp
4422 ===================================================================
4423 RCS file: xmlspec/XMLMirror.cpp
4424 diff -N xmlspec/XMLMirror.cpp
4425 --- /dev/null 1 Jan 1970 00:00:00 -0000
4426 +++ rpm/xmlspec/XMLMirror.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
4429 +#include "XMLMirror.h"
4430 +#include "XMLSpec.h"
4432 +using namespace std;
4434 +// attribute structure for XMLMirror
4435 +structValidAttrs g_paMirrorAttrs[] =
4437 + {0x0000, true, false, "path", XATTRTYPE_STRING, {"*", NULL}},
4438 + {0x0001, false, false, "description", XATTRTYPE_STRING, {"*", NULL}},
4439 + {0x0002, false, false, "country", XATTRTYPE_STRING, {"*", NULL}},
4440 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4443 +bool XMLMirror::parseCreate(XMLAttrs* pAttrs,
4447 + // validate the attributes
4448 + if (!pAttrs->validate(g_paMirrorAttrs, (XMLBase*)pSpec))
4451 + XMLMirror mirror(pAttrs->asString("path"),
4452 + pAttrs->asString("description"),
4453 + pAttrs->asString("country"));
4454 + if (bPatch && pSpec->numPatches())
4455 + pSpec->lastPatch().addMirror(mirror);
4456 + else if (!bPatch && pSpec->numSources())
4457 + pSpec->lastSource().addMirror(mirror);
4461 +XMLMirror::XMLMirror(const char* szPath,
4462 + const char* szDescription,
4463 + const char* szCountry) : XMLBase()
4466 + m_sPath.assign(szPath);
4467 + if (szDescription)
4468 + m_sDescription.assign(szDescription);
4470 + m_sCountry.assign(szCountry);
4473 +XMLMirror::XMLMirror(const XMLMirror& rMirror)
4476 + m_sPath.assign(rMirror.m_sPath);
4477 + m_sDescription.assign(rMirror.m_sDescription);
4478 + m_sCountry.assign(rMirror.m_sCountry);
4481 +XMLMirror::~XMLMirror()
4485 +XMLMirror XMLMirror::operator=(XMLMirror mirror)
4487 + m_sPath.assign(mirror.m_sPath);
4488 + m_sDescription.assign(mirror.m_sDescription);
4489 + m_sCountry.assign(mirror.m_sCountry);
4492 +void XMLMirror::toSpecFile(ostream& rOut)
4494 + rOut << endl << "# mirror: " << getPath();
4497 +void XMLMirror::toXMLFile(ostream& rOut)
4499 + rOut << endl << "\t\t<mirror path=\"" << getPath() << "\"";
4500 + if (hasDescription())
4501 + rOut << endl << "\t\t description=\"" << getDescription() << "\"";
4503 + rOut << endl << "\t\t country=\"" << getCountry() << "\"";
4506 Index: xmlspec/XMLMirror.h
4507 ===================================================================
4508 RCS file: xmlspec/XMLMirror.h
4509 diff -N xmlspec/XMLMirror.h
4510 --- /dev/null 1 Jan 1970 00:00:00 -0000
4511 +++ rpm/xmlspec/XMLMirror.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
4513 +#ifndef _H_XMLMIRROR_
4514 +#define _H_XMLMIRROR_
4516 +// standard C++ includes
4519 +#include <iostream>
4522 +#include "XMLAttrs.h"
4523 +#include "XMLBase.h"
4525 +// forward declaration
4528 +using namespace std;
4531 +class XMLMirror : public XMLBase
4534 +// static object creation functions
4538 + * static function for creation of an XMLMirror object
4540 + * @param pAttrs Pointer to our attribute structure
4541 + * @param pSpec Pointer to our spec that is to ultimately
4542 + * contain the object
4543 + * @param bPatch true if we are handling the mirror for a patch
4544 + * @return true on success, false otherwise
4546 + static bool parseCreate(XMLAttrs* pAttrs,
4548 + bool bPatch = false);
4551 +// constructors/destructor
4555 + * Default constructor for the XMLMirror object
4557 + * @param szPath Full path for the mirror
4558 + * @param szDescription Full mirror description
4559 + * @param szCoutry Country code for the mirror
4562 + XMLMirror(const char* szPath,
4563 + const char* szDescription,
4564 + const char* szCountry);
4569 + * @param rMirror Reference to the object to copy
4572 + XMLMirror(const XMLMirror& rMirror);
4575 + * Destructor for an XMLMirror object
4587 + * Assignment operator
4589 + * @param mirror The mirror to get the values from
4590 + * @return The modified object
4592 + XMLMirror operator=(XMLMirror mirror);
4595 +// public member functions
4599 + * Converts an XMLMirror object to a RPM spec file
4601 + * @param rOut File stream
4604 + void toSpecFile(ostream& rOut);
4607 + * Converts an XMLMirror object to an XML spec file
4609 + * @param rOut File stream
4612 + void toXMLFile(ostream& rOut);
4615 +// member variable get/set functions
4619 + * Checks if we have a path
4622 + * @return true if we have a path, false otherise
4626 + return m_sPath.length() ? true : false;
4630 + * Returns the path
4633 + * @return The path strinbg
4635 + const char* getPath()
4637 + return m_sPath.c_str();
4641 + * Checks if we have a description set
4644 + * @return true is we have a description, false otherwise
4646 + bool hasDescription()
4648 + return m_sDescription.length() ? true : false;
4652 + * Returns the description
4655 + * @return the description string
4657 + const char* getDescription()
4659 + return m_sDescription.c_str();
4663 + * Checks if we have a country set
4666 + * @return true if we have a country, false otherwise
4670 + return m_sCountry.length() ? true : false;
4674 + * Gets the country
4677 + * @return The country string
4679 + const char* getCountry()
4681 + return m_sCountry.c_str();
4685 +// member variables
4689 + string m_sDescription;
4690 + string m_sCountry;
4694 Index: xmlspec/XMLMisc.cpp
4695 ===================================================================
4696 RCS file: xmlspec/XMLMisc.cpp
4697 diff -N xmlspec/XMLMisc.cpp
4698 --- /dev/null 1 Jan 1970 00:00:00 -0000
4699 +++ rpm/xmlspec/XMLMisc.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
4701 +// standard c includes
4703 +#include <stdlib.h>
4704 +#include <string.h>
4706 +using namespace std;
4708 +char* g_szaDays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL };
4709 +char* g_szaMonths[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
4710 + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
4711 +int g_naLengths[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
4712 +char* g_szaBools[] = { "no", "yes", "false", "true", "0", "1", NULL };
4714 +char* splitStr(const char* szInput,
4719 + while (szInput[nLen] != cTerm && szInput[nLen] != '\0') {
4722 + char* szTemp = ((char*)szInput)+nLen;
4723 + while (*szTemp == cTerm && *szTemp != '\0')
4728 +int findStr(char* szaMatches[],
4729 + const char* szValue,
4732 + for (unsigned int i = 0; szaMatches[i] != NULL; i++) {
4733 + if (strcmp(szaMatches[i], "*") == 0)
4735 + else if (nLen == -1) {
4736 + if (strcasecmp(szaMatches[i], szValue) == 0)
4739 + else if (strncasecmp(szaMatches[i], szValue, nLen) == 0)
4745 +bool isInteger(const char* szValue,
4749 + nLen = strlen(szValue);
4750 + for (unsigned int i = 0; i < strlen(szValue); i++) {
4751 + if (szValue[i] < '0' || szValue[i] > '9')
4757 +bool isBool(const char* szValue,
4760 + return findStr(g_szaBools, szValue, nLen) != -1 ? true : false;
4763 +bool isDate(const char* szValue)
4766 + char* szTemp = splitStr(szValue, ' ', nLen);
4767 + if ((nPos = findStr(g_szaDays, szValue, nLen)) != -1) {
4768 + if ((nPos = findStr(g_szaMonths, szTemp, nLen)) != -1) {
4769 + szTemp = splitStr(szTemp, ' ', nLen);
4770 + char* szBuffer = new char[nLen+1];
4771 + sprintf(szBuffer, "%s", szTemp);
4772 + szBuffer[nLen] = '\0';
4773 + if (atoi(szBuffer) <= g_naLengths[nPos]) {
4774 + delete[] szBuffer;
4775 + szTemp = splitStr(szTemp, ' ', nLen);
4776 + return isInteger(szTemp, nLen);
4778 + delete[] szBuffer;
4784 +bool isEmail(const char* szValue)
4786 + bool bFound = false;
4787 + for (unsigned int j = 0; j < strlen(szValue); j++) {
4788 + if (szValue[j] == '@') {
4797 Index: xmlspec/XMLMisc.h
4798 ===================================================================
4799 RCS file: xmlspec/XMLMisc.h
4800 diff -N xmlspec/XMLMisc.h
4801 --- /dev/null 1 Jan 1970 00:00:00 -0000
4802 +++ rpm/xmlspec/XMLMisc.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
4804 +#ifndef _H_XMLMISC_
4805 +#define _H_XMLMISC_
4807 +extern char* g_szaDays[];
4808 +extern char* g_szaMonths[];
4811 + * Splits the input string according to the terminator, returning
4812 + * the length and the new search position
4814 + * @param szInput The input string
4815 + * @param cTerm The terminating character
4816 + * @param nLen the length buffer
4817 + * @return The next string position
4819 +extern char* splitStr(const char* szInput,
4824 + * Finds a string in an array of potential matches
4826 + * @param szaMatches The potential matches
4827 + * @param szValue The value to search for
4828 + * @return The position on success, -1 if not found
4830 +extern int findStr(char* szaMatches[],
4831 + const char* szValue,
4835 + * Checks if a string contains an integer
4837 + * @param szValue The string to check
4838 + * @param nLen The length to check, -1 to end of string
4839 + * @return true if the string is an integer, false otherwise
4841 +extern bool isInteger(const char* szValue,
4845 + * Checks if a string contains a boolean value
4847 + * @param szValue The value to check
4848 + * @return true if we have a boolean, false otherwise
4850 +extern bool isBool(const char* szValue,
4854 + * Checks if a string is in a valid date format
4856 + * @param szValue The string to check
4857 + * @return true is this is a date, false otherwise
4859 +extern bool isDate(const char* szValue);
4862 + * Checks if a string contains a valid e-mail address
4864 + * @param szValue the string to check
4865 + * @return true if this is an email address, false otherwise
4867 +extern bool isEmail(const char* szValue);
4870 Index: xmlspec/XMLPackage.cpp
4871 ===================================================================
4872 RCS file: xmlspec/XMLPackage.cpp
4873 diff -N xmlspec/XMLPackage.cpp
4874 --- /dev/null 1 Jan 1970 00:00:00 -0000
4875 +++ rpm/xmlspec/XMLPackage.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
4877 +// standard C++ includes
4881 +#include "XMLPackage.h"
4882 +#include "XMLRPMWrap.h"
4883 +#include "XMLSpec.h"
4886 +#include <rpmlib.h>
4888 +// attribute structure for XMLPackage
4889 +structValidAttrs g_paPackageAttrs[] =
4891 + {0x0000, false, false, "name", XATTRTYPE_STRING, {"*", NULL}},
4892 + {0x0001, true, false, "group", XATTRTYPE_STRING, {"*", NULL}},
4893 + {0x0002, false, false, "autoreq", XATTRTYPE_BOOL, {NULL}},
4894 + {0x0003, false, false, "autoprov", XATTRTYPE_BOOL, {NULL}},
4895 + {0x0004, false, false, "autoreqprov", XATTRTYPE_BOOL, {NULL}},
4896 + {0x0005, false, false, "sub", XATTRTYPE_BOOL, {NULL}},
4897 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4900 +bool XMLPackage::parseCreate(XMLAttrs* pAttrs,
4903 + // validate the attributes
4904 + if (!pAttrs->validate(g_paPackageAttrs, (XMLBase*)pSpec))
4907 + // setup the name attribute
4909 + if (pAttrs->asString("name"))
4910 + sName.assign(pAttrs->asString("name"));
4912 + // if we have a name, cool, now test if the package already exists
4913 + if (sName.length()) {
4914 + XMLPackage package(sName.c_str(), pAttrs->asString("group"),
4915 + pAttrs->asBool("autoreq") || pAttrs->asBool("autoreqprov"),
4916 + pAttrs->asBool("autoprov") || pAttrs->asBool("autoreqprov"),
4917 + pAttrs->asBool("sub"));
4918 + pSpec->addPackage(package);
4921 + // already something existing with %{name} ?
4923 + XMLPackage package(NULL, pAttrs->asString("group"),
4924 + pAttrs->asBool("autoreq") || pAttrs->asBool("autoreqprov"),
4925 + pAttrs->asBool("autoprov") || pAttrs->asBool("autoreqprov"),
4926 + pAttrs->asBool("sub"));
4927 + pSpec->addPackage(package);
4932 +bool XMLPackage::structCreate(PackageStruct* pPackage,
4936 + if (!pXSpec || !pSpec || !pPackage || !pPackage->header)
4939 + string sGroup, sName;
4940 + if (!getRPMHeader(pPackage->header, RPMTAG_GROUP, sGroup))
4942 + getRPMHeader(pPackage->header, RPMTAG_NAME, sName);
4943 + bool bSub = false;
4944 + if (sName.compare(pXSpec->getName()) == 0) {
4948 + XMLPackage package(bSub ? NULL : sName.c_str(), sGroup.c_str(),
4949 + pPackage->autoReq ? true : false,
4950 + pPackage->autoProv ? true : false,
4952 + t_StrVector svText;
4953 + t_StrVector svLang;
4954 + getRPMHeaderArray(pPackage->header, RPMTAG_HEADERI18NTABLE, svLang);
4955 + if (getRPMHeaderArray(pPackage->header, RPMTAG_SUMMARY, svText)) {
4956 + for (unsigned int i = 0; i < svText.size(); i++)
4957 + package.addSummary(svText[i].c_str(), svLang[i].c_str());
4959 + if (getRPMHeaderArray(pPackage->header, RPMTAG_DESCRIPTION, svText)) {
4960 + for (unsigned int i = 0; i < svText.size(); i++)
4961 + package.addDescription(svText[i].c_str(), svLang[i].c_str());
4963 + pXSpec->addPackage(package);
4965 + XMLPackageContainer::structCreate(pPackage, pSpec, pXSpec);
4966 + XMLFiles::structCreate(pPackage, pSpec, pXSpec);
4968 + // do the next package and return
4969 + XMLPackage::structCreate(pPackage->next, pSpec, pXSpec);
4973 +// attribute structure for summaries
4974 +structValidAttrs g_paDescriptionAttrs[] =
4976 + {0x0000, false, false, "lang", XATTRTYPE_STRING, {"*", NULL}},
4977 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4980 +bool XMLPackage::addDescription(XMLAttrs* pAttrs,
4981 + const char* szDescription,
4984 + if (pSpec && pAttrs->validate(g_paDescriptionAttrs, (XMLBase*)pSpec)) {
4985 + pSpec->lastPackage().addDescription(szDescription, pAttrs->asString("lang"));
4992 +// attribute structure for summaries
4993 +structValidAttrs g_paSummaryAttrs[] =
4995 + {0x0000, false, false, "lang", XATTRTYPE_STRING, {"*", NULL}},
4996 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4999 +bool XMLPackage::addSummary(XMLAttrs* pAttrs,
5000 + const char* szSummary,
5003 + if (pSpec && pAttrs->validate(g_paSummaryAttrs, (XMLBase*)pSpec)) {
5004 + pSpec->lastPackage().addSummary(szSummary, pAttrs->asString("lang"));
5011 +XMLPackage::XMLPackage(const char* szName,
5012 + const char* szGroup,
5019 + setGroup(szGroup);
5020 + setSubPackage(bSub);
5021 + setAutoRequires(bAutoReq);
5022 + setAutoProvides(bAutoProv);
5025 +XMLPackage::XMLPackage(const XMLPackage& rPackage)
5028 + setName(rPackage.m_sName.c_str());
5029 + setGroup(rPackage.m_sGroup.c_str());
5030 + setSubPackage(rPackage.m_bSub);
5031 + setAutoRequires(rPackage.m_bAutoReq);
5032 + setAutoProvides(rPackage.m_bAutoProv);
5033 + m_vSummaries = rPackage.m_vSummaries;
5034 + m_vDescriptions = rPackage.m_vDescriptions;
5035 + m_Requires = rPackage.m_Requires;
5036 + m_BuildRequires = rPackage.m_BuildRequires;
5037 + m_Provides = rPackage.m_Provides;
5038 + m_Obsoletes = rPackage.m_Obsoletes;
5039 + m_Post = rPackage.m_Post;
5040 + m_PostUn = rPackage.m_PostUn;
5041 + m_Pre = rPackage.m_Pre;
5042 + m_PreUn = rPackage.m_PreUn;
5043 + m_Verify = rPackage.m_Verify;
5044 + m_Files = rPackage.m_Files;
5047 +XMLPackage::~XMLPackage()
5051 +void XMLPackage::toSpecFile(ostream& rOut)
5053 + // top package bit
5055 + rOut << endl << "%package";
5056 + rOut << (!isSubPackage() ? " -n " : " ") << getName() << endl;
5059 + rOut << endl << endl;
5061 + for (unsigned int i = 0; i < numSummaries(); i++) {
5062 + rOut << "summary";
5063 + if (getSummary(i).hasLang())
5064 + rOut << "(" << getSummary(i).getLang() << "):";
5067 + rOut << " " << getSummary(i).getText() << endl;
5070 + rOut << "group: " << getGroup() << endl;
5071 + if (!hasAutoRequires() && !hasAutoProvides())
5072 + rOut << "autoreqprov: no" << endl;
5074 + if (!hasAutoRequires())
5075 + rOut << "autoreq: no" << endl;
5076 + if (!hasAutoProvides())
5077 + rOut << "autoprov: no" << endl;
5080 + getProvides().toSpecFile(rOut, "provides");
5081 + getObsoletes().toSpecFile(rOut, "obsoletes");
5082 + getRequires().toSpecFile(rOut, "requires");
5083 + getBuildRequires().toSpecFile(rOut, "buildrequires");
5085 + // add the description
5086 + for (unsigned int i = 0; i < numDescriptions(); i++) {
5087 + rOut << "%description ";
5088 + if (getDescription(i).hasLang())
5089 + rOut << "-l " << getDescription(i).getLang() << " ";
5091 + rOut << (!isSubPackage() ? "-n " : "");
5092 + rOut << getName();
5094 + rOut << endl << getDescription(i).getText() << endl;
5098 +void toSectionSpecFile(ostream& rOut,
5099 + const char* szSection,
5102 + rOut << endl << "%" << szSection;
5103 + if (pPkg->hasName())
5104 + rOut << (!pPkg->isSubPackage() ? " -n " : " ") << pPkg->getName();
5108 +void XMLPackage::toScriptsSpecFile(ostream& rOut)
5110 + if (getPre().numScripts()) {
5111 + toSectionSpecFile(rOut, "pre", this);
5112 + getPre().toSpecFile(rOut, "pre");
5115 + if (getPost().numScripts()) {
5116 + toSectionSpecFile(rOut, "post", this);
5117 + getPost().toSpecFile(rOut, "post");
5120 + if (getPreUn().numScripts()) {
5121 + toSectionSpecFile(rOut, "preun", this);
5122 + getPreUn().toSpecFile(rOut, "preun");
5125 + if (getPostUn().numScripts()) {
5126 + toSectionSpecFile(rOut, "postun", this);
5127 + getPostUn().toSpecFile(rOut, "postun");
5130 + if (getVerify().numScripts()) {
5131 + toSectionSpecFile(rOut, "verifyscript", this);
5132 + getVerify().toSpecFile(rOut, "verifyscript");
5136 +void XMLPackage::toFilesSpecFile(ostream& rOut)
5138 + rOut << endl << "%files";
5140 + rOut << (!isSubPackage() ? " -n " : " ") << getName();
5142 + getFiles().toSpecFile(rOut);
5145 +void XMLPackage::toXMLFile(ostream& rOut)
5147 + rOut << endl << "\t<package";
5149 + rOut << " name=\"" << getName() << "\"";
5150 + if (!isSubPackage())
5151 + rOut << " sub=\"no\"";
5154 + rOut << " group=\"" << getGroup() << "\"";
5155 + if (!hasAutoRequires() && !hasAutoProvides())
5156 + rOut << " autoreqprov=\"no\"";
5158 + if (!hasAutoRequires())
5159 + rOut << " autoreq=\"no\"";
5160 + if (!hasAutoProvides())
5161 + rOut << " autoprov=\"no\"";
5165 + for (unsigned int i = 0; i < numSummaries(); i++) {
5166 + rOut << endl << "\t\t<summary";
5167 + if (getSummary(i).hasLang())
5168 + rOut << " lang=\"" << getSummary(i).getLang() << "\"";
5169 + rOut << ">" << getSummary(i).getText() << "</summary>";
5171 + for (unsigned int i = 0; i < numDescriptions(); i++) {
5172 + rOut << endl << "\t\t<description";
5173 + if (getDescription(i).hasLang())
5174 + rOut << " lang=\"" << getDescription(i).getLang() << "\"";
5175 + rOut << ">" << getDescription(i).getText() << "</description>";
5178 + getProvides().toXMLFile(rOut, "provides");
5179 + getObsoletes().toXMLFile(rOut, "obsoletes");
5180 + getRequires().toXMLFile(rOut, "requires");
5181 + getBuildRequires().toXMLFile(rOut, "buildrequires");
5183 + getPre().toXMLFile(rOut, "pre");
5184 + getPost().toXMLFile(rOut, "post");
5185 + getPreUn().toXMLFile(rOut, "preun");
5186 + getPostUn().toXMLFile(rOut, "postun");
5187 + getVerify().toXMLFile(rOut, "verify");
5189 + getFiles().toXMLFile(rOut);
5191 + rOut << endl << "\t</package>";
5194 +void XMLPackage::toRPMStruct(Spec spec)
5196 + //Package pkg = newPackage(spec);
5197 + //if (!hasName() && pkg == spec->packages)
5198 + // fillOutMainPackage(pkg->header);
5199 + //else if (pkg != spec->packages)
5200 + // headerCopyTags(spec->packages->header,
5202 + // (int_32 *)copyTagsDuringParse);
5204 Index: xmlspec/XMLPackage.h
5205 ===================================================================
5206 RCS file: xmlspec/XMLPackage.h
5207 diff -N xmlspec/XMLPackage.h
5208 --- /dev/null 1 Jan 1970 00:00:00 -0000
5209 +++ rpm/xmlspec/XMLPackage.h 28 Aug 2002 10:52:43 -0000 1.3.2.1
5211 +#ifndef _H_XMLPACKAGE_
5212 +#define _H_XMLPACKAGE_
5214 +// standard C++ includes
5215 +#include <iostream>
5219 +// standard includes
5223 +#include "XMLAttrs.h"
5224 +#include "XMLBase.h"
5225 +#include "XMLFiles.h"
5226 +#include "XMLRequires.h"
5227 +#include "XMLScript.h"
5228 +#include "XMLText.h"
5231 +#include <rpmbuild.h>
5233 +// forward class declarations
5236 +using namespace std;
5238 +class XMLPackage : public XMLBase
5241 +// factory functions
5245 + * Creates an object as parsed from an XML spec
5247 + * @param pAttrs XML atrtributes to use
5248 + * @param pSpec The spec to which we are adding this object to
5249 + * @return true on success, false otherwise
5251 + static bool parseCreate(XMLAttrs* pAttrs,
5255 + * Creates package objects from an RPM Spec structure
5257 + * @param pPackage Pointer to the start package
5258 + * @param pSpec pointer to the RPM spec
5259 + * @param pXSpec Pointer to the spec object to populate
5260 + * @return true on success, false otherwise
5262 + static bool structCreate(PackageStruct* pPackage,
5267 + * Adds a description for the last package
5269 + * @param pAttrs The attributes
5270 + * @param szDescription the description
5271 + * @param pSpec The spec containing the package
5272 + * @return true on success, false otherwise
5274 + static bool addDescription(XMLAttrs* pAttrs,
5275 + const char* szDescription,
5279 + * Adds the summary for the last added package
5281 + * @param pAttrs The attributes
5282 + * @param szSummary The summary to set
5283 + * @param pSpec The spec contraining the package
5284 + * @return trus on success, false otherwise
5286 + static bool addSummary(XMLAttrs* pAttrs,
5287 + const char* szSummary,
5291 +// constructors/destructors
5295 + * Default constructor
5297 + * @param szName The package name
5298 + * @param szGroup The group this package belongs to
5299 + * @param bAutoReq Auto Requires
5300 + * @param bAutoProv Auto Provides
5301 + * @param bSub true if this is a sub-package
5304 + XMLPackage(const char* szName,
5305 + const char* szGroup,
5311 + * Copy constructor
5313 + * @param rPackage The package to copy from
5316 + XMLPackage(const XMLPackage& rPackage);
5327 +// public member functions
5331 + * Converts the object to a spec file
5333 + * @param rOut Output stream
5336 + void toSpecFile(ostream& rOut);
5339 + * Converts the scripts part of the object to a spec
5341 + * @param rOut Output stream
5344 + void toScriptsSpecFile(ostream& rOut);
5347 + * Converts the files part of the object to a spec
5349 + * @param rOut Output stream
5352 + void toFilesSpecFile(ostream& rOut);
5355 + * Converts the object to an XML spec
5357 + * @param rOut The output stream
5360 + void toXMLFile(ostream& rOut);
5363 + * Converts the object to an RPM structure
5365 + * @param Spec The main Spec object
5368 + void toRPMStruct(Spec spec);
5371 +// member variable get/set functions
5375 + * Checks of we have a package name
5378 + * @return true if we have a name, false otherwise
5382 + return m_sName.length() ? true : false;
5386 + * Gets the package name
5389 + * @return string containing the package name
5391 + const char* getName()
5393 + return m_sName.c_str();
5397 + * Sets the package name
5399 + * @param szName The name to set
5402 + void setName(const char* szName)
5405 + m_sName.assign(szName);
5409 + * Checks if we have a group
5412 + * @return true if we have a group, false otherwise
5416 + return m_sGroup.length() ? true : false;
5420 + * Returns the group
5423 + * @return string containing the group
5425 + const char* getGroup()
5427 + return m_sGroup.c_str();
5433 + * @param szGroup The group to set
5436 + void setGroup(const char* szGroup)
5439 + m_sGroup.assign(szGroup);
5443 + * Tests if we are a sub-package
5446 + * @return true if this is a sub-package
5448 + bool isSubPackage()
5454 + * Sets the sub-package status
5456 + * @param bSub The sub-package status
5459 + void setSubPackage(bool bSub)
5465 + * Tests for auto requires
5468 + * @return true if we have auto requires, false otherwise
5470 + bool hasAutoRequires()
5472 + return m_bAutoReq;
5476 + * Sets the auto requires state
5478 + * @param bAutoReq The auto requires state
5481 + void setAutoRequires(bool bAutoReq)
5483 + m_bAutoReq = bAutoReq;
5487 + * Tests for auto requires
5490 + * @return true if we have auto requires, false otherwise
5492 + bool hasAutoProvides()
5494 + return m_bAutoProv;
5498 + * Sets the auto provides status
5500 + * @param bAutoProv The auto provides status
5503 + void setAutoProvides(bool bAutoProv)
5505 + m_bAutoProv = bAutoProv;
5509 + * Gets the number of summaries
5512 + * @return the number of summaries
5514 + unsigned int numSummaries()
5516 + return m_vSummaries.size();
5522 + * @param nNum The number to get
5523 + * @return the summary
5525 + XMLText& getSummary(unsigned int nNum)
5527 + return m_vSummaries[nNum];
5533 + * @param szSummary the summary
5534 + * @param szLang the language
5537 + void addSummary(const char* szSummary,
5538 + const char* szLang = NULL)
5540 + if (szSummary && strlen(szSummary)) {
5541 + XMLText summary(szSummary, szLang);
5542 + m_vSummaries.push_back(summary);
5547 + * Gets the number of descriptions
5550 + * @return the number in our list
5552 + unsigned int numDescriptions()
5554 + return m_vDescriptions.size();
5558 + * Get a description
5560 + * @param nNum The description to get
5561 + * @return Reference to XMLText object
5563 + XMLText& getDescription(unsigned int nNum)
5565 + return m_vDescriptions[nNum];
5569 + * Adds a description
5571 + * @param szDescription The description string
5572 + * @param szLang The language
5575 + void addDescription(const char* szDescription,
5576 + const char* szLang = NULL)
5578 + if (szDescription && strlen(szDescription)) {
5579 + XMLText description(szDescription, szLang);
5580 + m_vDescriptions.push_back(description);
5585 + * Gets the provides
5588 + * @return reference to the provides
5590 + XMLPackageContainer& getProvides()
5592 + return m_Provides;
5596 + * Gets the package requires
5599 + * @return reference to the requires
5601 + XMLPackageContainer& getRequires()
5603 + return m_Requires;
5607 + * Get the buildrequires
5610 + * @return reference to the buildrequires
5612 + XMLPackageContainer& getBuildRequires()
5614 + return m_BuildRequires;
5618 + * Gets the obsoletes
5621 + * @return reference to the obsoletes
5623 + XMLPackageContainer& getObsoletes()
5625 + return m_Obsoletes;
5632 + * @return reference to the files
5634 + XMLFiles& getFiles()
5640 + * Gets the pre section
5643 + * @return reference to the pre section
5645 + XMLPackageScripts& getPre()
5651 + * Gets the post section
5654 + * @return reference to the post section
5656 + XMLPackageScripts& getPost()
5662 + * Gets the preun section
5665 + * @return reference to the preun section
5667 + XMLPackageScripts& getPreUn()
5673 + * Gets the postun section
5676 + * @return reference to the postun section
5678 + XMLPackageScripts& getPostUn()
5684 + * Gets the verify section
5687 + * @return reference to the verify section
5689 + XMLPackageScripts& getVerify()
5695 +// member variables
5703 + vector<XMLText> m_vSummaries;
5704 + vector<XMLText> m_vDescriptions;
5705 + XMLPackageContainer m_Requires;
5706 + XMLPackageContainer m_BuildRequires;
5707 + XMLPackageContainer m_Provides;
5708 + XMLPackageContainer m_Obsoletes;
5709 + XMLPackageScripts m_Pre;
5710 + XMLPackageScripts m_PreUn;
5711 + XMLPackageScripts m_Post;
5712 + XMLPackageScripts m_PostUn;
5713 + XMLPackageScripts m_Verify;
5718 Index: xmlspec/XMLParser.cpp
5719 ===================================================================
5720 RCS file: xmlspec/XMLParser.cpp
5721 diff -N xmlspec/XMLParser.cpp
5722 --- /dev/null 1 Jan 1970 00:00:00 -0000
5723 +++ rpm/xmlspec/XMLParser.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
5725 +// standard library includes
5726 +#include <stdarg.h>
5728 +#include <stdlib.h>
5730 +// standard C++ includes
5734 +// 3rd party library includes
5738 +#include "XMLSpec.h"
5740 +// this is the maximum tree dept we will require as
5741 +// well as the number of scructures a specific tag can
5743 +#define XML_MAX_TREE_DEPTH 5
5744 +#define XML_MAX_PRE_TAGS 10
5746 +using namespace std;
5748 +// these define the error values
5751 + XMLERR_WARNING = 0x0000,
5756 +// this defines the structure that we are using in the callback
5757 +// containing all the parse-specific data we might need.
5758 +struct structCBData
5760 + XML_Parser* m_pParser;
5761 + string m_sFilename;
5765 + unsigned int m_pnTree[XML_MAX_TREE_DEPTH];
5768 + XMLAttrs* m_pAttrs;
5771 +// enumeration of all XML tags that are recognised
5772 +enum enumXMLTAGValid
5779 + XTAG_EXCLUSIVEARCH,
5809 + XTAG_ANY = 0xFFFF // this always needs to be the last entry
5812 +// this is a structure to match tags to their values
5813 +struct structXMLMatch
5815 + unsigned int m_nVal;
5816 + int m_pnDepth[XML_MAX_TREE_DEPTH+1];
5817 + unsigned int m_pnFollows[XML_MAX_PRE_TAGS+1];
5821 +// this allows for the matching of all tags
5822 +structXMLMatch g_pMatches[] =
5825 + XTAG_SPEC, { 0, -1, -1}, {
5832 + XTAG_PACKAGE, { 1, 3, -1}, {
5843 + XTAG_SOURCE, { 1, -1, -1}, {
5850 + XTAG_PATCH, { 1, 2, -1}, {
5858 + XTAG_NOSOURCE, { 1, -1, -1}, {
5865 + XTAG_MIRROR, { 2, -1, -1}, {
5872 + XTAG_SUMMARY, { 2, -1, -1}, {
5879 + XTAG_DESC, { 2, -1, -1}, {
5886 + XTAG_REQS, { 2, -1, -1}, {
5893 + XTAG_BREQS, { 2, -1, -1}, {
5900 + XTAG_PROVS, { 2, -1, -1}, {
5907 + XTAG_OBSOLS, { 2, -1, -1}, {
5914 + XTAG_FILES, { 2, -1, -1}, {
5921 + XTAG_FILE, { 3, -1, -1}, {
5928 + XTAG_MACRO, { 1, -1, -1}, {
5935 + XTAG_PREP, { 1, -1, -1}, {
5942 + XTAG_SETUP, { 2, -1, -1}, {
5949 + XTAG_BUILD, { 1, -1, -1}, {
5956 + XTAG_INSTALL, { 1, -1, -1}, {
5963 + XTAG_CLEAN, { 1, -1, -1}, {
5970 + XTAG_PRE, { 2, -1, -1}, {
5977 + XTAG_POST, { 2, -1, -1}, {
5984 + XTAG_PREUN, { 2, -1, -1}, {
5991 + XTAG_POSTUN, { 2, -1, -1}, {
5998 + XTAG_VERIFY, { 2, -1, -1}, {
6005 + XTAG_SCRIPT, { 2, 3, -1}, {
6020 + XTAG_CHANGELOG, { 1, -1, -1}, {
6027 + XTAG_CHANGES, { 2, -1, -1}, {
6034 + XTAG_CHANGE, { 3, -1, -1}, {
6040 + // this always needs to be the last entry
6042 + XTAG_NO, {-1, -1, -1}, {
6049 +const char* treeToString(unsigned int* pnTree,
6052 + // internal string storage
6055 + // build the tree to the specified depth
6056 + for (int i = 0; i < nDepth; i++) {
6058 + while (g_pMatches[j].m_nVal != pnTree[i])
6060 + sTree += string("<") + string(g_pMatches[j].m_szName) + string(">");
6063 + // return the tree string
6064 + return sTree.c_str();
6067 +unsigned int getTagValue(const char* szElement,
6069 + unsigned int nPrev)
6071 + // first convert the tag to a tag value
6072 + unsigned int nTagVal = XTAG_NO;
6074 + // loop through all matches to see if we have a valid
6078 + // test if we have a match
6079 + if (strcasecmp(g_pMatches[i].m_szName, szElement) == 0) {
6080 + // look for a match on the tree depth
6082 + nTagVal = XTAG_WRONGSTRUCT;
6083 + while (g_pMatches[i].m_pnDepth[j] != -1) {
6084 + if (g_pMatches[i].m_pnDepth[j++] == nDepth) {
6087 + if (g_pMatches[i].m_pnFollows[j] == nPrev) {
6088 + nTagVal = g_pMatches[i].m_nVal;
6091 + } while (g_pMatches[i].m_pnFollows[++j] != XTAG_NO);
6098 + } while (g_pMatches[++i].m_nVal != XTAG_NO);
6104 +void createError(int nErrType,
6105 + structCBData* pData,
6106 + const char* szFormat, ...)
6108 + // one more error/warning
6109 + nErrType == XMLERR_WARNING ? pData->m_nWarnings++ : pData->m_nErrors++;
6111 + // setup internal variables
6112 + FILE* fOut = stderr;
6113 + switch (nErrType) {
6114 + case XMLERR_WARNING:
6116 + fprintf(fOut, "%s(%d): warning: ", pData->m_sFilename.c_str(),
6117 + XML_GetCurrentLineNumber(*(pData->m_pParser)));
6119 + case XMLERR_ERROR:
6120 + fprintf(fOut, "%s(%d): error: ", pData->m_sFilename.c_str(),
6121 + XML_GetCurrentLineNumber(*(pData->m_pParser)));
6123 + case XMLERR_FATAL:
6124 + fprintf(fOut, "%s(%d): fatal: ", pData->m_sFilename.c_str(),
6125 + XML_GetCurrentLineNumber(*(pData->m_pParser)));
6131 + // create the argument list and print
6132 + va_list vaArgList;
6133 + va_start(vaArgList, szFormat);
6134 + vfprintf(fOut, szFormat, vaArgList);
6135 + fprintf(fOut, "\n");
6138 +void startDepth0(structCBData* pData)
6140 + // this indicates a spec start
6141 + if (pData->m_pnTree[0] == XTAG_SPEC) {
6142 + // if we have a spec already, we are in trouble
6143 + if (pData->m_pSpec)
6144 + createError(XMLERR_ERROR, pData, "Extra 'spec' tag found.");
6145 + else if (!(pData->m_pSpec = XMLSpec::parseCreate(pData->m_pAttrs,
6146 + pData->m_sFilename.c_str())))
6147 + createError(XMLERR_ERROR, pData,
6148 + "Failed to parse 'spec' tag (%s).",
6149 + pData->m_pAttrs->getError());
6150 + else if (pData->m_pAttrs->hasWarning())
6151 + createError(XMLERR_WARNING, pData, pData->m_pAttrs->getWarning());
6155 +void startDepth1(structCBData* pData)
6157 + // make sure we have a spec
6158 + if (!pData->m_pSpec) {
6159 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6164 + switch (pData->m_pnTree[1]) {
6165 + case XTAG_PACKAGE:
6166 + if (!XMLPackage::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6167 + createError(XMLERR_ERROR, pData,
6168 + "Failed to parse 'package' tag or package already exists (%s).",
6169 + pData->m_pSpec->getError());
6170 + else if (pData->m_pSpec->hasWarning())
6171 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6174 + if (!XMLSource::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6175 + createError(XMLERR_ERROR, pData,
6176 + "Failed to parse 'source' tag (%s).",
6177 + pData->m_pSpec->getError());
6178 + else if (pData->m_pSpec->hasWarning())
6179 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6182 + if (!XMLPatch::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6183 + createError(XMLERR_ERROR, pData,
6184 + "Failed to parse 'patch' tag (%s).",
6185 + pData->m_pSpec->getError());
6186 + else if (pData->m_pSpec->hasWarning())
6187 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6189 + case XTAG_NOSOURCE:
6190 + if (!XMLNoSource::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6191 + createError(XMLERR_ERROR, pData,
6192 + "Failed to parse 'nosource' tag (%s).",
6193 + pData->m_pSpec->getError());
6194 + else if (pData->m_pSpec->hasWarning())
6195 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6197 + case XTAG_CHANGELOG:
6200 + case XTAG_INSTALL:
6207 +void startDepth2(structCBData* pData)
6209 + // make sure we have a spec
6210 + if (!pData->m_pSpec) {
6211 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6216 + switch (pData->m_pnTree[2]) {
6218 + switch (pData->m_pnTree[1]) {
6220 + if (!XMLMirror::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6221 + createError(XMLERR_ERROR, pData,
6222 + "Failed to parse 'mirror' tag (%s).",
6223 + pData->m_pSpec->getError());
6224 + else if (pData->m_pSpec->hasWarning())
6225 + createError(XMLERR_WARNING, pData,
6226 + pData->m_pSpec->getWarning());
6229 + if (!XMLMirror::parseCreate(pData->m_pAttrs, pData->m_pSpec, true))
6230 + createError(XMLERR_ERROR, pData,
6231 + "Failed to parse 'mirror' tag (%s).",
6232 + pData->m_pSpec->getError());
6233 + else if (pData->m_pSpec->hasWarning())
6234 + createError(XMLERR_WARNING, pData,
6235 + pData->m_pSpec->getWarning());
6240 + if (!XMLFiles::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6241 + createError(XMLERR_ERROR, pData,
6242 + "Failed to parse 'change' tag (%s).",
6243 + pData->m_pSpec->getError());
6244 + else if (pData->m_pSpec->hasWarning())
6245 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6247 + case XTAG_CHANGES:
6248 + if (!XMLChangelogDate::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6249 + createError(XMLERR_ERROR, pData,
6250 + "Failed to parse 'change' tag (%s).",
6251 + pData->m_pSpec->getError());
6252 + else if (pData->m_pSpec->hasWarning())
6253 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6256 + if (!XMLPackageScripts::createPreScripts(pData->m_pAttrs, pData->m_pSpec))
6257 + createError(XMLERR_ERROR, pData,
6258 + "Failed to parse 'pre' tag (%s).",
6259 + pData->m_pSpec->getError());
6260 + else if (pData->m_pSpec->hasWarning())
6261 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6264 + if (!XMLPackageScripts::createPostScripts(pData->m_pAttrs, pData->m_pSpec))
6265 + createError(XMLERR_ERROR, pData,
6266 + "Failed to parse 'pre' tag (%s).",
6267 + pData->m_pSpec->getError());
6268 + else if (pData->m_pSpec->hasWarning())
6269 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6272 + if (!XMLPackageScripts::createPreUnScripts(pData->m_pAttrs, pData->m_pSpec))
6273 + createError(XMLERR_ERROR, pData,
6274 + "Failed to parse 'pre' tag (%s).",
6275 + pData->m_pSpec->getError());
6276 + else if (pData->m_pSpec->hasWarning())
6277 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6280 + if (!XMLPackageScripts::createPostUnScripts(pData->m_pAttrs, pData->m_pSpec))
6281 + createError(XMLERR_ERROR, pData,
6282 + "Failed to parse 'pre' tag (%s).",
6283 + pData->m_pSpec->getError());
6284 + else if (pData->m_pSpec->hasWarning())
6285 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6288 + if (!XMLPackageScripts::createVerifyScripts(pData->m_pAttrs, pData->m_pSpec))
6289 + createError(XMLERR_ERROR, pData,
6290 + "Failed to parse 'pre' tag (%s).",
6291 + pData->m_pSpec->getError());
6292 + else if (pData->m_pSpec->hasWarning())
6293 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6304 +void startDepth3(structCBData* pData)
6306 + // make sure we have a spec
6307 + if (!pData->m_pSpec) {
6308 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6313 + switch (pData->m_pnTree[3]) {
6314 + case XTAG_PACKAGE:
6315 + switch (pData->m_pnTree[2]) {
6317 + if (!XMLPackageContainer::addRequire(pData->m_pAttrs,
6319 + createError(XMLERR_ERROR, pData,
6320 + "Failed to parse 'package' tag (%s).",
6321 + pData->m_pSpec->getError());
6322 + else if (pData->m_pSpec->hasWarning())
6323 + createError(XMLERR_WARNING, pData,
6324 + pData->m_pSpec->getWarning());
6327 + if (!XMLPackageContainer::addBuildRequire(pData->m_pAttrs,
6329 + createError(XMLERR_ERROR, pData,
6330 + "Failed to parse 'package' tag (%s).",
6331 + pData->m_pSpec->getError());
6332 + else if (pData->m_pSpec->hasWarning())
6333 + createError(XMLERR_WARNING, pData,
6334 + pData->m_pSpec->getWarning());
6337 + if (!XMLPackageContainer::addProvide(pData->m_pAttrs,
6339 + createError(XMLERR_ERROR, pData,
6340 + "Failed to parse 'package' tag (%s).",
6341 + pData->m_pSpec->getError());
6342 + else if (pData->m_pSpec->hasWarning())
6343 + createError(XMLERR_WARNING, pData,
6344 + pData->m_pSpec->getWarning());
6347 + if (!XMLPackageContainer::addObsolete(pData->m_pAttrs,
6349 + createError(XMLERR_ERROR, pData,
6350 + "Failed to parse 'package' tag (%s).",
6351 + pData->m_pSpec->getError());
6352 + else if (pData->m_pSpec->hasWarning())
6353 + createError(XMLERR_WARNING, pData,
6354 + pData->m_pSpec->getWarning());
6365 +void startElementCB(void* pCBData,
6366 + const char* szElement,
6367 + const char** szAttr)
6369 + // get the data structure we are working with and
6370 + structCBData* pData = (structCBData*)pCBData;
6372 + // validate and get the tag we are working with
6373 + unsigned int nTag = getTagValue(szElement,
6375 + pData->m_nDepth ? pData->m_pnTree[pData->m_nDepth-1] : XTAG_ANY);
6377 + if (nTag == XTAG_NO || nTag == XTAG_WRONGSTRUCT)
6378 + return createError(XMLERR_WARNING, pData, "Unexpected tag '%s' in structure '%s'.",
6380 + treeToString(pData->m_pnTree, pData->m_nDepth++));
6381 + pData->m_pnTree[pData->m_nDepth] = nTag;
6382 + pData->m_sData.assign("");
6384 + if (pData->m_pAttrs)
6385 + delete pData->m_pAttrs;
6386 + pData->m_pAttrs = new XMLAttrs(szAttr);
6388 + switch (pData->m_nDepth++) {
6390 + startDepth0(pData);
6393 + startDepth1(pData);
6396 + startDepth2(pData);
6399 + startDepth3(pData);
6406 +void endDepth1(structCBData* pData)
6408 + // make sure we have a spec
6409 + if (!pData->m_pSpec) {
6410 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6415 + switch (pData->m_pnTree[1]) {
6417 + if (!XMLMacro::parseCreate(pData->m_pAttrs,
6418 + pData->m_sData.c_str(),
6420 + createError(XMLERR_ERROR, pData,
6421 + "Failed to add macro entry (%s).",
6422 + pData->m_pAttrs->getError());
6423 + else if (pData->m_pSpec->hasWarning())
6424 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6431 +void endDepth2(structCBData* pData)
6433 + // make sure we have a spec
6434 + if (!pData->m_pSpec) {
6435 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6440 + switch (pData->m_pnTree[2]) {
6441 + case XTAG_SUMMARY:
6442 + if (!XMLPackage::addSummary(pData->m_pAttrs, pData->m_sData.c_str(),
6444 + createError(XMLERR_ERROR, pData,
6445 + "Failed to add 'summary'.");
6448 + if (!XMLPackage::addDescription(pData->m_pAttrs, pData->m_sData.c_str(),
6450 + createError(XMLERR_ERROR, pData,
6451 + "Failed to add 'description'.");
6454 + switch (pData->m_pnTree[1]) {
6456 + if (!XMLScripts::addPrepScript(pData->m_pAttrs,
6457 + pData->m_sData.c_str(),
6459 + createError(XMLERR_ERROR, pData,
6460 + "Failed to add shell entry.");
6463 + if (!XMLScripts::addBuildScript(pData->m_pAttrs,
6464 + pData->m_sData.c_str(),
6466 + createError(XMLERR_ERROR, pData,
6467 + "Failed to add shell entry.");
6469 + case XTAG_INSTALL:
6470 + if (!XMLScripts::addInstallScript(pData->m_pAttrs,
6471 + pData->m_sData.c_str(),
6473 + createError(XMLERR_ERROR, pData,
6474 + "Failed to add shell entry.");
6477 + if (!XMLScripts::addCleanScript(pData->m_pAttrs,
6478 + pData->m_sData.c_str(),
6480 + createError(XMLERR_ERROR, pData,
6481 + "Failed to add shell entry.");
6492 +void endDepth3(structCBData* pData)
6494 + // make sure we have a spec
6495 + if (!pData->m_pSpec) {
6496 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6501 + switch (pData->m_pnTree[3]) {
6503 + if (!XMLChangelogEntry::parseCreate(pData->m_pAttrs,
6504 + pData->m_sData.c_str(),
6506 + createError(XMLERR_ERROR, pData,
6507 + "Failed to add changelog entry.");
6508 + else if (pData->m_pSpec->hasWarning())
6509 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6512 + if (!XMLFile::parseCreate(pData->m_pAttrs,
6513 + pData->m_sData.c_str(),
6515 + createError(XMLERR_ERROR, pData, "Failed to parse 'file' tag (%s).",
6516 + pData->m_pSpec->getError());
6517 + else if (pData->m_pSpec->hasWarning())
6518 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6521 + switch (pData->m_pnTree[2]) {
6523 + if (!XMLPackageScripts::addPreScript(pData->m_pAttrs,
6524 + pData->m_sData.c_str(),
6526 + createError(XMLERR_ERROR, pData,
6527 + "Failed to parse 'script' tag (%s).",
6528 + pData->m_pSpec->getError());
6529 + else if (pData->m_pSpec->hasWarning())
6530 + createError(XMLERR_WARNING, pData,
6531 + pData->m_pSpec->getWarning());
6534 + if (!XMLPackageScripts::addPostScript(pData->m_pAttrs,
6535 + pData->m_sData.c_str(),
6537 + createError(XMLERR_ERROR, pData,
6538 + "Failed to parse 'script' tag (%s).",
6539 + pData->m_pSpec->getError());
6540 + else if (pData->m_pSpec->hasWarning())
6541 + createError(XMLERR_WARNING, pData,
6542 + pData->m_pSpec->getWarning());
6545 + if (!XMLPackageScripts::addPreUnScript(pData->m_pAttrs,
6546 + pData->m_sData.c_str(),
6548 + createError(XMLERR_ERROR, pData,
6549 + "Failed to parse 'script' tag (%s).",
6550 + pData->m_pSpec->getError());
6551 + else if (pData->m_pSpec->hasWarning())
6552 + createError(XMLERR_WARNING, pData,
6553 + pData->m_pSpec->getWarning());
6556 + if (!XMLPackageScripts::addPostUnScript(pData->m_pAttrs,
6557 + pData->m_sData.c_str(),
6559 + createError(XMLERR_ERROR, pData,
6560 + "Failed to parse 'script' tag (%s).",
6561 + pData->m_pSpec->getError());
6562 + else if (pData->m_pSpec->hasWarning())
6563 + createError(XMLERR_WARNING, pData,
6564 + pData->m_pSpec->getWarning());
6567 + if (!XMLPackageScripts::addVerifyScript(pData->m_pAttrs,
6568 + pData->m_sData.c_str(),
6570 + createError(XMLERR_ERROR, pData,
6571 + "Failed to parse 'script' tag (%s).",
6572 + pData->m_pSpec->getError());
6573 + else if (pData->m_pSpec->hasWarning())
6574 + createError(XMLERR_WARNING, pData,
6575 + pData->m_pSpec->getWarning());
6586 +void endElementCB(void* pCBData,
6587 + const char* szElement)
6589 + // get the data structure we are working with
6590 + structCBData* pData = (structCBData*)pCBData;
6591 + pData->m_nDepth--;
6593 + // validate and get the tag we are working with
6594 + unsigned int nTag = getTagValue(szElement,
6596 + pData->m_nDepth ? pData->m_pnTree[pData->m_nDepth-1] : XTAG_ANY);
6597 + if (nTag == XTAG_NO || nTag == XTAG_WRONGSTRUCT)
6600 + // handle the tree depth
6601 + switch (pData->m_nDepth) {
6618 + pData->m_sData.assign("");
6621 +void characterCB(void* pCBData,
6622 + const char* szStr,
6625 + // get the data structure we are working with
6626 + structCBData* pData = (structCBData*)pCBData;
6628 + // append the string to our internal data
6630 + char* szTmp = new char[nLen+1];
6631 + strncpy(szTmp, szStr, nLen);
6632 + szTmp[nLen] = '\0';
6633 + pData->m_sData.append(szTmp);
6638 +int parseXMLSpec(const char* szXMLFilename,
6641 + // create and setup our parser for use
6642 + printf("Creating XML parser instance ... ");
6643 + XML_Parser parser = XML_ParserCreate(NULL);
6645 + printf("Failed.\n\tERROR: Couldn't allocate memory for parser\n\n");
6650 + XML_SetElementHandler(parser, startElementCB, endElementCB);
6651 + XML_SetCharacterDataHandler(parser, characterCB);
6652 + structCBData stData;
6653 + stData.m_pParser = &parser;
6654 + stData.m_sFilename.assign(szXMLFilename);
6655 + stData.m_nWarnings = 0;
6656 + stData.m_nErrors = 0;
6657 + stData.m_nDepth = 0;
6658 + stData.m_pSpec = NULL;
6659 + stData.m_pAttrs = NULL;
6660 + XML_SetUserData(parser, (void*)&stData);
6662 + // open the input and output files here
6663 + printf("Opening input XML spec ... ");
6664 + ifstream fIn(szXMLFilename);
6665 + if (!fIn.is_open()) {
6666 + printf("Failed.\n\tERROR: Could not open %s\n\n", szXMLFilename);
6672 + // parse our configuration (loop through file,
6673 + // doing a break if needed (fatal error))
6674 + printf("Parsing %s: \n", szXMLFilename);
6675 + char szBuff[1024+1];
6676 + unsigned int nLength = 0;
6677 + while (!fIn.eof()) {
6678 + fIn.get(szBuff, 1024, '\0');
6679 + unsigned int nRead = strlen(szBuff);
6681 + if (!XML_Parse(parser, szBuff, nRead, fIn.eof() ? 1 : 0)) {
6682 + createError(XMLERR_FATAL, &stData, "XML parsing: %s",
6683 + XML_ErrorString(XML_GetErrorCode(parser)));
6688 + // print the end results
6689 + printf("\t%d bytes parsed, %d errors(s), %d warnings(s)\n",
6690 + nLength, stData.m_nErrors, stData.m_nWarnings);
6691 + printf("Closing input XML spec ... ");
6696 + if (stData.m_nErrors) {
6697 + if (stData.m_pSpec != NULL)
6698 + delete stData.m_pSpec;
6702 + pSpec = stData.m_pSpec;
6704 + // return number of errors
6705 + return stData.m_nErrors;
6707 Index: xmlspec/XMLParser.h
6708 ===================================================================
6709 RCS file: xmlspec/XMLParser.h
6710 diff -N xmlspec/XMLParser.h
6711 --- /dev/null 1 Jan 1970 00:00:00 -0000
6712 +++ rpm/xmlspec/XMLParser.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
6714 +#ifndef _H_XMLPARSER_
6715 +#define _H_XMLPARSER_
6718 +#include "XMLSpec.h"
6721 + * Parses an XML spec into the internal data structures as
6722 + * defined in the XML* classes.
6724 + * @param szXMLFilename The Spec to read as parser input
6725 + * @param pSpec A reference to the spec data structure we
6727 + * @return The number of parsing/other errors (0 == success)
6729 +extern int parseXMLSpec(const char* szXMLFilename,
6733 Index: xmlspec/XMLRPMWrap.cpp
6734 ===================================================================
6735 RCS file: xmlspec/XMLRPMWrap.cpp
6736 diff -N xmlspec/XMLRPMWrap.cpp
6737 --- /dev/null 1 Jan 1970 00:00:00 -0000
6738 +++ rpm/xmlspec/XMLRPMWrap.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
6740 +// standard c++ includes
6745 +#include <rpmlib.h>
6746 +#include <rpmbuild.h>
6748 +// type definitions
6749 +typedef vector<string> t_StrVector;
6751 +using namespace std;
6753 +bool getRPMHeader(Header header,
6757 + if (headerIsEntry(header, nTag)) {
6758 + int_32 nCount, nTagType;
6760 + if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount))
6763 + switch (nTagType) {
6764 + case RPM_INT32_TYPE:
6765 + sprintf(szTemp, "%d", *((int_32*)pBuffer));
6766 + rResult.assign(szTemp);
6768 + rResult.assign((char*)pBuffer);
6771 + headerFreeData(pBuffer, (rpmTagType_e)nTagType);
6778 +bool getRPMHeaderArray(Header header,
6780 + t_StrVector& rvResult)
6783 + if (headerIsEntry(header, nTag)) {
6784 + int_32 nCount, nTagType;
6786 + if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount))
6788 + if (nTagType == RPM_STRING_ARRAY_TYPE || nTagType == RPM_I18NSTRING_TYPE) {
6789 + for (int_32 i = 0; i < nCount; i++)
6790 + rvResult.push_back(((char**)pBuffer)[i]);
6793 + rvResult.push_back((char*)pBuffer);
6794 + headerFreeData(pBuffer, (rpmTagType_e)nTagType);
6801 +bool getRPMMacro(const char* szMacro,
6804 + char* szValue = rpmExpand(szMacro, NULL);
6806 + rResult.assign(szValue);
6812 Index: xmlspec/XMLRPMWrap.h
6813 ===================================================================
6814 RCS file: xmlspec/XMLRPMWrap.h
6815 diff -N xmlspec/XMLRPMWrap.h
6816 --- /dev/null 1 Jan 1970 00:00:00 -0000
6817 +++ rpm/xmlspec/XMLRPMWrap.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
6819 +#ifndef _H_XMLRPMWRAP_
6820 +#define _H_XMLRPMWRAP_
6822 +// standard C++ includes
6827 +#include <rpmlib.h>
6829 +// type definitions
6830 +typedef vector<string> t_StrVector;
6833 + * Gets an RPM header after checking that is does exist.
6835 + * @param header The RPM header to interrogate
6836 + * @param nTag The header tag to extract
6837 + * @param rResult The string to populate with the result
6838 + * @return true on success, false otherwise
6840 +extern bool getRPMHeader(Header header,
6842 + std::string& rResult);
6845 + * Gets an RPM header array into a vector after checking that it
6846 + * does indeed exist
6848 + * @param header The RPM header to interrogate
6849 + * @param nTag The header tag to extract
6850 + * @param rvResult The vector<string> to populate with the result
6851 + * @return true on success, false otherwise
6853 +extern bool getRPMHeaderArray(Header header,
6855 + t_StrVector& rvResult);
6858 + * Gets a specific RPM macro
6860 + * @param szMacro The macro to get the value of
6861 + * @param rResult The string to populate with the result
6862 + * @return true on success, false otherwise
6864 +extern bool getRPMMacro(const char* szMacro,
6865 + std::string& rResult);
6868 Index: xmlspec/XMLRequires.cpp
6869 ===================================================================
6870 RCS file: xmlspec/XMLRequires.cpp
6871 diff -N xmlspec/XMLRequires.cpp
6872 --- /dev/null 1 Jan 1970 00:00:00 -0000
6873 +++ rpm/xmlspec/XMLRequires.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
6876 +#include "XMLAttrs.h"
6877 +#include "XMLPackage.h"
6878 +#include "XMLRequires.h"
6879 +#include "XMLRPMWrap.h"
6880 +#include "XMLSpec.h"
6883 +#include <rpmlib.h>
6885 +using namespace std;
6887 +// attribute structure for XMLPackageEntry
6888 +structValidAttrs g_paEntryAttrs[] =
6890 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
6891 + {0x0001, false, false, "version", XATTRTYPE_STRING, {"*", NULL}},
6892 + {0x0002, false, false, "cmp", XATTRTYPE_STRING, {"*", NULL}},
6893 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
6896 +bool XMLPackageEntry::parseCreate(XMLAttrs* pAttrs,
6897 + XMLPackageContainer& rContainer)
6899 + // validate the attributes
6900 + if (!pAttrs->validate(g_paEntryAttrs, (XMLBase*)pAttrs))
6903 + // create and return
6904 + XMLPackageEntry entry(pAttrs->asString("name"), pAttrs->asString("version"),
6905 + pAttrs->asString("cmp"));
6906 + rContainer.addEntry(entry);
6910 +XMLPackageEntry::XMLPackageEntry(const char* szName,
6911 + const char* szVersion,
6912 + const char* szCmp)
6916 + m_sName.assign(szName);
6918 + m_sVersion.assign(szVersion);
6919 + m_sCmp.assign("=");
6921 + if (strcasecmp(szCmp, "lt") == 0)
6922 + m_sCmp.assign("<");
6923 + else if (strcasecmp(szCmp, "le") == 0)
6924 + m_sCmp.assign("<=");
6925 + else if (strcasecmp(szCmp, "gt") == 0)
6926 + m_sCmp.assign(">");
6927 + else if (strcasecmp(szCmp, "ge") == 0)
6928 + m_sCmp.assign(">=");
6932 +XMLPackageEntry::XMLPackageEntry(const XMLPackageEntry& rEntry)
6935 + m_sName.assign(rEntry.m_sName);
6936 + m_sVersion.assign(rEntry.m_sVersion);
6937 + m_sCmp.assign(rEntry.m_sCmp);
6940 +XMLPackageEntry::~XMLPackageEntry()
6944 +XMLPackageEntry XMLPackageEntry::operator=(XMLPackageEntry entry)
6946 + m_sName.assign(entry.m_sName);
6947 + m_sVersion.assign(entry.m_sVersion);
6948 + m_sCmp.assign(entry.m_sCmp);
6952 +void XMLPackageEntry::toSpecFile(ostream& rOut)
6954 + rOut << getName();
6955 + if (hasVersion()) {
6956 + rOut << " " << getCompare() << " " << getVersion();
6960 +void XMLPackageEntry::toXMLFile(ostream& rOut)
6962 + rOut << endl << "\t\t\t<package name=\"" << getName() << "\"";
6963 + if (hasVersion()) {
6964 + if (m_sCmp.compare("=") == 0)
6965 + rOut << " cmp=\"eq\"";
6966 + else if (m_sCmp.compare("<") == 0)
6967 + rOut << " cmp=\"lt\"";
6968 + else if (m_sCmp.compare("<=") == 0)
6969 + rOut << " cmp=\"le\"";
6970 + else if (m_sCmp.compare(">") == 0)
6971 + rOut << " cmp=\"gt\"";
6972 + else if (m_sCmp.compare(">=") == 0)
6973 + rOut << " cmp=\"ge\"";
6974 + rOut << " version=\"" << getVersion() << "\"";
6979 +XMLPackageContainer::XMLPackageContainer()
6984 +XMLPackageContainer::XMLPackageContainer(const XMLPackageContainer& rContainer)
6987 + m_vPackages = rContainer.m_vPackages;
6990 +XMLPackageContainer::~XMLPackageContainer()
6994 +XMLPackageContainer XMLPackageContainer::operator=(XMLPackageContainer container)
6996 + m_vPackages = container.m_vPackages;
7000 +void XMLPackageContainer::toSpecFile(ostream& rOut,
7001 + const char* szTag)
7003 + if (numEntries()) {
7004 + rOut << szTag << ": ";
7005 + for (unsigned int i = 0; i < numEntries(); i++) {
7006 + rOut << (i ? ", " : "");
7007 + getEntry(i).toSpecFile(rOut);
7013 +void XMLPackageContainer::toXMLFile(ostream& rOut,
7014 + const char* szTag)
7016 + if (numEntries()) {
7017 + rOut << endl << "\t\t<" << szTag << ">";
7018 + for (unsigned int i = 0; i < numEntries(); i++)
7019 + getEntry(i).toXMLFile(rOut);
7020 + rOut << endl << "\t\t</" << szTag << ">";
7024 +bool XMLPackageContainer::addRequire(XMLAttrs* pAttrs,
7029 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getRequires());
7032 +bool XMLPackageContainer::addBuildRequire(XMLAttrs* pAttrs,
7037 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getBuildRequires());
7040 +bool XMLPackageContainer::addProvide(XMLAttrs* pAttrs,
7045 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getProvides());
7048 +bool XMLPackageContainer::addObsolete(XMLAttrs* pAttrs,
7053 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getObsoletes());
7056 +bool XMLPackageContainer::structCreate(PackageStruct* pPackage,
7060 + if (!pXSpec || !pPackage || !pPackage->header)
7064 Index: xmlspec/XMLRequires.h
7065 ===================================================================
7066 RCS file: xmlspec/XMLRequires.h
7067 diff -N xmlspec/XMLRequires.h
7068 --- /dev/null 1 Jan 1970 00:00:00 -0000
7069 +++ rpm/xmlspec/XMLRequires.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
7071 +#ifndef _H_XMLREQUIRES_
7072 +#define _H_XMLREQUIRES_
7074 +// standard C++ includes
7075 +#include <iostream>
7079 +// standard C includes
7083 +#include "XMLAttrs.h"
7084 +#include "XMLBase.h"
7086 +// forward definitions
7088 +class XMLPackageContainer;
7091 +using namespace std;
7093 +//<package ...> (after requires, buildrequires, obsoletes, provides)
7094 +class XMLPackageEntry : public XMLBase
7097 +// factory functions
7101 + * Creates an object as parsed from an XML spec
7103 + * @param pAttrs XML atrtributes to use
7104 + * @param rContainer The container to which to add the object
7105 + * @return true on success, false otherwise
7107 + static bool parseCreate(XMLAttrs* pAttrs,
7108 + XMLPackageContainer& rContainer);
7111 +// constructors/destructor
7115 + * Default constructor
7117 + * @param szName Name of the package
7118 + * @param szVersion version of the package
7119 + * @param szCmp the comparator (eq,lt,le,gt,ge)
7122 + XMLPackageEntry(const char* szName,
7123 + const char* szVersion,
7124 + const char* szCmp);
7127 + * Copy constructor
7129 + * @param rEntry reference to the entrry to copy
7132 + XMLPackageEntry(const XMLPackageEntry& rEntry);
7140 + ~XMLPackageEntry();
7147 + * Assignment operator
7149 + * @param entry The entry to assigne to
7150 + * @return thye modified object
7152 + XMLPackageEntry operator=(XMLPackageEntry entry);
7154 +// member functions
7158 + * Converts the object into an RPM spec
7160 + * @param rOut Output stream
7163 + void toSpecFile(ostream& rOut);
7166 + * Converts the object into an XML spec
7168 + * @param rOut output stream
7171 + void toXMLFile(ostream& rOut);
7174 +// member variable get/set functions
7181 + * @return string containing the name
7183 + const char* getName()
7185 + return m_sName.c_str();
7189 + * Checks if we have a version
7192 + * @return true if available, false otherwise
7196 + return m_sVersion.length() ? true : false;
7200 + * Gets the version
7203 + * @return string containing the version
7205 + const char* getVersion()
7207 + return m_sVersion.c_str();
7211 + * Gets the comparision string
7214 + * @return string with the comparator (=, <, <=, >, >=, <>)
7216 + const char* getCompare()
7218 + return m_sCmp.c_str();
7222 +// member variables
7226 + string m_sVersion;
7230 +//<requires,obsoletes,buildrequires,provides ...>
7231 +class XMLPackageContainer : public XMLBase
7234 +// factory functions
7240 + * @param pAttrs XML attributes
7241 + * @param pSpecx pointer to the spec to add to
7242 + * @return true on success, false otherwise
7244 + static bool addRequire(XMLAttrs* pAttrs,
7248 + * Adds a buildrequire
7250 + * @param pAttrs XML attributes
7251 + * @param pSpecx pointer to the spec to add to
7252 + * @return true on success, false otherwise
7254 + static bool addBuildRequire(XMLAttrs* pAttrs,
7260 + * @param pAttrs XML attributes
7261 + * @param pSpecx pointer to the spec to add to
7262 + * @return true on success, false otherwise
7264 + static bool addProvide(XMLAttrs* pAttrs,
7268 + * Adds an obsolete
7270 + * @param pAttrs XML attributes
7271 + * @param pSpecx pointer to the spec to add to
7272 + * @return true on success, false otherwise
7274 + static bool addObsolete(XMLAttrs* pAttrs,
7278 + * Adds requires/provides/obsoletes from RPM structures
7280 + * @param pPackage pointer to the RPM package
7281 + * @param pSpec pointer to the RPM spec
7282 + * @param pXSpec pointer to the XML spec to populate
7283 + * @return true on success, false otherwise
7285 + static bool structCreate(PackageStruct* pPackage,
7290 +// constructors/destructor
7294 + * Default constructor
7299 + XMLPackageContainer();
7302 + * Copy constructor
7304 + * @param rContainer The container to copy
7307 + XMLPackageContainer(const XMLPackageContainer& rContainer);
7315 + virtual ~XMLPackageContainer();
7322 + * Assignment operator
7324 + * @param container The container to copy
7325 + * @return a copy of the object
7327 + XMLPackageContainer operator=(XMLPackageContainer container);
7330 +// member functions
7334 + * Converts the object into an RPM spec
7336 + * @param rOut Output stream
7337 + * @param szTag the tag for this object (eg. buildrequires)
7340 + virtual void toSpecFile(ostream& rOut,
7341 + const char* szTag);
7344 + * Converts the object into an XML spec
7346 + * @param rOut Output stream
7347 + * @para szTag the tag for this object (eg. buildrequires)
7350 + virtual void toXMLFile(ostream& rOut,
7351 + const char* szTag);
7354 +// member variable get/set functions
7358 + * Gets the number of entries
7361 + * @return the number of entries
7363 + unsigned int numEntries()
7365 + return m_vPackages.size();
7369 + * Gets a specific entry
7371 + * @param nNum The number of the entry
7372 + * @return reference to the entry
7374 + XMLPackageEntry& getEntry(unsigned int nNum)
7376 + return m_vPackages[nNum];
7382 + * @param rPackage the entry to add
7385 + void addEntry(XMLPackageEntry& rPackage)
7387 + m_vPackages.push_back(rPackage);
7391 +// member variables
7394 + vector<XMLPackageEntry> m_vPackages;
7398 Index: xmlspec/XMLScript.cpp
7399 ===================================================================
7400 RCS file: xmlspec/XMLScript.cpp
7401 diff -N xmlspec/XMLScript.cpp
7402 --- /dev/null 1 Jan 1970 00:00:00 -0000
7403 +++ rpm/xmlspec/XMLScript.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
7405 +// standard includes
7409 +#include "XMLPackage.h"
7410 +#include "XMLScript.h"
7411 +#include "XMLSpec.h"
7413 +// attribute structure for XMLScript
7414 +structValidAttrs g_paScriptAttrs[] =
7416 + {0x0000, false, false, "dir", XATTRTYPE_STRING, {"*", NULL}},
7417 + {0x0001, false, false, "interpreter", XATTRTYPE_STRING, {"*", NULL}},
7418 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
7421 +bool XMLScript::parseCreate(XMLAttrs* pAttrs,
7422 + const char* szScript,
7423 + XMLScripts& rContainer)
7425 + if (!pAttrs->validate(g_paScriptAttrs, (XMLBase*)pAttrs))
7427 + XMLScript script(szScript,
7428 + pAttrs->asString("interpreter"),
7429 + pAttrs->asString("dir"));
7430 + rContainer.add(script);
7434 +XMLScript::XMLScript(const char* szScript,
7435 + const char* szInterpreter,
7436 + const char* szDir)
7440 + m_sValue.assign(szScript);
7441 + if (szInterpreter)
7442 + m_sInterpreter.assign(szInterpreter);
7444 + m_sDir.assign(szDir);
7447 +XMLScript::XMLScript(const XMLScript& rScript)
7450 + m_sValue.assign(rScript.m_sValue);
7451 + m_sInterpreter.assign(rScript.m_sInterpreter);
7452 + m_sDir.assign(rScript.m_sDir);
7455 +XMLScript::~XMLScript()
7459 +XMLScript XMLScript::operator=(XMLScript script)
7461 + m_sValue.assign(script.m_sValue);
7462 + m_sInterpreter.assign(script.m_sInterpreter);
7463 + m_sDir.assign(script.m_sDir);
7466 +void XMLScript::toSpecFile(ostream& rOut)
7468 + if (hasDirectory())
7469 + rOut << "cd " << getDirectory() << endl;
7470 + rOut << getValue() << endl;
7473 +void XMLScript::toXMLFile(ostream& rOut,
7474 + const char* szIndent)
7476 + rOut << endl << szIndent << "\t\t<script";
7477 + if (hasDirectory())
7478 + rOut << " dir=\"" << getDirectory() << "\"";
7479 + rOut << ">" << getValue() << "</script>";
7482 +void XMLScript::toRPMStruct(StringBuf* pSB)
7484 + if (hasDirectory()) {
7485 + char szBuff[getDirectoryLen()+3+1]; // 3 == strlen("cd ")
7486 + sprintf(szBuff, "cd %s", getDirectory());
7487 + appendStringBuf(*pSB, szBuff);
7489 + appendStringBuf(*pSB, getValue());
7492 +bool XMLScripts::addPrepScript(XMLAttrs* pAttrs,
7493 + const char* szScript,
7496 + // no spec or already set
7499 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getPrep());
7502 +bool XMLScripts::addBuildScript(XMLAttrs* pAttrs,
7503 + const char* szScript,
7506 + // no spec or already set
7509 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getBuild());
7512 +bool XMLScripts::addInstallScript(XMLAttrs* pAttrs,
7513 + const char* szScript,
7516 + // no spec or already set
7519 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getInstall());
7522 +bool XMLScripts::addCleanScript(XMLAttrs* pAttrs,
7523 + const char* szScript,
7526 + // no spec or already set
7529 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getClean());
7532 +XMLScripts::XMLScripts()
7537 +XMLScripts::XMLScripts(const XMLScripts& rContainer)
7540 + m_vScripts = rContainer.m_vScripts;
7543 +XMLScripts::~XMLScripts()
7547 +void XMLScripts::toSpecFile(ostream& rOut,
7548 + const char* szTag)
7550 + if (numScripts()) {
7551 + rOut << endl << "%" << szTag << endl;
7552 + for (unsigned int i = 0; i < numScripts(); i++)
7553 + getScript(i).toSpecFile(rOut);
7557 +void XMLScripts::toXMLFile(ostream& rOut,
7558 + const char* szTag)
7560 + if (numScripts()) {
7561 + rOut << endl << "\t<" << szTag << ">";
7562 + for (unsigned int i = 0; i < numScripts(); i++)
7563 + getScript(i).toXMLFile(rOut, "");
7564 + rOut << endl << "\t</" << szTag << ">";
7568 +bool XMLPackageScripts::addPreScript(XMLAttrs* pAttrs,
7569 + const char* szScript,
7574 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPre());
7577 +bool XMLPackageScripts::addPostScript(XMLAttrs* pAttrs,
7578 + const char* szScript,
7583 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPost());
7586 +bool XMLPackageScripts::addPreUnScript(XMLAttrs* pAttrs,
7587 + const char* szScript,
7592 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPreUn());
7595 +bool XMLPackageScripts::addPostUnScript(XMLAttrs* pAttrs,
7596 + const char* szScript,
7601 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPostUn());
7604 +bool XMLPackageScripts::addVerifyScript(XMLAttrs* pAttrs,
7605 + const char* szScript,
7610 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getVerify());
7613 +bool XMLPackageScripts::createPreScripts(XMLAttrs* pAttrs,
7618 + pSpec->lastPackage().getPre().setInterpreter(pAttrs->asString("interpreter"));
7622 +bool XMLPackageScripts::createPostScripts(XMLAttrs* pAttrs,
7627 + pSpec->lastPackage().getPost().setInterpreter(pAttrs->asString("interpreter"));
7631 +bool XMLPackageScripts::createPreUnScripts(XMLAttrs* pAttrs,
7636 + pSpec->lastPackage().getPreUn().setInterpreter(pAttrs->asString("interpreter"));
7640 +bool XMLPackageScripts::createPostUnScripts(XMLAttrs* pAttrs,
7645 + pSpec->lastPackage().getPostUn().setInterpreter(pAttrs->asString("interpreter"));
7649 +bool XMLPackageScripts::createVerifyScripts(XMLAttrs* pAttrs,
7654 + pSpec->lastPackage().getVerify().setInterpreter(pAttrs->asString("interpreter"));
7658 +XMLPackageScripts::XMLPackageScripts()
7663 +XMLPackageScripts::XMLPackageScripts(const XMLPackageScripts& rContainer)
7664 + : XMLScripts(rContainer)
7668 +XMLPackageScripts::~XMLPackageScripts()
7672 +void XMLPackageScripts::toSpecFile(ostream& rOut,
7673 + const char* szTag)
7675 + // NOTE: header not done here, but by "package"
7676 + for (unsigned int i = 0; i < numScripts(); i++)
7677 + getScript(i).toSpecFile(rOut);
7680 +void XMLPackageScripts::toXMLFile(ostream& rOut,
7681 + const char* szTag)
7683 + if (numScripts()) {
7684 + rOut << endl << "\t\t<" << szTag << ">";
7685 + for (unsigned int i = 0; i < numScripts(); i++)
7686 + getScript(i).toXMLFile(rOut, "\t");
7687 + rOut << endl << "\t\t</" << szTag << ">";
7690 Index: xmlspec/XMLScript.h
7691 ===================================================================
7692 RCS file: xmlspec/XMLScript.h
7693 diff -N xmlspec/XMLScript.h
7694 --- /dev/null 1 Jan 1970 00:00:00 -0000
7695 +++ rpm/xmlspec/XMLScript.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
7697 +#ifndef _H_XMLSCRIPT_
7698 +#define _H_XMLSCRIPT_
7700 +// standard C++ includes
7701 +#include <iostream>
7706 +#include "XMLAttrs.h"
7707 +#include "XMLBase.h"
7710 +#include <rpmbuild.h>
7712 +// forward definitions
7717 +using namespace std;
7719 +class XMLScript : public XMLBase
7726 + * Creates a script object and adds it to the container
7728 + * @param pAttrs The XML attributes
7729 + * @param szScript The script value
7730 + * @param rContainer reference to the script container to add to
7731 + * @return true on success, false otherwise
7733 + static bool parseCreate(XMLAttrs* pAttrs,
7734 + const char* szScript,
7735 + XMLScripts& rContainer);
7738 +// constructors/destructor
7742 + * Default constructor
7744 + * @param szScript The script
7745 + * @param szInterpreter The interpreter to use for script execution
7746 + * @param szDir Directory to execute the script in
7749 + XMLScript(const char* szScript,
7750 + const char* szInterpreter,
7751 + const char* szDir);
7754 + * Copy constructor
7756 + * @param rScript Script to copy
7759 + XMLScript(const XMLScript& rScript);
7767 + virtual ~XMLScript();
7774 + * Assignment operator
7776 + * @param script the script to copy
7777 + * @return the copied object
7779 + XMLScript operator=(XMLScript script);
7782 +// member functions
7786 + * Converts the object into an RPM spec file
7788 + * @param rOut Output stream
7791 + void toSpecFile(ostream& rOut);
7794 + * Converts the object into an XML spec
7796 + * @param rOut Output stream
7797 + * @param szIndent Indent string
7800 + void toXMLFile(ostream& rOut,
7801 + const char* szIndent = "");
7804 + * Converts the object into an RPM structure
7806 + * @param pSB Pointer to the string buffer
7809 + virtual void toRPMStruct(StringBuf* pSB);
7812 +// member variable get/set functions
7816 + * Gets the script value
7819 + * @return string containing the script
7821 + const char* getValue()
7823 + return m_sValue.c_str();
7827 + * Checks if we have an interpreter
7830 + * @return true if we have an interpreter, false otherwise
7832 + bool hasInterpreter()
7834 + return m_sInterpreter.length() ? true : false;
7838 + * Gets the interpreter
7841 + * @return string contating the interpreter
7843 + const char* getInterpreter()
7845 + return m_sInterpreter.c_str();
7849 + * Checks if we have a direcory
7852 + * @return true if we have a directory, false otherwise
7854 + bool hasDirectory()
7856 + return m_sDir.length() ? true : false;
7860 + * Gets the directory
7863 + * @return string contating the directory
7865 + const char* getDirectory()
7867 + return m_sDir.c_str();
7871 + * Gets the length of the directory string
7874 + * @return length of the description string
7876 + unsigned int getDirectoryLen()
7878 + return m_sDir.length();
7882 +// member variables
7886 + string m_sInterpreter;
7890 +//<prep,build,install,clean ...>
7891 +class XMLScripts : public XMLBase
7894 +// factory functions
7897 + static bool addPrepScript(XMLAttrs* pAttrs,
7898 + const char* szScript,
7901 + static bool addBuildScript(XMLAttrs* pAttrs,
7902 + const char* szScript,
7905 + static bool addInstallScript(XMLAttrs* pAttrs,
7906 + const char* szScript,
7909 + static bool addCleanScript(XMLAttrs* pAttrs,
7910 + const char* szScript,
7914 +// constructors/destructor
7918 + * Default constructor
7926 + * Copy constructor
7928 + * @param rContainer the object to copy
7931 + XMLScripts(const XMLScripts& rContainer);
7939 + virtual ~XMLScripts();
7942 +// member functions
7946 + * Converts the object into an RPM spec file
7948 + * @param rOut Output stream
7949 + * @param szTag The tag name
7952 + virtual void toSpecFile(ostream& rOut,
7953 + const char* szTag);
7956 + * Converts the object into an XML spec
7958 + * @param rOut Output stream
7959 + * @param szTag The tag name
7962 + void toXMLFile(ostream& rOut,
7963 + const char* szTag);
7966 +// member variable get/set functions
7970 + * Checks if we have an interpreter
7973 + * @return true if we have an interpreter, false otherwise
7975 + bool hasInterpreter()
7977 + return m_sInterpreter.length() ? true : false;
7981 + * Gets the interpreter
7984 + * @return string contatining the interpreter
7986 + const char* getInterpreter()
7988 + return m_sInterpreter.c_str();
7992 + * Sets the script interpreter
7994 + * @param szInterpreter The interpreter
7997 + void setInterpreter(const char* szInterpreter)
7999 + if (szInterpreter)
8000 + m_sInterpreter.assign(szInterpreter);
8004 + * Gets the number of script entries
8007 + * @return the number of scripts
8009 + unsigned int numScripts()
8011 + return m_vScripts.size();
8015 + * Gets a specific script entry
8017 + * @param nNum The entry number
8018 + * @return Reference to the script entry
8020 + XMLScript& getScript(unsigned int nNum)
8022 + return m_vScripts[nNum];
8026 + * Adds an script entry
8028 + * @param szScript the script to add
8031 + void add(XMLScript& rScript)
8033 + m_vScripts.push_back(rScript);
8037 +// member variables
8040 + string m_sInterpreter;
8041 + vector<XMLScript> m_vScripts;
8044 +//<post, postun, ...>
8045 +class XMLPackageScripts : public XMLScripts
8048 +// factory functions
8052 + * Adds a pre script
8054 + * @param pAttrs The XML attributes
8055 + * @param szScript The script to add
8056 + * @param pSpec The spec to which we are adding
8057 + * @return true on success, false otherwise
8059 + static bool addPreScript(XMLAttrs* pAttrs,
8060 + const char* szScript,
8064 + * Adds a post script
8066 + * @param pAttrs The XML attributes
8067 + * @param szScript The script to add
8068 + * @param pSpec The spec to which we are adding
8069 + * @return true on success, false otherwise
8071 + static bool addPostScript(XMLAttrs* pAttrs,
8072 + const char* szScript,
8076 + * Adds a preun script
8078 + * @param pAttrs The XML attributes
8079 + * @param szScript The script to add
8080 + * @param pSpec The spec to which we are adding
8081 + * @return true on success, false otherwise
8083 + static bool addPreUnScript(XMLAttrs* pAttrs,
8084 + const char* szScript,
8088 + * Adds a postun script
8090 + * @param pAttrs The XML attributes
8091 + * @param szScript The script to add
8092 + * @param pSpec The spec to which we are adding
8093 + * @return true on success, false otherwise
8095 + static bool addPostUnScript(XMLAttrs* pAttrs,
8096 + const char* szScript,
8100 + * Adds a verify script
8102 + * @param pAttrs The XML attributes
8103 + * @param szScript The script to add
8104 + * @param pSpec The spec to which we are adding
8105 + * @return true on success, false otherwise
8107 + static bool addVerifyScript(XMLAttrs* pAttrs,
8108 + const char* szScript,
8112 + * Initialises a pre script container
8114 + * @param pAttrs The XML attributes
8115 + * @param pSpec The spec to which we are adding
8116 + * @return true on success, false otherwise
8118 + static bool createPreScripts(XMLAttrs* pAttrs,
8122 + * Initialises a post script container
8124 + * @param pAttrs The XML attributes
8125 + * @param pSpec The spec to which we are adding
8126 + * @return true on success, false otherwise
8128 + static bool createPostScripts(XMLAttrs* pAttrs,
8132 + * Initialises a preun script container
8134 + * @param pAttrs The XML attributes
8135 + * @param pSpec The spec to which we are adding
8136 + * @return true on success, false otherwise
8138 + static bool createPreUnScripts(XMLAttrs* pAttrs,
8142 + * Initialises a postun script container
8144 + * @param pAttrs The XML attributes
8145 + * @param pSpec The spec to which we are adding
8146 + * @return true on success, false otherwise
8148 + static bool createPostUnScripts(XMLAttrs* pAttrs,
8152 + * Initialises a verify script container
8154 + * @param pAttrs The XML attributes
8155 + * @param pSpec The spec to which we are adding
8156 + * @return true on success, false otherwise
8158 + static bool createVerifyScripts(XMLAttrs* pAttrs,
8162 +// constructors/destructors
8166 + * Default constructor
8171 + XMLPackageScripts();
8174 + * Copy constructor
8176 + * @param rScripts Reference to the object to copy
8179 + XMLPackageScripts(const XMLPackageScripts& rScripts);
8187 + ~XMLPackageScripts();
8190 +// member functions
8194 + * Converts the object into an RPM spec
8196 + * @param rOut Output stream
8197 + * @param szTag The tag name
8200 + virtual void toSpecFile(ostream& rOut,
8201 + const char* szTag);
8204 + * Converts the object into an XML spec
8206 + * @param rOut Output stream
8207 + * @param szTag The tag name
8210 + virtual void toXMLFile(ostream& rOut,
8211 + const char* szTag);
8216 Index: xmlspec/XMLSource.cpp
8217 ===================================================================
8218 RCS file: xmlspec/XMLSource.cpp
8219 diff -N xmlspec/XMLSource.cpp
8220 --- /dev/null 1 Jan 1970 00:00:00 -0000
8221 +++ rpm/xmlspec/XMLSource.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
8223 +// standard includes
8227 +#include "XMLSource.h"
8228 +#include "XMLSpec.h"
8231 +#include <rpmspec.h>
8233 +using namespace std;
8235 +bool XMLSource::structCreate(Source* pSource,
8239 + if (!pXSpec || !pSpec || !pSource)
8242 + // create our mirror
8243 + XMLMirror *pMirror = NULL;
8244 + if (pSource->source != pSource->fullSource) {
8245 + unsigned int nLen = pSource->source-pSource->fullSource;
8246 + char szPath[nLen+1];
8247 + strncpy(szPath, pSource->fullSource, nLen);
8248 + szPath[nLen] = '\0';
8249 + pMirror = new XMLMirror(szPath, NULL, NULL);
8252 + // generate the source, nosource, patch
8253 + XMLSource* pXSource = NULL;
8254 + XMLNoSource* pXNoSource = NULL;
8255 + XMLPatch* pXPatch = NULL;
8256 + switch (pSource->flags) {
8257 + case RPMBUILD_ISSOURCE:
8258 + pXSource = new XMLSource(pSource->source, pSource->num,
8259 + NULL, NULL, NULL);
8260 + pXSpec->addSource(*pXSource);
8262 + pXSpec->lastSource().addMirror(*pMirror);
8265 + case RPMBUILD_ISNO:
8266 + pXNoSource = new XMLNoSource(pSource->source, pSource->num,
8267 + NULL, NULL, NULL);
8268 + pXSpec->addNoSource(*pXNoSource);
8270 + pXSpec->lastNoSource().addMirror(*pMirror);
8271 + delete pXNoSource;
8273 + case RPMBUILD_ISPATCH:
8274 + pXPatch = new XMLPatch(pSource->source, pSource->num, NULL, NULL);
8275 + pXSpec->addPatch(*pXPatch);
8277 + pXSpec->lastPatch().addMirror(*pMirror);
8286 + // do the next source and return
8287 + XMLSource::structCreate(pSource->next, pSpec, pXSpec);
8291 +// attribute structure for XMLSource
8292 +structValidAttrs g_paSourceAttrs[] =
8294 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
8295 + {0x0001, false, false, "num", XATTRTYPE_INTEGER, {NULL}},
8296 + {0x0002, false, false, "dir", XATTRTYPE_STRING, {"*", NULL}},
8297 + {0x0003, false, false, "size", XATTRTYPE_INTEGER, {NULL}},
8298 + {0x0004, false, false, "md5", XATTRTYPE_STRING, {"*", NULL}},
8299 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
8302 +bool XMLSource::parseCreate(XMLAttrs* pAttrs,
8305 + // validate the attributes
8306 + if (!pAttrs->validate(g_paSourceAttrs, (XMLBase*)pSpec))
8309 + XMLSource source(pAttrs->asString("name"), pAttrs->asInteger("num"),
8310 + pAttrs->asString("dir"), pAttrs->asString("size"),
8311 + pAttrs->asString("md5"));
8312 + pSpec->addSource(source);
8317 +XMLSource::XMLSource(const char* szName,
8318 + unsigned int nNum,
8319 + const char* szDir,
8320 + const char* szSize,
8321 + const char* szMD5)
8325 + m_sName.assign(szName);
8328 + m_sDir.assign(szDir);
8330 + m_sSize.assign(szSize);
8332 + m_sMD5.assign(szMD5);
8335 +XMLSource::XMLSource(const XMLSource& rSource)
8338 + m_sName.assign(rSource.m_sName);
8339 + m_nNum = rSource.m_nNum;
8340 + m_sDir.assign(rSource.m_sDir);
8341 + m_sSize.assign(rSource.m_sSize);
8342 + m_sMD5.assign(rSource.m_sMD5);
8343 + m_vMirrors = rSource.m_vMirrors;
8346 +XMLSource::~XMLSource()
8350 +XMLSource XMLSource::operator=(XMLSource source)
8352 + m_sName.assign(source.m_sName);
8353 + m_nNum = source.m_nNum;
8354 + m_sDir.assign(source.m_sDir);
8355 + m_sSize.assign(source.m_sSize);
8356 + m_sMD5.assign(source.m_sMD5);
8357 + m_vMirrors = source.m_vMirrors;
8361 +void XMLSource::toSpecFile(ostream& rOut)
8363 + for (unsigned int i = 0; i < numMirrors(); i++)
8364 + getMirror(i).toSpecFile(rOut);
8366 + rOut << endl << "source";
8370 + rOut << getMirror(0).getPath();
8371 + rOut << getName();
8374 +void XMLSource::toXMLFile(ostream& rOut)
8376 + rOut << endl << "\t<source name=\"" << getName() << "\"";
8377 + rOut << endl << "\t num=\"";
8381 + rOut << endl << "\t size=\"" << getSize() << "\"";
8383 + rOut << endl << "\t md5=\"" << getMD5() << "\"";
8385 + rOut << endl << "\t dir=\"" << getDir() << "\"";
8388 + for (unsigned int i = 0; i < numMirrors(); i++)
8389 + getMirror(i).toXMLFile(rOut);
8391 + rOut << endl << "\t</source>";
8394 +void XMLSource::toRPMStruct(Spec pRPMSpec)
8396 + /*Source* pCurr = new Source;
8397 + unsigned int nNameLen = strlen(getName());
8398 + unsigned int nMirrorLen = 0;
8400 + pPrev->next = pCurr;
8401 + pCurr->next = NULL;
8403 + nMirrorlen = strlen(getMirror(0).getPath());
8404 + pCurr->fullSource = new char[nNamelen+nMirrorLen+1];
8405 + pCurr->fullSources[0] = '\0';
8407 + strcpy(pCurr->fullSource, getMirror(0).getPath());
8408 + strcat(pCurr->fullSource, getName());
8409 + pCurr->source = pCurr->fullSource+nMirrorLen;
8410 + pCurr->num = getNum();
8411 + pCurr->flags = RPMBUILD_ISSOURCE;
8415 +bool XMLNoSource::parseCreate(XMLAttrs* pAttrs,
8418 + // validate the attributes
8419 + if (!pAttrs->validate(g_paSourceAttrs, (XMLBase*)pSpec))
8422 + XMLNoSource source(pAttrs->asString("name"), pAttrs->asInteger("num"),
8423 + pAttrs->asString("dir"), pAttrs->asString("size"),
8424 + pAttrs->asString("md5"));
8425 + pSpec->addNoSource(source);
8429 +XMLNoSource::XMLNoSource(const char* szName,
8430 + unsigned int nNum,
8431 + const char* szDir,
8432 + const char* szSize,
8433 + const char* szMD5)
8434 + : XMLSource(szName,
8442 +XMLNoSource::XMLNoSource(const XMLNoSource& rNoSource)
8443 + : XMLSource(rNoSource.m_sName.c_str(),
8445 + rNoSource.m_sDir.c_str(),
8446 + rNoSource.m_sSize.c_str(),
8447 + rNoSource.m_sMD5.c_str())
8451 +XMLNoSource::~XMLNoSource()
8455 +void XMLNoSource::toSpecFile(ostream& rOut)
8457 + for (unsigned int i = 0; i < numMirrors(); i++)
8458 + getMirror(i).toSpecFile(rOut);
8460 + rOut << endl << "nosource";
8462 + rOut << ": " << getName();
8465 +void XMLNoSource::toXMLFile(ostream& rOut)
8467 + for (unsigned int i = 0; i < numMirrors(); i++)
8468 + getMirror(i).toXMLFile(rOut);
8471 +void XMLNoSource::toRPMStruct(Spec pRPMSpec)
8473 + //Source* pCurr = XMLSource::toRPMStruct(pPrev);
8474 + //pCurr->flags = RPMBUILD_ISNO;
8478 +// attribute structure for XMLPatch
8479 +structValidAttrs g_paPatchAttrs[] =
8481 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
8482 + {0x0001, false, false, "num", XATTRTYPE_INTEGER, {NULL}},
8483 + {0x0002, false, false, "size", XATTRTYPE_INTEGER, {NULL}},
8484 + {0x0003, false, false, "md5", XATTRTYPE_STRING, {"*", NULL}},
8485 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
8488 +bool XMLPatch::parseCreate(XMLAttrs* pAttrs,
8491 + // validate the attributes
8492 + if (!pAttrs->validate(g_paPatchAttrs, (XMLBase*)pSpec))
8495 + XMLPatch patch(pAttrs->asString("name"), pAttrs->asInteger("num"),
8496 + pAttrs->asString("size"), pAttrs->asString("md5"));
8497 + pSpec->addPatch(patch);
8501 +XMLPatch::XMLPatch(const char* szName,
8502 + unsigned int nNum,
8503 + const char* szSize,
8504 + const char* szMD5)
8505 + : XMLSource(szName,
8513 +XMLPatch::XMLPatch(const XMLPatch& rPatch)
8514 + : XMLSource(rPatch.m_sName.c_str(),
8517 + rPatch.m_sSize.c_str(),
8518 + rPatch.m_sMD5.c_str())
8522 +XMLPatch::~XMLPatch()
8526 +void XMLPatch::toSpecFile(ostream& rOut)
8528 + for (unsigned int i = 0; i < numMirrors(); i++)
8529 + getMirror(i).toSpecFile(rOut);
8530 + rOut << endl << "patch";
8532 + rOut << ": " << getName();
8535 +void XMLPatch::toXMLFile(ostream& rOut)
8537 + rOut << endl << "\t<patch name=\"" << getName() << "\"";
8538 + rOut << endl << "\t num=\"";
8542 + rOut << endl << "\t size=\"" << getSize() << "\"";
8544 + rOut << endl << "\t md5=\"" << getMD5() << "\"";
8546 + rOut << endl << "\t dir=\"" << getDir() << "\"";
8549 + for (unsigned int i = 0; i < numMirrors(); i++)
8550 + getMirror(i).toXMLFile(rOut);
8552 + rOut << endl << "\t</patch>";
8555 +void XMLPatch::toRPMStruct(Spec pRPMSpec)
8558 + //Source* pCurr = XMLSource::toRPMStruct(pPrev);
8559 + //pCurr->flags = RPMBUILD_ISPATCH;
8562 Index: xmlspec/XMLSource.h
8563 ===================================================================
8564 RCS file: xmlspec/XMLSource.h
8565 diff -N xmlspec/XMLSource.h
8566 --- /dev/null 1 Jan 1970 00:00:00 -0000
8567 +++ rpm/xmlspec/XMLSource.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
8569 +#ifndef _H_XMLSOURCE_
8570 +#define _H_XMLSOURCE_
8572 +// standard C++ includes
8575 +#include <iostream>
8577 +// standard includes
8581 +#include "XMLAttrs.h"
8582 +#include "XMLBase.h"
8583 +#include "XMLMirror.h"
8586 +#include <rpmbuild.h>
8588 +// forward declaration
8591 +using namespace std;
8594 +class XMLSource : public XMLBase
8597 +// factory functions
8601 + * Static factory function for the creation of XMLSource, XMLPatch, ...
8602 + * objects from RPM Source* structure.
8604 + * @param pSource Pointer to a list of sources
8605 + * @param pSpec pointer to the RPM spec
8606 + * @param pSpec pointer to our spec object
8607 + * @return true on success, false otherwise
8609 + static bool structCreate(Source* pSource,
8614 + * Static factory function for the creation of an XMLSource
8615 + * object from details parsed from an XML spec.
8617 + * @param pAttrs Pointer to an XML attribute object
8618 + * @param pspec Ponter to our spec object
8619 + * @param bPatch True if this source is a patch
8620 + * @return true on success, false otherwise
8622 + static bool parseCreate(XMLAttrs* pAttrs,
8626 +// constructors/destructor
8630 + * Default contructor
8632 + * @param szName The name
8633 + * @param szNum The source number
8634 + * @param szDir The unpack directory
8635 + * @param szSize The size of the source archive
8636 + * @param szMD5 The MD5 sum of the archive
8639 + XMLSource(const char* szName,
8640 + unsigned int nNum,
8641 + const char* szDir,
8642 + const char* szSize,
8643 + const char* szMD5);
8648 + * @param rSource The source that we are to copy
8651 + XMLSource(const XMLSource& rSource);
8659 + virtual ~XMLSource();
8666 + * Assignment operator
8668 + * @param source The source to copy
8669 + * @return copied object
8671 + XMLSource operator=(XMLSource source);
8674 +// Member functions
8678 + * Convert the object into an RPM spec file
8680 + * @param rOut Output stream
8683 + virtual void toSpecFile(ostream& rOut);
8686 + * Converts the object into an XML spec
8688 + * @param rOut Output stream
8691 + virtual void toXMLFile(ostream& rOut);
8694 + * Converts the object into an RPM structure
8696 + * @param spec the RPM structure to use
8699 + virtual void toRPMStruct(Spec spec);
8702 +// member variable get/set functions
8706 + * Checks if we have a source name
8709 + * @return true if we have a name, false otherwise
8713 + return m_sName.length() ? true : false;
8717 + * Get the source name
8720 + * @return string containing the name
8722 + const char* getName()
8724 + return m_sName.c_str();
8728 + * Get the length of the name
8731 + * @return the length of the name
8733 + unsigned int getNameLen()
8735 + return m_sName.length();
8739 + * Get the source number
8742 + * @return the number
8744 + unsigned int getNum()
8750 + * Checks to see if we have an unpack directory
8753 + * @return true if we have a specified directory, false otherwise
8757 + return m_sDir.length() ? true : false;
8761 + * Gets the directory that we are to unpack this source to
8764 + * @return string contating the directory
8766 + const char* getDir()
8768 + return m_sDir.c_str();
8772 + * Checks to see if we have a source size
8775 + * @return true if we have a size, false otherwise
8779 + return m_sSize.length() ? true : false;
8783 + * Gets the size of the source
8786 + * @return string contating the size
8788 + const char* getSize()
8790 + return m_sSize.c_str();
8794 + * Checks to see if this source has an MD5 sum
8797 + * @return true if we have an MD5, false oterwise
8801 + return m_sMD5.length() ? true : false;
8805 + * Gets the MD5 sum for this source
8808 + * @return string contating the MD5
8810 + const char* getMD5()
8812 + return m_sMD5.c_str();
8816 + * Add a mirror for this source
8818 + * @param rMirror The mirror to add
8821 + void addMirror(XMLMirror& rMirror)
8823 + m_vMirrors.push_back(rMirror);
8827 + * Gets the number of mirrors for this source
8830 + * @return the number oif mirrors
8832 + unsigned int numMirrors()
8834 + return m_vMirrors.size();
8838 + * Gets a specific mirror by number
8840 + * @param nNum The mirror to get
8841 + * @param the mirror
8843 + XMLMirror& getMirror(unsigned int nNum)
8845 + return m_vMirrors[nNum];
8849 +// member variables
8853 + unsigned int m_nNum;
8857 + vector<XMLMirror> m_vMirrors;
8861 +class XMLNoSource : public XMLSource
8868 + * Create an XMLNoSource object
8870 + * @param pAttrs XML attributes
8871 + * @param pSpec The spec to add the object o
8872 + * @return true on success, false otherwise
8874 + static bool parseCreate(XMLAttrs* pAttrs,
8878 +// constructors/destructor
8882 + * Default constructor
8884 + * @param szName The name
8885 + * @param nNum source number
8886 + * @param szDir Thje director to extract to
8887 + * @param szSize size of the archive
8888 + * @param szMD5 the MD5 sum of the archive
8891 + XMLNoSource(const char* szName,
8892 + unsigned int nNum,
8893 + const char* szDir,
8894 + const char* szSize,
8895 + const char* szMD5);
8898 + * Copy constructor
8900 + * @param rNoSource Reference to the object ot copy
8903 + XMLNoSource(const XMLNoSource& rNoSource);
8911 + virtual ~XMLNoSource();
8914 +// public member functions
8918 + * Converts the object into an RPM spec file
8920 + * @param rOut Output stream
8923 + virtual void toSpecFile(ostream& rOut);
8926 + * Converts the object into an XML spec
8928 + * @param rOut Output stream
8931 + virtual void toXMLFile(ostream& rOut);
8934 + * Converts the object into an RPM structure
8936 + * @param spec The RPM spec structure
8939 + virtual void toRPMStruct(Spec spec);
8943 +class XMLPatch : public XMLSource
8950 + * Create an XMLPatch object
8952 + * @param pAttrs XML attributes
8953 + * @param pSpec The spec to add the object o
8954 + * @return true on success, false otherwise
8956 + static bool parseCreate(XMLAttrs* pAttrs,
8960 +// constructors/destructor
8964 + * Default constructor
8966 + * @param szName archive name
8967 + * @param nNum source number
8968 + * @param szSize size of the archive
8969 + * @param szMD5 MD5 sum
8972 + XMLPatch(const char* szName,
8973 + unsigned int nNum,
8974 + const char* szSize,
8975 + const char* szMD5);
8978 + * Copy constructor
8980 + * @param rPatch Reference to the object to copy
8983 + XMLPatch(const XMLPatch& rPatch);
8991 + virtual ~XMLPatch();
8994 +// member functions
8998 + * Converts the object into an RPM spec file
9000 + * @param rOut Output stream
9003 + virtual void toSpecFile(ostream& rOut);
9006 + * Converts the object into an XML spec
9008 + * @param rOut Output stream
9011 + virtual void toXMLFile(ostream& rOut);
9014 + * Converts the object into an RPM structure
9016 + * @param spec The RPM spec structure
9019 + virtual void toRPMStruct(Spec spec);
9023 Index: xmlspec/XMLSpec.cpp
9024 ===================================================================
9025 RCS file: xmlspec/XMLSpec.cpp
9026 diff -N xmlspec/XMLSpec.cpp
9027 --- /dev/null 1 Jan 1970 00:00:00 -0000
9028 +++ rpm/xmlspec/XMLSpec.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
9030 +// 3rd party includes
9034 +#include "XMLAttrs.h"
9035 +#include "XMLRPMWrap.h"
9036 +#include "XMLSpec.h"
9039 +#include <rpmlib.h>
9041 +using namespace std;
9043 +// attribute structure for XMLSpec
9044 +structValidAttrs g_paSpecAttrs[] =
9046 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
9047 + {0x0001, true, false, "version", XATTRTYPE_STRING, {"*", NULL}},
9048 + {0x0002, true, false, "release", XATTRTYPE_STRING, {"*", NULL}},
9049 + {0x0003, false, false, "epoch", XATTRTYPE_INTEGER, {NULL}},
9050 + {0x0004, false, false, "distribution", XATTRTYPE_STRING, {"*", NULL}},
9051 + {0x0005, false, false, "vendor", XATTRTYPE_STRING, {"*", NULL}},
9052 + {0x0006, false, false, "packager", XATTRTYPE_STRING, {"*", NULL}},
9053 + {0x0007, false, false, "packager-email", XATTRTYPE_MAIL, {"*", NULL}},
9054 + {0x0008, false, false, "copyright", XATTRTYPE_STRING, {"*", NULL}},
9055 + {0x0009, false, false, "url", XATTRTYPE_STRING, {"*", NULL}},
9056 + {0x000A, false, false, "buildroot", XATTRTYPE_STRING, {"*", NULL}},
9057 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
9060 +XMLSpec* XMLSpec::parseCreate(XMLAttrs* pAttrs,
9061 + const char* szFilename)
9063 + // verify the attributes
9064 + if (!pAttrs->validate(g_paSpecAttrs, (XMLBase*)pAttrs))
9067 + // create and return
9068 + return new XMLSpec(szFilename,
9069 + pAttrs->asString("name"),
9070 + pAttrs->asString("version"),
9071 + pAttrs->asString("release"),
9072 + pAttrs->asString("epoch"),
9073 + pAttrs->asString("distribution"),
9074 + pAttrs->asString("vendor"),
9075 + pAttrs->asString("packager"),
9076 + pAttrs->asString("packager-email"),
9077 + pAttrs->asString("copyright"),
9078 + pAttrs->asString("url"),
9079 + pAttrs->asString("buildroot"));
9082 +XMLSpec* XMLSpec::structCreate(Spec pSpec)
9084 + if (!pSpec || !pSpec->packages || !pSpec->packages->header)
9087 + // create the spec with values from the RPM stuff
9088 + string sName, sVersion, sRelease, sEpoch, sDistro;
9089 + string sVendor, sPackager, sMail, sLicense, sURL;
9090 + if (!getRPMHeader(pSpec->packages->header, RPMTAG_NAME, sName) ||
9091 + !getRPMMacro("PACKAGE_VERSION", sVersion) ||
9092 + !getRPMMacro("PACKAGE_RELEASE", sRelease))
9094 + getRPMHeader(pSpec->packages->header, RPMTAG_EPOCH, sEpoch);
9095 + getRPMHeader(pSpec->packages->header, RPMTAG_DISTRIBUTION, sDistro);
9096 + getRPMHeader(pSpec->packages->header, RPMTAG_VENDOR, sVendor);
9097 + getRPMHeader(pSpec->packages->header, RPMTAG_PACKAGER, sPackager);
9098 + getRPMHeader(pSpec->packages->header, RPMTAG_LICENSE, sLicense);
9099 + getRPMHeader(pSpec->packages->header, RPMTAG_URL, sURL);
9100 + XMLSpec* pXSpec = new XMLSpec(pSpec->specFile, sName.c_str(), sVersion.c_str(),
9101 + sRelease.c_str(), sEpoch.c_str(), sDistro.c_str(),
9102 + sVendor.c_str(), sPackager.c_str(), sMail.c_str(),
9103 + sLicense.c_str(), sURL.c_str(), pSpec->buildRootURL);
9105 + // add sources, packages all kinds of funny stuff
9106 + XMLChangelog::structCreate(pSpec, pXSpec);
9107 + XMLSource::structCreate(pSpec->sources, pSpec, pXSpec);
9108 + XMLPackage::structCreate(pSpec->packages, pSpec, pXSpec);
9110 + // return the created spec
9114 +XMLSpec::XMLSpec(const char* szFilename,
9115 + const char* szName,
9116 + const char* szVersion,
9117 + const char* szRelease,
9118 + const char* szEpoch,
9119 + const char* szDistribution,
9120 + const char* szVendor,
9121 + const char* szPackager,
9122 + const char* szPkgrEmail,
9123 + const char* szCopyright,
9124 + const char* szURL,
9125 + const char* szBuildRoot) : XMLBase()
9128 + m_sFilename.assign(szFilename);
9130 + m_sName.assign(szName);
9132 + m_sVersion.assign(szVersion);
9134 + m_sRelease.assign(szRelease);
9136 + m_sEpoch.assign(szEpoch);
9137 + if (szDistribution)
9138 + m_sDistribution.assign(szDistribution);
9140 + m_sVendor.assign(szVendor);
9142 + m_sPackager.assign(szPackager);
9144 + m_sPkgrEmail.assign(szPkgrEmail);
9146 + m_sCopyright.assign(szCopyright);
9148 + m_sURL.assign(szURL);
9150 + m_sBuildRoot.assign(szBuildRoot);
9153 +XMLSpec::~XMLSpec()
9157 +void XMLSpec::toSpecFile(ostream& rOut)
9159 + for (unsigned int i = 0; i < numXMacros(); i++)
9160 + getXMacro(i).toSpecFile(rOut);
9162 + rOut << "name: " << getName() << endl;
9163 + rOut << "version: " << getVersion() << endl;
9164 + rOut << "release: " << getRelease() << endl;
9166 + rOut << "epoch: " << getEpoch() << endl;
9167 + if (hasCopyright())
9168 + rOut << "copyright: " << getCopyright() << endl;
9170 + rOut << "url: " << getURL() << endl;
9171 + if (hasBuildRoot())
9172 + rOut << "buildroot: " << getBuildRoot() << endl;
9173 + if (hasDistribution())
9174 + rOut << "distribution: " << getDistribution() << endl;
9176 + rOut << "vendor: " << getVendor() << endl;
9177 + if (hasPackager()) {
9178 + rOut << "packager: " << getPackager();
9179 + if (hasPkgrEmail())
9180 + rOut << " <" << getPkgrEmail() << ">";
9184 + for (unsigned int i = 0; i < numSources(); i++)
9185 + getSource(i).toSpecFile(rOut);
9186 + //for (unsigned int i = 0; i < numNoSources(); i++)
9187 + // getNoSource(i).toSpecFile(rOut);
9188 + for (unsigned int i = 0; i < numPatches(); i++)
9189 + getPatch(i).toSpecFile(rOut);
9190 + for (unsigned int i = 0; i < numPackages(); i++)
9191 + getPackage(i).toSpecFile(rOut);
9193 + getPrep().toSpecFile(rOut, "prep");
9194 + getBuild().toSpecFile(rOut, "build");
9195 + getInstall().toSpecFile(rOut, "install");
9196 + getClean().toSpecFile(rOut, "clean");
9198 + for (unsigned int i = 0; i < numPackages(); i++)
9199 + getPackage(i).toScriptsSpecFile(rOut);
9201 + for (unsigned int i = 0; i < numPackages(); i++)
9202 + getPackage(i).toFilesSpecFile(rOut);
9204 + getChangelog().toSpecFile(rOut);
9207 +void XMLSpec::toXMLFile(ostream& rOut)
9210 + rOut << "<?xml version=\"1.0\"?>";
9211 + rOut << endl << "<spec name=\"" << getName() << "\"";
9212 + rOut << endl << " version=\"" << getVersion() << "\"";
9213 + rOut << endl << " release=\"" << getRelease() << "\"";
9215 + rOut << endl << " epoch=\"" << getEpoch() << "\"";
9216 + if (hasCopyright())
9217 + rOut << endl << " copyright=\"" << getCopyright() << "\"";
9219 + rOut << endl << " url=\"" << getURL() << "\"";
9220 + if (hasBuildRoot())
9221 + rOut << endl << " buildroot=\"" << getBuildRoot() << "\"";
9222 + if (hasDistribution())
9223 + rOut << endl << " distribution=\"" << getDistribution() << "\"";
9225 + rOut << endl << " vendor=\"" << getVendor() << "\"";
9226 + if (hasPackager()) {
9227 + rOut << endl << " packager=\"" << getPackager() << "\"";
9228 + if (hasPkgrEmail())
9229 + rOut << endl << " packager-email=\"" << getPkgrEmail() << "\"";
9233 + for (unsigned int i = 0; i < numXMacros(); i++)
9234 + getXMacro(i).toXMLFile(rOut);
9235 + for (unsigned int i = 0; i < numSources(); i++)
9236 + getSource(i).toXMLFile(rOut);
9237 + for (unsigned int i = 0; i < numNoSources(); i++)
9238 + getNoSource(i).toXMLFile(rOut);
9239 + for (unsigned int i = 0; i < numPatches(); i++)
9240 + getPatch(i).toXMLFile(rOut);
9241 + for (unsigned int i = 0; i < numPackages(); i++)
9242 + getPackage(i).toXMLFile(rOut);
9244 + getPrep().toXMLFile(rOut, "prep");
9245 + getBuild().toXMLFile(rOut, "build");
9246 + getInstall().toXMLFile(rOut, "install");
9247 + getClean().toXMLFile(rOut, "clean");
9249 + getChangelog().toXMLFile(rOut);
9251 + rOut << endl << "</spec>";
9254 +void XMLSpec::toRPMStruct(Spec* pRPMSpec)
9256 + Spec spec = newSpec();
9257 + if (hasBuildRoot()) {
9258 + spec->gotBuildRootURL = 1;
9259 + spec->buildRootURL = strdup(getBuildRoot());
9260 + addMacro(spec->macros, "buildroot", NULL, getBuildRoot(), RMIL_SPEC);
9262 + addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
9263 + spec->timeCheck = rpmExpandNumeric("%{_timecheck}");
9265 + //getChangelog().toRPMStruct(spec);
9266 + /*for (unsigned int i = 0; i < numPackages(); i++)
9267 + getPackage(i).toRPMStruct(pRPMSpec);
9268 + for (unsigned int i = 0; i < numSources(); i++)
9269 + getSource(i).toRPMStruct(pRPMSpec);
9270 + for (unsigned int i = 0; i < numNoSources(); i++)
9271 + getNoSource(i).toRPMStruct(pRPMSpec);
9272 + for (unsigned int i = 0; i < numPatches(); i++)
9273 + getPatch(i).toRPMStruct(pRPMSpec);*/
9275 + //getPrep().toRPMStruct(spec);
9276 + //getBuild().toRPMStruct(spec);
9277 + //getInstall().toRPMStruct(spec);
9278 + //getClean().toRPMStruct(spec);
9282 Index: xmlspec/XMLSpec.h
9283 ===================================================================
9284 RCS file: xmlspec/XMLSpec.h
9285 diff -N xmlspec/XMLSpec.h
9286 --- /dev/null 1 Jan 1970 00:00:00 -0000
9287 +++ rpm/xmlspec/XMLSpec.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
9289 +#ifndef _H_XMLSPEC_
9290 +#define _H_XMLSPEC_
9292 +// standard C++ includes
9293 +#include <iostream>
9298 +#include "XMLAttrs.h"
9299 +#include "XMLBase.h"
9300 +#include "XMLChangelog.h"
9301 +#include "XMLMacro.h"
9302 +#include "XMLPackage.h"
9303 +#include "XMLScript.h"
9304 +#include "XMLSource.h"
9307 +#include <rpmbuild.h>
9309 +using namespace std;
9312 +class XMLSpec : public XMLBase
9315 +// static object creation functions
9319 + * Creates an XMLSpec from values parsed
9321 + * @param pAttrs The XML attributes
9322 + * @param szFilename The XML spec filename
9323 + * @return Pointer to the created spec
9325 + static XMLSpec* parseCreate(XMLAttrs* pAttrs,
9326 + const char* szFilename);
9329 + * Creates and XMLSpec from an RPM Spec structure
9331 + * @param pSpec The RPM spec structure
9332 + * @return Pointer to the created spec
9334 + static XMLSpec* structCreate(Spec pSpec);
9337 +// constructors/destructor
9341 + * Default constructor
9343 + * @param szFilename Filename of the spec on disk
9344 + * @param szName spec name
9345 + * @param szVersion Spec version
9346 + * @param szRelease spec release
9347 + * @param szEpoch spec epoch
9348 + * @param szDistribution spec distribution
9349 + * @param szVendor spec vendor
9350 + * @param szPackage spec packager
9351 + * @param szPkgEmail email address for the packager
9352 + * @param szCopyright spec copyright/licence
9353 + * @param szURL main package url
9354 + * @param szBuildRoot buildroot
9357 + XMLSpec(const char* szFilename,
9358 + const char* szName,
9359 + const char* szVersion,
9360 + const char* szRelease,
9361 + const char* szEpoch,
9362 + const char* szDistribution,
9363 + const char* szVendor,
9364 + const char* szPackager,
9365 + const char* szPkgrEmail,
9366 + const char* szCopyright,
9367 + const char* szURL,
9368 + const char* szBuildRoot);
9379 +// public member functions
9383 + * Converts the spec object to a normal RPM spec file
9385 + * @param rOut Reference to the stream to write the information to
9388 + void toSpecFile(ostream& rOut);
9391 + * Converts the spec object to an XML spec file
9393 + * @param rOut Reference to the stream to write the information to
9396 + void toXMLFile(ostream& rOut);
9399 + * Converts the spec object to an internal RPM structure
9402 + * @return the created RPM structure
9404 + void toRPMStruct(Spec* pRPMSpec);
9407 +// member variable get/set functions
9411 + * Adds a package to the internal list
9413 + * @param rPkg Reference to the package to add
9416 + void addPackage(XMLPackage& rPkg)
9418 + m_vPackages.push_back(rPkg);
9422 + * Gets the number of packages
9425 + * @return the number of packages
9427 + unsigned int numPackages()
9429 + return m_vPackages.size();
9433 + * Gets a specific package
9435 + * @param nNum The package number
9436 + * @return the required package
9438 + XMLPackage& getPackage(unsigned int nNum)
9440 + return m_vPackages[nNum];
9444 + * Gets the last package added
9447 + * @return the last package added
9449 + XMLPackage& lastPackage()
9451 + return m_vPackages[numPackages()-1];
9455 + * Adds a source to the internal list
9457 + * @param rSource Reference to the source to add
9460 + void addSource(XMLSource& rSource)
9462 + m_vSources.push_back(rSource);
9466 + * Gets the number of sources
9469 + * @return the number of sources
9471 + unsigned int numSources()
9473 + return m_vSources.size();
9477 + * Gets a specific source
9479 + * @param nNum The source number
9480 + * @return the required source
9482 + XMLSource& getSource(unsigned int nNum)
9484 + return m_vSources[nNum];
9488 + * Gets the last source added
9491 + * @return the last source added
9493 + XMLSource& lastSource()
9495 + return m_vSources[numSources()-1];
9499 + * Adds a source to the internal list
9501 + * @param rSource Reference to the source to add
9504 + void addNoSource(XMLNoSource& rSource)
9506 + m_vNoSources.push_back(rSource);
9510 + * Gets the number of nosources
9513 + * @return the number of nsources
9515 + unsigned int numNoSources()
9517 + return m_vNoSources.size();
9521 + * Gets a specific nosource
9523 + * @param nNum The nosource number
9524 + * @return the required nosource
9526 + XMLNoSource& getNoSource(unsigned int nNum)
9528 + return m_vNoSources[nNum];
9532 + * Gets the last nosource added
9535 + * @return the last nosource added
9537 + XMLNoSource& lastNoSource()
9539 + return m_vNoSources[numNoSources()-1];
9543 + * Adds a patch to the internal list
9545 + * @param rSource Reference to the patch to add
9548 + void addPatch(XMLPatch& rSource)
9550 + m_vPatches.push_back(rSource);
9554 + * Gets the number of patches
9557 + * @return the number of patches
9559 + unsigned int numPatches()
9561 + return m_vPatches.size();
9565 + * Gets a specific patch
9567 + * @param nNum The patch number
9568 + * @return the required patch
9570 + XMLPatch& getPatch(unsigned int nNum)
9572 + return m_vPatches[nNum];
9576 + * Gets the last patch added
9579 + * @return the last patch added
9581 + XMLPatch& lastPatch()
9583 + return m_vPatches[numPatches()-1];
9587 + * Adds a macro to the internal list
9589 + * @param rMacro Reference to the macro to add
9592 + void addXMacro(XMLMacro& rMacro)
9594 + m_vMacros.push_back(rMacro);
9598 + * Gets the number of macros
9601 + * @return the number of macros
9603 + unsigned int numXMacros()
9605 + return m_vMacros.size();
9609 + * Gets a specific macro
9611 + * @param nNum The macro number
9612 + * @return the required macro
9614 + XMLMacro& getXMacro(unsigned int nNum)
9616 + return m_vMacros[nNum];
9620 + * Checks if we have a filename
9623 + * @return true if available, false otherwise
9625 + bool hasFilename()
9627 + return m_sFilename.length() ? true : false;
9631 + * Gets the filename
9634 + * @return string containing the filename
9636 + const char* getFilename()
9638 + return m_sFilename.c_str();
9642 + * Checks if we have a name
9645 + * @return true if available, false otherwise
9649 + return m_sName.length() ? true : false;
9656 + * @return string containing the name
9658 + const char* getName()
9660 + return m_sName.c_str();
9664 + * Checks if we have a version
9667 + * @return true if available, false otherwise
9671 + return m_sVersion.length() ? true : false;
9675 + * Gets the version
9678 + * @return string containing the version
9680 + const char* getVersion()
9682 + return m_sVersion.c_str();
9686 + * Checks if we have a release
9689 + * @return true if available, false otherwise
9693 + return m_sRelease.length() ? true : false;
9697 + * Gets the release
9700 + * @return string containing the release
9702 + const char* getRelease()
9704 + return m_sRelease.c_str();
9708 + * Checks if we have a epoch
9711 + * @return true if available, false otherwise
9715 + return m_sEpoch.length() ? true : false;
9722 + * @return string containing the epoch
9724 + const char* getEpoch()
9726 + return m_sEpoch.c_str();
9730 + * Checks if we have a distribution
9733 + * @return true if available, false otherwise
9735 + bool hasDistribution()
9737 + return m_sDistribution.length() ? true : false;
9741 + * Gets the distribution
9744 + * @return string containing the distribution
9746 + const char* getDistribution()
9748 + return m_sDistribution.c_str();
9752 + * Checks if we have a vendor
9755 + * @return true if available, false otherwise
9759 + return m_sVendor.length() ? true : false;
9766 + * @return string containing the vendor
9768 + const char* getVendor()
9770 + return m_sVendor.c_str();
9774 + * Checks if we have a packager
9777 + * @return true if available, false otherwise
9779 + bool hasPackager()
9781 + return m_sPackager.length() ? true : false;
9785 + * Gets the packager
9788 + * @return string containing the packager
9790 + const char* getPackager()
9792 + return m_sPackager.c_str();
9796 + * Checks if we have a packager email
9799 + * @return true if available, false otherwise
9801 + bool hasPkgrEmail()
9803 + return m_sPkgrEmail.length() ? true : false;
9807 + * Gets the packager's email address
9810 + * @return string containing the packager's email address
9812 + const char* getPkgrEmail()
9814 + return m_sPkgrEmail.c_str();
9818 + * Checks if we have a copyright
9821 + * @return true if available, false otherwise
9823 + bool hasCopyright()
9825 + return m_sCopyright.length() ? true : false;
9829 + * Gets the copyright
9832 + * @return string containing the copyright
9834 + const char* getCopyright()
9836 + return m_sCopyright.c_str();
9840 + * Checks if we have an URL
9843 + * @return true if available, false otherwise
9847 + return m_sURL.length() ? true : false;
9854 + * @return string containing the URL
9856 + const char* getURL()
9858 + return m_sURL.c_str();
9862 + * Checks if we have a BuildRoot
9865 + * @return true if available, false otherwise
9867 + bool hasBuildRoot()
9869 + return m_sBuildRoot.length() ? true : false;
9873 + * Gets the buildroot
9876 + * @return string containing the buildroor
9878 + const char* getBuildRoot()
9880 + return m_sBuildRoot.c_str();
9884 + * Gets the prep section
9887 + * @return reference to the prep section
9889 + XMLScripts& getPrep()
9895 + * Gets the build section
9898 + * @return reference to the build section
9900 + XMLScripts& getBuild()
9906 + * Gets the install section
9909 + * @return reference to the install section
9911 + XMLScripts& getInstall()
9917 + * Gets the clean section
9920 + * @return reference to the clean section
9922 + XMLScripts& getClean()
9928 + * Gets the changelog section
9931 + * @return reference to the changelog section
9933 + XMLChangelog& getChangelog()
9935 + return m_Changelog;
9939 +// internal member variables
9942 + string m_sFilename;
9944 + string m_sVersion;
9945 + string m_sRelease;
9947 + string m_sDistribution;
9949 + string m_sPackager;
9950 + string m_sPkgrEmail;
9951 + string m_sCopyright;
9953 + string m_sBuildRoot;
9954 + vector<XMLPackage> m_vPackages;
9955 + vector<XMLSource> m_vSources;
9956 + vector<XMLNoSource> m_vNoSources;
9957 + vector<XMLPatch> m_vPatches;
9958 + vector<XMLMacro> m_vMacros;
9959 + XMLScripts m_Prep;
9960 + XMLScripts m_Build;
9961 + XMLScripts m_Install;
9962 + XMLScripts m_Clean;
9963 + XMLChangelog m_Changelog;
9967 Index: xmlspec/XMLText.cpp
9968 ===================================================================
9969 RCS file: xmlspec/XMLText.cpp
9970 diff -N xmlspec/XMLText.cpp
9971 --- /dev/null 1 Jan 1970 00:00:00 -0000
9972 +++ rpm/xmlspec/XMLText.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
9975 +#include "XMLText.h"
9977 +using namespace std;
9979 +XMLText::XMLText(const char* szText,
9980 + const char* szLang)
9987 +XMLText::XMLText(const XMLText& rText)
9990 + setText(rText.m_sText.c_str());
9991 + setLang(rText.m_sLang.c_str());
9994 +XMLText::~XMLText()
9997 Index: xmlspec/XMLText.h
9998 ===================================================================
9999 RCS file: xmlspec/XMLText.h
10000 diff -N xmlspec/XMLText.h
10001 --- /dev/null 1 Jan 1970 00:00:00 -0000
10002 +++ rpm/xmlspec/XMLText.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
10004 +#ifndef _H_XMLTEXT_
10005 +#define _H_XMLTEXT_
10007 +// standard c++ includes
10011 +#include "XMLBase.h"
10013 +using namespace std;
10015 +class XMLText : public XMLBase
10018 +// constructors/destructor
10022 + * Default constructor
10024 + * @param szText The text to add
10025 + * @param szLang The text's language
10028 + XMLText(const char* szText,
10029 + const char* szLang = NULL);
10032 + * Copy constructor
10034 + * @param rText reference to the text to copy
10037 + XMLText(const XMLText& rText);
10040 + * Default destructor
10048 +// get/set methods for internal variables
10054 + * @param szText The text
10057 + void setText(const char* szText)
10060 + m_sText.assign(szText);
10067 + * @return string containing the text
10069 + const char* getText()
10071 + return m_sText.c_str();
10075 + * Tests if we have a language for this description
10078 + * @return true if we have a language, false otherwise
10082 + return m_sLang.length() ? true : false;
10086 + * Sets the language
10088 + * @param szLang The language
10091 + void setLang(const char* szLang)
10094 + // FIXME: We need to get the actual default language as specified
10095 + // in one of the RPM headers (which I cannot find now) and
10096 + // substitute it here. (I know the value is "C", bu we should
10097 + // use the define.)
10098 + if (strcmp(szLang, "C") != 0)
10099 + m_sLang.assign(szLang);
10104 + * Gets the language
10107 + * @return string containing the language
10109 + const char* getLang()
10111 + return m_sLang.c_str();
10115 +// member variables
10123 Index: xmlspec/example.spec.xml
10124 ===================================================================
10125 RCS file: xmlspec/example.spec.xml
10126 diff -N xmlspec/example.spec.xml
10127 --- /dev/null 1 Jan 1970 00:00:00 -0000
10128 +++ rpm/xmlspec/example.spec.xml 28 Aug 2002 10:52:43 -0000 1.3.2.1
10130 +<?xml version="1.0"?>
10132 + This is an example XML spec file to demonstrate the xml2spec
10133 + conversion program. By running "xml2spec example.spec.xml" it
10134 + will create an output spec in "normal" RPM spec format, ready
10135 + for comsumption by rpmbuild.
10137 +<spec name="example"
10141 + url="http://www.rpm.org/"
10142 + distribution="Any distribution"
10144 + packager="Jaco Greeff"
10145 + packager-email="jaco@puxedo.org"
10146 + buildroot="%{tmppath}/lvr-%{name}-build">
10148 + <macro name="test">value is this</macro>
10150 + <source name="rpm-4.0.4.tar.bz2"
10153 + md5="bb80a5d06a48623ecbe3f2d41cac15f9">
10154 + <mirror path="ftp://ftp.rpm.org/"
10155 + description="Main RPM FTP site" />
10156 + <mirror path="http://www.puxedo.org/downloads/source/"
10157 + description="puxedo.org source distribution"
10160 + <source name="expat-1.95.2.tar.bz2"
10163 + md5="919c78ddaf7f319b7e07792309ae2f22">
10164 + <mirror path="http://expat.sourceforge.net/"
10165 + description="SourceForge Mirror"
10169 + <patch name="example-1.0-1.patch.bz2"
10172 + md5="467c78cbdf75619b7e0abc2309ae2f11" />
10174 + <nosource name="nosource-sample-0.98.bz2"
10177 + <package group="System/Libraries">
10179 + <package name="automake" />
10180 + <package name="autoconf" />
10181 + <package name="bash" />
10182 + <package name="binutils" />
10183 + <package name="gcc" />
10184 + <package name="glibc-devel" />
10187 + <package name="gcc" cmp="ge" version="2.95" />
10188 + <package name="glibc" cmp="ge" version="2.2" />
10189 + <package name="libogg" />
10192 + <package name="%{name}" />
10195 + <package name="old-example" />
10197 + <summary>This spec is just an example for some funny purpose.</summary>
10198 + <summary lang="af">Hierdie is net 'n toets vir i18n in die opsomming</summary>
10199 + <description>%{summary}</description>
10200 + <description lang="af">Nog 'n toets, hierdie keer in die beskrywing</description>
10202 + <script interpreter="/bin/sh">/sbin/ldconfig</script>
10205 + <script>/sbin/ldconfig</script>
10208 + <file user="root" group="root">/usr/lib/*.so*</file>
10212 + <package name="devel"
10213 + group="Development/Libraries">
10215 + <package name="%{name}" />
10216 + <package name="libtool" />
10217 + <package name="m4" />
10219 + <summary>The libvorbis-devel package contains development headers.</summary>
10220 + <description>%{summary}</description>
10222 + <script>some pre stuff under devel</script>
10223 + <script dir="/here/while/we/are/at/it">That ^^^ changed directory</script>
10225 + <files user="root"
10227 + <file>/usr/include/*.h</file>
10228 + <file group="rpm">/usr/lib/*.la</file>
10229 + <file user="rpm">/usr/share/aclocal/*</file>
10230 + <file mode="777">/usr/share/m4/*</file>
10231 + <file user="user" group="group" mode="444">/usr/share/man/*</file>
10235 + <package name="toys" sub="no" group="Application/Toys">
10237 + <package name="%{name}" />
10240 + <package name="oldtoys" />
10242 + <summary>The toys package contains toys</summary>
10243 + <description>%{summary}</description>
10245 + <script>some preun stuff under toys</script>
10248 + <script>Some verify stuff under toys</script>
10251 + <file>/usr/doc/*</file>
10256 + <script>rm -rf $RPM_BUILD_DIR/%{name}-%{version}rc3</script>
10257 + <script>rm -rf %{buildroot}</script>
10258 + <setup path="%{name}-%{version}rc3" />
10262 + <script>./configure --prefix=/usr</script>
10263 + <script>make PROFILE='-Wall -W -pg -g -O2 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static' CFLAGS='-O2 -ffast-math -D_REENTRANT -fsigned-char -DUSE_MEMORY_H'</script>
10267 + <script>make DESTDIR=%{buildroot} install</script>
10271 + <script>rm -rf %{buildroot}</script>
10272 + <script>rm -rf $RPM_BUILD_DIR/%{name}-%{version}rc3</script>
10276 + <changes date="Wed Jun 05 2002"
10277 + author="Jaco Greeff"
10278 + author-email="jaco@puxedo.org"
10279 + version="1.0-06">
10280 + <change>Changed spec to make sure the output spec file can be understood by RPM</change>
10281 + <change>Added languages (description/summary) and a test in Afrikaans</change>
10283 + <changes date="Mon Jun 03 2002"
10284 + author="Jaco Greeff"
10285 + author-email="jaco@puxedo.org"
10286 + version="1.0-05">
10287 + <change>Changed file attributes to mode, user and group</change>
10289 + <changes date="Thu May 30 2002"
10290 + author="Jaco Greeff"
10291 + author-email="jaco@puxedo.org"
10292 + version="1.0-04">
10293 + <change>Added attribute "interpreter" to script</change>
10295 + <changes date="Sat May 25 2002"
10296 + author="Jaco Greeff"
10297 + author-email="jaco@puxedo.org"
10298 + version="1.0-03">
10299 + <change>Moved <files> into <package> structure</change>
10300 + <change>Added <nosource> tag as example</change>
10301 + <change>Changed <shell> to <script></change>
10303 + <changes date="Sun May 19 2002"
10304 + author="Jaco Greeff"
10305 + author-email="jaco@puxedo.org"
10306 + version="1.0-02">
10307 + <change>Changed the formatting of the XML file to fit in with new implementation</change>
10308 + <change>Commented the spec to allow others to understand it as well</change>
10310 + <changes date="Wed May 15 2002"
10311 + author="Jaco Greeff"
10312 + author-email="jaco@puxedo.org"
10313 + version="1.0-01">
10314 + <change>Converted spec file to .spec.xml file for illustrative purposes</change>
10318 Index: xmlspec/spec2xml.cpp
10319 ===================================================================
10320 RCS file: xmlspec/spec2xml.cpp
10321 diff -N xmlspec/spec2xml.cpp
10322 --- /dev/null 1 Jan 1970 00:00:00 -0000
10323 +++ rpm/xmlspec/spec2xml.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
10325 +// standard C++ includes
10326 +#include <fstream>
10329 +#include "XMLSpec.h"
10332 +#include <rpmbuild.h>
10334 +// display some usage
10337 + printf("Usage: spec2xml input [output]\n");
10338 + printf("Converts the input pkg.spec file to a pkg.spec.xml\n");
10339 + printf("file for use in an rpmbuild command.\n\n");
10343 +// program entry point
10344 +int main(int argc,
10347 + printf("\nspec2xml, version 0.01\n");
10348 + if (argc != 2 && argc != 3) {
10353 + Spec pSpec = NULL;
10354 + printf("Parsing RPM spec %s:\n", argv[1]);
10355 + if (!parseSpec(&pSpec, argv[1], "/", "/var/tmp", 0, NULL, NULL, 1, 0)) {
10356 + printf("\tOk, spec parsed.\n");
10357 + printf("Creating XML structures:\n");
10358 + XMLSpec* pXSpec = XMLSpec::structCreate(pSpec);
10360 + printf("\tOk, structures created.\n");
10362 + printf("Writing XML to %s ... ", argv[2]);
10363 + ofstream fOut(argv[2]);
10364 + if (fOut.is_open()) {
10365 + pXSpec->toXMLFile(fOut);
10371 + printf("Failed.\n");
10375 + else if (argc == 2) {
10376 + pXSpec->toXMLFile(cout);
10384 + printf("\tFailed.\n");
10387 Index: xmlspec/xml2rpm.c
10388 ===================================================================
10389 RCS file: rpm/xmlspec/xml2rpm.c,v
10390 retrieving revision 1.2.2.1
10391 retrieving revision 1.2.2.2
10392 diff -u -u -r1.2.2.1 -r1.2.2.2
10393 --- rpm/xmlspec/xml2rpm.c 28 Aug 2002 10:52:43 -0000 1.2.2.1
10394 +++ rpm/xmlspec/xml2rpm.c 10 Oct 2002 22:47:59 -0000 1.2.2.2
10396 #include "xml2rpm.h"
10397 #include "xmlstruct.h"
10400 +#include "header_internal.h"
10403 // This is where our packaged scripts start (or the largest number
10405 int g_nMaxSourceNum = 511;
10406 @@ -304,8 +308,14 @@
10407 createRPMSource(pScript->m_szScript, g_nMaxSourceNum+1,
10408 pSpec, RPMBUILD_ISSOURCE);
10410 - if (pScript->m_szEntry)
10411 - appendLineStringBuf(pSb, pScript->m_szEntry);
10412 + if (pScript->m_szEntry) {
10413 + // we do a newStrEx to make sure we expand all
10414 + // macros, as is done in the case of the files
10415 + // (done as part of the fileToStr call)
10416 + newStrEx(pScript->m_szEntry, (char**)(&szTmp));
10417 + appendLineStringBuf(pSb, szTmp);
10418 + freeStr(&(szTmp));
10420 pScript = pScript->m_pNext;
10423 @@ -335,6 +345,32 @@
10424 pScripts->m_szInterpreter, 1);
10427 +void handleProvObsConf(Header pHeader, t_structXMLRequire* pReqs, rpmsenseFlags fSense)
10429 + t_structXMLRequire* pReq = NULL;
10436 + if (pReq->m_szName) {
10438 + if (pReq->m_szCompare && pReq->m_szVersion) {
10439 + for (i = 0; sReqComp[i].m_szCmp; i++) {
10440 + if (!strcasecmp(sReqComp[i].m_szCmp,
10441 + pReq->m_szCompare)) {
10442 + nFlags = (sReqComp[i].m_rpmCmp | RPMSENSE_ANY) & ~RPMSENSE_SENSEMASK;
10446 + addReqProv(NULL, pHeader, fSense | nFlags,
10447 + pReq->m_szName, pReq->m_szVersion, nIndex++);
10449 + pReq = pReq->m_pNext;
10453 void convertXMLPackage(const t_structXMLPackage* pXMLPkg,
10454 const t_structXMLSpec* pXMLSpec,
10456 @@ -364,6 +400,11 @@
10460 + // do the provides, obsoletes, conflicts
10461 + handleProvObsConf(pPkg->header, pXMLPkg->m_pProvides, RPMSENSE_PROVIDES);
10462 + handleProvObsConf(pPkg->header, pXMLPkg->m_pObsoletes, RPMSENSE_OBSOLETES);
10463 + handleProvObsConf(pPkg->header, pXMLPkg->m_pConflicts, RPMSENSE_CONFLICTS);
10465 if (pXMLPkg->m_szName)
10466 headerAddOrAppendEntry(pPkg->header, RPMTAG_NAME,
10467 RPM_STRING_TYPE, pXMLPkg->m_szName, 1);
10468 @@ -514,7 +555,7 @@
10469 pSpec->build = scriptsToStringBuf(pXMLSpec->m_pBuild, pSpec);
10470 pSpec->install = scriptsToStringBuf(pXMLSpec->m_pInstall, pSpec);
10471 pSpec->clean = scriptsToStringBuf(pXMLSpec->m_pClean, pSpec);
10474 convertXMLPackage(pXMLSpec->m_pPackages, pXMLSpec, pSpec);
10476 initSourceHeader(pSpec);
10477 Index: xmlspec/xml2spec.cpp
10478 ===================================================================
10479 RCS file: xmlspec/xml2spec.cpp
10480 diff -N xmlspec/xml2spec.cpp
10481 --- /dev/null 1 Jan 1970 00:00:00 -0000
10482 +++ rpm/xmlspec/xml2spec.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
10484 +// standard C++ includes
10485 +#include <fstream>
10488 +#include "XMLParser.h"
10489 +#include "XMLSpec.h"
10491 +// display some usage
10494 + printf("Usage: xml2spec input [output]\n");
10495 + printf("Converts the input pkg.spec.xml file to a pkg.spec\n");
10496 + printf("file for use in an rpmbuild command.\n\n");
10500 +// program entry point
10501 +int main(int argc,
10504 + printf("\nxml2spec, version 0.01\n");
10505 + if (argc != 2 && argc != 3) {
10510 + XMLSpec* pSpec = NULL;
10511 + if (parseXMLSpec(argv[1], pSpec) == 0 && pSpec) {
10513 + printf("Writing spec to %s ... ", argv[2]);
10514 + ofstream fOut(argv[2]);
10515 + if (fOut.is_open()) {
10516 + pSpec->toSpecFile(fOut);
10522 + printf("Failed.\n");
10526 + else if (argc == 2) {
10527 + pSpec->toSpecFile(cout);
10536 Index: xmlspec/xmlparse.c
10537 ===================================================================
10538 RCS file: rpm/xmlspec/xmlparse.c,v
10539 retrieving revision 1.1.2.1
10540 retrieving revision 1.1.2.2
10541 diff -u -u -r1.1.2.1 -r1.1.2.2
10542 --- rpm/xmlspec/xmlparse.c 28 Aug 2002 10:52:43 -0000 1.1.2.1
10543 +++ rpm/xmlspec/xmlparse.c 10 Oct 2002 22:47:59 -0000 1.1.2.2
10545 addXMLMacro(pParse->m_pAttrs, &(pSpec->m_pMacros));
10547 case TAGVAL_SOURCE:
10548 - addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources));
10549 + if (pSpec->m_pSources)
10550 + addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources));
10552 + if ((addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources))) &&
10553 + (pSpec->m_pSources->m_szDirectory)) {
10554 + newStr(pSpec->m_pSources->m_szDirectory,
10555 + (char**)&(pSpec->m_szBuildSubdir));
10560 addXMLSource(pParse->m_pAttrs, &(pSpec->m_pPatches));
10561 @@ -178,6 +186,12 @@
10562 appendStringBuf(pSb, szTmp);
10563 appendStringBuf(pSb, pSource->m_szName);
10565 + else if (!strcasecmp(szTmp, "tgz")) {
10567 + newStrEx("%{_gzipbin} -dc ", &szTmp);
10568 + appendStringBuf(pSb, szTmp);
10569 + appendStringBuf(pSb, pSource->m_szName);
10571 else if (!strcasecmp(szTmp, "zip")) {
10573 newStrEx("%{_unzipbin} ", &szTmp);
10574 @@ -265,8 +279,8 @@
10575 appendStringBuf(pSb, pSource->m_szName);
10578 - szTmp = malloc(strlen(" > patch -p1234567890 -s ")+strlen(pSource->m_szName)+1);
10579 - sprintf(szTmp, " | patch -p%d -s", nLevel);
10580 + szTmp = malloc(strlen(" > patch -pN1234567890 -s ")+strlen(pSource->m_szName)+1);
10581 + sprintf(szTmp, " | patch -Np%d -s", nLevel);
10582 appendStringBuf(pSb, szTmp);
10583 appendLineStringBuf(pSb, "");
10584 appendLineStringBuf(pSb, "STATUS=$?");
10585 @@ -290,6 +304,9 @@
10586 case TAGVAL_SUMMARY:
10587 case TAGVAL_DESCRIPTION:
10588 case TAGVAL_REQUIRES:
10589 + case TAGVAL_PROVIDES:
10590 + case TAGVAL_OBSOLETES:
10591 + case TAGVAL_CONFLICTS:
10592 // we don't need to do anything
10595 @@ -315,6 +332,18 @@
10596 pPkg = getLastXMLPackage(pSpec->m_pPackages);
10597 addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pRequires));
10599 + case TAGVAL_PROVIDE:
10600 + pPkg = getLastXMLPackage(pSpec->m_pPackages);
10601 + addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pProvides));
10603 + case TAGVAL_OBSOLETE:
10604 + pPkg = getLastXMLPackage(pSpec->m_pPackages);
10605 + addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pObsoletes));
10607 + case TAGVAL_CONFLICT:
10608 + pPkg = getLastXMLPackage(pSpec->m_pPackages);
10609 + addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pConflicts));
10611 case TAGVAL_CHANGE:
10612 pChanges = getLastXMLChanges(pSpec->m_pChangelog);
10613 addXMLChange(pParse->m_pAttrs, &(pChanges->m_pChanges));
10614 @@ -544,32 +573,26 @@
10617 t_structXMLParse* pParse = NULL;
10618 + char* szVal = NULL;
10619 char* szTmp = NULL;
10620 - char* szTmpValue = NULL;
10621 - char* szPos = NULL;
10623 if ((pParse = (t_structXMLParse*)pData)) {
10624 - szTmp = malloc(nLen+2);
10625 - szTmp[nLen] = '\0';
10626 - snprintf(szTmp, nLen+1, "%s", szValue);
10628 - while ((*szPos == ' ') ||
10629 - (*szPos == '\t') ||
10630 - (*szPos == '\r') ||
10631 - (*szPos == '\n'))
10634 - if (strlen(szPos)) {
10635 + szVal = malloc(nLen+2);
10636 + szVal[nLen] = '\0';
10637 + snprintf(szVal, nLen+1, "%s", szValue);
10638 + if (strlen(szVal)) {
10639 + while ((szTmp = strchr(szVal, '\t')))
10641 if (pParse->m_szValue) {
10642 - szTmpValue = malloc(strlen(szPos)+strlen(pParse->m_szValue)+1);
10643 - sprintf(szTmpValue, "%s%s", pParse->m_szValue, szPos);
10644 - newStr(szTmpValue, &(pParse->m_szValue));
10645 - free(szTmpValue);
10646 + szTmp = malloc(strlen(szVal)+strlen(pParse->m_szValue)+1);
10647 + sprintf(szTmp, "%s%s", pParse->m_szValue, szVal);
10648 + newStr(szTmp, &(pParse->m_szValue));
10652 - newStr(szPos, &(pParse->m_szValue));
10653 + newStr(szVal, &(pParse->m_szValue));
10660 Index: xmlspec/xmlstruct.c
10661 ===================================================================
10662 RCS file: rpm/xmlspec/xmlstruct.c,v
10663 retrieving revision 1.2.2.1
10664 retrieving revision 1.2.2.2
10665 diff -u -u -r1.2.2.1 -r1.2.2.2
10666 --- rpm/xmlspec/xmlstruct.c 28 Aug 2002 10:52:43 -0000 1.2.2.1
10667 +++ rpm/xmlspec/xmlstruct.c 10 Oct 2002 22:47:59 -0000 1.2.2.2
10670 while (pAttr && (strcasecmp(szName, pAttr->m_szName) != 0))
10671 pAttr = pAttr->m_pNext;
10677 @@ -236,7 +236,7 @@
10678 attrSetInt(pAttr, "size", &(pSource->m_nSize));
10679 attrSetStr(pAttr, "md5", &(pSource->m_szMD5));
10680 attrSetStr(pAttr, "directory", &(pSource->m_szDirectory));
10681 - attrSetInt(pAttr, "number", &(pSource->m_nNum));
10682 + attrSetInt(pAttr, "id", &(pSource->m_nNum));
10683 } while ((pAttr = pAttr->m_pNext));
10686 @@ -365,6 +365,8 @@
10688 if ((pScript = malloc(sizeof(t_structXMLScript)))) {
10689 pScript->m_szInterpreter = NULL;
10690 + pScript->m_szArch = NULL;
10691 + pScript->m_szOS = NULL;
10692 pScript->m_szScript = NULL;
10693 pScript->m_szEntry = NULL;
10694 pScript->m_pNext = NULL;
10695 @@ -373,6 +375,10 @@
10697 attrSetStr(pAttr, "interpreter",
10698 &(pScript->m_szInterpreter));
10699 + attrSetStr(pAttr, "arch",
10700 + &(pScript->m_szArch));
10701 + attrSetStr(pAttr, "os",
10702 + &(pScript->m_szOS));
10703 attrSetStr(pAttr, "script",
10704 &(pScript->m_szScript));
10705 } while ((pAttr = pAttr->m_pNext));
10706 @@ -386,6 +392,8 @@
10709 freeStr(&((*ppScript)->m_szInterpreter));
10710 + freeStr(&((*ppScript)->m_szArch));
10711 + freeStr(&((*ppScript)->m_szOS));
10712 freeStr(&((*ppScript)->m_szScript));
10713 freeStr(&((*ppScript)->m_szEntry));
10714 freeXMLScript(&((*ppScript)->m_pNext));
10715 @@ -485,6 +493,59 @@
10719 +t_structI18NStr* newI18NStr(const t_structXMLAttr* pAttrs)
10721 + t_structI18NStr* pStr = NULL;
10722 + t_structXMLAttr* pAttr = NULL;
10724 + if ((pStr = malloc(sizeof(t_structI18NStr)))) {
10725 + pStr->m_szLang = NULL;
10726 + pStr->m_szText = NULL;
10727 + pStr->m_pNext = NULL;
10729 + pAttr = (t_structXMLAttr*)pAttrs;
10731 + attrSetStr(pAttr, "lang", &(pStr->m_szLang));
10732 + } while ((pAttr = pAttr->m_pNext));
10738 +int freeI18NStr(t_structI18NStr** ppStr)
10741 + freeStr(&((*ppStr)->m_szLang));
10742 + freeStr(&((*ppStr)->m_szText));
10743 + freeI18NStr(&((*ppStr)->m_pNext));
10751 +t_structI18NStr* addI18NStr(const t_structXMLAttr* pAttrs,
10752 + t_structI18NStr** ppStr)
10754 + t_structI18NStr* pStr = NULL;
10756 + if ((pStr = getLastI18NStr(*ppStr)))
10757 + pStr = (pStr->m_pNext = newI18NStr(pAttrs));
10759 + pStr = (*ppStr = newI18NStr(pAttrs));
10764 +t_structI18NStr* getLastI18NStr(t_structI18NStr* pStr)
10766 + while (pStr && (pStr->m_pNext))
10767 + pStr = pStr->m_pNext;
10772 t_structXMLPackage* newXMLPackage(const t_structXMLAttr* pAttrs)
10774 t_structXMLPackage* pPackage = NULL;
10775 @@ -492,6 +553,7 @@
10777 if ((pPackage = malloc(sizeof(t_structXMLPackage)))) {
10778 pPackage->m_szName = NULL;
10779 + pPackage->m_szVersion = NULL;
10780 pPackage->m_szGroup = NULL;
10781 pPackage->m_szSummary = NULL;
10782 pPackage->m_szDescription = NULL;
10783 @@ -507,15 +569,21 @@
10784 pPackage->m_pRequires = NULL;
10785 pPackage->m_pSuggests = NULL;
10786 pPackage->m_pObsoletes = NULL;
10787 + pPackage->m_pConflicts = NULL;
10788 pPackage->m_pProvides = NULL;
10789 pPackage->m_pNext = NULL;
10791 pAttr = (t_structXMLAttr*)pAttrs;
10793 attrSetStr(pAttr, "name", &(pPackage->m_szName));
10794 + attrSetStr(pAttr, "version", &(pPackage->m_szVersion));
10795 attrSetStr(pAttr, "group", &(pPackage->m_szGroup));
10796 attrSetBool(pAttr, "autorequire", &(pPackage->m_nAutoRequire));
10797 + attrSetBool(pAttr, "autoreq", &(pPackage->m_nAutoRequire));
10798 attrSetBool(pAttr, "autoprovide", &(pPackage->m_nAutoProvide));
10799 + attrSetBool(pAttr, "autoprov", &(pPackage->m_nAutoProvide));
10800 + attrSetBool(pAttr, "autoreqprov", &(pPackage->m_nAutoProvide));
10801 + attrSetBool(pAttr, "autoreqprov", &(pPackage->m_nAutoRequire));
10802 attrSetBool(pAttr, "autosuggest", &(pPackage->m_nAutoSuggest));
10803 } while ((pAttr = pAttr->m_pNext));
10805 @@ -527,6 +595,7 @@
10808 freeStr(&((*ppPackage)->m_szName));
10809 + freeStr(&((*ppPackage)->m_szVersion));
10810 freeStr(&((*ppPackage)->m_szGroup));
10811 freeStr(&((*ppPackage)->m_szSummary));
10812 freeStr(&((*ppPackage)->m_szDescription));
10813 @@ -539,6 +608,7 @@
10814 freeXMLRequire(&((*ppPackage)->m_pRequires));
10815 freeXMLRequire(&((*ppPackage)->m_pSuggests));
10816 freeXMLRequire(&((*ppPackage)->m_pObsoletes));
10817 + freeXMLRequire(&((*ppPackage)->m_pConflicts));
10818 freeXMLRequire(&((*ppPackage)->m_pProvides));
10819 freeXMLPackage(&((*ppPackage)->m_pNext));
10821 Index: xmlspec/xmlstruct.h
10822 ===================================================================
10823 RCS file: rpm/xmlspec/xmlstruct.h,v
10824 retrieving revision 1.1.2.1
10825 retrieving revision 1.1.2.2
10826 diff -u -u -r1.1.2.1 -r1.1.2.2
10827 --- rpm/xmlspec/xmlstruct.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
10828 +++ rpm/xmlspec/xmlstruct.h 10 Oct 2002 22:47:59 -0000 1.1.2.2
10830 typedef struct structXMLScript
10832 char* m_szInterpreter;
10837 struct structXMLScript* m_pNext;
10840 } t_structXMLFiles;
10842 +typedef struct structI18NStr
10846 + struct structI18NStr* m_pNext;
10847 +} t_structI18NStr;
10849 typedef struct structXMLPackage
10852 + char* m_szVersion;
10855 char* m_szDescription;
10857 struct structXMLRequire* m_pRequires;
10858 struct structXMLRequire* m_pSuggests;
10859 struct structXMLRequire* m_pObsoletes;
10860 + struct structXMLRequire* m_pConflicts;
10861 struct structXMLRequire* m_pProvides;
10862 struct structXMLPackage* m_pNext;
10863 } t_structXMLPackage;
10864 @@ -200,6 +211,12 @@
10866 t_structXMLFiles* newXMLFiles(const t_structXMLAttr* pAttrs);
10867 int freeXMLFiles(t_structXMLFiles** ppFiles);
10869 +t_structI18NStr* newI18NStr(const t_structXMLAttr* pAttrs);
10870 +int freeI18NStr(t_structI18NStr** ppStr);
10871 +t_structI18NStr* addI18NStr(const t_structXMLAttr* pAttrs,
10872 + t_structI18NStr** ppStr);
10873 +t_structI18NStr* getLastI18NStr(t_structI18NStr* pStr);
10875 t_structXMLPackage* newXMLPackage(const t_structXMLAttr* pAttrs);
10876 int freeXMLPackage(t_structXMLPackage** ppPackage);
10877 Index: xmlspec/xmlverify.c
10878 ===================================================================
10879 RCS file: rpm/xmlspec/xmlverify.c,v
10880 retrieving revision 1.1.2.1
10881 retrieving revision 1.1.2.2
10882 diff -u -u -r1.1.2.1 -r1.1.2.2
10883 --- rpm/xmlspec/xmlverify.c 28 Aug 2002 10:52:43 -0000 1.1.2.1
10884 +++ rpm/xmlspec/xmlverify.c 10 Oct 2002 22:47:59 -0000 1.1.2.2
10886 {"size", ATTRTYPE_NUMERIC, 0},
10887 {"md5", ATTRTYPE_MD5, 0},
10888 {"path", ATTRTYPE_ANY, 0},
10889 - {"number", ATTRTYPE_NUMERIC, 0},
10890 + {"id", ATTRTYPE_NUMERIC, 0},
10891 {NULL, ATTRTYPE_ANY, 1}
10895 {"size", ATTRTYPE_NUMERIC, 0},
10896 {"md5", ATTRTYPE_MD5, 0},
10897 {"path", ATTRTYPE_ANY, 0},
10898 - {"number", ATTRTYPE_NUMERIC, 0},
10899 + {"id", ATTRTYPE_NUMERIC, 0},
10900 {NULL, ATTRTYPE_ANY, 1}
10903 @@ -165,6 +165,7 @@
10906 {"name", ATTRTYPE_ANY, 0},
10907 + {"version", ATTRTYPE_ANY, 0},
10908 {"group", ATTRTYPE_ANY, 1},
10909 {"autoreqprov", ATTRTYPE_BOOL, 0},
10910 {"autoprov", ATTRTYPE_BOOL, 0},
10911 @@ -219,6 +220,7 @@
10914 {"name", ATTRTYPE_ANY, 1},
10915 + {"version", ATTRTYPE_ANY, 0},
10916 {NULL, ATTRTYPE_ANY, 1}
10919 @@ -243,6 +245,34 @@
10922 {"name", ATTRTYPE_ANY, 1},
10923 + {"version", ATTRTYPE_ANY, 0},
10924 + {"cmp", ATTRTYPE_CMP, 0},
10925 + {NULL, ATTRTYPE_ANY, 1}
10929 + "conflicts", TAGVAL_CONFLICTS, 2,
10936 + {NULL, ATTRTYPE_ANY, 1}
10940 + "conflict", TAGVAL_CONFLICT, 3,
10944 + TAGVAL_CONFLICTS,
10948 + {"name", ATTRTYPE_ANY, 1},
10949 + {"version", ATTRTYPE_ANY, 0},
10950 + {"cmp", ATTRTYPE_CMP, 0},
10951 {NULL, ATTRTYPE_ANY, 1}
10954 @@ -280,6 +310,7 @@
10958 + {"lang", ATTRTYPE_ANY, 0},
10959 {NULL, ATTRTYPE_ANY, 1}
10962 @@ -291,6 +322,7 @@
10966 + {"lang", ATTRTYPE_ANY, 0},
10967 {NULL, ATTRTYPE_ANY, 1}
10970 @@ -317,6 +349,8 @@
10973 {"interpreter", ATTRTYPE_ANY, 0},
10974 + {"arch", ATTRTYPE_ANY, 0},
10975 + {"os", ATTRTYPE_ANY, 0},
10976 {"script", ATTRTYPE_SCRIPT, 0},
10977 {NULL, ATTRTYPE_ANY, 1}
10979 @@ -344,6 +378,8 @@
10982 {"interpreter", ATTRTYPE_ANY, 0},
10983 + {"arch", ATTRTYPE_ANY, 0},
10984 + {"os", ATTRTYPE_ANY, 0},
10985 {"script", ATTRTYPE_SCRIPT, 0},
10986 {NULL, ATTRTYPE_ANY, 1}
10988 @@ -371,6 +407,8 @@
10991 {"interpreter", ATTRTYPE_ANY, 0},
10992 + {"arch", ATTRTYPE_ANY, 0},
10993 + {"os", ATTRTYPE_ANY, 0},
10994 {"script", ATTRTYPE_SCRIPT, 0},
10995 {NULL, ATTRTYPE_ANY, 1}
10997 @@ -398,11 +436,14 @@
11000 {"interpreter", ATTRTYPE_ANY, 0},
11001 + {"arch", ATTRTYPE_ANY, 0},
11002 + {"os", ATTRTYPE_ANY, 0},
11003 {"script", ATTRTYPE_SCRIPT, 0},
11004 {NULL, ATTRTYPE_ANY, 1}
11007 - {"verify", TAGVAL_VERIFY, 2,
11009 + "verify", TAGVAL_VERIFY, 2,
11013 @@ -424,6 +465,8 @@
11016 {"interpreter", ATTRTYPE_ANY, 0},
11017 + {"arch", ATTRTYPE_ANY, 0},
11018 + {"os", ATTRTYPE_ANY, 0},
11019 {"script", ATTRTYPE_SCRIPT, 0},
11020 {NULL, ATTRTYPE_ANY, 1}
11022 @@ -463,6 +506,8 @@
11025 {"interpreter", ATTRTYPE_ANY, 0},
11026 + {"arch", ATTRTYPE_ANY, 0},
11027 + {"os", ATTRTYPE_ANY, 0},
11028 {"script", ATTRTYPE_SCRIPT, 0},
11029 {NULL, ATTRTYPE_ANY, 1}
11031 @@ -476,6 +521,8 @@
11034 {"source", ATTRTYPE_NUMERIC, 0},
11035 + {"arch", ATTRTYPE_ANY, 0},
11036 + {"os", ATTRTYPE_ANY, 0},
11037 {"path", ATTRTYPE_ANY, 0},
11038 {NULL, ATTRTYPE_ANY, 1}
11040 @@ -489,6 +536,8 @@
11043 {"patch", ATTRTYPE_NUMERIC, 0},
11044 + {"arch", ATTRTYPE_ANY, 0},
11045 + {"os", ATTRTYPE_ANY, 0},
11046 {"level", ATTRTYPE_NUMERIC, 0},
11047 {"path", ATTRTYPE_ANY, 0},
11048 {NULL, ATTRTYPE_ANY, 1}
11049 @@ -515,6 +564,8 @@
11052 {"interpreter", ATTRTYPE_ANY, 0},
11053 + {"arch", ATTRTYPE_ANY, 0},
11054 + {"os", ATTRTYPE_ANY, 0},
11055 {"script", ATTRTYPE_SCRIPT, 0},
11056 {NULL, ATTRTYPE_ANY, 1}
11058 @@ -540,6 +591,8 @@
11061 {"interpreter", ATTRTYPE_ANY, 0},
11062 + {"arch", ATTRTYPE_ANY, 0},
11063 + {"os", ATTRTYPE_ANY, 0},
11064 {"script", ATTRTYPE_SCRIPT, 0},
11065 {NULL, ATTRTYPE_ANY, 1}
11067 @@ -565,6 +618,8 @@
11070 {"interpreter", ATTRTYPE_ANY, 0},
11071 + {"arch", ATTRTYPE_ANY, 0},
11072 + {"os", ATTRTYPE_ANY, 0},
11073 {"script", ATTRTYPE_SCRIPT, 0},
11074 {NULL, ATTRTYPE_ANY, 1}
11076 Index: xmlspec/xmlverify.h
11077 ===================================================================
11078 RCS file: rpm/xmlspec/xmlverify.h,v
11079 retrieving revision 1.1.2.1
11080 retrieving revision 1.1.2.2
11081 diff -u -u -r1.1.2.1 -r1.1.2.2
11082 --- rpm/xmlspec/xmlverify.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
11083 +++ rpm/xmlspec/xmlverify.h 10 Oct 2002 22:47:59 -0000 1.1.2.2
11088 + TAGVAL_CONFLICTS,