diff -r 333964c621f1 -r cb59d6afeb61 openpkg/rpm.patch.feature
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openpkg/rpm.patch.feature Tue Jan 06 23:40:39 2009 +0100
@@ -0,0 +1,2211 @@
+##
+## rpm.patch.feature -- Annotated OpenPKG RPM Patch file
+## Copyright (c) 2000-2007 OpenPKG Foundation e.V.
+## Copyright (c) 2000-2007 Ralf S. Engelschall
+##
+## This file assembles changes to existing RPM source files between
+## the original RedHat RPM and the OpenPKG RPM variant. It can be
+## automatically applied to a vanilla RedHat RPM source tree with the
+## 'patch' tool to upgrade those files. Each patch snippet is annotated
+## with a short description.
+##
+## Created on: 13-Sep-2006
+##
+## ATTENTION: THIS PATCH FILE WAS AUTO-GENERATED FROM AN OPENPKG
+## RPM CVS REPOSITORY, HENCE DO NOT EDIT THIS FILE.
+##
+
++---------------------------------------------------------------------------
+| Remove "tools" directory from sub-directory list because it contains
+| things we are not interested in and which cause some build trouble
+| anyway.
+| Use a plain "rpmpopt" file without any trailing version.
+| Adjust paths to conform to OpenPKG filesystem layout.
+| Do not run the "installplatform" script, because not needed for OpenPKG.
++---------------------------------------------------------------------------
+Index: Makefile.am
+--- Makefile.am 29 May 2003 18:20:28 -0000 1.1.1.17
++++ Makefile.am 22 Jan 2004 21:42:02 -0000 1.2
+@@ -12,9 +12,9 @@
+ xmlspec/examples/*.sh xmlspec/examples/*.lst \
+ xmlspec/examples/*.xmlspec \
+ po/*.in po/*.po po/rpm.pot \
+- rpm.magic rpmpopt-$(VERSION) rpmqv.c rpm.c
++ rpm.magic rpmpopt rpmqv.c rpm.c
+
+-SUBDIRS = intl po @WITH_ZLIB_SUBDIR@ @WITH_ELFUTILS_SUBDIR@ file @WITH_DB_SUBDIR@ popt @WITH_BEECRYPT_SUBDIR@ rpmio rpmdb lib build misc @WITH_PYTHON_SUBDIR@ tools scripts tests doc .
++SUBDIRS = intl @WITH_ZLIB_SUBDIR@ @WITH_ELFUTILS_SUBDIR@ file @WITH_DB_SUBDIR@ popt @WITH_BEECRYPT_SUBDIR@ rpmio rpmdb lib build misc @WITH_PYTHON_SUBDIR@ scripts tests doc .
+
+ INCLUDES = \
+ -I$(top_srcdir)/build \
+@@ -47,13 +47,10 @@
+
+ pkglibdir = @RPMCONFIGDIR@
+ pkglib_PROGRAMS = rpmb rpmd rpmi rpmk rpmq
+-pkglib_DATA = rpmrc rpmpopt-$(VERSION) macros
++pkglib_DATA = rpmrc rpmpopt macros
+ pkglib_SCRIPTS = find-provides find-requires mkinstalldirs \
+ config.guess config.sub config.site
+
+-rpmpopt-$(VERSION): rpmpopt
+- cp rpmpopt $@
+-
+ noinst_HEADERS = build.h debug.h system.h
+
+ rpm_SOURCES =
+@@ -124,32 +121,32 @@
+ pkgsrcdir = $(prefix)/src/$(RPMCANONVENDOR)
+
+ install-data-local:
+- @$(mkinstalldirs) $(DESTDIR)$(varprefix)/lib/rpm
++ @$(mkinstalldirs) $(DESTDIR)$(varprefix)/lib/openpkg
+ @rm -f $(DESTDIR)$(libdir)/rpmrc
+ @@LN_S@ rpm/rpmrc $(DESTDIR)$(libdir)/rpmrc
+ @rm -f $(DESTDIR)$(libdir)/rpmpopt
+ @@LN_S@ rpm/rpmpopt $(DESTDIR)$(libdir)/rpmpopt
+ @rm -f $(DESTDIR)$(libdir)/rpm/rpmt
+- @@LN_S@ rpmb $(DESTDIR)$(libdir)/rpm/rpmt
+- @rm -f $(DESTDIR)$(libdir)/rpm/rpme
+- @@LN_S@ rpmi $(DESTDIR)$(libdir)/rpm/rpme
+- @rm -f $(DESTDIR)$(libdir)/rpm/rpmu
+- @@LN_S@ rpmi $(DESTDIR)$(libdir)/rpm/rpmu
+- @rm -f $(DESTDIR)$(libdir)/rpm/rpmv
+- @@LN_S@ rpmq $(DESTDIR)$(libdir)/rpm/rpmv
++ @@LN_S@ rpmb $(DESTDIR)$(libdir)/openpkg/rpmt
++ @rm -f $(DESTDIR)$(libdir)/openpkg/rpme
++ @@LN_S@ rpmi $(DESTDIR)$(libdir)/openpkg/rpme
++ @rm -f $(DESTDIR)$(libdir)/openpkg/rpmu
++ @@LN_S@ rpmi $(DESTDIR)$(libdir)/openpkg/rpmu
++ @rm -f $(DESTDIR)$(libdir)/openpkg/rpmv
++ @@LN_S@ rpmq $(DESTDIR)$(libdir)/openpkg/rpmv
+ rm -f $(DESTDIR)$(bindir)/rpmbuild
+- @LN_S@ ../lib/rpm/rpmb $(DESTDIR)$(bindir)/rpmbuild
++ @LN_S@ ../lib/openpkg/rpmb $(DESTDIR)$(bindir)/rpmbuild
+ rm -f $(DESTDIR)$(bindir)/rpmquery
+- @LN_S@ ../lib/rpm/rpmq $(DESTDIR)$(bindir)/rpmquery
++ @LN_S@ ../lib/openpkg/rpmq $(DESTDIR)$(bindir)/rpmquery
+ rm -f $(DESTDIR)$(bindir)/rpmverify
+- @LN_S@ ../lib/rpm/rpmv $(DESTDIR)$(bindir)/rpmverify
++ @LN_S@ ../lib/openpkg/rpmv $(DESTDIR)$(bindir)/rpmverify
+ rm -f $(DESTDIR)$(bindir)/rpmsign
+- @LN_S@ ../lib/rpm/rpmk $(DESTDIR)$(bindir)/rpmsign
++ @LN_S@ ../lib/openpkg/rpmk $(DESTDIR)$(bindir)/rpmsign
+ rm -f $(DESTDIR)$(bindir)/rpmdb ; \
+- @LN_S@ ../lib/rpm/rpmd $(DESTDIR)$(bindir)/rpmdb ; \
++ @LN_S@ ../lib/openpkg/rpmd $(DESTDIR)$(bindir)/rpmdb ; \
+ for bf in e i u ; do \
+ rm -f $(DESTDIR)$(bindir)/rpm$$bf ; \
+- @LN_S@ ../lib/rpm/rpm$$bf $(DESTDIR)$(bindir)/rpm$$bf ; \
++ @LN_S@ ../lib/openpkg/rpm$$bf $(DESTDIR)$(bindir)/rpm$$bf ; \
+ done
+ @for dir in BUILD RPMS SOURCES SPECS SRPMS ; do\
+ $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/$$dir;\
+@@ -174,11 +171,6 @@
+ *) $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/@host_cpu@ ;;\
+ esac
+ $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/noarch
+- @case "@host_os@" in \
+- mint) $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/m68kmint ;;\
+- solaris*|linux*) \
+- chmod u+x ./installplatform; DESTDIR="$(DESTDIR)" pkglibdir="$(pkglibdir)" ./installplatform rpmrc macros platform ;; \
+- esac
+ @$(mkinstalldirs) $(DESTDIR)/var/tmp
+
+ .PHONY: setperms
+@@ -198,10 +190,10 @@
+ $(__CHOWN) ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(pkglibdir)/$$f ;\
+ done
+ @$(__CHOWN) ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(pkglibdir)
+- @$(__CHOWN) -R ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(varprefix)/lib/rpm
+- -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/rpm/[A-Z]*
+- -@$(__CHMOD) 0775 $(DESTDIR)$(varprefix)/lib/rpm
+- -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/rpm/__db.*
++ @$(__CHOWN) -R ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(varprefix)/lib/openpkg
++ -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/openpkg/[A-Z]*
++ -@$(__CHMOD) 0775 $(DESTDIR)$(varprefix)/lib/openpkg
++ -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/openpkg/__db.*
+
+ .PHONY: unsetgid
+ unsetgid:
+@@ -244,7 +236,7 @@
+ @sudo ./rpm -ta rpm-$(VERSION).tar.gz
+
+ .PHONY: doxygen
+-doxygen @WITH_APIDOCS_TARGET@: Doxyfile rpmpopt-@VERSION@
++doxygen @WITH_APIDOCS_TARGET@: Doxyfile rpmpopt
+ rm -rf $@
+ mkdir -p $@
+ - [ X"@__DOXYGEN@" != Xno ] && @__DOXYGEN@
+
++---------------------------------------------------------------------------
+| Remove "tools" directory from sub-directory list because it contains
+| things we are not interested in and which cause some build trouble
+| anyway.
+| Use a plain "rpmpopt" file without any trailing version.
+| Adjust paths to conform to OpenPKG filesystem layout.
+| Do not run the "installplatform" script, because not needed for OpenPKG.
++---------------------------------------------------------------------------
+Index: Makefile.in
+--- Makefile.in 16 Jul 2003 17:05:42 -0000 1.1.1.23
++++ Makefile.in 22 Jan 2004 21:42:03 -0000 1.2
+@@ -265,10 +265,10 @@
+ xmlspec/examples/*.sh xmlspec/examples/*.lst \
+ xmlspec/examples/*.xmlspec \
+ po/*.in po/*.po po/rpm.pot \
+- rpm.magic rpmpopt-$(VERSION) rpmqv.c rpm.c
++ rpm.magic rpmpopt rpmqv.c rpm.c
+
+
+-SUBDIRS = intl po @WITH_ZLIB_SUBDIR@ @WITH_ELFUTILS_SUBDIR@ file @WITH_DB_SUBDIR@ popt @WITH_BEECRYPT_SUBDIR@ rpmio rpmdb lib build misc @WITH_PYTHON_SUBDIR@ tools scripts tests doc .
++SUBDIRS = intl @WITH_ZLIB_SUBDIR@ @WITH_ELFUTILS_SUBDIR@ file @WITH_DB_SUBDIR@ popt @WITH_BEECRYPT_SUBDIR@ rpmio rpmdb lib build misc @WITH_PYTHON_SUBDIR@ scripts tests doc .
+
+ INCLUDES = \
+ -I$(top_srcdir)/build \
+@@ -301,7 +301,7 @@
+ bin_PROGRAMS = rpm2cpio
+ bin_SCRIPTS = gendiff
+ pkglib_PROGRAMS = rpmb rpmd rpmi rpmk rpmq
+-pkglib_DATA = rpmrc rpmpopt-$(VERSION) macros
++pkglib_DATA = rpmrc rpmpopt macros
+ pkglib_SCRIPTS = find-provides find-requires mkinstalldirs \
+ config.guess config.sub config.site
+
+@@ -1058,8 +1058,6 @@
+ uninstall-rpmbinPROGRAMS
+
+
+-rpmpopt-$(VERSION): rpmpopt
+- cp rpmpopt $@
+ rpm.o: rpmqv.c
+ $(COMPILE) -DIAM_RPMDB -DIAM_RPMEIU -DIAM_RPMK -DIAM_RPMQV -o $@ -c rpmqv.c
+ rpmb.o: rpmqv.c
+@@ -1097,32 +1095,32 @@
+ `make -s sources -C popt`
+
+ install-data-local:
+- @$(mkinstalldirs) $(DESTDIR)$(varprefix)/lib/rpm
++ @$(mkinstalldirs) $(DESTDIR)$(varprefix)/lib/openpkg
+ @rm -f $(DESTDIR)$(libdir)/rpmrc
+ @@LN_S@ rpm/rpmrc $(DESTDIR)$(libdir)/rpmrc
+ @rm -f $(DESTDIR)$(libdir)/rpmpopt
+ @@LN_S@ rpm/rpmpopt $(DESTDIR)$(libdir)/rpmpopt
+- @rm -f $(DESTDIR)$(libdir)/rpm/rpmt
+- @@LN_S@ rpmb $(DESTDIR)$(libdir)/rpm/rpmt
+- @rm -f $(DESTDIR)$(libdir)/rpm/rpme
+- @@LN_S@ rpmi $(DESTDIR)$(libdir)/rpm/rpme
+- @rm -f $(DESTDIR)$(libdir)/rpm/rpmu
+- @@LN_S@ rpmi $(DESTDIR)$(libdir)/rpm/rpmu
+- @rm -f $(DESTDIR)$(libdir)/rpm/rpmv
+- @@LN_S@ rpmq $(DESTDIR)$(libdir)/rpm/rpmv
++ @rm -f $(DESTDIR)$(libdir)/openpkg/rpmt
++ @@LN_S@ rpmb $(DESTDIR)$(libdir)/openpkg/rpmt
++ @rm -f $(DESTDIR)$(libdir)/openpkg/rpme
++ @@LN_S@ rpmi $(DESTDIR)$(libdir)/openpkg/rpme
++ @rm -f $(DESTDIR)$(libdir)/openpkg/rpmu
++ @@LN_S@ rpmi $(DESTDIR)$(libdir)/openpkg/rpmu
++ @rm -f $(DESTDIR)$(libdir)/openpkg/rpmv
++ @@LN_S@ rpmq $(DESTDIR)$(libdir)/openpkg/rpmv
+ rm -f $(DESTDIR)$(bindir)/rpmbuild
+- @LN_S@ ../lib/rpm/rpmb $(DESTDIR)$(bindir)/rpmbuild
++ @LN_S@ ../lib/openpkg/rpmb $(DESTDIR)$(bindir)/rpmbuild
+ rm -f $(DESTDIR)$(bindir)/rpmquery
+- @LN_S@ ../lib/rpm/rpmq $(DESTDIR)$(bindir)/rpmquery
++ @LN_S@ ../lib/openpkg/rpmq $(DESTDIR)$(bindir)/rpmquery
+ rm -f $(DESTDIR)$(bindir)/rpmverify
+- @LN_S@ ../lib/rpm/rpmv $(DESTDIR)$(bindir)/rpmverify
++ @LN_S@ ../lib/openpkg/rpmv $(DESTDIR)$(bindir)/rpmverify
+ rm -f $(DESTDIR)$(bindir)/rpmsign
+- @LN_S@ ../lib/rpm/rpmk $(DESTDIR)$(bindir)/rpmsign
++ @LN_S@ ../lib/openpkg/rpmk $(DESTDIR)$(bindir)/rpmsign
+ rm -f $(DESTDIR)$(bindir)/rpmdb ; \
+- @LN_S@ ../lib/rpm/rpmd $(DESTDIR)$(bindir)/rpmdb ; \
++ @LN_S@ ../lib/openpkg/rpmd $(DESTDIR)$(bindir)/rpmdb ; \
+ for bf in e i u ; do \
+ rm -f $(DESTDIR)$(bindir)/rpm$$bf ; \
+- @LN_S@ ../lib/rpm/rpm$$bf $(DESTDIR)$(bindir)/rpm$$bf ; \
++ @LN_S@ ../lib/openpkg/rpm$$bf $(DESTDIR)$(bindir)/rpm$$bf ; \
+ done
+ @for dir in BUILD RPMS SOURCES SPECS SRPMS ; do\
+ $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/$$dir;\
+@@ -1147,11 +1145,6 @@
+ *) $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/@host_cpu@ ;;\
+ esac
+ $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/noarch
+- @case "@host_os@" in \
+- mint) $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/m68kmint ;;\
+- solaris*|linux*) \
+- chmod u+x ./installplatform; DESTDIR="$(DESTDIR)" pkglibdir="$(pkglibdir)" ./installplatform rpmrc macros platform ;; \
+- esac
+ @$(mkinstalldirs) $(DESTDIR)/var/tmp
+
+ .PHONY: setperms
+@@ -1171,10 +1164,10 @@
+ $(__CHOWN) ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(pkglibdir)/$$f ;\
+ done
+ @$(__CHOWN) ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(pkglibdir)
+- @$(__CHOWN) -R ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(varprefix)/lib/rpm
+- -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/rpm/[A-Z]*
+- -@$(__CHMOD) 0775 $(DESTDIR)$(varprefix)/lib/rpm
+- -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/rpm/__db.*
++ @$(__CHOWN) -R ${RPMUSER}.${RPMGROUP} $(DESTDIR)$(varprefix)/lib/openpkg
++ -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/openpkg/[A-Z]*
++ -@$(__CHMOD) 0775 $(DESTDIR)$(varprefix)/lib/openpkg
++ -@$(__CHMOD) 0664 $(DESTDIR)$(varprefix)/lib/openpkg/__db.*
+
+ .PHONY: unsetgid
+ unsetgid:
+@@ -1217,7 +1210,7 @@
+ @sudo ./rpm -ta rpm-$(VERSION).tar.gz
+
+ .PHONY: doxygen
+-doxygen @WITH_APIDOCS_TARGET@: Doxyfile rpmpopt-@VERSION@
++doxygen @WITH_APIDOCS_TARGET@: Doxyfile rpmpopt
+ rm -rf $@
+ mkdir -p $@
+ - [ X"@__DOXYGEN@" != Xno ] && @__DOXYGEN@
+
++---------------------------------------------------------------------------
+| Add support for splitted source directories, i.e., source files
+| alternatively can be placed into the .spec directory and are picked
+| up there, too.
++---------------------------------------------------------------------------
+Index: build/build.c
+--- build/build.c 4 Mar 2003 15:27:33 -0000 1.1.1.20
++++ build/build.c 6 Feb 2004 15:37:57 -0000 1.4
+@@ -33,7 +33,15 @@
+
+ for (p = spec->sources; p != NULL; p = p->next) {
+ if (! (p->flags & RPMBUILD_ISNO)) {
++#ifndef OPENPKG
+ const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
++#else
++ const char *fn = rpmGetPath("%{_specdir}/", p->source, NULL);
++ if (access(fn, F_OK) == -1) {
++ fn = _free(fn);
++ fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
++ }
++#endif
+ rc = Unlink(fn);
+ fn = _free(fn);
+ }
+@@ -42,7 +50,15 @@
+ for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
+ for (p = pkg->icon; p != NULL; p = p->next) {
+ if (! (p->flags & RPMBUILD_ISNO)) {
++#ifndef OPENPKG
+ const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
++#else
++ const char *fn = rpmGetPath("%{_specdir}/", p->source, NULL);
++ if (access(fn, F_OK) == -1) {
++ fn = _free(fn);
++ fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
++ }
++#endif
+ rc = Unlink(fn);
+ fn = _free(fn);
+ }
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/build.c
+--- build/build.c 4 Mar 2003 15:27:33 -0000 1.1.1.20
++++ build/build.c 6 Feb 2004 15:37:57 -0000 1.4
+@@ -113,6 +129,14 @@
+ mTemplate = "%{__spec_clean_template}";
+ mPost = "%{__spec_clean_post}";
+ break;
++#ifdef OPENPKG
++ case RPMBUILD_TRACK:
++ name = "%track";
++ sb = spec->track;
++ mTemplate = "%{__spec_track_template}";
++ mPost = "%{__spec_track_post}";
++ break;
++#endif
+ case RPMBUILD_STRINGBUF:
+ default:
+ mTemplate = "%{___build_template}";
+@@ -169,7 +193,11 @@
+
+ (void) fputs(buildTemplate, fp);
+
++#ifdef OPENPKG
++ if (what != RPMBUILD_PREP && what != RPMBUILD_RMBUILD && spec->buildSubdir && what != RPMBUILD_TRACK)
++#else
+ if (what != RPMBUILD_PREP && what != RPMBUILD_RMBUILD && spec->buildSubdir)
++#endif
+ fprintf(fp, "cd %s\n", spec->buildSubdir);
+
+ if (what == RPMBUILD_RMBUILD) {
+@@ -215,6 +243,9 @@
+ buildCmd = rpmExpand("%{___build_cmd}", " ", buildScript, NULL);
+ (void) poptParseArgvString(buildCmd, &argc, &argv);
+
++#ifdef OPENPKG
++ if (what != RPMBUILD_TRACK)
++#endif
+ rpmMessage(RPMMESS_NORMAL, _("Executing(%s): %s\n"), name, buildCmd);
+ if (!(child = fork())) {
+
+@@ -290,6 +323,12 @@
+ /*@=boundsread@*/
+ }
+ } else {
++#ifdef OPENPKG
++ if ((what & RPMBUILD_TRACK) &&
++ (rc = doScript(spec, RPMBUILD_TRACK, NULL, NULL, test)))
++ goto exit;
++#endif
++
+ if ((what & RPMBUILD_PREP) &&
+ (rc = doScript(spec, RPMBUILD_PREP, NULL, NULL, test)))
+ goto exit;
+
++---------------------------------------------------------------------------
+| Unconditionally remove temporary files ("rpm-tmp.XXXXX") which
+| were generated for the executed scripts. In OpenPKG we run the
+| scripts in debug mode ("set -x") anyway, so we never need to
+| see the whole generated script -- not even if it breaks. Instead
+| we would just have temporary files staying around forever.
++---------------------------------------------------------------------------
+Index: build/build.c
+--- build/build.c 4 Mar 2003 15:27:33 -0000 1.1.1.20
++++ build/build.c 6 Feb 2004 15:37:57 -0000 1.4
+@@ -242,7 +273,9 @@
+
+ exit:
+ if (scriptName) {
++#ifndef OPENPKG
+ if (!rc)
++#endif
+ (void) Unlink(scriptName);
+ scriptName = _free(scriptName);
+ }
+
++---------------------------------------------------------------------------
+| In OpenPKG we use per-package %{_sourcedir} and %{_specdir}
+| definitions (macros have trailing ".../%{name}"). On removal
+| of source(s) and .spec file, this per-package directory would
+| be kept (usually /RPM/SRC//), because RPM does
+| not know about this OpenPKG convention. So, let RPM try(!) to
+| remove the two directories (if they are empty) and just ignore
+| removal failures (if they are still not empty).
++---------------------------------------------------------------------------
+Index: build/build.c
+--- build/build.c 4 Mar 2003 15:27:33 -0000 1.1.1.20
++++ build/build.c 6 Feb 2004 15:37:57 -0000 1.4
+@@ -338,6 +377,21 @@
+ if (what & RPMBUILD_RMSPEC)
+ (void) Unlink(spec->specFile);
+
++#ifdef OPENPKG
++ if (what & RPMBUILD_RMSOURCE) {
++ const char *pn;
++ pn = rpmGetPath("%{_sourcedir}", NULL);
++ Rmdir(pn); /* ignore error, it is ok if it fails (usually with ENOTEMPTY) */
++ pn = _free(pn);
++ }
++ if (what & RPMBUILD_RMSPEC) {
++ const char *pn;
++ pn = rpmGetPath("%{_specdir}", NULL);
++ Rmdir(pn); /* ignore error, it is ok if it fails (usually with ENOTEMPTY) */
++ pn = _free(pn);
++ }
++#endif
++
+ exit:
+ if (rc && rpmlogGetNrecs() > 0) {
+ rpmMessage(RPMMESS_NORMAL, _("\n\nRPM build errors:\n"));
+
++---------------------------------------------------------------------------
+| Do not declare any files as %doc files by default.
++---------------------------------------------------------------------------
+Index: build/files.c
+--- build/files.c 4 Mar 2003 17:04:13 -0000 1.1.1.20
++++ build/files.c 6 Feb 2004 15:37:57 -0000 1.3
+@@ -1971,6 +1971,7 @@
+ fl.defSpecdFlags = 0;
+
+ fl.docDirCount = 0;
++#if 0
+ fl.docDirs[fl.docDirCount++] = xstrdup("/usr/doc");
+ fl.docDirs[fl.docDirCount++] = xstrdup("/usr/man");
+ fl.docDirs[fl.docDirCount++] = xstrdup("/usr/info");
+@@ -1981,6 +1982,7 @@
+ fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_docdir}", NULL);
+ fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_mandir}", NULL);
+ fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_infodir}", NULL);
++#endif
+
+ fl.fileList = NULL;
+ fl.fileListRecsAlloced = 0;
+
++---------------------------------------------------------------------------
+| Make sure the "Provides" headers are available for querying from the
+| .src.rpm files.
++---------------------------------------------------------------------------
+Index: build/files.c
+--- build/files.c 4 Mar 2003 17:04:13 -0000 1.1.1.20
++++ build/files.c 6 Feb 2004 15:37:57 -0000 1.3
+@@ -2183,6 +2185,12 @@
+ case RPMTAG_CHANGELOGTEXT:
+ case RPMTAG_URL:
+ case HEADER_I18NTABLE:
++#ifdef OPENPKG
++ case RPMTAG_PROVIDENAME:
++ case RPMTAG_PROVIDEVERSION:
++ case RPMTAG_PROVIDEFLAGS:
++ case RPMTAG_CLASS:
++#endif
+ if (ptr)
+ (void)headerAddEntry(spec->sourceHeader, tag, type, ptr, count);
+ /*@switchbreak@*/ break;
+
++---------------------------------------------------------------------------
+| Add support for splitted source directories, i.e., source files
+| alternatively can be placed into the .spec directory and are picked
+| up there, too.
++---------------------------------------------------------------------------
+Index: build/files.c
+--- build/files.c 4 Mar 2003 17:04:13 -0000 1.1.1.20
++++ build/files.c 6 Feb 2004 15:37:57 -0000 1.3
+@@ -2253,8 +2261,20 @@
+ }
+
+ { const char * sfn;
++#ifndef OPENPKG
+ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
+ "%{_sourcedir}/", srcPtr->source, NULL);
++#else
++ const char *sfn2;
++ sfn2 = rpmGetPath("%{_specdir}/", srcPtr->source, NULL);
++ if (access(sfn2, F_OK) == 0)
++ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
++ "%{_specdir}/", srcPtr->source, NULL);
++ else
++ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
++ "%{_sourcedir}/", srcPtr->source, NULL);
++ sfn2 = _free(sfn2);
++#endif
+ appendLineStringBuf(sourceFiles, sfn);
+ sfn = _free(sfn);
+ }
+@@ -2263,8 +2283,20 @@
+ for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
+ for (srcPtr = pkg->icon; srcPtr != NULL; srcPtr = srcPtr->next) {
+ const char * sfn;
++#ifndef OPENPKG
+ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
+ "%{_sourcedir}/", srcPtr->source, NULL);
++#else
++ const char *sfn2;
++ sfn2 = rpmGetPath("%{_specdir}/", srcPtr->source, NULL);
++ if (access(sfn2, F_OK) == 0)
++ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
++ "%{_specdir}/", srcPtr->source, NULL);
++ else
++ sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
++ "%{_sourcedir}/", srcPtr->source, NULL);
++ sfn2 = _free(sfn2);
++#endif
+ appendLineStringBuf(sourceFiles, sfn);
+ sfn = _free(sfn);
+ }
+
++---------------------------------------------------------------------------
+| Add support for splitted source directories, i.e., source files
+| alternatively can be placed into the .spec directory and are picked
+| up there, too.
++---------------------------------------------------------------------------
+Index: build/parsePreamble.c
+--- build/parsePreamble.c 3 Mar 2003 20:46:34 -0000 1.1.1.13
++++ build/parsePreamble.c 6 Feb 2004 15:37:58 -0000 1.3
+@@ -366,7 +368,15 @@
+ size_t nb, iconsize;
+
+ /* XXX use rpmGenPath(rootdir, "%{_sourcedir}/", file) for icon path. */
++#ifndef OPENPKG
+ fn = rpmGetPath("%{_sourcedir}/", file, NULL);
++#else
++ fn = rpmGetPath("%{_specdir}/", file, NULL);
++ if (access(fn, F_OK) == -1) {
++ fn = _free(fn);
++ fn = rpmGetPath("%{_sourcedir}/", file, NULL);
++ }
++#endif
+
+ fd = Fopen(fn, "r.ufdio");
+ if (fd == NULL || Ferror(fd)) {
+
++---------------------------------------------------------------------------
+| In OpenPKG, the RPM package contains own local versions of the
+| "patch" and "tar" tools, so we cannot accept hard-coded names here.
+| Instead we expand a variable to allow us to direct RPM to our tools.
+| Additionally, pass option "-b" to patch(1) so it creates original
+| files not only if a non-standard (not ".orig") suffix is used.
+| Finally, add support for the GNU patch "-d" option for convenient
+| changing into a subdirectory.
+| Remove "unzip" support, because in OpenPKG there are less than
+| a dozend packages requiring unpacking of .zip files. For these
+| it is fully sufficient to explicitly require the "infozip"
+| package (containing "unzip") and leaving the less portable
+| "unzip" out of the bootstrap package.
++---------------------------------------------------------------------------
+Index: build/parsePrep.c
+--- build/parsePrep.c 7 Aug 2002 14:20:45 -0000 1.1.1.10
++++ build/parsePrep.c 6 Jun 2005 15:53:04 -0000 1.4
+@@ -66,7 +66,7 @@
+ */
+ /*@-boundswrite@*/
+ /*@observer@*/ static char *doPatch(Spec spec, int c, int strip, const char *db,
+- int reverse, int removeEmpties)
++ int reverse, int removeEmpties, const char *subdir)
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/
+ {
+@@ -76,6 +76,7 @@
+ struct Source *sp;
+ rpmCompressedMagic compressed = COMPRESSED_NOT;
+ int urltype;
++ const char *patcher;
+
+ for (sp = spec->sources; sp != NULL; sp = sp->next) {
+ if ((sp->flags & RPMBUILD_ISPATCH) && (sp->num == c)) {
+@@ -97,6 +106,10 @@
+ strcat(args, "--suffix ");
+ strcat(args, db);
+ }
++ if (subdir) {
++ strcat(args, "-d ");
++ strcat(args, subdir);
++ }
+ if (reverse) {
+ strcat(args, " -R");
+ }
+@@ -124,6 +137,10 @@
+ /*@notreached@*/ break;
+ }
+
++ patcher = rpmGetPath("%{_patchbin}", NULL);
++ if (strcmp(patcher, "%{_patchbin}") == 0)
++ patcher = "patch";
++
+ if (compressed) {
+ const char *zipper = rpmGetPath(
+ (compressed == COMPRESSED_BZIP2 ? "%{_bzip2bin}" : "%{_gzipbin}"),
+@@ -131,22 +148,23 @@
+
+ sprintf(buf,
+ "echo \"Patch #%d (%s):\"\n"
+- "%s -d < %s | patch -p%d %s -s\n"
++ "%s -d <%s | %s -p%d %s -s -b\n"
+ "STATUS=$?\n"
+ "if [ $STATUS -ne 0 ]; then\n"
+ " exit $STATUS\n"
+ "fi",
+- c, /*@-unrecog@*/ (const char *) basename(fn), /*@=unrecog@*/
++ c, /*@-unrecog@*/ basename(fn), /*@=unrecog@*/
+ zipper,
+- fn, strip, args);
++ fn, patcher, strip, args);
+ zipper = _free(zipper);
+ } else {
+ sprintf(buf,
+ "echo \"Patch #%d (%s):\"\n"
+- "patch -p%d %s -s < %s", c, (const char *) basename(fn),
+- strip, args, fn);
++ "%s -p%d %s -s -b <%s", c, basename(fn),
++ patcher, strip, args, fn);
+ }
+
++ patcher = _free(patcher);
+ urlfn = _free(urlfn);
+ return buf;
+ }
+@@ -171,6 +189,7 @@
+ struct Source *sp;
+ rpmCompressedMagic compressed = COMPRESSED_NOT;
+ int urltype;
++ const char *tar;
+
+ for (sp = spec->sources; sp != NULL; sp = sp->next) {
+ if ((sp->flags & RPMBUILD_ISSOURCE) && (sp->num == c)) {
+@@ -228,6 +255,10 @@
+ /*@notreached@*/ break;
+ }
+
++ tar = rpmGetPath("%{_tarbin}", NULL);
++ if (strcmp(tar, "%{_tarbin}") == 0)
++ tar = "tar";
++
+ if (compressed != COMPRESSED_NOT) {
+ const char *zipper;
+ int needtar = 1;
+@@ -240,6 +271,7 @@
+ case COMPRESSED_BZIP2:
+ t = "%{_bzip2bin} -dc";
+ break;
++#if 0
+ case COMPRESSED_ZIP:
+ if (rpmIsVerbose() && !quietly)
+ t = "%{_unzipbin}";
+@@ -247,6 +279,7 @@
+ t = "%{_unzipbin} -qq";
+ needtar = 0;
+ break;
++#endif
+ }
+ zipper = rpmGetPath(t, NULL);
+ buf[0] = '\0';
+@@ -254,8 +287,13 @@
+ zipper = _free(zipper);
+ *t++ = ' ';
+ t = stpcpy(t, fn);
+- if (needtar)
+- t = stpcpy( stpcpy( stpcpy(t, " | tar "), taropts), " -");
++ if (needtar) {
++ t = stpcpy(t, " | ");
++ t = stpcpy(t, tar);
++ t = stpcpy(t, " ");
++ t = stpcpy(t, taropts);
++ t = stpcpy(t, " -");
++ }
+ t = stpcpy(t,
+ "\n"
+ "STATUS=$?\n"
+@@ -264,11 +302,14 @@
+ "fi");
+ } else {
+ buf[0] = '\0';
+- t = stpcpy( stpcpy(buf, "tar "), taropts);
+- *t++ = ' ';
++ t = stpcpy(buf, tar);
++ t = stpcpy(t, " ");
++ t = stpcpy(t, taropts);
++ t = stpcpy(t, " ");
+ t = stpcpy(t, fn);
+ }
+
++ tar = _free(tar);
+ urlfn = _free(urlfn);
+ return buf;
+ }
+@@ -443,7 +484,7 @@
+ /*@modifies spec->prep, rpmGlobalMacroContext,
+ fileSystem, internalState @*/
+ {
+- char *opt_b;
++ char *opt_b, *opt_d;
+ int opt_P, opt_p, opt_R, opt_E;
+ char *s;
+ char buf[BUFSIZ], *bp;
+@@ -453,6 +494,7 @@
+ memset(patch_nums, 0, sizeof(patch_nums));
+ opt_P = opt_p = opt_R = opt_E = 0;
+ opt_b = NULL;
++ opt_d = NULL;
+ patch_index = 0;
+
+ if (! strchr(" \t\n", line[6])) {
+@@ -492,6 +534,15 @@
+ spec->lineNum, spec->line);
+ return RPMERR_BADSPEC;
+ }
++ } else if (!strcmp(s, "-d")) {
++ /* orig suffix */
++ opt_d = strtok(NULL, " \t\n");
++ if (! opt_d) {
++ rpmError(RPMERR_BADSPEC,
++ _("line %d: Need arg to %%patch -d: %s\n"),
++ spec->lineNum, spec->line);
++ return RPMERR_BADSPEC;
++ }
+ } else if (!strncmp(s, "-p", sizeof("-p")-1)) {
+ /* unfortunately, we must support -pX */
+ if (! strchr(" \t\n", s[2])) {
+@@ -530,14 +581,14 @@
+ /* All args processed */
+
+ if (! opt_P) {
+- s = doPatch(spec, 0, opt_p, opt_b, opt_R, opt_E);
++ s = doPatch(spec, 0, opt_p, opt_b, opt_R, opt_E, opt_d);
+ if (s == NULL)
+ return RPMERR_BADSPEC;
+ appendLineStringBuf(spec->prep, s);
+ }
+
+ for (x = 0; x < patch_index; x++) {
+- s = doPatch(spec, patch_nums[x], opt_p, opt_b, opt_R, opt_E);
++ s = doPatch(spec, patch_nums[x], opt_p, opt_b, opt_R, opt_E, opt_d);
+ if (s == NULL)
+ return RPMERR_BADSPEC;
+ appendLineStringBuf(spec->prep, s);
+
++---------------------------------------------------------------------------
+| Add support for splitted source directories, i.e., source files
+| alternatively can be placed into the .spec directory and are picked
+| up there, too.
++---------------------------------------------------------------------------
+Index: build/parsePrep.c
+--- build/parsePrep.c 7 Aug 2002 14:20:45 -0000 1.1.1.10
++++ build/parsePrep.c 6 Jun 2005 15:53:04 -0000 1.4
+@@ -87,7 +88,15 @@
+ return NULL;
+ }
+
++#ifndef OPENPKG
+ urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
++#else
++ urlfn = rpmGetPath("%{_specdir}/", sp->source, NULL);
++ if (access(urlfn, F_OK) == -1) {
++ urlfn = _free(urlfn);
++ urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
++ }
++#endif
+
+ args[0] = '\0';
+ if (db) {
+@@ -182,7 +201,15 @@
+ return NULL;
+ }
+
++#ifndef OPENPKG
+ urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
++#else
++ urlfn = rpmGetPath("%{_specdir}/", sp->source, NULL);
++ if (access(urlfn, F_OK) == -1) {
++ urlfn = _free(urlfn);
++ urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
++ }
++#endif
+
+ /*@-internalglobs@*/ /* FIX: shrug */
+ taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf");
+
++---------------------------------------------------------------------------
+| Not everything on a system is RPM based (for instance OpenPKG is
+| just an add-on to the system), so do not assume we can just require
+| a package to provide "/bin/sh".
++---------------------------------------------------------------------------
+Index: build/parseScript.c
+--- build/parseScript.c 23 Jun 2002 19:47:12 -0000 1.1.1.12
++++ build/parseScript.c 30 Jan 2004 17:06:29 -0000 1.3
+@@ -261,6 +269,7 @@
+ stripTrailingBlanksStringBuf(sb);
+ p = getStringBuf(sb);
+
++ if (progArgv[0] != NULL && strcmp(progArgv[0], "/bin/sh") != 0)
+ (void) addReqProv(spec, pkg->header, (tagflags | RPMSENSE_INTERP), progArgv[0], NULL, 0);
+
+ /* Trigger script insertion is always delayed in order to */
+
++---------------------------------------------------------------------------
+| Add support for splitted source directories, i.e., source files
+| alternatively can be placed into the spec directory and are picked
+| up there, too.
++---------------------------------------------------------------------------
+Index: build/spec.c
+--- build/spec.c 4 Mar 2003 15:25:51 -0000 1.1.1.21
++++ build/spec.c 30 Jan 2004 17:06:31 -0000 1.3
+@@ -334,7 +337,15 @@
+
+ if (tag != RPMTAG_ICON) {
+ /*@-nullpass@*/ /* LCL: varargs needs null annotate. */
++#ifndef OPENPKG
+ const char *body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
++#else
++ const char *body = rpmGetPath("%{_specdir}/", p->source, NULL);
++ if (access(body, F_OK) == -1) {
++ body = _free(body);
++ body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
++ }
++#endif
+ /*@=nullpass@*/
+
+ sprintf(buf, "%s%d",
+
++---------------------------------------------------------------------------
+| Do not build with warnings on, because we do no RPM development
+| (so warnings are useless here), they cause some confusion inside
+| Berkeley-DB and also slow down building. Instead, increase the
+| optimization level. Additionally, disable static linking of RPM
+| tools. Finally, use "shtool mkdir" as the "mkdir -p" fallback.
++---------------------------------------------------------------------------
+Index: configure.ac
+--- configure.ac 2 Jul 2003 19:20:52 -0000 1.1.1.4
++++ configure.ac 13 Sep 2006 13:39:07 -0000
+@@ -53,7 +53,7 @@
+ AS=${AS-as}
+ AC_SUBST(AS)
+ if test "$ac_cv_prog_gcc" = yes; then
+- CFLAGS="$CFLAGS -D_GNU_SOURCE -D_REENTRANT -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts"
++ CFLAGS="$CFLAGS -O2 -D_GNU_SOURCE -D_REENTRANT"
+ fi
+ export CFLAGS
+
+@@ -142,6 +142,7 @@
+ # just link it dynamically
+ LDFLAGS_STATIC=""
+ fi
++LDFLAGS_STATIC="" # OpenPKG wants dynamically linked RPM tools
+ LDFLAGS_STATIC="${LDFLAGS} ${LDFLAGS_STATIC}" # libtool format
+ AC_MSG_RESULT($LDFLAGS_STATIC)
+ AC_SUBST(LDFLAGS_STATIC)
+@@ -201,7 +202,7 @@
+
+ if test X"$MKDIR_P" = X0 ; then
+ AC_MSG_RESULT(no)
+- MKDIR_P="`echo ${prefix}/lib/rpm/mkinstalldirs`"
++ MKDIR_P="@l_prefix@/lib/openpkg/shtool mkdir -f -p -m 755"
+ else
+ AC_MSG_RESULT(yes)
+ fi
+
++---------------------------------------------------------------------------
+| Disable the use of the internal zlib library, because
+| we build against an external one.
++---------------------------------------------------------------------------
+Index: configure.ac
+--- configure.ac 2 Jul 2003 19:20:52 -0000 1.1.1.4
++++ configure.ac 13 Sep 2006 13:39:09 -0000
+@@ -310,7 +311,7 @@
+ WITH_ZLIB_SUBDIR=
+ WITH_ZLIB_INCLUDE=
+ WITH_ZLIB_LIB=
+-if test -d zlib ; then
++if false; then
+ WITH_ZLIB_SUBDIR=zlib
+ addlib \${top_builddir}/zlib
+ WITH_ZLIB_INCLUDE="-I\${top_srcdir}/${WITH_ZLIB_SUBDIR}"
+
++---------------------------------------------------------------------------
+| Disable unnecessary INCPATH checks, because in OpenPKG the
+| externally used libraries are all explicitly given. And they just
+| would make RPM pick up things which we do not want to be picked up.
++---------------------------------------------------------------------------
+Index: configure.ac
+--- configure.ac 2 Jul 2003 19:20:52 -0000 1.1.1.4
++++ configure.ac 13 Sep 2006 13:39:11 -0000
+@@ -324,38 +325,38 @@
+
+ localdone=
+
+-dirs=$prefix
+-if test "$cross_compiling" != "yes"; then
+- dirs="$dirs /usr/local"
+-fi
+-for dir in $dirs
+-do
+- case $dir in
+- NONE|/usr) continue;;
+- /usr/local)
+- if test X$localdone != X ; then continue; fi
+- localdone="$dir"
+- ;;
+- esac
+-
+- AC_MSG_CHECKING(for $dir/lib in LIBS)
+- if test -d $dir/lib 2> /dev/null ; then
+- addlib $dir/lib
+- AC_MSG_RESULT(yes)
+- else
+- AC_MSG_RESULT(no)
+- fi
+-
+- AC_MSG_CHECKING(for $dir/include in INCPATH)
+- if test -d $dir/include 2>/dev/null ; then
+- if [ "$dir" != "/usr/local" ] ; then
+- INCPATH="$INCPATH -I$dir/include"
+- fi
+- AC_MSG_RESULT(yes)
+- else
+- AC_MSG_RESULT(no)
+- fi
+-done
++dnl dirs=$prefix
++dnl if test "$cross_compiling" != "yes"; then
++dnl dirs="$dirs /usr/local"
++dnl fi
++dnl for dir in $dirs
++dnl do
++dnl case $dir in
++dnl NONE|/usr) continue;;
++dnl /usr/local)
++dnl if test X$localdone != X ; then continue; fi
++dnl localdone="$dir"
++dnl ;;
++dnl esac
++dnl
++dnl AC_MSG_CHECKING(for $dir/lib in LIBS)
++dnl if test -d $dir/lib 2> /dev/null ; then
++dnl addlib $dir/lib
++dnl AC_MSG_RESULT(yes)
++dnl else
++dnl AC_MSG_RESULT(no)
++dnl fi
++dnl
++dnl AC_MSG_CHECKING(for $dir/include in INCPATH)
++dnl if test -d $dir/include 2>/dev/null ; then
++dnl if test "$dir" != "/usr/local"; then
++dnl INCPATH="$INCPATH -I$dir/include"
++dnl fi
++dnl AC_MSG_RESULT(yes)
++dnl else
++dnl AC_MSG_RESULT(no)
++dnl fi
++dnl done
+
+ AC_MSG_CHECKING(for /usr/ucblib in LIBS)
+ if test -d /usr/ucblib ; then
+
++---------------------------------------------------------------------------
+| Adjust paths for OpenPKG filesystem layout.
++---------------------------------------------------------------------------
+Index: configure.ac
+--- configure.ac 2 Jul 2003 19:20:52 -0000 1.1.1.4
++++ configure.ac 13 Sep 2006 13:39:12 -0000
+@@ -1200,12 +1202,12 @@
+ AC_SUBST(LOCALEDIR)
+ LIBDIR="`echo $libdir | sed 's-/lib$-/%{_lib}-'`"
+ AC_SUBST(LIBDIR)
+-RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
++RPMCONFIGDIR="@l_prefix@/lib/openpkg"
+ AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR",
+ [Full path to rpm global configuration directory (usually /usr/lib/rpm)])
+ AC_SUBST(RPMCONFIGDIR)
+
+-SYSCONFIGDIR="`echo /etc/rpm`"
++SYSCONFIGDIR="@l_prefix@/etc/openpkg"
+ AC_DEFINE_UNQUOTED(SYSCONFIGDIR, "$SYSCONFIGDIR",
+ [Full path to rpm system configuration directory (usually /etc/rpm)])
+ AC_SUBST(SYSCONFIGDIR)
+@@ -1215,17 +1217,17 @@
+ [Colon separated paths of macro files to read.])
+ AC_SUBST(MACROFILES)
+
+-LIBRPMRC_FILENAME="${RPMCONFIGDIR}/rpmrc"
++LIBRPMRC_FILENAME="${SYSCONFIGDIR}/rpmrc"
+ AC_DEFINE_UNQUOTED(LIBRPMRC_FILENAME, "$LIBRPMRC_FILENAME",
+ [Full path to rpmrc configuration file (usually /usr/lib/rpm/rpmrc)])
+ AC_SUBST(LIBRPMRC_FILENAME)
+
+-VENDORRPMRC_FILENAME="${RPMCONFIGDIR}/${RPMCANONVENDOR}/rpmrc"
++VENDORRPMRC_FILENAME="${SYSCONFIGDIR}/${RPMCANONVENDOR}/rpmrc"
+ AC_DEFINE_UNQUOTED(VENDORRPMRC_FILENAME, "$VENDORRPMRC_FILENAME",
+ [Full path to vendor rpmrc configuration file (usually /usr/lib/rpm/vendor/rpmrc)])
+ AC_SUBST(VENDORRPMRC_FILENAME)
+
+-LIBRPMALIAS_FILENAME="${RPMCONFIGDIR}/rpmpopt-${VERSION}"
++LIBRPMALIAS_FILENAME="${RPMCONFIGDIR}/rpmpopt"
+ AC_DEFINE_UNQUOTED(LIBRPMALIAS_FILENAME, "$LIBRPMALIAS_FILENAME",
+ [Full path to rpmpopt configuration file (usually /usr/lib/rpm/rpmpopt)])
+ AC_SUBST(LIBRPMALIAS_FILENAME)
+
++---------------------------------------------------------------------------
+| If running as "susr", do not unpack source RPM packages with "susr"
+| file ownerships as the OpenPKG Set-UID wrapper switches from "musr"
+| to "susr" on "openpkg rpm -Uvh *.src.rpm". As a result the installed
+| files could be never removed again by "musr". It is more consistent
+| to always unpack as "musr" if possible.
++---------------------------------------------------------------------------
+Index: lib/psm.c
+--- lib/psm.c 5 Jun 2003 12:43:18 -0000 1.1.1.6
++++ lib/psm.c 13 Sep 2006 13:39:15 -0000
+@@ -314,6 +314,20 @@
+
+ fi->uid = getuid();
+ fi->gid = getgid();
++#ifdef OPENPKG
++ if (fi->uid == 0) {
++ char *muid_str;
++ char *mgid_str;
++ uid_t *muid;
++ gid_t *mgid;
++ if ((muid_str = rpmExpand("%{l_muid}", NULL)) != NULL)
++ if ((muid = (uid_t)strtol(muid_str, (char **)NULL, 10)) > 0)
++ fi->uid = muid;
++ if ((mgid_str = rpmExpand("%{l_mgid}", NULL)) != NULL)
++ if ((mgid = (gid_t)strtol(mgid_str, (char **)NULL, 10)) > 0)
++ fi->gid = mgid;
++ }
++#endif
+ fi->astriplen = 0;
+ fi->striplen = 0;
+
+@@ -352,6 +366,9 @@
+ rpmrc = RPMRC_FAIL;
+ goto exit;
+ }
++#ifdef OPENPKG
++ chown(_sourcedir, fi->uid, fi->gid);
++#endif
+
+ _specdir = rpmGenPath(rpmtsRootDir(ts), "%{_specdir}", "");
+ rpmrc = rpmMkdirPath(_specdir, "specdir");
+@@ -359,6 +376,9 @@
+ rpmrc = RPMRC_FAIL;
+ goto exit;
+ }
++#ifdef OPENPKG
++ chown(_specdir, fi->uid, fi->gid);
++#endif
+
+ /* Build dnl/dil with {_sourcedir, _specdir} as values. */
+ if (i < fi->fc) {
+
++---------------------------------------------------------------------------
+| RPM has two platform id canonicalizations: hard-coded ones in
+| the "rpm" program and defined ones in the rpmrc files. The
+| hard-coded ones make the defined ones inconsistent. Additionally,
+| in OpenPKG we know exactly what we do. So, disable the hard-coded
+| canonicalizations and use only the defined ones. The only thing we
+| do inside RPM is to reduce the platform version to major and minor
+| version numbers in order to simplify the "rpmrc" files. Then, RPM
+| allows to read the platform from an external program. Adjust the
+| hard-coded path to this program and allow it to be overridden with
+| the macro %{__platform}. Finally, change the default definition of
+| %{_host} to not contain the vendor stuff to more conform to what
+| %{_target} usually is defined to and what we are using throughout
+| OpenPKG, too.
++---------------------------------------------------------------------------
+Index: lib/rpmrc.c
+--- lib/rpmrc.c 4 Jun 2003 18:18:45 -0000 1.1.1.25
++++ lib/rpmrc.c 6 Jun 2005 15:53:06 -0000 1.3
+@@ -27,7 +27,7 @@
+ const char * macrofiles = MACROFILES;
+
+ /*@observer@*/ /*@unchecked@*/
+-static const char * platform = "/etc/rpm/platform";
++static const char * platform = "@l_prefix@/etc/openpkg/platform";
+ /*@only@*/ /*@relnull@*/ /*@unchecked@*/
+ static const char ** platpat = NULL;
+ /*@unchecked@*/
+@@ -861,7 +861,11 @@
+
+ platpat = xrealloc(platpat, (nplatpat + 2) * sizeof(*platpat));
+ /*@-onlyunqglobaltrans@*/
++#ifdef OPENPKG
++ platpat[nplatpat] = rpmExpand("%{_host_cpu}-%{_host_os}", NULL);
++#else
+ platpat[nplatpat] = rpmExpand("%{_host_cpu}-%{_host_vendor}-%{_host_os}", (gnu && *gnu ? "-" : NULL), gnu, NULL);
++#endif
+ nplatpat++;
+ platpat[nplatpat] = NULL;
+ /*@=onlyunqglobaltrans@*/
+@@ -1055,14 +1059,35 @@
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies *arch, *os, rpmGlobalMacroContext, fileSystem, internalState @*/
+ {
++#ifdef OPENPKG
++ static struct utsname un_real;
++ /* utsname fields on some platforms (like HP-UX) are very small
++ (about 8 characters). This is too small for OpenPKG, so cheat! */
++ static struct {
++ char sysname[32];
++ char nodename[32];
++ char release[32];
++ char version[32];
++ char machine[32];
++ } un;
++#else
+ static struct utsname un;
++#endif
+ static int gotDefaults = 0;
+ char * chptr;
+ canonEntry canon;
+ int rc;
+
+ while (!gotDefaults) {
++#ifdef OPENPKG
++ const char *cp;
++ cp = rpmExpand("%{?__platform}", NULL);
++ if (cp == NULL || cp[0] == '\0')
++ cp = platform;
++ if (!rpmPlatform(cp)) {
++#else
+ if (!rpmPlatform(platform)) {
++#endif
+ const char * s;
+ s = rpmExpand("%{_host_cpu}", NULL);
+ if (s) {
+@@ -1079,9 +1104,44 @@
+ gotDefaults = 1;
+ break;
+ }
++#ifdef OPENPKG
++ rc = uname(&un_real);
++ strncpy(un.sysname, un_real.sysname, sizeof(un.sysname)); un.sysname [sizeof(un.sysname)-1] = '\0';
++ strncpy(un.nodename, un_real.nodename, sizeof(un.nodename)); un.nodename[sizeof(un.nodename)-1] = '\0';
++ strncpy(un.release, un_real.release, sizeof(un.release)); un.release [sizeof(un.release)-1] = '\0';
++ strncpy(un.version, un_real.version, sizeof(un.version)); un.version [sizeof(un.version)-1] = '\0';
++ strncpy(un.machine, un_real.machine, sizeof(un.machine)); un.machine [sizeof(un.machine)-1] = '\0';
++#else
+ rc = uname(&un);
++#endif
+ if (rc < 0) return;
+
++#ifdef OPENPKG
++ {
++ char *cp;
++ char *cpR;
++ int n;
++ cpR = un.release;
++ if ((n = strcspn(cpR, "0123456789")) > 0)
++ cpR += n;
++ if ((n = strspn(cpR, "0123456789.")) > 0) {
++ /* terminate after "N.N.N...." prefix */
++ cpR[n] = '\0';
++ /* shorten to "N.N" if longer */
++ if ((cp = strchr(cpR, '.')) != NULL) {
++ if ((cp = strchr(cp+1, '.')) != NULL)
++ *cp = '\0';
++ }
++ strcat(un.sysname, cpR);
++ }
++ /* fix up machine hardware name containing white-space as it
++ * happens to be on Power Macs running MacOS X
++ */
++ if (!strncmp(un.machine, "Power Macintosh", 15)) {
++ sprintf(un.machine, "powerpc");
++ }
++ }
++#else /* OPENPKG */
+ #if !defined(__linux__)
+ #ifdef SNI
+ /* USUALLY un.sysname on sinix does start with the word "SINIX"
+@@ -1298,6 +1358,7 @@
+ }
+ }
+ # endif
++#endif /* OPENPKG */
+
+ /* the uname() result goes through the arch_canon table */
+ canon = lookupInCanonTable(un.machine,
+
++---------------------------------------------------------------------------
+| In verbose file listing output, give the owner and group fields more
+| width and at the same time reduce the nlink and size fields to more
+| typical sizes within OpenPKG.
++---------------------------------------------------------------------------
+Index: lib/query.c
+--- lib/query.c 4 Jun 2003 18:24:14 -0000 1.1.1.13
++++ lib/query.c 22 Jan 2004 21:42:24 -0000 1.2
+@@ -33,7 +33,11 @@
+ /*@modifies *te @*/
+ {
+ char sizefield[15];
++#ifdef OPENPKG
++ char ownerfield[13+1], groupfield[13+1];
++#else
+ char ownerfield[8+1], groupfield[8+1];
++#endif
+ char timefield[100];
+ time_t when = mtime; /* important if sizeof(int_32) ! sizeof(time_t) */
+ struct tm * tm;
+@@ -58,7 +62,11 @@
+ groupfield[sizeof(groupfield)-1] = '\0';
+
+ /* this is normally right */
++#ifdef OPENPKG
++ sprintf(sizefield, "%8u", size);
++#else
+ sprintf(sizefield, "%12u", size);
++#endif
+
+ /* this knows too much about dev_t */
+
+@@ -98,7 +106,11 @@
+ (void)strftime(timefield, sizeof(timefield) - 1, fmt, tm);
+ }
+
++#ifdef OPENPKG
++ sprintf(te, "%s %d %-13s %-13s %8s %s %s", perms,
++#else
+ sprintf(te, "%s %4d %-8s%-8s %10s %s %s", perms,
++#endif
+ (int)nlink, ownerfield, groupfield, sizefield, timefield, namefield);
+ perms = _free(perms);
+ }
+
++---------------------------------------------------------------------------
+| Enable the exlusion of "%doc" files by default.
+| Disable "check-files" feature, because it is useless in OpenPKG
+| (we consistently use BuildRoot and our %files lists are fully
+| autogenerated) and just makes problems on bootstrapping.
+| Provide the possibility to optionally re-enable the old
+| RPM 4.0.2 way of RPM database operation by defining the
+| macro %{_rpmdb_private}. This is important for easily fixing
+| corrupted/hanging RPM database (on upgrades, etc) or if you
+| permanently have to operate RPM on a NFS filesystem where no
+| rpc.lockd(8) support is available.
+| Additionally, do not override the "_host_xx" macros because their
+| value (derived from /etc/openpkg/platform) is already
+| correctly set internally.
+| Additionally, provide default macros for the %track and %test
+| section expansion.
+| Finally, provide default for introduced variable
+| %{_force_oldpackage}, which, if non-zero, automatically enforces
+| --oldpackage on all upgrade operations (this is useful on
+| mass-upgrades from OpenPKG-CURRENT to OpenPKG-RELEASE).
++---------------------------------------------------------------------------
+Index: macros.in
+--- macros.in 2 Jul 2003 19:20:52 -0000 1.1.1.14
++++ macros.in 30 Jan 2004 17:06:27 -0000 1.3
+@@ -1,7 +1,7 @@
+ #/*! \page config_macros Default configuration: @RPMCONFIGDIR@/macros
+ # \verbatim
+ #
+-# $Id: macros.in,v 1.138.2.1 2003/07/02 19:14:06 jbj Exp $
++# $Id: macros.in,v 1.2 2004/01/22 21:42:09 rse Exp $
+ #
+ # This is a global RPM configuration file. All changes made here will
+ # be lost when the rpm package is upgraded. Any per-system configuration
+@@ -206,7 +206,7 @@
+
+ # Boolean (i.e. 1 == "yes", 0 == "no") that controls whether files
+ # marked as %doc should be installed.
+-#%_excludedocs
++%_excludedocs 1
+
+ # The port and machine name of a FTP proxy host running TIS firewall.
+ #
+@@ -305,7 +305,7 @@
+ # Returns list of unpackaged files, i.e. files in $RPM_BUILD_ROOT not packaged.
+ #
+ # Note: Disable (by commenting out) for legacy compatibility.
+-%__check_files @RPMCONFIGDIR@/check-files %{buildroot}
++#%__check_files @RPMCONFIGDIR@/check-files %{buildroot}
+
+ #
+ # Should unpackaged files in a build root terminate a build?
+@@ -449,7 +449,7 @@
+
+ # Use a CDB database model for concurrent access.
+ # XXX Add "private" here for legacy interoperation transiting to glibc+nptl.
+-%__dbi_cdb create cdb mpool mp_mmapsize=16Mb mp_size=1Mb
++%__dbi_cdb create cdb mpool mp_mmapsize=16Mb mp_size=1Mb %{?_rpmdb_private:private}
+
+ %__dbi_other %{?_tmppath:tmpdir=%{_tmppath}} %{?__dbi_cdb}
+
+@@ -618,6 +618,10 @@
+ # If non-zero, all erasures will be automagically repackaged.
+ %_repackage_all_erasures 0
+
++# If non-zero, automatically enforce --oldpackage for all upgrade operations
++# (useful on mass-upgrades from OpenPKG-CURRENT to OpenPKG-RELEASE)
++%_force_oldpackage 0
++
+ # Verify digest/signature flags for various rpm modes:
+ # 1 --nohdrchk if set, don't check rpmdb headers
+ #
+@@ -870,6 +874,26 @@
+ #%{__spec_clean_post}\
+ #%{nil}
+
++%__spec_track_shell %{___build_shell}
++%__spec_track_args %{___build_args}
++%__spec_track_cmd %{___build_cmd}
++%__spec_track_pre %{___build_pre}
++%__spec_track_body %{___build_body}
++%__spec_track_post %{___build_post}
++%__spec_track_template #!%{__spec_track_shell}\
++%{__spec_track_pre}\
++%{nil}
++
++%__spec_test_shell %{___build_shell}
++%__spec_test_args %{___build_args}
++%__spec_test_cmd %{___build_cmd}
++%__spec_test_pre %{___build_pre}
++%__spec_test_body %{___build_body}
++%__spec_test_post %{___build_post}
++%__spec_test_template #!%{__spec_test_shell}\
++%{__spec_test_pre}\
++%{nil}
++
+ %__spec_rmbuild_shell %{___build_shell}
+ %__spec_rmbuild_args %{___build_args}
+ %__spec_rmbuild_cmd %{___build_cmd}
+@@ -929,11 +953,11 @@
+ %_build_cpu %{_host_cpu}
+ %_build_vendor %{_host_vendor}
+ %_build_os %{_host_os}
+-%_host @host@
+-%_host_alias @host_alias@%{nil}
+-%_host_cpu @host_cpu@
+-%_host_vendor @host_vendor@
+-%_host_os @host_os@
++#%_host @host@
++#%_host_alias @host_alias@%{nil}
++#%_host_cpu @host_cpu@
++#%_host_vendor @host_vendor@
++#%_host_os @host_os@
+ %_target %{_host}
+ %_target_alias %{_host_alias}
+ %_target_cpu %{_host_cpu}
+
++---------------------------------------------------------------------------
+| Adjust path for OpenPKG filesystem layout.
++---------------------------------------------------------------------------
+Index: scripts/Makefile.am
+--- scripts/Makefile.am 20 Jun 2003 19:04:49 -0000 1.1.1.11
++++ scripts/Makefile.am 22 Jan 2004 21:42:34 -0000 1.2
+@@ -22,7 +22,7 @@
+
+ all:
+
+-configdir = ${prefix}/lib/rpm
++configdir = ${prefix}/lib/openpkg
+ config_SCRIPTS = \
+ brp-compress brp-python-bytecompile brp-redhat \
+ brp-strip brp-strip-comment-note \
+
++---------------------------------------------------------------------------
+| Adjust path for OpenPKG filesystem layout.
++---------------------------------------------------------------------------
+Index: scripts/Makefile.in
+--- scripts/Makefile.in 16 Jul 2003 17:05:49 -0000 1.1.1.14
++++ scripts/Makefile.in 22 Jan 2004 21:42:34 -0000 1.2
+@@ -273,7 +273,7 @@
+
+ installprefix = $(DESTDIR)
+
+-configdir = ${prefix}/lib/rpm
++configdir = ${prefix}/lib/openpkg
+ config_SCRIPTS = \
+ brp-compress brp-python-bytecompile brp-redhat \
+ brp-strip brp-strip-comment-note \
+
++---------------------------------------------------------------------------
+| Use GNU libtool's weaker -static (link with own static libraries)
+| instead of the strong -all-static (link even with static libc, etc),
+| because OpenPKG does not need to be fully static.
+| Additionally, adjust the path to file(1)'s "magic" file.
++---------------------------------------------------------------------------
+Index: file/Makefile.am
+--- file/Makefile.am 24 Jan 2003 19:41:56 -0000 1.1.1.1
++++ file/Makefile.am 22 Jan 2004 21:42:21 -0000 1.2
+@@ -36,7 +36,7 @@
+ #MAGIC = @datadir@/magic
+ #data_DATA = magic magic.mime magic.mgc magic.mime.mgc
+
+-pkglibdir = @prefix@/lib/rpm
++pkglibdir = @prefix@/lib/openpkg
+ pkglib_DATA = magic magic.mime magic.mgc magic.mime.mgc
+ MAGIC = $(pkglibdir)/magic
+ CPPFLAGS = -DMAGIC='"$(MAGIC)"'
+
++---------------------------------------------------------------------------
+| Use GNU libtool's weaker -static (link with own static libraries)
+| instead of the strong -all-static (link even with static libc, etc),
+| because OpenPKG does not need to be fully static.
+| Additionally, adjust the path to file(1)'s "magic" file.
++---------------------------------------------------------------------------
+Index: file/Makefile.in
+--- file/Makefile.in 16 Jul 2003 17:05:23 -0000 1.1.1.2
++++ file/Makefile.in 22 Jan 2004 21:42:22 -0000 1.2
+@@ -39,7 +39,7 @@
+
+ #MAGIC = @datadir@/magic
+ #data_DATA = magic magic.mime magic.mgc magic.mime.mgc
+-pkglibdir = @prefix@/lib/rpm
++pkglibdir = @prefix@/lib/openpkg
+ ACLOCAL = @ACLOCAL@
+ AMDEP_FALSE = @AMDEP_FALSE@
+ AMDEP_TRUE = @AMDEP_TRUE@
+@@ -159,7 +159,7 @@
+ noinst_PROGRAMS = file
+
+ file_SOURCES = file.c
+-file_LDFLAGS = -all-static
++file_LDFLAGS = -static
+ file_LDADD = libfmagic.la
+
+ man_MAGIC = magic.@fsect@
+
++---------------------------------------------------------------------------
+| Use GNU libtool's weaker -static (link with own static libraries)
+| instead of the strong -all-static (link even with static libc, etc),
+| because OpenPKG does not need to be fully static.
+| Additionally, disable the building of gettext stuff we don't need.
++---------------------------------------------------------------------------
+Index: popt/Makefile.am
+--- popt/Makefile.am 6 Mar 2003 23:16:43 -0000 1.1.1.9
++++ popt/Makefile.am 22 Jan 2004 21:42:28 -0000 1.2
+@@ -9,7 +9,7 @@
+ po/*.in po/*.po po/popt.pot \
+ popt.ps
+
+-SUBDIRS = intl po
++SUBDIRS = intl
+
+ INCLUDES = -I. -I$(top_srcdir)
+
+@@ -17,13 +17,13 @@
+
+ noinst_PROGRAMS = test1 test2 test3
+ test1_SOURCES = test1.c
+-test1_LDFLAGS = -all-static
++test1_LDFLAGS = -static
+ test1_LDADD = $(usrlib_LTLIBRARIES)
+ test2_SOURCES = test2.c
+-test2_LDFLAGS = -all-static
++test2_LDFLAGS = -static
+ test2_LDADD = $(usrlib_LTLIBRARIES)
+ test3_SOURCES = test3.c
+-test3_LDFLAGS = -all-static
++test3_LDFLAGS = -static
+ test3_LDADD = $(usrlib_LTLIBRARIES)
+
+ noinst_SCRIPTS = testit.sh
+
++---------------------------------------------------------------------------
+| Use GNU libtool's weaker -static (link with own static libraries)
+| instead of the strong -all-static (link even with static libc, etc),
+| because OpenPKG does not need to be fully static.
+| Additionally, disable the building of gettext stuff we don't need.
++---------------------------------------------------------------------------
+Index: popt/Makefile.in
+--- popt/Makefile.in 16 Jul 2003 17:04:49 -0000 1.1.1.14
++++ popt/Makefile.in 22 Jan 2004 21:42:28 -0000 1.2
+@@ -163,7 +163,7 @@
+ popt.ps
+
+
+-SUBDIRS = intl po
++SUBDIRS = intl
+
+ INCLUDES = -I. -I$(top_srcdir)
+
+@@ -171,13 +171,13 @@
+
+ noinst_PROGRAMS = test1 test2 test3
+ test1_SOURCES = test1.c
+-test1_LDFLAGS = -all-static
++test1_LDFLAGS = -static
+ test1_LDADD = $(usrlib_LTLIBRARIES)
+ test2_SOURCES = test2.c
+-test2_LDFLAGS = -all-static
++test2_LDFLAGS = -static
+ test2_LDADD = $(usrlib_LTLIBRARIES)
+ test3_SOURCES = test3.c
+-test3_LDFLAGS = -all-static
++test3_LDFLAGS = -static
+ test3_LDADD = $(usrlib_LTLIBRARIES)
+
+ noinst_SCRIPTS = testit.sh
+
++---------------------------------------------------------------------------
+| Revert back to the old behaviour of passing to "exec" programs an
+| extra "--" argument to separate options and arguments. Additionally,
+| allow the "!#:+" constructs to be used multiple times and then each
+| time eat another argument (instead of just eating an argument once
+| and expanding this multiple times).
++---------------------------------------------------------------------------
+Index: popt/popt.c
+--- popt/popt.c 22 Aug 2002 14:17:44 -0000 1.1.1.12
++++ popt/popt.c 22 Jan 2004 21:42:28 -0000 1.2
+@@ -400,9 +400,7 @@
+ }
+
+ if (con->leftovers != NULL && con->numLeftovers > 0) {
+-#if 0
+ argv[argc++] = "--";
+-#endif
+ memcpy(argv + argc, con->leftovers, sizeof(*argv) * con->numLeftovers);
+ argc += con->numLeftovers;
+ }
+@@ -580,10 +578,8 @@
+ if (!(s[0] == '#' && s[1] == ':' && s[2] == '+'))
+ /*@switchbreak@*/ break;
+ /* XXX Make sure that findNextArg deletes only next arg. */
+- if (a == NULL) {
+ if ((a = findNextArg(con, 1, 1)) == NULL)
+ /*@switchbreak@*/ break;
+- }
+ s += 3;
+
+ alen = strlen(a);
+
++---------------------------------------------------------------------------
+| Dedefine the stdio variable BUFSIZ because it is usually just 1024
+| on some platforms (on Linux it is 8192) and unfortunately RPM uses
+| it here for the macro expansion buffer. For OpenPKG the size 1024 is
+| definetely too small. So increase this to a 16KB buffer.
++---------------------------------------------------------------------------
+Index: rpmio/macro.c
+--- rpmio/macro.c 15 May 2003 13:42:01 -0000 1.1.1.7
++++ rpmio/macro.c 22 Jan 2004 21:42:32 -0000 1.2
+@@ -50,6 +50,9 @@
+
+ #include "debug.h"
+
++#undef BUFSIZ
++#define BUFSIZ 16384
++
+ #if defined(__LCLINT__)
+ /*@-exportheader@*/
+ extern const unsigned short int **__ctype_b_loc (void) /*@*/;
+
++---------------------------------------------------------------------------
+| Remove "unzip" support, because in OpenPKG there are less than
+| a dozend packages requiring unpacking of .zip files. For these
+| it is fully sufficient to explicitly require the "infozip"
+| package (containing "unzip") and leaving the less portable
+| "unzip" out of the bootstrap package.
++---------------------------------------------------------------------------
+Index: rpmio/macro.c
+--- rpmio/macro.c 15 May 2003 13:42:01 -0000 1.1.1.7
++++ rpmio/macro.c 22 Jan 2004 21:42:32 -0000 1.2
+@@ -1114,9 +1119,11 @@
+ case 2: /* COMPRESSED_BZIP2 */
+ sprintf(be, "%%_bzip2 %s", b);
+ break;
++#if 0
+ case 3: /* COMPRESSED_ZIP */
+ sprintf(be, "%%_unzip %s", b);
+ break;
++#endif
+ }
+ b = be;
+ } else if (STREQ("S", f, fn)) {
+@@ -1717,9 +1725,11 @@
+
+ if ((magic[0] == 'B') && (magic[1] == 'Z')) {
+ *compressed = COMPRESSED_BZIP2;
++#if 0
+ } else if ((magic[0] == 0120) && (magic[1] == 0113) &&
+ (magic[2] == 0003) && (magic[3] == 0004)) { /* pkzip */
+ *compressed = COMPRESSED_ZIP;
++#endif
+ } else if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */
+ ((magic[0] == 0037) && (magic[1] == 0236)) || /* old gzip */
+ ((magic[0] == 0037) && (magic[1] == 0036)) || /* pack */
+
++---------------------------------------------------------------------------
+| Make sure that an %{error:} macro really stops further
+| processing. Else it would be nothing more than a %{warn:}.
++---------------------------------------------------------------------------
+Index: rpmio/macro.c
+--- rpmio/macro.c 15 May 2003 13:42:01 -0000 1.1.1.7
++++ rpmio/macro.c 22 Jan 2004 21:42:32 -0000 1.2
+@@ -1329,7 +1337,7 @@
+ STREQ("error", f, fn)) {
+ int waserror = 0;
+ if (STREQ("error", f, fn))
+- waserror = 1;
++ waserror = 1, rc = 1;
+ if (g < ge)
+ doOutput(mb, waserror, g, gn);
+ else
+
++---------------------------------------------------------------------------
+| Reactivate build mode aliases which were removed in rpm-4.1
+| (and now should be available through "rpmbuild" only).
++---------------------------------------------------------------------------
+Index: rpmpopt.in
+--- rpmpopt.in 24 Jan 2003 14:56:30 -0000 1.1.1.7
++++ rpmpopt.in 22 Jan 2004 21:42:11 -0000 1.2
+@@ -147,28 +147,28 @@
+ # Popt glue to preserve legacy CLI behavior.
+ #
+ # XXX popt exec parsing doesn't honor POPT_ARGFLAG_ONEDASH
+-# XXX Build mode aliases, removed in rpm-4.1.
+-#rpm exec --bp rpmb -bp
+-#rpm exec --bc rpmb -bc
+-#rpm exec --bi rpmb -bi
+-#rpm exec --bl rpmb -bl
+-#rpm exec --ba rpmb -ba
+-#rpm exec --bb rpmb -bb
+-#rpm exec --bs rpmb -bs
+-#rpm exec --tp rpmb -tp
+-#rpm exec --tc rpmb -tc
+-#rpm exec --ti rpmb -ti
+-#rpm exec --tl rpmb -tl
+-#rpm exec --ta rpmb -ta
+-#rpm exec --tb rpmb -tb
+-#rpm exec --ts rpmb -ts
+-#rpm exec --rebuild rpmb --rebuild
+-#rpm exec --recompile rpmb --recompile
+-#rpm exec --clean rpmb --clean
+-#rpm exec --rmsource rpmb --rmsource
+-#rpm exec --rmspec rpmb --rmspec
+-#rpm exec --target rpmb --target
+-#rpm exec --short-circuit rpmb --short-circuit
++rpm exec --bp rpmb -bp
++rpm exec --bc rpmb -bc
++rpm exec --bi rpmb -bi
++rpm exec --bl rpmb -bl
++rpm exec --ba rpmb -ba
++rpm exec --bb rpmb -bb
++rpm exec --bs rpmb -bs
++rpm exec --bt rpmb -bt
++rpm exec --tp rpmb -tp
++rpm exec --tc rpmb -tc
++rpm exec --ti rpmb -ti
++rpm exec --tl rpmb -tl
++rpm exec --ta rpmb -ta
++rpm exec --tb rpmb -tb
++rpm exec --ts rpmb -ts
++rpm exec --rebuild rpmb --rebuild
++rpm exec --recompile rpmb --recompile
++rpm exec --clean rpmb --clean
++rpm exec --rmsource rpmb --rmsource
++rpm exec --rmspec rpmb --rmspec
++rpm exec --target rpmb --target
++rpm exec --short-circuit rpmb --short-circuit
+
+ rpm exec --initdb rpmd --initdb
+ rpm exec --rebuilddb rpmd --rebuilddb
+
++---------------------------------------------------------------------------
+| Allow "-bb --short-circuit" for continuing building a binary package
+| after the %install step (usually previously fixed and repeated with
+| "-bi --short-circuit".
++---------------------------------------------------------------------------
+Index: rpmqv.c
+--- rpmqv.c 4 Mar 2003 15:32:57 -0000 1.1.1.8
++++ rpmqv.c 6 Feb 2004 15:37:56 -0000 1.4
+@@ -682,6 +682,10 @@
+ case 'b':
+ ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
+ ba->buildAmount |= RPMBUILD_CLEAN;
++#ifdef OPENPKG
++ if ((ba->buildChar == 'b') && ba->shortCircuit)
++ /*@innerbreak@*/ break;
++#endif
+ /*@fallthrough@*/
+ case 'i':
+ ba->buildAmount |= RPMBUILD_INSTALL;
+
++---------------------------------------------------------------------------
+| Because permissions and ownership on Berkeley-DB region files
+| __db.XXX have to be already fixed in advance and those files cannot
+| be created in advance on the command line with some reasonable
+| default (as it is the case for the other files which are created
+| with [rpm]db_load), so force Berkeley-DB to accept zero-sized files
+| and create them (instead of thinking another process is currently
+| creating them).
++---------------------------------------------------------------------------
+Index: db/env/env_region.c
+--- db/env/env_region.c 18 Jan 2003 14:05:01 -0000 1.1.1.5
++++ db/env/env_region.c 22 Jan 2004 21:42:17 -0000 1.2
+@@ -184,6 +184,24 @@
+ }
+
+ /*
++ * OpenPKG hack: because permissions and ownership on Berkeley-DB
++ * region files __db.XXX have to be already fixed in advance and
++ * those files cannot be created in advance on the command line
++ * with some reasonable default (as it is the case for the other
++ * files which are created with [rpm]db_load), so force Berkeley-DB
++ * to accept zero-sized files and create them (instead of thinking
++ * another process is currently creating them).
++ */
++ if (mbytes == 0 && bytes == 0) {
++ if (F_ISSET(dbenv, DB_ENV_CREATE))
++ goto creation;
++ else {
++ ret = ENOENT;
++ goto err;
++ }
++ }
++
++ /*
+ * !!!
+ * A size_t is OK -- regions get mapped into memory, and so can't
+ * be larger than a size_t.
+
++---------------------------------------------------------------------------
+| Make sure RPM passes DB_CREATE to Berkeley-DB also if file exists,
+| but is (still) zero-sized.
++---------------------------------------------------------------------------
+Index: rpmdb/db3.c
+--- rpmdb/db3.c 3 Mar 2003 16:18:29 -0000 1.1.1.5
++++ rpmdb/db3.c 22 Jan 2004 21:42:29 -0000 1.2
+@@ -1019,9 +1019,13 @@
+ } else { /* dbhome is writable, check for persistent dbenv. */
+ /*@-mods@*/
+ const char * dbf = rpmGetPath(dbhome, "/__db.001", NULL);
++ struct stat sb;
++ long size = -1;
+ /*@=mods@*/
+
+- if (access(dbf, F_OK) == -1) {
++ if (stat(dbf, &sb) == 0)
++ size = (long)sb.st_size;
++ if (access(dbf, F_OK) == -1 || size == 0) {
+ /* ... non-existent (or unwritable) DBENV, will create ... */
+ dbi->dbi_oeflags |= DB_CREATE;
+ dbi->dbi_eflags &= ~DB_JOINENV;
+
++---------------------------------------------------------------------------
+| Add internal feature variable %{_force_oldpackage} which, if
+| non-zero, automatically enforces --oldpackage on all upgrade
+| operations (this is useful on mass-upgrades from OpenPKG-CURRENT to
+| OpenPKG-RELEASE).
++---------------------------------------------------------------------------
+Index: rpm.c
+--- rpm.c 16 May 2002 16:55:25 -0000 1.1.1.23
++++ rpm.c 22 Jan 2004 21:42:10 -0000 1.2
+@@ -1016,6 +1016,10 @@
+
+ if (oldPackage && !upgrade)
+ argerror(_("--oldpackage may only be used during upgrades"));
++#ifdef OPENPKG
++ if (upgrade && rpmExpandNumeric("%{?_force_oldpackage}"))
++ probFilter |= RPMPROB_FILTER_OLDPACKAGE;
++#endif
+
+ if (noPgp && bigMode != MODE_CHECKSIG)
+ argerror(_("--nopgp may only be used during signature checking"));
+
++---------------------------------------------------------------------------
+| Add OpenPKG branding to make sure people do not intermix
+| this RPM version with the stock RPM version.
++---------------------------------------------------------------------------
+Index: lib/poptALL.c
+--- lib/poptALL.c 25 Jun 2003 19:10:01 -0000 1.1.1.3
++++ lib/poptALL.c 22 Jan 2004 21:42:23 -0000 1.2
+@@ -102,7 +102,7 @@
+ /*@globals rpmEVR, fileSystem @*/
+ /*@modifies *fp, fileSystem @*/
+ {
+- fprintf(fp, _("RPM version %s\n"), rpmEVR);
++ fprintf(fp, _("OpenPKG RPM %s\n"), rpmEVR);
+ }
+
+ /**
+
++---------------------------------------------------------------------------
+| Add OpenPKG branding to make sure people do not intermix
+| this RPM version with the stock RPM version.
++---------------------------------------------------------------------------
+Index: rpm.c
+--- rpm.c 16 May 2002 16:55:25 -0000 1.1.1.23
++++ rpm.c 22 Jan 2004 21:42:10 -0000 1.2
+@@ -235,7 +235,7 @@
+ static void printHelpLine(char * prefix, char * help);
+
+ static void printVersion(void) {
+- fprintf(stdout, _("RPM version %s\n"), rpmEVR);
++ fprintf(stdout, _("OpenPKG RPM %s\n"), rpmEVR);
+ }
+
+ static void printBanner(void) {
+
++---------------------------------------------------------------------------
+| Add OpenPKG branding to make sure people do not intermix
+| this RPM version with the stock RPM version.
++---------------------------------------------------------------------------
+Index: rpmqv.c
+--- rpmqv.c 4 Mar 2003 15:32:57 -0000 1.1.1.8
++++ rpmqv.c 6 Feb 2004 15:37:56 -0000 1.4
+@@ -126,7 +126,7 @@
+ /*@globals rpmEVR, fileSystem @*/
+ /*@modifies *fp, fileSystem @*/
+ {
+- fprintf(fp, _("RPM version %s\n"), rpmEVR);
++ fprintf(fp, _("OpenPKG RPM %s\n"), rpmEVR);
+ }
+
+ static void printBanner(FILE * fp)
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: rpmqv.c
+--- rpmqv.c 4 Mar 2003 15:32:57 -0000 1.1.1.8
++++ rpmqv.c 6 Feb 2004 15:37:56 -0000 1.4
+@@ -703,7 +707,19 @@
+ /*@innerbreak@*/ break;
+ case 's':
+ ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
++ /* enforce no dependency checking */
++ ba->noDeps = 1;
+ /*@innerbreak@*/ break;
++#ifdef OPENPKG
++ case 't':
++ ba->buildAmount |= RPMBUILD_TRACK;
++ /* enforce no dependency checking and expansion of %setup, %patch and %prep macros */
++ ba->noDeps = 1;
++ rpmDefineMacro(NULL, "setup #", RMIL_CMDLINE);
++ rpmDefineMacro(NULL, "patch #", RMIL_CMDLINE);
++ rpmDefineMacro(NULL, "prep %%prep", RMIL_CMDLINE);
++ /*@innerbreak@*/ break;
++#endif
+ }
+
+ if (!poptPeekArg(optCon)) {
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/pack.c
+--- build/pack.c 4 Mar 2003 17:03:17 -0000 1.1.1.20
++++ build/pack.c 30 Jan 2004 17:06:29 -0000 1.2
+@@ -252,6 +252,15 @@
+ return RPMERR_BADFILENAME;
+ }
+ }
++#ifdef OPENPKG
++ if (pkg->testFile) {
++ if (addFileToTag(spec, pkg->testFile, pkg->header, RPMTAG_TEST)) {
++ rpmError(RPMERR_BADFILENAME,
++ _("Could not open Test file: %s\n"), pkg->testFile);
++ return RPMERR_BADFILENAME;
++ }
++ }
++#endif
+
+ for (p = pkg->triggerFiles; p != NULL; p = p->next) {
+ (void) headerAddOrAppendEntry(pkg->header, RPMTAG_TRIGGERSCRIPTPROG,
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/parseBuildInstallClean.c
+--- build/parseBuildInstallClean.c 3 Mar 2003 20:43:30 -0000 1.1.1.9
++++ build/parseBuildInstallClean.c 30 Jan 2004 17:06:29 -0000 1.2
+@@ -29,6 +29,11 @@
+ } else if (parsePart == PART_CLEAN) {
+ sbp = &(spec->clean);
+ name = "%clean";
++#ifdef OPENPKG
++ } else if (parsePart == PART_TRACK) {
++ sbp = &(spec->track);
++ name = "%track";
++#endif
+ }
+ /*@=branchstate@*/
+
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/parseScript.c
+--- build/parseScript.c 23 Jun 2002 19:47:12 -0000 1.1.1.12
++++ build/parseScript.c 30 Jan 2004 17:06:29 -0000 1.3
+@@ -156,6 +156,14 @@
+ progtag = RPMTAG_TRIGGERSCRIPTPROG;
+ partname = "%triggerpostun";
+ break;
++#ifdef OPENPKG
++ case PART_TEST:
++ tag = RPMTAG_TEST;
++ tagflags = RPMSENSE_SCRIPT_TEST;
++ progtag = RPMTAG_TESTPROG;
++ partname = "%test";
++ break;
++#endif
+ }
+ /*@=branchstate@*/
+
+@@ -303,6 +312,11 @@
+ case PART_VERIFYSCRIPT:
+ pkg->verifyFile = xstrdup(file);
+ break;
++#ifdef OPENPKG
++ case PART_TEST:
++ pkg->testFile = xstrdup(file);
++ break;
++#endif
+ }
+ }
+ }
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/parseSpec.c
+--- build/parseSpec.c 15 May 2003 13:38:57 -0000 1.1.1.15
++++ build/parseSpec.c 30 Jan 2004 17:06:30 -0000 1.2
+@@ -43,6 +43,10 @@
+ { PART_TRIGGERIN, 0, "%triggerin"},
+ { PART_TRIGGERIN, 0, "%trigger"},
+ { PART_VERIFYSCRIPT, 0, "%verifyscript"},
++#ifdef OPENPKG
++ { PART_TRACK, 0, "%track"},
++ { PART_TEST, 0, "%test"},
++#endif
+ {0, 0, 0}
+ };
+
+@@ -489,6 +493,15 @@
+ parsePart = parseFiles(spec);
+ /*@switchbreak@*/ break;
+
++#ifdef OPENPKG
++ case PART_TRACK:
++ parsePart = parseBuildInstallClean(spec, parsePart);
++ /*@switchbreak@*/ break;
++ case PART_TEST:
++ parsePart = parseScript(spec, parsePart);
++ /*@switchbreak@*/ break;
++#endif
++
+ case PART_NONE: /* XXX avoid gcc whining */
+ case PART_LAST:
+ case PART_BUILDARCHITECTURES:
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/poptBT.c
+--- build/poptBT.c 3 Mar 2003 20:04:12 -0000 1.1.1.3
++++ build/poptBT.c 30 Jan 2004 17:06:30 -0000 1.2
+@@ -35,6 +35,9 @@
+ #define POPT_BL 0x626c
+ #define POPT_BP 0x6270
+ #define POPT_BS 0x6273
++#ifdef OPENPKG
++#define POPT_BT 0x6274
++#endif
+ #define POPT_TA 0x7461
+ #define POPT_TB 0x7462
+ #define POPT_TC 0x7463
+@@ -82,6 +85,9 @@
+ case POPT_BL:
+ case POPT_BP:
+ case POPT_BS:
++#ifdef OPENPKG
++ case POPT_BT:
++#endif
+ case POPT_TA:
+ case POPT_TB:
+ case POPT_TC:
+@@ -177,6 +183,11 @@
+ { "bs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BS,
+ N_("build source package only from "),
+ N_("") },
++#ifdef OPENPKG
++ { "bt", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BT,
++ N_("track versions of sources from "),
++ N_("") },
++#endif
+
+ { "tp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TP,
+ N_("build through %prep (unpack sources and apply patches) from "),
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/rpmbuild.h
+--- build/rpmbuild.h 4 Mar 2003 17:03:07 -0000 1.1.1.13
++++ build/rpmbuild.h 30 Jan 2004 17:06:30 -0000 1.2
+@@ -34,6 +34,9 @@
+ RPMBUILD_RMSOURCE = (1 << 8), /*!< Remove source(s) and patch(s). */
+ RPMBUILD_RMBUILD = (1 << 9), /*!< Remove build sub-tree. */
+ RPMBUILD_STRINGBUF = (1 << 10), /*!< only for doScript() */
++#ifdef OPENPKG
++ RPMBUILD_TRACK = (1 << 12), /*!< Execute %%track. */
++#endif
+ RPMBUILD_RMSPEC = (1 << 11) /*!< Remove spec file. */
+ } rpmBuildFlags;
+ /*@=typeuse@*/
+@@ -69,7 +72,13 @@
+ PART_VERIFYSCRIPT = 16, /*!< */
+ PART_BUILDARCHITECTURES= 17,/*!< */
+ PART_TRIGGERPOSTUN = 18, /*!< */
++#ifdef OPENPKG
++ PART_TRACK = 19, /*!< */
++ PART_TEST = 20, /*!< */
++ PART_LAST = 21 /*!< */
++#else
+ PART_LAST = 19 /*!< */
++#endif
+ } rpmParseState;
+
+ #define STRIP_NOTHING 0
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/rpmspec.h
+--- build/rpmspec.h 4 Mar 2003 15:30:23 -0000 1.1.1.11
++++ build/rpmspec.h 30 Jan 2004 17:06:30 -0000 1.2
+@@ -164,6 +164,10 @@
+ StringBuf check; /*!< %check scriptlet. */
+ /*@only@*/
+ StringBuf clean; /*!< %clean scriptlet. */
++#ifdef OPENPKG
++/*@only@*/
++ StringBuf track; /*!< %track scriptlet. */
++#endif
+
+ /*@owned@*/
+ Package packages; /*!< Package list. */
+@@ -196,6 +200,10 @@
+ const char * postUnFile; /*!< %postun scriptlet. */
+ /*@only@*/
+ const char * verifyFile; /*!< %verifyscript scriptlet. */
++#ifdef OPENPKG
++/*@only@*/
++ const char * testFile; /*!< %test scriptlet. */
++#endif
+
+ /*@only@*/
+ StringBuf specialDoc;
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: build/spec.c
+--- build/spec.c 4 Mar 2003 15:25:51 -0000 1.1.1.21
++++ build/spec.c 30 Jan 2004 17:06:31 -0000 1.3
+@@ -138,6 +138,9 @@
+ p->preUnFile = NULL;
+ p->postUnFile = NULL;
+ p->verifyFile = NULL;
++#ifdef OPENPKG
++ p->testFile = NULL;
++#endif
+
+ p->specialDoc = NULL;
+
+@@ -444,6 +455,9 @@
+ spec->install = NULL;
+ spec->check = NULL;
+ spec->clean = NULL;
++#ifdef OPENPKG
++ spec->track = NULL;
++#endif
+
+ spec->sources = NULL;
+ spec->packages = NULL;
+@@ -491,6 +505,9 @@
+ spec->install = freeStringBuf(spec->install);
+ spec->check = freeStringBuf(spec->check);
+ spec->clean = freeStringBuf(spec->clean);
++#ifdef OPENPKG
++ spec->track = freeStringBuf(spec->track);
++#endif
+
+ spec->buildRootURL = _free(spec->buildRootURL);
+ spec->buildSubdir = _free(spec->buildSubdir);
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
++---------------------------------------------------------------------------
+Index: lib/rpmlib.h
+--- lib/rpmlib.h 19 Jun 2003 17:39:35 -0000 1.1.1.26
++++ lib/rpmlib.h 30 Jan 2004 17:06:31 -0000 1.2
+@@ -414,6 +414,12 @@
+ RPMTAG_FILEDEPENDSN = 1144,
+ RPMTAG_DEPENDSDICT = 1145,
+ RPMTAG_SOURCEPKGID = 1146,
++#ifdef OPENPKG
++ RPMTAG_TRACK = 1200,
++ RPMTAG_TEST = 1201,
++ RPMTAG_TESTPROG = 1202,
++ RPMTAG_CLASS = 1203,
++#endif
+ /*@-enummemuse@*/
+ RPMTAG_FIRSTFREE_TAG /*!< internal */
+ /*@=enummemuse@*/
+@@ -488,6 +494,9 @@
+ RPMSENSE_SCRIPT_BUILD = (1 << 21), /*!< %build build dependency. */
+ RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */
+ RPMSENSE_SCRIPT_CLEAN = (1 << 23), /*!< %clean build dependency. */
++#ifdef OPENPKG
++ RPMSENSE_SCRIPT_TEST = (1 << 29), /*!< %test build dependency. */
++#endif
+ RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature) dependency. */
+ /*@-enummemuse@*/
+ RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< @todo Implement %triggerprein. */
+
++---------------------------------------------------------------------------
+| Add support for the OpenPKG custom .spec file sections %track
+| (package build-time feature for performing vendor source tracking)
+| and %test (package install-time feature for performing package
+| run-time tests).
+| Additionally, add support for "Class" header.
++---------------------------------------------------------------------------
+Index: rpmdb/tagtbl.c
+--- rpmdb/tagtbl.c 2 Jul 2003 20:20:27 -0000 1.1.1.4
++++ rpmdb/tagtbl.c 30 Jan 2004 17:06:32 -0000 1.2
+@@ -135,6 +135,12 @@
+ { "RPMTAG_FILEDEPENDSN", 1144, },
+ { "RPMTAG_DEPENDSDICT", 1145, },
+ { "RPMTAG_SOURCEPKGID", 1146, },
++#ifdef OPENPKG
++ { "RPMTAG_TRACK", 1200, },
++ { "RPMTAG_TEST", 1201, },
++ { "RPMTAG_TESTPROG", 1202, },
++ { "RPMTAG_CLASS", 1203, },
++#endif
+ { NULL, 0 }
+ };
+
+
++---------------------------------------------------------------------------
+| Add support for "Class" header.
++---------------------------------------------------------------------------
+Index: build/parsePreamble.c
+--- build/parsePreamble.c 3 Mar 2003 20:46:34 -0000 1.1.1.13
++++ build/parsePreamble.c 6 Feb 2004 15:37:58 -0000 1.3
+@@ -21,6 +21,7 @@
+ RPMTAG_LICENSE,
+ RPMTAG_PACKAGER,
+ RPMTAG_DISTRIBUTION,
++ RPMTAG_CLASS,
+ RPMTAG_DISTURL,
+ RPMTAG_VENDOR,
+ RPMTAG_ICON,
+@@ -327,6 +328,7 @@
+ { RPMTAG_VENDOR, "%{vendor}" },
+ { RPMTAG_PACKAGER, "%{packager}" },
+ { RPMTAG_DISTRIBUTION, "%{distribution}" },
++ { RPMTAG_CLASS, "%{class}" },
+ { RPMTAG_DISTURL, "%{disturl}" },
+ { -1, NULL }
+ };
+@@ -537,6 +547,7 @@
+ (void) stashSt(spec, pkg->header, tag, lang);
+ /*@fallthrough@*/
+ case RPMTAG_DISTRIBUTION:
++ case RPMTAG_CLASS:
+ case RPMTAG_VENDOR:
+ case RPMTAG_LICENSE:
+ case RPMTAG_PACKAGER:
+@@ -743,6 +754,7 @@
+ {RPMTAG_LICENSE, 0, 0, "copyright"},
+ {RPMTAG_LICENSE, 0, 0, "license"},
+ {RPMTAG_DISTRIBUTION, 0, 0, "distribution"},
++ {RPMTAG_CLASS, 0, 0, "class"},
+ {RPMTAG_DISTURL, 0, 0, "disturl"},
+ {RPMTAG_VENDOR, 0, 0, "vendor"},
+ {RPMTAG_GROUP, 0, 1, "group"},