Main Page Modules Data Structures File List Data Fields Globals Related Pages

# 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 "cpio.h"`
`#include "rpmfi.h"`
`#include "rpmte.h"`
`#include "buildio.h"`
`#include "myftw.h"`
`#include "legacy.h"`
`#include "misc.h"`
`#include "debug.h"`

Go to the source code of this file.

## Data Structures
struct | AttrRec_s
struct | DepMsg_t
struct | FileList_s
| Package file tree walk data. More...
struct | FileListRec_s
struct | VFA
## Defines
#define | MYALLPERMS 07777
#define | _RPMFI_INTERNAL
#define | _RPMTE_INTERNAL
#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_s * | FileListRec
typedef AttrRec_s * | AttrRec
typedef FileList_s * | FileList
| Package file tree walk data. More...
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
void | nullAttrRec (AttrRec ar)
void | freeAttrRec (AttrRec ar)
void | dupAttrRec (const AttrRec oar, AttrRec nar)
char * | strtokWithQuotes (char *s, char *delim)
void | timeCheck (int tc, Header h)
int | parseForVerify (char *buf, FileList fl)
| Parse verify and defverify from file manifest. More...
int | parseForDev (char *buf, FileList fl)
| Parse dev from file manifest. More...
int | parseForAttr (char *buf, FileList fl)
| Parse attr and defattr from file manifest. More...
int | parseForConfig (char *buf, FileList fl)
| Parse config from file manifest. More...
int | langCmp (const void *ap, const void *bp)
int | parseForLang (char *buf, FileList fl)
| Parse lang from file manifest. More...
int | parseForRegexLang (const char *fileName, char **lang)
int | parseForRegexMultiLib (const char *fileName)
int | parseForSimple (Spec spec, Package pkg, char *buf, FileList fl, const char **fileName)
| Parse simple attributes (e.g. More...
int | compareFileListRecs (const void *ap, const void *bp)
int | isDoc (FileList fl, const char *fileName)
| Test if file is located in a docdir. More...
int | checkHardLinks (FileList fl)
| Verify that file attributes scope over hardlinks correctly. More...
void | genCpioListAndHeader (FileList fl, rpmfi *cpioList, Header h, int isSrc)
| Add file entries to header. More...
FileListRec | freeFileList (FileListRec fileList, int count)
int | addFile (FileList fl, const char *diskURL, struct stat *statp)
| Add a file to the package manifest. More...
int | processBinaryFile (Package pkg, FileList fl, const char *fileURL)
| Add a file to a binary package. More...
int | processPackageFiles (Spec spec, Package pkg, int installSpecialDoc, int test)
void | initSourceHeader (Spec spec)
int | processSourceFiles (Spec spec)
StringBuf | getOutputFrom (char *dir, char *argv[], const char *writePtr, int writeBytesLeft, int failNonZero)
int | generateDepends (Spec spec, Package pkg, rpmfi cpioList, int multiLib)
void | printDepMsg (DepMsg_t *dm, int count, const char **names, const char **versions, int *flags)
void | printDeps (Header h)
int | checkFiles (StringBuf fileList, int fileListLen)
| Check packaged file list against what's in the build root. More...
int | processBinaryFiles (Spec spec, int installSpecialDoc, int test)
## Variables
int | multiLib = 0
StringBuf | check_fileList = NULL
int | check_fileListLen = 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 _RPMFI_INTERNAL

| Definition at line 19 of file files.c.

#define _RPMTE_INTERNAL

| Definition at line 22 of file files.c.

#define fl_dev fl_st.st_dev

| Definition at line 63 of file files.c.

#define fl_gid fl_st.st_gid

| Definition at line 68 of file files.c.

#define fl_ino fl_st.st_ino

| Definition at line 64 of file files.c.

#define fl_mode fl_st.st_mode

| Definition at line 65 of file files.c.

#define fl_mtime fl_st.st_mtime

| Definition at line 71 of file files.c.

#define fl_nlink fl_st.st_nlink

| Definition at line 66 of file files.c.

#define fl_rdev fl_st.st_rdev

| Definition at line 69 of file files.c.

#define fl_size fl_st.st_size

| Definition at line 70 of file files.c.

#define fl_uid fl_st.st_uid

| Definition at line 67 of file files.c.

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

| Definition at line 415 of file files.c. Referenced by parseForAttr.

#define MAXDOCDIR 1024

| Definition at line 41 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 39 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 38 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

| Referenced by parseForAttr, and parseForVerify.

typedef struct VFA VFA_t

## Enumeration Type Documentation

enum specdFlags_e

  | Enumeration values:
  SPECD_DEFFILEMODE |
  SPECD_DEFDIRMODE |
  SPECD_DEFUID |
  SPECD_DEFGID |
  SPECD_DEFVERIFY |
  SPECD_FILEMODE |
  SPECD_DIRMODE |
  SPECD_UID |
  SPECD_GID |
  SPECD_VERIFY |
Definition at line 45 of file files.c.

## Function Documentation

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

  | Add a file to the package manifest. Parameters:
  fl | package file tree walk data
  diskURL | path to file
  statp | file stat (possibly NULL)
Returns: 0 on success Definition at line 1514 of file files.c. References _, addFile, appendStringBuf, check_fileListLen, FileListRec_s::diskURL, FileListRec_s::fileURL, FileListRec_s::fl_st, FileListRec_s::flags, getGname, getGnameS, getUname, getUnameS, FileListRec_s::gname, FileListRec_s::langs, Lstat, multiLib, myftw, myftwFunc, parseForRegexLang, parseForRegexMultiLib, RPMFILE_MULTILIB_MASK, FileListRec_s::specdFlags, FileListRec_s::uname, urlPath, FileListRec_s::verifyFlags, xmalloc, xrealloc, and xstrdup. Referenced by addFile, and processBinaryFile.

int checkFiles | ( | StringBuf | fileList,
|  | int | fileListLen
| ) | `[static]`

  | Check packaged file list against what's in the build root. Parameters:
  fileList | packaged file list
  fileListLen | no. of packaged files
Returns: -1 if skipped, 0 on OK, 1 on error Definition at line 2753 of file files.c. References _, _free, freeStringBuf, getOutputFrom, getStringBuf, poptParseArgvString, rpmExpand, and rpmExpandNumeric. Referenced by processBinaryFiles.

int checkHardLinks | ( | FileList | fl | ) | `[static]`

  | Verify that file attributes scope over hardlinks correctly. If partial hardlink sets are possible, then add tracking dependency. Parameters:
  fl | package file tree walk data
Returns: 1 if partial hardlink sets can exist, 0 otherwise. Definition at line 1098 of file files.c. Referenced by processPackageFiles.

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

| Definition at line 1067 of file files.c. Referenced by genCpioListAndHeader.

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

| Definition at line 174 of file files.c. References freeAttrRec, and xstrdup. Referenced by parseForAttr, and processPackageFiles.

void freeAttrRec | ( | AttrRec | ar | ) | `[static]`

| Definition at line 160 of file files.c. References _free. Referenced by dupAttrRec, and processPackageFiles.

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

| Definition at line 1492 of file files.c. References _free, and FileListRec_s::diskURL. Referenced by processPackageFiles, and processSourceFiles.

void genCpioListAndHeader | ( | FileList | fl,
|  | rpmfi * | cpioList,
|  | Header | h,
|  | int | isSrc
| ) | `[static]`

  | Add file entries to header. Todo: Should directories have doc/config attributes? (#14531) Remove RPMTAG_OLDFILENAMES, add dirname/basename instead. Parameters:
  fl | package file tree walk data
  cpioList |
  h |
  isSrc |
Definition at line 1135 of file files.c. References _, _free, 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, FileListRec_s::fileURL, FileListRec_s::flags, getGidS, getUidS, FileListRec_s::gname, headerAddEntry, headerAddOrAppendEntry, isDoc, FileListRec_s::langs, Readlink, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, rpmExpandNumeric, rpmfi, RPMFILE_CONFIG, RPMFILE_DOC, RPMFILE_EXCLUDE, RPMFILE_GHOST, RPMFILE_MULTILIB_MASK, RPMFILE_MULTILIB_SHIFT, rpmlibNeedsFeature, RPMTAG_BASENAMES, 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, rpmts, 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, TR_ADDED, uint_16, uint_32, FileListRec_s::uname, urlPath, FileListRec_s::verifyFlags, xcalloc, and xmalloc. Referenced by processPackageFiles, and processSourceFiles.

int generateDepends | ( | Spec | spec,
|  | Package | pkg,
|  | rpmfi | cpioList,
|  | int | multiLib
| ) | `[static]`

| Definition at line 2500 of file files.c. References _, _free, appendLineStringBuf, appendStringBuf, DepMsg_t::argv, CPIO_MULTILIB, freeStringBuf, DepMsg_t::ftag, getOutputFrom, getStringBuf, DepMsg_t::msg, multiLib, newStringBuf, DepMsg_t::ntag, parseRCPOT, poptParseArgvString, rpmExpand, rpmfi, RPMSENSE_FIND_PROVIDES, RPMSENSE_FIND_REQUIRES, RPMSENSE_MULTILIB, RPMTAG_PROVIDEFLAGS, RPMTAG_REQUIREFLAGS, xcalloc, xrealloc, and xstrdup. Referenced by processBinaryFiles.

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

| Definition at line 2300 of file files.c. References _, appendStringBuf, errno, EXIT_FAILURE, newStringBuf, strerror, and unsetenv. Referenced by checkFiles, and generateDepends.

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

  | Test if file is located in a docdir. Bug: Use of strstr(3) might result in false positives. Parameters:
  fl | package file tree walk data
  fileName | file path
Returns: 1 if doc file, 0 if not Definition at line 1081 of file files.c. Referenced by genCpioListAndHeader.

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

| Definition at line 720 of file files.c. Referenced by parseForLang.

void nullAttrRec | ( | AttrRec | ar | ) | `[static]`

| Definition at line 148 of file files.c. Referenced by parseForAttr, and processPackageFiles.

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

  | Parse attr and defattr from file manifest. Parameters:
  buf |
  fl | package file tree walk data
Returns: 0 on success Definition at line 526 of file files.c. References _, alloca, dupAttrRec, isAttrDefault, MYALLPERMS, nullAttrRec, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, SPECD_DIRMODE, SPECD_FILEMODE, SPECD_GID, SPECD_UID, and specdFlags. Referenced by processPackageFiles.

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

  | Parse config from file manifest. Parameters:
  buf |
  fl | package file tree walk data
Returns: 0 on success Definition at line 659 of file files.c. References _, alloca, RPMFILE_CONFIG, RPMFILE_MISSINGOK, RPMFILE_NOREPLACE, SKIPNONWHITE, SKIPSPACE, and SKIPWHITE. Referenced by processPackageFiles.

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

  | Parse dev from file manifest. Parameters:
  buf |
  fl | package file tree walk data
Returns: 0 on success Definition at line 424 of file files.c. References _, alloca, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, and xisdigit. Referenced by processPackageFiles.

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

  | Parse lang from file manifest. Parameters:
  buf |
  fl | package file tree walk data
Returns: 0 on success Definition at line 735 of file files.c. References _, alloca, langCmp, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, xmalloc, and xrealloc. Referenced by processPackageFiles.

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

| Definition at line 826 of file files.c. References _free, and rpmExpand. Referenced by addFile.

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

| Definition at line 872 of file files.c. References _free, and rpmExpand. Referenced by addFile.

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

  | Parse simple attributes (e.g. dir) from file manifest. Parameters:
  spec |
  pkg |
  buf |
  fl | package file tree walk data
  Return values:
  fileName |
Returns: 0 on success Definition at line 938 of file files.c. References _, _free, appendLineStringBuf, appendStringBuf, VFA::attribute, VFA::flag, headerNVR, MAXDOCDIR, MKDIR_P, multiLib, newStringBuf, RPMFILE_DOC, rpmGetPath, strtokWithQuotes, and xstrdup. Referenced by processPackageFiles.

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

  | Parse verify and defverify from file manifest. Parameters:
  buf |
  fl | package file tree walk data
Returns: 0 on success Definition at line 326 of file files.c. References _, alloca, VFA::attribute, VFA::flag, SKIPNONWHITE, SKIPSPACE, SKIPWHITE, SPECD_VERIFY, and specdFlags. Referenced by processPackageFiles.

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

| Definition at line 2650 of file files.c. References isDependsMULTILIB, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, and RPMSENSE_SENSEMASK. Referenced by printDeps.

void printDeps | ( | Header | h | ) | `[static]`

| Definition at line 2692 of file files.c. References DepMsg_t::ftag, HFD_t, HGE_t, DepMsg_t::msg, DepMsg_t::ntag, printDepMsg, rpmTagType, and DepMsg_t::vtag. Referenced by processBinaryFiles.

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

  | Add a file to a binary package. Parameters:
  pkg |
  fl | package file tree walk data
  fileURL |
Returns: 0 on success Definition at line 1746 of file files.c. References _, _free, addFile, myGlobPatternP, rpmGenPath, rpmGlob, and urlPath. Referenced by processPackageFiles.

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

| Definition at line 1822 of file files.c. References _, _free, appendStringBuf, FileList_s::buildRootURL, checkHardLinks, FileList_s::cur_ar, FileList_s::currentFlags, FileList_s::currentLangs, FileList_s::currentSpecdFlags, FileList_s::currentVerifyFlags, FileList_s::def_ar, FileList_s::defSpecdFlags, FileList_s::defVerifyFlags, FileList_s::devmajor, FileList_s::devminor, FileList_s::devtype, FileList_s::docDirCount, FileList_s::docDirs, doScript, dupAttrRec, expandMacros, Fclose, fdGetFp, Ferror, FileList_s::fileCount, FileList_s::fileList, FileList_s::fileListRecsAlloced, FileList_s::fileListRecsUsed, Fopen, freeAttrRec, freeFileList, freeSplitString, Fstrerror, genCpioListAndHeader, getStringBuf, handleComments, HGE_t, FileList_s::inFtw, FileList_s::isDir, FileList_s::isSpecialDoc, multiLib, FileList_s::nLangs, FileList_s::noGlob, nullAttrRec, parseForAttr, parseForConfig, parseForDev, parseForLang, parseForSimple, parseForVerify, FileList_s::passedSpecialDoc, FileList_s::prefix, processBinaryFile, FileList_s::processingFailed, RPMBUILD_STRINGBUF, rpmExpandNumeric, rpmfi, RPMFILE_MULTILIB, rpmGenPath, rpmGetPath, rpmlibNeedsFeature, RPMTAG_DEFAULTPREFIX, SKIPSPACE, splitString, timeCheck, FileList_s::totalFileSize, and xstrdup. Referenced by processBinaryFiles.

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

| Definition at line 227 of file files.c. Referenced by parseForSimple.

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

| Definition at line 271 of file files.c. References _, HFD_t, HGE_t, RPMTAG_FILEMTIMES, RPMTAG_OLDFILENAMES, and rpmTagType. Referenced by processPackageFiles.

## Variable Documentation

StringBuf check_fileList = NULL`[static]`

| Definition at line 101 of file files.c.

int check_fileListLen = 0`[static]`

| Definition at line 103 of file files.c. Referenced by addFile, and processBinaryFiles.

DepMsg_t depMsgs[]

| Definition at line 2456 of file files.c.

int multiLib = 0`[static]`

| Definition at line 97 of file files.c. Referenced by addFile, generateDepends, parseForSimple, and processPackageFiles.

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 306 of file files.c.

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 907 of file files.c.