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 );
290 return has_tag( RPMTAG_SOURCEPACKAGE ) && (
has_tag( RPMTAG_NOSOURCE ) ||
has_tag( RPMTAG_NOPATCH ) );
316 return int_val ( RPMTAG_EPOCH );
381 return int_val( RPMTAG_INSTALLTIME );
394 return int_val( RPMTAG_BUILDTIME );
396 #warning CHECK IF FILE REQUIRES HANDLING IS OBSOLETE
409 rpmTag kindFlags = rpmTag(0);
410 rpmTag kindVersion = rpmTag(0);
414 case RPMTAG_REQUIRENAME:
415 kindFlags = RPMTAG_REQUIREFLAGS;
416 kindVersion = RPMTAG_REQUIREVERSION;
418 case RPMTAG_PROVIDENAME:
419 kindFlags = RPMTAG_PROVIDEFLAGS;
420 kindVersion = RPMTAG_PROVIDEVERSION;
422 case RPMTAG_OBSOLETENAME:
423 kindFlags = RPMTAG_OBSOLETEFLAGS;
424 kindVersion = RPMTAG_OBSOLETEVERSION;
426 case RPMTAG_CONFLICTNAME:
427 kindFlags = RPMTAG_CONFLICTFLAGS;
428 kindVersion = RPMTAG_CONFLICTVERSION;
430 case RPMTAG_ENHANCESNAME:
431 kindFlags = RPMTAG_ENHANCESFLAGS;
432 kindVersion = RPMTAG_ENHANCESVERSION;
434 case RPMTAG_SUGGESTSNAME:
435 kindFlags = RPMTAG_SUGGESTSFLAGS;
436 kindVersion = RPMTAG_SUGGESTSVERSION;
439 INT <<
"Illegal RPMTAG_dependencyNAME " << tag_r << endl;
455 for (
unsigned i = 0; i < count; ++i )
458 std::string n( names[i] );
461 int32_t f = flags[i];
462 std::string v = versions[i];
475 switch ( f & RPMSENSE_SENSEMASK )
480 case RPMSENSE_LESS|RPMSENSE_EQUAL:
483 case RPMSENSE_GREATER:
486 case RPMSENSE_GREATER|RPMSENSE_EQUAL:
495 if ((pre && (f & RPMSENSE_PREREQ))
496 || ((! pre) && !(f & RPMSENSE_PREREQ)))
505 WAR <<
"Invalid capability: " << n <<
" " << op <<
" "
628 return int_val( RPMTAG_ARCHIVESIZE );
836 std::list<std::string> ret;
844 int_list( RPMTAG_DIRINDEXES, dirindexes );
845 for (
unsigned i = 0; i < basenames.
size(); ++ i )
847 ret.push_back( dirnames[dirindexes[i]] + basenames[i] );
864 std::list<FileInfo> ret;
872 int_list( RPMTAG_DIRINDEXES, dirindexes );
874 int_list( RPMTAG_FILESIZES, filesizes );
886 int_list( RPMTAG_FILEMODES, filemodes );
888 int_list( RPMTAG_FILEMTIMES, filemtimes );
890 int_list( RPMTAG_FILEFLAGS, fileflags );
894 for (
unsigned i = 0; i < basenames.
size(); ++ i )
899 uid =
unameToUid( usernames[i].c_str(), &uid );
909 gid =
gnameToGid( groupnames[i].c_str(), &gid );
917 dirnames[dirindexes[i]] + basenames[i],
922 mode_t(filemodes[i]),
924 bool(fileflags[i] & RPMFILE_GHOST),
928 ret.push_back( info );
948 if (
int_list( RPMTAG_CHANGELOGTIME, times ) )
954 for (
unsigned i = 0; i < times.
size(); ++ i )
980 int_list( RPMTAG_DIRINDEXES, dirindexes );
983 int_list( RPMTAG_FILEDEVICES, filedevices );
985 int_list( RPMTAG_FILEINODES, fileinodes );
987 int_list( RPMTAG_FILESIZES, filesizes );
989 int_list( RPMTAG_FILEMODES, filemodes );
996 std::vector<DiskUsage::Entry> entries;
997 entries.resize( dirnames.
size() );
998 for (
unsigned i = 0; i < dirnames.
size(); ++i )
1005 while ( --level && pos != std::string::npos )
1007 pos = entries[i].path.find(
"/", pos+1 );
1009 if ( pos != std::string::npos )
1011 entries[i].path.erase( pos+1 );
1015 for (
unsigned i = 0; i < basenames.
size(); ++ i )
1020 if ( trace.
insert( filedevices[i], fileinodes[i] ) )
1024 ++(entries[dirindexes[i]]._files);
1036 for (
unsigned i = 0; i < entries.size(); ++i )
1038 if ( entries[i]._size )
1039 tmpdata.
add( entries[i] );
1047 dudata_r.
add( ent );
1048 if ( ent.
path.size() <= 1 )
1055 if ( lpos == std::string::npos )
1058 ent.
path.erase( lpos + 1 );
Store and operate with byte count.
Single entry in a change log.
std::list< ChangelogEntry > Changelog
List of ChangelogEntry.
void clear()
Clear EntrySet.
void add(const Entry &newent_r)
Add an entry.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Edition represents [epoch:]version[-release]
unsigned epoch_t
Type of an epoch.
std::tr1::unordered_set< Capability > CapabilitySet
Holds data about how much space will be needed per directory.
iterator begin()
Forward iterator pointing to the first entry (if any)
Store and operate on date (time_t).
Simple cache remembering device/inode to detect hardlinks.
bool insert(const dev_t &dev_r, const ino_t &ino_r)
Remember dev/ino.
iterator end()
Forward iterator pointing behind the last entry.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Wrapper class for mode_t values as derived from ::stat.
Base class for Exception.
static bool globalInit()
Initialize lib librpm (read configfiles etc.).
static const Unit K
1024 Byte
SizeType blocks(ByteCount blocksize_r=K) const
Return number of blocks of size blocksize_r (default 1K).