summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--build/files.c56
-rw-r--r--lib/rpmlib.h3
-rw-r--r--lib/rpmrc.c1
4 files changed, 59 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index efd24b348..0ce249aef 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2.4.104 -> 2.4.105:
+ - added langpath: to rpmrc, and mark files with matches
+
2.4.103 -> 2.4.104:
- fixed popt/Makefile.in to use CPP from configure
- use tmppath from rpmrc to for ftp'd files (rather then /var/tmp)
diff --git a/build/files.c b/build/files.c
index a768db1c4..fb561a1e6 100644
--- a/build/files.c
+++ b/build/files.c
@@ -8,6 +8,8 @@
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
+#include <sys/types.h>
+#include <regex.h>
#include "spec.h"
#include "package.h"
@@ -94,6 +96,7 @@ static int parseForVerify(char *buf, struct FileList *fl);
static int parseForLang(char *buf, struct FileList *fl);
static int parseForAttr(char *buf, struct FileList *fl);
static int parseForConfig(char *buf, struct FileList *fl);
+static int parseForRegexLang(char *fileName, char **lang);
static int myGlobPatternP(char *pattern);
static int glob_error(const char *foo, int bar);
static void timeCheck(int tc, Header h);
@@ -719,6 +722,7 @@ static int addFile(struct FileList *fl, char *name, struct stat *statp)
int_16 fileMode;
int fileUid, fileGid;
char *fileUname, *fileGname;
+ char *lang;
strcpy(fileName, cleanFileName(name));
@@ -824,9 +828,14 @@ static int addFile(struct FileList *fl, char *name, struct stat *statp)
fl->fileList[fl->fileListRecsUsed].uname = fileUname;
fl->fileList[fl->fileListRecsUsed].gname = fileGname;
- fl->fileList[fl->fileListRecsUsed].lang =
- strdup(fl->currentLang ? fl->currentLang : "");
-
+ if (fl->currentLang) {
+ fl->fileList[fl->fileListRecsUsed].lang = strdup(fl->currentLang);
+ } else if (! parseForRegexLang(fileName, &lang)) {
+ fl->fileList[fl->fileListRecsUsed].lang = strdup(lang);
+ } else {
+ fl->fileList[fl->fileListRecsUsed].lang = strdup("");
+ }
+
fl->fileList[fl->fileListRecsUsed].flags = fl->currentFlags;
fl->fileList[fl->fileListRecsUsed].verifyFlags =
fl->currentVerifyFlags;
@@ -1021,6 +1030,47 @@ static int parseForVerify(char *buf, struct FileList *fl)
return 0;
}
+static int parseForRegexLang(char *fileName, char **lang)
+{
+ static int initialized = 0;
+ static int hasRegex = 0;
+ static regex_t compiledPatt;
+ static char buf[BUFSIZ];
+ int x;
+ regmatch_t matches[2];
+ char *patt, *s;
+
+ if (! initialized) {
+ initialized = 1;
+ patt = rpmGetVar(RPMVAR_LANGPATT);
+ if (! patt) {
+ return 1;
+ }
+ if (regcomp(&compiledPatt, patt, REG_EXTENDED)) {
+ return -1;
+ }
+ hasRegex = 1;
+ }
+
+ if (! hasRegex) {
+ return 1;
+ }
+
+ if (! regexec(&compiledPatt, fileName, 2, matches, REG_NOTEOL)) {
+ /* Got match */
+ s = fileName + matches[1].rm_eo - 1;
+ x = matches[1].rm_eo - matches[1].rm_so;
+ buf[x] = '\0';
+ while (x) {
+ buf[--x] = *s--;
+ }
+ *lang = buf;
+ return 0;
+ }
+
+ return 1;
+}
+
static int parseForLang(char *buf, struct FileList *fl)
{
char *p, *start, *end;
diff --git a/lib/rpmlib.h b/lib/rpmlib.h
index 67c7922a0..f92e9ce9d 100644
--- a/lib/rpmlib.h
+++ b/lib/rpmlib.h
@@ -221,8 +221,9 @@ extern const struct headerSprintfExtension rpmHeaderFormats[];
#define RPMVAR_BUILDSHELL 39
#define RPMVAR_INSTCHANGELOG 40
#define RPMVAR_BZIP2BIN 41
+#define RPMVAR_LANGPATT 42
-#define RPMVAR_NUM 42 /* number of RPMVAR entries */
+#define RPMVAR_NUM 43 /* number of RPMVAR entries */
char * rpmGetVar(int var);
int rpmGetBooleanVar(int var);
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index 8e4d64826..d79cbaf22 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -112,6 +112,7 @@ static struct rpmOption optionTable[] = {
{ "ftpproxy", RPMVAR_FTPPROXY, 0, 0 },
{ "gzipbin", RPMVAR_GZIPBIN, 0, 1 },
{ "instchangelog", RPMVAR_INSTCHANGELOG, 0, 0 },
+ { "langpatt", RPMVAR_LANGPATT, 0, 0 },
{ "messagelevel", RPMVAR_MESSAGELEVEL, 0, 0 },
{ "netsharedpath", RPMVAR_NETSHAREDPATH, 0, 0 },
{ "optflags", RPMVAR_OPTFLAGS, 1, 0 },