2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup rpmbuild
|
|
|
|
* \file build/files.c
|
2000-01-25 04:02:32 +08:00
|
|
|
* The post-build, pre-packaging file tree walk to assemble the package
|
|
|
|
* manifest.
|
|
|
|
*/
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1998-03-05 00:51:06 +08:00
|
|
|
|
1999-02-21 11:57:09 +08:00
|
|
|
#define MYALLPERMS 07777
|
1999-01-14 06:53:33 +08:00
|
|
|
|
1998-03-20 12:34:09 +08:00
|
|
|
#include <regex.h>
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <signal.h> /* getOutputFrom() */
|
1996-06-08 02:32:10 +08:00
|
|
|
|
2000-06-20 23:54:48 +08:00
|
|
|
#include <rpmio_internal.h>
|
1999-10-30 07:03:12 +08:00
|
|
|
#include <rpmbuild.h>
|
|
|
|
#include <rpmmacro.h>
|
|
|
|
|
1998-08-09 06:27:08 +08:00
|
|
|
#include "buildio.h"
|
1998-07-31 06:09:42 +08:00
|
|
|
|
1996-06-08 02:32:10 +08:00
|
|
|
#include "myftw.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
#include "md5.h"
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
|
|
|
|
#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
#define MAXDOCDIR 1024
|
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
typedef struct {
|
1998-11-25 08:42:36 +08:00
|
|
|
struct stat fl_st;
|
|
|
|
#define fl_dev fl_st.st_dev
|
|
|
|
#define fl_ino fl_st.st_ino
|
|
|
|
#define fl_mode fl_st.st_mode
|
|
|
|
#define fl_nlink fl_st.st_nlink /* unused */
|
|
|
|
#define fl_uid fl_st.st_uid
|
|
|
|
#define fl_gid fl_st.st_gid
|
|
|
|
#define fl_rdev fl_st.st_rdev
|
|
|
|
#define fl_size fl_st.st_size
|
|
|
|
#define fl_mtime fl_st.st_mtime
|
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
const char *diskURL; /* get file from here */
|
|
|
|
const char *fileURL; /* filename in cpio archive */
|
1999-10-05 03:40:03 +08:00
|
|
|
/*@observer@*/ const char *uname;
|
|
|
|
/*@observer@*/ const char *gname;
|
1998-11-26 03:31:10 +08:00
|
|
|
int flags;
|
|
|
|
int verifyFlags;
|
1999-05-18 02:44:14 +08:00
|
|
|
const char *langs; /* XXX locales separated with | */
|
1998-11-25 03:30:38 +08:00
|
|
|
} FileListRec;
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-11-26 03:31:10 +08:00
|
|
|
typedef struct {
|
|
|
|
const char *ar_fmodestr;
|
|
|
|
const char *ar_dmodestr;
|
|
|
|
const char *ar_user;
|
|
|
|
const char *ar_group;
|
|
|
|
mode_t ar_fmode;
|
|
|
|
mode_t ar_dmode;
|
|
|
|
} AttrRec;
|
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
static int multiLib = 0; /* MULTILIB */
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
struct FileList {
|
1999-11-24 08:03:54 +08:00
|
|
|
const char *buildRootURL;
|
1998-11-25 03:30:38 +08:00
|
|
|
const char *prefix;
|
1997-03-31 22:14:20 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
int fileCount;
|
|
|
|
int totalFileSize;
|
|
|
|
int processingFailed;
|
1997-04-15 04:04:18 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
int passedSpecialDoc;
|
|
|
|
int isSpecialDoc;
|
1997-04-15 04:04:18 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
int isDir;
|
|
|
|
int inFtw;
|
|
|
|
int currentFlags;
|
|
|
|
int currentVerifyFlags;
|
1998-11-26 03:31:10 +08:00
|
|
|
AttrRec cur_ar;
|
|
|
|
AttrRec def_ar;
|
1998-01-13 05:31:29 +08:00
|
|
|
int defVerifyFlags;
|
1999-05-18 00:27:38 +08:00
|
|
|
int nLangs;
|
1999-10-05 01:29:58 +08:00
|
|
|
/*@only@*/ const char **currentLangs;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
/* Hard coded limit of MAXDOCDIR docdirs. */
|
|
|
|
/* If you break it you are doing something wrong. */
|
1998-11-25 08:42:36 +08:00
|
|
|
const char *docDirs[MAXDOCDIR];
|
1998-01-13 05:31:29 +08:00
|
|
|
int docDirCount;
|
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
FileListRec *fileList;
|
1998-01-13 05:31:29 +08:00
|
|
|
int fileListRecsAlloced;
|
|
|
|
int fileListRecsUsed;
|
|
|
|
};
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
static void nullAttrRec(/*@out@*/AttrRec *ar)
|
|
|
|
{
|
|
|
|
ar->ar_fmodestr = NULL;
|
|
|
|
ar->ar_dmodestr = NULL;
|
|
|
|
ar->ar_user = NULL;
|
|
|
|
ar->ar_group = NULL;
|
|
|
|
ar->ar_fmode = 0;
|
|
|
|
ar->ar_dmode = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void freeAttrRec(AttrRec *ar)
|
|
|
|
{
|
1998-11-26 03:31:10 +08:00
|
|
|
FREE(ar->ar_fmodestr);
|
|
|
|
FREE(ar->ar_dmodestr);
|
|
|
|
FREE(ar->ar_user);
|
|
|
|
FREE(ar->ar_group);
|
|
|
|
/* XXX doesn't free ar (yet) */
|
|
|
|
}
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
static void dupAttrRec(AttrRec *oar, /*@out@*/ AttrRec *nar)
|
|
|
|
{
|
1999-01-28 03:40:01 +08:00
|
|
|
if (oar == nar) /* XXX pathological paranoia */
|
|
|
|
return;
|
|
|
|
freeAttrRec(nar);
|
1999-10-05 01:29:58 +08:00
|
|
|
nar->ar_fmodestr = (oar->ar_fmodestr ? xstrdup(oar->ar_fmodestr) : NULL);
|
|
|
|
nar->ar_dmodestr = (oar->ar_dmodestr ? xstrdup(oar->ar_dmodestr) : NULL);
|
|
|
|
nar->ar_user = (oar->ar_user ? xstrdup(oar->ar_user) : NULL);
|
|
|
|
nar->ar_group = (oar->ar_group ? xstrdup(oar->ar_group) : NULL);
|
|
|
|
nar->ar_fmode = oar->ar_fmode;
|
|
|
|
nar->ar_dmode = oar->ar_dmode;
|
1998-11-26 03:31:10 +08:00
|
|
|
}
|
|
|
|
|
1999-01-28 03:40:01 +08:00
|
|
|
#if 0
|
|
|
|
static void dumpAttrRec(const char *msg, AttrRec *ar) {
|
|
|
|
if (msg)
|
|
|
|
fprintf(stderr, "%s:\t", msg);
|
|
|
|
fprintf(stderr, "(%s, %s, %s, %s)\n",
|
|
|
|
ar->ar_fmodestr,
|
|
|
|
ar->ar_user,
|
|
|
|
ar->ar_group,
|
|
|
|
ar->ar_dmodestr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* strtokWithQuotes() modified from glibc strtok() */
|
|
|
|
/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU C Library.
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
License, or (at your option) any later version.
|
1998-04-30 23:20:58 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
1997-04-15 04:04:18 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
|
|
|
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static char *strtokWithQuotes(char *s, char *delim)
|
|
|
|
{
|
|
|
|
static char *olds = NULL;
|
|
|
|
char *token;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (s == NULL) {
|
|
|
|
s = olds;
|
|
|
|
}
|
1997-04-15 04:04:18 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Skip leading delimiters */
|
|
|
|
s += strspn(s, delim);
|
|
|
|
if (*s == '\0') {
|
|
|
|
return NULL;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Find the end of the token. */
|
|
|
|
token = s;
|
|
|
|
if (*token == '"') {
|
|
|
|
token++;
|
|
|
|
/* Find next " char */
|
|
|
|
s = strchr(token, '"');
|
|
|
|
} else {
|
|
|
|
s = strpbrk(token, delim);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1997-04-15 04:04:18 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Terminate it */
|
|
|
|
if (s == NULL) {
|
|
|
|
/* This token finishes the string */
|
|
|
|
olds = strchr(token, '\0');
|
|
|
|
} else {
|
|
|
|
/* Terminate the token and make olds point past it */
|
|
|
|
*s = '\0';
|
|
|
|
olds = s+1;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
return token;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static void timeCheck(int tc, Header h)
|
1998-01-13 05:31:29 +08:00
|
|
|
{
|
1998-07-26 05:00:26 +08:00
|
|
|
int *mtime;
|
1999-10-30 00:06:01 +08:00
|
|
|
char **files;
|
1998-07-26 05:00:26 +08:00
|
|
|
int count, x, currentTime;
|
|
|
|
|
1999-10-30 00:06:01 +08:00
|
|
|
headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &files, &count);
|
1998-07-26 05:00:26 +08:00
|
|
|
headerGetEntry(h, RPMTAG_FILEMTIMES, NULL, (void **) &mtime, NULL);
|
|
|
|
|
|
|
|
currentTime = time(NULL);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
for (x = 0; x < count; x++) {
|
1998-07-26 05:00:26 +08:00
|
|
|
if (currentTime - mtime[x] > tc) {
|
1999-10-30 00:06:01 +08:00
|
|
|
rpmMessage(RPMMESS_WARNING, _("TIMECHECK failure: %s\n"), files[x]);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-10-30 00:06:01 +08:00
|
|
|
FREE(files);
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-11-26 03:09:55 +08:00
|
|
|
typedef struct VFA {
|
|
|
|
char * attribute;
|
|
|
|
int flag;
|
|
|
|
} VFA_t;
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/** */
|
1998-11-26 03:09:55 +08:00
|
|
|
VFA_t verifyAttrs[] = {
|
|
|
|
{ "md5", RPMVERIFY_MD5 },
|
|
|
|
{ "size", RPMVERIFY_FILESIZE },
|
|
|
|
{ "link", RPMVERIFY_LINKTO },
|
|
|
|
{ "user", RPMVERIFY_USER },
|
|
|
|
{ "group", RPMVERIFY_GROUP },
|
|
|
|
{ "mtime", RPMVERIFY_MTIME },
|
|
|
|
{ "mode", RPMVERIFY_MODE },
|
|
|
|
{ "rdev", RPMVERIFY_RDEV },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static int parseForVerify(char *buf, struct FileList *fl)
|
|
|
|
{
|
1999-07-04 06:58:08 +08:00
|
|
|
char *p, *pe, *q;
|
|
|
|
const char *name;
|
1998-07-26 05:00:26 +08:00
|
|
|
int *resultVerify;
|
1999-07-04 06:58:08 +08:00
|
|
|
int not;
|
|
|
|
int verifyFlags;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if ((p = strstr(buf, (name = "%verify"))) != NULL) {
|
1998-07-26 05:00:26 +08:00
|
|
|
resultVerify = &(fl->currentVerifyFlags);
|
1999-07-04 06:58:08 +08:00
|
|
|
} else if ((p = strstr(buf, (name = "%defverify"))) != NULL) {
|
|
|
|
resultVerify = &(fl->defVerifyFlags);
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (pe = p; (pe-p) < strlen(name); pe++)
|
|
|
|
*pe = ' ';
|
1997-04-15 04:04:18 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
SKIPSPACE(pe);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if (*pe != '(') {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Missing '(' in %s %s"), name, pe);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
1997-04-15 04:04:18 +08:00
|
|
|
}
|
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Bracket %*verify args */
|
|
|
|
*pe++ = ' ';
|
|
|
|
for (p = pe; *pe && *pe != ')'; pe++)
|
|
|
|
;
|
1997-04-15 04:04:18 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if (*pe == '\0') {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Missing ')' in %s(%s"), name, p);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Localize. Erase parsed string */
|
|
|
|
q = alloca((pe-p) + 1);
|
|
|
|
strncpy(q, p, pe-p);
|
|
|
|
q[pe-p] = '\0';
|
|
|
|
while (p <= pe)
|
|
|
|
*p++ = ' ';
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
not = 0;
|
|
|
|
verifyFlags = RPMVERIFY_NONE;
|
1998-11-25 03:30:38 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
for (p = q; *p; p = pe) {
|
|
|
|
SKIPWHITE(p);
|
|
|
|
if (*p == '\0')
|
|
|
|
break;
|
|
|
|
pe = p;
|
|
|
|
SKIPNONWHITE(pe);
|
|
|
|
if (*pe)
|
|
|
|
*pe++ = '\0';
|
|
|
|
|
1998-11-26 03:09:55 +08:00
|
|
|
{ VFA_t *vfa;
|
|
|
|
for (vfa = verifyAttrs; vfa->attribute != NULL; vfa++) {
|
|
|
|
if (strcmp(p, vfa->attribute))
|
|
|
|
continue;
|
|
|
|
verifyFlags |= vfa->flag;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (vfa->attribute)
|
|
|
|
continue;
|
|
|
|
}
|
1999-07-04 06:58:08 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (!strcmp(p, "not")) {
|
1999-01-28 03:40:01 +08:00
|
|
|
not ^= 1;
|
1998-06-03 03:53:21 +08:00
|
|
|
} else {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Invalid %s token: %s"), name, p);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
*resultVerify = not ? ~(verifyFlags) : verifyFlags;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-11-26 04:23:32 +08:00
|
|
|
#define isAttrDefault(_ars) ((_ars)[0] == '-' && (_ars)[1] == '\0')
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static int parseForAttr(char *buf, struct FileList *fl)
|
|
|
|
{
|
1999-07-04 06:58:08 +08:00
|
|
|
char *p, *pe, *q;
|
|
|
|
const char *name;
|
|
|
|
int x;
|
1998-11-26 04:23:32 +08:00
|
|
|
AttrRec arbuf, *ar = &arbuf, *ret_ar;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if ((p = strstr(buf, (name = "%attr"))) != NULL) {
|
1998-11-26 04:23:32 +08:00
|
|
|
ret_ar = &(fl->cur_ar);
|
1999-07-04 06:58:08 +08:00
|
|
|
} else if ((p = strstr(buf, (name = "%defattr"))) != NULL) {
|
|
|
|
ret_ar = &(fl->def_ar);
|
|
|
|
} else
|
|
|
|
return 0;
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
for (pe = p; (pe-p) < strlen(name); pe++)
|
|
|
|
*pe = ' ';
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
SKIPSPACE(pe);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if (*pe != '(') {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Missing '(' in %s %s"), name, pe);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Bracket %*attr args */
|
|
|
|
*pe++ = ' ';
|
|
|
|
for (p = pe; *pe && *pe != ')'; pe++)
|
|
|
|
;
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if (ret_ar == &(fl->def_ar)) { /* %defattr */
|
|
|
|
q = pe;
|
|
|
|
q++;
|
|
|
|
SKIPSPACE(q);
|
|
|
|
if (*q) {
|
1998-07-26 05:00:26 +08:00
|
|
|
rpmError(RPMERR_BADSPEC,
|
1999-07-04 06:58:08 +08:00
|
|
|
_("Non-white space follows %s(): %s"), name, q);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
1997-03-31 22:14:20 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1997-03-31 22:14:20 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Localize. Erase parsed string */
|
|
|
|
q = alloca((pe-p) + 1);
|
|
|
|
strncpy(q, p, pe-p);
|
|
|
|
q[pe-p] = '\0';
|
|
|
|
while (p <= pe)
|
|
|
|
*p++ = ' ';
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
nullAttrRec(ar);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
p = q; SKIPWHITE(p);
|
|
|
|
if (*p) {
|
|
|
|
pe = p; SKIPNONWHITE(pe); if (*pe) *pe++ = '\0';
|
|
|
|
ar->ar_fmodestr = p;
|
|
|
|
p = pe; SKIPWHITE(p);
|
|
|
|
}
|
|
|
|
if (*p) {
|
|
|
|
pe = p; SKIPNONWHITE(pe); if (*pe) *pe++ = '\0';
|
|
|
|
ar->ar_user = p;
|
|
|
|
p = pe; SKIPWHITE(p);
|
|
|
|
}
|
|
|
|
if (*p) {
|
|
|
|
pe = p; SKIPNONWHITE(pe); if (*pe) *pe++ = '\0';
|
|
|
|
ar->ar_group = p;
|
|
|
|
p = pe; SKIPWHITE(p);
|
|
|
|
}
|
|
|
|
if (*p && ret_ar == &(fl->def_ar)) { /* %defattr */
|
|
|
|
pe = p; SKIPNONWHITE(pe); if (*pe) *pe++ = '\0';
|
|
|
|
ar->ar_dmodestr = p;
|
|
|
|
p = pe; SKIPWHITE(p);
|
|
|
|
}
|
1999-02-08 05:19:00 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if (!(ar->ar_fmodestr && ar->ar_user && ar->ar_group) || *p != '\0') {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad syntax: %s(%s)"), name, q);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do a quick test on the mode argument and adjust for "-" */
|
1998-11-26 04:23:32 +08:00
|
|
|
if (ar->ar_fmodestr && !isAttrDefault(ar->ar_fmodestr)) {
|
|
|
|
unsigned int ui;
|
|
|
|
x = sscanf(ar->ar_fmodestr, "%o", &ui);
|
1999-02-21 11:57:09 +08:00
|
|
|
if ((x == 0) || (ar->ar_fmode & ~MYALLPERMS)) {
|
1999-07-04 06:58:08 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad mode spec: %s(%s)"), name, q);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1998-11-26 04:23:32 +08:00
|
|
|
ar->ar_fmode = ui;
|
|
|
|
} else
|
|
|
|
ar->ar_fmodestr = NULL;
|
|
|
|
|
|
|
|
if (ar->ar_dmodestr && !isAttrDefault(ar->ar_dmodestr)) {
|
|
|
|
unsigned int ui;
|
|
|
|
x = sscanf(ar->ar_dmodestr, "%o", &ui);
|
1999-02-21 11:57:09 +08:00
|
|
|
if ((x == 0) || (ar->ar_dmode & ~MYALLPERMS)) {
|
1999-07-04 06:58:08 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad dirmode spec: %s(%s)"), name, q);
|
1998-11-26 04:23:32 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1998-11-26 04:23:32 +08:00
|
|
|
ar->ar_dmode = ui;
|
|
|
|
} else
|
|
|
|
ar->ar_dmodestr = NULL;
|
|
|
|
|
|
|
|
if (!(ar->ar_user && !isAttrDefault(ar->ar_user)))
|
1998-11-26 03:31:10 +08:00
|
|
|
ar->ar_user = NULL;
|
1998-11-26 04:23:32 +08:00
|
|
|
|
|
|
|
if (!(ar->ar_group && !isAttrDefault(ar->ar_group)))
|
1998-11-26 03:31:10 +08:00
|
|
|
ar->ar_group = NULL;
|
1998-11-26 04:23:32 +08:00
|
|
|
|
|
|
|
dupAttrRec(ar, ret_ar);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parseForConfig(char *buf, struct FileList *fl)
|
|
|
|
{
|
1999-07-04 06:58:08 +08:00
|
|
|
char *p, *pe, *q;
|
|
|
|
const char *name;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if ((p = strstr(buf, (name = "%config"))) == NULL)
|
1998-07-26 05:00:26 +08:00
|
|
|
return 0;
|
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
fl->currentFlags = RPMFILE_CONFIG;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
for (pe = p; (pe-p) < strlen(name); pe++)
|
|
|
|
*pe = ' ';
|
|
|
|
SKIPSPACE(pe);
|
|
|
|
if (*pe != '(')
|
1998-07-26 05:00:26 +08:00
|
|
|
return 0;
|
1998-03-04 01:07:39 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Bracket %config args */
|
|
|
|
*pe++ = ' ';
|
|
|
|
for (p = pe; *pe && *pe != ')'; pe++)
|
|
|
|
;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if (*pe == '\0') {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Missing ')' in %s(%s"), name, p);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Localize. Erase parsed string */
|
|
|
|
q = alloca((pe-p) + 1);
|
|
|
|
strncpy(q, p, pe-p);
|
|
|
|
q[pe-p] = '\0';
|
|
|
|
while (p <= pe)
|
|
|
|
*p++ = ' ';
|
|
|
|
|
|
|
|
for (p = q; *p; p = pe) {
|
|
|
|
SKIPWHITE(p);
|
|
|
|
if (*p == '\0')
|
|
|
|
break;
|
|
|
|
pe = p;
|
|
|
|
SKIPNONWHITE(pe);
|
|
|
|
if (*pe)
|
|
|
|
*pe++ = '\0';
|
1998-07-26 05:00:26 +08:00
|
|
|
if (!strcmp(p, "missingok")) {
|
|
|
|
fl->currentFlags |= RPMFILE_MISSINGOK;
|
|
|
|
} else if (!strcmp(p, "noreplace")) {
|
|
|
|
fl->currentFlags |= RPMFILE_NOREPLACE;
|
|
|
|
} else {
|
1999-07-04 06:58:08 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Invalid %s token: %s"), name, p);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parseForLang(char *buf, struct FileList *fl)
|
|
|
|
{
|
1999-07-04 06:58:08 +08:00
|
|
|
char *p, *pe, *q;
|
|
|
|
const char *name;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
while ((p = strstr(buf, (name = "%lang"))) != NULL) {
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
for (pe = p; (pe-p) < strlen(name); pe++)
|
|
|
|
*pe = ' ';
|
|
|
|
SKIPSPACE(pe);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
if (*pe != '(') {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Missing '(' in %s %s"), name, pe);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Bracket %lang args */
|
|
|
|
*pe++ = ' ';
|
1999-05-18 02:44:14 +08:00
|
|
|
for (pe = p; *pe && *pe != ')'; pe++)
|
|
|
|
;
|
1999-07-04 06:58:08 +08:00
|
|
|
|
1999-05-18 02:44:14 +08:00
|
|
|
if (*pe == '\0') {
|
1999-07-04 06:58:08 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Missing ')' in %s(%s"), name, p);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
/* Localize. Erase parsed string */
|
|
|
|
q = alloca((pe-p) + 1);
|
|
|
|
strncpy(q, p, pe-p);
|
|
|
|
q[pe-p] = '\0';
|
|
|
|
while (p <= pe)
|
|
|
|
*p++ = ' ';
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-05-18 02:44:14 +08:00
|
|
|
/* Parse multiple arguments from %lang */
|
1999-07-04 06:58:08 +08:00
|
|
|
for (p = q; *p; p = pe) {
|
1999-05-18 02:44:14 +08:00
|
|
|
char *newp;
|
|
|
|
size_t np;
|
|
|
|
int i;
|
|
|
|
|
1999-07-04 06:58:08 +08:00
|
|
|
SKIPWHITE(p);
|
|
|
|
pe = p;
|
|
|
|
SKIPNONWHITE(pe);
|
1999-05-18 00:27:38 +08:00
|
|
|
|
1999-05-18 02:44:14 +08:00
|
|
|
np = pe - p;
|
|
|
|
|
|
|
|
/* Sanity check on locale lengths */
|
1999-09-08 06:49:45 +08:00
|
|
|
if (np < 1 || (np == 1 && *p != 'C') || np >= 32) {
|
1999-05-18 03:32:15 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Unusual locale length: \"%.*s\" in %%lang(%s)"),
|
1999-09-08 06:49:45 +08:00
|
|
|
(int)np, p, q);
|
1999-05-18 02:44:14 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for duplicate locales */
|
|
|
|
for (i = 0; i < fl->nLangs; i++) {
|
|
|
|
if (strncmp(fl->currentLangs[i], p, np))
|
|
|
|
continue;
|
1999-05-18 03:32:15 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Duplicate locale %.*s in %%lang(%s)"),
|
1999-09-08 06:49:45 +08:00
|
|
|
(int)np, p, q);
|
1999-05-18 02:44:14 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new locale */
|
|
|
|
fl->currentLangs = (const char **) ((fl->currentLangs == NULL)
|
1999-09-21 11:22:53 +08:00
|
|
|
? xmalloc(sizeof(*fl->currentLangs))
|
|
|
|
: xrealloc(fl->currentLangs,((fl->nLangs+1)*sizeof(*fl->currentLangs))));
|
|
|
|
newp = xmalloc( np+1 );
|
1999-05-18 03:32:15 +08:00
|
|
|
strncpy(newp, p, np);
|
|
|
|
newp[np] = '\0';
|
1999-05-18 02:44:14 +08:00
|
|
|
fl->currentLangs[fl->nLangs++] = newp;
|
1999-05-18 03:32:15 +08:00
|
|
|
if (*pe == ',') pe++; /* skip , if present */
|
1999-05-18 02:44:14 +08:00
|
|
|
}
|
|
|
|
}
|
1996-07-23 10:41:54 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
static int parseForRegexLang(const char *fileName, /*@out@*/char **lang)
|
1998-07-26 05:00:26 +08:00
|
|
|
{
|
|
|
|
static int initialized = 0;
|
|
|
|
static int hasRegex = 0;
|
|
|
|
static regex_t compiledPatt;
|
|
|
|
static char buf[BUFSIZ];
|
|
|
|
int x;
|
|
|
|
regmatch_t matches[2];
|
1998-11-25 08:42:36 +08:00
|
|
|
const char *s;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (! initialized) {
|
1999-03-21 05:09:47 +08:00
|
|
|
const char *patt = rpmExpand("%{_langpatt}", NULL);
|
1999-10-30 00:06:01 +08:00
|
|
|
int rc = 0;
|
1999-03-21 05:09:47 +08:00
|
|
|
if (!(patt && *patt != '%'))
|
1999-10-30 00:06:01 +08:00
|
|
|
rc = 1;
|
|
|
|
else if (regcomp(&compiledPatt, patt, REG_EXTENDED))
|
|
|
|
rc = -1;
|
1999-03-21 05:09:47 +08:00
|
|
|
xfree(patt);
|
1999-10-30 00:06:01 +08:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
1998-07-26 05:00:26 +08:00
|
|
|
hasRegex = 1;
|
1999-03-21 05:09:47 +08:00
|
|
|
initialized = 1;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-11-25 08:42:36 +08:00
|
|
|
if (! hasRegex || regexec(&compiledPatt, fileName, 2, matches, REG_NOTEOL))
|
1998-07-26 05:00:26 +08:00
|
|
|
return 1;
|
|
|
|
|
1998-11-25 08:42:36 +08:00
|
|
|
/* 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--;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1998-11-25 08:42:36 +08:00
|
|
|
if (lang)
|
|
|
|
*lang = buf;
|
|
|
|
return 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
static int parseForRegexMultiLib(const char *fileName)
|
|
|
|
{
|
|
|
|
static int initialized = 0;
|
|
|
|
static int hasRegex = 0;
|
|
|
|
static regex_t compiledPatt;
|
|
|
|
|
|
|
|
if (! initialized) {
|
|
|
|
const char *patt;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
initialized = 1;
|
|
|
|
patt = rpmExpand("%{_multilibpatt}", NULL);
|
|
|
|
if (!(patt && *patt != '%'))
|
|
|
|
rc = 1;
|
|
|
|
else if (regcomp(&compiledPatt, patt, REG_EXTENDED | REG_NOSUB))
|
|
|
|
rc = -1;
|
|
|
|
xfree(patt);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
hasRegex = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! hasRegex || regexec(&compiledPatt, fileName, 0, NULL, 0))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/** */
|
1998-09-05 00:17:46 +08:00
|
|
|
VFA_t virtualFileAttributes[] = {
|
|
|
|
{ "%dir", 0 }, /* XXX why not RPMFILE_DIR? */
|
|
|
|
{ "%doc", RPMFILE_DOC },
|
|
|
|
{ "%ghost", RPMFILE_GHOST },
|
|
|
|
{ "%readme", RPMFILE_README },
|
|
|
|
{ "%license", RPMFILE_LICENSE },
|
2000-07-06 04:39:15 +08:00
|
|
|
{ "%multilib", 0 },
|
1998-09-05 00:17:46 +08:00
|
|
|
|
|
|
|
#if WHY_NOT
|
|
|
|
{ "%spec", RPMFILE_SPEC },
|
|
|
|
{ "%config", RPMFILE_CONFIG },
|
|
|
|
{ "%donotuse", RPMFILE_DONOTUSE }, /* XXX WTFO? */
|
|
|
|
{ "%missingok", RPMFILE_CONFIG|RPMFILE_MISSINGOK },
|
|
|
|
{ "%noreplace", RPMFILE_CONFIG|RPMFILE_NOREPLACE },
|
|
|
|
#endif
|
|
|
|
|
1998-10-08 19:55:37 +08:00
|
|
|
{ NULL, 0 }
|
1998-09-05 00:17:46 +08:00
|
|
|
};
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char *buf,
|
1998-11-25 08:42:36 +08:00
|
|
|
struct FileList *fl, const char **fileName)
|
1998-07-26 05:00:26 +08:00
|
|
|
{
|
1998-09-05 00:17:46 +08:00
|
|
|
char *s, *t;
|
1998-07-26 05:00:26 +08:00
|
|
|
int res, specialDoc = 0;
|
|
|
|
char specialDocBuf[BUFSIZ];
|
|
|
|
|
|
|
|
specialDocBuf[0] = '\0';
|
|
|
|
*fileName = NULL;
|
|
|
|
res = 0;
|
1998-09-05 00:17:46 +08:00
|
|
|
|
|
|
|
t = buf;
|
|
|
|
while ((s = strtokWithQuotes(t, " \t\n")) != NULL) {
|
|
|
|
t = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
if (!strcmp(s, "%docdir")) {
|
|
|
|
s = strtokWithQuotes(NULL, " \t\n");
|
|
|
|
if (fl->docDirCount == MAXDOCDIR) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_INTERNAL, _("Hit limit for %%docdir"));
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
res = 1;
|
|
|
|
}
|
1999-09-21 11:22:53 +08:00
|
|
|
fl->docDirs[fl->docDirCount++] = xstrdup(s);
|
1998-07-26 05:00:26 +08:00
|
|
|
if (strtokWithQuotes(NULL, " \t\n")) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_INTERNAL, _("Only one arg for %%docdir"));
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
res = 1;
|
|
|
|
}
|
|
|
|
break;
|
1998-09-05 00:17:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set flags for virtual file attributes */
|
|
|
|
{ VFA_t *vfa;
|
|
|
|
for (vfa = virtualFileAttributes; vfa->attribute != NULL; vfa++) {
|
|
|
|
if (strcmp(s, vfa->attribute))
|
|
|
|
continue;
|
2000-07-06 04:39:15 +08:00
|
|
|
if (!vfa->flag) {
|
|
|
|
if (!strcmp(s, "%dir"))
|
|
|
|
fl->isDir = 1; /* XXX why not RPMFILE_DIR? */
|
|
|
|
else if (!strcmp(s, "%multilib"))
|
|
|
|
fl->currentFlags |= multiLib;
|
|
|
|
} else
|
1998-09-05 00:17:46 +08:00
|
|
|
fl->currentFlags |= vfa->flag;
|
|
|
|
break;
|
|
|
|
}
|
1998-09-15 22:26:02 +08:00
|
|
|
/* if we got an attribute, continue with next token */
|
|
|
|
if (vfa->attribute != NULL)
|
1998-09-05 00:17:46 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*fileName) {
|
|
|
|
/* We already got a file -- error */
|
1998-11-25 08:42:36 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Two files on one line: %s"), *fileName);
|
1998-09-05 00:17:46 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
res = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*s != '/') {
|
|
|
|
if (fl->currentFlags & RPMFILE_DOC) {
|
|
|
|
specialDoc = 1;
|
|
|
|
strcat(specialDocBuf, " ");
|
|
|
|
strcat(specialDocBuf, s);
|
|
|
|
} else {
|
|
|
|
/* not in %doc, does not begin with / -- error */
|
1998-07-26 05:00:26 +08:00
|
|
|
rpmError(RPMERR_BADSPEC,
|
1998-09-28 06:03:52 +08:00
|
|
|
_("File must begin with \"/\": %s"), s);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
res = 1;
|
|
|
|
}
|
1998-09-05 00:17:46 +08:00
|
|
|
} else {
|
|
|
|
*fileName = s;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (specialDoc) {
|
|
|
|
if (*fileName || (fl->currentFlags & ~(RPMFILE_DOC))) {
|
|
|
|
rpmError(RPMERR_BADSPEC,
|
1998-09-28 06:03:52 +08:00
|
|
|
_("Can't mix special %%doc with other forms: %s"),
|
1998-07-26 05:00:26 +08:00
|
|
|
*fileName);
|
|
|
|
fl->processingFailed = 1;
|
|
|
|
res = 1;
|
|
|
|
} else {
|
1999-01-06 07:13:56 +08:00
|
|
|
/* XXX WATCHOUT: buf is an arg */
|
1999-09-07 04:59:39 +08:00
|
|
|
{ const char *ddir, *n, *v;
|
1999-01-14 04:24:00 +08:00
|
|
|
|
1999-09-07 04:59:39 +08:00
|
|
|
headerNVR(pkg->header, &n, &v, NULL);
|
1999-01-14 04:24:00 +08:00
|
|
|
|
1999-09-07 04:59:39 +08:00
|
|
|
ddir = rpmGetPath("%{_docdir}/", n, "-", v, NULL);
|
1999-01-14 04:24:00 +08:00
|
|
|
strcpy(buf, ddir);
|
|
|
|
xfree(ddir);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX FIXME: this is easy to do as macro expansion */
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
if (! fl->passedSpecialDoc) {
|
|
|
|
pkg->specialDoc = newStringBuf();
|
|
|
|
appendStringBuf(pkg->specialDoc, "DOCDIR=$RPM_BUILD_ROOT");
|
|
|
|
appendLineStringBuf(pkg->specialDoc, buf);
|
|
|
|
appendLineStringBuf(pkg->specialDoc, "export DOCDIR");
|
|
|
|
appendLineStringBuf(pkg->specialDoc, "rm -rf $DOCDIR");
|
|
|
|
appendLineStringBuf(pkg->specialDoc, MKDIR_P " $DOCDIR");
|
|
|
|
|
|
|
|
*fileName = buf;
|
|
|
|
fl->passedSpecialDoc = 1;
|
|
|
|
fl->isSpecialDoc = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
appendStringBuf(pkg->specialDoc, "cp -pr ");
|
|
|
|
appendStringBuf(pkg->specialDoc, specialDocBuf);
|
|
|
|
appendLineStringBuf(pkg->specialDoc, " $DOCDIR");
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
return res;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static int compareFileListRecs(const void *ap, const void *bp)
|
1996-06-08 02:32:10 +08:00
|
|
|
{
|
1999-11-24 08:03:54 +08:00
|
|
|
const char *a = ((FileListRec *)ap)->fileURL;
|
|
|
|
const char *b = ((FileListRec *)bp)->fileURL;
|
1998-07-26 05:00:26 +08:00
|
|
|
return strcmp(a, b);
|
|
|
|
}
|
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
static int isDoc(struct FileList *fl, const char *fileName)
|
1998-07-26 05:00:26 +08:00
|
|
|
{
|
|
|
|
int x = fl->docDirCount;
|
|
|
|
|
|
|
|
while (x--) {
|
|
|
|
if (strstr(fileName, fl->docDirs[x]) == fileName) {
|
|
|
|
return 1;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
return 0;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
2000-09-27 01:19:32 +08:00
|
|
|
/**
|
|
|
|
* @todo Should directories have %doc/%config attributes? (#14531)
|
|
|
|
*/
|
1998-01-13 05:31:29 +08:00
|
|
|
static void genCpioListAndHeader(struct FileList *fl,
|
|
|
|
struct cpioFileMapping **cpioList,
|
|
|
|
int *cpioCount, Header h, int isSrc)
|
|
|
|
{
|
1998-11-25 03:30:38 +08:00
|
|
|
int skipLen;
|
1998-01-13 05:31:29 +08:00
|
|
|
int count;
|
1998-11-25 03:30:38 +08:00
|
|
|
FileListRec *flp;
|
|
|
|
struct cpioFileMapping *clp;
|
1999-10-01 01:45:42 +08:00
|
|
|
char *s;
|
|
|
|
char buf[BUFSIZ];
|
2000-07-06 04:39:15 +08:00
|
|
|
uint_32 multiLibMask = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
/* Sort the big list */
|
|
|
|
qsort(fl->fileList, fl->fileListRecsUsed,
|
|
|
|
sizeof(*(fl->fileList)), compareFileListRecs);
|
|
|
|
|
|
|
|
/* Generate the cpio list and the header */
|
1998-11-25 03:30:38 +08:00
|
|
|
skipLen = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
if (! isSrc) {
|
1998-11-25 03:30:38 +08:00
|
|
|
skipLen = 1;
|
|
|
|
if (fl->prefix)
|
|
|
|
skipLen += strlen(fl->prefix);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-11-25 03:30:38 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
*cpioCount = 0;
|
1999-09-21 11:22:53 +08:00
|
|
|
clp = *cpioList = xmalloc(sizeof(**cpioList) * fl->fileListRecsUsed);
|
1998-11-25 03:30:38 +08:00
|
|
|
|
|
|
|
for (flp = fl->fileList, count = fl->fileListRecsUsed; count > 0; flp++, count--) {
|
1999-11-24 08:03:54 +08:00
|
|
|
if ((count > 1) && !strcmp(flp->fileURL, flp[1].fileURL)) {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("File listed twice: %s"), flp->fileURL);
|
1998-01-13 05:31:29 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
}
|
2000-07-06 04:39:15 +08:00
|
|
|
|
|
|
|
if (flp->flags & RPMFILE_MULTILIB_MASK)
|
|
|
|
multiLibMask |=
|
|
|
|
(1 << ((flp->flags & RPMFILE_MULTILIB_MASK))
|
|
|
|
>> RPMFILE_MULTILIB_SHIFT);
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
/* Make the cpio list */
|
1998-11-25 03:30:38 +08:00
|
|
|
if (! (flp->flags & RPMFILE_GHOST)) {
|
1999-11-24 08:03:54 +08:00
|
|
|
clp->fsPath = xstrdup(flp->diskURL);
|
2000-07-12 06:23:16 +08:00
|
|
|
/* XXX legacy requires './' payload prefix to be omitted from rpm packages. */
|
|
|
|
{ char * t = buf;
|
|
|
|
if (!isSrc && !rpmExpandNumeric("%{_noPayloadPrefix}")) {
|
|
|
|
t = stpcpy(t, "./");
|
|
|
|
rpmlibNeedsFeature(h, "PayloadFilesHavePrefix", "4.0-1");
|
|
|
|
}
|
2000-07-10 07:10:25 +08:00
|
|
|
t = stpcpy(t, (flp->fileURL + skipLen));
|
|
|
|
clp->archivePath = xstrdup(buf);
|
|
|
|
}
|
1998-11-25 08:42:36 +08:00
|
|
|
clp->finalMode = flp->fl_mode;
|
|
|
|
clp->finalUid = flp->fl_uid;
|
|
|
|
clp->finalGid = flp->fl_gid;
|
1998-11-25 03:30:38 +08:00
|
|
|
clp->mapFlags = CPIO_MAP_PATH | CPIO_MAP_MODE |
|
1998-01-13 05:31:29 +08:00
|
|
|
CPIO_MAP_UID | CPIO_MAP_GID;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
|
|
|
if (isSrc)
|
1998-11-25 03:30:38 +08:00
|
|
|
clp->mapFlags |= CPIO_FOLLOW_SYMLINKS;
|
2000-07-06 04:39:15 +08:00
|
|
|
if (flp->flags & RPMFILE_MULTILIB_MASK)
|
|
|
|
clp->mapFlags |= CPIO_MULTILIB;
|
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
clp++;
|
1998-01-13 05:31:29 +08:00
|
|
|
(*cpioCount)++;
|
|
|
|
}
|
|
|
|
|
1999-10-06 23:51:38 +08:00
|
|
|
/* Make the header, the OLDFILENAMES will get converted to a
|
|
|
|
compressed file list write before we write the actual package to
|
|
|
|
disk. */
|
|
|
|
headerAddOrAppendEntry(h, RPMTAG_OLDFILENAMES, RPM_STRING_ARRAY_TYPE,
|
1999-11-24 08:03:54 +08:00
|
|
|
&(flp->fileURL), 1);
|
1999-06-02 22:45:46 +08:00
|
|
|
|
|
|
|
if (sizeof(flp->fl_size) != sizeof(uint_32)) {
|
|
|
|
uint_32 psize = (uint_32)flp->fl_size;
|
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILESIZES, RPM_INT32_TYPE,
|
|
|
|
&(psize), 1);
|
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILESIZES, RPM_INT32_TYPE,
|
1998-11-25 08:42:36 +08:00
|
|
|
&(flp->fl_size), 1);
|
1999-06-02 22:45:46 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEUSERNAME, RPM_STRING_ARRAY_TYPE,
|
1998-11-25 03:30:38 +08:00
|
|
|
&(flp->uname), 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEGROUPNAME, RPM_STRING_ARRAY_TYPE,
|
1998-11-25 03:30:38 +08:00
|
|
|
&(flp->gname), 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEMTIMES, RPM_INT32_TYPE,
|
1998-11-25 08:42:36 +08:00
|
|
|
&(flp->fl_mtime), 1);
|
1999-01-28 03:40:01 +08:00
|
|
|
if (sizeof(flp->fl_mode) != sizeof(uint_16)) {
|
1998-11-25 08:42:36 +08:00
|
|
|
uint_16 pmode = (uint_16)flp->fl_mode;
|
1998-03-01 04:29:11 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEMODES, RPM_INT16_TYPE,
|
|
|
|
&(pmode), 1);
|
1999-01-28 03:40:01 +08:00
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEMODES, RPM_INT16_TYPE,
|
1998-11-25 08:42:36 +08:00
|
|
|
&(flp->fl_mode), 1);
|
1999-01-28 03:40:01 +08:00
|
|
|
}
|
|
|
|
if (sizeof(flp->fl_rdev) != sizeof(uint_16)) {
|
1998-11-25 08:42:36 +08:00
|
|
|
uint_16 prdev = (uint_16)flp->fl_rdev;
|
1998-03-01 04:29:11 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILERDEVS, RPM_INT16_TYPE,
|
|
|
|
&(prdev), 1);
|
1999-01-28 03:40:01 +08:00
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILERDEVS, RPM_INT16_TYPE,
|
1998-11-25 08:42:36 +08:00
|
|
|
&(flp->fl_rdev), 1);
|
1999-01-28 03:40:01 +08:00
|
|
|
}
|
|
|
|
if (sizeof(flp->fl_dev) != sizeof(uint_32)) {
|
1998-11-25 08:42:36 +08:00
|
|
|
uint_32 pdevice = (uint_32)flp->fl_dev;
|
1998-03-01 04:29:11 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEDEVICES, RPM_INT32_TYPE,
|
|
|
|
&(pdevice), 1);
|
1999-01-28 03:40:01 +08:00
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEDEVICES, RPM_INT32_TYPE,
|
1998-11-25 08:42:36 +08:00
|
|
|
&(flp->fl_dev), 1);
|
1999-01-28 03:40:01 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEINODES, RPM_INT32_TYPE,
|
1998-11-25 08:42:36 +08:00
|
|
|
&(flp->fl_ino), 1);
|
1999-05-18 00:40:11 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILELANGS, RPM_STRING_ARRAY_TYPE,
|
1999-05-18 02:44:14 +08:00
|
|
|
&(flp->langs), 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
/* We used to add these, but they should not be needed */
|
|
|
|
/* headerAddOrAppendEntry(h, RPMTAG_FILEUIDS,
|
1998-11-25 08:42:36 +08:00
|
|
|
* RPM_INT32_TYPE, &(flp->fl_uid), 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
* headerAddOrAppendEntry(h, RPMTAG_FILEGIDS,
|
1998-11-25 08:42:36 +08:00
|
|
|
* RPM_INT32_TYPE, &(flp->fl_gid), 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
buf[0] = '\0';
|
1998-11-25 08:42:36 +08:00
|
|
|
if (S_ISREG(flp->fl_mode))
|
1999-11-24 08:03:54 +08:00
|
|
|
mdfile(flp->diskURL, buf);
|
1998-01-13 05:31:29 +08:00
|
|
|
s = buf;
|
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEMD5S, RPM_STRING_ARRAY_TYPE,
|
|
|
|
&s, 1);
|
|
|
|
|
|
|
|
buf[0] = '\0';
|
1999-12-03 01:07:29 +08:00
|
|
|
if (S_ISLNK(flp->fl_mode)) {
|
|
|
|
buf[Readlink(flp->diskURL, buf, BUFSIZ)] = '\0';
|
|
|
|
if (fl->buildRootURL) {
|
|
|
|
const char * buildRoot;
|
|
|
|
(void) urlPath(fl->buildRootURL, &buildRoot);
|
|
|
|
|
|
|
|
if (buf[0] == '/' && strcmp(buildRoot, "/") &&
|
|
|
|
!strncmp(buf, buildRoot, strlen(buildRoot))) {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Symlink points to BuildRoot: %s -> %s"),
|
|
|
|
flp->fileURL, buf);
|
|
|
|
fl->processingFailed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
s = buf;
|
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILELINKTOS, RPM_STRING_ARRAY_TYPE,
|
|
|
|
&s, 1);
|
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
if (flp->flags & RPMFILE_GHOST) {
|
|
|
|
flp->verifyFlags &= ~(RPMVERIFY_MD5 | RPMVERIFY_FILESIZE |
|
1998-01-13 05:31:29 +08:00
|
|
|
RPMVERIFY_LINKTO | RPMVERIFY_MTIME);
|
|
|
|
}
|
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEVERIFYFLAGS, RPM_INT32_TYPE,
|
1998-11-25 03:30:38 +08:00
|
|
|
&(flp->verifyFlags), 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
if (!isSrc && isDoc(fl, flp->fileURL))
|
1998-11-25 03:30:38 +08:00
|
|
|
flp->flags |= RPMFILE_DOC;
|
2000-09-27 01:19:32 +08:00
|
|
|
/* XXX Should directories have %doc/%config attributes? (#14531) */
|
1998-11-25 08:42:36 +08:00
|
|
|
if (S_ISDIR(flp->fl_mode))
|
1998-11-25 03:30:38 +08:00
|
|
|
flp->flags &= ~(RPMFILE_CONFIG|RPMFILE_DOC);
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
headerAddOrAppendEntry(h, RPMTAG_FILEFLAGS, RPM_INT32_TYPE,
|
1998-11-25 03:30:38 +08:00
|
|
|
&(flp->flags), 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE,
|
|
|
|
&(fl->totalFileSize), 1);
|
2000-07-06 04:39:15 +08:00
|
|
|
/* XXX This should be added always so that packages look alike.
|
|
|
|
* XXX However, there is logic in files.c/depends.c that checks for
|
|
|
|
* XXX existence (rather than value) that will need to change as well.
|
|
|
|
*/
|
|
|
|
if (multiLibMask)
|
|
|
|
headerAddEntry(h, RPMTAG_MULTILIBS, RPM_INT32_TYPE,
|
|
|
|
&multiLibMask, 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
static void freeFileList(FileListRec *fileList, int count)
|
1996-06-08 02:32:10 +08:00
|
|
|
{
|
1998-01-13 05:31:29 +08:00
|
|
|
while (count--) {
|
1999-11-24 08:03:54 +08:00
|
|
|
FREE(fileList[count].diskURL);
|
|
|
|
FREE(fileList[count].fileURL);
|
1999-05-18 00:27:38 +08:00
|
|
|
FREE(fileList[count].langs);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
FREE(fileList);
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
static int addFile(struct FileList *fl, const char * diskURL, struct stat *statp)
|
1996-06-08 02:32:10 +08:00
|
|
|
{
|
1999-11-24 08:03:54 +08:00
|
|
|
const char *fileURL = diskURL;
|
1998-01-13 05:31:29 +08:00
|
|
|
struct stat statbuf;
|
1998-11-25 08:42:36 +08:00
|
|
|
mode_t fileMode;
|
|
|
|
uid_t fileUid;
|
|
|
|
gid_t fileGid;
|
1999-10-05 03:40:03 +08:00
|
|
|
const char *fileUname;
|
|
|
|
const char *fileGname;
|
1998-03-20 12:34:09 +08:00
|
|
|
char *lang;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
/* Path may have prepended buildRootURL, so locate the original filename. */
|
|
|
|
/*
|
|
|
|
* XXX There are 3 types of entry into addFile:
|
|
|
|
*
|
|
|
|
* From diskUrl statp
|
|
|
|
* =====================================================
|
|
|
|
* processBinaryFile path NULL
|
|
|
|
* processBinaryFile glob result path NULL
|
|
|
|
* myftw path stat
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
{ const char *fileName;
|
1999-11-27 05:58:42 +08:00
|
|
|
(void) urlPath(fileURL, &fileName);
|
1999-11-24 08:03:54 +08:00
|
|
|
if (fl->buildRootURL && strcmp(fl->buildRootURL, "/"))
|
|
|
|
fileURL += strlen(fl->buildRootURL);
|
|
|
|
}
|
1996-07-09 10:06:26 +08:00
|
|
|
|
2000-07-10 07:10:25 +08:00
|
|
|
/* XXX make sure '/' can be packaged also */
|
|
|
|
if (*fileURL == '\0')
|
|
|
|
fileURL = "/";
|
|
|
|
|
1996-07-09 10:06:26 +08:00
|
|
|
/* If we are using a prefix, validate the file */
|
1998-01-13 05:31:29 +08:00
|
|
|
if (!fl->inFtw && fl->prefix) {
|
1999-11-24 08:03:54 +08:00
|
|
|
const char *prefixTest;
|
1998-11-25 03:30:38 +08:00
|
|
|
const char *prefixPtr = fl->prefix;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
(void) urlPath(fileURL, &prefixTest);
|
1996-07-10 09:38:14 +08:00
|
|
|
while (*prefixPtr && *prefixTest && (*prefixTest == *prefixPtr)) {
|
1996-07-09 10:06:26 +08:00
|
|
|
prefixPtr++;
|
|
|
|
prefixTest++;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
if (*prefixPtr || (*prefixTest && *prefixTest != '/')) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("File doesn't match prefix (%s): %s"),
|
1999-11-24 08:03:54 +08:00
|
|
|
fl->prefix, fileURL);
|
1998-01-13 05:31:29 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
1996-07-09 10:06:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
if (statp == NULL) {
|
1998-01-13 05:31:29 +08:00
|
|
|
statp = &statbuf;
|
1999-11-24 08:03:54 +08:00
|
|
|
if (Lstat(diskURL, statp)) {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("File not found: %s"), diskURL);
|
1998-01-13 05:31:29 +08:00
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1996-07-23 10:41:54 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if ((! fl->isDir) && S_ISDIR(statp->st_mode)) {
|
1996-06-08 02:32:10 +08:00
|
|
|
/* We use our own ftw() call, because ftw() uses stat() */
|
|
|
|
/* instead of lstat(), which causes it to follow symlinks! */
|
1998-01-13 05:31:29 +08:00
|
|
|
/* It also has better callback support. */
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
fl->inFtw = 1; /* Flag to indicate file has buildRootURL prefixed */
|
1998-01-13 05:31:29 +08:00
|
|
|
fl->isDir = 1; /* Keep it from following myftw() again */
|
1999-11-24 08:03:54 +08:00
|
|
|
myftw(diskURL, 16, (myftwFunc) addFile, fl);
|
1998-01-13 05:31:29 +08:00
|
|
|
fl->isDir = 0;
|
|
|
|
fl->inFtw = 0;
|
1998-11-25 03:30:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fileMode = statp->st_mode;
|
|
|
|
fileUid = statp->st_uid;
|
|
|
|
fileGid = statp->st_gid;
|
|
|
|
|
1999-02-08 05:19:00 +08:00
|
|
|
if (S_ISDIR(fileMode) && fl->cur_ar.ar_dmodestr) {
|
|
|
|
fileMode &= S_IFMT;
|
|
|
|
fileMode |= fl->cur_ar.ar_dmode;
|
|
|
|
} else if (fl->cur_ar.ar_fmodestr != NULL) {
|
|
|
|
fileMode &= S_IFMT;
|
|
|
|
fileMode |= fl->cur_ar.ar_fmode;
|
1998-11-25 03:30:38 +08:00
|
|
|
}
|
1998-11-26 03:31:10 +08:00
|
|
|
if (fl->cur_ar.ar_user) {
|
|
|
|
fileUname = getUnameS(fl->cur_ar.ar_user);
|
1998-11-25 03:30:38 +08:00
|
|
|
} else {
|
|
|
|
fileUname = getUname(fileUid);
|
|
|
|
}
|
1998-11-26 03:31:10 +08:00
|
|
|
if (fl->cur_ar.ar_group) {
|
|
|
|
fileGname = getGnameS(fl->cur_ar.ar_group);
|
1998-11-25 03:30:38 +08:00
|
|
|
} else {
|
|
|
|
fileGname = getGname(fileGid);
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-01-28 03:40:01 +08:00
|
|
|
#if 0 /* XXX this looks dumb to me */
|
1998-11-25 03:30:38 +08:00
|
|
|
if (! (fileUname && fileGname)) {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad owner/group: %s\n"), diskName);
|
|
|
|
fl->processingFailed = 1;
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1999-03-24 20:38:08 +08:00
|
|
|
#else
|
|
|
|
/* Default user/group to builder's user/group */
|
2000-07-10 07:10:25 +08:00
|
|
|
if (fileUname == NULL)
|
1999-03-24 20:38:08 +08:00
|
|
|
fileUname = getUname(getuid());
|
2000-07-10 07:10:25 +08:00
|
|
|
if (fileGname == NULL)
|
1999-03-24 20:38:08 +08:00
|
|
|
fileGname = getGname(getgid());
|
1999-01-28 03:40:01 +08:00
|
|
|
#endif
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("File %4d: %07o %s.%s\t %s\n"), fl->fileCount,
|
1999-11-24 08:03:54 +08:00
|
|
|
fileMode, fileUname, fileGname, fileURL);
|
1998-11-25 03:30:38 +08:00
|
|
|
|
|
|
|
/* Add to the file list */
|
|
|
|
if (fl->fileListRecsUsed == fl->fileListRecsAlloced) {
|
|
|
|
fl->fileListRecsAlloced += 128;
|
1999-09-21 11:22:53 +08:00
|
|
|
fl->fileList = xrealloc(fl->fileList,
|
1998-11-25 03:30:38 +08:00
|
|
|
fl->fileListRecsAlloced * sizeof(*(fl->fileList)));
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-01-28 03:40:01 +08:00
|
|
|
{ FileListRec * flp = &fl->fileList[fl->fileListRecsUsed];
|
|
|
|
|
|
|
|
flp->fl_st = *statp; /* structure assignment */
|
|
|
|
flp->fl_mode = fileMode;
|
|
|
|
flp->fl_uid = fileUid;
|
|
|
|
flp->fl_gid = fileGid;
|
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
flp->fileURL = xstrdup(fileURL);
|
|
|
|
flp->diskURL = xstrdup(diskURL);
|
1999-01-28 03:40:01 +08:00
|
|
|
flp->uname = fileUname;
|
|
|
|
flp->gname = fileGname;
|
|
|
|
|
1999-05-18 00:27:38 +08:00
|
|
|
if (fl->currentLangs && fl->nLangs > 0) {
|
1999-05-18 02:44:14 +08:00
|
|
|
char *ncl;
|
|
|
|
size_t nl = 0;
|
1999-05-18 00:27:38 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fl->nLangs; i++)
|
1999-05-18 02:44:14 +08:00
|
|
|
nl += strlen(fl->currentLangs[i]) + 1;
|
|
|
|
|
1999-09-21 11:22:53 +08:00
|
|
|
flp->langs = ncl = xmalloc(nl);
|
1999-05-18 02:44:14 +08:00
|
|
|
for (i = 0; i < fl->nLangs; i++) {
|
|
|
|
const char *ocl;
|
|
|
|
if (i) *ncl++ = '|';
|
|
|
|
for (ocl = fl->currentLangs[i]; *ocl; ocl++)
|
|
|
|
*ncl++ = *ocl;
|
|
|
|
*ncl = '\0';
|
|
|
|
}
|
1999-11-24 08:03:54 +08:00
|
|
|
} else if (! parseForRegexLang(fileURL, &lang)) {
|
1999-09-21 11:22:53 +08:00
|
|
|
flp->langs = xstrdup(lang);
|
1999-01-28 03:40:01 +08:00
|
|
|
} else {
|
1999-09-21 11:22:53 +08:00
|
|
|
flp->langs = xstrdup("");
|
1999-01-28 03:40:01 +08:00
|
|
|
}
|
1998-03-20 12:34:09 +08:00
|
|
|
|
1999-01-28 03:40:01 +08:00
|
|
|
flp->flags = fl->currentFlags;
|
|
|
|
flp->verifyFlags = fl->currentVerifyFlags;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
if (multiLib
|
|
|
|
&& !(flp->flags & RPMFILE_MULTILIB_MASK)
|
|
|
|
&& !parseForRegexMultiLib(fileURL))
|
|
|
|
flp->flags |= multiLib;
|
|
|
|
|
1999-01-28 03:40:01 +08:00
|
|
|
fl->totalFileSize += flp->fl_size;
|
|
|
|
}
|
1998-11-25 03:30:38 +08:00
|
|
|
|
|
|
|
fl->fileListRecsUsed++;
|
|
|
|
fl->fileCount++;
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
static int processBinaryFile(/*@unused@*/Package pkg, struct FileList *fl,
|
1999-11-24 08:03:54 +08:00
|
|
|
const char *fileURL)
|
1996-06-08 02:32:10 +08:00
|
|
|
{
|
1999-11-24 08:03:54 +08:00
|
|
|
int doGlob;
|
|
|
|
const char *diskURL = NULL;
|
1999-10-05 01:29:58 +08:00
|
|
|
int rc = 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
doGlob = myGlobPatternP(fileURL);
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
/* Check that file starts with leading "/" */
|
1999-11-24 08:03:54 +08:00
|
|
|
{ const char * fileName;
|
|
|
|
(void) urlPath(fileURL, &fileName);
|
|
|
|
if (*fileName != '/') {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("File needs leading \"/\": %s"), fileName);
|
|
|
|
rc = 1;
|
|
|
|
goto exit;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
/* Copy file name or glob pattern removing multiple "/" chars. */
|
1999-11-24 08:03:54 +08:00
|
|
|
/*
|
|
|
|
* Note: rpmGetPath should guarantee a "canonical" path. That means
|
|
|
|
* that the following pathologies should be weeded out:
|
|
|
|
* //bin//sh
|
|
|
|
* //usr//bin/
|
1999-11-25 00:16:17 +08:00
|
|
|
* /.././../usr/../bin//./sh
|
1999-11-24 08:03:54 +08:00
|
|
|
*/
|
|
|
|
diskURL = rpmGenPath(fl->buildRootURL, NULL, fileURL);
|
1999-10-05 01:29:58 +08:00
|
|
|
|
|
|
|
if (doGlob) {
|
1999-12-13 05:14:05 +08:00
|
|
|
const char ** argv = NULL;
|
|
|
|
int argc = 0;
|
1999-12-12 09:46:13 +08:00
|
|
|
int i;
|
1999-11-24 08:03:54 +08:00
|
|
|
|
1999-12-13 01:46:22 +08:00
|
|
|
rc = rpmGlob(diskURL, &argc, &argv);
|
2000-01-06 03:46:45 +08:00
|
|
|
if (rc == 0 && argc >= 1 && !myGlobPatternP(argv[0])) {
|
1999-12-12 09:46:13 +08:00
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
rc = addFile(fl, argv[i], NULL);
|
|
|
|
xfree(argv[i]);
|
|
|
|
}
|
|
|
|
xfree(argv);
|
2000-01-06 03:46:45 +08:00
|
|
|
} else {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("File not found by glob: %s"), diskURL);
|
|
|
|
rc = 1;
|
1999-12-12 09:46:13 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
} else {
|
1999-11-24 08:03:54 +08:00
|
|
|
rc = addFile(fl, diskURL, NULL);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
exit:
|
1999-11-24 08:03:54 +08:00
|
|
|
if (diskURL)
|
|
|
|
xfree(diskURL);
|
1999-10-05 01:29:58 +08:00
|
|
|
if (rc)
|
|
|
|
fl->processingFailed = 1;
|
1998-07-26 05:00:26 +08:00
|
|
|
return rc;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static int processPackageFiles(Spec spec, Package pkg,
|
|
|
|
int installSpecialDoc, int test)
|
1998-03-20 12:34:09 +08:00
|
|
|
{
|
1998-07-26 05:00:26 +08:00
|
|
|
struct FileList fl;
|
1998-11-25 08:42:36 +08:00
|
|
|
char *s, **files, **fp;
|
|
|
|
const char *fileName;
|
1998-07-26 05:00:26 +08:00
|
|
|
char buf[BUFSIZ];
|
1999-10-05 01:29:58 +08:00
|
|
|
AttrRec specialDocAttrRec;
|
1998-07-26 05:00:26 +08:00
|
|
|
char *specialDoc = NULL;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
|
|
|
#ifdef MULTILIB
|
|
|
|
multiLib = rpmExpandNumeric("%{_multilibno}");
|
|
|
|
if (multiLib)
|
|
|
|
multiLib = RPMFILE_MULTILIB(multiLib);
|
|
|
|
#endif /* MULTILIB */
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
nullAttrRec(&specialDocAttrRec);
|
1998-07-26 05:00:26 +08:00
|
|
|
pkg->cpioList = NULL;
|
|
|
|
pkg->cpioCount = 0;
|
|
|
|
|
|
|
|
if (pkg->fileFile) {
|
1999-01-28 03:40:01 +08:00
|
|
|
const char *ffn;
|
1999-11-13 01:20:49 +08:00
|
|
|
FD_t fd;
|
1999-01-28 03:40:01 +08:00
|
|
|
|
2000-02-22 11:09:53 +08:00
|
|
|
/* XXX W2DO? urlPath might be useful here. */
|
|
|
|
if (*pkg->fileFile == '/') {
|
|
|
|
ffn = rpmGetPath(pkg->fileFile, NULL);
|
|
|
|
} else {
|
|
|
|
/* XXX FIXME: add %{_buildsubdir} */
|
|
|
|
ffn = rpmGetPath("%{_builddir}/",
|
|
|
|
(spec->buildSubdir ? spec->buildSubdir : "") ,
|
|
|
|
"/", pkg->fileFile, NULL);
|
|
|
|
}
|
1999-11-15 03:15:18 +08:00
|
|
|
fd = Fopen(ffn, "r.fpio");
|
1998-09-06 04:02:08 +08:00
|
|
|
|
1999-11-13 01:20:49 +08:00
|
|
|
if (fd == NULL || Ferror(fd)) {
|
1998-07-26 05:00:26 +08:00
|
|
|
rpmError(RPMERR_BADFILENAME,
|
1999-11-13 01:20:49 +08:00
|
|
|
_("Could not open %%files file %s: %s"),
|
2000-02-12 07:16:47 +08:00
|
|
|
ffn, Fstrerror(fd));
|
1998-07-26 05:00:26 +08:00
|
|
|
return RPMERR_BADFILENAME;
|
1998-03-20 12:34:09 +08:00
|
|
|
}
|
2000-08-10 00:49:10 +08:00
|
|
|
xfree(ffn);
|
|
|
|
|
1999-12-02 03:57:17 +08:00
|
|
|
while (fgets(buf, sizeof(buf), (FILE *)fdGetFp(fd))) {
|
1998-07-26 05:00:26 +08:00
|
|
|
handleComments(buf);
|
1998-08-01 04:11:49 +08:00
|
|
|
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line: %s"), buf);
|
1998-07-26 05:00:26 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
appendStringBuf(pkg->fileList, buf);
|
|
|
|
}
|
1999-11-13 01:20:49 +08:00
|
|
|
Fclose(fd);
|
1998-03-20 12:34:09 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Init the file list structure */
|
2000-07-06 04:39:15 +08:00
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
/* XXX spec->buildRootURL == NULL, then xstrdup("") is returned */
|
|
|
|
fl.buildRootURL = rpmGenPath(spec->rootURL, spec->buildRootURL, NULL);
|
1999-01-28 03:40:01 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (headerGetEntry(pkg->header, RPMTAG_DEFAULTPREFIX,
|
1999-04-14 20:35:08 +08:00
|
|
|
NULL, (void **)&fl.prefix, NULL)) {
|
1999-09-21 11:22:53 +08:00
|
|
|
fl.prefix = xstrdup(fl.prefix);
|
1998-07-26 05:00:26 +08:00
|
|
|
} else {
|
|
|
|
fl.prefix = NULL;
|
1998-03-20 12:34:09 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.fileCount = 0;
|
|
|
|
fl.totalFileSize = 0;
|
|
|
|
fl.processingFailed = 0;
|
1998-03-20 12:34:09 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.passedSpecialDoc = 0;
|
1999-10-05 01:29:58 +08:00
|
|
|
fl.isSpecialDoc = 0;
|
|
|
|
|
|
|
|
fl.isDir = 0;
|
|
|
|
fl.inFtw = 0;
|
|
|
|
fl.currentFlags = 0;
|
|
|
|
fl.currentVerifyFlags = 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
nullAttrRec(&fl.cur_ar);
|
|
|
|
nullAttrRec(&fl.def_ar);
|
1998-11-26 03:43:31 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
fl.defVerifyFlags = RPMVERIFY_ALL;
|
1999-05-18 00:27:38 +08:00
|
|
|
fl.nLangs = 0;
|
|
|
|
fl.currentLangs = NULL;
|
1998-03-20 12:34:09 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.docDirCount = 0;
|
1999-09-21 11:22:53 +08:00
|
|
|
fl.docDirs[fl.docDirCount++] = xstrdup("/usr/doc");
|
|
|
|
fl.docDirs[fl.docDirCount++] = xstrdup("/usr/man");
|
|
|
|
fl.docDirs[fl.docDirCount++] = xstrdup("/usr/info");
|
|
|
|
fl.docDirs[fl.docDirCount++] = xstrdup("/usr/X11R6/man");
|
1999-01-06 07:13:56 +08:00
|
|
|
fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_docdir}", NULL);
|
1999-07-23 07:05:43 +08:00
|
|
|
fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_mandir}", NULL);
|
|
|
|
fl.docDirs[fl.docDirCount++] = rpmGetPath("%{_infodir}", NULL);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
fl.fileList = NULL;
|
|
|
|
fl.fileListRecsAlloced = 0;
|
|
|
|
fl.fileListRecsUsed = 0;
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
s = getStringBuf(pkg->fileList);
|
|
|
|
files = splitString(s, strlen(s), '\n');
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
for (fp = files; *fp != NULL; fp++) {
|
1998-07-26 05:00:26 +08:00
|
|
|
s = *fp;
|
|
|
|
SKIPSPACE(s);
|
1998-11-25 03:30:38 +08:00
|
|
|
if (*s == '\0')
|
|
|
|
continue;
|
1998-07-26 05:00:26 +08:00
|
|
|
fileName = NULL;
|
|
|
|
strcpy(buf, s);
|
|
|
|
|
|
|
|
/* Reset for a new line in %files */
|
|
|
|
fl.isDir = 0;
|
|
|
|
fl.inFtw = 0;
|
1999-04-30 22:59:47 +08:00
|
|
|
fl.currentFlags = 0;
|
1999-10-05 01:29:58 +08:00
|
|
|
fl.currentVerifyFlags = fl.defVerifyFlags;
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.isSpecialDoc = 0;
|
1999-05-18 00:27:38 +08:00
|
|
|
|
|
|
|
/* XXX should reset to %deflang value */
|
|
|
|
if (fl.currentLangs) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < fl.nLangs; i++)
|
|
|
|
xfree(fl.currentLangs[i]);
|
|
|
|
FREE(fl.currentLangs);
|
|
|
|
}
|
|
|
|
fl.nLangs = 0;
|
1998-11-25 03:30:38 +08:00
|
|
|
|
1998-11-26 03:43:31 +08:00
|
|
|
dupAttrRec(&fl.def_ar, &fl.cur_ar);
|
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
if (parseForVerify(buf, &fl))
|
|
|
|
continue;
|
|
|
|
if (parseForAttr(buf, &fl))
|
|
|
|
continue;
|
|
|
|
if (parseForConfig(buf, &fl))
|
|
|
|
continue;
|
|
|
|
if (parseForLang(buf, &fl))
|
|
|
|
continue;
|
|
|
|
if (parseForSimple(spec, pkg, buf, &fl, &fileName))
|
|
|
|
continue;
|
|
|
|
if (fileName == NULL)
|
|
|
|
continue;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
if (fl.isSpecialDoc) {
|
|
|
|
/* Save this stuff for last */
|
1998-11-26 03:52:12 +08:00
|
|
|
FREE(specialDoc);
|
1999-09-21 11:22:53 +08:00
|
|
|
specialDoc = xstrdup(fileName);
|
1998-11-26 03:52:12 +08:00
|
|
|
dupAttrRec(&fl.cur_ar, &specialDocAttrRec);
|
1998-07-26 05:00:26 +08:00
|
|
|
} else {
|
|
|
|
processBinaryFile(pkg, &fl, fileName);
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Now process special doc, if there is one */
|
|
|
|
if (specialDoc) {
|
|
|
|
if (installSpecialDoc) {
|
|
|
|
doScript(spec, RPMBUILD_STRINGBUF, "%doc", pkg->specialDoc, test);
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-04-30 22:59:47 +08:00
|
|
|
/* Reset for %doc */
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.isDir = 0;
|
|
|
|
fl.inFtw = 0;
|
|
|
|
fl.currentFlags = 0;
|
|
|
|
fl.currentVerifyFlags = 0;
|
1999-05-18 00:27:38 +08:00
|
|
|
|
|
|
|
/* XXX should reset to %deflang value */
|
|
|
|
if (fl.currentLangs) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < fl.nLangs; i++)
|
|
|
|
xfree(fl.currentLangs[i]);
|
|
|
|
FREE(fl.currentLangs);
|
|
|
|
}
|
|
|
|
fl.nLangs = 0;
|
1999-04-30 22:59:47 +08:00
|
|
|
|
|
|
|
dupAttrRec(&specialDocAttrRec, &fl.cur_ar);
|
|
|
|
freeAttrRec(&specialDocAttrRec);
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
processBinaryFile(pkg, &fl, specialDoc);
|
1999-04-30 22:59:47 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
FREE(specialDoc);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
freeSplitString(files);
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (! fl.processingFailed) {
|
|
|
|
genCpioListAndHeader(&fl, &(pkg->cpioList), &(pkg->cpioCount),
|
|
|
|
pkg->header, 0);
|
|
|
|
|
|
|
|
if (spec->timeCheck) {
|
|
|
|
timeCheck(spec->timeCheck, pkg->header);
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Clean up */
|
1999-11-24 08:03:54 +08:00
|
|
|
FREE(fl.buildRootURL);
|
1998-07-26 05:00:26 +08:00
|
|
|
FREE(fl.prefix);
|
1998-11-26 03:43:31 +08:00
|
|
|
|
|
|
|
freeAttrRec(&fl.cur_ar);
|
|
|
|
freeAttrRec(&fl.def_ar);
|
|
|
|
|
1999-05-18 00:27:38 +08:00
|
|
|
if (fl.currentLangs) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < fl.nLangs; i++)
|
|
|
|
xfree(fl.currentLangs[i]);
|
|
|
|
FREE(fl.currentLangs);
|
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
freeFileList(fl.fileList, fl.fileListRecsUsed);
|
|
|
|
while (fl.docDirCount--) {
|
|
|
|
FREE(fl.docDirs[fl.docDirCount]);
|
|
|
|
}
|
|
|
|
return fl.processingFailed;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/** */
|
1999-04-17 22:23:42 +08:00
|
|
|
void initSourceHeader(Spec spec)
|
1998-07-26 05:00:26 +08:00
|
|
|
{
|
|
|
|
HeaderIterator hi;
|
|
|
|
int tag, type, count;
|
|
|
|
void * ptr;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->sourceHeader = headerNew();
|
|
|
|
/* Only specific tags are added to the source package header */
|
1999-10-30 00:06:01 +08:00
|
|
|
for (hi = headerInitIterator(spec->packages->header);
|
|
|
|
headerNextIterator(hi, &tag, &type, &ptr, &count);
|
|
|
|
ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE)
|
|
|
|
? xfree(ptr), NULL : NULL))
|
|
|
|
{
|
1998-07-26 05:00:26 +08:00
|
|
|
switch (tag) {
|
2000-07-11 11:46:56 +08:00
|
|
|
case RPMTAG_NAME:
|
|
|
|
case RPMTAG_VERSION:
|
|
|
|
case RPMTAG_RELEASE:
|
|
|
|
case RPMTAG_EPOCH:
|
|
|
|
case RPMTAG_SUMMARY:
|
|
|
|
case RPMTAG_DESCRIPTION:
|
|
|
|
case RPMTAG_PACKAGER:
|
|
|
|
case RPMTAG_DISTRIBUTION:
|
|
|
|
case RPMTAG_DISTURL:
|
|
|
|
case RPMTAG_VENDOR:
|
|
|
|
case RPMTAG_LICENSE:
|
|
|
|
case RPMTAG_GROUP:
|
|
|
|
case RPMTAG_OS:
|
|
|
|
case RPMTAG_ARCH:
|
|
|
|
case RPMTAG_CHANGELOGTIME:
|
|
|
|
case RPMTAG_CHANGELOGNAME:
|
|
|
|
case RPMTAG_CHANGELOGTEXT:
|
|
|
|
case RPMTAG_URL:
|
|
|
|
case HEADER_I18NTABLE:
|
1998-07-26 05:00:26 +08:00
|
|
|
headerAddEntry(spec->sourceHeader, tag, type, ptr, count);
|
|
|
|
break;
|
2000-07-11 11:46:56 +08:00
|
|
|
default:
|
1998-07-26 05:00:26 +08:00
|
|
|
/* do not copy */
|
|
|
|
break;
|
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
headerFreeIterator(hi);
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-04-17 22:23:42 +08:00
|
|
|
/* Add the build restrictions */
|
1999-10-30 00:06:01 +08:00
|
|
|
for (hi = headerInitIterator(spec->buildRestrictions);
|
|
|
|
headerNextIterator(hi, &tag, &type, &ptr, &count);
|
|
|
|
ptr = ((type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE)
|
|
|
|
? xfree(ptr), NULL : NULL))
|
|
|
|
{
|
1999-04-17 22:23:42 +08:00
|
|
|
headerAddEntry(spec->sourceHeader, tag, type, ptr, count);
|
|
|
|
}
|
|
|
|
headerFreeIterator(hi);
|
|
|
|
|
|
|
|
if (spec->buildArchitectureCount) {
|
|
|
|
headerAddEntry(spec->sourceHeader, RPMTAG_BUILDARCHS,
|
|
|
|
RPM_STRING_ARRAY_TYPE,
|
|
|
|
spec->buildArchitectures, spec->buildArchitectureCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/** */
|
1999-04-17 22:23:42 +08:00
|
|
|
int processSourceFiles(Spec spec)
|
|
|
|
{
|
|
|
|
struct Source *srcPtr;
|
|
|
|
StringBuf sourceFiles;
|
|
|
|
int x, isSpec = 1;
|
|
|
|
struct FileList fl;
|
1999-12-22 01:11:43 +08:00
|
|
|
char *s, **files, **fp;
|
1999-04-17 22:23:42 +08:00
|
|
|
Package pkg;
|
|
|
|
|
|
|
|
sourceFiles = newStringBuf();
|
|
|
|
|
1999-04-21 23:32:23 +08:00
|
|
|
/* XXX
|
|
|
|
* XXX This is where the source header for noarch packages needs
|
|
|
|
* XXX to be initialized.
|
|
|
|
*/
|
|
|
|
if (spec->sourceHeader == NULL)
|
|
|
|
initSourceHeader(spec);
|
1999-04-17 22:23:42 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* Construct the file list and source entries */
|
|
|
|
appendLineStringBuf(sourceFiles, spec->specFile);
|
1998-08-02 21:48:37 +08:00
|
|
|
for (srcPtr = spec->sources; srcPtr != NULL; srcPtr = srcPtr->next) {
|
1998-07-26 05:00:26 +08:00
|
|
|
if (srcPtr->flags & RPMBUILD_ISSOURCE) {
|
|
|
|
headerAddOrAppendEntry(spec->sourceHeader, RPMTAG_SOURCE,
|
|
|
|
RPM_STRING_ARRAY_TYPE, &srcPtr->source, 1);
|
|
|
|
if (srcPtr->flags & RPMBUILD_ISNO) {
|
|
|
|
headerAddOrAppendEntry(spec->sourceHeader, RPMTAG_NOSOURCE,
|
|
|
|
RPM_INT32_TYPE, &srcPtr->num, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (srcPtr->flags & RPMBUILD_ISPATCH) {
|
|
|
|
headerAddOrAppendEntry(spec->sourceHeader, RPMTAG_PATCH,
|
|
|
|
RPM_STRING_ARRAY_TYPE, &srcPtr->source, 1);
|
|
|
|
if (srcPtr->flags & RPMBUILD_ISNO) {
|
|
|
|
headerAddOrAppendEntry(spec->sourceHeader, RPMTAG_NOPATCH,
|
|
|
|
RPM_INT32_TYPE, &srcPtr->num, 1);
|
|
|
|
}
|
|
|
|
}
|
1998-09-06 04:02:08 +08:00
|
|
|
|
1999-01-06 07:13:56 +08:00
|
|
|
{ const char *s;
|
|
|
|
s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
|
|
|
|
"%{_sourcedir}/", srcPtr->source, NULL);
|
|
|
|
appendLineStringBuf(sourceFiles, s);
|
|
|
|
xfree(s);
|
1998-09-06 04:02:08 +08:00
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-08-02 21:48:37 +08:00
|
|
|
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
|
|
|
|
for (srcPtr = pkg->icon; srcPtr != NULL; srcPtr = srcPtr->next) {
|
1999-01-06 07:13:56 +08:00
|
|
|
const char *s;
|
|
|
|
s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
|
|
|
|
"%{_sourcedir}/", srcPtr->source, NULL);
|
|
|
|
appendLineStringBuf(sourceFiles, s);
|
|
|
|
xfree(s);
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->sourceCpioList = NULL;
|
|
|
|
spec->sourceCpioCount = 0;
|
|
|
|
|
1999-09-21 11:22:53 +08:00
|
|
|
fl.fileList = xmalloc((spec->numSources + 1) * sizeof(FileListRec));
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.processingFailed = 0;
|
|
|
|
fl.fileListRecsUsed = 0;
|
|
|
|
fl.totalFileSize = 0;
|
|
|
|
fl.prefix = NULL;
|
|
|
|
|
|
|
|
s = getStringBuf(sourceFiles);
|
|
|
|
files = splitString(s, strlen(s), '\n');
|
|
|
|
|
|
|
|
/* The first source file is the spec file */
|
|
|
|
x = 0;
|
1998-11-25 03:30:38 +08:00
|
|
|
for (fp = files; *fp != NULL; fp++) {
|
1999-12-22 01:11:43 +08:00
|
|
|
const char * diskURL, *diskPath;
|
1998-11-25 03:30:38 +08:00
|
|
|
FileListRec *flp;
|
1999-12-22 01:11:43 +08:00
|
|
|
|
|
|
|
diskURL = *fp;
|
|
|
|
SKIPSPACE(diskURL);
|
|
|
|
if (! *diskURL)
|
1998-11-25 03:30:38 +08:00
|
|
|
continue;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
flp = &fl.fileList[x];
|
|
|
|
|
|
|
|
flp->flags = isSpec ? RPMFILE_SPECFILE : 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
/* files with leading ! are no source files */
|
1999-12-22 01:11:43 +08:00
|
|
|
if (*diskURL == '!') {
|
1998-11-25 03:30:38 +08:00
|
|
|
flp->flags |= RPMFILE_GHOST;
|
1999-12-22 01:11:43 +08:00
|
|
|
diskURL++;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-10-30 07:03:12 +08:00
|
|
|
|
1999-12-22 01:11:43 +08:00
|
|
|
urlPath(diskURL, &diskPath);
|
1999-10-30 07:03:12 +08:00
|
|
|
|
1999-12-22 01:11:43 +08:00
|
|
|
flp->diskURL = xstrdup(diskURL);
|
|
|
|
diskPath = strrchr(diskPath, '/');
|
|
|
|
if (diskPath)
|
|
|
|
diskPath++;
|
1999-10-30 07:03:12 +08:00
|
|
|
else
|
1999-12-22 01:11:43 +08:00
|
|
|
diskPath = diskURL;
|
1999-10-30 07:03:12 +08:00
|
|
|
|
1999-12-22 01:11:43 +08:00
|
|
|
flp->fileURL = xstrdup(diskPath);
|
1998-11-25 03:30:38 +08:00
|
|
|
flp->verifyFlags = RPMVERIFY_ALL;
|
|
|
|
|
2000-02-16 00:40:28 +08:00
|
|
|
if (Stat(diskURL, &flp->fl_st)) {
|
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad file: %s: %s"),
|
|
|
|
diskURL, strerror(errno));
|
|
|
|
fl.processingFailed = 1;
|
|
|
|
}
|
1998-11-25 03:30:38 +08:00
|
|
|
|
1998-11-25 08:42:36 +08:00
|
|
|
flp->uname = getUname(flp->fl_uid);
|
|
|
|
flp->gname = getGname(flp->fl_gid);
|
1999-09-21 11:22:53 +08:00
|
|
|
flp->langs = xstrdup("");
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-11-25 08:42:36 +08:00
|
|
|
fl.totalFileSize += flp->fl_size;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-11-25 03:30:38 +08:00
|
|
|
if (! (flp->uname && flp->gname)) {
|
2000-02-16 00:40:28 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("Bad owner/group: %s"), diskURL);
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.processingFailed = 1;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
isSpec = 0;
|
|
|
|
x++;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
fl.fileListRecsUsed = x;
|
|
|
|
freeSplitString(files);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (! fl.processingFailed) {
|
|
|
|
genCpioListAndHeader(&fl, &(spec->sourceCpioList),
|
|
|
|
&(spec->sourceCpioCount), spec->sourceHeader, 1);
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
freeStringBuf(sourceFiles);
|
|
|
|
freeFileList(fl.fileList, fl.fileListRecsUsed);
|
|
|
|
return fl.processingFailed;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static StringBuf getOutputFrom(char *dir, char *argv[],
|
1999-07-24 03:19:15 +08:00
|
|
|
const char *writePtr, int writeBytesLeft,
|
1998-07-26 05:00:26 +08:00
|
|
|
int failNonZero)
|
|
|
|
{
|
|
|
|
int progPID;
|
|
|
|
int toProg[2];
|
|
|
|
int fromProg[2];
|
|
|
|
int status;
|
|
|
|
void *oldhandler;
|
|
|
|
StringBuf readBuff;
|
1999-06-17 23:44:47 +08:00
|
|
|
int done;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
oldhandler = signal(SIGPIPE, SIG_IGN);
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
toProg[0] = toProg[1] = 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
pipe(toProg);
|
1999-10-05 01:29:58 +08:00
|
|
|
fromProg[0] = fromProg[1] = 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
pipe(fromProg);
|
|
|
|
|
|
|
|
if (!(progPID = fork())) {
|
|
|
|
close(toProg[1]);
|
|
|
|
close(fromProg[0]);
|
|
|
|
|
1998-11-20 02:10:28 +08:00
|
|
|
dup2(toProg[0], STDIN_FILENO); /* Make stdin the in pipe */
|
|
|
|
dup2(fromProg[1], STDOUT_FILENO); /* Make stdout the out pipe */
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
close(toProg[0]);
|
|
|
|
close(fromProg[1]);
|
|
|
|
|
|
|
|
if (dir) {
|
|
|
|
chdir(dir);
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
execvp(argv[0], argv);
|
1999-11-11 06:09:49 +08:00
|
|
|
/* XXX this error message is probably not seen. */
|
1999-10-04 23:15:46 +08:00
|
|
|
rpmError(RPMERR_EXEC, _("Couldn't exec %s: %s"),
|
|
|
|
argv[0], strerror(errno));
|
1998-07-26 05:00:26 +08:00
|
|
|
_exit(RPMERR_EXEC);
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
if (progPID < 0) {
|
1999-10-04 23:15:46 +08:00
|
|
|
rpmError(RPMERR_FORK, _("Couldn't fork %s: %s"),
|
|
|
|
argv[0], strerror(errno));
|
1998-07-26 05:00:26 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
close(toProg[0]);
|
|
|
|
close(fromProg[1]);
|
|
|
|
|
|
|
|
/* Do not block reading or writing from/to prog. */
|
|
|
|
fcntl(fromProg[0], F_SETFL, O_NONBLOCK);
|
|
|
|
fcntl(toProg[1], F_SETFL, O_NONBLOCK);
|
|
|
|
|
|
|
|
readBuff = newStringBuf();
|
|
|
|
|
|
|
|
do {
|
1999-06-17 23:44:47 +08:00
|
|
|
fd_set ibits, obits;
|
|
|
|
struct timeval tv;
|
|
|
|
int nfd, nbw, nbr;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
done = 0;
|
|
|
|
top:
|
|
|
|
/* XXX the select is mainly a timer since all I/O is non-blocking */
|
|
|
|
FD_ZERO(&ibits);
|
|
|
|
FD_ZERO(&obits);
|
|
|
|
if (fromProg[0] >= 0) {
|
|
|
|
FD_SET(fromProg[0], &ibits);
|
|
|
|
}
|
|
|
|
if (toProg[1] >= 0) {
|
|
|
|
FD_SET(toProg[1], &obits);
|
|
|
|
}
|
|
|
|
tv.tv_sec = 1;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
nfd = ((fromProg[0] > toProg[1]) ? fromProg[0] : toProg[1]);
|
|
|
|
if ((rc = select(nfd, &ibits, &obits, NULL, &tv)) < 0) {
|
|
|
|
if (errno == EINTR)
|
|
|
|
goto top;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-10-02 21:45:30 +08:00
|
|
|
/* Write any data to program */
|
1999-06-17 23:44:47 +08:00
|
|
|
if (toProg[1] >= 0 && FD_ISSET(toProg[1], &obits)) {
|
|
|
|
if (writeBytesLeft) {
|
|
|
|
if ((nbw = write(toProg[1], writePtr,
|
1998-07-26 05:00:26 +08:00
|
|
|
(1024<writeBytesLeft) ? 1024 : writeBytesLeft)) < 0) {
|
|
|
|
if (errno != EAGAIN) {
|
|
|
|
perror("getOutputFrom()");
|
1998-11-21 04:18:22 +08:00
|
|
|
exit(EXIT_FAILURE);
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-06-17 23:44:47 +08:00
|
|
|
nbw = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1999-06-17 23:44:47 +08:00
|
|
|
writeBytesLeft -= nbw;
|
|
|
|
writePtr += nbw;
|
|
|
|
} else if (toProg[1] >= 0) { /* close write fd */
|
1998-07-26 05:00:26 +08:00
|
|
|
close(toProg[1]);
|
1998-09-10 23:09:21 +08:00
|
|
|
toProg[1] = -1;
|
1999-06-17 23:44:47 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
/* Read any data from prog */
|
1999-10-01 01:45:42 +08:00
|
|
|
{ char buf[BUFSIZ+1];
|
|
|
|
while ((nbr = read(fromProg[0], buf, sizeof(buf)-1)) > 0) {
|
|
|
|
buf[nbr] = '\0';
|
|
|
|
appendStringBuf(readBuff, buf);
|
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
|
|
|
|
1998-10-08 19:55:37 +08:00
|
|
|
/* terminate on (non-blocking) EOF or error */
|
1999-06-17 23:44:47 +08:00
|
|
|
done = (nbr == 0 || (nbr < 0 && errno != EAGAIN));
|
|
|
|
|
|
|
|
} while (!done);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-10-02 21:45:30 +08:00
|
|
|
/* Clean up */
|
1998-09-10 23:09:21 +08:00
|
|
|
if (toProg[1] >= 0)
|
|
|
|
close(toProg[1]);
|
1999-06-17 23:44:47 +08:00
|
|
|
if (fromProg[0] >= 0)
|
|
|
|
close(fromProg[0]);
|
1998-11-17 05:40:28 +08:00
|
|
|
(void)signal(SIGPIPE, oldhandler);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-10-02 21:45:30 +08:00
|
|
|
/* Collect status from prog */
|
1998-11-17 05:40:28 +08:00
|
|
|
(void)waitpid(progPID, &status, 0);
|
1998-07-26 05:00:26 +08:00
|
|
|
if (failNonZero && (!WIFEXITED(status) || WEXITSTATUS(status))) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_EXEC, _("%s failed"), argv[0]);
|
1998-07-26 05:00:26 +08:00
|
|
|
return NULL;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1998-10-02 21:45:30 +08:00
|
|
|
if (writeBytesLeft) {
|
|
|
|
rpmError(RPMERR_EXEC, _("failed to write all data to %s"), argv[0]);
|
|
|
|
return NULL;
|
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
return readBuff;
|
1997-03-31 22:14:20 +08:00
|
|
|
}
|
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
typedef struct {
|
|
|
|
const char *msg;
|
|
|
|
const char *argv[4];
|
|
|
|
int ntag;
|
|
|
|
int vtag;
|
|
|
|
int ftag;
|
|
|
|
int mask;
|
|
|
|
int xor;
|
|
|
|
} DepMsg_t;
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/** */
|
1999-07-24 03:19:15 +08:00
|
|
|
DepMsg_t depMsgs[] = {
|
|
|
|
{ "Provides", { "%{__find_provides}", NULL, NULL, NULL },
|
|
|
|
RPMTAG_PROVIDENAME, RPMTAG_PROVIDEVERSION, RPMTAG_PROVIDEFLAGS,
|
|
|
|
0, -1 },
|
|
|
|
{ "PreReq", { "%{__find_prereq}", NULL, NULL, NULL },
|
|
|
|
RPMTAG_REQUIRENAME, RPMTAG_REQUIREVERSION, RPMTAG_REQUIREFLAGS,
|
|
|
|
RPMSENSE_PREREQ, 0 },
|
|
|
|
{ "Requires", { "%{__find_requires}", NULL, NULL, NULL },
|
|
|
|
-1, -1, RPMTAG_REQUIREFLAGS, /* XXX inherit name/version arrays */
|
|
|
|
RPMSENSE_PREREQ, RPMSENSE_PREREQ },
|
|
|
|
{ "Conflicts", { "%{__find_conflicts}", NULL, NULL, NULL },
|
|
|
|
RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTVERSION, RPMTAG_CONFLICTFLAGS,
|
|
|
|
0, -1 },
|
|
|
|
{ "Obsoletes", { "%{__find_obsoletes}", NULL, NULL, NULL },
|
|
|
|
RPMTAG_OBSOLETENAME, RPMTAG_OBSOLETEVERSION, RPMTAG_OBSOLETEFLAGS,
|
|
|
|
0, -1 },
|
|
|
|
{ NULL, { NULL, NULL, NULL, NULL }, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int generateDepends(Spec spec, Package pkg,
|
2000-07-06 04:39:15 +08:00
|
|
|
struct cpioFileMapping *cpioList, int cpioCount,
|
|
|
|
int multiLib)
|
1997-03-31 22:14:20 +08:00
|
|
|
{
|
1998-07-26 05:00:26 +08:00
|
|
|
StringBuf writeBuf;
|
|
|
|
int writeBytes;
|
|
|
|
StringBuf readBuf;
|
1999-07-24 03:19:15 +08:00
|
|
|
DepMsg_t *dm;
|
|
|
|
char *myargv[4];
|
1999-10-05 01:29:58 +08:00
|
|
|
int failnonzero = 0;
|
1999-07-24 03:19:15 +08:00
|
|
|
int rc = 0;
|
1997-03-31 22:14:20 +08:00
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
if (cpioCount <= 0)
|
1997-03-31 22:14:20 +08:00
|
|
|
return 0;
|
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
if (! (pkg->autoReq || pkg->autoProv))
|
1997-03-31 22:14:20 +08:00
|
|
|
return 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
writeBuf = newStringBuf();
|
2000-07-06 04:39:15 +08:00
|
|
|
for (writeBytes = 0; cpioCount--; cpioList++) {
|
|
|
|
|
|
|
|
if (multiLib == 2) {
|
|
|
|
if (!(cpioList->mapFlags & CPIO_MULTILIB))
|
|
|
|
continue;
|
|
|
|
cpioList->mapFlags &= ~CPIO_MULTILIB;
|
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
writeBytes += strlen(cpioList->fsPath) + 1;
|
|
|
|
appendLineStringBuf(writeBuf, cpioList->fsPath);
|
1997-03-31 22:14:20 +08:00
|
|
|
}
|
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
for (dm = depMsgs; dm->msg != NULL; dm++) {
|
1999-10-05 01:29:58 +08:00
|
|
|
int i, tag;
|
1999-07-24 03:19:15 +08:00
|
|
|
|
|
|
|
tag = (dm->ftag > 0) ? dm->ftag : dm->ntag;
|
1997-03-31 22:14:20 +08:00
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
switch(tag) {
|
|
|
|
case RPMTAG_PROVIDEFLAGS:
|
|
|
|
if (!pkg->autoProv)
|
|
|
|
continue;
|
|
|
|
failnonzero = 1;
|
|
|
|
break;
|
|
|
|
case RPMTAG_REQUIREFLAGS:
|
|
|
|
if (!pkg->autoReq)
|
|
|
|
continue;
|
|
|
|
failnonzero = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
1999-10-05 01:29:58 +08:00
|
|
|
/*@notreached@*/ break;
|
1997-03-31 22:14:20 +08:00
|
|
|
}
|
1999-07-24 03:19:15 +08:00
|
|
|
|
|
|
|
/* Get the script name to run */
|
|
|
|
myargv[0] = rpmExpand(dm->argv[0], NULL);
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
if (!(myargv[0] && *myargv[0] != '%')) {
|
|
|
|
free(myargv[0]);
|
1999-07-24 03:19:15 +08:00
|
|
|
continue;
|
1999-10-05 01:29:58 +08:00
|
|
|
}
|
1999-07-24 03:19:15 +08:00
|
|
|
|
|
|
|
rpmMessage(RPMMESS_NORMAL, _("Finding %s: (using %s)...\n"),
|
|
|
|
dm->msg, myargv[0]);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (*myargv[0] != '/') { /* XXX FIXME: stat script here */
|
|
|
|
free(myargv[0]);
|
|
|
|
myargv[0] = NULL;
|
|
|
|
continue;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-07-24 03:19:15 +08:00
|
|
|
#endif
|
1997-03-31 22:14:20 +08:00
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
/* Expand rest of script arguments (if any) */
|
|
|
|
for (i = 1; i < 4; i++) {
|
|
|
|
myargv[i] = dm->argv[i] ? rpmExpand(dm->argv[i], NULL) : NULL;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
readBuf = getOutputFrom(NULL, myargv,
|
|
|
|
getStringBuf(writeBuf), writeBytes, failnonzero);
|
|
|
|
|
|
|
|
/* Free expanded args */
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (myargv[i] == NULL) continue;
|
|
|
|
free(myargv[i]);
|
|
|
|
myargv[i] = NULL;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-11-17 05:40:28 +08:00
|
|
|
if (readBuf == NULL) {
|
1999-07-24 03:19:15 +08:00
|
|
|
rc = RPMERR_EXEC;
|
|
|
|
rpmError(rc, _("Failed to find %s:"), dm->msg);
|
|
|
|
break;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1998-01-23 12:23:33 +08:00
|
|
|
|
1999-07-24 03:19:15 +08:00
|
|
|
/* Parse dependencies into header */
|
2000-07-06 04:39:15 +08:00
|
|
|
rc = parseRCPOT(spec, pkg, getStringBuf(readBuf), tag, 0,
|
|
|
|
multiLib > 1 ? RPMSENSE_MULTILIB : 0);
|
1998-07-26 05:00:26 +08:00
|
|
|
freeStringBuf(readBuf);
|
1999-07-24 03:19:15 +08:00
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
rpmError(rc, _("Failed to find %s:"), dm->msg);
|
|
|
|
break;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
|
|
|
}
|
1998-01-23 12:23:33 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
freeStringBuf(writeBuf);
|
1999-07-24 03:19:15 +08:00
|
|
|
return rc;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1998-01-23 12:23:33 +08:00
|
|
|
|
1999-07-23 06:38:44 +08:00
|
|
|
static void printDepMsg(DepMsg_t *dm, int count, const char **names,
|
|
|
|
const char **versions, int *flags)
|
1998-01-23 12:23:33 +08:00
|
|
|
{
|
1999-07-23 06:38:44 +08:00
|
|
|
int hasVersions = (versions != NULL);
|
|
|
|
int hasFlags = (flags != NULL);
|
|
|
|
int i, bingo;
|
|
|
|
|
|
|
|
bingo = 0;
|
|
|
|
for (i = 0; i < count; i++, names++, versions++, flags++) {
|
|
|
|
if (hasFlags && !((*flags & dm->mask) ^ dm->xor))
|
|
|
|
continue;
|
|
|
|
if (bingo == 0) {
|
|
|
|
rpmMessage(RPMMESS_NORMAL, "%s:", dm->msg);
|
|
|
|
bingo = 1;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-07-23 06:38:44 +08:00
|
|
|
rpmMessage(RPMMESS_NORMAL, " %s", *names);
|
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
if (hasFlags && isDependsMULTILIB(*flags))
|
|
|
|
rpmMessage(RPMMESS_NORMAL, " (multilib)");
|
|
|
|
|
1999-07-23 06:38:44 +08:00
|
|
|
if (hasVersions && !(*versions != NULL && **versions != '\0'))
|
|
|
|
continue;
|
|
|
|
if (!(hasFlags && (*flags && RPMSENSE_SENSEMASK)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rpmMessage(RPMMESS_NORMAL, " ");
|
|
|
|
if (*flags & RPMSENSE_LESS)
|
|
|
|
rpmMessage(RPMMESS_NORMAL, "<");
|
|
|
|
if (*flags & RPMSENSE_GREATER)
|
|
|
|
rpmMessage(RPMMESS_NORMAL, ">");
|
|
|
|
if (*flags & RPMSENSE_EQUAL)
|
|
|
|
rpmMessage(RPMMESS_NORMAL, "=");
|
|
|
|
|
|
|
|
rpmMessage(RPMMESS_NORMAL, " %s", *versions);
|
|
|
|
}
|
|
|
|
if (bingo)
|
1998-07-26 05:00:26 +08:00
|
|
|
rpmMessage(RPMMESS_NORMAL, "\n");
|
1999-07-23 06:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void printDeps(Header h)
|
|
|
|
{
|
|
|
|
const char **names = NULL;
|
|
|
|
const char **versions = NULL;
|
|
|
|
int *flags = NULL;
|
|
|
|
DepMsg_t *dm;
|
|
|
|
int type, count;
|
|
|
|
|
|
|
|
for (dm = depMsgs; dm->msg != NULL; dm++) {
|
|
|
|
switch (dm->ntag) {
|
|
|
|
case 0:
|
|
|
|
FREE(names);
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FREE(names);
|
|
|
|
if (!headerGetEntry(h, dm->ntag, &type, (void **) &names, &count))
|
|
|
|
continue;
|
|
|
|
break;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-07-23 06:38:44 +08:00
|
|
|
switch (dm->vtag) {
|
|
|
|
case 0:
|
|
|
|
FREE(versions);
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FREE(versions);
|
|
|
|
headerGetEntry(h, dm->vtag, NULL, (void **) &versions, NULL);
|
|
|
|
break;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-07-23 06:38:44 +08:00
|
|
|
switch (dm->ftag) {
|
|
|
|
case 0:
|
|
|
|
flags = NULL;
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
headerGetEntry(h, dm->ftag, NULL, (void **) &flags, NULL);
|
|
|
|
break;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1999-07-23 06:38:44 +08:00
|
|
|
printDepMsg(dm, count, names, versions, flags);
|
1998-01-23 12:23:33 +08:00
|
|
|
}
|
1999-07-23 06:38:44 +08:00
|
|
|
FREE(names);
|
|
|
|
FREE(versions);
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1998-01-23 12:23:33 +08:00
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/** */
|
1998-07-26 05:00:26 +08:00
|
|
|
int processBinaryFiles(Spec spec, int installSpecialDoc, int test)
|
|
|
|
{
|
|
|
|
Package pkg;
|
1999-10-05 01:29:58 +08:00
|
|
|
int res = 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-08-02 21:48:37 +08:00
|
|
|
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
|
1999-10-05 01:29:58 +08:00
|
|
|
const char *n, *v, *r;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (pkg->fileList == NULL)
|
1998-07-26 05:00:26 +08:00
|
|
|
continue;
|
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
headerNVR(pkg->header, &n, &v, &r);
|
|
|
|
rpmMessage(RPMMESS_NORMAL, _("Processing files: %s-%s-%s\n"), n, v, r);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1999-10-05 01:29:58 +08:00
|
|
|
if ((rc = processPackageFiles(spec, pkg, installSpecialDoc, test)))
|
1998-07-26 05:00:26 +08:00
|
|
|
res = rc;
|
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
/* XXX This should be added always so that packages look alike.
|
|
|
|
* XXX However, there is logic in files.c/depends.c that checks for
|
|
|
|
* XXX existence (rather than value) that will need to change as well.
|
|
|
|
*/
|
|
|
|
if (headerGetEntry(pkg->header, RPMTAG_MULTILIBS, NULL, NULL, NULL)) {
|
|
|
|
generateDepends(spec, pkg, pkg->cpioList, pkg->cpioCount, 1);
|
|
|
|
generateDepends(spec, pkg, pkg->cpioList, pkg->cpioCount, 2);
|
|
|
|
} else
|
|
|
|
generateDepends(spec, pkg, pkg->cpioList, pkg->cpioCount, 0);
|
1999-07-23 06:38:44 +08:00
|
|
|
printDeps(pkg->header);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-01-23 12:23:33 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
return res;
|
1998-01-23 12:23:33 +08:00
|
|
|
}
|