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 if test $withval = no ; then
58 dnl ------------------ without internal db
60 -AC_CHECK_HEADERS(db3/db.h)
61 +AC_CHECK_HEADERS(db.h)
63 dnl Check for Berkeley db3 API.
64 AC_CHECK_FUNC(db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"],
65 + AC_CHECK_LIB(db-4.1, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-4.1"],
66 + AC_CHECK_LIB(db-4.0, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-4.0"],
67 AC_CHECK_LIB(db-3.2, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-3.2"],
68 AC_CHECK_LIB(db-3.1, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-3.1"],
69 AC_CHECK_LIB(db-3.0, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-3.0"],
78 if test X"$DBLIBSRCS" = X; then
80 dnl Determine the canonical arch-vendor-os for the build machine
81 case "${build_cpu}" in
82 *86) RPMCANONARCH=i386 ;;
83 +x86_64*) RPMCANONARCH=x86_64 ;;
84 alpha*) RPMCANONARCH=alpha ;;
85 sparc*) RPMCANONARCH=sparc ;;
86 ia64*) RPMCANONARCH=ia64 ;;
87 Index: installplatform
88 ===================================================================
89 RCS file: rpm/installplatform,v
90 retrieving revision 2.34
91 retrieving revision 2.34.2.2
92 diff -u -u -r2.34 -r2.34.2.2
93 --- rpm/installplatform 30 Jul 2002 17:07:39 -0000 2.34
94 +++ rpm/installplatform 11 Oct 2002 17:23:27 -0000 2.34.2.2
96 alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;;
97 sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
98 powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6]\|$\)_ppc64\1_' ;;
99 + s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;;
104 sparc-linux) MULTILIBNO=1 ;;
105 sparcv9-linux) MULTILIBNO=1 ;;
106 sparc64-linux) ARCH_INSTALL_POST=${pkglibdir}/brp-sparc64-linux; LIB=lib64; MULTILIBNO=2 ;;
107 + s390-linux) MULTILIBNO=1 ;;
108 + s390x-linux) LIB=lib64; MULTILIBNO=2 ;;
109 + ppc-linux) MULTILIBNO=1 ;;
110 + ppc64-linux) LIB=lib64; MULTILIBNO=2 ;;
111 + i?86-linux|athlon-linux) MULTILIBNO=1 ;;
112 + x86_64-linux) LIB=lib64; MULTILIBNO=2 ;;
115 if [ -n "$MULTILIBNO" ]; then
117 ===================================================================
118 RCS file: rpm/rpmqv.c,v
119 retrieving revision 1.98
120 retrieving revision 1.98.2.2
121 diff -u -u -r1.98 -r1.98.2.2
122 --- rpm/rpmqv.c 6 Aug 2002 01:41:46 -0000 1.98
123 +++ rpm/rpmqv.c 6 Nov 2002 17:28:19 -0000 1.98.2.2
125 freeSpecVec = freeSpec;
128 +#if defined(ENABLE_NLS)
129 /* set up the correct locale */
130 (void) setlocale(LC_ALL, "" );
134 bindtextdomain(PACKAGE, LOCALEDIR);
138 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
144 + _noDirTokens = rpmExpandNumeric("%{?_noDirTokens}");
147 (void) rpmtsSetRootDir(ts, rpmcliRootDir);
149 Index: beecrypt/base64.c
150 ===================================================================
151 RCS file: rpm/beecrypt/base64.c,v
152 retrieving revision 1.20
153 retrieving revision 1.20.2.1
154 diff -u -u -r1.20 -r1.20.2.1
155 --- rpm/beecrypt/base64.c 2 Jul 2002 23:54:35 -0000 1.20
156 +++ rpm/beecrypt/base64.c 9 Oct 2002 19:05:39 -0000 1.20.2.1
160 /*@-internalglobs -modfilesys @*/
161 -char * b64encode (const void * data, int ns)
162 +char * b64encode (const void * data, size_t ns)
164 static char b64enc[] =
165 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
174 fprintf(stderr, "%7u %02x %02x %02x -> %02x %02x %02x %02x\n",
176 #define CRC24_POLY 0x1864cfbL
179 -char * b64crc (const unsigned char * data, int ns)
180 +char * b64crc (const unsigned char * data, size_t ns)
182 const unsigned char *s = data;
183 uint32 crc = CRC24_INIT;
186 /*@-internalglobs -modfilesys @*/
188 -int b64decode (const char * s, void ** datap, int *lenp)
189 +int b64decode (const char * s, void ** datap, size_t *lenp)
191 unsigned char b64dec[256];
192 const unsigned char *t;
193 Index: beecrypt/base64.h
194 ===================================================================
195 RCS file: rpm/beecrypt/base64.h,v
196 retrieving revision 1.14
197 retrieving revision 1.14.2.2
198 diff -u -u -r1.14 -r1.14.2.2
199 --- rpm/beecrypt/base64.h 13 May 2002 22:45:31 -0000 1.14
200 +++ rpm/beecrypt/base64.h 6 Nov 2002 17:28:19 -0000 1.14.2.2
202 * @return (malloc'd) base64 string
204 BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
205 -char * b64encode (const void * data, int ns)
206 +char * b64encode (const void * data, size_t ns)
210 * Encode crc of binary input data into 5 bytes of base64 output.
211 * @param data binary data
212 - * @param ns crc of data
213 + * @param ns no. bytes of binary data
214 * @return (malloc'd) base64 string
216 BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
217 -char * b64crc (const unsigned char * data, int ns)
218 +char * b64crc (const unsigned char * data, size_t ns)
223 * @return 0 on success, 1: s == NULL, 2: bad length, 3: bad char
225 BEECRYPTAPI /*@unused@*/
226 -int b64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ int *lenp)
227 +int b64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ size_t *lenp)
228 /*@modifies *datap, *lenp @*/;
232 ===================================================================
233 RCS file: rpm/db3/configure,v
234 retrieving revision 1.20
235 retrieving revision 1.20.2.1
236 diff -u -u -r1.20 -r1.20.2.1
237 --- rpm/db3/configure 30 Jul 2002 16:39:09 -0000 1.20
238 +++ rpm/db3/configure 6 Nov 2002 17:28:20 -0000 1.20.2.1
243 -# XXX hacks to get db-3.3.4 to configure properly
244 -#ln -sf ../dist $db_dist/../db/dist
245 -#ln -sf ../dist $db_dist
247 # XXX edit CFLAGS= ... out of invocation args ???
248 ARGS="`echo $* | sed -e 's% [^ ]*CFLAGS=[^ ]*%%' -e 's% -[^-][^ ]*%%g' -e 's%--cache-file=.*$%%'`"
251 --enable-shared --enable-static --enable-rpc \
252 --with-uniquename=_rpmdb --srcdir=$db_dist
254 -# XXX hack to get db-3.3.4 to configure properly
255 -#rm -f $db_dist/../db/dist $db_dist/dist
257 mv Makefile Makefile.orig
258 -cat Makefile.orig | sed -e 's/ -g$/ -g -O2/' -e '/^install:/c\
259 +cat Makefile.orig | sed -e '/^install[:-]/c\
262 @echo $(OBJS) $(C_OBJS) \
264 distdir install check:\
266 -db3_install: all install_setip' > Makefile
267 +db4_install: all install_setip' > Makefile
270 cat db.h.orig | sed \
273 -e '/^#define db_create/i\
274 /*@-declundef -noparams -fcnuse@*/' \
275 - -e '/^#define db_xa_switch/a\
276 + -e '/^int txn_commit __P((/a\
277 /*@=declundef =noparams =fcnuse =fielduse =enummemuse =typeuse @*/' > db.h
279 # Generate manifest for rpmdb.
281 ===================================================================
282 RCS file: rpm/lib/formats.c,v
283 retrieving revision 2.71.2.1
284 retrieving revision 2.71.2.2
285 diff -u -u -r2.71.2.1 -r2.71.2.2
286 --- rpm/lib/formats.c 19 Aug 2002 22:21:20 -0000 2.71.2.1
287 +++ rpm/lib/formats.c 9 Oct 2002 19:05:39 -0000 2.71.2.2
302 - int nt = ((element + 2) / 3) * 4;
303 + size_t nt = ((element + 2) / 3) * 4;
308 ===================================================================
309 RCS file: rpm/lib/package.c,v
310 retrieving revision 2.112.2.10
311 retrieving revision 2.112.2.11
312 diff -u -u -r2.112.2.10 -r2.112.2.11
313 --- rpm/lib/package.c 17 Sep 2002 15:18:23 -0000 2.112.2.10
314 +++ rpm/lib/package.c 9 Oct 2002 19:05:39 -0000 2.112.2.11
316 if (uc > 0 && pvlen != uc) {
317 (void) snprintf(buf, sizeof(buf),
318 _("blob size(%d): BAD, 8 + 16 * il(%d) + dl(%d)\n"),
320 + (int)uc, (int)il, (int)dl);
325 memset(block, 0, sizeof(block));
326 if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {
327 (void) snprintf(buf, sizeof(buf),
328 - _("hdr size(%d): BAD, read returned %d\n"), sizeof(block), xx);
329 + _("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
332 if (memcmp(block, header_magic, sizeof(header_magic))) {
334 ===================================================================
335 RCS file: rpm/lib/poptALL.c,v
336 retrieving revision 2.10.2.2
337 retrieving revision 2.10.2.3
338 diff -u -u -r2.10.2.2 -r2.10.2.3
339 --- rpm/lib/poptALL.c 27 Aug 2002 20:42:17 -0000 2.10.2.2
340 +++ rpm/lib/poptALL.c 25 Oct 2002 17:31:37 -0000 2.10.2.3
345 -#if !defined(__LCLINT__)
346 +#if defined(ENABLE_NLS)
347 (void) setlocale(LC_ALL, "" );
350 +#define LOCALEDIR "/usr/share/locale"
352 (void) bindtextdomain(PACKAGE, LOCALEDIR);
353 (void) textdomain(PACKAGE);
356 ===================================================================
357 RCS file: rpm/lib/psm.c,v
358 retrieving revision 2.126.2.7
359 retrieving revision 2.126.2.9
360 diff -u -u -r2.126.2.7 -r2.126.2.9
361 --- rpm/lib/psm.c 17 Sep 2002 15:18:23 -0000 2.126.2.7
362 +++ rpm/lib/psm.c 9 Oct 2002 19:05:39 -0000 2.126.2.9
363 @@ -695,15 +695,19 @@
364 (void) sigaddset(&caught, signum);
368 - pid_t reaped = waitpid(0, &status, WNOHANG);
372 - for (i = 0; i < psmtbl.npsms; i++) {
373 - rpmpsm psm = psmtbl.psms[i];
374 - if (psm->child != reaped)
375 - /*@innercontinue@*/ continue;
378 + pid_t reaped = waitpid(0, &status, WNOHANG);
382 + /*@innerbreak@*/ break;
385 + for (i = 0; i < psmtbl.npsms; i++) {
386 + rpmpsm psm = psmtbl.psms[i];
387 + if (psm->child != reaped)
388 + /*@innercontinue@*/ continue;
392 @@ -712,11 +716,12 @@
396 - psm->reaped = reaped;
397 - psm->status = status;
398 - /*@innerbreak@*/ break;
399 + psm->reaped = reaped;
400 + psm->status = status;
401 + /*@innerbreak@*/ break;
404 - } /*@switchbreak@*/ break;
405 + /*@switchbreak@*/ break;
407 /*@switchbreak@*/ break;
413 - * Fork a new process.
414 - * @param psm package state machine data
415 - * @return fork(2) pid
417 -static pid_t psmFork(rpmpsm psm)
418 - /*@globals fileSystem, internalState @*/
419 - /*@modifies fileSystem, internalState @*/
423 - if ((pid = fork()) != 0) {
426 -fprintf(stderr, " Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, pid);
433 * Register a child reaper, then fork a child.
434 * @param psm package state machine data
435 * @return fork(2) pid
438 empty = psmtbl.npsms++;
441 if (psmtbl.psms) /* XXX can't happen */
442 psmtbl.psms[empty] = rpmpsmLink(psm, "psmRegister");
444 @@ -844,15 +828,24 @@
447 (void) enableSignal(SIGCHLD);
450 + if ((psm->child = fork()) != 0) {
453 +fprintf(stderr, " Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
457 (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
459 - return psmFork(psm);
464 * Unregister a child reaper.
466 -static int psmUnregister(rpmpsm psm, pid_t child)
467 +static int psmWaitUnregister(rpmpsm psm, pid_t child)
468 /*@globals psmtbl, fileSystem, internalState @*/
469 /*@modifies psmtbl, fileSystem, internalState @*/
472 (void) sigfillset(&newMask); /* block all signals */
473 (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
476 + while (psm->reaped != psm->child) {
477 + (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
478 + sleep(1); /* XXX sleep guarantees loop traversal. */
479 + (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
485 +fprintf(stderr, " Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
489 for (i = 0; i < psmtbl.npsms; i++) {
490 if (psmtbl.psms[i] == NULL)
495 - * Return reaped pid safely (i.e. with signals blocked).
496 - * @param psm package state machine data
499 -static inline pid_t psmGetReaped(rpmpsm psm)
500 - /*@globals fileSystem @*/
501 - /*@modifies fileSystem @*/
503 - sigset_t newMask, oldMask;
506 - (void) sigfillset(&newMask); /* block all signals */
507 - (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
508 - reaped = psm->reaped;
509 - (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
514 * Wait for child process to be reaped.
515 * @param psm package state machine data
518 /*@modifies psm, fileSystem, internalState @*/
522 - while (psmGetReaped(psm) == 0)
527 -fprintf(stderr, " Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
529 - (void) psmUnregister(psm, psm->child);
530 + (void) psmWaitUnregister(psm, psm->child);
533 psm->reaped = waitpid(psm->child, &psm->status, 0);
537 const char *n, *v, *r;
540 if (progArgv == NULL && script == NULL)
542 @@ -1119,8 +1097,7 @@
543 if (out == NULL) return RPMRC_FAIL; /* XXX can't happen */
546 - pid = psmRegisterFork(psm);
548 + (void) psmRegisterFork(psm);
549 if (psm->child == 0) {
550 const char * rootDir;
553 ===================================================================
554 RCS file: rpm/lib/query.c,v
555 retrieving revision 2.138.2.8
556 retrieving revision 2.138.2.9
557 diff -u -u -r2.138.2.8 -r2.138.2.9
558 --- rpm/lib/query.c 17 Sep 2002 15:18:23 -0000 2.138.2.8
559 +++ rpm/lib/query.c 9 Oct 2002 19:05:39 -0000 2.138.2.9
563 if (qva->qva_flags & QUERY_FOR_DUMPFILES) {
564 - sprintf(te, "%s %d %d %s 0%o ", fn, fsize, fmtime, fmd5, fmode);
565 + sprintf(te, "%s %d %d %s 0%o ", fn, (int)fsize, fmtime, fmd5, fmode);
568 if (fuser && fgroup) {
570 ===================================================================
571 RCS file: rpm/lib/rpmcli.h,v
572 retrieving revision 2.47.2.2
573 retrieving revision 2.47.2.3
574 diff -u -u -r2.47.2.2 -r2.47.2.3
575 --- rpm/lib/rpmcli.h 17 Sep 2002 15:18:24 -0000 2.47.2.2
576 +++ rpm/lib/rpmcli.h 9 Oct 2002 19:05:39 -0000 2.47.2.3
578 * @param argv array of package file names (NULL terminated)
579 * @return 0 on success
581 -int rpmErase(rpmts ts, const struct rpmInstallArguments_s * ia,
582 +int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
583 /*@null@*/ const char ** argv)
584 /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
585 /*@modifies ts, ia, rpmGlobalMacroContext,
587 ===================================================================
588 RCS file: rpm/lib/rpmds.h,v
589 retrieving revision 2.36
590 retrieving revision 2.36.2.1
591 diff -u -u -r2.36 -r2.36.2.1
592 --- rpm/lib/rpmds.h 3 Aug 2002 22:31:39 -0000 2.36
593 +++ rpm/lib/rpmds.h 6 Nov 2002 17:28:20 -0000 2.36.2.1
596 * Set "Don't promote Epoch:" flag.
597 * @param ds dependency set
598 + * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
599 * @return previous "Don't promote Epoch:" flag
601 int rpmdsSetNoPromote(/*@null@*/ rpmds ds, int nopromote)
602 Index: lib/rpminstall.c
603 ===================================================================
604 RCS file: rpm/lib/rpminstall.c,v
605 retrieving revision 1.118.2.5
606 retrieving revision 1.118.2.6
607 diff -u -u -r1.118.2.5 -r1.118.2.6
608 --- rpm/lib/rpminstall.c 31 Aug 2002 22:30:22 -0000 1.118.2.5
609 +++ rpm/lib/rpminstall.c 9 Oct 2002 19:05:39 -0000 1.118.2.6
614 -int rpmErase(rpmts ts,
615 - const struct rpmInstallArguments_s * ia,
616 +int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
620 Index: lib/signature.c
621 ===================================================================
622 RCS file: rpm/lib/signature.c,v
623 retrieving revision 2.139.2.7
624 retrieving revision 2.139.2.8
625 diff -u -u -r2.139.2.7 -r2.139.2.8
626 --- rpm/lib/signature.c 17 Sep 2002 15:18:24 -0000 2.139.2.7
627 +++ rpm/lib/signature.c 9 Oct 2002 19:05:39 -0000 2.139.2.8
629 memset(block, 0, sizeof(block));
630 if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {
631 (void) snprintf(buf, sizeof(buf),
632 - _("sigh size(%d): BAD, read returned %d\n"), sizeof(block), xx);
633 + _("sigh size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
636 if (memcmp(block, header_magic, sizeof(header_magic))) {
638 dataStart = (unsigned char *) (pe + il);
639 if ((xx = timedRead(fd, (char *)pe, nb)) != nb) {
640 (void) snprintf(buf, sizeof(buf),
641 - _("sigh blob(%d): BAD, read returned %d\n"), nb, xx);
642 + _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx);
646 @@ -985,11 +985,11 @@
647 if (size != dig->nbytes) {
649 t = stpcpy(t, rpmSigString(res));
650 - sprintf(t, " Expected(%d) != (%d)\n", size, dig->nbytes);
651 + sprintf(t, " Expected(%d) != (%d)\n", (int)size, (int)dig->nbytes);
654 t = stpcpy(t, rpmSigString(res));
655 - sprintf(t, " (%d)", dig->nbytes);
656 + sprintf(t, " (%d)", (int)dig->nbytes);
660 Index: lib/transaction.c
661 ===================================================================
662 RCS file: rpm/lib/transaction.c,v
663 retrieving revision 1.274.2.6
664 retrieving revision 1.274.2.7
665 diff -u -u -r1.274.2.6 -r1.274.2.7
666 --- rpm/lib/transaction.c 31 Aug 2002 22:30:22 -0000 1.274.2.6
667 +++ rpm/lib/transaction.c 25 Oct 2002 17:31:38 -0000 1.274.2.7
668 @@ -1018,7 +1018,7 @@
672 -rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elments\n"), rpmtsNElements(ts));
673 +rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elements\n"), rpmtsNElements(ts));
674 ps = rpmtsProblems(ts);
675 /* The ordering doesn't matter here */
677 Index: python/_rpmdb.c
678 ===================================================================
679 RCS file: rpm/python/_rpmdb.c,v
680 retrieving revision 1.4
681 retrieving revision 1.4.2.1
682 diff -u -u -r1.4 -r1.4.2.1
683 --- rpm/python/_rpmdb.c 7 Jun 2002 13:12:34 -0000 1.4
684 +++ rpm/python/_rpmdb.c 6 Nov 2002 16:47:02 -0000 1.4.2.1
686 /* 40 = 4.0, 33 = 3.3; this will break if the second number is > 9 */
687 #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR)
689 -#define PY_BSDDB_VERSION "3.3.1"
690 +#define PY_BSDDB_VERSION "3.4.2"
692 -static char *rcs_id = "$Id$";
693 +static char *rcs_id = "$Id$";
699 case 0: /* successful, no error */ break;
703 #if INCOMPLETE_IS_WARNING
704 strcpy(errTxt, db_strerror(err));
706 errObj = DBIncompleteError;
711 case DB_KEYEMPTY: errObj = DBKeyEmptyError; break;
712 case DB_KEYEXIST: errObj = DBKeyExistError; break;
713 @@ -1023,12 +1025,29 @@
714 secondaryDB->associateCallback = callback;
715 secondaryDB->primaryDBType = _DB_get_type(self);
718 + /* PyEval_InitThreads is called here due to a quirk in python 1.5
719 + * - 2.2.1 (at least) according to Russell Williamson <merel@wt.net>:
720 + * The global interepreter lock is not initialized until the first
721 + * thread is created using thread.start_new_thread() or fork() is
722 + * called. that would cause the ALLOW_THREADS here to segfault due
723 + * to a null pointer reference if no threads or child processes
724 + * have been created. This works around that and is a no-op if
725 + * threads have already been initialized.
726 + * (see pybsddb-users mailing list post on 2002-08-07)
728 + PyEval_InitThreads();
729 MYDB_BEGIN_ALLOW_THREADS;
731 + err = self->db->associate(self->db, NULL,
733 + _db_associateCallback,
736 err = self->db->associate(self->db,
738 _db_associateCallback,
741 MYDB_END_ALLOW_THREADS;
744 @@ -1498,7 +1517,11 @@
747 MYDB_BEGIN_ALLOW_THREADS;
749 + err = self->db->open(self->db, NULL, filename, dbname, type, flags, mode);
751 err = self->db->open(self->db, filename, dbname, type, flags, mode);
753 MYDB_END_ALLOW_THREADS;
754 if (makeDBError(err)) {
756 @@ -1851,7 +1874,9 @@
757 MAKE_HASH_ENTRY(nkeys);
758 MAKE_HASH_ENTRY(ndata);
759 MAKE_HASH_ENTRY(pagesize);
761 MAKE_HASH_ENTRY(nelem);
763 MAKE_HASH_ENTRY(ffactor);
764 MAKE_HASH_ENTRY(buckets);
765 MAKE_HASH_ENTRY(free);
766 @@ -1896,7 +1921,7 @@
767 MAKE_QUEUE_ENTRY(re_len);
768 MAKE_QUEUE_ENTRY(re_pad);
769 MAKE_QUEUE_ENTRY(pgfree);
770 -#if (DBVER >= 31) && (DBVER < 40)
772 MAKE_QUEUE_ENTRY(start);
774 MAKE_QUEUE_ENTRY(first_recno);
775 @@ -2334,8 +2359,6 @@
776 if (!PyArg_ParseTuple(args, ":close"))
779 - CHECK_CURSOR_NOT_CLOSED(self);
781 if (self->dbc != NULL) {
782 MYDB_BEGIN_ALLOW_THREADS;
783 err = self->dbc->c_close(self->dbc);
784 @@ -2424,7 +2447,7 @@
786 DBC_get(DBCursorObject* self, PyObject* args, PyObject *kwargs)
790 PyObject* keyobj = NULL;
791 PyObject* dataobj = NULL;
792 PyObject* retval = NULL;
793 @@ -3309,7 +3332,7 @@
798 + u_int32_t flags = 0;
800 if (!PyArg_ParseTuple(args, "|i:lock_stat", &flags))
802 @@ -3337,7 +3360,9 @@
804 #define MAKE_ENTRY(name) _addIntToDict(d, #name, sp->st_##name)
811 MAKE_ENTRY(maxlocks);
812 @@ -3421,7 +3446,7 @@
819 if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags))
821 @@ -4116,7 +4141,9 @@
822 ADD_INT(d, DB_APPEND);
823 ADD_INT(d, DB_BEFORE);
824 ADD_INT(d, DB_CACHED_COUNTS);
826 ADD_INT(d, DB_CHECKPOINT);
829 ADD_INT(d, DB_COMMIT);
831 @@ -4124,7 +4151,9 @@
833 ADD_INT(d, DB_CONSUME_WAIT);
836 ADD_INT(d, DB_CURLSN);
838 ADD_INT(d, DB_CURRENT);
840 ADD_INT(d, DB_FAST_STAT);
841 @@ -4164,7 +4193,9 @@
842 ADD_INT(d, DB_DONOTINDEX);
846 ADD_INT(d, DB_INCOMPLETE);
848 ADD_INT(d, DB_KEYEMPTY);
849 ADD_INT(d, DB_KEYEXIST);
850 ADD_INT(d, DB_LOCK_DEADLOCK);
851 Index: python/header-py.c
852 ===================================================================
853 RCS file: rpm/python/header-py.c,v
854 retrieving revision 1.20
855 retrieving revision 1.20.2.1
856 diff -u -u -r1.20 -r1.20.2.1
857 --- rpm/python/header-py.c 7 Aug 2002 23:19:10 -0000 1.20
858 +++ rpm/python/header-py.c 15 Oct 2002 19:03:22 -0000 1.20.2.1
860 return rpmVersionCompare(a->h, b->h);
863 +static long hdr_hash(hdrObject *h)
870 /*@unchecked@*/ /*@observer@*/
872 0, /* tp_as_number */
873 0, /* tp_as_sequence */
874 &hdr_as_mapping, /* tp_as_mapping */
876 + hdr_hash, /* tp_hash */
880 Index: python/rpmdb/__init__.py
881 ===================================================================
882 RCS file: rpm/python/rpmdb/__init__.py,v
883 retrieving revision 1.2
884 retrieving revision 1.2.2.1
885 diff -u -u -r1.2 -r1.2.2.1
886 --- rpm/python/rpmdb/__init__.py 3 Jun 2002 20:44:08 -0000 1.2
887 +++ rpm/python/rpmdb/__init__.py 6 Nov 2002 16:47:02 -0000 1.2.2.1
889 flags = _checkflag(flag)
892 - if cachesize is not None: d.set_cachesize(cachesize)
893 + if cachesize is not None: d.set_cachesize(0, cachesize)
894 if pgsize is not None: d.set_pagesize(pgsize)
895 if lorder is not None: d.set_lorder(lorder)
896 if ffactor is not None: d.set_h_ffactor(ffactor)
899 flags = _checkflag(flag)
901 - if cachesize is not None: d.set_cachesize(cachesize)
902 + if cachesize is not None: d.set_cachesize(0, cachesize)
903 if pgsize is not None: d.set_pagesize(pgsize)
904 if lorder is not None: d.set_lorder(lorder)
908 flags = _checkflag(flag)
910 - if cachesize is not None: d.set_cachesize(cachesize)
911 + if cachesize is not None: d.set_cachesize(0, cachesize)
912 if pgsize is not None: d.set_pagesize(pgsize)
913 if lorder is not None: d.set_lorder(lorder)
915 Index: python/rpmdb/dbshelve.py
916 ===================================================================
917 RCS file: rpm/python/rpmdb/dbshelve.py,v
918 retrieving revision 1.2
919 retrieving revision 1.2.2.1
920 diff -u -u -r1.2 -r1.2.2.1
921 --- rpm/python/rpmdb/dbshelve.py 5 Jun 2002 20:28:03 -0000 1.2
922 +++ rpm/python/rpmdb/dbshelve.py 6 Nov 2002 16:47:02 -0000 1.2.2.1
924 if type(flags) == type(''):
927 - flags = db.DB_READONLY
928 + flags = db.DB_RDONLY
932 Index: python/rpmdb/dbtables.py
933 ===================================================================
934 RCS file: rpm/python/rpmdb/dbtables.py,v
935 retrieving revision 1.1
936 retrieving revision 1.1.2.1
937 diff -u -u -r1.1 -r1.1.2.1
938 --- rpm/python/rpmdb/dbtables.py 3 Jun 2002 20:44:08 -0000 1.1
939 +++ rpm/python/rpmdb/dbtables.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
941 #-----------------------------------------------------------------------
943 # Copyright (C) 2000, 2001 by Autonomous Zone Industries
944 +# Copyright (C) 2002 Gregory P. Smith
946 # License: This is free software. You may use this software for any
947 # purpose including modification/redistribution, so long as
949 def __call__(self, s):
950 return s[:len(self.prefix)] == self.prefix
952 +class PostfixCond(Cond):
953 + """Acts as a condition function for matching a string postfix"""
954 + def __init__(self, postfix):
955 + self.postfix = postfix
956 + def __call__(self, s):
957 + return s[-len(self.postfix):] == self.postfix
959 class LikeCond(Cond):
961 Acts as a function that will match using an SQL 'LIKE' style
962 @@ -523,17 +531,10 @@
963 # if no condition was specified or the condition
964 # succeeds, add row to our match list.
965 if not condition or condition(data) :
966 - # only create new entries in matcing_rowids on
967 - # the first pass, otherwise reject the
968 - # rowid as it must not have matched
969 - # the previous passes
970 - if column_num == 0 :
971 - if not matching_rowids.has_key(rowid) :
972 - matching_rowids[rowid] = {}
973 - if savethiscolumndata :
974 - matching_rowids[rowid][column] = data
976 - rejected_rowids[rowid] = rowid
977 + if not matching_rowids.has_key(rowid) :
978 + matching_rowids[rowid] = {}
979 + if savethiscolumndata :
980 + matching_rowids[rowid][column] = data
982 if matching_rowids.has_key(rowid) :
983 del matching_rowids[rowid]
984 Index: python/rpmdb/dbutils.py
985 ===================================================================
986 RCS file: rpm/python/rpmdb/dbutils.py,v
987 retrieving revision 1.1
988 retrieving revision 1.1.2.1
989 diff -u -u -r1.1 -r1.1.2.1
990 --- rpm/python/rpmdb/dbutils.py 3 Jun 2002 20:44:08 -0000 1.1
991 +++ rpm/python/rpmdb/dbutils.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
993 #------------------------------------------------------------------------
995 -# In my performance tests, using this (as in dbtest.py test4) is
996 -# slightly slower than simply compiling _db.c with MYDB_THREAD
997 -# undefined to prevent multithreading support in the C module.
998 -# Using NoDeadlockDb also prevent deadlocks from mutliple processes
999 -# accessing the same database.
1001 # Copyright (C) 2000 Autonomous Zone Industries
1003 # License: This is free software. You may use this software for any
1005 # Author: Gregory P. Smith <greg@electricrain.com>
1007 # Note: I don't know how useful this is in reality since when a
1008 -# DBDeadlockError happens the current transaction is supposed to be
1009 +# DBLockDeadlockError happens the current transaction is supposed to be
1010 # aborted. If it doesn't then when the operation is attempted again
1011 # the deadlock is still happening...
1015 import _rpmdb as _db
1017 -_deadlock_MinSleepTime = 1.0/64 # always sleep at least N seconds between retrys
1018 -_deadlock_MaxSleepTime = 1.0 # never sleep more than N seconds between retrys
1019 +_deadlock_MinSleepTime = 1.0/64 # always sleep at least N seconds between retrys
1020 +_deadlock_MaxSleepTime = 3.14159 # never sleep more than N seconds between retrys
1022 +_deadlock_VerboseFile = None # Assign a file object to this for a "sleeping"
1023 + # message to be written to it each retry
1025 def DeadlockWrap(function, *_args, **_kwargs):
1026 """DeadlockWrap(function, *_args, **_kwargs) - automatically retries
1027 function in case of a database deadlock.
1029 - This is a DeadlockWrapper method which DB calls can be made using to
1030 - preform infinite retrys with sleeps in between when a DBLockDeadlockError
1031 - exception is raised in a database call:
1032 + This is a function intended to be used to wrap database calls such
1033 + that they perform retrys with exponentially backing off sleeps in
1034 + between when a DBLockDeadlockError exception is raised.
1036 + A 'max_retries' parameter may optionally be passed to prevent it
1037 + from retrying forever (in which case the exception will be reraised).
1041 DeadlockWrap(d.put, "foo", data="bar") # set key "foo" to "bar"
1043 sleeptime = _deadlock_MinSleepTime
1045 + max_retries = _kwargs.get('max_retries', -1)
1046 + if _kwargs.has_key('max_retries'):
1047 + del _kwargs['max_retries']
1050 return apply(function, _args, _kwargs)
1051 except _db.DBLockDeadlockError:
1052 - print 'DeadlockWrap sleeping ', sleeptime
1053 + if _deadlock_VerboseFile:
1054 + _deadlock_VerboseFile.write('dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
1056 # exponential backoff in the sleep time
1057 sleeptime = sleeptime * 2
1058 if sleeptime > _deadlock_MaxSleepTime :
1059 sleeptime = _deadlock_MaxSleepTime
1060 + max_retries = max_retries - 1
1061 + if max_retries == -1:
1065 #------------------------------------------------------------------------
1066 Index: python/test/test_dbshelve.py
1067 ===================================================================
1068 RCS file: rpm/python/test/test_dbshelve.py,v
1069 retrieving revision 1.1
1070 retrieving revision 1.1.2.1
1071 diff -u -u -r1.1 -r1.1.2.1
1072 --- rpm/python/test/test_dbshelve.py 3 Jun 2002 20:44:08 -0000 1.1
1073 +++ rpm/python/test/test_dbshelve.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
1077 class HashShelveTestCase(BasicShelveTestCase):
1078 - dbtype = db.DB_BTREE
1079 + dbtype = db.DB_HASH
1080 dbflags = db.DB_CREATE
1086 class ThreadHashShelveTestCase(BasicShelveTestCase):
1087 - dbtype = db.DB_BTREE
1088 + dbtype = db.DB_HASH
1089 dbflags = db.DB_CREATE | db.DB_THREAD
1094 class EnvHashShelveTestCase(BasicEnvShelveTestCase):
1096 - dbtype = db.DB_BTREE
1097 + dbtype = db.DB_HASH
1098 dbflags = db.DB_CREATE
1103 class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase):
1104 envflags = db.DB_THREAD
1105 - dbtype = db.DB_BTREE
1106 + dbtype = db.DB_HASH
1107 dbflags = db.DB_CREATE | db.DB_THREAD
1110 Index: python/test/test_dbtables.py
1111 ===================================================================
1112 RCS file: rpm/python/test/test_dbtables.py,v
1113 retrieving revision 1.1
1114 retrieving revision 1.1.2.1
1115 diff -u -u -r1.1 -r1.1.2.1
1116 --- rpm/python/test/test_dbtables.py 3 Jun 2002 20:44:08 -0000 1.1
1117 +++ rpm/python/test/test_dbtables.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
1119 #-----------------------------------------------------------------------
1121 # Copyright (C) 2000, 2001 by Autonomous Zone Industries
1122 +# Copyright (C) 2002 Gregory P. Smith
1126 @@ -157,6 +158,40 @@
1127 conditions={'c': lambda c: c == 'meep'})
1128 assert len(values) == 1
1129 assert values[0]['b'] == "bad"
1132 + def test04_MultiCondSelect(self):
1133 + tabname = "test04_MultiCondSelect"
1135 + self.tdb.Drop(tabname)
1136 + except dbtables.TableDBError:
1138 + self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
1141 + self.tdb.Insert(tabname, {'a': "", 'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1), 'f': "Zero"})
1143 + except dbtables.TableDBError:
1146 + self.tdb.Insert(tabname, {'a': "A", 'b': "B", 'c': "C", 'd': "D", 'e': "E"})
1147 + self.tdb.Insert(tabname, {'a': "-A", 'b': "-B", 'c': "-C", 'd': "-D", 'e': "-E"})
1148 + self.tdb.Insert(tabname, {'a': "A-", 'b': "B-", 'c': "C-", 'd': "D-", 'e': "E-"})
1151 + self.tdb._db_print()
1153 + # This select should return 0 rows. it is designed to test
1154 + # the bug identified and fixed in sourceforge bug # 590449
1155 + # (Big Thanks to "Rob Tillotson (n9mtb)" for tracking this down
1156 + # and supplying a fix!! This one caused many headaches to say
1158 + values = self.tdb.Select(tabname, ['b', 'a', 'd'],
1159 + conditions={'e': dbtables.ExactCond('E'),
1160 + 'a': dbtables.ExactCond('A'),
1161 + 'd': dbtables.PrefixCond('-')
1163 + assert len(values) == 0, values
1166 def test_CreateOrExtend(self):
1167 Index: python/test/test_thread.py
1168 ===================================================================
1169 RCS file: rpm/python/test/test_thread.py,v
1170 retrieving revision 1.1
1171 retrieving revision 1.1.2.1
1172 diff -u -u -r1.1 -r1.1.2.1
1173 --- rpm/python/test/test_thread.py 3 Jun 2002 20:44:08 -0000 1.1
1174 +++ rpm/python/test/test_thread.py 6 Nov 2002 16:47:02 -0000 1.1.2.1
1177 from test_all import verbose
1179 -from rpmdb import db
1180 +from rpmdb import db, dbutils
1183 #----------------------------------------------------------------------
1189 + dbutils._deadlock_VerboseFile = sys.stdout
1191 homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
1192 self.homeDir = homeDir
1193 try: os.mkdir(homeDir)
1196 for x in range(start, stop):
1198 - d.put(key, self.makeData(key))
1199 + dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
1200 if verbose and x % 100 == 0:
1201 print "%s: records %d - %d finished" % (name, start, x)
1204 # create a bunch of records
1205 for x in xrange(start, stop):
1207 - d.put(key, self.makeData(key))
1208 + dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
1210 if verbose and x % 100 == 0:
1211 print "%s: records %d - %d finished" % (name, start, x)
1212 @@ -221,12 +224,12 @@
1213 if random() <= 0.05:
1214 for y in xrange(start, x):
1217 + data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
1218 assert data == self.makeData(key)
1223 + dbutils.DeadlockWrap(d.sync, max_retries=12)
1224 except db.DBIncompleteError, val:
1226 print "could not complete sync()..."
1227 @@ -234,12 +237,12 @@
1228 # read them back, deleting a few
1229 for x in xrange(start, stop):
1232 + data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
1233 if verbose and x % 100 == 0:
1234 print "%s: fetched record (%s, %s)" % (name, key, data)
1235 - assert data == self.makeData(key)
1236 + assert data == self.makeData(key), (key, data, self.makeData(key))
1237 if random() <= 0.10:
1239 + dbutils.DeadlockWrap(d.delete, key, max_retries=12)
1241 print "%s: deleted record %s" % (name, key)
1246 class HashSimpleThreaded(SimpleThreadedBase):
1247 - dbtype = db.DB_BTREE
1248 + dbtype = db.DB_HASH
1251 #----------------------------------------------------------------------
1253 ===================================================================
1254 RCS file: rpm/rpmdb/db3.c,v
1255 retrieving revision 1.45
1256 retrieving revision 1.45.2.1
1257 diff -u -u -r1.45 -r1.45.2.1
1258 --- rpm/rpmdb/db3.c 13 Aug 2002 20:42:39 -0000 1.45
1259 +++ rpm/rpmdb/db3.c 6 Nov 2002 17:29:34 -0000 1.45.2.1
1260 @@ -266,11 +266,22 @@
1263 /*@-noeffectuncon@*/ /* FIX: annotate db3 methods */
1265 + /* 4.1: dbenv->set_app_dispatch(???) */
1266 + /* 4.1: dbenv->set_alloc(???) */
1267 + /* 4.1: dbenv->set_data_dir(???) */
1268 + /* 4.1: dbenv->set_encrypt(???) */
1270 dbenv->set_errcall(dbenv, rpmdb->db_errcall);
1271 dbenv->set_errfile(dbenv, rpmdb->db_errfile);
1272 dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
1273 /*@=noeffectuncon@*/
1275 + /* 4.1: dbenv->set_feedback(???) */
1276 + /* 4.1: dbenv->set_flags(???) */
1278 /* dbenv->set_paniccall(???) */
1280 xx = dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
1281 (dbi->dbi_verbose & DB_VERB_CHKPOINT));
1282 xx = dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
1283 @@ -279,16 +290,35 @@
1284 (dbi->dbi_verbose & DB_VERB_RECOVERY));
1285 xx = dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
1286 (dbi->dbi_verbose & DB_VERB_WAITSFOR));
1287 - /* dbenv->set_lg_max(???) */
1289 /* dbenv->set_lk_conflicts(???) */
1290 /* dbenv->set_lk_detect(???) */
1291 - /* dbenv->set_lk_max(???) */
1292 - xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mp_mmapsize);
1293 - xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
1294 - xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_mp_size, 0);
1295 - xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
1296 + /* 4.1: dbenv->set_lk_max_lockers(???) */
1297 + /* 4.1: dbenv->set_lk_max_locks(???) */
1298 + /* 4.1: dbenv->set_lk_max_objects(???) */
1300 + /* 4.1: dbenv->set_lg_bsize(???) */
1301 + /* 4.1: dbenv->set_lg_dir(???) */
1302 + /* 4.1: dbenv->set_lg_max(???) */
1303 + /* 4.1: dbenv->set_lg_regionmax(???) */
1305 + if (dbi->dbi_mmapsize) {
1306 + xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mmapsize);
1307 + xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
1309 + if (dbi->dbi_cachesize) {
1310 + xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_cachesize, 0);
1311 + xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
1314 + /* 4.1 dbenv->set_timeout(???) */
1315 /* dbenv->set_tx_max(???) */
1316 + /* 4.1: dbenv->set_tx_timestamp(???) */
1317 /* dbenv->set_tx_recover(???) */
1319 + /* dbenv->set_rep_transport(???) */
1320 + /* dbenv->set_rep_limit(???) */
1322 if (dbi->dbi_no_fsync) {
1323 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0) || (DB_VERSION_MAJOR == 4)
1324 xx = db_env_set_func_fsync(db3_fsync_disable);
1325 @@ -366,7 +396,11 @@
1327 rc = db->sync(db, flags);
1328 /* XXX DB_INCOMPLETE is returned occaisionally with multiple access. */
1329 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1330 + _printit = _debug;
1332 _printit = (rc == DB_INCOMPLETE ? 0 : _debug);
1334 rc = cvtdberr(dbi, "db->sync", rc, _printit);
1337 @@ -599,10 +633,17 @@
1339 DB * db = dbi->dbi_db;
1340 DB * secondary = dbisecondary->dbi_db;
1341 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1342 + DB_TXN * txnid = NULL;
1346 /*@-moduncon@*/ /* FIX: annotate db3 methods */
1347 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1348 + rc = db->associate(db, txnid, secondary, callback, flags);
1350 rc = db->associate(db, secondary, callback, flags);
1353 rc = cvtdberr(dbi, "db->associate", rc, _debug);
1358 DB_ENV * dbenv = NULL;
1359 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1360 + DB_TXN * txnid = NULL;
1365 @@ -981,18 +1025,7 @@
1367 rc = cvtdberr(dbi, "db_create", rc, _debug);
1368 if (rc == 0 && db != NULL) {
1369 - if (rc == 0 && dbi->dbi_lorder) {
1370 - rc = db->set_lorder(db, dbi->dbi_lorder);
1371 - rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
1373 - if (rc == 0 && dbi->dbi_cachesize) {
1374 - rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
1375 - rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
1377 - if (rc == 0 && dbi->dbi_pagesize) {
1378 - rc = db->set_pagesize(db, dbi->dbi_pagesize);
1379 - rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
1382 /* XXX 3.3.4 change. */
1383 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3) || (DB_VERSION_MAJOR == 4)
1385 @@ -1008,6 +1041,27 @@
1386 rc = cvtdberr(dbi, "db->set_malloc", rc, _debug);
1390 +/* 4.1: db->set_cache_priority(???) */
1391 + if (rc == 0 && !dbi->dbi_use_dbenv && dbi->dbi_cachesize) {
1392 + rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
1393 + rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
1395 +/* 4.1: db->set_encrypt(???) */
1396 +/* 4.1: db->set_errcall(dbenv, rpmdb->db_errcall); */
1397 +/* 4.1: db->set_errfile(dbenv, rpmdb->db_errfile); */
1398 +/* 4.1: db->set_errpfx(dbenv, rpmdb->db_errpfx); */
1399 + /* 4.1: db->set_feedback(???) */
1401 + if (rc == 0 && dbi->dbi_lorder) {
1402 + rc = db->set_lorder(db, dbi->dbi_lorder);
1403 + rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
1405 + if (rc == 0 && dbi->dbi_pagesize) {
1406 + rc = db->set_pagesize(db, dbi->dbi_pagesize);
1407 + rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
1409 + /* 4.1: db->set_paniccall(???) */
1410 if (rc == 0 && oflags & DB_CREATE) {
1411 switch(dbi->dbi_type) {
1413 @@ -1042,6 +1096,7 @@
1417 +/* 4.1: db->set_append_recno(???) */
1418 if (dbi->dbi_bt_flags) {
1419 rc = db->set_flags(db, dbi->dbi_bt_flags);
1420 rc = cvtdberr(dbi, "db->set_bt_flags", rc, _debug);
1421 @@ -1073,6 +1128,7 @@
1424 if (dbi->dbi_re_delim) {
1425 +/* 4.1: db->set_append_recno(???) */
1426 rc = db->set_re_delim(db, dbi->dbi_re_delim);
1427 rc = cvtdberr(dbi, "db->set_re_selim", rc, _debug);
1429 @@ -1124,8 +1180,13 @@
1430 ? dbfullpath : dbfile;
1433 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1434 + rc = db->open(db, txnid, dbpath, dbsubfile,
1435 + dbi->dbi_type, oflags, dbi->dbi_perms);
1437 rc = db->open(db, dbpath, dbsubfile,
1438 dbi->dbi_type, oflags, dbi->dbi_perms);
1441 if (rc == 0 && dbi->dbi_type == DB_UNKNOWN) {
1442 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3 && DB_VERSION_PATCH == 11) \
1443 Index: rpmdb/dbconfig.c
1444 ===================================================================
1445 RCS file: rpm/rpmdb/dbconfig.c,v
1446 retrieving revision 1.33
1447 retrieving revision 1.33.2.1
1448 diff -u -u -r1.33 -r1.33.2.1
1449 --- rpm/rpmdb/dbconfig.c 3 Aug 2002 22:31:39 -0000 1.33
1450 +++ rpm/rpmdb/dbconfig.c 6 Nov 2002 17:29:34 -0000 1.33.2.1
1451 @@ -190,9 +190,11 @@
1452 { "lorder", 0,POPT_ARG_INT, &db3dbi.dbi_lorder, 0,
1455 - { "mp_mmapsize", 0,POPT_ARG_INT, &db3dbi.dbi_mp_mmapsize, 0,
1456 + { "mmapsize", 0,POPT_ARG_INT, &db3dbi.dbi_mmapsize, 0,
1458 - { "mp_size", 0,POPT_ARG_INT, &db3dbi.dbi_mp_size, 0,
1459 + { "mp_mmapsize", 0,POPT_ARG_INT, &db3dbi.dbi_mmapsize, 0,
1461 + { "mp_size", 0,POPT_ARG_INT, &db3dbi.dbi_cachesize, 0,
1463 { "pagesize", 0,POPT_ARG_INT, &db3dbi.dbi_pagesize, 0,
1466 /** @todo Set a reasonable "last gasp" default db config. */
1467 /*@observer@*/ /*@unchecked@*/
1468 static const char *db3_config_default =
1469 - "db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:mp_size=512Kb:pagesize=512:perms=0644";
1470 + "db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:cachesize=512Kb:pagesize=512:perms=0644";
1473 dbiIndex db3New(rpmdb rpmdb, rpmTag rpmtag)
1475 if (!dbi->dbi_use_dbenv) { /* db3 dbenv is always used now. */
1476 dbi->dbi_use_dbenv = 1;
1477 dbi->dbi_eflags |= (DB_INIT_MPOOL|DB_JOINENV);
1478 - dbi->dbi_mp_mmapsize = 16 * 1024 * 1024;
1479 - dbi->dbi_mp_size = 1 * 1024 * 1024;
1480 + dbi->dbi_mmapsize = 16 * 1024 * 1024;
1481 + dbi->dbi_cachesize = 1 * 1024 * 1024;
1484 if ((dbi->dbi_bt_flags | dbi->dbi_h_flags) & DB_DUP)
1485 Index: rpmdb/header.c
1486 ===================================================================
1487 RCS file: rpm/rpmdb/header.c,v
1488 retrieving revision 1.17.2.11
1489 retrieving revision 1.17.2.12
1490 diff -u -u -r1.17.2.11 -r1.17.2.12
1491 --- rpm/rpmdb/header.c 17 Sep 2002 15:19:45 -0000 1.17.2.11
1492 +++ rpm/rpmdb/header.c 6 Nov 2002 17:29:34 -0000 1.17.2.12
1493 @@ -2825,6 +2825,7 @@
1499 case RPM_STRING_ARRAY_TYPE:
1500 strarray = (const char **)data;
1501 Index: rpmdb/header.h
1502 ===================================================================
1503 RCS file: rpm/rpmdb/header.h,v
1504 retrieving revision 1.6
1505 retrieving revision 1.6.2.1
1506 diff -u -u -r1.6 -r1.6.2.1
1507 --- rpm/rpmdb/header.h 13 Jul 2002 19:10:02 -0000 1.6
1508 +++ rpm/rpmdb/header.h 6 Nov 2002 17:29:34 -0000 1.6.2.1
1510 /* RPM - Copyright (C) 1995-2001 Red Hat Software */
1521 #if !defined(__HEADER_PROTOTYPES__)
1522 -#include <hdrinline.h>
1523 +#include "hdrinline.h"
1527 Index: rpmdb/rpmdb.h
1528 ===================================================================
1529 RCS file: rpm/rpmdb/rpmdb.h,v
1530 retrieving revision 1.46.2.2
1531 retrieving revision 1.46.2.3
1532 diff -u -u -r1.46.2.2 -r1.46.2.3
1533 --- rpm/rpmdb/rpmdb.h 17 Sep 2002 15:19:46 -0000 1.46.2.2
1534 +++ rpm/rpmdb/rpmdb.h 6 Nov 2002 17:29:34 -0000 1.46.2.3
1539 -#include <rpmlib.h>
1541 +#include "rpmlib.h"
1547 int dbi_region_init;
1549 /* mpool sub-system parameters */
1550 - int dbi_mp_mmapsize; /*!< (10Mb) */
1551 - int dbi_mp_size; /*!< (128Kb) */
1552 + int dbi_mmapsize; /*!< (10Mb) */
1553 + int dbi_cachesize; /*!< (128Kb) */
1554 /* lock sub-system parameters */
1555 unsigned int dbi_lk_max;
1556 unsigned int dbi_lk_detect;
1558 /*@modifies fileSystem @*/;
1560 /* dbinfo parameters */
1561 - int dbi_cachesize; /*!< */
1562 int dbi_pagesize; /*!< (fs blksize) */
1563 /*@unused@*/ /*@null@*/
1564 void * (*dbi_malloc) (size_t nbytes)
1565 Index: rpmio/rpmlog.c
1566 ===================================================================
1567 RCS file: rpm/rpmio/rpmlog.c,v
1568 retrieving revision 2.27
1569 retrieving revision 2.27.2.1
1570 diff -u -u -r2.27 -r2.27.2.1
1571 --- rpm/rpmio/rpmlog.c 2 Jul 2002 23:54:38 -0000 2.27
1572 +++ rpm/rpmio/rpmlog.c 20 Sep 2002 16:33:49 -0000 2.27.2.1
1574 else /* glibc 2.0 */
1576 msgbuf = xrealloc(msgbuf, msgnb);
1579 msgbuf[msgnb - 1] = '\0';
1581 Index: rpmio/rpmrpc.c
1582 ===================================================================
1583 RCS file: rpm/rpmio/rpmrpc.c,v
1584 retrieving revision 2.27.2.2
1585 retrieving revision 2.27.2.3
1586 diff -u -u -r2.27.2.2 -r2.27.2.3
1587 --- rpm/rpmio/rpmrpc.c 17 Sep 2002 15:19:46 -0000 2.27.2.2
1588 +++ rpm/rpmio/rpmrpc.c 9 Oct 2002 19:06:24 -0000 2.27.2.3
1589 @@ -1023,7 +1023,7 @@
1590 (unsigned)st->st_dev,
1591 (unsigned)st->st_ino,
1594 + (unsigned)st->st_nlink,
1597 (unsigned)st->st_rdev,
1598 Index: tools/sections.c
1599 ===================================================================
1600 RCS file: rpm/tools/sections.c,v
1601 retrieving revision 1.1.2.2
1602 retrieving revision 1.1.2.4
1603 diff -u -u -r1.1.2.2 -r1.1.2.4
1604 --- rpm/tools/sections.c 22 Aug 2002 19:19:47 -0000 1.1.2.2
1605 +++ rpm/tools/sections.c 9 Oct 2002 19:06:24 -0000 1.1.2.4
1606 @@ -24,38 +24,168 @@
1610 - Elf32_Off orig_e_shoff;
1611 - Elf32_Off n_sections;
1612 + Elf64_Off orig_e_shoff;
1613 + Elf64_Off n_sections;
1614 UnstripInfoSection64 sections[1];
1618 +elf_32_to_file (uint32_t x, int file_is_little_endian)
1620 + volatile uint32_t out;
1621 + unsigned char *outbytes;
1623 + outbytes = (unsigned char *)&out;
1624 + if (file_is_little_endian)
1626 + outbytes[0] = (x >> 0) & 0xff;
1627 + outbytes[1] = (x >> 8) & 0xff;
1628 + outbytes[2] = (x >> 16) & 0xff;
1629 + outbytes[3] = (x >> 24) & 0xff;
1631 + else /* big endian */
1633 + outbytes[0] = (x >> 24) & 0xff;
1634 + outbytes[1] = (x >> 16) & 0xff;
1635 + outbytes[2] = (x >> 8) & 0xff;
1636 + outbytes[3] = (x >> 0) & 0xff;
1643 +elf_64_to_file (uint64_t x, int file_is_little_endian)
1645 + volatile uint64_t out;
1646 + unsigned char *outbytes;
1649 + outbytes = (unsigned char *)&out;
1650 + if (file_is_little_endian)
1652 + for (i = 0; i < 8; i++)
1653 + outbytes[i] = (x >> (8*i)) & 0xff;
1655 + else /* big endian */
1657 + for (i = 0; i < 8; i++)
1658 + outbytes[7-i] = (x >> (8*i)) & 0xff;
1665 word32_to_file (Elf32_Word x, Elf *elf)
1667 - /* FIXME: implement */
1669 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1670 + return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1674 off32_to_file (Elf32_Off x, Elf *elf)
1676 - /* FIXME: implement */
1678 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1679 + return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1683 +word64_to_file (Elf64_Word x, Elf *elf)
1685 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1686 + return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1690 +off64_to_file (Elf64_Off x, Elf *elf)
1692 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1693 + return elf_64_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1697 +elf_32_from_file (uint32_t x, int file_is_little_endian)
1699 + unsigned char *inbytes;
1701 + inbytes = (unsigned char *)&x;
1702 + if (file_is_little_endian)
1705 + (inbytes[0] << 0) |
1706 + (inbytes[1] << 8) |
1707 + (inbytes[2] << 16) |
1708 + (inbytes[3] << 24);
1710 + else /* big endian */
1713 + (inbytes[0] << 24) |
1714 + (inbytes[1] << 16) |
1715 + (inbytes[2] << 8) |
1716 + (inbytes[3] << 0);
1721 +elf_64_from_file (uint64_t x, int file_is_little_endian)
1723 + unsigned char *inbytes;
1725 + inbytes = (unsigned char *)&x;
1726 + if (file_is_little_endian)
1729 + ((uint64_t)inbytes[0] << 0) |
1730 + ((uint64_t)inbytes[1] << 8) |
1731 + ((uint64_t)inbytes[2] << 16) |
1732 + ((uint64_t)inbytes[3] << 24) |
1733 + ((uint64_t)inbytes[4] << 32) |
1734 + ((uint64_t)inbytes[5] << 40) |
1735 + ((uint64_t)inbytes[6] << 48) |
1736 + ((uint64_t)inbytes[7] << 56);
1738 + else /* big endian */
1741 + ((uint64_t)inbytes[0] << 56) |
1742 + ((uint64_t)inbytes[1] << 48) |
1743 + ((uint64_t)inbytes[2] << 40) |
1744 + ((uint64_t)inbytes[3] << 32) |
1745 + ((uint64_t)inbytes[4] << 24) |
1746 + ((uint64_t)inbytes[5] << 16) |
1747 + ((uint64_t)inbytes[6] << 8) |
1748 + ((uint64_t)inbytes[7] << 0);
1753 word32_from_file (Elf32_Word x, Elf *elf)
1755 - /* FIXME: implement */
1757 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1758 + return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1762 off32_from_file (Elf32_Off x, Elf *elf)
1764 - /* FIXME: implement */
1766 + Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1767 + return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1771 +word64_from_file (Elf64_Word x, Elf *elf)
1773 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1774 + return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1778 +off64_from_file (Elf64_Off x, Elf *elf)
1780 + Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1781 + return elf_64_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1789 + UnstripInfo64 *info64;
1795 + /* orig_e_shoff */ sizeof (Elf64_Off) +
1796 + /* n_sections */ sizeof (Elf64_Off) +
1797 + /* sections */ info->n_sections * sizeof (UnstripInfoSection64);
1799 + data->d_buf = calloc (1, data->d_size);
1801 + info64 = (UnstripInfo64 *) data->d_buf;
1803 + info64->orig_e_shoff = off64_to_file (info->orig_e_shoff, elf);
1804 + info64->n_sections = off64_to_file (info->n_sections, elf);
1806 + for (i = 0; i < info->n_sections; i++)
1808 + info64->sections[i].debug_section = word64_to_file (info->sections[i].debug_section, elf);
1809 + info64->sections[i].name = word64_to_file (info->sections[i].name, elf);
1810 + info64->sections[i].orig_offset = off64_to_file (info->sections[i].orig_offset, elf);
1815 @@ -101,14 +253,21 @@
1821 data->d_type = ELF_T_BYTE;
1824 - /* FIXME: use right version */
1825 - unstrip_info_to_data32 (info, elf, data);
1826 + gelf_getehdr (elf, &ehdr);
1827 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1828 + unstrip_info_to_data32 (info, elf, data);
1829 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1830 + unstrip_info_to_data64 (info, elf, data);
1832 + fprintf (stderr, "Warning. unsupported elf class\n");
1837 unstrip_info_from_data32 (UnstripInfo *info,
1840 @@ -130,23 +289,49 @@
1845 +unstrip_info_from_data64 (UnstripInfo *info,
1849 + UnstripInfo64 *info64;
1852 + info64 = (UnstripInfo64 *) data->d_buf;
1854 + info->orig_e_shoff = off64_from_file (info64->orig_e_shoff, elf);
1855 + info->n_sections = off64_from_file (info64->n_sections, elf);
1857 + info->sections = calloc (info->n_sections, sizeof (UnstripInfoSection));
1858 + for (i = 0; i < info->n_sections; i++)
1860 + info->sections[i].debug_section = word64_from_file (info64->sections[i].debug_section, elf);
1861 + info->sections[i].name = word64_from_file (info64->sections[i].name, elf);
1862 + info->sections[i].orig_offset = off64_from_file (info64->sections[i].orig_offset, elf);
1867 unstrip_info_from_data (Elf *elf,
1874 info = malloc (sizeof (UnstripInfo));
1876 - /* FIXME: use right version */
1877 - unstrip_info_from_data32 (info,
1880 + gelf_getehdr (elf, &ehdr);
1881 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1882 + unstrip_info_from_data32 (info, elf, data);
1883 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1884 + unstrip_info_from_data64 (info, elf, data);
1886 + fprintf (stderr, "Warning. unsupported elf class\n");
1893 debug_link_to_data32 (DebugLink *debuglink,
1895 @@ -166,23 +351,53 @@
1896 data->d_buf = calloc (1, data->d_size);
1898 strcpy (data->d_buf, debuglink->filename);
1899 - p = data->d_buf + namelen_aligned;
1900 + p = ((char *)data->d_buf) + namelen_aligned;
1902 *(Elf32_Word *)p = word32_to_file (debuglink->checksum, elf);
1903 - p += sizeof (Elf32_Word);
1907 +debug_link_to_data64 (DebugLink *debuglink,
1911 + size_t namelen_aligned;
1914 + data->d_align = 4;
1916 + namelen_aligned = align_up (strlen(debuglink->filename) + 1, 4);
1919 + /* name */ namelen_aligned +
1920 + /* checksum */ sizeof (Elf64_Word);
1922 + data->d_buf = calloc (1, data->d_size);
1924 + strcpy (data->d_buf, debuglink->filename);
1925 + p = ((char *)data->d_buf) + namelen_aligned;
1927 + *(Elf64_Word *)p = word64_to_file (debuglink->checksum, elf);
1931 debug_link_to_data (DebugLink *debuglink, Elf *elf, Elf_Data *data)
1935 data->d_type = ELF_T_BYTE;
1938 - /* FIXME: use right version */
1939 - debug_link_to_data32 (debuglink, elf, data);
1940 + gelf_getehdr (elf, &ehdr);
1941 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1942 + debug_link_to_data32 (debuglink, elf, data);
1943 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1944 + debug_link_to_data64 (debuglink, elf, data);
1946 + fprintf (stderr, "Warning. unsupported elf class\n");
1951 debug_link_from_data32 (DebugLink *debuglink,
1954 @@ -194,24 +409,44 @@
1956 namelen_aligned = align_up (strlen (debuglink->filename) + 1, 4);
1958 - p = data->d_buf + namelen_aligned;
1959 + p = ((char *)data->d_buf) + namelen_aligned;
1961 debuglink->checksum = word32_from_file (*(Elf32_Word *)p, elf);
1962 - p += sizeof (Elf32_Word);
1966 +debug_link_from_data64 (DebugLink *debuglink,
1970 + size_t namelen_aligned;
1973 + debuglink->filename = strdup (data->d_buf);
1975 + namelen_aligned = align_up (strlen (debuglink->filename) + 1, 4);
1977 + p = ((char *)data->d_buf) + namelen_aligned;
1979 + debuglink->checksum = word64_from_file (*(Elf64_Word *)p, elf);
1984 debug_link_from_data (Elf *elf, Elf_Data *data)
1987 DebugLink *debuglink;
1989 debuglink = malloc (sizeof (DebugLink));
1991 - /* FIXME: use right version */
1992 - debug_link_from_data32 (debuglink,
1995 + gelf_getehdr (elf, &ehdr);
1996 + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1997 + debug_link_from_data32 (debuglink, elf, data);
1998 + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1999 + debug_link_from_data64 (debuglink, elf, data);
2001 + fprintf (stderr, "Warning. unsupported elf class\n");
2005 Index: tools/striptofile.c
2006 ===================================================================
2007 RCS file: rpm/tools/striptofile.c,v
2008 retrieving revision 1.1.2.2
2009 retrieving revision 1.1.2.4
2010 diff -u -u -r1.1.2.2 -r1.1.2.4
2011 --- rpm/tools/striptofile.c 22 Aug 2002 19:19:47 -0000 1.1.2.2
2012 +++ rpm/tools/striptofile.c 9 Oct 2002 19:06:24 -0000 1.1.2.4
2014 int keep_all_section_headers = 1;
2015 int add_unstrip_info = 0;
2018 +#if defined(NhUNUSED)
2020 copy_to_file(Elf *elf, Elf *out_elf)
2031 strip_to_file(Elf *elf, Elf *out_elf, DebugLink *debuglink)
2036 int changed_offsets;
2037 GElf_Off last_offset;
2038 - int i, debuglink_name;
2040 + int debuglink_name = 0;
2042 elf_flagelf (out_elf, ELF_C_SET, ELF_F_LAYOUT);
2045 /* Update section header stringtab ref */
2046 gelf_getehdr (out_elf, &out_ehdr);
2047 out_ehdr.e_shstrndx = section_map[out_ehdr.e_shstrndx];
2048 - out_ehdr.e_shoff = align_up (last_offset, 4);
2049 + out_ehdr.e_shoff = align_up (last_offset, 8);
2050 gelf_update_ehdr(out_elf, &out_ehdr);
2052 /* Update section header links */
2059 copy_debuginfo_to_file(Elf *elf, Elf *out_elf)
2063 unsigned char *section_strtab;
2066 - int unstripinfo_name;
2067 + int unstripinfo_name = 0;
2069 info = malloc (sizeof (UnstripInfo));
2074 const char *origname;
2075 + char *origname_base;
2076 char *debugname, *strippedname;
2077 DebugLink *debuglink;
2078 poptContext optCon; /* context for parsing command-line options */
2079 @@ -433,14 +437,13 @@
2084 - const char * bn = strrchr(origname, '/');
2085 - if ((bn = strrchr(origname, '/')) != NULL)
2089 - debugname = strconcat (output_dir, "/", bn, ".debug", NULL);
2093 + origname_base = path_basename (origname);
2094 + debugname = strconcat (output_dir, "/", origname_base, ".debug", NULL);
2095 + free (origname_base);
2098 debugname = strconcat (origname, ".debug", NULL);
2100 strippedname = strconcat (origname, ".XXXXXX", NULL);
2101 Index: tools/unstripfile.c
2102 ===================================================================
2103 RCS file: rpm/tools/unstripfile.c,v
2104 retrieving revision 1.1.2.2
2105 retrieving revision 1.1.2.3
2106 diff -u -u -r1.1.2.2 -r1.1.2.3
2107 --- rpm/tools/unstripfile.c 22 Aug 2002 19:19:47 -0000 1.1.2.2
2108 +++ rpm/tools/unstripfile.c 9 Oct 2002 19:06:24 -0000 1.1.2.3
2115 read_debuglink (Elf *elf)
2124 find_section (Elf *elf, const unsigned char *name, const unsigned char *strtab)
2133 find_in_strtab (char *name, char *strtab, size_t strtab_len)
2142 unstrip_file (Elf *elf, Elf *debug_elf, Elf *out_elf)
2145 Index: tools/utils.c
2146 ===================================================================
2147 RCS file: rpm/tools/utils.c,v
2148 retrieving revision 1.1.2.3
2149 retrieving revision 1.1.2.4
2150 diff -u -u -r1.1.2.3 -r1.1.2.4
2151 --- rpm/tools/utils.c 4 Sep 2002 18:13:35 -0000 1.1.2.3
2152 +++ rpm/tools/utils.c 9 Oct 2002 19:06:24 -0000 1.1.2.4
2159 my_stpcpy (char *dest,
2166 -unsigned int crc32 (unsigned int crc, unsigned char *buf, size_t len)
2167 +static unsigned int crc32 (unsigned int crc, unsigned char *buf, size_t len)
2171 Index: xmlspec/Makefile
2172 ===================================================================
2173 RCS file: rpm/xmlspec/Makefile,v
2174 retrieving revision 1.5.2.2
2175 retrieving revision 1.5.2.3
2176 diff -u -u -r1.5.2.2 -r1.5.2.3
2177 --- rpm/xmlspec/Makefile 28 Aug 2002 10:53:03 -0000 1.5.2.2
2178 +++ rpm/xmlspec/Makefile 10 Oct 2002 22:47:59 -0000 1.5.2.3
2180 CFLAGS = -O2 -Wall -Wpointer-arith -Wno-char-subscripts
2181 INCDIR = -I. -I.. -I../build -I../lib -I../misc -I../popt -I../rpmdb -I../rpmio
2183 -DESTDIR = /usr/local
2188 XMLBUILD = rpmxmlbuild
2189 XMLBUILD_SRC = rpmxmlbuild.c
2191 LIBS = $(XMLLIB) $(RPMDIR)/build/.libs/librpmbuild.a \
2192 $(RPMDIR)/lib/.libs/librpm.a $(RPMDIR)/rpmdb/.libs/librpmdb.a \
2193 $(RPMDIR)/rpmio/.libs/librpmio.a $(RPMDIR)/popt/.libs/libpopt.a \
2194 + $(RPMDIR)/libelf/lib/.libs/libelf.a \
2196 LIBDIR = -L. -L$(RPMDIR)/.libs -L/usr/lib
2199 $(STRIP) $(XMLBUILD)
2202 - @(cp $(XMLBUILD) $(DESTDIR)/bin)
2203 - @(cp $(XMLLIB) $(DESTDIR)/lib)
2204 - @(cp $(XMLLIB_H) $(DESTDIR)/include)
2205 + @(install -m 755 $(XMLBUILD) $(DESTDIR)$(prefix)/bin)
2206 + @(install -m 644 $(XMLLIB) $(DESTDIR)$(prefix)/lib)
2207 + @(install -m 644 $(XMLLIB_H) $(DESTDIR)$(prefix)/include/rpm)
2209 $(XMLLIB): $(XMLLIB_OBJ)
2210 $(AR) $(ARFLAGS) $(XMLLIB) $(XMLLIB_OBJ)
2211 Index: xmlspec/XMLAttrs.cpp
2212 ===================================================================
2213 RCS file: xmlspec/XMLAttrs.cpp
2214 diff -N xmlspec/XMLAttrs.cpp
2215 --- /dev/null 1 Jan 1970 00:00:00 -0000
2216 +++ rpm/xmlspec/XMLAttrs.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
2218 +// standard C++ includes
2221 +// standard includes
2222 +#include <string.h>
2225 +#include "XMLAttrs.h"
2226 +#include "XMLMisc.h"
2227 +#include "XMLSpec.h"
2229 +using namespace std;
2231 +XMLAttr::XMLAttr(const char* szName,
2232 + const char* szValue)
2236 + m_sName.assign(szName);
2238 + m_sValue.assign(szValue);
2241 +XMLAttr::XMLAttr(const XMLAttr& rAttr)
2244 + m_sName.assign(rAttr.m_sName);
2245 + m_sValue.assign(rAttr.m_sValue);
2248 +XMLAttr::~XMLAttr()
2252 +XMLAttr XMLAttr::operator=(XMLAttr attr)
2254 + m_sName.assign(attr.m_sName);
2255 + m_sValue.assign(attr.m_sValue);
2258 +XMLAttrs::XMLAttrs(const char** szAttrs)
2261 + for (int i = 0; szAttrs && szAttrs[i]; i += 2) {
2262 + XMLAttr attr(szAttrs[i], szAttrs[i+1]);
2263 + m_vAttrs.push_back(attr);
2267 +XMLAttrs::XMLAttrs(const XMLAttrs& rAttrs)
2270 + m_vAttrs = rAttrs.m_vAttrs;
2273 +XMLAttrs::~XMLAttrs()
2277 +bool validateAttr(structValidAttrs& rAttr,
2278 + const char* szValue)
2280 + switch (rAttr.m_nType) {
2281 + case XATTRTYPE_STRING:
2282 + return findStr(rAttr.m_szaMatches, szValue) != -1 ? true : false;
2284 + case XATTRTYPE_INTEGER:
2285 + return isInteger(szValue);
2287 + case XATTRTYPE_BOOL:
2288 + return isBool(szValue);
2290 + case XATTRTYPE_DATE:
2291 + return isDate(szValue);
2293 + case XATTRTYPE_MAIL:
2294 + return isEmail(szValue);
2296 + case XATTRTYPE_NONE:
2304 +static char* szaTypeDesc[] = { "string",
2306 + "bool [Values: true|false]",
2307 + "date [Format: DDD MMM DD YYYY]",
2310 +bool XMLAttrs::validate(structValidAttrs* paValids,
2313 + // nothing found at present
2314 + for (unsigned int i = 0; paValids[i].m_nValue != XATTR_END; i++)
2315 + paValids[i].m_bFound = false;
2317 + // test everything we have
2318 + for (unsigned int i = 0; i < num(); i++) {
2319 + bool bInvalid = true;
2320 + for (unsigned int j = 0; paValids[j].m_nValue != XATTR_END; j++) {
2321 + if (strcasecmp(paValids[j].m_szName, get(i).getName()) == 0) {
2322 + paValids[j].m_bFound = true;
2323 + if (!validateAttr(paValids[j], get(i).asString())) {
2325 + sprintf(szTmp, "Attribute value '%s' is not a valid %s.",
2326 + get(i).asString(), szaTypeDesc[paValids[j].m_nType]);
2327 + pError->setError(szTmp);
2337 + sprintf(szTmp, "Unknown attribute '%s'", get(i).getName());
2338 + pError->setWarning(szTmp);
2342 + // see if we have mandator tags that are not there
2343 + for (unsigned int i = 0; paValids[i].m_nValue != XATTR_END; i++) {
2344 + if (paValids[i].m_bMandatory && !paValids[i].m_bFound) {
2346 + sprintf(szTmp, "Mandatory attribute '%s' not found",
2347 + paValids[i].m_szName);
2348 + pError->setError(szTmp);
2353 + // if we got this far, everything is ok
2357 +unsigned int getPos(const char* szName,
2361 + for (unsigned int i = 0; i < pAttrs->num(); i++) {
2362 + if (strcasecmp(szName, pAttrs->get(i).getName()) == 0)
2369 +const char* XMLAttrs::asString(const char* szName)
2371 + unsigned int nPos = getPos(szName, this);
2372 + return (nPos == XATTR_END) ? NULL : get(nPos).asString();
2375 +unsigned int XMLAttrs::asInteger(const char* szName)
2377 + unsigned int nPos = getPos(szName, this);
2378 + return (nPos == XATTR_END) ? 0 : get(nPos).asInteger();
2381 +bool XMLAttrs::asBool(const char* szName)
2383 + unsigned int nPos = getPos(szName, this);
2384 + return (nPos == XATTR_END) ? true : get(nPos).asBool();
2386 Index: xmlspec/XMLAttrs.h
2387 ===================================================================
2388 RCS file: xmlspec/XMLAttrs.h
2389 diff -N xmlspec/XMLAttrs.h
2390 --- /dev/null 1 Jan 1970 00:00:00 -0000
2391 +++ rpm/xmlspec/XMLAttrs.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
2393 +#ifndef _H_XMLATTRS_
2394 +#define _H_XMLATTRS_
2396 +// standard C++ includes
2400 +// standard C includes
2401 +#include <string.h>
2404 +#include "XMLBase.h"
2406 +using namespace std;
2408 +// definition for the end of the attributes
2409 +#define XATTR_END 0xFFFF
2410 +#define XATTR_NUM_VALSTR 5
2414 + XATTRTYPE_STRING = 0,
2415 + XATTRTYPE_INTEGER,
2419 + XATTRTYPE_NONE = XATTR_END
2422 +struct structValidAttrs
2424 + unsigned int m_nValue;
2425 + bool m_bMandatory;
2428 + unsigned int m_nType;
2429 + char* m_szaMatches[XATTR_NUM_VALSTR+1];
2432 +// forward class definitions
2435 +class XMLAttr : public XMLBase
2438 +// contructors/destructor
2442 + * Default constructor
2444 + * @param szName The name of the attribute
2445 + * @param szValue The attribute value
2448 + XMLAttr(const char* szName,
2449 + const char* szValue);
2452 + * Copy constructor
2454 + * @param rAttr Reference to the attribute to copy
2457 + XMLAttr(const XMLAttr& rAttr);
2472 + * Assignment operator
2474 + * @param attr The attribute to copy
2475 + * @return the assigned obkect
2477 + XMLAttr operator=(XMLAttr attr);
2480 +// get/set functions
2484 + * Returns the attribute name
2487 + * @return string containing the attribute name
2489 + const char* getName()
2491 + return m_sName.c_str();
2495 + * Returns the attribute value (as string)
2498 + * @return string containing the attribute value
2500 + const char* asString()
2502 + return m_sValue.c_str();
2506 + * Returns the attribute value (as integer)
2509 + * @return the attribute as an integer
2511 + unsigned int asInteger()
2513 + return atoi(m_sValue.c_str());
2517 + * Returns the attribute value as a boolean
2520 + * @return true if set, false otherwise
2524 + bool isSet = true;
2525 + if (strcasecmp(m_sValue.c_str(), "no") == 0 ||
2526 + strcasecmp(m_sValue.c_str(), "0") == 0 ||
2527 + strcasecmp(m_sValue.c_str(), "false") == 0)
2533 +// member variables
2540 +class XMLAttrs : public XMLBase
2543 +// constructors/destructor
2547 + * The default attribute constructor
2549 + * @param szAttrs Pointer to an array of attributes, terminated by NULL
2552 + XMLAttrs(const char** szAttrs);
2555 + * Copy constructor
2557 + * @param rAttrs The attribute object to copy
2560 + XMLAttrs(const XMLAttrs& rAttrs);
2563 + * The default destructor
2571 +// member functions
2575 + * Validates an attribute object against the valid attributes. This
2576 + * checks for mandatory attributes (error) as well as unexpected
2577 + * attributes. (warnings)
2579 + * @param paValids Pointer to the array of valid attributes
2580 + * @param pError The class in which we will set the errors
2581 + * and/or warnings.
2582 + * @return true on valid attributes, false otherwise
2584 + bool validate(structValidAttrs* paValids,
2588 +// member variables get/set functions
2592 + * Gets the number of attributes contained in this object
2595 + * @returns The number of attributes
2597 + unsigned int num()
2599 + return m_vAttrs.size();
2603 + * Returns a specific attribute by number
2605 + * @param nNum The number of the attribute to return
2606 + * @return The attribute or NULL if it doesn't exist
2608 + XMLAttr& get(unsigned int nNum)
2610 + return m_vAttrs[nNum];
2614 + * Returns the attribute as specified by the name
2616 + * @param szName The name of the attribute whose value we are
2618 + * @return The attribute as a string
2620 + const char* asString(const char* szName);
2623 + * Returns the attribute as specified by the name
2625 + * @param szName The name of the attribute whose value we are
2627 + * @return The attribute as an integer
2629 + unsigned int asInteger(const char* szName);
2632 + * Returns the attribute as specified by the name
2634 + * @param szName The name of the attribute whose value we are
2636 + * @return The attribute as a bool
2638 + bool asBool(const char* szName);
2641 +// protected data members
2644 + vector<XMLAttr> m_vAttrs;
2648 Index: xmlspec/XMLBase.h
2649 ===================================================================
2650 RCS file: xmlspec/XMLBase.h
2651 diff -N xmlspec/XMLBase.h
2652 --- /dev/null 1 Jan 1970 00:00:00 -0000
2653 +++ rpm/xmlspec/XMLBase.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
2655 +#ifndef _H_XMLBASE_
2656 +#define _H_XMLBASE_
2658 +// standard C++ includes
2661 +// standard include
2664 +using namespace std;
2669 +// constructors/destructor methods
2673 + * Default class constructor
2680 + m_bHasError = false;
2681 + m_bHasWarning = false;
2685 + * Default class destructor
2695 +// member variable get and set functions
2699 + * Tests if the object has an error set.
2702 + * @return true if we have an error, false otherwise
2706 + return m_bHasError;
2710 + * Sets the error message that can be retrieved from this
2713 + * @param szError The error string
2716 + void setError(const char* szError = NULL)
2719 + m_bHasError = true;
2720 + m_sError.assign(szError);
2723 + m_bHasError = false;
2727 + * Returns the currently set error value
2730 + * @return pointer to the error string
2732 + const char* getError()
2734 + m_bHasError = false;
2735 + return m_sError.c_str();
2739 + * Tests if the object has a warning set.
2742 + * @return true if we have a warning, false otherwise
2746 + return m_bHasWarning;
2750 + * Sets the warning message that can be retrieved from this
2753 + * @param szWarning The warning string
2756 + void setWarning(const char* szWarning = NULL)
2759 + m_bHasWarning = true;
2760 + m_sWarning.assign(szWarning);
2763 + m_bHasWarning = false;
2767 + * Returns the currently set warning value
2770 + * @return pointer to the warning string
2772 + const char* getWarning()
2774 + m_bHasWarning = false;
2775 + return m_sWarning.c_str();
2779 +// protected internal variables
2784 + bool m_bHasWarning;
2785 + string m_sWarning;
2789 Index: xmlspec/XMLChangelog.cpp
2790 ===================================================================
2791 RCS file: xmlspec/XMLChangelog.cpp
2792 diff -N xmlspec/XMLChangelog.cpp
2793 --- /dev/null 1 Jan 1970 00:00:00 -0000
2794 +++ rpm/xmlspec/XMLChangelog.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
2796 +// standard C++ includes
2800 +#include "XMLChangelog.h"
2801 +#include "XMLMisc.h"
2802 +#include "XMLRPMWrap.h"
2803 +#include "XMLSpec.h"
2805 +using namespace std;
2807 +bool XMLChangelogEntry::parseCreate(XMLAttrs* pAttrs,
2808 + const char* szChange,
2813 + XMLChangelogEntry change(szChange);
2814 + pSpec->getChangelog().lastDate().addEntry(change);
2818 +bool XMLChangelogEntry::structCreate(const char* szEntries,
2821 + if (!pXSpec || !szEntries)
2823 + char* szIn = (char*)szEntries;
2824 + char* szOut = NULL;
2827 + while (nLen != 0) {
2828 + szOut = splitStr(szIn, '\n', nLen);
2829 + if (strncmp(szIn, "- ", 2) == 0) {
2832 + if (sChange.length()) {
2833 + XMLChangelogEntry change(sChange.c_str());
2834 + pXSpec->getChangelog().lastDate().addEntry(change);
2836 + sChange.assign("");
2838 + sChange.append(szIn, nLen);
2841 + if (sChange.length()) {
2842 + XMLChangelogEntry change(sChange.c_str());
2843 + pXSpec->getChangelog().lastDate().addEntry(change);
2848 +XMLChangelogEntry::XMLChangelogEntry(const char* szChange)
2851 + m_sChange.assign(szChange);
2854 +XMLChangelogEntry::XMLChangelogEntry(const XMLChangelogEntry& rEntry)
2857 + m_sChange.assign(rEntry.m_sChange);
2860 +XMLChangelogEntry::~XMLChangelogEntry()
2864 +void XMLChangelogEntry::toSpecFile(ostream& rOut)
2866 + rOut << endl << "- " << getChange();
2869 +void XMLChangelogEntry::toXMLFile(ostream& rOut)
2871 + rOut << endl << "\t\t\t<change>" << getChange() << "</change>";
2874 +// attribute structure for XMLChangelogDate
2875 +structValidAttrs g_paChangelogDateAttrs[] =
2877 + {0x0000, true, false, "date", XATTRTYPE_DATE, {NULL}},
2878 + {0x0001, true, false, "author", XATTRTYPE_STRING, {"*", NULL}},
2879 + {0x0002, false, false, "author-email", XATTRTYPE_MAIL, {NULL}},
2880 + {0x0003, false, false, "version", XATTRTYPE_STRING, {"*", NULL}},
2881 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
2884 +bool XMLChangelogDate::parseCreate(XMLAttrs* pAttrs,
2887 + // validate our attributes
2888 + if (!pAttrs->validate(g_paChangelogDateAttrs, (XMLBase*)pSpec))
2891 + XMLChangelogDate date(pAttrs->asString("date"),
2892 + pAttrs->asString("author"),
2893 + pAttrs->asString("author-email"),
2894 + pAttrs->asString("version"));
2895 + pSpec->getChangelog().addDate(date);
2899 +bool XMLChangelogDate::structCreate(const char* szDate,
2900 + const char* szName,
2901 + const char* szEntries,
2904 + if (!szDate || !szName || !szEntries || ! pXSpec)
2906 + time_t tTime = (time_t)(atol(szDate)) - timezone;
2907 + struct tm *sTime = gmtime(&tTime);
2908 + sTime->tm_year += 1900;
2910 + sprintf(szTmp,"%s %s %d %d", g_szaDays[sTime->tm_wday],
2911 + g_szaMonths[sTime->tm_mon],
2912 + sTime->tm_mday, sTime->tm_year);
2913 + XMLChangelogDate date(szTmp, szName, NULL, NULL);
2914 + pXSpec->getChangelog().addDate(date);
2915 + XMLChangelogEntry::structCreate(szEntries, pXSpec);
2919 +XMLChangelogDate::XMLChangelogDate(const char* szDate,
2920 + const char* szAuthor,
2921 + const char* szEmail,
2922 + const char* szVersion)
2926 + m_sDate.assign(szDate);
2928 + m_sAuthor.assign(szAuthor);
2930 + m_sEmail.assign(szEmail);
2932 + m_sVersion.assign(szVersion);
2935 +XMLChangelogDate::XMLChangelogDate(const XMLChangelogDate& rDate)
2938 + m_sDate.assign(rDate.m_sDate);
2939 + m_sAuthor.assign(rDate.m_sAuthor);
2940 + m_sEmail.assign(rDate.m_sEmail);
2941 + m_sVersion.assign(rDate.m_sVersion);
2942 + m_vEntries = rDate.m_vEntries;
2945 +XMLChangelogDate::~XMLChangelogDate()
2949 +void XMLChangelogDate::toSpecFile(ostream& rOut)
2951 + rOut << endl << "* " << getDate() << " " << getAuthor();
2953 + rOut << " <" << getEmail() << ">";
2955 + rOut << " " << getVersion();
2956 + for (unsigned int i = 0; i < numEntries(); i++)
2957 + getEntry(i).toSpecFile(rOut);
2961 +void XMLChangelogDate::toXMLFile(ostream& rOut)
2963 + rOut << endl << "\t\t<changes date=\"" << getDate() << "\"";
2964 + rOut << endl << "\t\t author=\"" << getAuthor() << "\"";
2966 + rOut << endl << "\t\t author-email=\"" << getEmail() << "\"";
2968 + rOut << endl << "\t\t version=\"" << getVersion() << "\"";
2970 + for (unsigned int i = 0; i < numEntries(); i++)
2971 + getEntry(i).toXMLFile(rOut);
2972 + rOut << endl << "\t\t</changes>";
2975 +bool XMLChangelog::structCreate(Spec pSpec,
2978 + if (!pXSpec || !pSpec || !pSpec->packages || !pSpec->packages->header)
2980 + // FIXME: it looks like RPM only stores the tomost date in the
2981 + // spec file so we are only allowed to get that one instead of an
2982 + // array of time_t's
2984 + t_StrVector svChanges;
2985 + t_StrVector svNames;
2986 + getRPMHeader(pSpec->packages->header, RPMTAG_CHANGELOGTIME, sDates);
2987 + getRPMHeaderArray(pSpec->packages->header, RPMTAG_CHANGELOGNAME, svNames);
2988 + getRPMHeaderArray(pSpec->packages->header, RPMTAG_CHANGELOGTEXT, svChanges);
2989 + for (unsigned int i = 0; i < svNames.size(); i++)
2990 + XMLChangelogDate::structCreate(sDates.c_str(), svNames[i].c_str(),
2991 + svChanges[i].c_str(), pXSpec);
2995 +XMLChangelog::XMLChangelog()
3000 +XMLChangelog::XMLChangelog(const XMLChangelog& rChangelog)
3003 + m_vDates = rChangelog.m_vDates;
3006 +XMLChangelog::~XMLChangelog()
3010 +void XMLChangelog::toSpecFile(ostream& rOut)
3013 + rOut << endl << "%changelog";
3014 + for (unsigned int i = 0; i < numDates(); i++)
3015 + getDate(i).toSpecFile(rOut);
3020 +void XMLChangelog::toXMLFile(ostream& rOut)
3023 + rOut << endl << "\t<changelog>";
3024 + for (unsigned int i = 0; i < numDates(); i++)
3025 + getDate(i).toXMLFile(rOut);
3026 + rOut << endl << "\t</changelog>";
3030 +void XMLChangelog::toRPMStruct(Spec spec)
3033 Index: xmlspec/XMLChangelog.h
3034 ===================================================================
3035 RCS file: xmlspec/XMLChangelog.h
3036 diff -N xmlspec/XMLChangelog.h
3037 --- /dev/null 1 Jan 1970 00:00:00 -0000
3038 +++ rpm/xmlspec/XMLChangelog.h 28 Aug 2002 10:52:43 -0000 1.3.2.1
3040 +#ifndef _H_XMLCHANGELOG_
3041 +#define _H_XMLCHANGELOG_
3043 +// standard C++ includes
3044 +#include <iostream>
3048 +// standard includes
3052 +#include "XMLAttrs.h"
3053 +#include "XMLBase.h"
3056 +#include <rpmbuild.h>
3058 +// forward class definitions
3060 +class XMLChangelog;
3062 +using namespace std;
3064 +class XMLChangelogEntry : public XMLBase
3067 +// factory functions
3071 + * Adds a changelog entry
3073 + * @param pAttrs The XML attributes
3074 + * @param szEntry The entry to create
3075 + * @param pSpec Pointer to our spec
3076 + * @return true on success, false othersise
3078 + static bool parseCreate(XMLAttrs* pAttrs,
3079 + const char* szEntry,
3084 + * Creates changelog entries from the data provided to us by RPM
3085 + * @param szEntries The netries we are to evaluate
3086 + * @param pXSpec pointer to the XML spec we are working with
3087 + * @return true on success,. false otherwise
3089 + static bool structCreate(const char* szEntries,
3093 +// constructors/destructor
3097 + * Default contructor
3099 + * @param szChange The change entry
3102 + XMLChangelogEntry(const char* szChange);
3105 + * Copy constructor
3107 + * @param rEntry Reference to the entry to copy
3110 + XMLChangelogEntry(const XMLChangelogEntry& rEntry);
3118 + ~XMLChangelogEntry();
3121 +// member functions
3125 + * Outputs the object into a spec file
3127 + * @param rOut Reference to our output stream
3130 + void toSpecFile(ostream& rOut);
3133 + * Outputs the object into an XML spec file
3135 + * @param rOut Reference to our output stream
3138 + void toXMLFile(ostream& rOut);
3141 +// member variable get/set functions
3145 + * Returns the enrty
3148 + * @return string containing the entry
3150 + const char* getChange()
3152 + return m_sChange.c_str();
3156 +// member variables
3162 +class XMLChangelogDate : public XMLBase
3165 +// factory functions
3169 + * Creates a XMLChangelogDate object
3171 + * @param pAttrs The XML attributes
3172 + * @param pSpec The spec to add this object to
3173 + * @return true on success, false otherwise
3175 + static bool parseCreate(XMLAttrs* pAttrs,
3179 + * Creates an XMLChangelogDate object from the information provided to
3182 + * @param szDate The date to generate this for
3183 + * @param szEntries The entries to add to this date
3184 + * @param pXSpec The XML spec we are working with
3185 + * @return true on success, false otherwise
3187 + static bool structCreate(const char* szDate,
3188 + const char* szName,
3189 + const char* szEntries,
3193 +// constructors/destructor
3197 + * Default contructor
3199 + * @param szDate The date
3200 + * @param szAuthor The author
3201 + * @param szEmail The author's email
3202 + * @param szVersion The version in which this change was made
3205 + XMLChangelogDate(const char* szDate,
3206 + const char* szAuthor,
3207 + const char* szEmail,
3208 + const char* szVersion);
3213 + * @param rDate Reference to the date object to copy
3216 + XMLChangelogDate(const XMLChangelogDate& rDate);
3224 + ~XMLChangelogDate();
3227 +// public member functions
3231 + * Outputs the object into a spec file
3233 + * @param rOut Reference to our output stream
3236 + void toSpecFile(ostream& rOut);
3239 + * Outputs the object into an XML spec file
3241 + * @param rOut Reference to our output stream
3244 + void toXMLFile(ostream& rOut);
3247 +// member variables get/set functions
3251 + * Returns the date for the group of entries
3254 + * @return string representation of the date
3256 + const char* getDate()
3258 + return m_sDate.c_str();
3262 + * Checks for an author
3265 + * @return true if we have an author, false otherwise
3269 + return m_sAuthor.length() ? true : false;
3273 + * Returns the author's name
3276 + * @return string containing the author's name
3278 + const char* getAuthor()
3280 + return m_sAuthor.c_str();
3284 + * Checks if we have an email address for the author
3287 + * @return true if we hava an email, false otherwise
3291 + return m_sEmail.length() ? true : false;
3295 + * Returns the author's email addresse
3298 + * @return a string containing the author's email address
3300 + const char* getEmail()
3302 + return m_sEmail.c_str();
3306 + * Checks if we have a change version
3309 + * @return true if we have a version, false otherwise
3313 + return m_sVersion.length() ? true : false;
3317 + * Gets the change version
3320 + * @return string containing the version
3322 + const char* getVersion()
3324 + return m_sVersion.c_str();
3328 + * Returns the number of entries for this date
3331 + * @return the number of entries
3333 + unsigned int numEntries()
3335 + return m_vEntries.size();
3339 + * Returns a specific entry
3341 + * @param nNum The number of the entry to return
3342 + * @return the enrty
3344 + XMLChangelogEntry& getEntry(unsigned int nNum)
3346 + return m_vEntries[nNum];
3350 + * Adds an entry for this date
3352 + * @param szEntry The entry to add
3355 + void addEntry(XMLChangelogEntry& rEntry)
3357 + m_vEntries.push_back(rEntry);
3361 +// member variables
3367 + string m_sVersion;
3368 + vector<XMLChangelogEntry> m_vEntries;
3371 +class XMLChangelog : public XMLBase
3374 +// static factory functions
3378 + * Creates changelog objects from an RPM Spec structure
3380 + * @param pSpec Pointer to the RPM spec
3381 + * @param pXSpec pointer to the XMLSpec object to populate
3382 + * @return true on success, false otherwise
3384 + static bool structCreate(Spec pSpec,
3388 +// constructors/destructor
3392 + * Default constructor
3400 + * Copy constructor
3402 + * @param rChangelog The object to copy
3405 + XMLChangelog(const XMLChangelog& rChangelog);
3416 +// public member functions
3420 + * Converts the object into a spec file
3422 + * @param rOut Reference to the output stream
3425 + void toSpecFile(ostream& rOut);
3428 + * Converts the object into an xML spec
3430 + * @param rOut Reference to the output stream
3433 + void toXMLFile(ostream& rOut);
3436 + * Converts the object into an RPM structure
3438 + * @param spec RPM structure
3441 + void toRPMStruct(Spec spec);
3443 +// variable get/set functions
3447 + * Adds a date to the changelog
3449 + * @param rDate The date to add
3452 + void addDate(XMLChangelogDate& rDate)
3454 + m_vDates.push_back(rDate);
3458 + * Returns the number of dates in the changelog
3461 + * @return the number of dates
3463 + unsigned int numDates()
3465 + return m_vDates.size();
3469 + * Gets a specific date
3471 + * @param nNum The entry number
3472 + * @return The requated date
3474 + XMLChangelogDate& getDate(unsigned int nNum)
3476 + return m_vDates[nNum];
3480 + * Gets the last date we have added
3483 + * @return the last date
3485 + XMLChangelogDate& lastDate()
3487 + return m_vDates[numDates()-1];
3491 +// member variables
3494 + vector<XMLChangelogDate> m_vDates;
3498 Index: xmlspec/XMLFiles.cpp
3499 ===================================================================
3500 RCS file: xmlspec/XMLFiles.cpp
3501 diff -N xmlspec/XMLFiles.cpp
3502 --- /dev/null 1 Jan 1970 00:00:00 -0000
3503 +++ rpm/xmlspec/XMLFiles.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
3505 +// standard includes
3509 +#include "XMLAttrs.h"
3510 +#include "XMLFiles.h"
3511 +#include "XMLPackage.h"
3512 +#include "XMLSpec.h"
3515 +#include <rpmlib.h>
3516 +#include <stringbuf.h>
3518 +using namespace std;
3520 +// attribute structure for XMLFile
3521 +structValidAttrs g_paFileAttrs[] =
3523 + {0x0000, false, false, "mode", XATTRTYPE_INTEGER, {NULL}},
3524 + {0x0001, false, false, "group", XATTRTYPE_STRING, {"*", NULL}},
3525 + {0x0002, false, false, "user", XATTRTYPE_STRING, {"*", NULL}},
3526 + {0x0003, false, false, "config", XATTRTYPE_STRING, {"noreplace",
3528 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
3531 +bool XMLFile::parseCreate(XMLAttrs* pAttrs,
3532 + const char* szPath,
3535 + // validate the attributes
3536 + if (!pSpec || !pAttrs->validate(g_paFileAttrs, (XMLBase*)pSpec))
3539 + // create and return
3540 + XMLFile file(pAttrs->asString("mode"), pAttrs->asString("user"),
3541 + pAttrs->asString("group"), pAttrs->asString("config"), szPath);
3542 + pSpec->lastPackage().getFiles().addFile(file);
3546 +XMLFile::XMLFile(const char* szMode,
3547 + const char* szOwner,
3548 + const char* szGroup,
3549 + const char* szConfig,
3550 + const char* szPath)
3554 + m_sMode.assign(szMode);
3556 + m_sOwner.assign(szOwner);
3558 + m_sGroup.assign(szGroup);
3560 + m_sConfig.assign(szConfig);
3562 + m_sPath.assign(szPath);
3565 +XMLFile::XMLFile(const XMLFile& rFile)
3568 + setMode(rFile.m_sMode.c_str());
3569 + setOwner(rFile.m_sOwner.c_str());
3570 + setGroup(rFile.m_sGroup.c_str());
3571 + setConfig(rFile.m_sConfig.c_str());
3572 + setPath(rFile.m_sPath.c_str());
3575 +XMLFile::~XMLFile()
3579 +XMLFile XMLFile::operator=(XMLFile file)
3581 + setMode(file.m_sMode.c_str());
3582 + setOwner(file.m_sOwner.c_str());
3583 + setGroup(file.m_sGroup.c_str());
3584 + setConfig(file.m_sConfig.c_str());
3585 + setPath(file.m_sPath.c_str());
3588 +void XMLFile::toSpecFile(ostream& rOut)
3590 + if (hasMode() || hasOwner() || hasGroup()) {
3592 + rOut << (hasMode() ? getMode() : "-");
3593 + rOut << "," << (hasOwner() ? getOwner() : "-");
3594 + rOut << "," << (hasGroup() ? getGroup() : "-");
3597 + if (hasConfig()) {
3598 + rOut << "%config(" << getConfig() << ") ";
3600 + rOut << getPath() << endl;
3603 +void XMLFile::toXMLFile(ostream& rOut)
3605 + rOut << endl << "\t\t\t<file";
3607 + rOut << " mode=\"" << getMode() << "\"";
3609 + rOut << " user=\"" << getOwner() << "\"";
3611 + rOut << " group=\"" << getGroup() << "\"";
3613 + rOut << " config=\"" << getConfig() << "\"";
3615 + rOut << getPath() << "</file>";
3618 +// attribute structure for XMLFiles
3619 +structValidAttrs g_paFilesAttrs[] =
3621 + {0x0000, false, false, "mode", XATTRTYPE_INTEGER, {NULL}},
3622 + {0x0001, false, false, "group", XATTRTYPE_STRING, {"*", NULL}},
3623 + {0x0002, false, false, "user", XATTRTYPE_STRING, {"*", NULL}},
3624 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
3627 +bool XMLFiles::parseCreate(XMLAttrs* pAttrs,
3630 + if (!pSpec || !pAttrs->validate(g_paFilesAttrs, (XMLBase*)pSpec))
3632 + pSpec->lastPackage().getFiles().setDefMode(pAttrs->asString("mode"));
3633 + pSpec->lastPackage().getFiles().setDefOwner(pAttrs->asString("user"));
3634 + pSpec->lastPackage().getFiles().setDefGroup(pAttrs->asString("group"));
3638 +bool XMLFiles::structCreate(PackageStruct* pPackage,
3642 + if (!pXSpec || !pSpec || !pPackage || !pPackage->fileList)
3647 +XMLFiles::XMLFiles()
3652 +XMLFiles::XMLFiles(const XMLFiles& rFiles)
3655 + setDefMode(rFiles.m_sMode.c_str());
3656 + setDefOwner(rFiles.m_sOwner.c_str());
3657 + setDefGroup(rFiles.m_sGroup.c_str());
3658 + m_vFiles = rFiles.m_vFiles;
3661 +XMLFiles::~XMLFiles()
3665 +XMLFiles XMLFiles::operator=(XMLFiles files)
3667 + setDefMode(files.m_sMode.c_str());
3668 + setDefOwner(files.m_sOwner.c_str());
3669 + setDefGroup(files.m_sGroup.c_str());
3670 + m_vFiles = files.m_vFiles;
3674 +void XMLFiles::toSpecFile(ostream& rOut)
3677 + if (hasDefMode() || hasDefOwner() || hasDefGroup()) {
3678 + rOut << "%defattr(";
3679 + rOut << (hasDefMode() ? getDefMode() : "-");
3680 + rOut << "," << (hasDefOwner() ? getDefOwner() : "-");
3681 + rOut << "," << (hasDefGroup() ? getDefGroup() : "-");
3682 + rOut << ")" << endl;
3684 + for (unsigned int i = 0; i < numFiles(); i++)
3685 + getFile(i).toSpecFile(rOut);
3689 +void XMLFiles::toXMLFile(ostream& rOut)
3692 + rOut << endl << "\t\t<files";
3694 + rOut << " mode=\"" << getDefMode() << "\"";
3695 + if (hasDefOwner())
3696 + rOut << " user=\"" << getDefOwner() << "\"";
3697 + if (hasDefGroup())
3698 + rOut << " group=\"" << getDefGroup() << "\"";
3700 + for (unsigned int i = 0; i < numFiles(); i++)
3701 + getFile(i).toXMLFile(rOut);
3702 + rOut << endl << "\t\t</files>";
3705 Index: xmlspec/XMLFiles.h
3706 ===================================================================
3707 RCS file: xmlspec/XMLFiles.h
3708 diff -N xmlspec/XMLFiles.h
3709 --- /dev/null 1 Jan 1970 00:00:00 -0000
3710 +++ rpm/xmlspec/XMLFiles.h 28 Aug 2002 10:52:43 -0000 1.3.2.1
3712 +#ifndef _H_XMLFILES_
3713 +#define _H_XMLFILES_
3715 +// standard C++ includes
3716 +#include <iostream>
3720 +// standard includes
3724 +#include "XMLAttrs.h"
3725 +#include "XMLBase.h"
3728 +#include <rpmbuild.h>
3730 +// forward class definitions
3735 +using namespace std;
3738 +class XMLFile : public XMLBase
3741 +// object creation static functions
3745 + * Creates a file object and add it to the correct XMLFiles
3748 + * @param pAttrs The attributes in the XML tag
3749 + * @param szPath The file path
3750 + * @param pSpec The spec to which these files belong
3751 + * @return true on success, false otherwise
3753 + static bool parseCreate(XMLAttrs* pAttrs,
3754 + const char* szPath,
3758 +// constructors/destructor
3762 + * Default contructor
3764 + * @param szMode The file's mode (NULL if default)
3765 + * @param szOwner The file's owner (NULL if default)
3766 + * @param szGroup The file's group (NULL if default)
3767 + * @param szConfig The configuration parameter
3768 + * @param szPath The file path
3771 + XMLFile(const char* szMode,
3772 + const char* szUser,
3773 + const char* szGroup,
3774 + const char* szConfig,
3775 + const char* szPath);
3778 + * Copy constructire
3780 + * @param rFile Reference to the object to copy
3783 + XMLFile(const XMLFile& rFile);
3786 + * Default destructor
3798 + * Assignment operator
3800 + * @param file The file that we wish to copy
3801 + * @return a copy of the original
3803 + XMLFile operator=(XMLFile file);
3806 +// member functions
3810 + * Outputs the obkect to an RPM spec file
3812 + * @param rOut Reference to the output stream
3815 + void toSpecFile(ostream& rOut);
3818 + * Outputs the object to an XML spec file
3820 + * @param rOut Reference to the output stream
3823 + void toXMLFile(ostream& rOut);
3826 +// member variable get/set functions
3830 + * Returns the file path
3833 + * @return string containing the path
3835 + const char* getPath()
3837 + return m_sPath.c_str();
3841 + * Sets the file path
3843 + * @param szPath The path to set
3846 + void setPath(const char* szPath)
3849 + m_sPath.assign(szPath);
3853 + * Checks for a file mode
3856 + * @return true if we have one, false otherwise
3860 + return m_sMode.length() ? true : false;
3864 + * Returns the file mode
3867 + * @return the mode string
3869 + const char* getMode()
3871 + return m_sMode.c_str();
3875 + * Sets the file mode
3877 + * @param szMode The mode to set
3880 + void setMode(const char* szMode)
3883 + m_sMode.assign(szMode);
3887 + * Checks if we have a file owner
3890 + * @return true if we have an owner, false otherwise
3894 + return m_sOwner.length() ? true : false;
3898 + * Returns the file owner
3901 + * @return the owner as a string
3903 + const char* getOwner()
3905 + return m_sOwner.c_str();
3909 + * Sets the file owner
3911 + * @param szOwner The file owner
3914 + void setOwner(const char* szOwner)
3917 + m_sOwner.assign(szOwner);
3921 + * Checks for a file group
3924 + * @return true if we have a group, false otherwise
3928 + return m_sGroup.length() ? true : false;
3932 + * Returns the file group
3935 + * @return string containing the group
3937 + const char* getGroup()
3939 + return m_sGroup.c_str();
3943 + * Sets the file group
3945 + * @param szGroup The group to set
3948 + void setGroup(const char* szGroup)
3951 + m_sGroup.assign(szGroup);
3955 + * Checks for config directives
3958 + * @return true if we have one, false otherwise
3962 + return m_sConfig.length() ? true : false;
3966 + * Returns the config attribute
3969 + * @return the sttribute string
3971 + const char* getConfig()
3973 + return m_sConfig.c_str();
3977 + * Sets the config attribute
3979 + * @param szConfig The configuration
3982 + void setConfig(const char* szConfig)
3985 + m_sConfig.assign(szConfig);
3989 +// member variables
4000 +class XMLFiles : public XMLBase
4003 +// object creation static functions
4007 + * Creates an object as parsed from an XML spec
4009 + * @param pAttrs XML atrtributes to use
4010 + * @param pSpec The spec to which we are adding this object to
4011 + * @return true on success, false otherwise
4013 + static bool parseCreate(XMLAttrs* pAttrs,
4017 + * Creates file objects from an RPM Spec structure
4019 + * @param pPackage Pointer to the package
4020 + * @param pSpec Pointer to the RPM spec
4021 + * @param pXSpec pointer to the XMLSpec object to populate
4022 + * @return true on success, false otherwise
4024 + static bool structCreate(PackageStruct* pPackage,
4029 +// constructors/destructor
4033 + * Default constructor
4041 + * Copy constructor
4043 + * @param rFiles Reference to the object to copy
4046 + XMLFiles(const XMLFiles& rFiles);
4057 +// member functions
4061 + * Converts the object into an RPM spec
4063 + * @param rOut Output stream
4066 + void toSpecFile(ostream& rOut);
4069 + * Converts the object into an XML spec
4071 + * @param rOut Output stream
4074 + void toXMLFile(ostream& rOut);
4081 + * Assignment operator
4083 + * @param files XMLFiles object to copy
4084 + * @return copied object
4086 + XMLFiles operator=(XMLFiles files);
4089 +// member variable get/set functions
4093 + * Adds a file to our file list
4095 + * @param rFile File to add
4098 + void addFile(XMLFile& rFile)
4100 + m_vFiles.push_back(rFile);
4104 + * Returns the number of files in our list
4109 + unsigned int numFiles()
4111 + return m_vFiles.size();
4115 + * Returns a specific file
4117 + * @param nNum Number of the file to return
4118 + * @return the file object
4120 + XMLFile& getFile(unsigned int nNum)
4122 + return m_vFiles[nNum];
4126 + * Checks for a default mode
4129 + * @return true if we have a default mode, false otherwise
4133 + return m_sMode.length() ? true : false;
4137 + * Sets the default mode
4139 + * @param szMode The mode value
4142 + void setDefMode(const char* szMode)
4145 + m_sMode.assign(szMode);
4149 + * Returns the default mode
4152 + * @return string containing the mode
4154 + const char* getDefMode()
4156 + return m_sMode.c_str();
4160 + * Check if we have a default owner
4163 + * @return true if we have an owner, false otherwise
4165 + bool hasDefOwner()
4167 + return m_sOwner.length() ? true : false;
4171 + * Sets the default owner
4173 + * @param szOwner The owner
4176 + void setDefOwner(const char* szOwner)
4179 + m_sOwner.assign(szOwner);
4183 + * Returns the default owner
4186 + * @return the owner string
4188 + const char* getDefOwner()
4190 + return m_sOwner.c_str();
4194 + * Checks if we have a default group
4197 + * @return true if we have an owner, false otherwise
4199 + bool hasDefGroup()
4201 + return m_sGroup.length() ? true : false;
4205 + * Sets the default group
4207 + * @param szGroup The group to set
4210 + void setDefGroup(const char* szGroup)
4213 + m_sGroup.assign(szGroup);
4217 + * Gets the default group
4220 + * @return string representation of the group
4222 + const char* getDefGroup()
4224 + return m_sGroup.c_str();
4228 +// member variables
4234 + vector<XMLFile> m_vFiles;
4238 Index: xmlspec/XMLMacro.cpp
4239 ===================================================================
4240 RCS file: xmlspec/XMLMacro.cpp
4241 diff -N xmlspec/XMLMacro.cpp
4242 --- /dev/null 1 Jan 1970 00:00:00 -0000
4243 +++ rpm/xmlspec/XMLMacro.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
4246 +#include "XMLMacro.h"
4247 +#include "XMLSpec.h"
4249 +using namespace std;
4251 +// attribute structure for XMLMacro
4252 +structValidAttrs g_paMacroAttrs[] =
4254 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
4255 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4258 +bool XMLMacro::parseCreate(XMLAttrs* pAttrs,
4259 + const char* szMacro,
4262 + if (!pSpec || !szMacro || !pAttrs->validate(g_paMacroAttrs, (XMLBase*)pAttrs))
4264 + XMLMacro macro(pAttrs->asString("name"), szMacro);
4265 + pSpec->addXMacro(macro);
4269 +XMLMacro::XMLMacro(const char* szName,
4270 + const char* szMacro)
4274 + m_sName.assign(szName);
4276 + m_sValue.assign(szMacro);
4279 +XMLMacro::XMLMacro(const XMLMacro& rMacro)
4282 + m_sName.assign(rMacro.m_sName);
4283 + m_sValue.assign(rMacro.m_sValue);
4286 +XMLMacro::~XMLMacro()
4290 +XMLMacro XMLMacro::operator=(XMLMacro macro)
4292 + m_sName.assign(macro.m_sName);
4293 + m_sValue.assign(macro.m_sValue);
4296 +void XMLMacro::toSpecFile(ostream& rOut)
4298 + rOut << "%define " << getName() << " " << getValue() << endl;
4301 +void XMLMacro::toXMLFile(ostream& rOut)
4303 + rOut << endl << "\t<macro name=\"" << getName() << "\">";
4304 + rOut << getValue() << "</macro>";
4306 Index: xmlspec/XMLMacro.h
4307 ===================================================================
4308 RCS file: xmlspec/XMLMacro.h
4309 diff -N xmlspec/XMLMacro.h
4310 --- /dev/null 1 Jan 1970 00:00:00 -0000
4311 +++ rpm/xmlspec/XMLMacro.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
4313 +#ifndef _H_XMLMACRO_
4314 +#define _H_XMLMACRO_
4316 +// standard C++ includes
4317 +#include <iostream>
4321 +#include "XMLAttrs.h"
4323 +// forward class definitions
4326 +using namespace std;
4329 +class XMLMacro : public XMLBase
4332 +// factory functions
4336 + * Creates an XMLMacro object
4338 + * @param pAttrs XML tag attributes
4339 + * @param szMacro The macro contents
4340 + * @param pSpec the spec to add the macro to
4341 + * @return true on success, false otherwise
4343 + static bool parseCreate(XMLAttrs* pAttrs,
4344 + const char* szMacro,
4348 +// constructors/destructor
4352 + * Default constructor
4354 + * @param szName The name of the macro
4355 + * @param szMacro The expanded macro
4358 + XMLMacro(const char* szName,
4359 + const char* szMacro);
4362 + * Copy constructor
4364 + * @param rMacro the macro to copy
4367 + XMLMacro(const XMLMacro& rMacro);
4382 + * Assignment operator
4384 + * @param macro The macro to copy
4385 + * @return our copied object
4387 + XMLMacro operator=(XMLMacro macro);
4390 +// member functions
4394 + * Outputs the macro into an RPM spec
4396 + * @param rOut Output stream
4399 + void toSpecFile(ostream& rOut);
4402 + * Outputs the macro into an XML spec
4404 + * @param rOut Output stream
4407 + void toXMLFile(ostream& rOut);
4410 +// member get/set functions
4414 + * Gets the macro name
4417 + * @return string containing the macro name
4419 + const char* getName()
4421 + return m_sName.c_str();
4425 + * Gets tha macro value
4428 + * @return string contatining the macro value
4430 + const char* getValue()
4432 + return m_sValue.c_str();
4436 +// member variables
4444 Index: xmlspec/XMLMirror.cpp
4445 ===================================================================
4446 RCS file: xmlspec/XMLMirror.cpp
4447 diff -N xmlspec/XMLMirror.cpp
4448 --- /dev/null 1 Jan 1970 00:00:00 -0000
4449 +++ rpm/xmlspec/XMLMirror.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
4452 +#include "XMLMirror.h"
4453 +#include "XMLSpec.h"
4455 +using namespace std;
4457 +// attribute structure for XMLMirror
4458 +structValidAttrs g_paMirrorAttrs[] =
4460 + {0x0000, true, false, "path", XATTRTYPE_STRING, {"*", NULL}},
4461 + {0x0001, false, false, "description", XATTRTYPE_STRING, {"*", NULL}},
4462 + {0x0002, false, false, "country", XATTRTYPE_STRING, {"*", NULL}},
4463 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4466 +bool XMLMirror::parseCreate(XMLAttrs* pAttrs,
4470 + // validate the attributes
4471 + if (!pAttrs->validate(g_paMirrorAttrs, (XMLBase*)pSpec))
4474 + XMLMirror mirror(pAttrs->asString("path"),
4475 + pAttrs->asString("description"),
4476 + pAttrs->asString("country"));
4477 + if (bPatch && pSpec->numPatches())
4478 + pSpec->lastPatch().addMirror(mirror);
4479 + else if (!bPatch && pSpec->numSources())
4480 + pSpec->lastSource().addMirror(mirror);
4484 +XMLMirror::XMLMirror(const char* szPath,
4485 + const char* szDescription,
4486 + const char* szCountry) : XMLBase()
4489 + m_sPath.assign(szPath);
4490 + if (szDescription)
4491 + m_sDescription.assign(szDescription);
4493 + m_sCountry.assign(szCountry);
4496 +XMLMirror::XMLMirror(const XMLMirror& rMirror)
4499 + m_sPath.assign(rMirror.m_sPath);
4500 + m_sDescription.assign(rMirror.m_sDescription);
4501 + m_sCountry.assign(rMirror.m_sCountry);
4504 +XMLMirror::~XMLMirror()
4508 +XMLMirror XMLMirror::operator=(XMLMirror mirror)
4510 + m_sPath.assign(mirror.m_sPath);
4511 + m_sDescription.assign(mirror.m_sDescription);
4512 + m_sCountry.assign(mirror.m_sCountry);
4515 +void XMLMirror::toSpecFile(ostream& rOut)
4517 + rOut << endl << "# mirror: " << getPath();
4520 +void XMLMirror::toXMLFile(ostream& rOut)
4522 + rOut << endl << "\t\t<mirror path=\"" << getPath() << "\"";
4523 + if (hasDescription())
4524 + rOut << endl << "\t\t description=\"" << getDescription() << "\"";
4526 + rOut << endl << "\t\t country=\"" << getCountry() << "\"";
4529 Index: xmlspec/XMLMirror.h
4530 ===================================================================
4531 RCS file: xmlspec/XMLMirror.h
4532 diff -N xmlspec/XMLMirror.h
4533 --- /dev/null 1 Jan 1970 00:00:00 -0000
4534 +++ rpm/xmlspec/XMLMirror.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
4536 +#ifndef _H_XMLMIRROR_
4537 +#define _H_XMLMIRROR_
4539 +// standard C++ includes
4542 +#include <iostream>
4545 +#include "XMLAttrs.h"
4546 +#include "XMLBase.h"
4548 +// forward declaration
4551 +using namespace std;
4554 +class XMLMirror : public XMLBase
4557 +// static object creation functions
4561 + * static function for creation of an XMLMirror object
4563 + * @param pAttrs Pointer to our attribute structure
4564 + * @param pSpec Pointer to our spec that is to ultimately
4565 + * contain the object
4566 + * @param bPatch true if we are handling the mirror for a patch
4567 + * @return true on success, false otherwise
4569 + static bool parseCreate(XMLAttrs* pAttrs,
4571 + bool bPatch = false);
4574 +// constructors/destructor
4578 + * Default constructor for the XMLMirror object
4580 + * @param szPath Full path for the mirror
4581 + * @param szDescription Full mirror description
4582 + * @param szCoutry Country code for the mirror
4585 + XMLMirror(const char* szPath,
4586 + const char* szDescription,
4587 + const char* szCountry);
4592 + * @param rMirror Reference to the object to copy
4595 + XMLMirror(const XMLMirror& rMirror);
4598 + * Destructor for an XMLMirror object
4610 + * Assignment operator
4612 + * @param mirror The mirror to get the values from
4613 + * @return The modified object
4615 + XMLMirror operator=(XMLMirror mirror);
4618 +// public member functions
4622 + * Converts an XMLMirror object to a RPM spec file
4624 + * @param rOut File stream
4627 + void toSpecFile(ostream& rOut);
4630 + * Converts an XMLMirror object to an XML spec file
4632 + * @param rOut File stream
4635 + void toXMLFile(ostream& rOut);
4638 +// member variable get/set functions
4642 + * Checks if we have a path
4645 + * @return true if we have a path, false otherise
4649 + return m_sPath.length() ? true : false;
4653 + * Returns the path
4656 + * @return The path strinbg
4658 + const char* getPath()
4660 + return m_sPath.c_str();
4664 + * Checks if we have a description set
4667 + * @return true is we have a description, false otherwise
4669 + bool hasDescription()
4671 + return m_sDescription.length() ? true : false;
4675 + * Returns the description
4678 + * @return the description string
4680 + const char* getDescription()
4682 + return m_sDescription.c_str();
4686 + * Checks if we have a country set
4689 + * @return true if we have a country, false otherwise
4693 + return m_sCountry.length() ? true : false;
4697 + * Gets the country
4700 + * @return The country string
4702 + const char* getCountry()
4704 + return m_sCountry.c_str();
4708 +// member variables
4712 + string m_sDescription;
4713 + string m_sCountry;
4717 Index: xmlspec/XMLMisc.cpp
4718 ===================================================================
4719 RCS file: xmlspec/XMLMisc.cpp
4720 diff -N xmlspec/XMLMisc.cpp
4721 --- /dev/null 1 Jan 1970 00:00:00 -0000
4722 +++ rpm/xmlspec/XMLMisc.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
4724 +// standard c includes
4726 +#include <stdlib.h>
4727 +#include <string.h>
4729 +using namespace std;
4731 +char* g_szaDays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL };
4732 +char* g_szaMonths[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
4733 + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
4734 +int g_naLengths[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
4735 +char* g_szaBools[] = { "no", "yes", "false", "true", "0", "1", NULL };
4737 +char* splitStr(const char* szInput,
4742 + while (szInput[nLen] != cTerm && szInput[nLen] != '\0') {
4745 + char* szTemp = ((char*)szInput)+nLen;
4746 + while (*szTemp == cTerm && *szTemp != '\0')
4751 +int findStr(char* szaMatches[],
4752 + const char* szValue,
4755 + for (unsigned int i = 0; szaMatches[i] != NULL; i++) {
4756 + if (strcmp(szaMatches[i], "*") == 0)
4758 + else if (nLen == -1) {
4759 + if (strcasecmp(szaMatches[i], szValue) == 0)
4762 + else if (strncasecmp(szaMatches[i], szValue, nLen) == 0)
4768 +bool isInteger(const char* szValue,
4772 + nLen = strlen(szValue);
4773 + for (unsigned int i = 0; i < strlen(szValue); i++) {
4774 + if (szValue[i] < '0' || szValue[i] > '9')
4780 +bool isBool(const char* szValue,
4783 + return findStr(g_szaBools, szValue, nLen) != -1 ? true : false;
4786 +bool isDate(const char* szValue)
4789 + char* szTemp = splitStr(szValue, ' ', nLen);
4790 + if ((nPos = findStr(g_szaDays, szValue, nLen)) != -1) {
4791 + if ((nPos = findStr(g_szaMonths, szTemp, nLen)) != -1) {
4792 + szTemp = splitStr(szTemp, ' ', nLen);
4793 + char* szBuffer = new char[nLen+1];
4794 + sprintf(szBuffer, "%s", szTemp);
4795 + szBuffer[nLen] = '\0';
4796 + if (atoi(szBuffer) <= g_naLengths[nPos]) {
4797 + delete[] szBuffer;
4798 + szTemp = splitStr(szTemp, ' ', nLen);
4799 + return isInteger(szTemp, nLen);
4801 + delete[] szBuffer;
4807 +bool isEmail(const char* szValue)
4809 + bool bFound = false;
4810 + for (unsigned int j = 0; j < strlen(szValue); j++) {
4811 + if (szValue[j] == '@') {
4820 Index: xmlspec/XMLMisc.h
4821 ===================================================================
4822 RCS file: xmlspec/XMLMisc.h
4823 diff -N xmlspec/XMLMisc.h
4824 --- /dev/null 1 Jan 1970 00:00:00 -0000
4825 +++ rpm/xmlspec/XMLMisc.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
4827 +#ifndef _H_XMLMISC_
4828 +#define _H_XMLMISC_
4830 +extern char* g_szaDays[];
4831 +extern char* g_szaMonths[];
4834 + * Splits the input string according to the terminator, returning
4835 + * the length and the new search position
4837 + * @param szInput The input string
4838 + * @param cTerm The terminating character
4839 + * @param nLen the length buffer
4840 + * @return The next string position
4842 +extern char* splitStr(const char* szInput,
4847 + * Finds a string in an array of potential matches
4849 + * @param szaMatches The potential matches
4850 + * @param szValue The value to search for
4851 + * @return The position on success, -1 if not found
4853 +extern int findStr(char* szaMatches[],
4854 + const char* szValue,
4858 + * Checks if a string contains an integer
4860 + * @param szValue The string to check
4861 + * @param nLen The length to check, -1 to end of string
4862 + * @return true if the string is an integer, false otherwise
4864 +extern bool isInteger(const char* szValue,
4868 + * Checks if a string contains a boolean value
4870 + * @param szValue The value to check
4871 + * @return true if we have a boolean, false otherwise
4873 +extern bool isBool(const char* szValue,
4877 + * Checks if a string is in a valid date format
4879 + * @param szValue The string to check
4880 + * @return true is this is a date, false otherwise
4882 +extern bool isDate(const char* szValue);
4885 + * Checks if a string contains a valid e-mail address
4887 + * @param szValue the string to check
4888 + * @return true if this is an email address, false otherwise
4890 +extern bool isEmail(const char* szValue);
4893 Index: xmlspec/XMLPackage.cpp
4894 ===================================================================
4895 RCS file: xmlspec/XMLPackage.cpp
4896 diff -N xmlspec/XMLPackage.cpp
4897 --- /dev/null 1 Jan 1970 00:00:00 -0000
4898 +++ rpm/xmlspec/XMLPackage.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
4900 +// standard C++ includes
4904 +#include "XMLPackage.h"
4905 +#include "XMLRPMWrap.h"
4906 +#include "XMLSpec.h"
4909 +#include <rpmlib.h>
4911 +// attribute structure for XMLPackage
4912 +structValidAttrs g_paPackageAttrs[] =
4914 + {0x0000, false, false, "name", XATTRTYPE_STRING, {"*", NULL}},
4915 + {0x0001, true, false, "group", XATTRTYPE_STRING, {"*", NULL}},
4916 + {0x0002, false, false, "autoreq", XATTRTYPE_BOOL, {NULL}},
4917 + {0x0003, false, false, "autoprov", XATTRTYPE_BOOL, {NULL}},
4918 + {0x0004, false, false, "autoreqprov", XATTRTYPE_BOOL, {NULL}},
4919 + {0x0005, false, false, "sub", XATTRTYPE_BOOL, {NULL}},
4920 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
4923 +bool XMLPackage::parseCreate(XMLAttrs* pAttrs,
4926 + // validate the attributes
4927 + if (!pAttrs->validate(g_paPackageAttrs, (XMLBase*)pSpec))
4930 + // setup the name attribute
4932 + if (pAttrs->asString("name"))
4933 + sName.assign(pAttrs->asString("name"));
4935 + // if we have a name, cool, now test if the package already exists
4936 + if (sName.length()) {
4937 + XMLPackage package(sName.c_str(), pAttrs->asString("group"),
4938 + pAttrs->asBool("autoreq") || pAttrs->asBool("autoreqprov"),
4939 + pAttrs->asBool("autoprov") || pAttrs->asBool("autoreqprov"),
4940 + pAttrs->asBool("sub"));
4941 + pSpec->addPackage(package);
4944 + // already something existing with %{name} ?
4946 + XMLPackage package(NULL, pAttrs->asString("group"),
4947 + pAttrs->asBool("autoreq") || pAttrs->asBool("autoreqprov"),
4948 + pAttrs->asBool("autoprov") || pAttrs->asBool("autoreqprov"),
4949 + pAttrs->asBool("sub"));
4950 + pSpec->addPackage(package);
4955 +bool XMLPackage::structCreate(PackageStruct* pPackage,
4959 + if (!pXSpec || !pSpec || !pPackage || !pPackage->header)
4962 + string sGroup, sName;
4963 + if (!getRPMHeader(pPackage->header, RPMTAG_GROUP, sGroup))
4965 + getRPMHeader(pPackage->header, RPMTAG_NAME, sName);
4966 + bool bSub = false;
4967 + if (sName.compare(pXSpec->getName()) == 0) {
4971 + XMLPackage package(bSub ? NULL : sName.c_str(), sGroup.c_str(),
4972 + pPackage->autoReq ? true : false,
4973 + pPackage->autoProv ? true : false,
4975 + t_StrVector svText;
4976 + t_StrVector svLang;
4977 + getRPMHeaderArray(pPackage->header, RPMTAG_HEADERI18NTABLE, svLang);
4978 + if (getRPMHeaderArray(pPackage->header, RPMTAG_SUMMARY, svText)) {
4979 + for (unsigned int i = 0; i < svText.size(); i++)
4980 + package.addSummary(svText[i].c_str(), svLang[i].c_str());
4982 + if (getRPMHeaderArray(pPackage->header, RPMTAG_DESCRIPTION, svText)) {
4983 + for (unsigned int i = 0; i < svText.size(); i++)
4984 + package.addDescription(svText[i].c_str(), svLang[i].c_str());
4986 + pXSpec->addPackage(package);
4988 + XMLPackageContainer::structCreate(pPackage, pSpec, pXSpec);
4989 + XMLFiles::structCreate(pPackage, pSpec, pXSpec);
4991 + // do the next package and return
4992 + XMLPackage::structCreate(pPackage->next, pSpec, pXSpec);
4996 +// attribute structure for summaries
4997 +structValidAttrs g_paDescriptionAttrs[] =
4999 + {0x0000, false, false, "lang", XATTRTYPE_STRING, {"*", NULL}},
5000 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
5003 +bool XMLPackage::addDescription(XMLAttrs* pAttrs,
5004 + const char* szDescription,
5007 + if (pSpec && pAttrs->validate(g_paDescriptionAttrs, (XMLBase*)pSpec)) {
5008 + pSpec->lastPackage().addDescription(szDescription, pAttrs->asString("lang"));
5015 +// attribute structure for summaries
5016 +structValidAttrs g_paSummaryAttrs[] =
5018 + {0x0000, false, false, "lang", XATTRTYPE_STRING, {"*", NULL}},
5019 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
5022 +bool XMLPackage::addSummary(XMLAttrs* pAttrs,
5023 + const char* szSummary,
5026 + if (pSpec && pAttrs->validate(g_paSummaryAttrs, (XMLBase*)pSpec)) {
5027 + pSpec->lastPackage().addSummary(szSummary, pAttrs->asString("lang"));
5034 +XMLPackage::XMLPackage(const char* szName,
5035 + const char* szGroup,
5042 + setGroup(szGroup);
5043 + setSubPackage(bSub);
5044 + setAutoRequires(bAutoReq);
5045 + setAutoProvides(bAutoProv);
5048 +XMLPackage::XMLPackage(const XMLPackage& rPackage)
5051 + setName(rPackage.m_sName.c_str());
5052 + setGroup(rPackage.m_sGroup.c_str());
5053 + setSubPackage(rPackage.m_bSub);
5054 + setAutoRequires(rPackage.m_bAutoReq);
5055 + setAutoProvides(rPackage.m_bAutoProv);
5056 + m_vSummaries = rPackage.m_vSummaries;
5057 + m_vDescriptions = rPackage.m_vDescriptions;
5058 + m_Requires = rPackage.m_Requires;
5059 + m_BuildRequires = rPackage.m_BuildRequires;
5060 + m_Provides = rPackage.m_Provides;
5061 + m_Obsoletes = rPackage.m_Obsoletes;
5062 + m_Post = rPackage.m_Post;
5063 + m_PostUn = rPackage.m_PostUn;
5064 + m_Pre = rPackage.m_Pre;
5065 + m_PreUn = rPackage.m_PreUn;
5066 + m_Verify = rPackage.m_Verify;
5067 + m_Files = rPackage.m_Files;
5070 +XMLPackage::~XMLPackage()
5074 +void XMLPackage::toSpecFile(ostream& rOut)
5076 + // top package bit
5078 + rOut << endl << "%package";
5079 + rOut << (!isSubPackage() ? " -n " : " ") << getName() << endl;
5082 + rOut << endl << endl;
5084 + for (unsigned int i = 0; i < numSummaries(); i++) {
5085 + rOut << "summary";
5086 + if (getSummary(i).hasLang())
5087 + rOut << "(" << getSummary(i).getLang() << "):";
5090 + rOut << " " << getSummary(i).getText() << endl;
5093 + rOut << "group: " << getGroup() << endl;
5094 + if (!hasAutoRequires() && !hasAutoProvides())
5095 + rOut << "autoreqprov: no" << endl;
5097 + if (!hasAutoRequires())
5098 + rOut << "autoreq: no" << endl;
5099 + if (!hasAutoProvides())
5100 + rOut << "autoprov: no" << endl;
5103 + getProvides().toSpecFile(rOut, "provides");
5104 + getObsoletes().toSpecFile(rOut, "obsoletes");
5105 + getRequires().toSpecFile(rOut, "requires");
5106 + getBuildRequires().toSpecFile(rOut, "buildrequires");
5108 + // add the description
5109 + for (unsigned int i = 0; i < numDescriptions(); i++) {
5110 + rOut << "%description ";
5111 + if (getDescription(i).hasLang())
5112 + rOut << "-l " << getDescription(i).getLang() << " ";
5114 + rOut << (!isSubPackage() ? "-n " : "");
5115 + rOut << getName();
5117 + rOut << endl << getDescription(i).getText() << endl;
5121 +void toSectionSpecFile(ostream& rOut,
5122 + const char* szSection,
5125 + rOut << endl << "%" << szSection;
5126 + if (pPkg->hasName())
5127 + rOut << (!pPkg->isSubPackage() ? " -n " : " ") << pPkg->getName();
5131 +void XMLPackage::toScriptsSpecFile(ostream& rOut)
5133 + if (getPre().numScripts()) {
5134 + toSectionSpecFile(rOut, "pre", this);
5135 + getPre().toSpecFile(rOut, "pre");
5138 + if (getPost().numScripts()) {
5139 + toSectionSpecFile(rOut, "post", this);
5140 + getPost().toSpecFile(rOut, "post");
5143 + if (getPreUn().numScripts()) {
5144 + toSectionSpecFile(rOut, "preun", this);
5145 + getPreUn().toSpecFile(rOut, "preun");
5148 + if (getPostUn().numScripts()) {
5149 + toSectionSpecFile(rOut, "postun", this);
5150 + getPostUn().toSpecFile(rOut, "postun");
5153 + if (getVerify().numScripts()) {
5154 + toSectionSpecFile(rOut, "verifyscript", this);
5155 + getVerify().toSpecFile(rOut, "verifyscript");
5159 +void XMLPackage::toFilesSpecFile(ostream& rOut)
5161 + rOut << endl << "%files";
5163 + rOut << (!isSubPackage() ? " -n " : " ") << getName();
5165 + getFiles().toSpecFile(rOut);
5168 +void XMLPackage::toXMLFile(ostream& rOut)
5170 + rOut << endl << "\t<package";
5172 + rOut << " name=\"" << getName() << "\"";
5173 + if (!isSubPackage())
5174 + rOut << " sub=\"no\"";
5177 + rOut << " group=\"" << getGroup() << "\"";
5178 + if (!hasAutoRequires() && !hasAutoProvides())
5179 + rOut << " autoreqprov=\"no\"";
5181 + if (!hasAutoRequires())
5182 + rOut << " autoreq=\"no\"";
5183 + if (!hasAutoProvides())
5184 + rOut << " autoprov=\"no\"";
5188 + for (unsigned int i = 0; i < numSummaries(); i++) {
5189 + rOut << endl << "\t\t<summary";
5190 + if (getSummary(i).hasLang())
5191 + rOut << " lang=\"" << getSummary(i).getLang() << "\"";
5192 + rOut << ">" << getSummary(i).getText() << "</summary>";
5194 + for (unsigned int i = 0; i < numDescriptions(); i++) {
5195 + rOut << endl << "\t\t<description";
5196 + if (getDescription(i).hasLang())
5197 + rOut << " lang=\"" << getDescription(i).getLang() << "\"";
5198 + rOut << ">" << getDescription(i).getText() << "</description>";
5201 + getProvides().toXMLFile(rOut, "provides");
5202 + getObsoletes().toXMLFile(rOut, "obsoletes");
5203 + getRequires().toXMLFile(rOut, "requires");
5204 + getBuildRequires().toXMLFile(rOut, "buildrequires");
5206 + getPre().toXMLFile(rOut, "pre");
5207 + getPost().toXMLFile(rOut, "post");
5208 + getPreUn().toXMLFile(rOut, "preun");
5209 + getPostUn().toXMLFile(rOut, "postun");
5210 + getVerify().toXMLFile(rOut, "verify");
5212 + getFiles().toXMLFile(rOut);
5214 + rOut << endl << "\t</package>";
5217 +void XMLPackage::toRPMStruct(Spec spec)
5219 + //Package pkg = newPackage(spec);
5220 + //if (!hasName() && pkg == spec->packages)
5221 + // fillOutMainPackage(pkg->header);
5222 + //else if (pkg != spec->packages)
5223 + // headerCopyTags(spec->packages->header,
5225 + // (int_32 *)copyTagsDuringParse);
5227 Index: xmlspec/XMLPackage.h
5228 ===================================================================
5229 RCS file: xmlspec/XMLPackage.h
5230 diff -N xmlspec/XMLPackage.h
5231 --- /dev/null 1 Jan 1970 00:00:00 -0000
5232 +++ rpm/xmlspec/XMLPackage.h 28 Aug 2002 10:52:43 -0000 1.3.2.1
5234 +#ifndef _H_XMLPACKAGE_
5235 +#define _H_XMLPACKAGE_
5237 +// standard C++ includes
5238 +#include <iostream>
5242 +// standard includes
5246 +#include "XMLAttrs.h"
5247 +#include "XMLBase.h"
5248 +#include "XMLFiles.h"
5249 +#include "XMLRequires.h"
5250 +#include "XMLScript.h"
5251 +#include "XMLText.h"
5254 +#include <rpmbuild.h>
5256 +// forward class declarations
5259 +using namespace std;
5261 +class XMLPackage : public XMLBase
5264 +// factory functions
5268 + * Creates an object as parsed from an XML spec
5270 + * @param pAttrs XML atrtributes to use
5271 + * @param pSpec The spec to which we are adding this object to
5272 + * @return true on success, false otherwise
5274 + static bool parseCreate(XMLAttrs* pAttrs,
5278 + * Creates package objects from an RPM Spec structure
5280 + * @param pPackage Pointer to the start package
5281 + * @param pSpec pointer to the RPM spec
5282 + * @param pXSpec Pointer to the spec object to populate
5283 + * @return true on success, false otherwise
5285 + static bool structCreate(PackageStruct* pPackage,
5290 + * Adds a description for the last package
5292 + * @param pAttrs The attributes
5293 + * @param szDescription the description
5294 + * @param pSpec The spec containing the package
5295 + * @return true on success, false otherwise
5297 + static bool addDescription(XMLAttrs* pAttrs,
5298 + const char* szDescription,
5302 + * Adds the summary for the last added package
5304 + * @param pAttrs The attributes
5305 + * @param szSummary The summary to set
5306 + * @param pSpec The spec contraining the package
5307 + * @return trus on success, false otherwise
5309 + static bool addSummary(XMLAttrs* pAttrs,
5310 + const char* szSummary,
5314 +// constructors/destructors
5318 + * Default constructor
5320 + * @param szName The package name
5321 + * @param szGroup The group this package belongs to
5322 + * @param bAutoReq Auto Requires
5323 + * @param bAutoProv Auto Provides
5324 + * @param bSub true if this is a sub-package
5327 + XMLPackage(const char* szName,
5328 + const char* szGroup,
5334 + * Copy constructor
5336 + * @param rPackage The package to copy from
5339 + XMLPackage(const XMLPackage& rPackage);
5350 +// public member functions
5354 + * Converts the object to a spec file
5356 + * @param rOut Output stream
5359 + void toSpecFile(ostream& rOut);
5362 + * Converts the scripts part of the object to a spec
5364 + * @param rOut Output stream
5367 + void toScriptsSpecFile(ostream& rOut);
5370 + * Converts the files part of the object to a spec
5372 + * @param rOut Output stream
5375 + void toFilesSpecFile(ostream& rOut);
5378 + * Converts the object to an XML spec
5380 + * @param rOut The output stream
5383 + void toXMLFile(ostream& rOut);
5386 + * Converts the object to an RPM structure
5388 + * @param Spec The main Spec object
5391 + void toRPMStruct(Spec spec);
5394 +// member variable get/set functions
5398 + * Checks of we have a package name
5401 + * @return true if we have a name, false otherwise
5405 + return m_sName.length() ? true : false;
5409 + * Gets the package name
5412 + * @return string containing the package name
5414 + const char* getName()
5416 + return m_sName.c_str();
5420 + * Sets the package name
5422 + * @param szName The name to set
5425 + void setName(const char* szName)
5428 + m_sName.assign(szName);
5432 + * Checks if we have a group
5435 + * @return true if we have a group, false otherwise
5439 + return m_sGroup.length() ? true : false;
5443 + * Returns the group
5446 + * @return string containing the group
5448 + const char* getGroup()
5450 + return m_sGroup.c_str();
5456 + * @param szGroup The group to set
5459 + void setGroup(const char* szGroup)
5462 + m_sGroup.assign(szGroup);
5466 + * Tests if we are a sub-package
5469 + * @return true if this is a sub-package
5471 + bool isSubPackage()
5477 + * Sets the sub-package status
5479 + * @param bSub The sub-package status
5482 + void setSubPackage(bool bSub)
5488 + * Tests for auto requires
5491 + * @return true if we have auto requires, false otherwise
5493 + bool hasAutoRequires()
5495 + return m_bAutoReq;
5499 + * Sets the auto requires state
5501 + * @param bAutoReq The auto requires state
5504 + void setAutoRequires(bool bAutoReq)
5506 + m_bAutoReq = bAutoReq;
5510 + * Tests for auto requires
5513 + * @return true if we have auto requires, false otherwise
5515 + bool hasAutoProvides()
5517 + return m_bAutoProv;
5521 + * Sets the auto provides status
5523 + * @param bAutoProv The auto provides status
5526 + void setAutoProvides(bool bAutoProv)
5528 + m_bAutoProv = bAutoProv;
5532 + * Gets the number of summaries
5535 + * @return the number of summaries
5537 + unsigned int numSummaries()
5539 + return m_vSummaries.size();
5545 + * @param nNum The number to get
5546 + * @return the summary
5548 + XMLText& getSummary(unsigned int nNum)
5550 + return m_vSummaries[nNum];
5556 + * @param szSummary the summary
5557 + * @param szLang the language
5560 + void addSummary(const char* szSummary,
5561 + const char* szLang = NULL)
5563 + if (szSummary && strlen(szSummary)) {
5564 + XMLText summary(szSummary, szLang);
5565 + m_vSummaries.push_back(summary);
5570 + * Gets the number of descriptions
5573 + * @return the number in our list
5575 + unsigned int numDescriptions()
5577 + return m_vDescriptions.size();
5581 + * Get a description
5583 + * @param nNum The description to get
5584 + * @return Reference to XMLText object
5586 + XMLText& getDescription(unsigned int nNum)
5588 + return m_vDescriptions[nNum];
5592 + * Adds a description
5594 + * @param szDescription The description string
5595 + * @param szLang The language
5598 + void addDescription(const char* szDescription,
5599 + const char* szLang = NULL)
5601 + if (szDescription && strlen(szDescription)) {
5602 + XMLText description(szDescription, szLang);
5603 + m_vDescriptions.push_back(description);
5608 + * Gets the provides
5611 + * @return reference to the provides
5613 + XMLPackageContainer& getProvides()
5615 + return m_Provides;
5619 + * Gets the package requires
5622 + * @return reference to the requires
5624 + XMLPackageContainer& getRequires()
5626 + return m_Requires;
5630 + * Get the buildrequires
5633 + * @return reference to the buildrequires
5635 + XMLPackageContainer& getBuildRequires()
5637 + return m_BuildRequires;
5641 + * Gets the obsoletes
5644 + * @return reference to the obsoletes
5646 + XMLPackageContainer& getObsoletes()
5648 + return m_Obsoletes;
5655 + * @return reference to the files
5657 + XMLFiles& getFiles()
5663 + * Gets the pre section
5666 + * @return reference to the pre section
5668 + XMLPackageScripts& getPre()
5674 + * Gets the post section
5677 + * @return reference to the post section
5679 + XMLPackageScripts& getPost()
5685 + * Gets the preun section
5688 + * @return reference to the preun section
5690 + XMLPackageScripts& getPreUn()
5696 + * Gets the postun section
5699 + * @return reference to the postun section
5701 + XMLPackageScripts& getPostUn()
5707 + * Gets the verify section
5710 + * @return reference to the verify section
5712 + XMLPackageScripts& getVerify()
5718 +// member variables
5726 + vector<XMLText> m_vSummaries;
5727 + vector<XMLText> m_vDescriptions;
5728 + XMLPackageContainer m_Requires;
5729 + XMLPackageContainer m_BuildRequires;
5730 + XMLPackageContainer m_Provides;
5731 + XMLPackageContainer m_Obsoletes;
5732 + XMLPackageScripts m_Pre;
5733 + XMLPackageScripts m_PreUn;
5734 + XMLPackageScripts m_Post;
5735 + XMLPackageScripts m_PostUn;
5736 + XMLPackageScripts m_Verify;
5741 Index: xmlspec/XMLParser.cpp
5742 ===================================================================
5743 RCS file: xmlspec/XMLParser.cpp
5744 diff -N xmlspec/XMLParser.cpp
5745 --- /dev/null 1 Jan 1970 00:00:00 -0000
5746 +++ rpm/xmlspec/XMLParser.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
5748 +// standard library includes
5749 +#include <stdarg.h>
5751 +#include <stdlib.h>
5753 +// standard C++ includes
5757 +// 3rd party library includes
5761 +#include "XMLSpec.h"
5763 +// this is the maximum tree dept we will require as
5764 +// well as the number of scructures a specific tag can
5766 +#define XML_MAX_TREE_DEPTH 5
5767 +#define XML_MAX_PRE_TAGS 10
5769 +using namespace std;
5771 +// these define the error values
5774 + XMLERR_WARNING = 0x0000,
5779 +// this defines the structure that we are using in the callback
5780 +// containing all the parse-specific data we might need.
5781 +struct structCBData
5783 + XML_Parser* m_pParser;
5784 + string m_sFilename;
5788 + unsigned int m_pnTree[XML_MAX_TREE_DEPTH];
5791 + XMLAttrs* m_pAttrs;
5794 +// enumeration of all XML tags that are recognised
5795 +enum enumXMLTAGValid
5802 + XTAG_EXCLUSIVEARCH,
5832 + XTAG_ANY = 0xFFFF // this always needs to be the last entry
5835 +// this is a structure to match tags to their values
5836 +struct structXMLMatch
5838 + unsigned int m_nVal;
5839 + int m_pnDepth[XML_MAX_TREE_DEPTH+1];
5840 + unsigned int m_pnFollows[XML_MAX_PRE_TAGS+1];
5844 +// this allows for the matching of all tags
5845 +structXMLMatch g_pMatches[] =
5848 + XTAG_SPEC, { 0, -1, -1}, {
5855 + XTAG_PACKAGE, { 1, 3, -1}, {
5866 + XTAG_SOURCE, { 1, -1, -1}, {
5873 + XTAG_PATCH, { 1, 2, -1}, {
5881 + XTAG_NOSOURCE, { 1, -1, -1}, {
5888 + XTAG_MIRROR, { 2, -1, -1}, {
5895 + XTAG_SUMMARY, { 2, -1, -1}, {
5902 + XTAG_DESC, { 2, -1, -1}, {
5909 + XTAG_REQS, { 2, -1, -1}, {
5916 + XTAG_BREQS, { 2, -1, -1}, {
5923 + XTAG_PROVS, { 2, -1, -1}, {
5930 + XTAG_OBSOLS, { 2, -1, -1}, {
5937 + XTAG_FILES, { 2, -1, -1}, {
5944 + XTAG_FILE, { 3, -1, -1}, {
5951 + XTAG_MACRO, { 1, -1, -1}, {
5958 + XTAG_PREP, { 1, -1, -1}, {
5965 + XTAG_SETUP, { 2, -1, -1}, {
5972 + XTAG_BUILD, { 1, -1, -1}, {
5979 + XTAG_INSTALL, { 1, -1, -1}, {
5986 + XTAG_CLEAN, { 1, -1, -1}, {
5993 + XTAG_PRE, { 2, -1, -1}, {
6000 + XTAG_POST, { 2, -1, -1}, {
6007 + XTAG_PREUN, { 2, -1, -1}, {
6014 + XTAG_POSTUN, { 2, -1, -1}, {
6021 + XTAG_VERIFY, { 2, -1, -1}, {
6028 + XTAG_SCRIPT, { 2, 3, -1}, {
6043 + XTAG_CHANGELOG, { 1, -1, -1}, {
6050 + XTAG_CHANGES, { 2, -1, -1}, {
6057 + XTAG_CHANGE, { 3, -1, -1}, {
6063 + // this always needs to be the last entry
6065 + XTAG_NO, {-1, -1, -1}, {
6072 +const char* treeToString(unsigned int* pnTree,
6075 + // internal string storage
6078 + // build the tree to the specified depth
6079 + for (int i = 0; i < nDepth; i++) {
6081 + while (g_pMatches[j].m_nVal != pnTree[i])
6083 + sTree += string("<") + string(g_pMatches[j].m_szName) + string(">");
6086 + // return the tree string
6087 + return sTree.c_str();
6090 +unsigned int getTagValue(const char* szElement,
6092 + unsigned int nPrev)
6094 + // first convert the tag to a tag value
6095 + unsigned int nTagVal = XTAG_NO;
6097 + // loop through all matches to see if we have a valid
6101 + // test if we have a match
6102 + if (strcasecmp(g_pMatches[i].m_szName, szElement) == 0) {
6103 + // look for a match on the tree depth
6105 + nTagVal = XTAG_WRONGSTRUCT;
6106 + while (g_pMatches[i].m_pnDepth[j] != -1) {
6107 + if (g_pMatches[i].m_pnDepth[j++] == nDepth) {
6110 + if (g_pMatches[i].m_pnFollows[j] == nPrev) {
6111 + nTagVal = g_pMatches[i].m_nVal;
6114 + } while (g_pMatches[i].m_pnFollows[++j] != XTAG_NO);
6121 + } while (g_pMatches[++i].m_nVal != XTAG_NO);
6127 +void createError(int nErrType,
6128 + structCBData* pData,
6129 + const char* szFormat, ...)
6131 + // one more error/warning
6132 + nErrType == XMLERR_WARNING ? pData->m_nWarnings++ : pData->m_nErrors++;
6134 + // setup internal variables
6135 + FILE* fOut = stderr;
6136 + switch (nErrType) {
6137 + case XMLERR_WARNING:
6139 + fprintf(fOut, "%s(%d): warning: ", pData->m_sFilename.c_str(),
6140 + XML_GetCurrentLineNumber(*(pData->m_pParser)));
6142 + case XMLERR_ERROR:
6143 + fprintf(fOut, "%s(%d): error: ", pData->m_sFilename.c_str(),
6144 + XML_GetCurrentLineNumber(*(pData->m_pParser)));
6146 + case XMLERR_FATAL:
6147 + fprintf(fOut, "%s(%d): fatal: ", pData->m_sFilename.c_str(),
6148 + XML_GetCurrentLineNumber(*(pData->m_pParser)));
6154 + // create the argument list and print
6155 + va_list vaArgList;
6156 + va_start(vaArgList, szFormat);
6157 + vfprintf(fOut, szFormat, vaArgList);
6158 + fprintf(fOut, "\n");
6161 +void startDepth0(structCBData* pData)
6163 + // this indicates a spec start
6164 + if (pData->m_pnTree[0] == XTAG_SPEC) {
6165 + // if we have a spec already, we are in trouble
6166 + if (pData->m_pSpec)
6167 + createError(XMLERR_ERROR, pData, "Extra 'spec' tag found.");
6168 + else if (!(pData->m_pSpec = XMLSpec::parseCreate(pData->m_pAttrs,
6169 + pData->m_sFilename.c_str())))
6170 + createError(XMLERR_ERROR, pData,
6171 + "Failed to parse 'spec' tag (%s).",
6172 + pData->m_pAttrs->getError());
6173 + else if (pData->m_pAttrs->hasWarning())
6174 + createError(XMLERR_WARNING, pData, pData->m_pAttrs->getWarning());
6178 +void startDepth1(structCBData* pData)
6180 + // make sure we have a spec
6181 + if (!pData->m_pSpec) {
6182 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6187 + switch (pData->m_pnTree[1]) {
6188 + case XTAG_PACKAGE:
6189 + if (!XMLPackage::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6190 + createError(XMLERR_ERROR, pData,
6191 + "Failed to parse 'package' tag or package already exists (%s).",
6192 + pData->m_pSpec->getError());
6193 + else if (pData->m_pSpec->hasWarning())
6194 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6197 + if (!XMLSource::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6198 + createError(XMLERR_ERROR, pData,
6199 + "Failed to parse 'source' tag (%s).",
6200 + pData->m_pSpec->getError());
6201 + else if (pData->m_pSpec->hasWarning())
6202 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6205 + if (!XMLPatch::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6206 + createError(XMLERR_ERROR, pData,
6207 + "Failed to parse 'patch' tag (%s).",
6208 + pData->m_pSpec->getError());
6209 + else if (pData->m_pSpec->hasWarning())
6210 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6212 + case XTAG_NOSOURCE:
6213 + if (!XMLNoSource::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6214 + createError(XMLERR_ERROR, pData,
6215 + "Failed to parse 'nosource' tag (%s).",
6216 + pData->m_pSpec->getError());
6217 + else if (pData->m_pSpec->hasWarning())
6218 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6220 + case XTAG_CHANGELOG:
6223 + case XTAG_INSTALL:
6230 +void startDepth2(structCBData* pData)
6232 + // make sure we have a spec
6233 + if (!pData->m_pSpec) {
6234 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6239 + switch (pData->m_pnTree[2]) {
6241 + switch (pData->m_pnTree[1]) {
6243 + if (!XMLMirror::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6244 + createError(XMLERR_ERROR, pData,
6245 + "Failed to parse 'mirror' tag (%s).",
6246 + pData->m_pSpec->getError());
6247 + else if (pData->m_pSpec->hasWarning())
6248 + createError(XMLERR_WARNING, pData,
6249 + pData->m_pSpec->getWarning());
6252 + if (!XMLMirror::parseCreate(pData->m_pAttrs, pData->m_pSpec, true))
6253 + createError(XMLERR_ERROR, pData,
6254 + "Failed to parse 'mirror' tag (%s).",
6255 + pData->m_pSpec->getError());
6256 + else if (pData->m_pSpec->hasWarning())
6257 + createError(XMLERR_WARNING, pData,
6258 + pData->m_pSpec->getWarning());
6263 + if (!XMLFiles::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6264 + createError(XMLERR_ERROR, pData,
6265 + "Failed to parse 'change' tag (%s).",
6266 + pData->m_pSpec->getError());
6267 + else if (pData->m_pSpec->hasWarning())
6268 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6270 + case XTAG_CHANGES:
6271 + if (!XMLChangelogDate::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6272 + createError(XMLERR_ERROR, pData,
6273 + "Failed to parse 'change' tag (%s).",
6274 + pData->m_pSpec->getError());
6275 + else if (pData->m_pSpec->hasWarning())
6276 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6279 + if (!XMLPackageScripts::createPreScripts(pData->m_pAttrs, pData->m_pSpec))
6280 + createError(XMLERR_ERROR, pData,
6281 + "Failed to parse 'pre' tag (%s).",
6282 + pData->m_pSpec->getError());
6283 + else if (pData->m_pSpec->hasWarning())
6284 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6287 + if (!XMLPackageScripts::createPostScripts(pData->m_pAttrs, pData->m_pSpec))
6288 + createError(XMLERR_ERROR, pData,
6289 + "Failed to parse 'pre' tag (%s).",
6290 + pData->m_pSpec->getError());
6291 + else if (pData->m_pSpec->hasWarning())
6292 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6295 + if (!XMLPackageScripts::createPreUnScripts(pData->m_pAttrs, pData->m_pSpec))
6296 + createError(XMLERR_ERROR, pData,
6297 + "Failed to parse 'pre' tag (%s).",
6298 + pData->m_pSpec->getError());
6299 + else if (pData->m_pSpec->hasWarning())
6300 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6303 + if (!XMLPackageScripts::createPostUnScripts(pData->m_pAttrs, pData->m_pSpec))
6304 + createError(XMLERR_ERROR, pData,
6305 + "Failed to parse 'pre' tag (%s).",
6306 + pData->m_pSpec->getError());
6307 + else if (pData->m_pSpec->hasWarning())
6308 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6311 + if (!XMLPackageScripts::createVerifyScripts(pData->m_pAttrs, pData->m_pSpec))
6312 + createError(XMLERR_ERROR, pData,
6313 + "Failed to parse 'pre' tag (%s).",
6314 + pData->m_pSpec->getError());
6315 + else if (pData->m_pSpec->hasWarning())
6316 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6327 +void startDepth3(structCBData* pData)
6329 + // make sure we have a spec
6330 + if (!pData->m_pSpec) {
6331 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6336 + switch (pData->m_pnTree[3]) {
6337 + case XTAG_PACKAGE:
6338 + switch (pData->m_pnTree[2]) {
6340 + if (!XMLPackageContainer::addRequire(pData->m_pAttrs,
6342 + createError(XMLERR_ERROR, pData,
6343 + "Failed to parse 'package' tag (%s).",
6344 + pData->m_pSpec->getError());
6345 + else if (pData->m_pSpec->hasWarning())
6346 + createError(XMLERR_WARNING, pData,
6347 + pData->m_pSpec->getWarning());
6350 + if (!XMLPackageContainer::addBuildRequire(pData->m_pAttrs,
6352 + createError(XMLERR_ERROR, pData,
6353 + "Failed to parse 'package' tag (%s).",
6354 + pData->m_pSpec->getError());
6355 + else if (pData->m_pSpec->hasWarning())
6356 + createError(XMLERR_WARNING, pData,
6357 + pData->m_pSpec->getWarning());
6360 + if (!XMLPackageContainer::addProvide(pData->m_pAttrs,
6362 + createError(XMLERR_ERROR, pData,
6363 + "Failed to parse 'package' tag (%s).",
6364 + pData->m_pSpec->getError());
6365 + else if (pData->m_pSpec->hasWarning())
6366 + createError(XMLERR_WARNING, pData,
6367 + pData->m_pSpec->getWarning());
6370 + if (!XMLPackageContainer::addObsolete(pData->m_pAttrs,
6372 + createError(XMLERR_ERROR, pData,
6373 + "Failed to parse 'package' tag (%s).",
6374 + pData->m_pSpec->getError());
6375 + else if (pData->m_pSpec->hasWarning())
6376 + createError(XMLERR_WARNING, pData,
6377 + pData->m_pSpec->getWarning());
6388 +void startElementCB(void* pCBData,
6389 + const char* szElement,
6390 + const char** szAttr)
6392 + // get the data structure we are working with and
6393 + structCBData* pData = (structCBData*)pCBData;
6395 + // validate and get the tag we are working with
6396 + unsigned int nTag = getTagValue(szElement,
6398 + pData->m_nDepth ? pData->m_pnTree[pData->m_nDepth-1] : XTAG_ANY);
6400 + if (nTag == XTAG_NO || nTag == XTAG_WRONGSTRUCT)
6401 + return createError(XMLERR_WARNING, pData, "Unexpected tag '%s' in structure '%s'.",
6403 + treeToString(pData->m_pnTree, pData->m_nDepth++));
6404 + pData->m_pnTree[pData->m_nDepth] = nTag;
6405 + pData->m_sData.assign("");
6407 + if (pData->m_pAttrs)
6408 + delete pData->m_pAttrs;
6409 + pData->m_pAttrs = new XMLAttrs(szAttr);
6411 + switch (pData->m_nDepth++) {
6413 + startDepth0(pData);
6416 + startDepth1(pData);
6419 + startDepth2(pData);
6422 + startDepth3(pData);
6429 +void endDepth1(structCBData* pData)
6431 + // make sure we have a spec
6432 + if (!pData->m_pSpec) {
6433 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6438 + switch (pData->m_pnTree[1]) {
6440 + if (!XMLMacro::parseCreate(pData->m_pAttrs,
6441 + pData->m_sData.c_str(),
6443 + createError(XMLERR_ERROR, pData,
6444 + "Failed to add macro entry (%s).",
6445 + pData->m_pAttrs->getError());
6446 + else if (pData->m_pSpec->hasWarning())
6447 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6454 +void endDepth2(structCBData* pData)
6456 + // make sure we have a spec
6457 + if (!pData->m_pSpec) {
6458 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6463 + switch (pData->m_pnTree[2]) {
6464 + case XTAG_SUMMARY:
6465 + if (!XMLPackage::addSummary(pData->m_pAttrs, pData->m_sData.c_str(),
6467 + createError(XMLERR_ERROR, pData,
6468 + "Failed to add 'summary'.");
6471 + if (!XMLPackage::addDescription(pData->m_pAttrs, pData->m_sData.c_str(),
6473 + createError(XMLERR_ERROR, pData,
6474 + "Failed to add 'description'.");
6477 + switch (pData->m_pnTree[1]) {
6479 + if (!XMLScripts::addPrepScript(pData->m_pAttrs,
6480 + pData->m_sData.c_str(),
6482 + createError(XMLERR_ERROR, pData,
6483 + "Failed to add shell entry.");
6486 + if (!XMLScripts::addBuildScript(pData->m_pAttrs,
6487 + pData->m_sData.c_str(),
6489 + createError(XMLERR_ERROR, pData,
6490 + "Failed to add shell entry.");
6492 + case XTAG_INSTALL:
6493 + if (!XMLScripts::addInstallScript(pData->m_pAttrs,
6494 + pData->m_sData.c_str(),
6496 + createError(XMLERR_ERROR, pData,
6497 + "Failed to add shell entry.");
6500 + if (!XMLScripts::addCleanScript(pData->m_pAttrs,
6501 + pData->m_sData.c_str(),
6503 + createError(XMLERR_ERROR, pData,
6504 + "Failed to add shell entry.");
6515 +void endDepth3(structCBData* pData)
6517 + // make sure we have a spec
6518 + if (!pData->m_pSpec) {
6519 + createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6524 + switch (pData->m_pnTree[3]) {
6526 + if (!XMLChangelogEntry::parseCreate(pData->m_pAttrs,
6527 + pData->m_sData.c_str(),
6529 + createError(XMLERR_ERROR, pData,
6530 + "Failed to add changelog entry.");
6531 + else if (pData->m_pSpec->hasWarning())
6532 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6535 + if (!XMLFile::parseCreate(pData->m_pAttrs,
6536 + pData->m_sData.c_str(),
6538 + createError(XMLERR_ERROR, pData, "Failed to parse 'file' tag (%s).",
6539 + pData->m_pSpec->getError());
6540 + else if (pData->m_pSpec->hasWarning())
6541 + createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6544 + switch (pData->m_pnTree[2]) {
6546 + if (!XMLPackageScripts::addPreScript(pData->m_pAttrs,
6547 + pData->m_sData.c_str(),
6549 + createError(XMLERR_ERROR, pData,
6550 + "Failed to parse 'script' tag (%s).",
6551 + pData->m_pSpec->getError());
6552 + else if (pData->m_pSpec->hasWarning())
6553 + createError(XMLERR_WARNING, pData,
6554 + pData->m_pSpec->getWarning());
6557 + if (!XMLPackageScripts::addPostScript(pData->m_pAttrs,
6558 + pData->m_sData.c_str(),
6560 + createError(XMLERR_ERROR, pData,
6561 + "Failed to parse 'script' tag (%s).",
6562 + pData->m_pSpec->getError());
6563 + else if (pData->m_pSpec->hasWarning())
6564 + createError(XMLERR_WARNING, pData,
6565 + pData->m_pSpec->getWarning());
6568 + if (!XMLPackageScripts::addPreUnScript(pData->m_pAttrs,
6569 + pData->m_sData.c_str(),
6571 + createError(XMLERR_ERROR, pData,
6572 + "Failed to parse 'script' tag (%s).",
6573 + pData->m_pSpec->getError());
6574 + else if (pData->m_pSpec->hasWarning())
6575 + createError(XMLERR_WARNING, pData,
6576 + pData->m_pSpec->getWarning());
6579 + if (!XMLPackageScripts::addPostUnScript(pData->m_pAttrs,
6580 + pData->m_sData.c_str(),
6582 + createError(XMLERR_ERROR, pData,
6583 + "Failed to parse 'script' tag (%s).",
6584 + pData->m_pSpec->getError());
6585 + else if (pData->m_pSpec->hasWarning())
6586 + createError(XMLERR_WARNING, pData,
6587 + pData->m_pSpec->getWarning());
6590 + if (!XMLPackageScripts::addVerifyScript(pData->m_pAttrs,
6591 + pData->m_sData.c_str(),
6593 + createError(XMLERR_ERROR, pData,
6594 + "Failed to parse 'script' tag (%s).",
6595 + pData->m_pSpec->getError());
6596 + else if (pData->m_pSpec->hasWarning())
6597 + createError(XMLERR_WARNING, pData,
6598 + pData->m_pSpec->getWarning());
6609 +void endElementCB(void* pCBData,
6610 + const char* szElement)
6612 + // get the data structure we are working with
6613 + structCBData* pData = (structCBData*)pCBData;
6614 + pData->m_nDepth--;
6616 + // validate and get the tag we are working with
6617 + unsigned int nTag = getTagValue(szElement,
6619 + pData->m_nDepth ? pData->m_pnTree[pData->m_nDepth-1] : XTAG_ANY);
6620 + if (nTag == XTAG_NO || nTag == XTAG_WRONGSTRUCT)
6623 + // handle the tree depth
6624 + switch (pData->m_nDepth) {
6641 + pData->m_sData.assign("");
6644 +void characterCB(void* pCBData,
6645 + const char* szStr,
6648 + // get the data structure we are working with
6649 + structCBData* pData = (structCBData*)pCBData;
6651 + // append the string to our internal data
6653 + char* szTmp = new char[nLen+1];
6654 + strncpy(szTmp, szStr, nLen);
6655 + szTmp[nLen] = '\0';
6656 + pData->m_sData.append(szTmp);
6661 +int parseXMLSpec(const char* szXMLFilename,
6664 + // create and setup our parser for use
6665 + printf("Creating XML parser instance ... ");
6666 + XML_Parser parser = XML_ParserCreate(NULL);
6668 + printf("Failed.\n\tERROR: Couldn't allocate memory for parser\n\n");
6673 + XML_SetElementHandler(parser, startElementCB, endElementCB);
6674 + XML_SetCharacterDataHandler(parser, characterCB);
6675 + structCBData stData;
6676 + stData.m_pParser = &parser;
6677 + stData.m_sFilename.assign(szXMLFilename);
6678 + stData.m_nWarnings = 0;
6679 + stData.m_nErrors = 0;
6680 + stData.m_nDepth = 0;
6681 + stData.m_pSpec = NULL;
6682 + stData.m_pAttrs = NULL;
6683 + XML_SetUserData(parser, (void*)&stData);
6685 + // open the input and output files here
6686 + printf("Opening input XML spec ... ");
6687 + ifstream fIn(szXMLFilename);
6688 + if (!fIn.is_open()) {
6689 + printf("Failed.\n\tERROR: Could not open %s\n\n", szXMLFilename);
6695 + // parse our configuration (loop through file,
6696 + // doing a break if needed (fatal error))
6697 + printf("Parsing %s: \n", szXMLFilename);
6698 + char szBuff[1024+1];
6699 + unsigned int nLength = 0;
6700 + while (!fIn.eof()) {
6701 + fIn.get(szBuff, 1024, '\0');
6702 + unsigned int nRead = strlen(szBuff);
6704 + if (!XML_Parse(parser, szBuff, nRead, fIn.eof() ? 1 : 0)) {
6705 + createError(XMLERR_FATAL, &stData, "XML parsing: %s",
6706 + XML_ErrorString(XML_GetErrorCode(parser)));
6711 + // print the end results
6712 + printf("\t%d bytes parsed, %d errors(s), %d warnings(s)\n",
6713 + nLength, stData.m_nErrors, stData.m_nWarnings);
6714 + printf("Closing input XML spec ... ");
6719 + if (stData.m_nErrors) {
6720 + if (stData.m_pSpec != NULL)
6721 + delete stData.m_pSpec;
6725 + pSpec = stData.m_pSpec;
6727 + // return number of errors
6728 + return stData.m_nErrors;
6730 Index: xmlspec/XMLParser.h
6731 ===================================================================
6732 RCS file: xmlspec/XMLParser.h
6733 diff -N xmlspec/XMLParser.h
6734 --- /dev/null 1 Jan 1970 00:00:00 -0000
6735 +++ rpm/xmlspec/XMLParser.h 28 Aug 2002 10:52:43 -0000 1.1.1.1.2.1
6737 +#ifndef _H_XMLPARSER_
6738 +#define _H_XMLPARSER_
6741 +#include "XMLSpec.h"
6744 + * Parses an XML spec into the internal data structures as
6745 + * defined in the XML* classes.
6747 + * @param szXMLFilename The Spec to read as parser input
6748 + * @param pSpec A reference to the spec data structure we
6750 + * @return The number of parsing/other errors (0 == success)
6752 +extern int parseXMLSpec(const char* szXMLFilename,
6756 Index: xmlspec/XMLRPMWrap.cpp
6757 ===================================================================
6758 RCS file: xmlspec/XMLRPMWrap.cpp
6759 diff -N xmlspec/XMLRPMWrap.cpp
6760 --- /dev/null 1 Jan 1970 00:00:00 -0000
6761 +++ rpm/xmlspec/XMLRPMWrap.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
6763 +// standard c++ includes
6768 +#include <rpmlib.h>
6769 +#include <rpmbuild.h>
6771 +// type definitions
6772 +typedef vector<string> t_StrVector;
6774 +using namespace std;
6776 +bool getRPMHeader(Header header,
6780 + if (headerIsEntry(header, nTag)) {
6781 + int_32 nCount, nTagType;
6783 + if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount))
6786 + switch (nTagType) {
6787 + case RPM_INT32_TYPE:
6788 + sprintf(szTemp, "%d", *((int_32*)pBuffer));
6789 + rResult.assign(szTemp);
6791 + rResult.assign((char*)pBuffer);
6794 + headerFreeData(pBuffer, (rpmTagType_e)nTagType);
6801 +bool getRPMHeaderArray(Header header,
6803 + t_StrVector& rvResult)
6806 + if (headerIsEntry(header, nTag)) {
6807 + int_32 nCount, nTagType;
6809 + if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount))
6811 + if (nTagType == RPM_STRING_ARRAY_TYPE || nTagType == RPM_I18NSTRING_TYPE) {
6812 + for (int_32 i = 0; i < nCount; i++)
6813 + rvResult.push_back(((char**)pBuffer)[i]);
6816 + rvResult.push_back((char*)pBuffer);
6817 + headerFreeData(pBuffer, (rpmTagType_e)nTagType);
6824 +bool getRPMMacro(const char* szMacro,
6827 + char* szValue = rpmExpand(szMacro, NULL);
6829 + rResult.assign(szValue);
6835 Index: xmlspec/XMLRPMWrap.h
6836 ===================================================================
6837 RCS file: xmlspec/XMLRPMWrap.h
6838 diff -N xmlspec/XMLRPMWrap.h
6839 --- /dev/null 1 Jan 1970 00:00:00 -0000
6840 +++ rpm/xmlspec/XMLRPMWrap.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
6842 +#ifndef _H_XMLRPMWRAP_
6843 +#define _H_XMLRPMWRAP_
6845 +// standard C++ includes
6850 +#include <rpmlib.h>
6852 +// type definitions
6853 +typedef vector<string> t_StrVector;
6856 + * Gets an RPM header after checking that is does exist.
6858 + * @param header The RPM header to interrogate
6859 + * @param nTag The header tag to extract
6860 + * @param rResult The string to populate with the result
6861 + * @return true on success, false otherwise
6863 +extern bool getRPMHeader(Header header,
6865 + std::string& rResult);
6868 + * Gets an RPM header array into a vector after checking that it
6869 + * does indeed exist
6871 + * @param header The RPM header to interrogate
6872 + * @param nTag The header tag to extract
6873 + * @param rvResult The vector<string> to populate with the result
6874 + * @return true on success, false otherwise
6876 +extern bool getRPMHeaderArray(Header header,
6878 + t_StrVector& rvResult);
6881 + * Gets a specific RPM macro
6883 + * @param szMacro The macro to get the value of
6884 + * @param rResult The string to populate with the result
6885 + * @return true on success, false otherwise
6887 +extern bool getRPMMacro(const char* szMacro,
6888 + std::string& rResult);
6891 Index: xmlspec/XMLRequires.cpp
6892 ===================================================================
6893 RCS file: xmlspec/XMLRequires.cpp
6894 diff -N xmlspec/XMLRequires.cpp
6895 --- /dev/null 1 Jan 1970 00:00:00 -0000
6896 +++ rpm/xmlspec/XMLRequires.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
6899 +#include "XMLAttrs.h"
6900 +#include "XMLPackage.h"
6901 +#include "XMLRequires.h"
6902 +#include "XMLRPMWrap.h"
6903 +#include "XMLSpec.h"
6906 +#include <rpmlib.h>
6908 +using namespace std;
6910 +// attribute structure for XMLPackageEntry
6911 +structValidAttrs g_paEntryAttrs[] =
6913 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
6914 + {0x0001, false, false, "version", XATTRTYPE_STRING, {"*", NULL}},
6915 + {0x0002, false, false, "cmp", XATTRTYPE_STRING, {"*", NULL}},
6916 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
6919 +bool XMLPackageEntry::parseCreate(XMLAttrs* pAttrs,
6920 + XMLPackageContainer& rContainer)
6922 + // validate the attributes
6923 + if (!pAttrs->validate(g_paEntryAttrs, (XMLBase*)pAttrs))
6926 + // create and return
6927 + XMLPackageEntry entry(pAttrs->asString("name"), pAttrs->asString("version"),
6928 + pAttrs->asString("cmp"));
6929 + rContainer.addEntry(entry);
6933 +XMLPackageEntry::XMLPackageEntry(const char* szName,
6934 + const char* szVersion,
6935 + const char* szCmp)
6939 + m_sName.assign(szName);
6941 + m_sVersion.assign(szVersion);
6942 + m_sCmp.assign("=");
6944 + if (strcasecmp(szCmp, "lt") == 0)
6945 + m_sCmp.assign("<");
6946 + else if (strcasecmp(szCmp, "le") == 0)
6947 + m_sCmp.assign("<=");
6948 + else if (strcasecmp(szCmp, "gt") == 0)
6949 + m_sCmp.assign(">");
6950 + else if (strcasecmp(szCmp, "ge") == 0)
6951 + m_sCmp.assign(">=");
6955 +XMLPackageEntry::XMLPackageEntry(const XMLPackageEntry& rEntry)
6958 + m_sName.assign(rEntry.m_sName);
6959 + m_sVersion.assign(rEntry.m_sVersion);
6960 + m_sCmp.assign(rEntry.m_sCmp);
6963 +XMLPackageEntry::~XMLPackageEntry()
6967 +XMLPackageEntry XMLPackageEntry::operator=(XMLPackageEntry entry)
6969 + m_sName.assign(entry.m_sName);
6970 + m_sVersion.assign(entry.m_sVersion);
6971 + m_sCmp.assign(entry.m_sCmp);
6975 +void XMLPackageEntry::toSpecFile(ostream& rOut)
6977 + rOut << getName();
6978 + if (hasVersion()) {
6979 + rOut << " " << getCompare() << " " << getVersion();
6983 +void XMLPackageEntry::toXMLFile(ostream& rOut)
6985 + rOut << endl << "\t\t\t<package name=\"" << getName() << "\"";
6986 + if (hasVersion()) {
6987 + if (m_sCmp.compare("=") == 0)
6988 + rOut << " cmp=\"eq\"";
6989 + else if (m_sCmp.compare("<") == 0)
6990 + rOut << " cmp=\"lt\"";
6991 + else if (m_sCmp.compare("<=") == 0)
6992 + rOut << " cmp=\"le\"";
6993 + else if (m_sCmp.compare(">") == 0)
6994 + rOut << " cmp=\"gt\"";
6995 + else if (m_sCmp.compare(">=") == 0)
6996 + rOut << " cmp=\"ge\"";
6997 + rOut << " version=\"" << getVersion() << "\"";
7002 +XMLPackageContainer::XMLPackageContainer()
7007 +XMLPackageContainer::XMLPackageContainer(const XMLPackageContainer& rContainer)
7010 + m_vPackages = rContainer.m_vPackages;
7013 +XMLPackageContainer::~XMLPackageContainer()
7017 +XMLPackageContainer XMLPackageContainer::operator=(XMLPackageContainer container)
7019 + m_vPackages = container.m_vPackages;
7023 +void XMLPackageContainer::toSpecFile(ostream& rOut,
7024 + const char* szTag)
7026 + if (numEntries()) {
7027 + rOut << szTag << ": ";
7028 + for (unsigned int i = 0; i < numEntries(); i++) {
7029 + rOut << (i ? ", " : "");
7030 + getEntry(i).toSpecFile(rOut);
7036 +void XMLPackageContainer::toXMLFile(ostream& rOut,
7037 + const char* szTag)
7039 + if (numEntries()) {
7040 + rOut << endl << "\t\t<" << szTag << ">";
7041 + for (unsigned int i = 0; i < numEntries(); i++)
7042 + getEntry(i).toXMLFile(rOut);
7043 + rOut << endl << "\t\t</" << szTag << ">";
7047 +bool XMLPackageContainer::addRequire(XMLAttrs* pAttrs,
7052 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getRequires());
7055 +bool XMLPackageContainer::addBuildRequire(XMLAttrs* pAttrs,
7060 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getBuildRequires());
7063 +bool XMLPackageContainer::addProvide(XMLAttrs* pAttrs,
7068 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getProvides());
7071 +bool XMLPackageContainer::addObsolete(XMLAttrs* pAttrs,
7076 + return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getObsoletes());
7079 +bool XMLPackageContainer::structCreate(PackageStruct* pPackage,
7083 + if (!pXSpec || !pPackage || !pPackage->header)
7087 Index: xmlspec/XMLRequires.h
7088 ===================================================================
7089 RCS file: xmlspec/XMLRequires.h
7090 diff -N xmlspec/XMLRequires.h
7091 --- /dev/null 1 Jan 1970 00:00:00 -0000
7092 +++ rpm/xmlspec/XMLRequires.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
7094 +#ifndef _H_XMLREQUIRES_
7095 +#define _H_XMLREQUIRES_
7097 +// standard C++ includes
7098 +#include <iostream>
7102 +// standard C includes
7106 +#include "XMLAttrs.h"
7107 +#include "XMLBase.h"
7109 +// forward definitions
7111 +class XMLPackageContainer;
7114 +using namespace std;
7116 +//<package ...> (after requires, buildrequires, obsoletes, provides)
7117 +class XMLPackageEntry : public XMLBase
7120 +// factory functions
7124 + * Creates an object as parsed from an XML spec
7126 + * @param pAttrs XML atrtributes to use
7127 + * @param rContainer The container to which to add the object
7128 + * @return true on success, false otherwise
7130 + static bool parseCreate(XMLAttrs* pAttrs,
7131 + XMLPackageContainer& rContainer);
7134 +// constructors/destructor
7138 + * Default constructor
7140 + * @param szName Name of the package
7141 + * @param szVersion version of the package
7142 + * @param szCmp the comparator (eq,lt,le,gt,ge)
7145 + XMLPackageEntry(const char* szName,
7146 + const char* szVersion,
7147 + const char* szCmp);
7150 + * Copy constructor
7152 + * @param rEntry reference to the entrry to copy
7155 + XMLPackageEntry(const XMLPackageEntry& rEntry);
7163 + ~XMLPackageEntry();
7170 + * Assignment operator
7172 + * @param entry The entry to assigne to
7173 + * @return thye modified object
7175 + XMLPackageEntry operator=(XMLPackageEntry entry);
7177 +// member functions
7181 + * Converts the object into an RPM spec
7183 + * @param rOut Output stream
7186 + void toSpecFile(ostream& rOut);
7189 + * Converts the object into an XML spec
7191 + * @param rOut output stream
7194 + void toXMLFile(ostream& rOut);
7197 +// member variable get/set functions
7204 + * @return string containing the name
7206 + const char* getName()
7208 + return m_sName.c_str();
7212 + * Checks if we have a version
7215 + * @return true if available, false otherwise
7219 + return m_sVersion.length() ? true : false;
7223 + * Gets the version
7226 + * @return string containing the version
7228 + const char* getVersion()
7230 + return m_sVersion.c_str();
7234 + * Gets the comparision string
7237 + * @return string with the comparator (=, <, <=, >, >=, <>)
7239 + const char* getCompare()
7241 + return m_sCmp.c_str();
7245 +// member variables
7249 + string m_sVersion;
7253 +//<requires,obsoletes,buildrequires,provides ...>
7254 +class XMLPackageContainer : public XMLBase
7257 +// factory functions
7263 + * @param pAttrs XML attributes
7264 + * @param pSpecx pointer to the spec to add to
7265 + * @return true on success, false otherwise
7267 + static bool addRequire(XMLAttrs* pAttrs,
7271 + * Adds a buildrequire
7273 + * @param pAttrs XML attributes
7274 + * @param pSpecx pointer to the spec to add to
7275 + * @return true on success, false otherwise
7277 + static bool addBuildRequire(XMLAttrs* pAttrs,
7283 + * @param pAttrs XML attributes
7284 + * @param pSpecx pointer to the spec to add to
7285 + * @return true on success, false otherwise
7287 + static bool addProvide(XMLAttrs* pAttrs,
7291 + * Adds an obsolete
7293 + * @param pAttrs XML attributes
7294 + * @param pSpecx pointer to the spec to add to
7295 + * @return true on success, false otherwise
7297 + static bool addObsolete(XMLAttrs* pAttrs,
7301 + * Adds requires/provides/obsoletes from RPM structures
7303 + * @param pPackage pointer to the RPM package
7304 + * @param pSpec pointer to the RPM spec
7305 + * @param pXSpec pointer to the XML spec to populate
7306 + * @return true on success, false otherwise
7308 + static bool structCreate(PackageStruct* pPackage,
7313 +// constructors/destructor
7317 + * Default constructor
7322 + XMLPackageContainer();
7325 + * Copy constructor
7327 + * @param rContainer The container to copy
7330 + XMLPackageContainer(const XMLPackageContainer& rContainer);
7338 + virtual ~XMLPackageContainer();
7345 + * Assignment operator
7347 + * @param container The container to copy
7348 + * @return a copy of the object
7350 + XMLPackageContainer operator=(XMLPackageContainer container);
7353 +// member functions
7357 + * Converts the object into an RPM spec
7359 + * @param rOut Output stream
7360 + * @param szTag the tag for this object (eg. buildrequires)
7363 + virtual void toSpecFile(ostream& rOut,
7364 + const char* szTag);
7367 + * Converts the object into an XML spec
7369 + * @param rOut Output stream
7370 + * @para szTag the tag for this object (eg. buildrequires)
7373 + virtual void toXMLFile(ostream& rOut,
7374 + const char* szTag);
7377 +// member variable get/set functions
7381 + * Gets the number of entries
7384 + * @return the number of entries
7386 + unsigned int numEntries()
7388 + return m_vPackages.size();
7392 + * Gets a specific entry
7394 + * @param nNum The number of the entry
7395 + * @return reference to the entry
7397 + XMLPackageEntry& getEntry(unsigned int nNum)
7399 + return m_vPackages[nNum];
7405 + * @param rPackage the entry to add
7408 + void addEntry(XMLPackageEntry& rPackage)
7410 + m_vPackages.push_back(rPackage);
7414 +// member variables
7417 + vector<XMLPackageEntry> m_vPackages;
7421 Index: xmlspec/XMLScript.cpp
7422 ===================================================================
7423 RCS file: xmlspec/XMLScript.cpp
7424 diff -N xmlspec/XMLScript.cpp
7425 --- /dev/null 1 Jan 1970 00:00:00 -0000
7426 +++ rpm/xmlspec/XMLScript.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
7428 +// standard includes
7432 +#include "XMLPackage.h"
7433 +#include "XMLScript.h"
7434 +#include "XMLSpec.h"
7436 +// attribute structure for XMLScript
7437 +structValidAttrs g_paScriptAttrs[] =
7439 + {0x0000, false, false, "dir", XATTRTYPE_STRING, {"*", NULL}},
7440 + {0x0001, false, false, "interpreter", XATTRTYPE_STRING, {"*", NULL}},
7441 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
7444 +bool XMLScript::parseCreate(XMLAttrs* pAttrs,
7445 + const char* szScript,
7446 + XMLScripts& rContainer)
7448 + if (!pAttrs->validate(g_paScriptAttrs, (XMLBase*)pAttrs))
7450 + XMLScript script(szScript,
7451 + pAttrs->asString("interpreter"),
7452 + pAttrs->asString("dir"));
7453 + rContainer.add(script);
7457 +XMLScript::XMLScript(const char* szScript,
7458 + const char* szInterpreter,
7459 + const char* szDir)
7463 + m_sValue.assign(szScript);
7464 + if (szInterpreter)
7465 + m_sInterpreter.assign(szInterpreter);
7467 + m_sDir.assign(szDir);
7470 +XMLScript::XMLScript(const XMLScript& rScript)
7473 + m_sValue.assign(rScript.m_sValue);
7474 + m_sInterpreter.assign(rScript.m_sInterpreter);
7475 + m_sDir.assign(rScript.m_sDir);
7478 +XMLScript::~XMLScript()
7482 +XMLScript XMLScript::operator=(XMLScript script)
7484 + m_sValue.assign(script.m_sValue);
7485 + m_sInterpreter.assign(script.m_sInterpreter);
7486 + m_sDir.assign(script.m_sDir);
7489 +void XMLScript::toSpecFile(ostream& rOut)
7491 + if (hasDirectory())
7492 + rOut << "cd " << getDirectory() << endl;
7493 + rOut << getValue() << endl;
7496 +void XMLScript::toXMLFile(ostream& rOut,
7497 + const char* szIndent)
7499 + rOut << endl << szIndent << "\t\t<script";
7500 + if (hasDirectory())
7501 + rOut << " dir=\"" << getDirectory() << "\"";
7502 + rOut << ">" << getValue() << "</script>";
7505 +void XMLScript::toRPMStruct(StringBuf* pSB)
7507 + if (hasDirectory()) {
7508 + char szBuff[getDirectoryLen()+3+1]; // 3 == strlen("cd ")
7509 + sprintf(szBuff, "cd %s", getDirectory());
7510 + appendStringBuf(*pSB, szBuff);
7512 + appendStringBuf(*pSB, getValue());
7515 +bool XMLScripts::addPrepScript(XMLAttrs* pAttrs,
7516 + const char* szScript,
7519 + // no spec or already set
7522 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getPrep());
7525 +bool XMLScripts::addBuildScript(XMLAttrs* pAttrs,
7526 + const char* szScript,
7529 + // no spec or already set
7532 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getBuild());
7535 +bool XMLScripts::addInstallScript(XMLAttrs* pAttrs,
7536 + const char* szScript,
7539 + // no spec or already set
7542 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getInstall());
7545 +bool XMLScripts::addCleanScript(XMLAttrs* pAttrs,
7546 + const char* szScript,
7549 + // no spec or already set
7552 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->getClean());
7555 +XMLScripts::XMLScripts()
7560 +XMLScripts::XMLScripts(const XMLScripts& rContainer)
7563 + m_vScripts = rContainer.m_vScripts;
7566 +XMLScripts::~XMLScripts()
7570 +void XMLScripts::toSpecFile(ostream& rOut,
7571 + const char* szTag)
7573 + if (numScripts()) {
7574 + rOut << endl << "%" << szTag << endl;
7575 + for (unsigned int i = 0; i < numScripts(); i++)
7576 + getScript(i).toSpecFile(rOut);
7580 +void XMLScripts::toXMLFile(ostream& rOut,
7581 + const char* szTag)
7583 + if (numScripts()) {
7584 + rOut << endl << "\t<" << szTag << ">";
7585 + for (unsigned int i = 0; i < numScripts(); i++)
7586 + getScript(i).toXMLFile(rOut, "");
7587 + rOut << endl << "\t</" << szTag << ">";
7591 +bool XMLPackageScripts::addPreScript(XMLAttrs* pAttrs,
7592 + const char* szScript,
7597 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPre());
7600 +bool XMLPackageScripts::addPostScript(XMLAttrs* pAttrs,
7601 + const char* szScript,
7606 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPost());
7609 +bool XMLPackageScripts::addPreUnScript(XMLAttrs* pAttrs,
7610 + const char* szScript,
7615 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPreUn());
7618 +bool XMLPackageScripts::addPostUnScript(XMLAttrs* pAttrs,
7619 + const char* szScript,
7624 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPostUn());
7627 +bool XMLPackageScripts::addVerifyScript(XMLAttrs* pAttrs,
7628 + const char* szScript,
7633 + return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getVerify());
7636 +bool XMLPackageScripts::createPreScripts(XMLAttrs* pAttrs,
7641 + pSpec->lastPackage().getPre().setInterpreter(pAttrs->asString("interpreter"));
7645 +bool XMLPackageScripts::createPostScripts(XMLAttrs* pAttrs,
7650 + pSpec->lastPackage().getPost().setInterpreter(pAttrs->asString("interpreter"));
7654 +bool XMLPackageScripts::createPreUnScripts(XMLAttrs* pAttrs,
7659 + pSpec->lastPackage().getPreUn().setInterpreter(pAttrs->asString("interpreter"));
7663 +bool XMLPackageScripts::createPostUnScripts(XMLAttrs* pAttrs,
7668 + pSpec->lastPackage().getPostUn().setInterpreter(pAttrs->asString("interpreter"));
7672 +bool XMLPackageScripts::createVerifyScripts(XMLAttrs* pAttrs,
7677 + pSpec->lastPackage().getVerify().setInterpreter(pAttrs->asString("interpreter"));
7681 +XMLPackageScripts::XMLPackageScripts()
7686 +XMLPackageScripts::XMLPackageScripts(const XMLPackageScripts& rContainer)
7687 + : XMLScripts(rContainer)
7691 +XMLPackageScripts::~XMLPackageScripts()
7695 +void XMLPackageScripts::toSpecFile(ostream& rOut,
7696 + const char* szTag)
7698 + // NOTE: header not done here, but by "package"
7699 + for (unsigned int i = 0; i < numScripts(); i++)
7700 + getScript(i).toSpecFile(rOut);
7703 +void XMLPackageScripts::toXMLFile(ostream& rOut,
7704 + const char* szTag)
7706 + if (numScripts()) {
7707 + rOut << endl << "\t\t<" << szTag << ">";
7708 + for (unsigned int i = 0; i < numScripts(); i++)
7709 + getScript(i).toXMLFile(rOut, "\t");
7710 + rOut << endl << "\t\t</" << szTag << ">";
7713 Index: xmlspec/XMLScript.h
7714 ===================================================================
7715 RCS file: xmlspec/XMLScript.h
7716 diff -N xmlspec/XMLScript.h
7717 --- /dev/null 1 Jan 1970 00:00:00 -0000
7718 +++ rpm/xmlspec/XMLScript.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
7720 +#ifndef _H_XMLSCRIPT_
7721 +#define _H_XMLSCRIPT_
7723 +// standard C++ includes
7724 +#include <iostream>
7729 +#include "XMLAttrs.h"
7730 +#include "XMLBase.h"
7733 +#include <rpmbuild.h>
7735 +// forward definitions
7740 +using namespace std;
7742 +class XMLScript : public XMLBase
7749 + * Creates a script object and adds it to the container
7751 + * @param pAttrs The XML attributes
7752 + * @param szScript The script value
7753 + * @param rContainer reference to the script container to add to
7754 + * @return true on success, false otherwise
7756 + static bool parseCreate(XMLAttrs* pAttrs,
7757 + const char* szScript,
7758 + XMLScripts& rContainer);
7761 +// constructors/destructor
7765 + * Default constructor
7767 + * @param szScript The script
7768 + * @param szInterpreter The interpreter to use for script execution
7769 + * @param szDir Directory to execute the script in
7772 + XMLScript(const char* szScript,
7773 + const char* szInterpreter,
7774 + const char* szDir);
7777 + * Copy constructor
7779 + * @param rScript Script to copy
7782 + XMLScript(const XMLScript& rScript);
7790 + virtual ~XMLScript();
7797 + * Assignment operator
7799 + * @param script the script to copy
7800 + * @return the copied object
7802 + XMLScript operator=(XMLScript script);
7805 +// member functions
7809 + * Converts the object into an RPM spec file
7811 + * @param rOut Output stream
7814 + void toSpecFile(ostream& rOut);
7817 + * Converts the object into an XML spec
7819 + * @param rOut Output stream
7820 + * @param szIndent Indent string
7823 + void toXMLFile(ostream& rOut,
7824 + const char* szIndent = "");
7827 + * Converts the object into an RPM structure
7829 + * @param pSB Pointer to the string buffer
7832 + virtual void toRPMStruct(StringBuf* pSB);
7835 +// member variable get/set functions
7839 + * Gets the script value
7842 + * @return string containing the script
7844 + const char* getValue()
7846 + return m_sValue.c_str();
7850 + * Checks if we have an interpreter
7853 + * @return true if we have an interpreter, false otherwise
7855 + bool hasInterpreter()
7857 + return m_sInterpreter.length() ? true : false;
7861 + * Gets the interpreter
7864 + * @return string contating the interpreter
7866 + const char* getInterpreter()
7868 + return m_sInterpreter.c_str();
7872 + * Checks if we have a direcory
7875 + * @return true if we have a directory, false otherwise
7877 + bool hasDirectory()
7879 + return m_sDir.length() ? true : false;
7883 + * Gets the directory
7886 + * @return string contating the directory
7888 + const char* getDirectory()
7890 + return m_sDir.c_str();
7894 + * Gets the length of the directory string
7897 + * @return length of the description string
7899 + unsigned int getDirectoryLen()
7901 + return m_sDir.length();
7905 +// member variables
7909 + string m_sInterpreter;
7913 +//<prep,build,install,clean ...>
7914 +class XMLScripts : public XMLBase
7917 +// factory functions
7920 + static bool addPrepScript(XMLAttrs* pAttrs,
7921 + const char* szScript,
7924 + static bool addBuildScript(XMLAttrs* pAttrs,
7925 + const char* szScript,
7928 + static bool addInstallScript(XMLAttrs* pAttrs,
7929 + const char* szScript,
7932 + static bool addCleanScript(XMLAttrs* pAttrs,
7933 + const char* szScript,
7937 +// constructors/destructor
7941 + * Default constructor
7949 + * Copy constructor
7951 + * @param rContainer the object to copy
7954 + XMLScripts(const XMLScripts& rContainer);
7962 + virtual ~XMLScripts();
7965 +// member functions
7969 + * Converts the object into an RPM spec file
7971 + * @param rOut Output stream
7972 + * @param szTag The tag name
7975 + virtual void toSpecFile(ostream& rOut,
7976 + const char* szTag);
7979 + * Converts the object into an XML spec
7981 + * @param rOut Output stream
7982 + * @param szTag The tag name
7985 + void toXMLFile(ostream& rOut,
7986 + const char* szTag);
7989 +// member variable get/set functions
7993 + * Checks if we have an interpreter
7996 + * @return true if we have an interpreter, false otherwise
7998 + bool hasInterpreter()
8000 + return m_sInterpreter.length() ? true : false;
8004 + * Gets the interpreter
8007 + * @return string contatining the interpreter
8009 + const char* getInterpreter()
8011 + return m_sInterpreter.c_str();
8015 + * Sets the script interpreter
8017 + * @param szInterpreter The interpreter
8020 + void setInterpreter(const char* szInterpreter)
8022 + if (szInterpreter)
8023 + m_sInterpreter.assign(szInterpreter);
8027 + * Gets the number of script entries
8030 + * @return the number of scripts
8032 + unsigned int numScripts()
8034 + return m_vScripts.size();
8038 + * Gets a specific script entry
8040 + * @param nNum The entry number
8041 + * @return Reference to the script entry
8043 + XMLScript& getScript(unsigned int nNum)
8045 + return m_vScripts[nNum];
8049 + * Adds an script entry
8051 + * @param szScript the script to add
8054 + void add(XMLScript& rScript)
8056 + m_vScripts.push_back(rScript);
8060 +// member variables
8063 + string m_sInterpreter;
8064 + vector<XMLScript> m_vScripts;
8067 +//<post, postun, ...>
8068 +class XMLPackageScripts : public XMLScripts
8071 +// factory functions
8075 + * Adds a pre script
8077 + * @param pAttrs The XML attributes
8078 + * @param szScript The script to add
8079 + * @param pSpec The spec to which we are adding
8080 + * @return true on success, false otherwise
8082 + static bool addPreScript(XMLAttrs* pAttrs,
8083 + const char* szScript,
8087 + * Adds a post script
8089 + * @param pAttrs The XML attributes
8090 + * @param szScript The script to add
8091 + * @param pSpec The spec to which we are adding
8092 + * @return true on success, false otherwise
8094 + static bool addPostScript(XMLAttrs* pAttrs,
8095 + const char* szScript,
8099 + * Adds a preun script
8101 + * @param pAttrs The XML attributes
8102 + * @param szScript The script to add
8103 + * @param pSpec The spec to which we are adding
8104 + * @return true on success, false otherwise
8106 + static bool addPreUnScript(XMLAttrs* pAttrs,
8107 + const char* szScript,
8111 + * Adds a postun script
8113 + * @param pAttrs The XML attributes
8114 + * @param szScript The script to add
8115 + * @param pSpec The spec to which we are adding
8116 + * @return true on success, false otherwise
8118 + static bool addPostUnScript(XMLAttrs* pAttrs,
8119 + const char* szScript,
8123 + * Adds a verify script
8125 + * @param pAttrs The XML attributes
8126 + * @param szScript The script to add
8127 + * @param pSpec The spec to which we are adding
8128 + * @return true on success, false otherwise
8130 + static bool addVerifyScript(XMLAttrs* pAttrs,
8131 + const char* szScript,
8135 + * Initialises a pre script container
8137 + * @param pAttrs The XML attributes
8138 + * @param pSpec The spec to which we are adding
8139 + * @return true on success, false otherwise
8141 + static bool createPreScripts(XMLAttrs* pAttrs,
8145 + * Initialises a post script container
8147 + * @param pAttrs The XML attributes
8148 + * @param pSpec The spec to which we are adding
8149 + * @return true on success, false otherwise
8151 + static bool createPostScripts(XMLAttrs* pAttrs,
8155 + * Initialises a preun script container
8157 + * @param pAttrs The XML attributes
8158 + * @param pSpec The spec to which we are adding
8159 + * @return true on success, false otherwise
8161 + static bool createPreUnScripts(XMLAttrs* pAttrs,
8165 + * Initialises a postun script container
8167 + * @param pAttrs The XML attributes
8168 + * @param pSpec The spec to which we are adding
8169 + * @return true on success, false otherwise
8171 + static bool createPostUnScripts(XMLAttrs* pAttrs,
8175 + * Initialises a verify script container
8177 + * @param pAttrs The XML attributes
8178 + * @param pSpec The spec to which we are adding
8179 + * @return true on success, false otherwise
8181 + static bool createVerifyScripts(XMLAttrs* pAttrs,
8185 +// constructors/destructors
8189 + * Default constructor
8194 + XMLPackageScripts();
8197 + * Copy constructor
8199 + * @param rScripts Reference to the object to copy
8202 + XMLPackageScripts(const XMLPackageScripts& rScripts);
8210 + ~XMLPackageScripts();
8213 +// member functions
8217 + * Converts the object into an RPM spec
8219 + * @param rOut Output stream
8220 + * @param szTag The tag name
8223 + virtual void toSpecFile(ostream& rOut,
8224 + const char* szTag);
8227 + * Converts the object into an XML spec
8229 + * @param rOut Output stream
8230 + * @param szTag The tag name
8233 + virtual void toXMLFile(ostream& rOut,
8234 + const char* szTag);
8239 Index: xmlspec/XMLSource.cpp
8240 ===================================================================
8241 RCS file: xmlspec/XMLSource.cpp
8242 diff -N xmlspec/XMLSource.cpp
8243 --- /dev/null 1 Jan 1970 00:00:00 -0000
8244 +++ rpm/xmlspec/XMLSource.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
8246 +// standard includes
8250 +#include "XMLSource.h"
8251 +#include "XMLSpec.h"
8254 +#include <rpmspec.h>
8256 +using namespace std;
8258 +bool XMLSource::structCreate(Source* pSource,
8262 + if (!pXSpec || !pSpec || !pSource)
8265 + // create our mirror
8266 + XMLMirror *pMirror = NULL;
8267 + if (pSource->source != pSource->fullSource) {
8268 + unsigned int nLen = pSource->source-pSource->fullSource;
8269 + char szPath[nLen+1];
8270 + strncpy(szPath, pSource->fullSource, nLen);
8271 + szPath[nLen] = '\0';
8272 + pMirror = new XMLMirror(szPath, NULL, NULL);
8275 + // generate the source, nosource, patch
8276 + XMLSource* pXSource = NULL;
8277 + XMLNoSource* pXNoSource = NULL;
8278 + XMLPatch* pXPatch = NULL;
8279 + switch (pSource->flags) {
8280 + case RPMBUILD_ISSOURCE:
8281 + pXSource = new XMLSource(pSource->source, pSource->num,
8282 + NULL, NULL, NULL);
8283 + pXSpec->addSource(*pXSource);
8285 + pXSpec->lastSource().addMirror(*pMirror);
8288 + case RPMBUILD_ISNO:
8289 + pXNoSource = new XMLNoSource(pSource->source, pSource->num,
8290 + NULL, NULL, NULL);
8291 + pXSpec->addNoSource(*pXNoSource);
8293 + pXSpec->lastNoSource().addMirror(*pMirror);
8294 + delete pXNoSource;
8296 + case RPMBUILD_ISPATCH:
8297 + pXPatch = new XMLPatch(pSource->source, pSource->num, NULL, NULL);
8298 + pXSpec->addPatch(*pXPatch);
8300 + pXSpec->lastPatch().addMirror(*pMirror);
8309 + // do the next source and return
8310 + XMLSource::structCreate(pSource->next, pSpec, pXSpec);
8314 +// attribute structure for XMLSource
8315 +structValidAttrs g_paSourceAttrs[] =
8317 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
8318 + {0x0001, false, false, "num", XATTRTYPE_INTEGER, {NULL}},
8319 + {0x0002, false, false, "dir", XATTRTYPE_STRING, {"*", NULL}},
8320 + {0x0003, false, false, "size", XATTRTYPE_INTEGER, {NULL}},
8321 + {0x0004, false, false, "md5", XATTRTYPE_STRING, {"*", NULL}},
8322 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
8325 +bool XMLSource::parseCreate(XMLAttrs* pAttrs,
8328 + // validate the attributes
8329 + if (!pAttrs->validate(g_paSourceAttrs, (XMLBase*)pSpec))
8332 + XMLSource source(pAttrs->asString("name"), pAttrs->asInteger("num"),
8333 + pAttrs->asString("dir"), pAttrs->asString("size"),
8334 + pAttrs->asString("md5"));
8335 + pSpec->addSource(source);
8340 +XMLSource::XMLSource(const char* szName,
8341 + unsigned int nNum,
8342 + const char* szDir,
8343 + const char* szSize,
8344 + const char* szMD5)
8348 + m_sName.assign(szName);
8351 + m_sDir.assign(szDir);
8353 + m_sSize.assign(szSize);
8355 + m_sMD5.assign(szMD5);
8358 +XMLSource::XMLSource(const XMLSource& rSource)
8361 + m_sName.assign(rSource.m_sName);
8362 + m_nNum = rSource.m_nNum;
8363 + m_sDir.assign(rSource.m_sDir);
8364 + m_sSize.assign(rSource.m_sSize);
8365 + m_sMD5.assign(rSource.m_sMD5);
8366 + m_vMirrors = rSource.m_vMirrors;
8369 +XMLSource::~XMLSource()
8373 +XMLSource XMLSource::operator=(XMLSource source)
8375 + m_sName.assign(source.m_sName);
8376 + m_nNum = source.m_nNum;
8377 + m_sDir.assign(source.m_sDir);
8378 + m_sSize.assign(source.m_sSize);
8379 + m_sMD5.assign(source.m_sMD5);
8380 + m_vMirrors = source.m_vMirrors;
8384 +void XMLSource::toSpecFile(ostream& rOut)
8386 + for (unsigned int i = 0; i < numMirrors(); i++)
8387 + getMirror(i).toSpecFile(rOut);
8389 + rOut << endl << "source";
8393 + rOut << getMirror(0).getPath();
8394 + rOut << getName();
8397 +void XMLSource::toXMLFile(ostream& rOut)
8399 + rOut << endl << "\t<source name=\"" << getName() << "\"";
8400 + rOut << endl << "\t num=\"";
8404 + rOut << endl << "\t size=\"" << getSize() << "\"";
8406 + rOut << endl << "\t md5=\"" << getMD5() << "\"";
8408 + rOut << endl << "\t dir=\"" << getDir() << "\"";
8411 + for (unsigned int i = 0; i < numMirrors(); i++)
8412 + getMirror(i).toXMLFile(rOut);
8414 + rOut << endl << "\t</source>";
8417 +void XMLSource::toRPMStruct(Spec pRPMSpec)
8419 + /*Source* pCurr = new Source;
8420 + unsigned int nNameLen = strlen(getName());
8421 + unsigned int nMirrorLen = 0;
8423 + pPrev->next = pCurr;
8424 + pCurr->next = NULL;
8426 + nMirrorlen = strlen(getMirror(0).getPath());
8427 + pCurr->fullSource = new char[nNamelen+nMirrorLen+1];
8428 + pCurr->fullSources[0] = '\0';
8430 + strcpy(pCurr->fullSource, getMirror(0).getPath());
8431 + strcat(pCurr->fullSource, getName());
8432 + pCurr->source = pCurr->fullSource+nMirrorLen;
8433 + pCurr->num = getNum();
8434 + pCurr->flags = RPMBUILD_ISSOURCE;
8438 +bool XMLNoSource::parseCreate(XMLAttrs* pAttrs,
8441 + // validate the attributes
8442 + if (!pAttrs->validate(g_paSourceAttrs, (XMLBase*)pSpec))
8445 + XMLNoSource source(pAttrs->asString("name"), pAttrs->asInteger("num"),
8446 + pAttrs->asString("dir"), pAttrs->asString("size"),
8447 + pAttrs->asString("md5"));
8448 + pSpec->addNoSource(source);
8452 +XMLNoSource::XMLNoSource(const char* szName,
8453 + unsigned int nNum,
8454 + const char* szDir,
8455 + const char* szSize,
8456 + const char* szMD5)
8457 + : XMLSource(szName,
8465 +XMLNoSource::XMLNoSource(const XMLNoSource& rNoSource)
8466 + : XMLSource(rNoSource.m_sName.c_str(),
8468 + rNoSource.m_sDir.c_str(),
8469 + rNoSource.m_sSize.c_str(),
8470 + rNoSource.m_sMD5.c_str())
8474 +XMLNoSource::~XMLNoSource()
8478 +void XMLNoSource::toSpecFile(ostream& rOut)
8480 + for (unsigned int i = 0; i < numMirrors(); i++)
8481 + getMirror(i).toSpecFile(rOut);
8483 + rOut << endl << "nosource";
8485 + rOut << ": " << getName();
8488 +void XMLNoSource::toXMLFile(ostream& rOut)
8490 + for (unsigned int i = 0; i < numMirrors(); i++)
8491 + getMirror(i).toXMLFile(rOut);
8494 +void XMLNoSource::toRPMStruct(Spec pRPMSpec)
8496 + //Source* pCurr = XMLSource::toRPMStruct(pPrev);
8497 + //pCurr->flags = RPMBUILD_ISNO;
8501 +// attribute structure for XMLPatch
8502 +structValidAttrs g_paPatchAttrs[] =
8504 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
8505 + {0x0001, false, false, "num", XATTRTYPE_INTEGER, {NULL}},
8506 + {0x0002, false, false, "size", XATTRTYPE_INTEGER, {NULL}},
8507 + {0x0003, false, false, "md5", XATTRTYPE_STRING, {"*", NULL}},
8508 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
8511 +bool XMLPatch::parseCreate(XMLAttrs* pAttrs,
8514 + // validate the attributes
8515 + if (!pAttrs->validate(g_paPatchAttrs, (XMLBase*)pSpec))
8518 + XMLPatch patch(pAttrs->asString("name"), pAttrs->asInteger("num"),
8519 + pAttrs->asString("size"), pAttrs->asString("md5"));
8520 + pSpec->addPatch(patch);
8524 +XMLPatch::XMLPatch(const char* szName,
8525 + unsigned int nNum,
8526 + const char* szSize,
8527 + const char* szMD5)
8528 + : XMLSource(szName,
8536 +XMLPatch::XMLPatch(const XMLPatch& rPatch)
8537 + : XMLSource(rPatch.m_sName.c_str(),
8540 + rPatch.m_sSize.c_str(),
8541 + rPatch.m_sMD5.c_str())
8545 +XMLPatch::~XMLPatch()
8549 +void XMLPatch::toSpecFile(ostream& rOut)
8551 + for (unsigned int i = 0; i < numMirrors(); i++)
8552 + getMirror(i).toSpecFile(rOut);
8553 + rOut << endl << "patch";
8555 + rOut << ": " << getName();
8558 +void XMLPatch::toXMLFile(ostream& rOut)
8560 + rOut << endl << "\t<patch name=\"" << getName() << "\"";
8561 + rOut << endl << "\t num=\"";
8565 + rOut << endl << "\t size=\"" << getSize() << "\"";
8567 + rOut << endl << "\t md5=\"" << getMD5() << "\"";
8569 + rOut << endl << "\t dir=\"" << getDir() << "\"";
8572 + for (unsigned int i = 0; i < numMirrors(); i++)
8573 + getMirror(i).toXMLFile(rOut);
8575 + rOut << endl << "\t</patch>";
8578 +void XMLPatch::toRPMStruct(Spec pRPMSpec)
8581 + //Source* pCurr = XMLSource::toRPMStruct(pPrev);
8582 + //pCurr->flags = RPMBUILD_ISPATCH;
8585 Index: xmlspec/XMLSource.h
8586 ===================================================================
8587 RCS file: xmlspec/XMLSource.h
8588 diff -N xmlspec/XMLSource.h
8589 --- /dev/null 1 Jan 1970 00:00:00 -0000
8590 +++ rpm/xmlspec/XMLSource.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
8592 +#ifndef _H_XMLSOURCE_
8593 +#define _H_XMLSOURCE_
8595 +// standard C++ includes
8598 +#include <iostream>
8600 +// standard includes
8604 +#include "XMLAttrs.h"
8605 +#include "XMLBase.h"
8606 +#include "XMLMirror.h"
8609 +#include <rpmbuild.h>
8611 +// forward declaration
8614 +using namespace std;
8617 +class XMLSource : public XMLBase
8620 +// factory functions
8624 + * Static factory function for the creation of XMLSource, XMLPatch, ...
8625 + * objects from RPM Source* structure.
8627 + * @param pSource Pointer to a list of sources
8628 + * @param pSpec pointer to the RPM spec
8629 + * @param pSpec pointer to our spec object
8630 + * @return true on success, false otherwise
8632 + static bool structCreate(Source* pSource,
8637 + * Static factory function for the creation of an XMLSource
8638 + * object from details parsed from an XML spec.
8640 + * @param pAttrs Pointer to an XML attribute object
8641 + * @param pspec Ponter to our spec object
8642 + * @param bPatch True if this source is a patch
8643 + * @return true on success, false otherwise
8645 + static bool parseCreate(XMLAttrs* pAttrs,
8649 +// constructors/destructor
8653 + * Default contructor
8655 + * @param szName The name
8656 + * @param szNum The source number
8657 + * @param szDir The unpack directory
8658 + * @param szSize The size of the source archive
8659 + * @param szMD5 The MD5 sum of the archive
8662 + XMLSource(const char* szName,
8663 + unsigned int nNum,
8664 + const char* szDir,
8665 + const char* szSize,
8666 + const char* szMD5);
8671 + * @param rSource The source that we are to copy
8674 + XMLSource(const XMLSource& rSource);
8682 + virtual ~XMLSource();
8689 + * Assignment operator
8691 + * @param source The source to copy
8692 + * @return copied object
8694 + XMLSource operator=(XMLSource source);
8697 +// Member functions
8701 + * Convert the object into an RPM spec file
8703 + * @param rOut Output stream
8706 + virtual void toSpecFile(ostream& rOut);
8709 + * Converts the object into an XML spec
8711 + * @param rOut Output stream
8714 + virtual void toXMLFile(ostream& rOut);
8717 + * Converts the object into an RPM structure
8719 + * @param spec the RPM structure to use
8722 + virtual void toRPMStruct(Spec spec);
8725 +// member variable get/set functions
8729 + * Checks if we have a source name
8732 + * @return true if we have a name, false otherwise
8736 + return m_sName.length() ? true : false;
8740 + * Get the source name
8743 + * @return string containing the name
8745 + const char* getName()
8747 + return m_sName.c_str();
8751 + * Get the length of the name
8754 + * @return the length of the name
8756 + unsigned int getNameLen()
8758 + return m_sName.length();
8762 + * Get the source number
8765 + * @return the number
8767 + unsigned int getNum()
8773 + * Checks to see if we have an unpack directory
8776 + * @return true if we have a specified directory, false otherwise
8780 + return m_sDir.length() ? true : false;
8784 + * Gets the directory that we are to unpack this source to
8787 + * @return string contating the directory
8789 + const char* getDir()
8791 + return m_sDir.c_str();
8795 + * Checks to see if we have a source size
8798 + * @return true if we have a size, false otherwise
8802 + return m_sSize.length() ? true : false;
8806 + * Gets the size of the source
8809 + * @return string contating the size
8811 + const char* getSize()
8813 + return m_sSize.c_str();
8817 + * Checks to see if this source has an MD5 sum
8820 + * @return true if we have an MD5, false oterwise
8824 + return m_sMD5.length() ? true : false;
8828 + * Gets the MD5 sum for this source
8831 + * @return string contating the MD5
8833 + const char* getMD5()
8835 + return m_sMD5.c_str();
8839 + * Add a mirror for this source
8841 + * @param rMirror The mirror to add
8844 + void addMirror(XMLMirror& rMirror)
8846 + m_vMirrors.push_back(rMirror);
8850 + * Gets the number of mirrors for this source
8853 + * @return the number oif mirrors
8855 + unsigned int numMirrors()
8857 + return m_vMirrors.size();
8861 + * Gets a specific mirror by number
8863 + * @param nNum The mirror to get
8864 + * @param the mirror
8866 + XMLMirror& getMirror(unsigned int nNum)
8868 + return m_vMirrors[nNum];
8872 +// member variables
8876 + unsigned int m_nNum;
8880 + vector<XMLMirror> m_vMirrors;
8884 +class XMLNoSource : public XMLSource
8891 + * Create an XMLNoSource object
8893 + * @param pAttrs XML attributes
8894 + * @param pSpec The spec to add the object o
8895 + * @return true on success, false otherwise
8897 + static bool parseCreate(XMLAttrs* pAttrs,
8901 +// constructors/destructor
8905 + * Default constructor
8907 + * @param szName The name
8908 + * @param nNum source number
8909 + * @param szDir Thje director to extract to
8910 + * @param szSize size of the archive
8911 + * @param szMD5 the MD5 sum of the archive
8914 + XMLNoSource(const char* szName,
8915 + unsigned int nNum,
8916 + const char* szDir,
8917 + const char* szSize,
8918 + const char* szMD5);
8921 + * Copy constructor
8923 + * @param rNoSource Reference to the object ot copy
8926 + XMLNoSource(const XMLNoSource& rNoSource);
8934 + virtual ~XMLNoSource();
8937 +// public member functions
8941 + * Converts the object into an RPM spec file
8943 + * @param rOut Output stream
8946 + virtual void toSpecFile(ostream& rOut);
8949 + * Converts the object into an XML spec
8951 + * @param rOut Output stream
8954 + virtual void toXMLFile(ostream& rOut);
8957 + * Converts the object into an RPM structure
8959 + * @param spec The RPM spec structure
8962 + virtual void toRPMStruct(Spec spec);
8966 +class XMLPatch : public XMLSource
8973 + * Create an XMLPatch object
8975 + * @param pAttrs XML attributes
8976 + * @param pSpec The spec to add the object o
8977 + * @return true on success, false otherwise
8979 + static bool parseCreate(XMLAttrs* pAttrs,
8983 +// constructors/destructor
8987 + * Default constructor
8989 + * @param szName archive name
8990 + * @param nNum source number
8991 + * @param szSize size of the archive
8992 + * @param szMD5 MD5 sum
8995 + XMLPatch(const char* szName,
8996 + unsigned int nNum,
8997 + const char* szSize,
8998 + const char* szMD5);
9001 + * Copy constructor
9003 + * @param rPatch Reference to the object to copy
9006 + XMLPatch(const XMLPatch& rPatch);
9014 + virtual ~XMLPatch();
9017 +// member functions
9021 + * Converts the object into an RPM spec file
9023 + * @param rOut Output stream
9026 + virtual void toSpecFile(ostream& rOut);
9029 + * Converts the object into an XML spec
9031 + * @param rOut Output stream
9034 + virtual void toXMLFile(ostream& rOut);
9037 + * Converts the object into an RPM structure
9039 + * @param spec The RPM spec structure
9042 + virtual void toRPMStruct(Spec spec);
9046 Index: xmlspec/XMLSpec.cpp
9047 ===================================================================
9048 RCS file: xmlspec/XMLSpec.cpp
9049 diff -N xmlspec/XMLSpec.cpp
9050 --- /dev/null 1 Jan 1970 00:00:00 -0000
9051 +++ rpm/xmlspec/XMLSpec.cpp 28 Aug 2002 10:52:43 -0000 1.3.2.1
9053 +// 3rd party includes
9057 +#include "XMLAttrs.h"
9058 +#include "XMLRPMWrap.h"
9059 +#include "XMLSpec.h"
9062 +#include <rpmlib.h>
9064 +using namespace std;
9066 +// attribute structure for XMLSpec
9067 +structValidAttrs g_paSpecAttrs[] =
9069 + {0x0000, true, false, "name", XATTRTYPE_STRING, {"*", NULL}},
9070 + {0x0001, true, false, "version", XATTRTYPE_STRING, {"*", NULL}},
9071 + {0x0002, true, false, "release", XATTRTYPE_STRING, {"*", NULL}},
9072 + {0x0003, false, false, "epoch", XATTRTYPE_INTEGER, {NULL}},
9073 + {0x0004, false, false, "distribution", XATTRTYPE_STRING, {"*", NULL}},
9074 + {0x0005, false, false, "vendor", XATTRTYPE_STRING, {"*", NULL}},
9075 + {0x0006, false, false, "packager", XATTRTYPE_STRING, {"*", NULL}},
9076 + {0x0007, false, false, "packager-email", XATTRTYPE_MAIL, {"*", NULL}},
9077 + {0x0008, false, false, "copyright", XATTRTYPE_STRING, {"*", NULL}},
9078 + {0x0009, false, false, "url", XATTRTYPE_STRING, {"*", NULL}},
9079 + {0x000A, false, false, "buildroot", XATTRTYPE_STRING, {"*", NULL}},
9080 + {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}}
9083 +XMLSpec* XMLSpec::parseCreate(XMLAttrs* pAttrs,
9084 + const char* szFilename)
9086 + // verify the attributes
9087 + if (!pAttrs->validate(g_paSpecAttrs, (XMLBase*)pAttrs))
9090 + // create and return
9091 + return new XMLSpec(szFilename,
9092 + pAttrs->asString("name"),
9093 + pAttrs->asString("version"),
9094 + pAttrs->asString("release"),
9095 + pAttrs->asString("epoch"),
9096 + pAttrs->asString("distribution"),
9097 + pAttrs->asString("vendor"),
9098 + pAttrs->asString("packager"),
9099 + pAttrs->asString("packager-email"),
9100 + pAttrs->asString("copyright"),
9101 + pAttrs->asString("url"),
9102 + pAttrs->asString("buildroot"));
9105 +XMLSpec* XMLSpec::structCreate(Spec pSpec)
9107 + if (!pSpec || !pSpec->packages || !pSpec->packages->header)
9110 + // create the spec with values from the RPM stuff
9111 + string sName, sVersion, sRelease, sEpoch, sDistro;
9112 + string sVendor, sPackager, sMail, sLicense, sURL;
9113 + if (!getRPMHeader(pSpec->packages->header, RPMTAG_NAME, sName) ||
9114 + !getRPMMacro("PACKAGE_VERSION", sVersion) ||
9115 + !getRPMMacro("PACKAGE_RELEASE", sRelease))
9117 + getRPMHeader(pSpec->packages->header, RPMTAG_EPOCH, sEpoch);
9118 + getRPMHeader(pSpec->packages->header, RPMTAG_DISTRIBUTION, sDistro);
9119 + getRPMHeader(pSpec->packages->header, RPMTAG_VENDOR, sVendor);
9120 + getRPMHeader(pSpec->packages->header, RPMTAG_PACKAGER, sPackager);
9121 + getRPMHeader(pSpec->packages->header, RPMTAG_LICENSE, sLicense);
9122 + getRPMHeader(pSpec->packages->header, RPMTAG_URL, sURL);
9123 + XMLSpec* pXSpec = new XMLSpec(pSpec->specFile, sName.c_str(), sVersion.c_str(),
9124 + sRelease.c_str(), sEpoch.c_str(), sDistro.c_str(),
9125 + sVendor.c_str(), sPackager.c_str(), sMail.c_str(),
9126 + sLicense.c_str(), sURL.c_str(), pSpec->buildRootURL);
9128 + // add sources, packages all kinds of funny stuff
9129 + XMLChangelog::structCreate(pSpec, pXSpec);
9130 + XMLSource::structCreate(pSpec->sources, pSpec, pXSpec);
9131 + XMLPackage::structCreate(pSpec->packages, pSpec, pXSpec);
9133 + // return the created spec
9137 +XMLSpec::XMLSpec(const char* szFilename,
9138 + const char* szName,
9139 + const char* szVersion,
9140 + const char* szRelease,
9141 + const char* szEpoch,
9142 + const char* szDistribution,
9143 + const char* szVendor,
9144 + const char* szPackager,
9145 + const char* szPkgrEmail,
9146 + const char* szCopyright,
9147 + const char* szURL,
9148 + const char* szBuildRoot) : XMLBase()
9151 + m_sFilename.assign(szFilename);
9153 + m_sName.assign(szName);
9155 + m_sVersion.assign(szVersion);
9157 + m_sRelease.assign(szRelease);
9159 + m_sEpoch.assign(szEpoch);
9160 + if (szDistribution)
9161 + m_sDistribution.assign(szDistribution);
9163 + m_sVendor.assign(szVendor);
9165 + m_sPackager.assign(szPackager);
9167 + m_sPkgrEmail.assign(szPkgrEmail);
9169 + m_sCopyright.assign(szCopyright);
9171 + m_sURL.assign(szURL);
9173 + m_sBuildRoot.assign(szBuildRoot);
9176 +XMLSpec::~XMLSpec()
9180 +void XMLSpec::toSpecFile(ostream& rOut)
9182 + for (unsigned int i = 0; i < numXMacros(); i++)
9183 + getXMacro(i).toSpecFile(rOut);
9185 + rOut << "name: " << getName() << endl;
9186 + rOut << "version: " << getVersion() << endl;
9187 + rOut << "release: " << getRelease() << endl;
9189 + rOut << "epoch: " << getEpoch() << endl;
9190 + if (hasCopyright())
9191 + rOut << "copyright: " << getCopyright() << endl;
9193 + rOut << "url: " << getURL() << endl;
9194 + if (hasBuildRoot())
9195 + rOut << "buildroot: " << getBuildRoot() << endl;
9196 + if (hasDistribution())
9197 + rOut << "distribution: " << getDistribution() << endl;
9199 + rOut << "vendor: " << getVendor() << endl;
9200 + if (hasPackager()) {
9201 + rOut << "packager: " << getPackager();
9202 + if (hasPkgrEmail())
9203 + rOut << " <" << getPkgrEmail() << ">";
9207 + for (unsigned int i = 0; i < numSources(); i++)
9208 + getSource(i).toSpecFile(rOut);
9209 + //for (unsigned int i = 0; i < numNoSources(); i++)
9210 + // getNoSource(i).toSpecFile(rOut);
9211 + for (unsigned int i = 0; i < numPatches(); i++)
9212 + getPatch(i).toSpecFile(rOut);
9213 + for (unsigned int i = 0; i < numPackages(); i++)
9214 + getPackage(i).toSpecFile(rOut);
9216 + getPrep().toSpecFile(rOut, "prep");
9217 + getBuild().toSpecFile(rOut, "build");
9218 + getInstall().toSpecFile(rOut, "install");
9219 + getClean().toSpecFile(rOut, "clean");
9221 + for (unsigned int i = 0; i < numPackages(); i++)
9222 + getPackage(i).toScriptsSpecFile(rOut);
9224 + for (unsigned int i = 0; i < numPackages(); i++)
9225 + getPackage(i).toFilesSpecFile(rOut);
9227 + getChangelog().toSpecFile(rOut);
9230 +void XMLSpec::toXMLFile(ostream& rOut)
9233 + rOut << "<?xml version=\"1.0\"?>";
9234 + rOut << endl << "<spec name=\"" << getName() << "\"";
9235 + rOut << endl << " version=\"" << getVersion() << "\"";
9236 + rOut << endl << " release=\"" << getRelease() << "\"";
9238 + rOut << endl << " epoch=\"" << getEpoch() << "\"";
9239 + if (hasCopyright())
9240 + rOut << endl << " copyright=\"" << getCopyright() << "\"";
9242 + rOut << endl << " url=\"" << getURL() << "\"";
9243 + if (hasBuildRoot())
9244 + rOut << endl << " buildroot=\"" << getBuildRoot() << "\"";
9245 + if (hasDistribution())
9246 + rOut << endl << " distribution=\"" << getDistribution() << "\"";
9248 + rOut << endl << " vendor=\"" << getVendor() << "\"";
9249 + if (hasPackager()) {
9250 + rOut << endl << " packager=\"" << getPackager() << "\"";
9251 + if (hasPkgrEmail())
9252 + rOut << endl << " packager-email=\"" << getPkgrEmail() << "\"";
9256 + for (unsigned int i = 0; i < numXMacros(); i++)
9257 + getXMacro(i).toXMLFile(rOut);
9258 + for (unsigned int i = 0; i < numSources(); i++)
9259 + getSource(i).toXMLFile(rOut);
9260 + for (unsigned int i = 0; i < numNoSources(); i++)
9261 + getNoSource(i).toXMLFile(rOut);
9262 + for (unsigned int i = 0; i < numPatches(); i++)
9263 + getPatch(i).toXMLFile(rOut);
9264 + for (unsigned int i = 0; i < numPackages(); i++)
9265 + getPackage(i).toXMLFile(rOut);
9267 + getPrep().toXMLFile(rOut, "prep");
9268 + getBuild().toXMLFile(rOut, "build");
9269 + getInstall().toXMLFile(rOut, "install");
9270 + getClean().toXMLFile(rOut, "clean");
9272 + getChangelog().toXMLFile(rOut);
9274 + rOut << endl << "</spec>";
9277 +void XMLSpec::toRPMStruct(Spec* pRPMSpec)
9279 + Spec spec = newSpec();
9280 + if (hasBuildRoot()) {
9281 + spec->gotBuildRootURL = 1;
9282 + spec->buildRootURL = strdup(getBuildRoot());
9283 + addMacro(spec->macros, "buildroot", NULL, getBuildRoot(), RMIL_SPEC);
9285 + addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
9286 + spec->timeCheck = rpmExpandNumeric("%{_timecheck}");
9288 + //getChangelog().toRPMStruct(spec);
9289 + /*for (unsigned int i = 0; i < numPackages(); i++)
9290 + getPackage(i).toRPMStruct(pRPMSpec);
9291 + for (unsigned int i = 0; i < numSources(); i++)
9292 + getSource(i).toRPMStruct(pRPMSpec);
9293 + for (unsigned int i = 0; i < numNoSources(); i++)
9294 + getNoSource(i).toRPMStruct(pRPMSpec);
9295 + for (unsigned int i = 0; i < numPatches(); i++)
9296 + getPatch(i).toRPMStruct(pRPMSpec);*/
9298 + //getPrep().toRPMStruct(spec);
9299 + //getBuild().toRPMStruct(spec);
9300 + //getInstall().toRPMStruct(spec);
9301 + //getClean().toRPMStruct(spec);
9305 Index: xmlspec/XMLSpec.h
9306 ===================================================================
9307 RCS file: xmlspec/XMLSpec.h
9308 diff -N xmlspec/XMLSpec.h
9309 --- /dev/null 1 Jan 1970 00:00:00 -0000
9310 +++ rpm/xmlspec/XMLSpec.h 28 Aug 2002 10:52:43 -0000 1.2.2.1
9312 +#ifndef _H_XMLSPEC_
9313 +#define _H_XMLSPEC_
9315 +// standard C++ includes
9316 +#include <iostream>
9321 +#include "XMLAttrs.h"
9322 +#include "XMLBase.h"
9323 +#include "XMLChangelog.h"
9324 +#include "XMLMacro.h"
9325 +#include "XMLPackage.h"
9326 +#include "XMLScript.h"
9327 +#include "XMLSource.h"
9330 +#include <rpmbuild.h>
9332 +using namespace std;
9335 +class XMLSpec : public XMLBase
9338 +// static object creation functions
9342 + * Creates an XMLSpec from values parsed
9344 + * @param pAttrs The XML attributes
9345 + * @param szFilename The XML spec filename
9346 + * @return Pointer to the created spec
9348 + static XMLSpec* parseCreate(XMLAttrs* pAttrs,
9349 + const char* szFilename);
9352 + * Creates and XMLSpec from an RPM Spec structure
9354 + * @param pSpec The RPM spec structure
9355 + * @return Pointer to the created spec
9357 + static XMLSpec* structCreate(Spec pSpec);
9360 +// constructors/destructor
9364 + * Default constructor
9366 + * @param szFilename Filename of the spec on disk
9367 + * @param szName spec name
9368 + * @param szVersion Spec version
9369 + * @param szRelease spec release
9370 + * @param szEpoch spec epoch
9371 + * @param szDistribution spec distribution
9372 + * @param szVendor spec vendor
9373 + * @param szPackage spec packager
9374 + * @param szPkgEmail email address for the packager
9375 + * @param szCopyright spec copyright/licence
9376 + * @param szURL main package url
9377 + * @param szBuildRoot buildroot
9380 + XMLSpec(const char* szFilename,
9381 + const char* szName,
9382 + const char* szVersion,
9383 + const char* szRelease,
9384 + const char* szEpoch,
9385 + const char* szDistribution,
9386 + const char* szVendor,
9387 + const char* szPackager,
9388 + const char* szPkgrEmail,
9389 + const char* szCopyright,
9390 + const char* szURL,
9391 + const char* szBuildRoot);
9402 +// public member functions
9406 + * Converts the spec object to a normal RPM spec file
9408 + * @param rOut Reference to the stream to write the information to
9411 + void toSpecFile(ostream& rOut);
9414 + * Converts the spec object to an XML spec file
9416 + * @param rOut Reference to the stream to write the information to
9419 + void toXMLFile(ostream& rOut);
9422 + * Converts the spec object to an internal RPM structure
9425 + * @return the created RPM structure
9427 + void toRPMStruct(Spec* pRPMSpec);
9430 +// member variable get/set functions
9434 + * Adds a package to the internal list
9436 + * @param rPkg Reference to the package to add
9439 + void addPackage(XMLPackage& rPkg)
9441 + m_vPackages.push_back(rPkg);
9445 + * Gets the number of packages
9448 + * @return the number of packages
9450 + unsigned int numPackages()
9452 + return m_vPackages.size();
9456 + * Gets a specific package
9458 + * @param nNum The package number
9459 + * @return the required package
9461 + XMLPackage& getPackage(unsigned int nNum)
9463 + return m_vPackages[nNum];
9467 + * Gets the last package added
9470 + * @return the last package added
9472 + XMLPackage& lastPackage()
9474 + return m_vPackages[numPackages()-1];
9478 + * Adds a source to the internal list
9480 + * @param rSource Reference to the source to add
9483 + void addSource(XMLSource& rSource)
9485 + m_vSources.push_back(rSource);
9489 + * Gets the number of sources
9492 + * @return the number of sources
9494 + unsigned int numSources()
9496 + return m_vSources.size();
9500 + * Gets a specific source
9502 + * @param nNum The source number
9503 + * @return the required source
9505 + XMLSource& getSource(unsigned int nNum)
9507 + return m_vSources[nNum];
9511 + * Gets the last source added
9514 + * @return the last source added
9516 + XMLSource& lastSource()
9518 + return m_vSources[numSources()-1];
9522 + * Adds a source to the internal list
9524 + * @param rSource Reference to the source to add
9527 + void addNoSource(XMLNoSource& rSource)
9529 + m_vNoSources.push_back(rSource);
9533 + * Gets the number of nosources
9536 + * @return the number of nsources
9538 + unsigned int numNoSources()
9540 + return m_vNoSources.size();
9544 + * Gets a specific nosource
9546 + * @param nNum The nosource number
9547 + * @return the required nosource
9549 + XMLNoSource& getNoSource(unsigned int nNum)
9551 + return m_vNoSources[nNum];
9555 + * Gets the last nosource added
9558 + * @return the last nosource added
9560 + XMLNoSource& lastNoSource()
9562 + return m_vNoSources[numNoSources()-1];
9566 + * Adds a patch to the internal list
9568 + * @param rSource Reference to the patch to add
9571 + void addPatch(XMLPatch& rSource)
9573 + m_vPatches.push_back(rSource);
9577 + * Gets the number of patches
9580 + * @return the number of patches
9582 + unsigned int numPatches()
9584 + return m_vPatches.size();
9588 + * Gets a specific patch
9590 + * @param nNum The patch number
9591 + * @return the required patch
9593 + XMLPatch& getPatch(unsigned int nNum)
9595 + return m_vPatches[nNum];
9599 + * Gets the last patch added
9602 + * @return the last patch added
9604 + XMLPatch& lastPatch()
9606 + return m_vPatches[numPatches()-1];
9610 + * Adds a macro to the internal list
9612 + * @param rMacro Reference to the macro to add
9615 + void addXMacro(XMLMacro& rMacro)
9617 + m_vMacros.push_back(rMacro);
9621 + * Gets the number of macros
9624 + * @return the number of macros
9626 + unsigned int numXMacros()
9628 + return m_vMacros.size();
9632 + * Gets a specific macro
9634 + * @param nNum The macro number
9635 + * @return the required macro
9637 + XMLMacro& getXMacro(unsigned int nNum)
9639 + return m_vMacros[nNum];
9643 + * Checks if we have a filename
9646 + * @return true if available, false otherwise
9648 + bool hasFilename()
9650 + return m_sFilename.length() ? true : false;
9654 + * Gets the filename
9657 + * @return string containing the filename
9659 + const char* getFilename()
9661 + return m_sFilename.c_str();
9665 + * Checks if we have a name
9668 + * @return true if available, false otherwise
9672 + return m_sName.length() ? true : false;
9679 + * @return string containing the name
9681 + const char* getName()
9683 + return m_sName.c_str();
9687 + * Checks if we have a version
9690 + * @return true if available, false otherwise
9694 + return m_sVersion.length() ? true : false;
9698 + * Gets the version
9701 + * @return string containing the version
9703 + const char* getVersion()
9705 + return m_sVersion.c_str();
9709 + * Checks if we have a release
9712 + * @return true if available, false otherwise
9716 + return m_sRelease.length() ? true : false;
9720 + * Gets the release
9723 + * @return string containing the release
9725 + const char* getRelease()
9727 + return m_sRelease.c_str();
9731 + * Checks if we have a epoch
9734 + * @return true if available, false otherwise
9738 + return m_sEpoch.length() ? true : false;
9745 + * @return string containing the epoch
9747 + const char* getEpoch()
9749 + return m_sEpoch.c_str();
9753 + * Checks if we have a distribution
9756 + * @return true if available, false otherwise
9758 + bool hasDistribution()
9760 + return m_sDistribution.length() ? true : false;
9764 + * Gets the distribution
9767 + * @return string containing the distribution
9769 + const char* getDistribution()
9771 + return m_sDistribution.c_str();
9775 + * Checks if we have a vendor
9778 + * @return true if available, false otherwise
9782 + return m_sVendor.length() ? true : false;
9789 + * @return string containing the vendor
9791 + const char* getVendor()
9793 + return m_sVendor.c_str();
9797 + * Checks if we have a packager
9800 + * @return true if available, false otherwise
9802 + bool hasPackager()
9804 + return m_sPackager.length() ? true : false;
9808 + * Gets the packager
9811 + * @return string containing the packager
9813 + const char* getPackager()
9815 + return m_sPackager.c_str();
9819 + * Checks if we have a packager email
9822 + * @return true if available, false otherwise
9824 + bool hasPkgrEmail()
9826 + return m_sPkgrEmail.length() ? true : false;
9830 + * Gets the packager's email address
9833 + * @return string containing the packager's email address
9835 + const char* getPkgrEmail()
9837 + return m_sPkgrEmail.c_str();
9841 + * Checks if we have a copyright
9844 + * @return true if available, false otherwise
9846 + bool hasCopyright()
9848 + return m_sCopyright.length() ? true : false;
9852 + * Gets the copyright
9855 + * @return string containing the copyright
9857 + const char* getCopyright()
9859 + return m_sCopyright.c_str();
9863 + * Checks if we have an URL
9866 + * @return true if available, false otherwise
9870 + return m_sURL.length() ? true : false;
9877 + * @return string containing the URL
9879 + const char* getURL()
9881 + return m_sURL.c_str();
9885 + * Checks if we have a BuildRoot
9888 + * @return true if available, false otherwise
9890 + bool hasBuildRoot()
9892 + return m_sBuildRoot.length() ? true : false;
9896 + * Gets the buildroot
9899 + * @return string containing the buildroor
9901 + const char* getBuildRoot()
9903 + return m_sBuildRoot.c_str();
9907 + * Gets the prep section
9910 + * @return reference to the prep section
9912 + XMLScripts& getPrep()
9918 + * Gets the build section
9921 + * @return reference to the build section
9923 + XMLScripts& getBuild()
9929 + * Gets the install section
9932 + * @return reference to the install section
9934 + XMLScripts& getInstall()
9940 + * Gets the clean section
9943 + * @return reference to the clean section
9945 + XMLScripts& getClean()
9951 + * Gets the changelog section
9954 + * @return reference to the changelog section
9956 + XMLChangelog& getChangelog()
9958 + return m_Changelog;
9962 +// internal member variables
9965 + string m_sFilename;
9967 + string m_sVersion;
9968 + string m_sRelease;
9970 + string m_sDistribution;
9972 + string m_sPackager;
9973 + string m_sPkgrEmail;
9974 + string m_sCopyright;
9976 + string m_sBuildRoot;
9977 + vector<XMLPackage> m_vPackages;
9978 + vector<XMLSource> m_vSources;
9979 + vector<XMLNoSource> m_vNoSources;
9980 + vector<XMLPatch> m_vPatches;
9981 + vector<XMLMacro> m_vMacros;
9982 + XMLScripts m_Prep;
9983 + XMLScripts m_Build;
9984 + XMLScripts m_Install;
9985 + XMLScripts m_Clean;
9986 + XMLChangelog m_Changelog;
9990 Index: xmlspec/XMLText.cpp
9991 ===================================================================
9992 RCS file: xmlspec/XMLText.cpp
9993 diff -N xmlspec/XMLText.cpp
9994 --- /dev/null 1 Jan 1970 00:00:00 -0000
9995 +++ rpm/xmlspec/XMLText.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
9998 +#include "XMLText.h"
10000 +using namespace std;
10002 +XMLText::XMLText(const char* szText,
10003 + const char* szLang)
10010 +XMLText::XMLText(const XMLText& rText)
10013 + setText(rText.m_sText.c_str());
10014 + setLang(rText.m_sLang.c_str());
10017 +XMLText::~XMLText()
10020 Index: xmlspec/XMLText.h
10021 ===================================================================
10022 RCS file: xmlspec/XMLText.h
10023 diff -N xmlspec/XMLText.h
10024 --- /dev/null 1 Jan 1970 00:00:00 -0000
10025 +++ rpm/xmlspec/XMLText.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
10027 +#ifndef _H_XMLTEXT_
10028 +#define _H_XMLTEXT_
10030 +// standard c++ includes
10034 +#include "XMLBase.h"
10036 +using namespace std;
10038 +class XMLText : public XMLBase
10041 +// constructors/destructor
10045 + * Default constructor
10047 + * @param szText The text to add
10048 + * @param szLang The text's language
10051 + XMLText(const char* szText,
10052 + const char* szLang = NULL);
10055 + * Copy constructor
10057 + * @param rText reference to the text to copy
10060 + XMLText(const XMLText& rText);
10063 + * Default destructor
10071 +// get/set methods for internal variables
10077 + * @param szText The text
10080 + void setText(const char* szText)
10083 + m_sText.assign(szText);
10090 + * @return string containing the text
10092 + const char* getText()
10094 + return m_sText.c_str();
10098 + * Tests if we have a language for this description
10101 + * @return true if we have a language, false otherwise
10105 + return m_sLang.length() ? true : false;
10109 + * Sets the language
10111 + * @param szLang The language
10114 + void setLang(const char* szLang)
10117 + // FIXME: We need to get the actual default language as specified
10118 + // in one of the RPM headers (which I cannot find now) and
10119 + // substitute it here. (I know the value is "C", bu we should
10120 + // use the define.)
10121 + if (strcmp(szLang, "C") != 0)
10122 + m_sLang.assign(szLang);
10127 + * Gets the language
10130 + * @return string containing the language
10132 + const char* getLang()
10134 + return m_sLang.c_str();
10138 +// member variables
10146 Index: xmlspec/example.spec.xml
10147 ===================================================================
10148 RCS file: xmlspec/example.spec.xml
10149 diff -N xmlspec/example.spec.xml
10150 --- /dev/null 1 Jan 1970 00:00:00 -0000
10151 +++ rpm/xmlspec/example.spec.xml 28 Aug 2002 10:52:43 -0000 1.3.2.1
10153 +<?xml version="1.0"?>
10155 + This is an example XML spec file to demonstrate the xml2spec
10156 + conversion program. By running "xml2spec example.spec.xml" it
10157 + will create an output spec in "normal" RPM spec format, ready
10158 + for comsumption by rpmbuild.
10160 +<spec name="example"
10164 + url="http://www.rpm.org/"
10165 + distribution="Any distribution"
10167 + packager="Jaco Greeff"
10168 + packager-email="jaco@puxedo.org"
10169 + buildroot="%{tmppath}/lvr-%{name}-build">
10171 + <macro name="test">value is this</macro>
10173 + <source name="rpm-4.0.4.tar.bz2"
10176 + md5="bb80a5d06a48623ecbe3f2d41cac15f9">
10177 + <mirror path="ftp://ftp.rpm.org/"
10178 + description="Main RPM FTP site" />
10179 + <mirror path="http://www.puxedo.org/downloads/source/"
10180 + description="puxedo.org source distribution"
10183 + <source name="expat-1.95.2.tar.bz2"
10186 + md5="919c78ddaf7f319b7e07792309ae2f22">
10187 + <mirror path="http://expat.sourceforge.net/"
10188 + description="SourceForge Mirror"
10192 + <patch name="example-1.0-1.patch.bz2"
10195 + md5="467c78cbdf75619b7e0abc2309ae2f11" />
10197 + <nosource name="nosource-sample-0.98.bz2"
10200 + <package group="System/Libraries">
10202 + <package name="automake" />
10203 + <package name="autoconf" />
10204 + <package name="bash" />
10205 + <package name="binutils" />
10206 + <package name="gcc" />
10207 + <package name="glibc-devel" />
10210 + <package name="gcc" cmp="ge" version="2.95" />
10211 + <package name="glibc" cmp="ge" version="2.2" />
10212 + <package name="libogg" />
10215 + <package name="%{name}" />
10218 + <package name="old-example" />
10220 + <summary>This spec is just an example for some funny purpose.</summary>
10221 + <summary lang="af">Hierdie is net 'n toets vir i18n in die opsomming</summary>
10222 + <description>%{summary}</description>
10223 + <description lang="af">Nog 'n toets, hierdie keer in die beskrywing</description>
10225 + <script interpreter="/bin/sh">/sbin/ldconfig</script>
10228 + <script>/sbin/ldconfig</script>
10231 + <file user="root" group="root">/usr/lib/*.so*</file>
10235 + <package name="devel"
10236 + group="Development/Libraries">
10238 + <package name="%{name}" />
10239 + <package name="libtool" />
10240 + <package name="m4" />
10242 + <summary>The libvorbis-devel package contains development headers.</summary>
10243 + <description>%{summary}</description>
10245 + <script>some pre stuff under devel</script>
10246 + <script dir="/here/while/we/are/at/it">That ^^^ changed directory</script>
10248 + <files user="root"
10250 + <file>/usr/include/*.h</file>
10251 + <file group="rpm">/usr/lib/*.la</file>
10252 + <file user="rpm">/usr/share/aclocal/*</file>
10253 + <file mode="777">/usr/share/m4/*</file>
10254 + <file user="user" group="group" mode="444">/usr/share/man/*</file>
10258 + <package name="toys" sub="no" group="Application/Toys">
10260 + <package name="%{name}" />
10263 + <package name="oldtoys" />
10265 + <summary>The toys package contains toys</summary>
10266 + <description>%{summary}</description>
10268 + <script>some preun stuff under toys</script>
10271 + <script>Some verify stuff under toys</script>
10274 + <file>/usr/doc/*</file>
10279 + <script>rm -rf $RPM_BUILD_DIR/%{name}-%{version}rc3</script>
10280 + <script>rm -rf %{buildroot}</script>
10281 + <setup path="%{name}-%{version}rc3" />
10285 + <script>./configure --prefix=/usr</script>
10286 + <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>
10290 + <script>make DESTDIR=%{buildroot} install</script>
10294 + <script>rm -rf %{buildroot}</script>
10295 + <script>rm -rf $RPM_BUILD_DIR/%{name}-%{version}rc3</script>
10299 + <changes date="Wed Jun 05 2002"
10300 + author="Jaco Greeff"
10301 + author-email="jaco@puxedo.org"
10302 + version="1.0-06">
10303 + <change>Changed spec to make sure the output spec file can be understood by RPM</change>
10304 + <change>Added languages (description/summary) and a test in Afrikaans</change>
10306 + <changes date="Mon Jun 03 2002"
10307 + author="Jaco Greeff"
10308 + author-email="jaco@puxedo.org"
10309 + version="1.0-05">
10310 + <change>Changed file attributes to mode, user and group</change>
10312 + <changes date="Thu May 30 2002"
10313 + author="Jaco Greeff"
10314 + author-email="jaco@puxedo.org"
10315 + version="1.0-04">
10316 + <change>Added attribute "interpreter" to script</change>
10318 + <changes date="Sat May 25 2002"
10319 + author="Jaco Greeff"
10320 + author-email="jaco@puxedo.org"
10321 + version="1.0-03">
10322 + <change>Moved <files> into <package> structure</change>
10323 + <change>Added <nosource> tag as example</change>
10324 + <change>Changed <shell> to <script></change>
10326 + <changes date="Sun May 19 2002"
10327 + author="Jaco Greeff"
10328 + author-email="jaco@puxedo.org"
10329 + version="1.0-02">
10330 + <change>Changed the formatting of the XML file to fit in with new implementation</change>
10331 + <change>Commented the spec to allow others to understand it as well</change>
10333 + <changes date="Wed May 15 2002"
10334 + author="Jaco Greeff"
10335 + author-email="jaco@puxedo.org"
10336 + version="1.0-01">
10337 + <change>Converted spec file to .spec.xml file for illustrative purposes</change>
10341 Index: xmlspec/spec2xml.cpp
10342 ===================================================================
10343 RCS file: xmlspec/spec2xml.cpp
10344 diff -N xmlspec/spec2xml.cpp
10345 --- /dev/null 1 Jan 1970 00:00:00 -0000
10346 +++ rpm/xmlspec/spec2xml.cpp 28 Aug 2002 10:52:43 -0000 1.1.2.1
10348 +// standard C++ includes
10349 +#include <fstream>
10352 +#include "XMLSpec.h"
10355 +#include <rpmbuild.h>
10357 +// display some usage
10360 + printf("Usage: spec2xml input [output]\n");
10361 + printf("Converts the input pkg.spec file to a pkg.spec.xml\n");
10362 + printf("file for use in an rpmbuild command.\n\n");
10366 +// program entry point
10367 +int main(int argc,
10370 + printf("\nspec2xml, version 0.01\n");
10371 + if (argc != 2 && argc != 3) {
10376 + Spec pSpec = NULL;
10377 + printf("Parsing RPM spec %s:\n", argv[1]);
10378 + if (!parseSpec(&pSpec, argv[1], "/", "/var/tmp", 0, NULL, NULL, 1, 0)) {
10379 + printf("\tOk, spec parsed.\n");
10380 + printf("Creating XML structures:\n");
10381 + XMLSpec* pXSpec = XMLSpec::structCreate(pSpec);
10383 + printf("\tOk, structures created.\n");
10385 + printf("Writing XML to %s ... ", argv[2]);
10386 + ofstream fOut(argv[2]);
10387 + if (fOut.is_open()) {
10388 + pXSpec->toXMLFile(fOut);
10394 + printf("Failed.\n");
10398 + else if (argc == 2) {
10399 + pXSpec->toXMLFile(cout);
10407 + printf("\tFailed.\n");
10410 Index: xmlspec/xml2rpm.c
10411 ===================================================================
10412 RCS file: rpm/xmlspec/xml2rpm.c,v
10413 retrieving revision 1.2.2.1
10414 retrieving revision 1.2.2.2
10415 diff -u -u -r1.2.2.1 -r1.2.2.2
10416 --- rpm/xmlspec/xml2rpm.c 28 Aug 2002 10:52:43 -0000 1.2.2.1
10417 +++ rpm/xmlspec/xml2rpm.c 10 Oct 2002 22:47:59 -0000 1.2.2.2
10419 #include "xml2rpm.h"
10420 #include "xmlstruct.h"
10423 +#include "header_internal.h"
10426 // This is where our packaged scripts start (or the largest number
10428 int g_nMaxSourceNum = 511;
10429 @@ -304,8 +308,14 @@
10430 createRPMSource(pScript->m_szScript, g_nMaxSourceNum+1,
10431 pSpec, RPMBUILD_ISSOURCE);
10433 - if (pScript->m_szEntry)
10434 - appendLineStringBuf(pSb, pScript->m_szEntry);
10435 + if (pScript->m_szEntry) {
10436 + // we do a newStrEx to make sure we expand all
10437 + // macros, as is done in the case of the files
10438 + // (done as part of the fileToStr call)
10439 + newStrEx(pScript->m_szEntry, (char**)(&szTmp));
10440 + appendLineStringBuf(pSb, szTmp);
10441 + freeStr(&(szTmp));
10443 pScript = pScript->m_pNext;
10446 @@ -335,6 +345,32 @@
10447 pScripts->m_szInterpreter, 1);
10450 +void handleProvObsConf(Header pHeader, t_structXMLRequire* pReqs, rpmsenseFlags fSense)
10452 + t_structXMLRequire* pReq = NULL;
10459 + if (pReq->m_szName) {
10461 + if (pReq->m_szCompare && pReq->m_szVersion) {
10462 + for (i = 0; sReqComp[i].m_szCmp; i++) {
10463 + if (!strcasecmp(sReqComp[i].m_szCmp,
10464 + pReq->m_szCompare)) {
10465 + nFlags = (sReqComp[i].m_rpmCmp | RPMSENSE_ANY) & ~RPMSENSE_SENSEMASK;
10469 + addReqProv(NULL, pHeader, fSense | nFlags,
10470 + pReq->m_szName, pReq->m_szVersion, nIndex++);
10472 + pReq = pReq->m_pNext;
10476 void convertXMLPackage(const t_structXMLPackage* pXMLPkg,
10477 const t_structXMLSpec* pXMLSpec,
10479 @@ -364,6 +400,11 @@
10483 + // do the provides, obsoletes, conflicts
10484 + handleProvObsConf(pPkg->header, pXMLPkg->m_pProvides, RPMSENSE_PROVIDES);
10485 + handleProvObsConf(pPkg->header, pXMLPkg->m_pObsoletes, RPMSENSE_OBSOLETES);
10486 + handleProvObsConf(pPkg->header, pXMLPkg->m_pConflicts, RPMSENSE_CONFLICTS);
10488 if (pXMLPkg->m_szName)
10489 headerAddOrAppendEntry(pPkg->header, RPMTAG_NAME,
10490 RPM_STRING_TYPE, pXMLPkg->m_szName, 1);
10491 @@ -514,7 +555,7 @@
10492 pSpec->build = scriptsToStringBuf(pXMLSpec->m_pBuild, pSpec);
10493 pSpec->install = scriptsToStringBuf(pXMLSpec->m_pInstall, pSpec);
10494 pSpec->clean = scriptsToStringBuf(pXMLSpec->m_pClean, pSpec);
10497 convertXMLPackage(pXMLSpec->m_pPackages, pXMLSpec, pSpec);
10499 initSourceHeader(pSpec);
10500 Index: xmlspec/xml2spec.cpp
10501 ===================================================================
10502 RCS file: xmlspec/xml2spec.cpp
10503 diff -N xmlspec/xml2spec.cpp
10504 --- /dev/null 1 Jan 1970 00:00:00 -0000
10505 +++ rpm/xmlspec/xml2spec.cpp 28 Aug 2002 10:52:43 -0000 1.2.2.1
10507 +// standard C++ includes
10508 +#include <fstream>
10511 +#include "XMLParser.h"
10512 +#include "XMLSpec.h"
10514 +// display some usage
10517 + printf("Usage: xml2spec input [output]\n");
10518 + printf("Converts the input pkg.spec.xml file to a pkg.spec\n");
10519 + printf("file for use in an rpmbuild command.\n\n");
10523 +// program entry point
10524 +int main(int argc,
10527 + printf("\nxml2spec, version 0.01\n");
10528 + if (argc != 2 && argc != 3) {
10533 + XMLSpec* pSpec = NULL;
10534 + if (parseXMLSpec(argv[1], pSpec) == 0 && pSpec) {
10536 + printf("Writing spec to %s ... ", argv[2]);
10537 + ofstream fOut(argv[2]);
10538 + if (fOut.is_open()) {
10539 + pSpec->toSpecFile(fOut);
10545 + printf("Failed.\n");
10549 + else if (argc == 2) {
10550 + pSpec->toSpecFile(cout);
10559 Index: xmlspec/xmlparse.c
10560 ===================================================================
10561 RCS file: rpm/xmlspec/xmlparse.c,v
10562 retrieving revision 1.1.2.1
10563 retrieving revision 1.1.2.2
10564 diff -u -u -r1.1.2.1 -r1.1.2.2
10565 --- rpm/xmlspec/xmlparse.c 28 Aug 2002 10:52:43 -0000 1.1.2.1
10566 +++ rpm/xmlspec/xmlparse.c 10 Oct 2002 22:47:59 -0000 1.1.2.2
10568 addXMLMacro(pParse->m_pAttrs, &(pSpec->m_pMacros));
10570 case TAGVAL_SOURCE:
10571 - addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources));
10572 + if (pSpec->m_pSources)
10573 + addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources));
10575 + if ((addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources))) &&
10576 + (pSpec->m_pSources->m_szDirectory)) {
10577 + newStr(pSpec->m_pSources->m_szDirectory,
10578 + (char**)&(pSpec->m_szBuildSubdir));
10583 addXMLSource(pParse->m_pAttrs, &(pSpec->m_pPatches));
10584 @@ -178,6 +186,12 @@
10585 appendStringBuf(pSb, szTmp);
10586 appendStringBuf(pSb, pSource->m_szName);
10588 + else if (!strcasecmp(szTmp, "tgz")) {
10590 + newStrEx("%{_gzipbin} -dc ", &szTmp);
10591 + appendStringBuf(pSb, szTmp);
10592 + appendStringBuf(pSb, pSource->m_szName);
10594 else if (!strcasecmp(szTmp, "zip")) {
10596 newStrEx("%{_unzipbin} ", &szTmp);
10597 @@ -265,8 +279,8 @@
10598 appendStringBuf(pSb, pSource->m_szName);
10601 - szTmp = malloc(strlen(" > patch -p1234567890 -s ")+strlen(pSource->m_szName)+1);
10602 - sprintf(szTmp, " | patch -p%d -s", nLevel);
10603 + szTmp = malloc(strlen(" > patch -pN1234567890 -s ")+strlen(pSource->m_szName)+1);
10604 + sprintf(szTmp, " | patch -Np%d -s", nLevel);
10605 appendStringBuf(pSb, szTmp);
10606 appendLineStringBuf(pSb, "");
10607 appendLineStringBuf(pSb, "STATUS=$?");
10608 @@ -290,6 +304,9 @@
10609 case TAGVAL_SUMMARY:
10610 case TAGVAL_DESCRIPTION:
10611 case TAGVAL_REQUIRES:
10612 + case TAGVAL_PROVIDES:
10613 + case TAGVAL_OBSOLETES:
10614 + case TAGVAL_CONFLICTS:
10615 // we don't need to do anything
10618 @@ -315,6 +332,18 @@
10619 pPkg = getLastXMLPackage(pSpec->m_pPackages);
10620 addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pRequires));
10622 + case TAGVAL_PROVIDE:
10623 + pPkg = getLastXMLPackage(pSpec->m_pPackages);
10624 + addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pProvides));
10626 + case TAGVAL_OBSOLETE:
10627 + pPkg = getLastXMLPackage(pSpec->m_pPackages);
10628 + addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pObsoletes));
10630 + case TAGVAL_CONFLICT:
10631 + pPkg = getLastXMLPackage(pSpec->m_pPackages);
10632 + addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pConflicts));
10634 case TAGVAL_CHANGE:
10635 pChanges = getLastXMLChanges(pSpec->m_pChangelog);
10636 addXMLChange(pParse->m_pAttrs, &(pChanges->m_pChanges));
10637 @@ -544,32 +573,26 @@
10640 t_structXMLParse* pParse = NULL;
10641 + char* szVal = NULL;
10642 char* szTmp = NULL;
10643 - char* szTmpValue = NULL;
10644 - char* szPos = NULL;
10646 if ((pParse = (t_structXMLParse*)pData)) {
10647 - szTmp = malloc(nLen+2);
10648 - szTmp[nLen] = '\0';
10649 - snprintf(szTmp, nLen+1, "%s", szValue);
10651 - while ((*szPos == ' ') ||
10652 - (*szPos == '\t') ||
10653 - (*szPos == '\r') ||
10654 - (*szPos == '\n'))
10657 - if (strlen(szPos)) {
10658 + szVal = malloc(nLen+2);
10659 + szVal[nLen] = '\0';
10660 + snprintf(szVal, nLen+1, "%s", szValue);
10661 + if (strlen(szVal)) {
10662 + while ((szTmp = strchr(szVal, '\t')))
10664 if (pParse->m_szValue) {
10665 - szTmpValue = malloc(strlen(szPos)+strlen(pParse->m_szValue)+1);
10666 - sprintf(szTmpValue, "%s%s", pParse->m_szValue, szPos);
10667 - newStr(szTmpValue, &(pParse->m_szValue));
10668 - free(szTmpValue);
10669 + szTmp = malloc(strlen(szVal)+strlen(pParse->m_szValue)+1);
10670 + sprintf(szTmp, "%s%s", pParse->m_szValue, szVal);
10671 + newStr(szTmp, &(pParse->m_szValue));
10675 - newStr(szPos, &(pParse->m_szValue));
10676 + newStr(szVal, &(pParse->m_szValue));
10683 Index: xmlspec/xmlstruct.c
10684 ===================================================================
10685 RCS file: rpm/xmlspec/xmlstruct.c,v
10686 retrieving revision 1.2.2.1
10687 retrieving revision 1.2.2.2
10688 diff -u -u -r1.2.2.1 -r1.2.2.2
10689 --- rpm/xmlspec/xmlstruct.c 28 Aug 2002 10:52:43 -0000 1.2.2.1
10690 +++ rpm/xmlspec/xmlstruct.c 10 Oct 2002 22:47:59 -0000 1.2.2.2
10693 while (pAttr && (strcasecmp(szName, pAttr->m_szName) != 0))
10694 pAttr = pAttr->m_pNext;
10700 @@ -236,7 +236,7 @@
10701 attrSetInt(pAttr, "size", &(pSource->m_nSize));
10702 attrSetStr(pAttr, "md5", &(pSource->m_szMD5));
10703 attrSetStr(pAttr, "directory", &(pSource->m_szDirectory));
10704 - attrSetInt(pAttr, "number", &(pSource->m_nNum));
10705 + attrSetInt(pAttr, "id", &(pSource->m_nNum));
10706 } while ((pAttr = pAttr->m_pNext));
10709 @@ -365,6 +365,8 @@
10711 if ((pScript = malloc(sizeof(t_structXMLScript)))) {
10712 pScript->m_szInterpreter = NULL;
10713 + pScript->m_szArch = NULL;
10714 + pScript->m_szOS = NULL;
10715 pScript->m_szScript = NULL;
10716 pScript->m_szEntry = NULL;
10717 pScript->m_pNext = NULL;
10718 @@ -373,6 +375,10 @@
10720 attrSetStr(pAttr, "interpreter",
10721 &(pScript->m_szInterpreter));
10722 + attrSetStr(pAttr, "arch",
10723 + &(pScript->m_szArch));
10724 + attrSetStr(pAttr, "os",
10725 + &(pScript->m_szOS));
10726 attrSetStr(pAttr, "script",
10727 &(pScript->m_szScript));
10728 } while ((pAttr = pAttr->m_pNext));
10729 @@ -386,6 +392,8 @@
10732 freeStr(&((*ppScript)->m_szInterpreter));
10733 + freeStr(&((*ppScript)->m_szArch));
10734 + freeStr(&((*ppScript)->m_szOS));
10735 freeStr(&((*ppScript)->m_szScript));
10736 freeStr(&((*ppScript)->m_szEntry));
10737 freeXMLScript(&((*ppScript)->m_pNext));
10738 @@ -485,6 +493,59 @@
10742 +t_structI18NStr* newI18NStr(const t_structXMLAttr* pAttrs)
10744 + t_structI18NStr* pStr = NULL;
10745 + t_structXMLAttr* pAttr = NULL;
10747 + if ((pStr = malloc(sizeof(t_structI18NStr)))) {
10748 + pStr->m_szLang = NULL;
10749 + pStr->m_szText = NULL;
10750 + pStr->m_pNext = NULL;
10752 + pAttr = (t_structXMLAttr*)pAttrs;
10754 + attrSetStr(pAttr, "lang", &(pStr->m_szLang));
10755 + } while ((pAttr = pAttr->m_pNext));
10761 +int freeI18NStr(t_structI18NStr** ppStr)
10764 + freeStr(&((*ppStr)->m_szLang));
10765 + freeStr(&((*ppStr)->m_szText));
10766 + freeI18NStr(&((*ppStr)->m_pNext));
10774 +t_structI18NStr* addI18NStr(const t_structXMLAttr* pAttrs,
10775 + t_structI18NStr** ppStr)
10777 + t_structI18NStr* pStr = NULL;
10779 + if ((pStr = getLastI18NStr(*ppStr)))
10780 + pStr = (pStr->m_pNext = newI18NStr(pAttrs));
10782 + pStr = (*ppStr = newI18NStr(pAttrs));
10787 +t_structI18NStr* getLastI18NStr(t_structI18NStr* pStr)
10789 + while (pStr && (pStr->m_pNext))
10790 + pStr = pStr->m_pNext;
10795 t_structXMLPackage* newXMLPackage(const t_structXMLAttr* pAttrs)
10797 t_structXMLPackage* pPackage = NULL;
10798 @@ -492,6 +553,7 @@
10800 if ((pPackage = malloc(sizeof(t_structXMLPackage)))) {
10801 pPackage->m_szName = NULL;
10802 + pPackage->m_szVersion = NULL;
10803 pPackage->m_szGroup = NULL;
10804 pPackage->m_szSummary = NULL;
10805 pPackage->m_szDescription = NULL;
10806 @@ -507,15 +569,21 @@
10807 pPackage->m_pRequires = NULL;
10808 pPackage->m_pSuggests = NULL;
10809 pPackage->m_pObsoletes = NULL;
10810 + pPackage->m_pConflicts = NULL;
10811 pPackage->m_pProvides = NULL;
10812 pPackage->m_pNext = NULL;
10814 pAttr = (t_structXMLAttr*)pAttrs;
10816 attrSetStr(pAttr, "name", &(pPackage->m_szName));
10817 + attrSetStr(pAttr, "version", &(pPackage->m_szVersion));
10818 attrSetStr(pAttr, "group", &(pPackage->m_szGroup));
10819 attrSetBool(pAttr, "autorequire", &(pPackage->m_nAutoRequire));
10820 + attrSetBool(pAttr, "autoreq", &(pPackage->m_nAutoRequire));
10821 attrSetBool(pAttr, "autoprovide", &(pPackage->m_nAutoProvide));
10822 + attrSetBool(pAttr, "autoprov", &(pPackage->m_nAutoProvide));
10823 + attrSetBool(pAttr, "autoreqprov", &(pPackage->m_nAutoProvide));
10824 + attrSetBool(pAttr, "autoreqprov", &(pPackage->m_nAutoRequire));
10825 attrSetBool(pAttr, "autosuggest", &(pPackage->m_nAutoSuggest));
10826 } while ((pAttr = pAttr->m_pNext));
10828 @@ -527,6 +595,7 @@
10831 freeStr(&((*ppPackage)->m_szName));
10832 + freeStr(&((*ppPackage)->m_szVersion));
10833 freeStr(&((*ppPackage)->m_szGroup));
10834 freeStr(&((*ppPackage)->m_szSummary));
10835 freeStr(&((*ppPackage)->m_szDescription));
10836 @@ -539,6 +608,7 @@
10837 freeXMLRequire(&((*ppPackage)->m_pRequires));
10838 freeXMLRequire(&((*ppPackage)->m_pSuggests));
10839 freeXMLRequire(&((*ppPackage)->m_pObsoletes));
10840 + freeXMLRequire(&((*ppPackage)->m_pConflicts));
10841 freeXMLRequire(&((*ppPackage)->m_pProvides));
10842 freeXMLPackage(&((*ppPackage)->m_pNext));
10844 Index: xmlspec/xmlstruct.h
10845 ===================================================================
10846 RCS file: rpm/xmlspec/xmlstruct.h,v
10847 retrieving revision 1.1.2.1
10848 retrieving revision 1.1.2.2
10849 diff -u -u -r1.1.2.1 -r1.1.2.2
10850 --- rpm/xmlspec/xmlstruct.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
10851 +++ rpm/xmlspec/xmlstruct.h 10 Oct 2002 22:47:59 -0000 1.1.2.2
10853 typedef struct structXMLScript
10855 char* m_szInterpreter;
10860 struct structXMLScript* m_pNext;
10863 } t_structXMLFiles;
10865 +typedef struct structI18NStr
10869 + struct structI18NStr* m_pNext;
10870 +} t_structI18NStr;
10872 typedef struct structXMLPackage
10875 + char* m_szVersion;
10878 char* m_szDescription;
10880 struct structXMLRequire* m_pRequires;
10881 struct structXMLRequire* m_pSuggests;
10882 struct structXMLRequire* m_pObsoletes;
10883 + struct structXMLRequire* m_pConflicts;
10884 struct structXMLRequire* m_pProvides;
10885 struct structXMLPackage* m_pNext;
10886 } t_structXMLPackage;
10887 @@ -200,6 +211,12 @@
10889 t_structXMLFiles* newXMLFiles(const t_structXMLAttr* pAttrs);
10890 int freeXMLFiles(t_structXMLFiles** ppFiles);
10892 +t_structI18NStr* newI18NStr(const t_structXMLAttr* pAttrs);
10893 +int freeI18NStr(t_structI18NStr** ppStr);
10894 +t_structI18NStr* addI18NStr(const t_structXMLAttr* pAttrs,
10895 + t_structI18NStr** ppStr);
10896 +t_structI18NStr* getLastI18NStr(t_structI18NStr* pStr);
10898 t_structXMLPackage* newXMLPackage(const t_structXMLAttr* pAttrs);
10899 int freeXMLPackage(t_structXMLPackage** ppPackage);
10900 Index: xmlspec/xmlverify.c
10901 ===================================================================
10902 RCS file: rpm/xmlspec/xmlverify.c,v
10903 retrieving revision 1.1.2.1
10904 retrieving revision 1.1.2.2
10905 diff -u -u -r1.1.2.1 -r1.1.2.2
10906 --- rpm/xmlspec/xmlverify.c 28 Aug 2002 10:52:43 -0000 1.1.2.1
10907 +++ rpm/xmlspec/xmlverify.c 10 Oct 2002 22:47:59 -0000 1.1.2.2
10909 {"size", ATTRTYPE_NUMERIC, 0},
10910 {"md5", ATTRTYPE_MD5, 0},
10911 {"path", ATTRTYPE_ANY, 0},
10912 - {"number", ATTRTYPE_NUMERIC, 0},
10913 + {"id", ATTRTYPE_NUMERIC, 0},
10914 {NULL, ATTRTYPE_ANY, 1}
10918 {"size", ATTRTYPE_NUMERIC, 0},
10919 {"md5", ATTRTYPE_MD5, 0},
10920 {"path", ATTRTYPE_ANY, 0},
10921 - {"number", ATTRTYPE_NUMERIC, 0},
10922 + {"id", ATTRTYPE_NUMERIC, 0},
10923 {NULL, ATTRTYPE_ANY, 1}
10926 @@ -165,6 +165,7 @@
10929 {"name", ATTRTYPE_ANY, 0},
10930 + {"version", ATTRTYPE_ANY, 0},
10931 {"group", ATTRTYPE_ANY, 1},
10932 {"autoreqprov", ATTRTYPE_BOOL, 0},
10933 {"autoprov", ATTRTYPE_BOOL, 0},
10934 @@ -219,6 +220,7 @@
10937 {"name", ATTRTYPE_ANY, 1},
10938 + {"version", ATTRTYPE_ANY, 0},
10939 {NULL, ATTRTYPE_ANY, 1}
10942 @@ -243,6 +245,34 @@
10945 {"name", ATTRTYPE_ANY, 1},
10946 + {"version", ATTRTYPE_ANY, 0},
10947 + {"cmp", ATTRTYPE_CMP, 0},
10948 + {NULL, ATTRTYPE_ANY, 1}
10952 + "conflicts", TAGVAL_CONFLICTS, 2,
10959 + {NULL, ATTRTYPE_ANY, 1}
10963 + "conflict", TAGVAL_CONFLICT, 3,
10967 + TAGVAL_CONFLICTS,
10971 + {"name", ATTRTYPE_ANY, 1},
10972 + {"version", ATTRTYPE_ANY, 0},
10973 + {"cmp", ATTRTYPE_CMP, 0},
10974 {NULL, ATTRTYPE_ANY, 1}
10977 @@ -280,6 +310,7 @@
10981 + {"lang", ATTRTYPE_ANY, 0},
10982 {NULL, ATTRTYPE_ANY, 1}
10985 @@ -291,6 +322,7 @@
10989 + {"lang", ATTRTYPE_ANY, 0},
10990 {NULL, ATTRTYPE_ANY, 1}
10993 @@ -317,6 +349,8 @@
10996 {"interpreter", ATTRTYPE_ANY, 0},
10997 + {"arch", ATTRTYPE_ANY, 0},
10998 + {"os", ATTRTYPE_ANY, 0},
10999 {"script", ATTRTYPE_SCRIPT, 0},
11000 {NULL, ATTRTYPE_ANY, 1}
11002 @@ -344,6 +378,8 @@
11005 {"interpreter", ATTRTYPE_ANY, 0},
11006 + {"arch", ATTRTYPE_ANY, 0},
11007 + {"os", ATTRTYPE_ANY, 0},
11008 {"script", ATTRTYPE_SCRIPT, 0},
11009 {NULL, ATTRTYPE_ANY, 1}
11011 @@ -371,6 +407,8 @@
11014 {"interpreter", ATTRTYPE_ANY, 0},
11015 + {"arch", ATTRTYPE_ANY, 0},
11016 + {"os", ATTRTYPE_ANY, 0},
11017 {"script", ATTRTYPE_SCRIPT, 0},
11018 {NULL, ATTRTYPE_ANY, 1}
11020 @@ -398,11 +436,14 @@
11023 {"interpreter", ATTRTYPE_ANY, 0},
11024 + {"arch", ATTRTYPE_ANY, 0},
11025 + {"os", ATTRTYPE_ANY, 0},
11026 {"script", ATTRTYPE_SCRIPT, 0},
11027 {NULL, ATTRTYPE_ANY, 1}
11030 - {"verify", TAGVAL_VERIFY, 2,
11032 + "verify", TAGVAL_VERIFY, 2,
11036 @@ -424,6 +465,8 @@
11039 {"interpreter", ATTRTYPE_ANY, 0},
11040 + {"arch", ATTRTYPE_ANY, 0},
11041 + {"os", ATTRTYPE_ANY, 0},
11042 {"script", ATTRTYPE_SCRIPT, 0},
11043 {NULL, ATTRTYPE_ANY, 1}
11045 @@ -463,6 +506,8 @@
11048 {"interpreter", ATTRTYPE_ANY, 0},
11049 + {"arch", ATTRTYPE_ANY, 0},
11050 + {"os", ATTRTYPE_ANY, 0},
11051 {"script", ATTRTYPE_SCRIPT, 0},
11052 {NULL, ATTRTYPE_ANY, 1}
11054 @@ -476,6 +521,8 @@
11057 {"source", ATTRTYPE_NUMERIC, 0},
11058 + {"arch", ATTRTYPE_ANY, 0},
11059 + {"os", ATTRTYPE_ANY, 0},
11060 {"path", ATTRTYPE_ANY, 0},
11061 {NULL, ATTRTYPE_ANY, 1}
11063 @@ -489,6 +536,8 @@
11066 {"patch", ATTRTYPE_NUMERIC, 0},
11067 + {"arch", ATTRTYPE_ANY, 0},
11068 + {"os", ATTRTYPE_ANY, 0},
11069 {"level", ATTRTYPE_NUMERIC, 0},
11070 {"path", ATTRTYPE_ANY, 0},
11071 {NULL, ATTRTYPE_ANY, 1}
11072 @@ -515,6 +564,8 @@
11075 {"interpreter", ATTRTYPE_ANY, 0},
11076 + {"arch", ATTRTYPE_ANY, 0},
11077 + {"os", ATTRTYPE_ANY, 0},
11078 {"script", ATTRTYPE_SCRIPT, 0},
11079 {NULL, ATTRTYPE_ANY, 1}
11081 @@ -540,6 +591,8 @@
11084 {"interpreter", ATTRTYPE_ANY, 0},
11085 + {"arch", ATTRTYPE_ANY, 0},
11086 + {"os", ATTRTYPE_ANY, 0},
11087 {"script", ATTRTYPE_SCRIPT, 0},
11088 {NULL, ATTRTYPE_ANY, 1}
11090 @@ -565,6 +618,8 @@
11093 {"interpreter", ATTRTYPE_ANY, 0},
11094 + {"arch", ATTRTYPE_ANY, 0},
11095 + {"os", ATTRTYPE_ANY, 0},
11096 {"script", ATTRTYPE_SCRIPT, 0},
11097 {NULL, ATTRTYPE_ANY, 1}
11099 Index: xmlspec/xmlverify.h
11100 ===================================================================
11101 RCS file: rpm/xmlspec/xmlverify.h,v
11102 retrieving revision 1.1.2.1
11103 retrieving revision 1.1.2.2
11104 diff -u -u -r1.1.2.1 -r1.1.2.2
11105 --- rpm/xmlspec/xmlverify.h 28 Aug 2002 10:52:43 -0000 1.1.2.1
11106 +++ rpm/xmlspec/xmlverify.h 10 Oct 2002 22:47:59 -0000 1.1.2.2
11111 + TAGVAL_CONFLICTS,