diff -Naur rpm-4.1.orig/Makefile.in rpm-4.1.runtime/Makefile.in
--- rpm-4.1.orig/Makefile.in	Tue Jul 22 11:45:16 2003
+++ rpm-4.1.runtime/Makefile.in	Tue Jul 22 11:46:12 2003
@@ -71,7 +71,7 @@
 OBJEXT = @OBJEXT@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 
-pkglibdir = @RPMCONFIGDIR@
+pkglibdir = @RPMCONFIGDIROLD@
 AMTAR = @AMTAR@
 AR = @AR@
 AS = @AS@
@@ -241,7 +241,6 @@
 	$(top_builddir)/popt/libpopt.la \
 	@WITH_LIBELF_LIB@ \
 	@WITH_ZLIB_LIB@ \
-	@INTLLIBS@ \
 	@LIBMISC@
 
 
@@ -267,32 +266,32 @@
 #rpm_LDFLAGS =		@LDFLAGS_STATIC@ $(myLDFLAGS)
 #rpm_LDADD =		$(myLDADD)
 rpmb_SOURCES = build.c
-rpmb_LDFLAGS = $(myLDFLAGS)
+rpmb_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmb_LDADD = rpmb.o $(myLDADD)
 
 rpmd_SOURCES = 
-rpmd_LDFLAGS = $(myLDFLAGS)
+rpmd_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmd_LDADD = rpmd.o $(myLDADD)
 
 rpmi_SOURCES = 
-rpmi_LDFLAGS = $(myLDFLAGS)
+rpmi_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmi_LDADD = rpmi.o $(myLDADD)
 
 rpmk_SOURCES = 
-rpmk_LDFLAGS = $(myLDFLAGS)
+rpmk_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmk_LDADD = rpmk.o $(myLDADD)
 
 rpmq_SOURCES = 
-rpmq_LDFLAGS = $(myLDFLAGS)
+rpmq_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
 rpmq_LDADD = rpmq.o $(myLDADD)
 
 rpm2cpio_SOURCES = rpm2cpio.c
-rpm2cpio_LDFLAGS = $(myLDFLAGS)
+rpm2cpio_LDFLAGS = @LDFLAGS_STATIC@ $(myLDFLAGS)
 rpm2cpio_LDADD = $(myLDADD) @LIBMISC@
 
 CVSTAG = r$(subst .,-,$(VERSION))
 
-pkgsrcdir = $(prefix)/src/rpm
+pkgsrcdir = $(prefix)/src/denx
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
diff -Naur rpm-4.1.orig/autodeps/linux.req rpm-4.1.runtime/autodeps/linux.req
--- rpm-4.1.orig/autodeps/linux.req	Fri Jun 28 18:55:04 2002
+++ rpm-4.1.runtime/autodeps/linux.req	Tue Jul 22 11:50:21 2003
@@ -70,21 +70,21 @@
 
 #
 # --- Script interpreters.
-for f in $scriptlist; do
-    [ -r $f -a -x $f ] || continue
-    interp=`head -n 1 $f | sed -e 's/^\#\![ 	]*//' | cut -d" " -f1`
-    interplist="$interplist $interp"
-    case $interp in
-    */perl)	perllist="$perllist $f" ;;
-    esac
-done
-[ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; }
+#for f in $scriptlist; do
+#    [ -r $f -a -x $f ] || continue
+#    interp=`head -n 1 $f | sed -e 's/^\#\![ 	]*//' | cut -d" " -f1`
+#    interplist="$interplist $interp"
+#    case $interp in
+#    */perl)	perllist="$perllist $f" ;;
+#    esac
+#done
+#[ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; }
 
 #
 # --- Add perl module files to perllist.
-for f in $filelist; do
-    [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f"
-done
+#for f in $filelist; do
+#    [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f"
+#done
 
 #
 # --- Weak symbol versions (from glibc).
diff -Naur rpm-4.1.orig/build/files.c rpm-4.1.runtime/build/files.c
--- rpm-4.1.orig/build/files.c	Tue Aug 20 20:52:20 2002
+++ rpm-4.1.runtime/build/files.c	Tue Jul 22 11:46:12 2003
@@ -29,6 +29,10 @@
 #include "misc.h"
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * target_arch;
+#endif
+
 /*@access Header @*/
 /*@access rpmfi @*/
 /*@access rpmte @*/
@@ -2553,6 +2557,9 @@
 	    tagflags = RPMSENSE_FIND_PROVIDES;
 	    /*@switchbreak@*/ break;
 	case RPMTAG_REQUIREFLAGS:
+#ifdef HAVE_RUNTIME_PREFIX
+           if (!target_arch) continue;
+#endif
 	    if (!pkg->autoReq)
 		continue;
 	    failnonzero = 0;
diff -Naur rpm-4.1.orig/build/pack.c rpm-4.1.runtime/build/pack.c
--- rpm-4.1.orig/build/pack.c	Fri Aug 23 23:16:13 2002
+++ rpm-4.1.runtime/build/pack.c	Tue Jul 22 11:46:12 2003
@@ -25,6 +25,11 @@
 #include "rpmlead.h"
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * target_cpu;
+extern char * target_arch;
+#endif
+
 /*@access rpmts @*/
 /*@access rpmfi @*/	/* compared with NULL */
 /*@access Header @*/	/* compared with NULL */
@@ -757,6 +762,62 @@
 		       RPM_INT32_TYPE, getBuildTime(), 1);
 
 	providePackageNVR(pkg->header);
+
+#ifdef HAVE_RUNTIME_PREFIX
+	if (target_arch) {
+		int type, count;
+		char * name, * tmp;
+		headerGetEntry(pkg->header, RPMTAG_NAME, &type, 
+			(void **) &name, &count);
+		tmp = xmalloc(strlen(name)+strlen(target_arch)+
+			strlen(target_cpu)+5);
+		strcpy(tmp, name);
+		sprintf(tmp+strlen(tmp), "-%s_%s",target_arch,target_cpu);
+		headerModifyEntry(pkg->header, RPMTAG_NAME, RPM_STRING_TYPE, 
+			tmp, 1);
+	}
+
+	if (getenv("CROSS_COMPILE")) {
+		char ** rname, ** cname;
+		char *  tmp;
+		char *  cc = getenv("CROSS_COMPILE");
+		int type, count = 0, i;
+
+		if (cc[strlen(cc)-1]=='-')
+	   		cc[strlen(cc)-1]=0;
+
+	 	headerGetEntry(pkg->header, RPMTAG_REQUIRENAME, &type, 
+			(void **) &rname, &count);
+	 	for (i=0; i<count; i++) {
+	 		if (!strstr(rname[i],cc) && !strchr(rname[i],'(') &&
+			   !strchr(rname[i],'/') &&
+			   !strstr(rname[i],".so")) {
+				tmp = xmalloc(strlen(rname[i])+1+strlen(cc)+1);
+				sprintf(tmp,"%s-%s",rname[i],cc);
+				rname[i]=tmp;
+	   		}
+	 	}
+	 	if (count != 0)
+	 		headerModifyEntry(pkg->header, RPMTAG_REQUIRENAME, 
+				RPM_STRING_ARRAY_TYPE, rname, count);
+
+	 	count = 0;
+	 	headerGetEntry(pkg->header, RPMTAG_CONFLICTNAME, &type, 
+			(void **) &cname, &count);
+	 	for (i=0; i<count; i++) {
+	 		if (!strstr(cname[i],cc) && !strchr(cname[i],'(') &&
+			   !strchr(cname[i],'/') &&
+			   !strstr(cname[i],".so")) {
+				tmp = xmalloc(strlen(cname[i])+1+strlen(cc)+1);
+				sprintf(tmp,"%s-%s",cname[i],cc);
+				cname[i]=tmp;
+	 		}
+	 	}
+	 	if (count != 0)
+	 		headerModifyEntry(pkg->header, RPMTAG_CONFLICTNAME, 
+				RPM_STRING_ARRAY_TYPE, cname, count);
+	}
+#endif
 
     {	const char * optflags = rpmExpand("%{optflags}", NULL);
 	(void) headerAddEntry(pkg->header, RPMTAG_OPTFLAGS, RPM_STRING_TYPE,
diff -Naur rpm-4.1.orig/build/parseSpec.c rpm-4.1.runtime/build/parseSpec.c
--- rpm-4.1.orig/build/parseSpec.c	Wed Jul  3 03:54:36 2002
+++ rpm-4.1.runtime/build/parseSpec.c	Tue Jul 22 11:46:12 2003
@@ -280,12 +280,18 @@
 	match = !matchTok(arch, s);
 	arch = _free(arch);
     } else if (! strncmp("%ifos", s, sizeof("%ifos")-1)) {
-	const char *os = rpmExpand("%{_target_os}", NULL);
+	const char *os = rpmExpand("%{_build_os}", NULL);
+	char *tmp;
+	if ((tmp = strstr(os,"-gnu")) != NULL)
+		os[strlen(os)-strlen(tmp)]=0;
 	s += 5;
 	match = matchTok(os, s);
 	os = _free(os);
     } else if (! strncmp("%ifnos", s, sizeof("%ifnos")-1)) {
-	const char *os = rpmExpand("%{_target_os}", NULL);
+	const char *os = rpmExpand("%{_build_os}", NULL);
+	char *tmp;
+	if ((tmp = strstr(os,"-gnu")) != NULL)
+		os[strlen(os)-strlen(tmp)]=0;
 	s += 6;
 	match = !matchTok(os, s);
 	os = _free(os);
diff -Naur rpm-4.1.orig/config.h.in rpm-4.1.runtime/config.h.in
--- rpm-4.1.orig/config.h.in	Sat Aug 31 17:33:32 2002
+++ rpm-4.1.runtime/config.h.in	Tue Jul 22 11:46:12 2003
@@ -538,6 +538,15 @@
 /* Version number of package */
 #undef VERSION
 
+/* detect the prefix in runtime */
+#undef HAVE_RUNTIME_PREFIX
+
+/* the target arhitecture */
+#undef TARGET_ARCH
+
+/* the target os */
+#undef TARGET_OS
+
 /* Define to 1 if on AIX 3.
    System headers sometimes define this.
    We just want to avoid a redefinition error message.  */
diff -Naur rpm-4.1.orig/configure rpm-4.1.runtime/configure
--- rpm-4.1.orig/configure	Sat Aug 31 17:23:24 2002
+++ rpm-4.1.runtime/configure	Tue Jul 22 11:46:12 2003
@@ -1276,6 +1276,40 @@
 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
 _ACEOF
 
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RUNTIME_PREFIX 1
+_ACEOF
+
+# Check whether --with-target_arch or --without-target_arch was given.
+if test "${with_target_arch+set}" = set; then
+  withval="$with_target_arch"
+  target_arch="$withval"
+else
+  target_arch=ppc
+fi
+
+cat >> confdefs.h <<_ACEOF
+#define TARGET_ARCH "$target_arch"
+_ACEOF
+
+# Check whether --with-target_os or --without-target_os was given.
+if test "${with_target_os+set}" = set; then
+  withval="$with_target_os"
+  target_os="$withval"
+else
+  target_os=linux
+fi
+
+cat >> confdefs.h <<_ACEOF
+#define TARGET_OS "$target_os"
+_ACEOF
+
+OSSHELL=/bin/sh
+
+case "$target" in
+       *-*-solaris*)   OSSHELL="/usr/local/bin/bash";;
+       *-*-linux*)     OSSHELL="/bin/sh";;
+esac
 
 # Let the site file select an alternate cache file if it wants to.
 # Prefer explicitly selected file to automatically selected ones.
@@ -21418,17 +21452,7 @@
 case "${build_os_noversion}" in
 mint)		RPMCANONARCH=m68kmint ;;
 esac
-RPMCANONVENDOR="$build_vendor"
-case "${build_vendor}" in
-unknown|pc|ibm|redhat|pld|mandrake|conectiva|lvr|yellowdog)
-	test -f /etc/redhat-release &&		RPMCANONVENDOR=redhat
-	test -f /etc/pld-release &&		RPMCANONVENDOR=pld
-	test -f /etc/mandrake-release &&	RPMCANONVENDOR=mandrake
-	test -f /etc/conectiva-release &&	RPMCANONVENDOR=conectiva
-	test -f /etc/lvr-release &&		RPMCANONVENDOR=lvr
-	test -f /etc/yellowdog-release &&	RPMCANONVENDOR=yellowdog
-	;;
-esac
+RPMCANONVENDOR="denx"
 RPMCANONOS="$build_os_noversion"
 
 
@@ -21439,7 +21463,9 @@
 else
     usrprefix=$prefix
 fi
-LOCALEDIR="`echo ${usrprefix}/share/locale`"
+
+runtime_prefix='%{_runtimeprefix}/usr'
+LOCALEDIR="`echo ${runtime_prefix}/share/locale`"
 
 cat >>confdefs.h <<_ACEOF
 #define LOCALEDIR "$LOCALEDIR"
@@ -21448,15 +21474,15 @@
 
 LIBDIR="`echo $libdir | sed 's-/lib$-/%{_lib}-'`"
 
-RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIROLD="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIR="`echo ${runtime_prefix}/lib/rpm`"
 
 cat >>confdefs.h <<_ACEOF
 #define RPMCONFIGDIR "$RPMCONFIGDIR"
 _ACEOF
 
 
-
-SYSCONFIGDIR="`echo /etc/rpm`"
+SYSCONFIGDIR="`echo ${runtime_prefix}/etc/rpm`"
 
 cat >>confdefs.h <<_ACEOF
 #define SYSCONFIGDIR "$SYSCONFIGDIR"
@@ -21464,7 +21490,7 @@
 
 
 
-MACROFILES="${RPMCONFIGDIR}/macros:${RPMCONFIGDIR}/%{_target_platform}/macros:${SYSCONFIGDIR}/macros:${SYSCONFIGDIR}/macros.specspo:${SYSCONFIGDIR}/macros.db1:${SYSCONFIGDIR}/%{_target_platform}/macros:~/.rpmmacros"
+MACROFILES="${RPMCONFIGDIR}/macros:${RPMCONFIGDIR}/%{_target_platform}/macros:${SYSCONFIGDIR}/macros:${SYSCONFIGDIR}/macros.specspo:${SYSCONFIGDIR}/macros.db1:${SYSCONFIGDIR}/%{_target_platform}/macros:~/.eldt_rpmmacros"
 
 cat >>confdefs.h <<_ACEOF
 #define MACROFILES "$MACROFILES"
@@ -22299,6 +22325,7 @@
 s,@LOCALEDIR@,$LOCALEDIR,;t t
 s,@LIBDIR@,$LIBDIR,;t t
 s,@RPMCONFIGDIR@,$RPMCONFIGDIR,;t t
+s,@RPMCONFIGDIROLD@,$RPMCONFIGDIROLD,;t t
 s,@SYSCONFIGDIR@,$SYSCONFIGDIR,;t t
 s,@MACROFILES@,$MACROFILES,;t t
 s,@LIBRPMRC_FILENAME@,$LIBRPMRC_FILENAME,;t t
@@ -22311,6 +22338,7 @@
 s,@LIBMISC@,$LIBMISC,;t t
 s,@RPM@,$RPM,;t t
 s,@OBJDUMP@,$OBJDUMP,;t t
+s,@OSSHELL@,$OSSHELL,;t t
 s,@subdirs@,$subdirs,;t t
 CEOF
 
diff -Naur rpm-4.1.orig/intl/Makefile.in rpm-4.1.runtime/intl/Makefile.in
--- rpm-4.1.orig/intl/Makefile.in	Sun Jul 21 18:20:41 2002
+++ rpm-4.1.runtime/intl/Makefile.in	Tue Jul 22 11:46:12 2003
@@ -105,9 +105,9 @@
 
 INCLUDES = -I.. -I. -I$(top_srcdir)/intl
 
-all: all-@USE_INCLUDED_LIBINTL@
+all: all-no
 all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
-all-no: all-no-@BUILD_INCLUDED_LIBINTL@
+all-no: all-no-no
 all-no-yes: libgnuintl.$la
 all-no-no:
 
diff -Naur rpm-4.1.orig/lib/Makefile.in rpm-4.1.runtime/lib/Makefile.in
--- rpm-4.1.orig/lib/Makefile.in	Sat Aug 31 17:23:17 2002
+++ rpm-4.1.runtime/lib/Makefile.in	Tue Jul 22 11:46:12 2003
@@ -229,7 +229,7 @@
 	-L$(top_builddir)/popt
 
 
-mylibs = -lrpm -lrpmdb -lrpmio -lpopt @LIBS@ @INTLLIBS@ @LIBMISC@
+mylibs = -lrpm -lrpmdb -lrpmio -lpopt @LIBS@ @LIBMISC@
 LIBS = 
 
 lib_LTLIBRARIES = librpm.la
diff -Naur rpm-4.1.orig/lib/depends.c rpm-4.1.runtime/lib/depends.c
--- rpm-4.1.orig/lib/depends.c	Tue Aug 20 17:29:06 2002
+++ rpm-4.1.runtime/lib/depends.c	Tue Jul 22 11:46:12 2003
@@ -603,6 +603,10 @@
 	   then if we're installing the libraries only, don't count it in. */
 	if (multiLib && !isDependsMULTILIB(Flags))
 	    continue;
+#ifdef HAVE_RUNTIME_PREFIX
+	if (*Name == '/' && !access(Name, F_OK))
+		continue;
+#endif
 
 	rc = unsatisfiedDepend(ts, requires, adding);
 
diff -Naur rpm-4.1.orig/lib/rpmfi.c rpm-4.1.runtime/lib/rpmfi.c
--- rpm-4.1.orig/lib/rpmfi.c	Tue Jul 22 11:45:16 2003
+++ rpm-4.1.runtime/lib/rpmfi.c	Tue Jul 22 11:46:12 2003
@@ -745,6 +745,7 @@
 		    fn, relocations[j].newPath);
 	nrelocated++;
 
+#ifndef HAVE_RUNTIME_PREFIX
 	strcpy(fn, relocations[j].newPath);
 	{   char * te = strrchr(fn, '/');
 	    if (te) {
@@ -758,6 +759,22 @@
 	    *te = '\0';			/* terminate new directory name */
 	    /*@=nullpass =nullderef@*/
 	}
+#else
+	{
+	    char * s = strrchr(fn, '/');
+
+	    if (s)
+	 	s++;
+	    else
+	 	s = fn;
+
+	    /* fn is the new dirName, and s is the new baseName */
+	    if (strcmp(baseNames[i], s))
+		baseNames[i] = alloca_strdup(s);
+
+	    *s = 0;
+	}
+#endif
 
 	/* Does this directory already exist in the directory list? */
 	for (j = 0; j < dirCount; j++) {
diff -Naur rpm-4.1.orig/lib/rpminstall.c rpm-4.1.runtime/lib/rpminstall.c
--- rpm-4.1.orig/lib/rpminstall.c	Mon Sep 16 23:06:08 2002
+++ rpm-4.1.runtime/lib/rpminstall.c	Tue Jul 22 11:46:12 2003
@@ -35,6 +35,10 @@
 /*@unchecked@*/
 int rpmcliProgressTotal = 0;
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+#endif
+
 /**
  * Print a CLI progress bar.
  * @todo Unsnarl isatty(STDOUT_FILENO) from the control flow.
@@ -325,12 +329,14 @@
 			rpmShowProgress, (void *) ((long)notifyFlags));
     }
 
+#ifndef HAVE_RUNTIME_PREFIX
     if ((eiu->relocations = relocations) != NULL) {
 	while (eiu->relocations->oldPath)
 	    eiu->relocations++;
 	if (eiu->relocations->newPath == NULL)
 	    eiu->relocations = NULL;
     }
+#endif
 
     /* Build fully globbed list of arguments in argv[argc]. */
     /*@-branchstate@*/
@@ -484,6 +490,55 @@
 	default:
 	    /*@switchbreak@*/ break;
 	}
+#ifdef HAVE_RUNTIME_PREFIX
+	{
+		int type, count, i;
+		char * name, * arch , * tmp, * cpu;
+		int num_relocs;
+
+		for (num_relocs = 0; relocations && 
+			relocations[num_relocs].oldPath &&
+			relocations[num_relocs].newPath; num_relocs++);
+
+		relocations = xrealloc(relocations, sizeof(*relocations) *
+					(num_relocs + 2));
+		relocations[num_relocs].oldPath = "/";
+		relocations[num_relocs].newPath = runtime_prefix;
+
+
+		headerGetEntry(eiu->h, RPMTAG_ARCH , &type, (void **) &arch, 
+			&count);
+		headerGetEntry(eiu->h, RPMTAG_NAME , &type, (void **) &name, 
+			&count);
+
+		for (i = strlen(name); i > 0; i--)
+			if (name[i] == '-') {
+				if (count == 1) break;
+				else count++;
+			}
+
+		if (count == 1 && !strncmp(name + i + 1, arch, strlen(arch))) {
+			tmp = xmalloc(strlen(relocations[num_relocs].newPath) +
+				strlen(name) + 20);
+
+			cpu = name + i + strlen(arch) + 2;
+			sprintf(tmp, "%s/%s_%s/",
+				relocations[num_relocs].newPath, arch, cpu);
+			relocations[num_relocs].newPath = tmp;
+			probFilter |= RPMPROB_FILTER_FORCERELOCATE |
+				RPMPROB_FILTER_IGNOREARCH | 
+				RPMPROB_FILTER_IGNOREOS;
+		} else {
+			tmp = xmalloc(strlen(relocations[num_relocs].newPath) 
+				+ 10);
+			sprintf(tmp, "%s/", relocations[num_relocs].newPath);
+			relocations[num_relocs].newPath = tmp;
+			probFilter |= RPMPROB_FILTER_FORCERELOCATE ;
+		}
+		relocations[num_relocs+1].oldPath = NULL;
+		relocations[num_relocs+1].newPath = NULL;
+    	}
+#endif
 
 	eiu->isSource = headerIsEntry(eiu->h, RPMTAG_SOURCEPACKAGE);
 
diff -Naur rpm-4.1.orig/lib/rpmrc.c rpm-4.1.runtime/lib/rpmrc.c
--- rpm-4.1.orig/lib/rpmrc.c	Tue Jul 22 11:45:16 2003
+++ rpm-4.1.runtime/lib/rpmrc.c	Tue Jul 22 11:46:12 2003
@@ -24,7 +24,7 @@
 /*@access FD_t@*/		/* compared with NULL */
 
 /*@observer@*/ /*@unchecked@*/
-static const char *defrcfiles = LIBRPMRC_FILENAME ":" VENDORRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc"; 
+static const char *defrcfiles = LIBRPMRC_FILENAME ":" VENDORRPMRC_FILENAME ":%{_runtimeprefix}/etc/rpmrc:~/.eldt_rpmrc"; 
 
 /*@observer@*/ /*@checked@*/
 const char * macrofiles = MACROFILES;
@@ -519,6 +519,184 @@
 export RPM_BUILD_ROOT\n}\
 ";
 
+#ifdef HAVE_RUNTIME_PREFIX
+#define LIB_PATH "/usr/lib/rpm/"
+#define USR_PATH "/usr/bin/"
+extern char * runtime_prefix;
+extern char * target_arch;
+extern char * target_cpu;
+extern int    install_mode;
+
+int get_path_len();
+void obtain_runtime_prefix(char *argv0);
+
+int get_path_len ()
+{
+	int path_max;
+
+#ifdef PATH_MAX
+	return PATH_MAX;
+#else
+	path_max = pathconf (path, _PC_PATH_MAX);
+	if (path_max <= 0)
+		path_max = 4096;
+	return path_max;
+#endif
+}
+
+void find_file_path (char * filename, char * path)
+{
+	char  * p;
+	char  * dirs;
+	char  * entry, * tmp;
+	DIR * dir;
+	int found;
+	struct dirent * file;
+
+	p = getenv("PATH");
+	dirs  = xmalloc(strlen(p)+1);
+	entry = xmalloc(strlen(p)+1);
+	tmp = xmalloc(strlen(p)+1);
+	strcpy(dirs, p);
+
+	for (found = 0, p = strtok_r(dirs, ":", &entry); !found && p;
+		p = strtok_r(NULL, ":", &entry)) {
+		dir = opendir(p);
+		if (!dir) continue;
+		while (file = readdir(dir)) {
+			if (!strncmp(filename, file->d_name, file->d_reclen)) {
+				struct stat fstat;
+				sprintf(tmp, "%s/%s", p, file->d_name);
+				if (stat(tmp, &fstat) < 0) continue;
+				if (!S_ISREG(fstat.st_mode)) continue;
+				if ((fstat.st_mode & S_IXUSR) || 
+				    (fstat.st_mode & S_IXGRP) ||
+				    (fstat.st_mode & S_IXOTH)) {
+					found = 1;
+					break;
+				}
+			}
+
+		 }
+		 closedir(dir);
+	}
+
+	strcpy(path, tmp);
+}
+
+void obtain_runtime_prefix (char *argv0)
+{
+	char * tmp, *p;
+	int i, path_len;
+
+	install_mode = 0;
+	path_len = get_path_len();
+	runtime_prefix = xmalloc(path_len+1);
+	tmp = xmalloc(path_len+1);
+	strcpy(runtime_prefix,argv0);
+
+again:
+	for (i = strlen(runtime_prefix); i > 0; i--) 
+		if (runtime_prefix[i] == '/') break;
+
+	if (i > 0)
+		runtime_prefix[i+1]=0; 
+	else {
+		find_file_path(runtime_prefix, runtime_prefix);
+		goto again;
+
+	}
+	realpath(runtime_prefix,tmp);
+	strcat(tmp,"/");
+
+	if (!strcmp(tmp + (strlen(tmp) - strlen(LIB_PATH)), LIB_PATH))
+		strcat(tmp,"../../../"); 
+	else
+		if (!strcmp(tmp + (strlen(tmp) - strlen(USR_PATH)), USR_PATH))
+			 strcat(tmp, "../../");
+		else
+			 strcat(tmp, "../");
+
+	realpath(tmp, runtime_prefix);
+	if (getenv("CROSS_COMPILE")) {
+		tmp = strdup(getenv("CROSS_COMPILE"));
+
+		p = rindex(tmp, '/');
+
+		if (!p) 
+			p =  tmp; 
+		else  
+			p ++;
+
+		target_arch = p;
+		for(i = strlen(target_arch); i > 0; i--)
+		if (target_arch[i] == '_') {
+			target_arch[i] = 0;
+			break;
+		}
+
+
+		if (i <= 0) {
+			printf("CROSS_COMPILE variable has wrong format\n");
+			exit(2);
+		}
+
+		target_cpu = strdup(target_arch + strlen(target_arch) + 1);
+		if (target_cpu[strlen(target_cpu) - 1] == '-')
+			target_cpu[strlen(target_cpu) - 1] = 0;
+
+		addMacro(NULL, "_targetarch", NULL, target_arch, RMIL_DEFAULT);
+		addMacro(NULL, "_targetcpu" , NULL, target_arch, RMIL_DEFAULT);
+		addMacro(NULL, "_realtargetcpu", NULL, target_cpu, 
+			RMIL_DEFAULT);
+
+	} else {
+		/* If CROSS_COMPILE variable is not set, analyse the argv[0].
+		   If argv[0] is <arch>-rpm, set _targetarch to <arch>.
+		   If argv[0] is <arch>_<cpu>-rpm, set _targetarch to <arch> and
+		   set CROSS_COMPILE to <arch>_<cpu>.
+		*/
+		p = basename(argv0);
+		tmp = strrchr(p, '-');
+
+		if (tmp && --tmp != p) {
+			target_arch = strdup(p);
+			target_arch[tmp - p + 1] = '\0';
+			if (p = strchr(target_arch, '_')) {
+				/* <cpu> component present */
+
+				setenv("CROSS_COMPILE", target_arch, 0);
+				*p = '\0';
+				target_cpu = strdup(p + 1);
+				addMacro(NULL, "_targetcpu", NULL, target_arch,
+					 RMIL_DEFAULT);
+			 	addMacro(NULL, "_realtargetcpu", NULL, 
+					target_cpu, RMIL_DEFAULT);
+			} else {
+				target_cpu  = NULL;
+			}
+			setenv("CURRENT_ARCH",target_arch, 0);
+			addMacro(NULL, "_targetarch", NULL, target_arch, 
+				RMIL_DEFAULT);
+		 } else {
+			target_arch = NULL;
+			target_cpu  = NULL;
+			if (getenv("CURRENT_ARCH")) {
+				addMacro(NULL, "_targetarch", NULL, 
+					getenv("CURRENT_ARCH"), RMIL_DEFAULT);
+			} else {
+				addMacro(NULL, "_targetarch", NULL, 
+					TARGET_ARCH, RMIL_DEFAULT);
+			}
+		 }
+
+	}
+
+	addMacro(NULL, "_runtimeprefix",NULL, runtime_prefix,RMIL_DEFAULT);
+	setenv("RUNTIME_PREFIX",runtime_prefix,1);
+}
+#endif
+
 static void setDefaults(void)
 	/*@globals rpmGlobalMacroContext,
 		internalState @*/
@@ -796,7 +974,13 @@
     char * p, * pe;
     int rc;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    char * pl = alloca(strlen(platform) + strlen(runtime_prefix) + 2);
+    sprintf(pl, "%s/%s\n", runtime_prefix, platform);
+    rc = rpmioSlurp((const char *)pl, &b, &blen);
+#else
     rc = rpmioSlurp(platform, &b, &blen);
+#endif
 
     if (rc || b == NULL || blen <= 0) {
 	rc = -1;
@@ -1620,10 +1804,22 @@
     delMacro(NULL, "_target_cpu");
     addMacro(NULL, "_target_cpu", NULL, ca, RMIL_RPMRC);
     delMacro(NULL, "_target_os");
+#ifdef HAVE_RUNTIME_PREFIX
+    if (getenv("CROSS_COMPILE"))
+	addMacro(NULL, "_target_os", NULL, TARGET_OS, RMIL_RPMRC);
+    else
+	addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC);
+#else
     addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC);
+#endif
 /*
  * XXX Make sure that per-arch optflags is initialized correctly.
  */
+
+#ifdef HAVE_RUNTIME_PREFIX
+  ca = rpmExpand("%{_target_cpu}", NULL);
+#endif
+
   { const char *optflags = rpmGetVarArch(RPMVAR_OPTFLAGS, ca);
     if (optflags != NULL) {
 	delMacro(NULL, "optflags");
@@ -1776,6 +1972,9 @@
 	    strcpy(fn, home);
 	    r++;
 	}
+#ifdef HAVE_RUNTIME_PREFIX
+	r = rpmExpand(r, NULL);
+#endif
 	strncat(fn, r, sizeof(fn) - (strlen(fn) + 1));
 	fn[sizeof(fn)-1] = '\0';
 
diff -Naur rpm-4.1.orig/macros.in rpm-4.1.runtime/macros.in
--- rpm-4.1.orig/macros.in	Tue Jul 22 11:45:16 2003
+++ rpm-4.1.runtime/macros.in	Tue Jul 22 11:46:12 2003
@@ -96,7 +96,7 @@
 %_builddir		%{_topdir}/BUILD
 
 #	The interpreter used for build scriptlets.
-%_buildshell		/bin/sh
+%_buildshell		@OSSHELL@
 
 #	The path to the bzip2 executable (legacy, use %{__bzip2} instead).
 %_bzip2bin		%{__bzip2}
diff -Naur rpm-4.1.orig/popt/Makefile.in rpm-4.1.runtime/popt/Makefile.in
--- rpm-4.1.orig/popt/Makefile.in	Sat Aug 31 17:22:18 2002
+++ rpm-4.1.runtime/popt/Makefile.in	Tue Jul 22 11:46:12 2003
@@ -130,7 +130,7 @@
 
 noinst_HEADERS = findme.h poptint.h system.h
 
-noinst_PROGRAMS = test1 test2 test3
+#noinst_PROGRAMS = test1 test2 test3
 test1_SOURCES = test1.c
 test1_LDFLAGS = -all-static
 test1_LDADD = $(lib_LTLIBRARIES)
@@ -168,7 +168,7 @@
 am_libpopt_la_OBJECTS = popt.lo findme.lo poptparse.lo poptconfig.lo \
 	popthelp.lo
 libpopt_la_OBJECTS = $(am_libpopt_la_OBJECTS)
-noinst_PROGRAMS = test1$(EXEEXT) test2$(EXEEXT) test3$(EXEEXT)
+#noinst_PROGRAMS = test1$(EXEEXT) test2$(EXEEXT) test3$(EXEEXT)
 PROGRAMS = $(noinst_PROGRAMS)
 
 am_test1_OBJECTS = test1.$(OBJEXT)
diff -Naur rpm-4.1.orig/popt/config.h.in rpm-4.1.runtime/popt/config.h.in
--- rpm-4.1.orig/popt/config.h.in	Sat Aug 31 17:39:40 2002
+++ rpm-4.1.runtime/popt/config.h.in	Tue Jul 22 11:46:12 2003
@@ -208,6 +208,9 @@
 /* Full path to popt top_sourcedir. */
 #undef POPT_SOURCE_PATH
 
+/* detect the prefix in runtime */
+#undef HAVE_RUNTIME_PREFIX
+
 /* Define if <inttypes.h> exists and defines unusable PRI* macros. */
 #undef PRI_MACROS_BROKEN
 
diff -Naur rpm-4.1.orig/popt/configure rpm-4.1.runtime/popt/configure
--- rpm-4.1.orig/popt/configure	Sat Aug 31 17:22:20 2002
+++ rpm-4.1.runtime/popt/configure	Tue Jul 22 11:46:13 2003
@@ -8439,7 +8439,9 @@
 fi
 
 
-
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RUNTIME_PREFIX 1
+_ACEOF
 
 
 
diff -Naur rpm-4.1.orig/popt/intl/Makefile.in rpm-4.1.runtime/popt/intl/Makefile.in
--- rpm-4.1.orig/popt/intl/Makefile.in	Sun Jul 21 18:21:15 2002
+++ rpm-4.1.runtime/popt/intl/Makefile.in	Tue Jul 22 11:46:13 2003
@@ -105,9 +105,9 @@
 
 INCLUDES = -I.. -I. -I$(top_srcdir)/intl
 
-all: all-@USE_INCLUDED_LIBINTL@
+all: all-no
 all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
-all-no: all-no-@BUILD_INCLUDED_LIBINTL@
+all-no: all-no-no
 all-no-yes: libgnuintl.$la
 all-no-no:
 
diff -Naur rpm-4.1.orig/popt/popt.c rpm-4.1.runtime/popt/popt.c
--- rpm-4.1.orig/popt/popt.c	Thu Aug 22 18:17:44 2002
+++ rpm-4.1.runtime/popt/popt.c	Tue Jul 22 11:46:13 2003
@@ -51,6 +51,9 @@
 
 void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
 {
+#ifdef HAVE_RUNTIME_PREFIX
+    path = (const char *) rpmExpand(path, NULL);
+#endif
     con->execPath = _free(con->execPath);
     con->execPath = xstrdup(path);
     con->execAbsolute = allowAbsolute;
diff -Naur rpm-4.1.orig/popt/poptconfig.c rpm-4.1.runtime/popt/poptconfig.c
--- rpm-4.1.orig/popt/poptconfig.c	Thu Aug 22 18:17:50 2002
+++ rpm-4.1.runtime/popt/poptconfig.c	Tue Jul 22 11:46:13 2003
@@ -100,6 +100,10 @@
     int fd, rc;
     off_t fileLength;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    fn = rpmExpand(fn, NULL);
+#endif
+
     fd = open(fn, O_RDONLY);
     if (fd < 0)
 	return (errno == ENOENT ? 0 : POPT_ERROR_ERRNO);
diff -Naur rpm-4.1.orig/rpm.c rpm-4.1.runtime/rpm.c
--- rpm-4.1.orig/rpm.c	Thu May 16 20:55:25 2002
+++ rpm-4.1.runtime/rpm.c	Tue Jul 22 11:46:13 2003
@@ -234,6 +234,14 @@
 static void printUsage(void);
 static void printHelpLine(char * prefix, char * help);
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+extern char * target_arch;
+extern char * target_cpu;
+extern int    install_mode;
+extern void obtain_runtime_prefix(char *argv0);
+#endif
+
 static void printVersion(void) {
     fprintf(stdout, _("RPM version %s\n"), rpmEVR);
 }
@@ -604,6 +612,10 @@
     int upgrade = 0;
     int freshen = 0;
     int probFilter = 0;
+
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
 	
 #if HAVE_MCHECK_H && HAVE_MTRACE
     mtrace();	/* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
@@ -673,10 +685,20 @@
     /* set up the correct locale */
     setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef	__LCLINT__
 #define	LOCALEDIR	"/usr/share/locale"
 #endif
     bindtextdomain(PACKAGE, LOCALEDIR);
+#else /* HAVE_RUNTIME_PREFIX */
+    {
+	char * localedir;
+	localedir = xmalloc(get_path_len() + 1);
+	sprintf(localedir, "%s/share/locale", runtime_prefix);
+	bindtextdomain(PACKAGE, localedir);
+	free(localedir);
+    }
+#endif
     textdomain(PACKAGE);
 
     rpmSetVerbosity(RPMMESS_NORMAL);	/* XXX silly use by showrc */
diff -Naur rpm-4.1.orig/rpmdb/rpmdb.c rpm-4.1.runtime/rpmdb/rpmdb.c
--- rpm-4.1.orig/rpmdb/rpmdb.c	Tue Sep 17 18:55:52 2002
+++ rpm-4.1.runtime/rpmdb/rpmdb.c	Tue Jul 22 11:46:13 2003
@@ -42,6 +42,10 @@
 #include "header_internal.h"	/* XXX for HEADERFLAG_ALLOCATED */
 #include "debug.h"
 
+#ifdef HAVE_RUNTIME_PREFIX
+#include "rpmlib.h"
+#endif
+
 /*@access dbiIndexSet@*/
 /*@access dbiIndexItem@*/
 /*@access rpmts@*/		/* XXX compared with NULL */
@@ -2307,6 +2311,20 @@
     mi->mi_prevoffset = mi->mi_offset;
     mi->mi_modified = 0;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    if (getenv("CROSS_COMPILE")) {
+	int type, count;
+	char * name, * tmp = getenv("CROSS_COMPILE");
+
+	if (tmp[strlen(tmp) - 1] == '-')
+	     tmp[strlen(tmp) - 1] = 0;
+
+	headerGetEntry(mi->mi_h, RPMTAG_NAME, &type, (void **) &name, &count);
+	if (strcmp(name + strlen(name) - strlen(tmp), tmp) != 0)
+	    return rpmdbNextIterator(mi);
+    }
+#endif
+
 /*@-compdef -retalias -retexpose -usereleased @*/
     return mi->mi_h;
 /*@=compdef =retalias =retexpose =usereleased @*/
@@ -2438,6 +2456,23 @@
     (void) rpmdbCheckSignals();
 
     /* XXX HACK to remove rpmdbFindByLabel/findMatches from the API */
+#ifdef HAVE_RUNTIME_PREFIX
+    if (getenv("CROSS_COMPILE") && keyp && rpmtag != RPMDBI_PACKAGES) {
+	char * tmp_keyp;
+	char * tmp = getenv("CROSS_COMPILE");
+
+	if (tmp[strlen(tmp) - 1] == '-')
+	    tmp[strlen(tmp) - 1] = 0;
+
+	if (!strstr(keyp, tmp) && !strstr(keyp, ".so") &&
+	    !strchr(keyp, '/') && !strchr(keyp, '(')) {
+	    tmp_keyp = xmalloc(strlen(keyp) + 1 + strlen(tmp) + 1);
+	    sprintf(tmp_keyp, "%s-%s", keyp, tmp);
+	    keyp = tmp_keyp;
+	}
+   }
+#endif
+
     if (rpmtag == RPMDBI_LABEL) {
 	rpmtag = RPMTAG_NAME;
 	isLabel = 1;
diff -Naur rpm-4.1.orig/rpmio/macro.c rpm-4.1.runtime/rpmio/macro.c
--- rpm-4.1.orig/rpmio/macro.c	Tue Sep 17 18:58:23 2002
+++ rpm-4.1.runtime/rpmio/macro.c	Tue Jul 22 11:46:13 2003
@@ -111,6 +111,57 @@
 
 #define	MACRO_CHUNK_SIZE	16
 
+#ifdef HAVE_RUNTIME_PREFIX
+typedef struct {
+	char * name;
+	char * subst;
+	int target_only;
+} Subst;
+
+Subst Substitutions[16] = {
+	{"_usr",	   "/usr",0},
+	{"_prefix",	   "/usr",0},
+	{"_sysconfdir",	   "/etc",0},
+	{"_mandir",	   "%{_prefix}/share/man",0},
+	{"_localstatedir", "/var",0},
+	{"_usrsrc",	   "%{_runtimeprefix}%{_usr}/src",0},
+	{"_var",	   "%{_runtimeprefix}/var",0},
+	{"__find_provides","%{_runtimeprefix}/usr/lib/rpm/find-provides",0},
+	{"__find_requires",   "%{_runtimeprefix}/usr/lib/rpm/find-requires",0},
+	{"__os_install_post", "%{_runtimeprefix}/usr/lib/rpm/brp-compress \
+		%{_runtimeprefix}/usr/lib/rpm/brp-strip \
+		%{_runtimeprefix}/usr/lib/rpm/brp-strip-comment-note \
+		%{nil}",0},
+	{"find_lang","%{_runtimeprefix}/usr/lib/rpm/find-lang.sh %{buildroot}"
+			,0},
+	{"_arch",	"%{_targetarch}",1},
+	{"_target_cpu",	"%{_targetcpu}",1},
+	{"_vendor",	"denx"},
+	{"_topdir",	"%{_usrsrc}/%{_vendor}"},
+	{"_dbapi",	"3"}
+};
+
+char * runtime_prefix;
+char * target_arch;
+char * target_cpu;
+int    install_mode;
+
+static char * replace_poor_macros(const char * macroname, const char * body);
+
+static char * replace_poor_macros(const char * macroname, const char * body)
+{
+       int i;
+
+       for (i=0;i<sizeof(Substitutions)/sizeof(Substitutions[0]);i++) {
+	       if (!target_arch && Substitutions[i].target_only) continue;
+	       if (!strcmp(macroname,Substitutions[i].name))
+		       return Substitutions[i].subst;
+       }
+
+       return body;
+}
+#endif
+
 /* forward ref */
 static int expandMacro(MacroBuf mb)
 	/*@globals rpmGlobalMacroContext,
@@ -1515,6 +1566,11 @@
 {
     MacroEntry * mep;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    const char * bb;
+    bb = replace_poor_macros(n, b);
+#endif
+
     if (mc == NULL) mc = rpmGlobalMacroContext;
 
     /* If new name, expand macro table */
@@ -1527,7 +1583,11 @@
 
     if (mep != NULL) {
 	/* Push macro over previous definition */
+#ifdef HAVE_RUNTIME_PREFIX
+	pushMacro(mep, n, o, bb, level);
+#else
 	pushMacro(mep, n, o, b, level);
+#endif
 
 	/* If new name, sort macro table */
 	if ((*mep)->prev == NULL)
@@ -1620,6 +1680,10 @@
 		strncat(buf, "/", sizeof(buf) - strlen(buf));
 	    }
 	}
+#ifdef HAVE_RUNTIME_PREFIX
+	/* Or another shell variable */
+	mfile = rpmExpand(mfile, NULL);
+#endif
 	strncat(buf, mfile, sizeof(buf) - strlen(buf));
 	buf[sizeof(buf)-1] = '\0';
 
@@ -1986,6 +2050,10 @@
     int errflg = 0;
     extern char *optarg;
     extern int optind;
+
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
 
     while ((c = getopt(argc, argv, "f:")) != EOF ) {
 	switch (c) {
diff -Naur rpm-4.1.orig/rpmqv.c rpm-4.1.runtime/rpmqv.c
--- rpm-4.1.orig/rpmqv.c	Thu Aug 22 20:26:22 2002
+++ rpm-4.1.runtime/rpmqv.c	Tue Jul 22 11:46:13 2003
@@ -122,6 +122,11 @@
     exit(EXIT_FAILURE);
 }
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+extern void obtain_runtime_prefix(char *argv0);
+#endif
+
 static void printVersion(FILE * fp)
 	/*@globals rpmEVR, fileSystem @*/
 	/*@modifies *fp, fileSystem @*/
@@ -203,6 +208,10 @@
     int i;
 #endif
 	
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
+
 #if HAVE_MCHECK_H && HAVE_MTRACE
     /*@-noeffect@*/
     mtrace();	/* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
@@ -220,6 +229,13 @@
 	else __progname = argv[0];
     }
 
+#ifdef HAVE_RUNTIME_PREFIX
+    {
+	char * tmp;
+	if ((tmp = strrchr(__progname, '-')) != NULL) __progname = ++tmp;
+    }
+#endif
+
     /* Set the major mode based on argv[0] */
     /*@-nullpass@*/
 #ifdef	IAM_RPMBT
@@ -274,10 +290,20 @@
     /* set up the correct locale */
     (void) setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef	__LCLINT__
 #define	LOCALEDIR	"/usr/share/locale"
 #endif
     bindtextdomain(PACKAGE, LOCALEDIR);
+#else /* HAVE_RUNTIME_PREFIX */
+    {
+	char * localedir;
+	localedir = xmalloc(get_path_len() + 1);
+	sprintf(localedir, "%s/share/locale", runtime_prefix);
+	bindtextdomain(PACKAGE, localedir);
+	free(localedir);
+    }
+#endif
     textdomain(PACKAGE);
 
     rpmSetVerbosity(RPMMESS_NORMAL);	/* XXX silly use by showrc */
diff -Naur rpm-4.1.orig/rpmrc.in rpm-4.1.runtime/rpmrc.in
--- rpm-4.1.orig/rpmrc.in	Fri Jul 19 01:42:20 2002
+++ rpm-4.1.runtime/rpmrc.in	Tue Jul 22 11:46:13 2003
@@ -30,7 +30,7 @@
 
 optflags: sparc -O2 -m32 -mtune=ultrasparc
 optflags: sparcv9 -O2 -m32 -mcpu=ultrasparc
-optflags: sparc64 -O2 -m64 -mcpu=ultrasparc
+optflags: sparc64 -O2 -m32 -mcpu=ultrasparc
 
 optflags: m68k -O2 -fomit-frame-pointer
 
@@ -98,7 +98,7 @@
 arch_canon:     ia64:	ia64	9
 
 arch_canon:	sparc64:sparc64 10
-arch_canon:	sun4u:	sparc64 10
+arch_canon:	sun4u:	sparc   3
 arch_canon:	mipsel:	mipsel	11
 
 arch_canon:	armv3l: armv3l	12
@@ -176,7 +176,7 @@
 buildarchtranslate: sun4d: sparc
 buildarchtranslate: sun4m: sparc
 buildarchtranslate: sparcv9: sparc
-buildarchtranslate: sun4u: sparc64
+buildarchtranslate: sun4u: sparc
 
 buildarchtranslate: osfmach3_ppc: ppc
 buildarchtranslate: powerpc: ppc
@@ -343,7 +343,7 @@
 buildarch_compat: s390: noarch
 buildarch_compat: s390x: noarch
 
-macrofiles:	@RPMCONFIGDIR@/macros:@RPMCONFIGDIR@/%{_target}/macros:@SYSCONFIGDIR@/macros.specspo:@SYSCONFIGDIR@/macros.prelink:@SYSCONFIGDIR@/macros.solve:@SYSCONFIGDIR@/macros.up2date:@SYSCONFIGDIR@/macros:@SYSCONFIGDIR@/%{_target}/macros:~/.rpmmacros
+macrofiles:	@RPMCONFIGDIR@/macros:@RPMCONFIGDIR@/%{_target}/macros:@SYSCONFIGDIR@/macros.specspo:@SYSCONFIGDIR@/macros.prelink:@SYSCONFIGDIR@/macros.solve:@SYSCONFIGDIR@/macros.up2date:@SYSCONFIGDIR@/%{_target}/macros:~/.eldt_rpmmacros
 
 # \endverbatim
 #*/
diff -Naur rpm-4.1.orig/scripts/find-lang.sh rpm-4.1.runtime/scripts/find-lang.sh
--- rpm-4.1.orig/scripts/find-lang.sh	Fri Jun 28 18:51:17 2002
+++ rpm-4.1.runtime/scripts/find-lang.sh	Tue Jul 22 11:46:13 2003
@@ -82,17 +82,13 @@
 s:'"$TOP_DIR"'::
 '"$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*/'"$NAME"'\.mo$\):%lang(\2) \1\2\3:
 '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%lang(\2) \1\2:
-s:^\([^%].*\)::
-s:%lang(C) ::
-' > $MO_NAME
+' | sed -n '/^%/p' | sed -e 's:%lang(C) ::' > $MO_NAME
 
 find $TOP_DIR -type d|sed '
 s:'"$TOP_DIR"'::
 '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1:
 '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%dir %lang(\2) \1\2:
-s:^\([^%].*\)::
-s:%lang(C) ::
-' >> $MO_NAME
+' | sed -n '/^%/p' | sed -e 's:%lang(C) ::' >> $MO_NAME
 
 if ! grep -q / $MO_NAME; then
 	echo "No translations found for ${NAME} in ${TOP_DIR}"
diff -Naur rpm-4.1.orig/tools/Makefile.in rpm-4.1.runtime/tools/Makefile.in
--- rpm-4.1.orig/tools/Makefile.in	Sat Aug 31 17:23:21 2002
+++ rpm-4.1.runtime/tools/Makefile.in	Tue Jul 22 11:46:13 2003
@@ -225,15 +225,14 @@
 	$(top_builddir)/rpmdb/librpmdb.la \
 	$(top_builddir)/rpmio/librpmio.la \
 	$(top_builddir)/popt/libpopt.la \
-	@WITH_LIBELF_LIB@ \
-	@INTLLIBS@
+	@WITH_LIBELF_LIB@ 
 
 
 noinst_PROGRAMS = \
 	dump dumpdb rpmarchive rpmheader rpmlead rpmsignature
 
 
-pkgbindir = @RPMCONFIGDIR@
+pkgbindir = @RPMCONFIGDIROLD@
 pkgbin_PROGRAMS = javadeps rpmcache striptofile unstripfile
 
 bin_PROGRAMS = rpmgraph
diff -Naur rpm-4.1.orig/tools/rpmsort.c rpm-4.1.runtime/tools/rpmsort.c
--- rpm-4.1.orig/tools/rpmsort.c	Mon Sep 16 23:07:19 2002
+++ rpm-4.1.runtime/tools/rpmsort.c	Tue Jul 22 11:46:13 2003
@@ -291,16 +291,31 @@
     int arg;
     int ec = 0;
 
+#ifdef HAVE_RUNTIME_PREFIX
+    obtain_runtime_prefix(argv[0]);
+#endif
+
 #if HAVE_MCHECK_H && HAVE_MTRACE
     mtrace();	/* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
 #endif
     setprogname(argv[0]);	/* Retrofit glibc __progname */
     (void)setlocale(LC_ALL, "" );
 
+#ifndef HAVE_RUNTIME_PREFIX
 #ifdef  __LCLINT__
 #define LOCALEDIR	"/usr/share/locale"
 #endif
     (void)bindtextdomain(PACKAGE, LOCALEDIR);
+#else /* HAVE_RUNTIME_PREFIX */
+    {
+	char * localedir;
+
+	localedir = xmalloc(get_path_len()+1);
+	sprintf(localedir, "%s/share/locale", runtime_prefix);
+	bindtextdomain(PACKAGE, localedir);
+	free(localedir);
+    }
+#endif
     (void)textdomain(PACKAGE);
 
     _depends_debug = 1;
@@ -315,8 +330,10 @@
 	    rpmIncreaseVerbosity();
 	    break;
 	default:
+#if 0
 	    fprintf(stderr, _("unknown popt return (%d)"), arg);
 	    exit(EXIT_FAILURE);
+#endif
 	    /*@notreached@*/ break;
 	}
     }
--- rpm-4.1.orig/lib/transaction.c	Tue Jul 22 11:46:12 2003
+++ rpm-4.1.runtime/lib/transaction.c	Tue Jul 22 13:14:00 2003
@@ -47,6 +47,10 @@
 /*@access rpmtsi @*/
 /*@access rpmts @*/
 
+#ifdef HAVE_RUNTIME_PREFIX
+extern char * runtime_prefix;
+#endif
+
 /**
  */
 static int archOkay(/*@null@*/ const char * pkgArch)
@@ -502,6 +506,8 @@
     uint_32 fixupSize = 0;
     rpmps ps;
     const char * fn;
+    char *t = 0;
+    int len;
     int i, j;
   
     ps = rpmtsProblems(ts);
@@ -520,6 +526,13 @@
 	    continue;
 
 	fn = rpmfiFN(fi);
+#ifdef HAVE_RUNTIME_PREFIX
+        len = strlen(runtime_prefix);
+        if (strncmp(fn, runtime_prefix, len)) {
+                t = malloc(len + 1 + strlen(fn));
+                sprintf(t, "%s%s", runtime_prefix, fn);
+        }
+#endif
 	fiFps = fi->fps + i;
 	FFlags = rpmfiFFlags(fi);
 	FMode = rpmfiFMode(fi);
@@ -592,7 +605,7 @@
 		/* XXX is this test still necessary? */
 		if (fi->actions[i] != FA_UNKNOWN)
 		    /*@switchbreak@*/ break;
-		if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
+		if ((FFlags & RPMFILE_CONFIG) && !lstat(t?t:fn, &sb)) {
 		    /* Here is a non-overlapped pre-existing config file. */
 		    fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
 			? FA_ALTNAME : FA_BACKUP;
@@ -617,7 +630,7 @@
 	    /* Try to get the disk accounting correct even if a conflict. */
 	    fixupSize = rpmfiFSize(otherFi);
 
-	    if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
+	    if ((FFlags & RPMFILE_CONFIG) && !lstat(t?t:fn, &sb)) {
 		/* Here is an overlapped  pre-existing config file. */
 		fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
 			? FA_ALTNAME : FA_SKIP;
@@ -663,6 +676,12 @@
 	/* Update disk space info for a file. */
 	rpmtsUpdateDSI(ts, fiFps->entry->dev,
                 rpmfiFSize(fi), fi->replacedSizes[i], fixupSize, fi->actions[i]);
+#ifdef HAVE_RUNTIME_PREFIX
+        if (t) {
+                free(t);
+        }
+        t = 0;
+#endif
 
     }
     ps = rpmpsFree(ps);
