33 static char * lastUname = NULL;
34 static size_t lastUnameLen = 0;
35 static size_t lastUnameAlloced;
37 struct passwd * pwent;
43 }
else if (strcmp(thisUname,
"root") == 0) {
50 thisUnameLen = strlen(thisUname);
51 if (lastUname == NULL || thisUnameLen != lastUnameLen ||
52 strcmp(thisUname, lastUname) != 0)
54 if (lastUnameAlloced < thisUnameLen + 1) {
55 lastUnameAlloced = thisUnameLen + 10;
56 lastUname = (
char *)realloc(lastUname, lastUnameAlloced);
59 strcpy(lastUname, thisUname);
62 pwent = getpwnam(thisUname);
67 pwent = getpwnam(thisUname);
68 if (pwent == NULL)
return -1;
71 lastUid = pwent->pw_uid;
83 static char * lastGname = NULL;
84 static size_t lastGnameLen = 0;
85 static size_t lastGnameAlloced;
90 if (thisGname == NULL) {
93 }
else if (strcmp(thisGname,
"root") == 0) {
100 thisGnameLen = strlen(thisGname);
101 if (lastGname == NULL || thisGnameLen != lastGnameLen ||
102 strcmp(thisGname, lastGname) != 0)
104 if (lastGnameAlloced < thisGnameLen + 1) {
105 lastGnameAlloced = thisGnameLen + 10;
106 lastGname = (
char *)realloc(lastGname, lastGnameAlloced);
109 strcpy(lastGname, thisGname);
112 grent = getgrnam(thisGname);
117 grent = getgrnam(thisGname);
120 if (strcmp(thisGname,
"lock") == 0) {
126 if (strcmp(thisGname,
"mail") == 0) {
135 lastGid = grent->gr_gid;
214 PathInfo file( path_r );
215 if ( ! file.isFile() )
217 ERR <<
"Not a file: " << file << endl;
221 FD_t fd = ::Fopen( file.asString().c_str(),
"r.ufdio" );
222 if ( fd == 0 || ::Ferror(fd) )
224 ERR <<
"Can't open file for reading: " << file <<
" (" << ::Fstrerror(fd) <<
")" << endl;
231 rpmts ts = ::rpmtsCreate();
232 unsigned vsflag = RPMVSF_DEFAULT;
234 vsflag |= _RPMVSF_NODIGESTS;
236 vsflag |= _RPMVSF_NOSIGNATURES;
237 ::rpmtsSetVSFlags( ts, rpmVSFlags(vsflag) );
240 int res = ::rpmReadPackageFile( ts, fd, path_r.asString().c_str(), &nh );
248 WAR <<
"Error reading header from " << path_r <<
" error(" << res <<
")" << endl;
255 MIL << h <<
" from " << path_r << endl;
273 << (
isSrc() ?
".src}" :
"}");
285 return has_tag( RPMTAG_SOURCEPACKAGE );
311 return int_val ( RPMTAG_EPOCH );
376 return int_val( RPMTAG_INSTALLTIME );
389 return int_val( RPMTAG_BUILDTIME );
391 #warning CHECK IF FILE REQUIRES HANDLING IS OBSOLETE
404 rpmTag kindFlags = rpmTag(0);
405 rpmTag kindVersion = rpmTag(0);
409 case RPMTAG_REQUIRENAME:
410 kindFlags = RPMTAG_REQUIREFLAGS;
411 kindVersion = RPMTAG_REQUIREVERSION;
413 case RPMTAG_PROVIDENAME:
414 kindFlags = RPMTAG_PROVIDEFLAGS;
415 kindVersion = RPMTAG_PROVIDEVERSION;
417 case RPMTAG_OBSOLETENAME:
418 kindFlags = RPMTAG_OBSOLETEFLAGS;
419 kindVersion = RPMTAG_OBSOLETEVERSION;
421 case RPMTAG_CONFLICTNAME:
422 kindFlags = RPMTAG_CONFLICTFLAGS;
423 kindVersion = RPMTAG_CONFLICTVERSION;
425 case RPMTAG_ENHANCESNAME:
426 kindFlags = RPMTAG_ENHANCESFLAGS;
427 kindVersion = RPMTAG_ENHANCESVERSION;
429 case RPMTAG_SUGGESTSNAME:
430 kindFlags = RPMTAG_SUGGESTSFLAGS;
431 kindVersion = RPMTAG_SUGGESTSVERSION;
434 INT <<
"Illegal RPMTAG_dependencyNAME " << tag_r << endl;
450 for (
unsigned i = 0; i < count; ++i )
453 std::string n( names[i] );
456 int32_t f = flags[i];
457 std::string v = versions[i];
470 switch ( f & RPMSENSE_SENSEMASK )
475 case RPMSENSE_LESS|RPMSENSE_EQUAL:
478 case RPMSENSE_GREATER:
481 case RPMSENSE_GREATER|RPMSENSE_EQUAL:
490 if ((pre && (f & RPMSENSE_PREREQ))
491 || ((! pre) && !(f & RPMSENSE_PREREQ)))
500 WAR <<
"Invalid capability: " << n <<
" " << op <<
" "
623 return int_val( RPMTAG_ARCHIVESIZE );
831 std::list<std::string> ret;
839 int_list( RPMTAG_DIRINDEXES, dirindexes );
840 for (
unsigned i = 0; i < basenames.
size(); ++ i )
842 ret.push_back( dirnames[dirindexes[i]] + basenames[i] );
859 std::list<FileInfo> ret;
867 int_list( RPMTAG_DIRINDEXES, dirindexes );
869 int_list( RPMTAG_FILESIZES, filesizes );
881 int_list( RPMTAG_FILEMODES, filemodes );
883 int_list( RPMTAG_FILEMTIMES, filemtimes );
885 int_list( RPMTAG_FILEFLAGS, fileflags );
889 for (
unsigned i = 0; i < basenames.
size(); ++ i )
894 uid =
unameToUid( usernames[i].c_str(), &uid );
904 gid =
gnameToGid( groupnames[i].c_str(), &gid );
912 dirnames[dirindexes[i]] + basenames[i],
917 mode_t(filemodes[i]),
919 bool(fileflags[i] & RPMFILE_GHOST),
923 ret.push_back( info );
943 if (
int_list( RPMTAG_CHANGELOGTIME, times ) )
949 for (
unsigned i = 0; i < times.
size(); ++ i )
975 int_list( RPMTAG_DIRINDEXES, dirindexes );
978 int_list( RPMTAG_FILEDEVICES, filedevices );
980 int_list( RPMTAG_FILEINODES, fileinodes );
982 int_list( RPMTAG_FILESIZES, filesizes );
984 int_list( RPMTAG_FILEMODES, filemodes );
991 std::vector<DiskUsage::Entry> entries;
992 entries.resize( dirnames.
size() );
993 for (
unsigned i = 0; i < dirnames.
size(); ++i )
1000 while ( --level && pos != std::string::npos )
1002 pos = entries[i].path.find(
"/", pos+1 );
1004 if ( pos != std::string::npos )
1006 entries[i].path.erase( pos+1 );
1010 for (
unsigned i = 0; i < basenames.
size(); ++ i )
1015 if ( trace.
insert( filedevices[i], fileinodes[i] ) )
1019 ++(entries[dirindexes[i]]._files);
1031 for (
unsigned i = 0; i < entries.size(); ++i )
1033 if ( entries[i]._size )
1034 tmpdata.
add( entries[i] );
1042 dudata_r.
add( ent );
1043 if ( ent.
path.size() <= 1 )
1050 if ( lpos == std::string::npos )
1053 ent.
path.erase( lpos + 1 );