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 <rpmio_internal.h>
#include <fts.h>
#include <rpmbuild.h>
#include "cpio.h"
#include "argv.h"
#include "rpmfc.h"
#include "rpmfi.h"
#include <selinux/selinux.h>
#include "rpmte.h"
#include "buildio.h"
#include "legacy.h"
#include "misc.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

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_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)
 
Parameters:
s 

static void timeCheck (int tc, Header h)
static int parseForVerify (char *buf, FileList fl)
 Parse verify and defverify from file manifest.
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)
 Parse config from file manifest.
static int langCmp (const void *ap, const void *bp)
static int parseForLang (char *buf, FileList fl)
 Parse lang from file manifest.
static int parseForRegexLang (const char *fileName, char **lang)
static int parseForSimple (Spec spec, Package pkg, char *buf, FileList fl, const char **fileName)
 Parse simple attributes (e.g.
static int compareFileListRecs (const void *ap, const void *bp)
static int isDoc (FileList fl, const char *fileName)
 Test if file is located in a docdir.
static int checkHardLinks (FileList fl)
 Verify that file attributes scope over hardlinks correctly.
static void genCpioListAndHeader (FileList fl, rpmfi *fip, Header h, int isSrc)
 Add file entries to header.
static FileListRec freeFileList (FileListRec fileList, int count)
static int recurseDir (FileList fl, const char *diskURL)
 Add directory (and all of its files) to the package manifest.
static int addFile (FileList fl, const char *diskURL, struct stat *statp)
 Add a file to the package manifest.
static int processMetadataFile (Package pkg, FileList fl, const char *fileURL, rpmTag tag)
 Add a pubkey/policy/icon to a binary package.
static int processBinaryFile (Package pkg, FileList fl, const char *fileURL)
 Add a file to a binary package.
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 int checkFiles (StringBuf fileList)
 Check packaged file list against what's in the build root.
int processBinaryFiles (Spec spec, int installSpecialDoc, int test)
 Post-build processing for binary package(s).

Variables

static struct AttrRec_s root_ar = { NULL, NULL, "root", "root", 0, 0 }
static StringBuf check_fileList = NULL
VFA_t verifyAttrs []
VFA_t virtualFileAttributes []


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

#define _RPMTE_INTERNAL

Definition at line 28 of file files.c.

#define fl_dev   fl_st.st_dev

Definition at line 68 of file files.c.

#define fl_gid   fl_st.st_gid

Definition at line 73 of file files.c.

#define fl_ino   fl_st.st_ino

Definition at line 69 of file files.c.

#define fl_mode   fl_st.st_mode

Definition at line 70 of file files.c.

#define fl_mtime   fl_st.st_mtime

Definition at line 76 of file files.c.

#define fl_nlink   fl_st.st_nlink

Definition at line 71 of file files.c.

#define fl_rdev   fl_st.st_rdev

Definition at line 74 of file files.c.

#define fl_size   fl_st.st_size

Definition at line 75 of file files.c.

#define fl_uid   fl_st.st_uid

Definition at line 72 of file files.c.

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

Definition at line 416 of file files.c.

Referenced by parseForAttr().

#define MAXDOCDIR   1024

Definition at line 46 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 44 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 43 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 50 of file files.c.


Function Documentation

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

References _, appendStringBuf, 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, check_fileList, 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(), FileList_s::nLangs, parseForRegexLang(), FileList_s::prefix, FileList_s::processingFailed, recurseDir(), rpmError, RPMFILE_EXCLUDE, S_ISLNK, FileListRec_s::specdFlags, FileList_s::totalFileSize, FileListRec_s::uname, urlPath(), FileListRec_s::verifyFlags, xmalloc(), xrealloc(), and xstrdup().

Referenced by processBinaryFile(), processMetadataFile(), and recurseDir().

static int checkFiles ( StringBuf  fileList  )  [static]

Check packaged file list against what's in the build root.

Parameters:
fileList packaged file list
Returns:
-1 if skipped, 0 on OK, 1 on error

Definition at line 2441 of file files.c.

References _, _free(), FileList_s::fileList, freeStringBuf(), getStringBuf(), rpmExpand(), rpmExpandNumeric(), rpmfcExec(), RPMMESS_ERROR, RPMMESS_NORMAL, RPMMESS_WARNING, and rpmMessage.

Referenced by processBinaryFiles().

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

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

Referenced by processPackageFiles().

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

Definition at line 1059 of file files.c.

Referenced by genCpioListAndHeader().

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

Definition at line 190 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 176 of file files.c.

References _free(), and ar.

Referenced by dupAttrRec(), processPackageFiles(), and processSourceFiles().

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

Definition at line 1477 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,
rpmfi fip,
Header  h,
int  isSrc 
) [static]

Add file entries to header.

Todo:
Should directories have doc/config attributes? (#14531)
Todo:
Remove RPMTAG_OLDFILENAMES, add dirname/basename instead.
Parameters:
fl package file tree walk data
Return values:
*fip file info for package
Parameters:
h 
isSrc 

Definition at line 1129 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, FileListRec_s::diskURL, domd5(), expandFilelist(), FA_COPYOUT, FA_SKIP, FileList_s::fileList, FileList_s::fileListRecsUsed, FileListRec_s::fileURL, FileListRec_s::flags, freecon, FileListRec_s::gname, headerAddEntry(), headerAddOrAppendEntry(), isDoc(), FileListRec_s::langs, FileList_s::prefix, FileList_s::processingFailed, Readlink(), RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, rpmError, rpmExpandNumeric(), rpmfiFree(), RPMFILE_CONFIG, RPMFILE_DOC, RPMFILE_EXCLUDE, RPMFILE_GHOST, rpmfiNew(), rpmGetPath(), rpmlibNeedsFeature(), RPMMESS_WARNING, rpmMessage, RPMTAG_BASENAMES, RPMTAG_FILECONTEXTS, 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_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, TR_ADDED, FileListRec_s::uname, urlPath(), FileListRec_s::verifyFlags, xcalloc(), and xmalloc().

Referenced by processPackageFiles(), and processSourceFiles().

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

Test if file is located in a docdir.

Parameters:
fl package file tree walk data
fileName file path
Returns:
1 if doc file, 0 if not

Definition at line 1072 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 721 of file files.c.

Referenced by parseForLang().

static void nullAttrRec ( AttrRec  ar  )  [static]

Definition at line 164 of file files.c.

References ar.

Referenced by parseForAttr(), and processPackageFiles().

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

Parse attr and defattr from file manifest.

Parameters:
buf current spec file line
fl package file tree walk data
Returns:
0 on success

Definition at line 527 of file files.c.

References _, alloca(), ar, 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(), and processSourceFiles().

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

Parse config from file manifest.

Parameters:
buf current spec file line
fl package file tree walk data
Returns:
0 on success

Definition at line 660 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:
buf current spec file line
fl package file tree walk data
Returns:
0 on success

Definition at line 425 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]

Parse lang from file manifest.

Parameters:
buf current spec file line
fl package file tree walk data
Returns:
0 on success

Definition at line 736 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 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]

Parse simple attributes (e.g.

dir) from file manifest.

Parameters:
spec 
pkg 
buf current spec file line
fl package file tree walk data
Return values:
*fileName file name
Returns:
0 on success

Definition at line 906 of file files.c.

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

Referenced by processPackageFiles().

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

Parse verify and defverify from file manifest.

Parameters:
buf current spec file line
fl package file tree walk data
Returns:
0 on success

Definition at line 327 of file files.c.

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

Referenced by processPackageFiles().

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

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

Referenced by processPackageFiles().

static int processMetadataFile ( Package  pkg,
FileList  fl,
const char *  fileURL,
rpmTag  tag 
) [static]

Add a pubkey/policy/icon to a binary package.

Parameters:
pkg 
fl package file tree walk data
fileURL path to file, relative is builddir, absolute buildroot.
tag tag to add
Returns:
0 on success

Definition at line 1769 of file files.c.

References _, _free(), addFile(), FileList_s::buildRootURL, Package_s::header, headerAddOrAppendEntry(), PGPARMOR_PUBKEY, pgpArmorWrap(), pgpReadPkts(), FileList_s::processingFailed, RPM_STRING_ARRAY_TYPE, rpmError, rpmGenPath(), rpmioSlurp(), RPMTAG_POLICIES, RPMTAG_PUBKEYS, and urlPath().

Referenced by processPackageFiles().

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

Definition at line 1931 of file files.c.

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

Referenced by processBinaryFiles().

static int recurseDir ( FileList  fl,
const char *  diskURL 
) [static]

Add directory (and all of its files) to the package manifest.

Parameters:
fl package file tree walk data
diskURL path to file
Returns:
0 on success

Definition at line 1712 of file files.c.

References addFile(), _ftsent::fts_accpath, Fts_close(), FTS_COMFOLLOW, FTS_D, FTS_DC, FTS_DEFAULT, FTS_DNR, FTS_DOT, FTS_DP, FTS_ERR, FTS_F, _ftsent::fts_info, FTS_INIT, FTS_NOCHDIR, FTS_NS, FTS_NSOK, Fts_open(), FTS_PHYSICAL, Fts_read(), FTS_SL, FTS_SLNONE, _ftsent::fts_statp, FTS_W, ftsSet, FileList_s::inFtw, and FileList_s::isDir.

Referenced by addFile().

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

Parameters:
s 

Parameters:
delim 

Definition at line 227 of file files.c.

Referenced by parseForSimple().

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

Definition at line 271 of file files.c.

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

Referenced by processPackageFiles().


Variable Documentation

StringBuf check_fileList = NULL [static]

Definition at line 115 of file files.c.

Referenced by addFile(), and processBinaryFiles().

struct AttrRec_s root_ar = { NULL, NULL, "root", "root", 0, 0 } [static]

Definition at line 110 of file files.c.

Referenced by processPackageFiles().

VFA_t verifyAttrs[]

Initial value:

 {
    { "md5",    0,      RPMVERIFY_MD5 },
    { "size",   0,      RPMVERIFY_FILESIZE },
    { "link",   0,      RPMVERIFY_LINKTO },
    { "user",   0,      RPMVERIFY_USER },
    { "group",  0,      RPMVERIFY_GROUP },
    { "mtime",  0,      RPMVERIFY_MTIME },
    { "mode",   0,      RPMVERIFY_MODE },
    { "rdev",   0,      RPMVERIFY_RDEV },
    { NULL, 0,  0 }
}

Definition at line 307 of file files.c.

Referenced by parseForVerify().

VFA_t virtualFileAttributes[]

Initial value:

 {
        { "%dir",       0,      0 },    
        { "%doc",       0,      RPMFILE_DOC },
        { "%ghost",     0,      RPMFILE_GHOST },
        { "%exclude",   0,      RPMFILE_EXCLUDE },
        { "%readme",    0,      RPMFILE_README },
        { "%license",   0,      RPMFILE_LICENSE },
        { "%pubkey",    0,      RPMFILE_PUBKEY },
        { "%policy",    0,      RPMFILE_POLICY },









        { NULL, 0, 0 }
}

Definition at line 874 of file files.c.

Referenced by parseForSimple().


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2