build/files.c File Reference

The post-build, pre-packaging file tree walk to assemble the package manifest. More...

#include "system.h"
#include <regex.h>
#include <signal.h>
#include <rpmio_internal.h>
#include <rpmbuild.h>
#include "buildio.h"
#include "myftw.h"
#include "md5.h"
#include "debug.h"

Go to the source code of this file.

Data Structures

struct  FileListRec_s
struct  AttrRec_s
struct  FileList_s
 Package file tree walk data. More...
struct  VFA
struct  DepMsg_t

Defines

#define MYALLPERMS   07777
#define SKIPWHITE(_x)   {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
#define SKIPNONWHITE(_x)   {while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
#define MAXDOCDIR   1024
#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
#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
#define isAttrDefault(_ars)   ((_ars)[0] == '-' && (_ars)[1] == '\0')

Typedefs

typedef enum specdFlags_e specdFlags
typedef FileListRec_sFileListRec
typedef AttrRec_sAttrRec
typedef FileList_sFileList
 Package file tree walk data.
typedef VFA VFA_t

Enumerations

enum  specdFlags_e {
  SPECD_DEFFILEMODE = (1 << 0), SPECD_DEFDIRMODE = (1 << 1), SPECD_DEFUID = (1 << 2), SPECD_DEFGID = (1 << 3),
  SPECD_DEFVERIFY = (1 << 4), SPECD_FILEMODE = (1 << 8), SPECD_DIRMODE = (1 << 9), SPECD_UID = (1 << 10),
  SPECD_GID = (1 << 11), SPECD_VERIFY = (1 << 12)
}

Functions

static void nullAttrRec (AttrRec ar)
static void freeAttrRec (AttrRec ar)
static void dupAttrRec (const AttrRec oar, AttrRec nar)
static char * strtokWithQuotes (char *s, char *delim)
static void timeCheck (int tc, Header h)
static int parseForVerify (char *buf, FileList fl)
 
Parameters:
fl package file tree walk data

static int parseForDev (char *buf, FileList fl)
 Parse dev from file manifest.
static int parseForAttr (char *buf, FileList fl)
 Parse attr and defattr from file manifest.
static int parseForConfig (char *buf, FileList fl)
 
Parameters:
fl package file tree walk data

static int langCmp (const void *ap, const void *bp)
static int parseForLang (char *buf, FileList fl)
 
Parameters:
fl package file tree walk data

static int parseForRegexLang (const char *fileName, char **lang)
static int parseForRegexMultiLib (const char *fileName)
static int parseForSimple (Spec spec, Package pkg, char *buf, FileList fl, const char **fileName)
 
Parameters:
fl package file tree walk data

static int compareFileListRecs (const void *ap, const void *bp)
static int isDoc (FileList fl, const char *fileName)
 
Parameters:
fl package file tree walk data

static int checkHardLinks (FileList fl)
 Verify that file attributes scope over hardlinks correctly.
static void genCpioListAndHeader (FileList fl, TFI_t *cpioList, Header h, int isSrc)
static FileListRec freeFileList (FileListRec fileList, int count)
static int addFile (FileList fl, const char *diskURL, struct stat *statp)
 
Parameters:
fl package file tree walk data

static int processBinaryFile (Package pkg, FileList fl, const char *fileURL)
 
Parameters:
fl package file tree walk data

static int processPackageFiles (Spec spec, Package pkg, int installSpecialDoc, int test)
void initSourceHeader (Spec spec)
 Create and initialize header for source package.
int processSourceFiles (Spec spec)
 Post-build processing for source package.
static StringBuf getOutputFrom (char *dir, char *argv[], const char *writePtr, int writeBytesLeft, int failNonZero)
static int generateDepends (Spec spec, Package pkg, TFI_t cpioList, int multiLib)
static void printDepMsg (DepMsg_t *dm, int count, const char **names, const char **versions, int *flags)
static void printDeps (Header h)
int processBinaryFiles (Spec spec, int installSpecialDoc, int test)
 Post-build processing for binary package(s).

Variables

int _noDirTokens
static int multiLib = 0
VFA_t verifyAttrs []
VFA_t virtualFileAttributes []
DepMsg_t depMsgs []


Detailed Description

The post-build, pre-packaging file tree walk to assemble the package manifest.

Definition in file files.c.


Define Documentation

#define fl_dev   fl_st.st_dev

Definition at line 57 of file files.c.

#define fl_gid   fl_st.st_gid

Definition at line 62 of file files.c.

#define fl_ino   fl_st.st_ino

Definition at line 58 of file files.c.

#define fl_mode   fl_st.st_mode

Definition at line 59 of file files.c.

#define fl_mtime   fl_st.st_mtime

Definition at line 65 of file files.c.

#define fl_nlink   fl_st.st_nlink

Definition at line 60 of file files.c.

#define fl_rdev   fl_st.st_rdev

Definition at line 63 of file files.c.

#define fl_size   fl_st.st_size

Definition at line 64 of file files.c.

#define fl_uid   fl_st.st_uid

Definition at line 61 of file files.c.

#define isAttrDefault ( _ars   )     ((_ars)[0] == '-' && (_ars)[1] == '\0')

Definition at line 394 of file files.c.

Referenced by parseForAttr().

#define MAXDOCDIR   1024

Definition at line 31 of file files.c.

Referenced by parseForSimple().

#define MYALLPERMS   07777

Definition at line 9 of file files.c.

Referenced by parseForAttr().

#define SKIPNONWHITE ( _x   )     {while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}

Definition at line 29 of file files.c.

Referenced by parseForAttr(), parseForConfig(), parseForDev(), parseForLang(), parseForVerify(), parseNoSource(), and parseRCPOT().

#define SKIPWHITE ( _x   )     {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}

Definition at line 28 of file files.c.

Referenced by parseForAttr(), parseForConfig(), parseForDev(), parseForLang(), parseForVerify(), parseNoSource(), and parseRCPOT().


Typedef Documentation

typedef struct AttrRec_s * AttrRec

typedef struct FileList_s * FileList

Package file tree walk data.

typedef struct FileListRec_s * FileListRec

typedef enum specdFlags_e specdFlags

typedef struct VFA VFA_t


Enumeration Type Documentation

enum specdFlags_e

Enumerator:
SPECD_DEFFILEMODE 
SPECD_DEFDIRMODE 
SPECD_DEFUID 
SPECD_DEFGID 
SPECD_DEFVERIFY 
SPECD_FILEMODE 
SPECD_DIRMODE 
SPECD_UID 
SPECD_GID 
SPECD_VERIFY 

Definition at line 39 of file files.c.


Function Documentation

static int addFile ( FileList  fl,
const char *  diskURL,
struct stat *  statp 
) [static]

Parameters:
fl package file tree walk data

Definition at line 1451 of file files.c.

References _, AttrRec_s::ar_dmode, AttrRec_s::ar_dmodestr, AttrRec_s::ar_fmode, AttrRec_s::ar_fmodestr, AttrRec_s::ar_group, AttrRec_s::ar_user, FileList_s::buildRootURL, FileList_s::cur_ar, FileList_s::currentFlags, FileList_s::currentLangs, FileList_s::currentSpecdFlags, FileList_s::currentVerifyFlags, FileList_s::devmajor, FileList_s::devminor, FileList_s::devtype, FileListRec_s::diskURL, FileList_s::fileCount, FileList_s::fileList, FileList_s::fileListRecsAlloced, FileList_s::fileListRecsUsed, FileListRec_s::fileURL, FileListRec_s::fl_st, FileListRec_s::flags, getGname(), getGnameS(), getUname(), getUnameS(), FileListRec_s::gname, FileList_s::inFtw, FileList_s::isDir, lang, FileListRec_s::langs, Lstat(), myftw(), FileList_s::nLangs, parseForRegexLang(), parseForRegexMultiLib(), FileList_s::prefix, FileList_s::processingFailed, rpmError, RPMFILE_MULTILIB_MASK, RPMMESS_DEBUG, rpmMessage, FileListRec_s::specdFlags, FileList_s::totalFileSize, FileListRec_s::uname, urlPath(), FileListRec_s::verifyFlags, xmalloc(), xrealloc(), and xstrdup().

Referenced by processBinaryFile().

static int checkHardLinks ( FileList  fl  )  [static]

Verify that file attributes scope over hardlinks correctly.

If partial hardlink sets are possible, then add tracking dependency.

Todo:
Only lang coloring is checked, doc et al also need doing.
Parameters:
fl package file tree walk data
Returns:
1 if partial hardlink sets can exist, 0 otherwise.

Definition at line 1041 of file files.c.

References FileList_s::fileList, FileList_s::fileListRecsUsed, and FileListRec_s::langs.

Referenced by processPackageFiles().

static int compareFileListRecs ( const void *  ap,
const void *  bp 
) [static]

Definition at line 1013 of file files.c.

Referenced by genCpioListAndHeader().

static void dupAttrRec ( const AttrRec  oar,
AttrRec  nar 
) [static]

Definition at line 162 of file files.c.

References AttrRec_s::ar_dmode, AttrRec_s::ar_dmodestr, AttrRec_s::ar_fmode, AttrRec_s::ar_fmodestr, AttrRec_s::ar_group, AttrRec_s::ar_user, freeAttrRec(), and xstrdup().

Referenced by parseForAttr(), and processPackageFiles().

static void freeAttrRec ( AttrRec  ar  )  [static]

Definition at line 148 of file files.c.

References _free(), AttrRec_s::ar_dmodestr, AttrRec_s::ar_fmodestr, AttrRec_s::ar_group, and AttrRec_s::ar_user.

Referenced by dupAttrRec(), and processPackageFiles().

static FileListRec freeFileList ( FileListRec  fileList,
int  count 
) [static]

Definition at line 1435 of file files.c.

References _free(), FileListRec_s::diskURL, FileListRec_s::fileURL, and FileListRec_s::langs.

Referenced by processPackageFiles(), and processSourceFiles().

static void genCpioListAndHeader ( FileList  fl,
TFI_t cpioList,
Header  h,
int  isSrc 
) [static]

Todo:
Should directories have doc/config attributes? (#14531)

Remove RPMTAG_OLDFILENAMES, add dirname/basename instead.

Parameters:
fl package file tree walk data

Definition at line 1086 of file files.c.

References _, _free(), _noDirTokens, FileList_s::buildRootURL, compareFileListRecs(), compressFilelist(), CPIO_FOLLOW_SYMLINKS, CPIO_MAP_GID, CPIO_MAP_MODE, CPIO_MAP_PATH, CPIO_MAP_TYPE, CPIO_MAP_UID, CPIO_MULTILIB, FileListRec_s::diskURL, domd5(), expandFilelist(), FA_COPYOUT, FA_SKIP, FileList_s::fileList, FileList_s::fileListRecsUsed, FileListRec_s::fileURL, FileListRec_s::flags, getGidS(), getUidS(), FileListRec_s::gname, headerAddEntry(), headerAddOrAppendEntry(), isDoc(), FileListRec_s::langs, loadFi(), FileList_s::prefix, FileList_s::processingFailed, Readlink(), RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, rpmError, rpmExpandNumeric(), RPMFILE_CONFIG, RPMFILE_DOC, RPMFILE_EXCLUDE, RPMFILE_GHOST, RPMFILE_MULTILIB_MASK, RPMFILE_MULTILIB_SHIFT, rpmlibNeedsFeature(), RPMMESS_WARNING, rpmMessage, RPMTAG_FILEDEVICES, RPMTAG_FILEFLAGS, RPMTAG_FILEGROUPNAME, RPMTAG_FILEINODES, RPMTAG_FILELANGS, RPMTAG_FILELINKTOS, RPMTAG_FILEMD5S, RPMTAG_FILEMODES, RPMTAG_FILEMTIMES, RPMTAG_FILERDEVS, RPMTAG_FILESIZES, RPMTAG_FILEUSERNAME, RPMTAG_FILEVERIFYFLAGS, RPMTAG_MULTILIBS, RPMTAG_OLDFILENAMES, RPMTAG_SIZE, RPMVERIFY_FILESIZE, RPMVERIFY_LINKTO, RPMVERIFY_MD5, RPMVERIFY_MTIME, S_ISLNK, SPECD_DEFDIRMODE, SPECD_DEFFILEMODE, SPECD_DEFGID, SPECD_DEFUID, SPECD_DEFVERIFY, SPECD_DIRMODE, SPECD_FILEMODE, SPECD_GID, SPECD_UID, SPECD_VERIFY, FileListRec_s::specdFlags, stpcpy(), FileList_s::totalFileSize, FileListRec_s::uname, urlPath(), FileListRec_s::verifyFlags, xcalloc(), and xmalloc().

Referenced by processPackageFiles(), and processSourceFiles().

static int generateDepends ( Spec  spec,
Package  pkg,
TFI_t  cpioList,
int  multiLib 
) [static]

Definition at line 2405 of file files.c.

References appendLineStringBuf, appendStringBuf, PackageStruct::autoProv, PackageStruct::autoReq, transactionFileInfo_s::bnl, CPIO_MULTILIB, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, transactionFileInfo_s::fc, transactionFileInfo_s::fmapflags, newStringBuf(), and xcalloc().

Referenced by processBinaryFiles().

static StringBuf getOutputFrom ( char *  dir,
char *  argv[],
const char *  writePtr,
int  writeBytesLeft,
int  failNonZero 
) [static]

Definition at line 2208 of file files.c.

References _, appendStringBuf, errno, EXIT_FAILURE, newStringBuf(), RPMERR_EXEC, RPMERR_FORK, rpmError, and strerror().

static int isDoc ( FileList  fl,
const char *  fileName 
) [static]

Parameters:
fl package file tree walk data

Definition at line 1023 of file files.c.

References FileList_s::docDirCount, and FileList_s::docDirs.

Referenced by genCpioListAndHeader().

static int langCmp ( const void *  ap,
const void *  bp 
) [static]

Definition at line 686 of file files.c.

Referenced by parseForLang().

static void nullAttrRec ( AttrRec  ar  )  [static]

Definition at line 136 of file files.c.

References AttrRec_s::ar_dmode, AttrRec_s::ar_dmodestr, AttrRec_s::ar_fmode, AttrRec_s::ar_fmodestr, AttrRec_s::ar_group, and AttrRec_s::ar_user.

Referenced by parseForAttr(), and processPackageFiles().

static int parseForAttr ( char *  buf,
FileList  fl 
) [static]

Parse attr and defattr from file manifest.

Parameters:
fl package file tree walk data

Definition at line 498 of file files.c.

References _, alloca(), FileList_s::cur_ar, FileList_s::currentSpecdFlags, FileList_s::def_ar, FileList_s::defSpecdFlags, dupAttrRec(), isAttrDefault, MYALLPERMS, nullAttrRec(), FileList_s::processingFailed, RPMERR_BADSPEC, rpmError, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, SPECD_DIRMODE, SPECD_FILEMODE, SPECD_GID, and SPECD_UID.

Referenced by processPackageFiles().

static int parseForConfig ( char *  buf,
FileList  fl 
) [static]

Parameters:
fl package file tree walk data

Definition at line 626 of file files.c.

References _, alloca(), FileList_s::currentFlags, FileList_s::processingFailed, RPMERR_BADSPEC, rpmError, RPMFILE_CONFIG, RPMFILE_MISSINGOK, RPMFILE_NOREPLACE, SKIPNONWHITE, SKIPSPACE, and SKIPWHITE.

Referenced by processPackageFiles().

static int parseForDev ( char *  buf,
FileList  fl 
) [static]

Parse dev from file manifest.

Parameters:
fl package file tree walk data

Definition at line 400 of file files.c.

References _, alloca(), FileList_s::devmajor, FileList_s::devminor, FileList_s::devtype, FileList_s::noGlob, FileList_s::processingFailed, RPMERR_BADSPEC, rpmError, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, and xisdigit().

Referenced by processPackageFiles().

static int parseForLang ( char *  buf,
FileList  fl 
) [static]

Parameters:
fl package file tree walk data

Definition at line 694 of file files.c.

References _, alloca(), FileList_s::currentLangs, langCmp(), FileList_s::nLangs, FileList_s::processingFailed, RPMERR_BADSPEC, rpmError, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, xmalloc(), and xrealloc().

Referenced by processPackageFiles().

static int parseForRegexLang ( const char *  fileName,
char **  lang 
) [static]

Definition at line 783 of file files.c.

References _free(), and rpmExpand().

Referenced by addFile().

static int parseForRegexMultiLib ( const char *  fileName  )  [static]

Definition at line 827 of file files.c.

References _free(), and rpmExpand().

Referenced by addFile().

static int parseForSimple ( Spec  spec,
Package  pkg,
char *  buf,
FileList  fl,
const char **  fileName 
) [static]

Parameters:
fl package file tree walk data

Definition at line 885 of file files.c.

References _, VFA::attribute, FileList_s::currentFlags, FileList_s::docDirCount, FileList_s::docDirs, VFA::flag, FileList_s::isDir, MAXDOCDIR, FileList_s::processingFailed, RPMERR_BADSPEC, RPMERR_INTERNAL, rpmError, RPMFILE_DOC, strtokWithQuotes(), virtualFileAttributes, and xstrdup().

Referenced by processPackageFiles().

static int parseForVerify ( char *  buf,
FileList  fl 
) [static]

Parameters:
fl package file tree walk data

Definition at line 306 of file files.c.

References _, alloca(), VFA::attribute, FileList_s::currentSpecdFlags, FileList_s::currentVerifyFlags, FileList_s::defSpecdFlags, FileList_s::defVerifyFlags, VFA::flag, name, FileList_s::processingFailed, RPMERR_BADSPEC, rpmError, RPMVERIFY_NONE, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, SPECD_VERIFY, and verifyAttrs.

Referenced by processPackageFiles().

static void printDepMsg ( DepMsg_t dm,
int  count,
const char **  names,
const char **  versions,
int *  flags 
) [static]

Definition at line 2551 of file files.c.

References isDependsMULTILIB, DepMsg_t::mask, DepMsg_t::msg, RPMMESS_NORMAL, rpmMessage, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, RPMSENSE_SENSEMASK, and DepMsg_t::xor.

Referenced by printDeps().

static void printDeps ( Header  h  )  [static]

Definition at line 2593 of file files.c.

References depMsgs, DepMsg_t::ftag, headerFreeData(), headerGetEntryMinMemory(), DepMsg_t::msg, DepMsg_t::ntag, printDepMsg(), and DepMsg_t::vtag.

Referenced by processBinaryFiles().

static int processBinaryFile ( Package  pkg,
FileList  fl,
const char *  fileURL 
) [static]

Parameters:
fl package file tree walk data

Definition at line 1668 of file files.c.

References _, _free(), addFile(), FileList_s::buildRootURL, myGlobPatternP(), FileList_s::noGlob, FileList_s::processingFailed, rpmError, rpmGenPath(), rpmGlob(), and urlPath().

Referenced by processPackageFiles().

static int processPackageFiles ( Spec  spec,
Package  pkg,
int  installSpecialDoc,
int  test 
) [static]

Definition at line 1743 of file files.c.

References _, _free(), appendStringBuf, SpecStruct::buildRootURL, SpecStruct::buildSubdir, checkHardLinks(), PackageStruct::cpioList, doScript(), dupAttrRec(), expandMacros(), Fclose(), fdGetFp(), Ferror(), PackageStruct::fileFile, PackageStruct::fileList, Fopen(), freeAttrRec(), freeFileList(), freeSplitString(), Fstrerror(), genCpioListAndHeader(), getStringBuf(), handleComments(), PackageStruct::header, headerGetEntryMinMemory(), SpecStruct::macros, nullAttrRec(), parseForAttr(), parseForConfig(), parseForDev(), parseForLang(), parseForSimple(), parseForVerify(), processBinaryFile(), SpecStruct::rootURL, RPMBUILD_STRINGBUF, RPMERR_BADFILENAME, rpmError, rpmExpandNumeric(), RPMFILE_MULTILIB, rpmGenPath(), rpmGetPath(), rpmlibNeedsFeature(), RPMTAG_DEFAULTPREFIX, RPMVERIFY_ALL, SKIPSPACE, PackageStruct::specialDoc, splitString(), timeCheck(), SpecStruct::timeCheck, and xstrdup().

Referenced by processBinaryFiles().

static char* strtokWithQuotes ( char *  s,
char *  delim 
) [static]

Definition at line 214 of file files.c.

Referenced by parseForSimple().

static void timeCheck ( int  tc,
Header  h 
) [static]

Definition at line 257 of file files.c.

References _, headerFreeData(), headerGetEntryMinMemory(), RPMMESS_WARNING, rpmMessage, RPMTAG_FILEMTIMES, and RPMTAG_OLDFILENAMES.

Referenced by processPackageFiles().


Variable Documentation

int _noDirTokens

Definition at line 289 of file misc.c.

Referenced by dbiUpdateRecord(), genCpioListAndHeader(), rpmdbAdd(), and rpmLeadVersion().

DepMsg_t depMsgs[]

Definition at line 2362 of file files.c.

Referenced by printDeps().

int multiLib = 0 [static]

Definition at line 91 of file files.c.

VFA_t verifyAttrs[]

Initial value:

 {
    { "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 }
}

Definition at line 290 of file files.c.

Referenced by parseForVerify().

VFA_t virtualFileAttributes[]

Initial value:

 {
        { "%dir",       0 },    
        { "%doc",       RPMFILE_DOC },
        { "%ghost",     RPMFILE_GHOST },
        { "%exclude",   RPMFILE_EXCLUDE },
        { "%readme",    RPMFILE_README },
        { "%license",   RPMFILE_LICENSE },
        { "%multilib",  0 },









        { NULL, 0 }
}

Definition at line 861 of file files.c.

Referenced by parseForSimple().


Generated on Wed Feb 13 14:05:39 2008 for rpm by  doxygen 1.5.2