libzypp  10.5.0
PackageDelta.cc
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <iostream>
00013 extern "C"
00014 {
00015 #include <solv/knownid.h>
00016 }
00017 
00018 #include "zypp/base/LogTools.h"
00019 
00020 #include "zypp/repo/PackageDelta.h"
00021 #include "zypp/sat/Pool.h"
00022 
00023 
00024 using std::endl;
00025 using std::string;
00026 
00027 
00029 namespace zypp
00030 { 
00031 
00032   namespace packagedelta
00033   { 
00034 
00035     DeltaRpm::DeltaRpm( sat::LookupAttr::iterator deltaInfo_r )
00036     {
00037       if ( deltaInfo_r.inSolvAttr() != sat::SolvAttr::repositoryDeltaInfo )
00038       {
00039         INT << "Illegal non-repositoryDeltaInfo iterator: " << deltaInfo_r << endl;
00040         return;
00041       }
00042       _repo = deltaInfo_r.inRepo();
00043 
00044       IdString locdir;
00045       IdString locname;
00046       IdString locevr;
00047       IdString locsuffix;
00048 
00049       IdString    seqname;
00050       IdString    seqevr;
00051       std::string seqnum;
00052 
00053       for_( it, deltaInfo_r.subBegin(), deltaInfo_r.subEnd() )
00054       {
00055         switch ( it.inSolvAttr().id() )
00056         {
00057           case DELTA_PACKAGE_NAME:
00058             _name = it.asString();
00059             break;
00060 
00061           case DELTA_PACKAGE_EVR:
00062             _edition = Edition( it.idStr() );
00063             break;
00064 
00065           case DELTA_PACKAGE_ARCH:
00066             _arch = Arch( it.idStr() );
00067             break;
00068 
00069           case DELTA_LOCATION_DIR:
00070             locdir = it.idStr();
00071             break;
00072 
00073           case DELTA_LOCATION_NAME:
00074             locname = it.idStr();
00075             break;
00076 
00077           case DELTA_LOCATION_EVR:
00078             locevr = it.idStr();
00079             break;
00080 
00081           case DELTA_LOCATION_SUFFIX:
00082             locsuffix = it.idStr();
00083             break;
00084 
00085           case DELTA_DOWNLOADSIZE:
00086             _location.setDownloadSize( ByteCount( it.asUnsigned(), ByteCount::K ) );
00087             break;
00088 
00089           case DELTA_CHECKSUM:
00090             _location.setChecksum( it.asCheckSum() );
00091             break;
00092 
00093           case DELTA_BASE_EVR:
00094             _baseversion.setEdition( Edition( it.idStr() ) );
00095             break;
00096 
00097           case DELTA_SEQ_NAME:
00098             seqname = it.idStr();
00099             break;
00100 
00101           case DELTA_SEQ_EVR:
00102             seqevr = it.idStr();
00103             break;
00104 
00105           case DELTA_SEQ_NUM:
00106             seqnum = it.asString();
00107             break;
00108 
00109           default:
00110             WAR << "Igore unknown attribute: " << it << endl;
00111         }
00112       }
00113 
00114       _location.setLocation( str::form( "%s/%s-%s.%s",
00115                                         locdir.c_str(),
00116                                         locname.c_str(),
00117                                         locevr.c_str(),
00118                                         locsuffix.c_str() ) );
00119 
00120       _baseversion.setSequenceinfo( str::form( "%s-%s-%s",
00121                                                seqname.c_str(),
00122                                                seqevr.c_str(),
00123                                                seqnum.c_str() ) );
00124     }
00125 
00126     std::ostream & operator<<( std::ostream & str, const DeltaRpm & obj )
00127     {
00128       return str
00129       << "DeltaRpm[" << obj.name() << "-" << obj.edition() << "." << obj.arch()
00130       << "](" << obj.location()
00131       << '|' << obj.baseversion().edition()
00132       << ',' << obj.baseversion().sequenceinfo()
00133       << ')';
00134     }
00135 
00137   } // namespace packagedelta
00140 } // namespace zypp