|
Igor Gnatenko |
889695 |
From bcc54f828865ea5ba8b99acb2b6882f6e32190b0 Mon Sep 17 00:00:00 2001
|
|
Igor Gnatenko |
53960f |
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
Igor Gnatenko |
53960f |
Date: Fri, 28 Jul 2017 18:30:37 +0200
|
|
Igor Gnatenko |
53960f |
Subject: [PATCH] store mapping for renamed files
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
We will need this in next commit so we know which original name
|
|
Igor Gnatenko |
53960f |
files had, so we can reference appropriate debug file.
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
889695 |
Reviewed-by: Mark Wielaard <mark@klomp.org>
|
|
Igor Gnatenko |
53960f |
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
|
|
Igor Gnatenko |
889695 |
(cherry picked from commit cc8a682c386bf28540dc3fa5dbbb66c57bca5ec5)
|
|
Igor Gnatenko |
53960f |
---
|
|
Igor Gnatenko |
889695 |
build/files.c | 42 +++++++++++++++++++++++++++++++-----------
|
|
Igor Gnatenko |
53960f |
build/rpmbuild_internal.h | 12 ++++++++++++
|
|
Igor Gnatenko |
53960f |
build/spec.c | 2 ++
|
|
Igor Gnatenko |
889695 |
3 files changed, 45 insertions(+), 11 deletions(-)
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
diff --git a/build/files.c b/build/files.c
|
|
Igor Gnatenko |
889695 |
index 36e1ed5ea..42709a549 100644
|
|
Igor Gnatenko |
53960f |
--- a/build/files.c
|
|
Igor Gnatenko |
53960f |
+++ b/build/files.c
|
|
Igor Gnatenko |
53960f |
@@ -50,6 +50,17 @@
|
|
Igor Gnatenko |
53960f |
#define DEBUG_ID_DIR "/usr/lib/debug/.build-id"
|
|
Igor Gnatenko |
53960f |
#define DEBUG_DWZ_DIR "/usr/lib/debug/.dwz"
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
+#undef HASHTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTKEYTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTDATATYPE
|
|
Igor Gnatenko |
53960f |
+#define HASHTYPE fileRenameHash
|
|
Igor Gnatenko |
53960f |
+#define HTKEYTYPE const char *
|
|
Igor Gnatenko |
889695 |
+#define HTDATATYPE const char *
|
|
Igor Gnatenko |
53960f |
+#include "lib/rpmhash.C"
|
|
Igor Gnatenko |
53960f |
+#undef HASHTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTKEYTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTDATATYPE
|
|
Igor Gnatenko |
53960f |
+
|
|
Igor Gnatenko |
53960f |
/**
|
|
Igor Gnatenko |
53960f |
*/
|
|
Igor Gnatenko |
53960f |
enum specfFlags_e {
|
|
Igor Gnatenko |
889695 |
@@ -982,19 +993,28 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
|
|
Igor Gnatenko |
53960f |
}
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
/* Adjust paths if needed */
|
|
Igor Gnatenko |
53960f |
- if (!isSrc && pkg->removePostfixes)
|
|
Igor Gnatenko |
53960f |
- for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
|
|
Igor Gnatenko |
53960f |
- char * cpiopath = flp->cpioPath;
|
|
Igor Gnatenko |
53960f |
-
|
|
Igor Gnatenko |
53960f |
- for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) {
|
|
Igor Gnatenko |
53960f |
- int len = strlen(*postfix_p);
|
|
Igor Gnatenko |
53960f |
- int plen = strlen(cpiopath);
|
|
Igor Gnatenko |
53960f |
- if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) {
|
|
Igor Gnatenko |
53960f |
- cpiopath[plen-len] = '\0';
|
|
Igor Gnatenko |
53960f |
- if (plen-len > 0 && cpiopath[plen-len-1] == '/') {
|
|
Igor Gnatenko |
53960f |
- cpiopath[plen-len-1] = '\0';
|
|
Igor Gnatenko |
53960f |
+ if (!isSrc && pkg->removePostfixes) {
|
|
Igor Gnatenko |
53960f |
+ pkg->fileRenameMap = fileRenameHashCreate(fl->files.used,
|
|
Igor Gnatenko |
53960f |
+ rstrhash, strcmp,
|
|
Igor Gnatenko |
53960f |
+ (fileRenameHashFreeKey)rfree, (fileRenameHashFreeData)rfree);
|
|
Igor Gnatenko |
53960f |
+ for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
|
|
Igor Gnatenko |
53960f |
+ char * cpiopath = flp->cpioPath;
|
|
Igor Gnatenko |
53960f |
+ char * cpiopath_orig = xstrdup(cpiopath);
|
|
Igor Gnatenko |
53960f |
+
|
|
Igor Gnatenko |
53960f |
+ for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) {
|
|
Igor Gnatenko |
53960f |
+ int len = strlen(*postfix_p);
|
|
Igor Gnatenko |
53960f |
+ int plen = strlen(cpiopath);
|
|
Igor Gnatenko |
53960f |
+ if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) {
|
|
Igor Gnatenko |
53960f |
+ cpiopath[plen-len] = '\0';
|
|
Igor Gnatenko |
53960f |
+ if (plen-len > 0 && cpiopath[plen-len-1] == '/') {
|
|
Igor Gnatenko |
53960f |
+ cpiopath[plen-len-1] = '\0';
|
|
Igor Gnatenko |
53960f |
+ }
|
|
Igor Gnatenko |
53960f |
}
|
|
Igor Gnatenko |
53960f |
}
|
|
Igor Gnatenko |
53960f |
+ if (strcmp(cpiopath_orig, cpiopath))
|
|
Igor Gnatenko |
53960f |
+ fileRenameHashAddEntry(pkg->fileRenameMap, xstrdup(cpiopath), cpiopath_orig);
|
|
Igor Gnatenko |
889695 |
+ else
|
|
Igor Gnatenko |
889695 |
+ _free(cpiopath_orig);
|
|
Igor Gnatenko |
53960f |
}
|
|
Igor Gnatenko |
53960f |
}
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
|
|
Igor Gnatenko |
889695 |
index 5978a6d32..5dd0a5b83 100644
|
|
Igor Gnatenko |
53960f |
--- a/build/rpmbuild_internal.h
|
|
Igor Gnatenko |
53960f |
+++ b/build/rpmbuild_internal.h
|
|
Igor Gnatenko |
53960f |
@@ -6,6 +6,17 @@
|
|
Igor Gnatenko |
53960f |
#include <rpm/rpmstrpool.h>
|
|
Igor Gnatenko |
53960f |
#include "build/rpmbuild_misc.h"
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
+#undef HASHTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTKEYTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTDATATYPE
|
|
Igor Gnatenko |
53960f |
+#define HASHTYPE fileRenameHash
|
|
Igor Gnatenko |
53960f |
+#define HTKEYTYPE const char *
|
|
Igor Gnatenko |
889695 |
+#define HTDATATYPE const char *
|
|
Igor Gnatenko |
53960f |
+#include "lib/rpmhash.H"
|
|
Igor Gnatenko |
53960f |
+#undef HASHTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTKEYTYPE
|
|
Igor Gnatenko |
53960f |
+#undef HTDATATYPE
|
|
Igor Gnatenko |
53960f |
+
|
|
Igor Gnatenko |
53960f |
struct TriggerFileEntry {
|
|
Igor Gnatenko |
53960f |
int index;
|
|
Igor Gnatenko |
53960f |
char * fileName;
|
|
Igor Gnatenko |
53960f |
@@ -120,6 +131,7 @@ struct Package_s {
|
|
Igor Gnatenko |
53960f |
ARGV_t fileList; /* If NULL, package will not be written */
|
|
Igor Gnatenko |
53960f |
ARGV_t fileExcludeList;
|
|
Igor Gnatenko |
53960f |
ARGV_t removePostfixes;
|
|
Igor Gnatenko |
53960f |
+ fileRenameHash fileRenameMap;
|
|
Igor Gnatenko |
53960f |
ARGV_t policyList;
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
Package next;
|
|
Igor Gnatenko |
53960f |
diff --git a/build/spec.c b/build/spec.c
|
|
Igor Gnatenko |
53960f |
index c33cde7eb..eaa5dce61 100644
|
|
Igor Gnatenko |
53960f |
--- a/build/spec.c
|
|
Igor Gnatenko |
53960f |
+++ b/build/spec.c
|
|
Igor Gnatenko |
53960f |
@@ -104,6 +104,7 @@ Package newPackage(const char *name, rpmstrPool pool, Package *pkglist)
|
|
Igor Gnatenko |
53960f |
p->fileExcludeList = NULL;
|
|
Igor Gnatenko |
53960f |
p->fileFile = NULL;
|
|
Igor Gnatenko |
53960f |
p->policyList = NULL;
|
|
Igor Gnatenko |
53960f |
+ p->fileRenameMap = NULL;
|
|
Igor Gnatenko |
53960f |
p->pool = rpmstrPoolLink(pool);
|
|
Igor Gnatenko |
53960f |
p->dpaths = NULL;
|
|
Igor Gnatenko |
53960f |
|
|
Igor Gnatenko |
53960f |
@@ -148,6 +149,7 @@ static Package freePackage(Package pkg)
|
|
Igor Gnatenko |
53960f |
pkg->fileFile = argvFree(pkg->fileFile);
|
|
Igor Gnatenko |
53960f |
pkg->policyList = argvFree(pkg->policyList);
|
|
Igor Gnatenko |
53960f |
pkg->removePostfixes = argvFree(pkg->removePostfixes);
|
|
Igor Gnatenko |
53960f |
+ pkg->fileRenameMap = fileRenameHashFree(pkg->fileRenameMap);
|
|
Igor Gnatenko |
53960f |
pkg->cpioList = rpmfilesFree(pkg->cpioList);
|
|
Igor Gnatenko |
53960f |
pkg->dpaths = argvFree(pkg->dpaths);
|
|
Igor Gnatenko |
53960f |
|