__pycache__/__init__.cpython-36.opt-1.pyc000064400000000161147205106300014074 0ustar003 ft` @sdS)Nrrr/usr/lib/python3.6/__init__.pys__pycache__/__init__.cpython-36.pyc000064400000000161147205106300013135 0ustar003 ft` @sdS)Nrrr/usr/lib/python3.6/__init__.pys__pycache__/group.cpython-36.opt-1.pyc000064400000033766147205106300013512 0ustar003 f<@sddlZddlZddlZddlZddlmZddlm Z ddl Z Gddde Z Gddde Z Gdd d e ZGd d d e ZdS) N)_)loggerc@sleZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS) PersistorBasecCs"||_i|_i|_i|_i|_dS)N)history _installed_removed _upgraded _downgraded)selfrr /usr/lib/python3.6/group.py__init__ s zPersistorBase.__init__cCs(t|jt|jt|jt|jS)N)lenrrrr )r r r r __len__(szPersistorBase.__len__cCsi|_i|_i|_i|_dS)N)rrrr )r r r r clean+szPersistorBase.cleancCstdS)N)NotImplementedError)r objr r r _get_obj_id1szPersistorBase._get_obj_idcCs*|jjj|d|tjj}|jtjjdS)N)rswdbaddItemlibdnf transactionTransactionItemReason_USERZsetStateZTransactionItemState_DONE)r itemactiontir r r _add_to_history4szPersistorBase._add_to_historycCs$||j|j|<|j|tjjdS)N)rrrrrTransactionItemAction_INSTALL)r rr r r install8szPersistorBase.installcCs$||j|j|<|j|tjjdS)N)rrrrrTransactionItemAction_REMOVE)r rr r r remove<szPersistorBase.removecCs$||j|j|<|j|tjjdS)N)rrrrrTransactionItemAction_UPGRADE)r rr r r upgrade@szPersistorBase.upgradecCs$||j|j|<|j|tjjdS)N)r rrrrTransactionItemAction_DOWNGRADE)r rr r r downgradeDszPersistorBase.downgradecCstdS)N)r)r obj_idnametranslated_name pkg_typesr r r newHszPersistorBase.newcCstdS)N)r)r r&r r r getKszPersistorBase.getcCstdS)N)r)r patternr r r search_by_patternNszPersistorBase.search_by_patternN)__name__ __module__ __qualname__r rrrrrr!r#r%r*r+r-r r r r rsrc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)GroupPersistorcCs"|jjj}dd|D}t|S)NcSsg|]}|jr|qSr )getCompsGroupItem).0ir r r Vsz+GroupPersistor.__iter__..)rrgetItemsiter)r itemsr r r __iter__Ts zGroupPersistor.__iter__cCs|jS)N) getGroupId)r rr r r rYszGroupPersistor._get_obj_idcCsH|jjj}|j||dk r(|j||dk r:|j||j||S)N)rrZcreateCompsGroupItemZ setGroupIdsetNamesetTranslatedNamesetPackageTypes)r r&r'r(r) swdb_groupr r r r*\s     zGroupPersistor.newcCs"|jjj|}|sdS|j}|S)N)rrr2)r r&r>r r r r+fs zGroupPersistor.getcCs|jjj|S)N)rrZgetCompsGroupItemsByPattern)r r,r r r r-msz GroupPersistor.search_by_patterncCs|jjj|S)N)rrZgetPackageCompsGroups)r pkg_namer r r get_package_groupspsz!GroupPersistor.get_package_groupscCs|jjj|dd}|tjjkr"dSt|j|}xJ|jj D]<\}}x2|j D]&}|j |kr`qN|j sjqN|j |qNWq.)rrr6r7)r r8r r r r9s zEnvironmentPersistor.__iter__cCs|jS)N)ZgetEnvironmentId)r rr r r rsz EnvironmentPersistor._get_obj_idcCsH|jjj}|j||dk r(|j||dk r:|j||j||S)N)rrZcreateCompsEnvironmentItemZsetEnvironmentIdr;r<r=)r r&r'r(r)swdb_envr r r r*s     zEnvironmentPersistor.newcCs"|jjj|}|sdS|j}|S)N)rrrM)r r&rNr r r r+s zEnvironmentPersistor.getcCs|jjj|S)N)rrZ!getCompsEnvironmentItemsByPattern)r r,r r r r-sz&EnvironmentPersistor.search_by_patterncCs|jjj|S)N)rrZgetCompsGroupEnvironments)r rHr r r get_group_environmentssz+EnvironmentPersistor.get_group_environmentscCs|jjj|}|sdSt|j|}xJ|jjD]<\}}x2|jD]&}|j|krTqB|j s^qB|j |qBWq0WxJ|j jD]<\}}x2|jD]&}|j|krq|j sq|j |qWq|W|rdSdS)NFT) rrIr+rDrOrr8Z getGroupsr:rEr!rrF)r rHr>Zgroup_environmentsZenv_idenvrIr r r is_removable_groups*  z'EnvironmentPersistor.is_removable_groupN) r.r/r0r9rr*r+r-rOrQr r r r rLs rLc@seZdZd,ddZddZddZdd Zd-d d Zd d ZddZ ddZ d.ddZ d/ddZ d0ddZ d1ddZd2ddZd3ddZd4ddZd d!Zd"d#Zed$d%Zed&d'Zd(d)Zd*d+ZdS)5RPMTransactionNc Cs:||_||_|js0y|jjjWn YnXi|_dS)N)rrrZinitTransaction _swdb_ti_pkg)r rrr r r r szRPMTransaction.__init__cs8jrjj}n jjj}fdd|D}t|S)Ncs&g|]}|jrtjjjj|qSr ) getRPMItemdnfdbrRPMTransactionItemWrapper)r3r4)r r r r5sz+RPMTransaction.__iter__..)rr6rrr7)r r8r )r r r9s   zRPMTransaction.__iter__cs8jrjj}n jjj}fdd|D}t|S)Ncs&g|]}|jrtjjjj|qSr )rTrUrVrrW)r3r4)r r r r5sz*RPMTransaction.__len__..)rr6rrr)r r8r )r r rs   zRPMTransaction.__len__cCsP|jjj}|j|j|j|jp$d|j|j|j |j |j |j |S)Nr) rrZ createRPMItemr;r'ZsetEpochZepochZ setVersionversionZ setReleasereleaseZsetArcharch)r rJrpm_itemr r r _pkg_to_swdb_rpm_items     z$RPMTransaction._pkg_to_swdb_rpm_itemcCsV|j|}|j|}|dkr&|j|}|jjj||||}|rH|j|||j|<|S)N)r\ get_repoid get_reasonrrr addReplacedByrS)r rJrrG replaced_byr[Zrepoidresultr r r r*s     zRPMTransaction.newcCst|dd}|r|S|jS)NZ_force_swdb_repoid)getattrZreponame)r rJrar r r r]s zRPMTransaction.get_repoidcCs|jjj|j|jdS)zGet reason for package)rrrCr'rZ)r rJr r r r^szRPMTransaction.get_reasoncCstjj|j|S)zGet reason for package)rrZTransactionItemReasonToStringr^)r rJr r r get_reason_nameszRPMTransaction.get_reason_namecCs8|pg}x*|D]"}|j|tjj}|r|j|qWdS)N)r*rrTransactionItemAction_OBSOLETEDr_)r obsoletedr`Zobsrr r r _add_obsoleted s  zRPMTransaction._add_obsoletedcCs6|j|tjj}|j|tjj|d}|j||ddS)N)r`)r*rrr$ TransactionItemAction_DOWNGRADEDrh)r r*oldrgti_newti_oldr r r add_downgradeszRPMTransaction.add_downgradecCs|j||dS)N) add_remove)r rjrGr r r add_eraseszRPMTransaction.add_erasecCs4|dkrtjj}|j|tjj|}|j||ddS)N)r`)rrrr*rrh)r r*rgrGrkr r r add_installszRPMTransaction.add_installcCs6|j|tjj}|j|tjj|d}|j||ddS)N)r`)r*rrTransactionItemAction_REINSTALL!TransactionItemAction_REINSTALLEDrh)r r*rjrgrkrlr r r add_reinstallszRPMTransaction.add_reinstallcCs"|p tjj}|j|tjj|}dS)N)rrrr*r )r rjrGrlr r r rn$s zRPMTransaction.add_removecCs6|j|tjj}|j|tjj|d}|j||ddS)N)r`)r*rrr"TransactionItemAction_UPGRADEDrh)r r*rjrgrkrlr r r add_upgrade(szRPMTransaction.add_upgradec Cs^|jr dS|jjrdSy.|drB|j rBtjtdj|dSWntk rXdSXdS)NrZmodularitylabelz\No available modular metadata for modular package '{}', it cannot be installed on the systemrc) Z _from_cmdlineZrepoZmodule_hotfixesZ_is_in_active_modulerZcriticalrformat ValueError)r hdrrJr r r _test_fail_safe-s zRPMTransaction._test_fail_safecCsRd}x0|D]&}y|jtjjkrP|jj}||j||j7}|j||dn|jtjjkrp|j |jj n|jtjj kr|jj}||j||j7}|j||dnL|jtjj kr|jj}||j||j7}|j||dn|jtjj kr|j |jj n|jtjjkr<|jj}||j||j7}|j||n|jtjjkr\|j |jj n|jtjjkr||j |jj nz|jtjjkr|jj}||j||j7}|j||dn@|jtjjkr|j |jj n |jtjjkrntd|jWq tjk r2}ztjjtd|WYdd}~Xq Xq W|rNtjjtd|S)z!Populate the RPM transaction set.rur4z%TransactionItemAction not handled: %szAn rpm exception occurred: %sNz1No available modular metadata for modular package)rrrr$rJZ_headerryZ addInstallriZaddEraseidxrZTransactionItemAction_OBSOLETErfrqZ addReinstallrrr r"rtZ#TransactionItemAction_REASON_CHANGE RuntimeErrorrpmerrorrU exceptionsErrorr)r ZtsZmodular_problemstsirxer r r _populate_rpm_ts;sR*zRPMTransaction._populate_rpm_tsc CsXt}xL|D]D}|jtjjkr y|j|jWq tk rNtd|Yq Xq W|S)Nz*TransactionItem is has no RPM attached: %s) rDrrUrZFORWARD_ACTIONSrFrJKeyErrorr|)r rarr r r install_setms zRPMTransaction.install_setc Csbt}xV|D]N}|jtjjtjjgkr y|j|jWq t k rXt d|Yq Xq W|S)Nz*TransactionItem is has no RPM attached: %s) rDrrUrZBACKWARD_ACTIONSrrrrFrJrr|)r rarr r r remove_setys zRPMTransaction.remove_setcCs,dd|jD}t|r(td|dSdS)zj Ensures all the members can be passed to rpm as they are to perform the transaction. cSsg|]}|jdkr|qS)src)rZ)r3rJr r r r5sz3RPMTransaction._rpm_limitations..z+Will not install a source rpm package (%s).rN)rrr)r Z src_installsr r r _rpm_limitationss  zRPMTransaction._rpm_limitationscsfdd|DS)Ncsg|]}|jkr|qSr )r)r3r)rr r r5sz-RPMTransaction._get_items..r )r rr )rr _get_itemsszRPMTransaction._get_items)N)NN)N)N)N)NN)N)N)N)r.r/r0r r9rr\r*r]r^rerhrmrorprsrnruryrpropertyrrrrr r r r rRs*          2  rR)Zlibdnf.transactionrZdnf.db.historyrUZdnf.transactionZdnf.exceptionsZdnf.i18nrZdnf.utilrr}objectrr1rLrRr r r r s  3<<__pycache__/group.cpython-36.pyc000064400000034130147205106300012535 0ustar003 f<@sddlZddlZddlZddlZddlmZddlm Z ddl Z Gddde Z Gddde Z Gdd d e ZGd d d e ZdS) N)_)loggerc@sleZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS) PersistorBasecCsBt|tjjjs ttt|||_i|_i|_ i|_ i|_ dS)N) isinstancednfdbhistoryZ SwdbInterfaceAssertionErrorstrtype _installed_removed _upgraded _downgraded)selfrr/usr/lib/python3.6/group.py__init__ s  zPersistorBase.__init__cCs(t|jt|jt|jt|jS)N)lenr r rr)rrrr__len__(szPersistorBase.__len__cCsi|_i|_i|_i|_dS)N)r r rr)rrrrclean+szPersistorBase.cleancCstdS)N)NotImplementedError)robjrrr _get_obj_id1szPersistorBase._get_obj_idcCs*|jjj|d|tjj}|jtjjdS)N)rswdbaddItemlibdnf transactionTransactionItemReason_USERZsetStateZTransactionItemState_DONE)ritemactiontirrr_add_to_history4szPersistorBase._add_to_historycCs$||j|j|<|j|tjjdS)N)r rr#rrTransactionItemAction_INSTALL)rrrrrinstall8szPersistorBase.installcCs$||j|j|<|j|tjjdS)N)r rr#rrTransactionItemAction_REMOVE)rrrrrremove<szPersistorBase.removecCs$||j|j|<|j|tjjdS)N)rrr#rrTransactionItemAction_UPGRADE)rrrrrupgrade@szPersistorBase.upgradecCs$||j|j|<|j|tjjdS)N)rrr#rrTransactionItemAction_DOWNGRADE)rrrrr downgradeDszPersistorBase.downgradecCstdS)N)r)robj_idnametranslated_name pkg_typesrrrnewHszPersistorBase.newcCstdS)N)r)rr,rrrgetKszPersistorBase.getcCstdS)N)r)rpatternrrrsearch_by_patternNszPersistorBase.search_by_patternN)__name__ __module__ __qualname__rrrrr#r%r'r)r+r0r1r3rrrrrsrc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)GroupPersistorcCs"|jjj}dd|D}t|S)NcSsg|]}|jr|qSr)getCompsGroupItem).0irrr Vsz+GroupPersistor.__iter__..)rrgetItemsiter)ritemsrrr__iter__Ts zGroupPersistor.__iter__cCs|jS)N) getGroupId)rrrrrrYszGroupPersistor._get_obj_idcCsH|jjj}|j||dk r(|j||dk r:|j||j||S)N)rrZcreateCompsGroupItemZ setGroupIdsetNamesetTranslatedNamesetPackageTypes)rr,r-r.r/ swdb_grouprrrr0\s     zGroupPersistor.newcCs"|jjj|}|sdS|j}|S)N)rrr8)rr,rDrrrr1fs zGroupPersistor.getcCs|jjj|S)N)rrZgetCompsGroupItemsByPattern)rr2rrrr3msz GroupPersistor.search_by_patterncCs|jjj|S)N)rrZgetPackageCompsGroups)rpkg_namerrrget_package_groupspsz!GroupPersistor.get_package_groupscCs|jjj|dd}|tjjkr"dSt|j|}xJ|jj D]<\}}x2|j D]&}|j |kr`qN|j sjqN|j |qNWqZ getPackagesZgetName getInstalledr'r add)rrEreasonZpackage_groupsgroup_idgrouppkgrrris_removable_pkgss*   zGroupPersistor.is_removable_pkgN) r4r5r6r?rr0r1r3rFrQrrrrr7Rs r7c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)EnvironmentPersistorcCs"|jjj}dd|D}t|S)NcSsg|]}|jr|qSr)getCompsEnvironmentItem)r9r:rrrr;sz1EnvironmentPersistor.__iter__..)rrr<r=)rr>rrrr?s zEnvironmentPersistor.__iter__cCs|jS)N)ZgetEnvironmentId)rrrrrrsz EnvironmentPersistor._get_obj_idcCsH|jjj}|j||dk r(|j||dk r:|j||j||S)N)rrZcreateCompsEnvironmentItemZsetEnvironmentIdrArBrC)rr,r-r.r/swdb_envrrrr0s     zEnvironmentPersistor.newcCs"|jjj|}|sdS|j}|S)N)rrrS)rr,rTrrrr1s zEnvironmentPersistor.getcCs|jjj|S)N)rrZ!getCompsEnvironmentItemsByPattern)rr2rrrr3sz&EnvironmentPersistor.search_by_patterncCs|jjj|S)N)rrZgetCompsGroupEnvironments)rrNrrrget_group_environmentssz+EnvironmentPersistor.get_group_environmentscCs|jjj|}|sdSt|j|}xJ|jjD]<\}}x2|jD]&}|j|krTqB|j s^qB|j |qBWq0WxJ|j jD]<\}}x2|jD]&}|j|krq|j sq|j |qWq|W|rdSdS)NFT) rrOr1rJrUr r>Z getGroupsr@rKr'r rL)rrNrDZgroup_environmentsZenv_idenvrOrrris_removable_groups*  z'EnvironmentPersistor.is_removable_groupN) r4r5r6r?rr0r1r3rUrWrrrrrRs rRc@seZdZd,ddZddZddZdd Zd-d d Zd d ZddZ ddZ d.ddZ d/ddZ d0ddZ d1ddZd2ddZd3ddZd4ddZd d!Zd"d#Zed$d%Zed&d'Zd(d)Zd*d+ZdS)5RPMTransactionNc Cs:||_||_|js0y|jjjWn YnXi|_dS)N)rrrZinitTransaction _swdb_ti_pkg)rrrrrrrszRPMTransaction.__init__cs8jrjj}n jjj}fdd|D}t|S)Ncs&g|]}|jrtjjjj|qSr) getRPMItemrrrRPMTransactionItemWrapper)r9r:)rrrr;sz+RPMTransaction.__iter__..)rr<rrr=)rr>r)rrr?s   zRPMTransaction.__iter__cs8jrjj}n jjj}fdd|D}t|S)Ncs&g|]}|jrtjjjj|qSr)rZrrrr[)r9r:)rrrr;sz*RPMTransaction.__len__..)rr<rrr)rr>r)rrrs   zRPMTransaction.__len__cCsP|jjj}|j|j|j|jp$d|j|j|j |j |j |j |S)Nr) rrZ createRPMItemrAr-ZsetEpochZepochZ setVersionversionZ setReleasereleaseZsetArcharch)rrPrpm_itemrrr_pkg_to_swdb_rpm_items     z$RPMTransaction._pkg_to_swdb_rpm_itemcCsV|j|}|j|}|dkr&|j|}|jjj||||}|rH|j|||j|<|S)N)r` get_repoid get_reasonrrr addReplacedByrY)rrPr!rM replaced_byr_Zrepoidresultrrrr0s     zRPMTransaction.newcCst|dd}|r|S|jS)NZ_force_swdb_repoid)getattrZreponame)rrPrerrrras zRPMTransaction.get_repoidcCs|jjj|j|jdS)zGet reason for package)rrrIr-r^)rrPrrrrbszRPMTransaction.get_reasoncCstjj|j|S)zGet reason for package)rrZTransactionItemReasonToStringrb)rrPrrrget_reason_nameszRPMTransaction.get_reason_namecCs8|pg}x*|D]"}|j|tjj}|r|j|qWdS)N)r0rrTransactionItemAction_OBSOLETEDrc)r obsoletedrdZobsr"rrr_add_obsoleted s  zRPMTransaction._add_obsoletedcCs6|j|tjj}|j|tjj|d}|j||ddS)N)rd)r0rrr* TransactionItemAction_DOWNGRADEDrl)rr0oldrkti_newti_oldrrr add_downgradeszRPMTransaction.add_downgradecCs|j||dS)N) add_remove)rrnrMrrr add_eraseszRPMTransaction.add_erasecCs4|dkrtjj}|j|tjj|}|j||ddS)N)rd)rrrr0r$rl)rr0rkrMrorrr add_installszRPMTransaction.add_installcCs6|j|tjj}|j|tjj|d}|j||ddS)N)rd)r0rrTransactionItemAction_REINSTALL!TransactionItemAction_REINSTALLEDrl)rr0rnrkrorprrr add_reinstallszRPMTransaction.add_reinstallcCs"|p tjj}|j|tjj|}dS)N)rrrr0r&)rrnrMrprrrrr$s zRPMTransaction.add_removecCs6|j|tjj}|j|tjj|d}|j||ddS)N)rd)r0rrr(TransactionItemAction_UPGRADEDrl)rr0rnrkrorprrr add_upgrade(szRPMTransaction.add_upgradec Cs^|jr dS|jjrdSy.|drB|j rBtjtdj|dSWntk rXdSXdS)NrZmodularitylabelz\No available modular metadata for modular package '{}', it cannot be installed on the systemrg) Z _from_cmdlineZrepoZmodule_hotfixesZ_is_in_active_modulerZcriticalrformat ValueError)rhdrrPrrr_test_fail_safe-s zRPMTransaction._test_fail_safecCsRd}x0|D]&}y|jtjjkrP|jj}||j||j7}|j||dn|jtjjkrp|j |jj n|jtjj kr|jj}||j||j7}|j||dnL|jtjj kr|jj}||j||j7}|j||dn|jtjj kr|j |jj n|jtjjkr<|jj}||j||j7}|j||n|jtjjkr\|j |jj n|jtjjkr||j |jj nz|jtjjkr|jj}||j||j7}|j||dn@|jtjjkr|j |jj n |jtjjkrntd|jWq tjk r2}ztjjtd|WYdd}~Xq Xq W|rNtjjtd|S)z!Populate the RPM transaction set.rur:z%TransactionItemAction not handled: %szAn rpm exception occurred: %sNz1No available modular metadata for modular package)r!rrr*rPZ_headerr}Z addInstallrmZaddEraseidxr$ZTransactionItemAction_OBSOLETErjruZ addReinstallrvr&r(rxZ#TransactionItemAction_REASON_CHANGE RuntimeErrorrpmerrorr exceptionsErrorr)rZtsZmodular_problemstsir|errr_populate_rpm_ts;sR*zRPMTransaction._populate_rpm_tsc CsXt}xL|D]D}|jtjjkr y|j|jWq tk rNtd|Yq Xq W|S)Nz*TransactionItem is has no RPM attached: %s) rJr!rrZFORWARD_ACTIONSrLrPKeyErrorr)rrerrrr install_setms zRPMTransaction.install_setc Csbt}xV|D]N}|jtjjtjjgkr y|j|jWq t k rXt d|Yq Xq W|S)Nz*TransactionItem is has no RPM attached: %s) rJr!rrZBACKWARD_ACTIONSrrvrLrPrr)rrerrrr remove_setys zRPMTransaction.remove_setcCs,dd|jD}t|r(td|dSdS)zj Ensures all the members can be passed to rpm as they are to perform the transaction. cSsg|]}|jdkr|qS)src)r^)r9rPrrrr;sz3RPMTransaction._rpm_limitations..z+Will not install a source rpm package (%s).rN)rrr)rZ src_installsrrr_rpm_limitationss  zRPMTransaction._rpm_limitationscsfdd|DS)Ncsg|]}|jkr|qSr)r!)r9r)r!rrr;sz-RPMTransaction._get_items..r)rr!r)r!r _get_itemsszRPMTransaction._get_items)N)NN)N)N)N)NN)N)N)N)r4r5r6rr?rr`r0rarbrirlrqrsrtrwrrryr}rpropertyrrrrrrrrrXs*          2  rX)Zlibdnf.transactionrZdnf.db.historyrZdnf.transactionZdnf.exceptionsZdnf.i18nrZdnf.utilrrobjectrr7rRrXrrrrs  3<<__pycache__/history.cpython-36.opt-1.pyc000064400000043250147205106300014044 0ustar003 ft`%:@sddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZmZGdddeZGd d d eZGd d d eZGd ddeZdS)N)ucd)misc) DatabaseError)GroupPersistorEnvironmentPersistorRPMTransactionc@sjeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ eddZeddZeddZeddZedd Zed!d"Zed#d$Zed%d&Zejd'd&Zed(d)Zejd*d)Zed+d,Zed-d.Zed/d0Zejd1d0Zed2d3Zd4d5Zed6d7Zd8d9Zed:d;Z edd?Z"d@S)ARPMTransactionItemWrappercCs||_||_dS)N)_swdb_item)selfswdbitemr/usr/lib/python3.6/history.py__init__#sz"RPMTransactionItemWrapper.__init__cCs|jjjS)N)r ZgetItemZtoStr)r rrr__str__(sz!RPMTransactionItemWrapper.__str__cCs |j|jkS)N)r )r otherrrr__lt__+sz RPMTransactionItemWrapper.__lt__cCs |j|jkS)N)r )r rrrr__eq__.sz RPMTransactionItemWrapper.__eq__cCs |jjS)N)r __hash__)r rrrr1sz"RPMTransactionItemWrapper.__hash__cCsdS)NTr)r patternrrrmatch4szRPMTransactionItemWrapper.matchcCs|jjdk S)N)r getRPMItem)r rrr is_package7sz$RPMTransactionItemWrapper.is_packagecCs|jjdk S)N)r getCompsGroupItem)r rrris_group:sz"RPMTransactionItemWrapper.is_groupcCs|jjdk S)N)r getCompsEnvironmentItem)r rrris_environment=sz(RPMTransactionItemWrapper.is_environmentcCs |jjS)N)r r)r rrr get_group@sz#RPMTransactionItemWrapper.get_groupcCs |jjS)N)r r)r rrrget_environmentCsz)RPMTransactionItemWrapper.get_environmentcCs|jjjS)N)r rZgetName)r rrrnameFszRPMTransactionItemWrapper.namecCs|jjjS)N)r rZgetEpoch)r rrrepochJszRPMTransactionItemWrapper.epochcCs|jjjS)N)r rZ getVersion)r rrrversionNsz!RPMTransactionItemWrapper.versioncCs|jjjS)N)r rZ getRelease)r rrrreleaseRsz!RPMTransactionItemWrapper.releasecCs|jjjS)N)r rZgetArch)r rrrarchVszRPMTransactionItemWrapper.archcCs*|jrdj|j|j|jSdj|j|jS)Nz{}:{}-{}z{}-{})r"formatr#r$)r rrrevrZszRPMTransactionItemWrapper.evrcCs|jjjS)N)r rZgetNEVRA)r rrrnevra`szRPMTransactionItemWrapper.nevracCs |jjS)N)r Z getAction)r rrractiondsz RPMTransactionItemWrapper.actioncCs|jj|dS)N)r Z setAction)r valuerrrr)hscCs |jjS)N)r Z getReason)r rrrreasonlsz RPMTransactionItemWrapper.reasoncCs |jj|S)N)r Z setReason)r r*rrrr+psc Cs$y |jjStk rdSXdS)N)r Z getActionNameAttributeError)r rrr action_namets z%RPMTransactionItemWrapper.action_namec Cs$y |jjStk rdSXdS)Nr,)r ZgetActionShortr-)r rrr action_short{s z&RPMTransactionItemWrapper.action_shortcCs |jjS)N)r getState)r rrrstateszRPMTransactionItemWrapper.statecCs|jj|dS)N)r setState)r r*rrrr1scCs |jjS)N)r getRepoid)r rrr from_reposz#RPMTransactionItemWrapper.from_repocCs|jjsdSd|jjS)Nr,@)r r3)r rrr ui_from_repos z&RPMTransactionItemWrapper.ui_from_repocCsdS)Nr)r rrr obsoletingsz$RPMTransactionItemWrapper.obsoletingcCs|jjj|S)N)r rpm get_reason)r rrrr9sz$RPMTransactionItemWrapper.get_reasoncCs|jjj|jS)N)r r8Z _swdb_ti_pkgr )r rrrpkgszRPMTransactionItemWrapper.pkgcCs|jjS)N)r:files)r rrrr;szRPMTransactionItemWrapper.filescCs|jS)N)r:)r rrr_activesz!RPMTransactionItemWrapper._activeN)#__name__ __module__ __qualname__rrrrrrrrrrr propertyr!r"r#r$r%r'r(r)setterr+r.r/r1r4r6r7r9r:r;r<rrrrr "sB                r c@seZdZdZdZddZeddZeddZedd Z ed d Z ed d Z eddZ eddZ eddZeddZeddZeddZeddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(S))TransactionWrapperFcCs ||_dS)N)_trans)r transrrrrszTransactionWrapper.__init__cCs |jjS)N)rCgetId)r rrrtidszTransactionWrapper.tidcCs |jjS)N)rCZ getCmdline)r rrrcmdlineszTransactionWrapper.cmdlinecCs |jjS)N)rCZ getReleasever)r rrr releaseverszTransactionWrapper.releasevercCs |jjS)N)rCZ getDtBegin)r rrr beg_timestampsz TransactionWrapper.beg_timestampcCs |jjS)N)rCZgetDtEnd)r rrr end_timestampsz TransactionWrapper.end_timestampcCs |jjS)N)rCgetRpmdbVersionBegin)r rrrbeg_rpmdb_versionsz$TransactionWrapper.beg_rpmdb_versioncCs |jjS)N)rCgetRpmdbVersionEnd)r rrrend_rpmdb_versionsz$TransactionWrapper.end_rpmdb_versioncCst|jjtjjkS)N)intrCr0libdnf transactionTransactionItemState_DONE)r rrr return_codeszTransactionWrapper.return_codecCs |jjS)N)rCZ getUserId)r rrrloginuidszTransactionWrapper.loginuidcCs|jS)N)packages)r rrrdataszTransactionWrapper.datacCs|jj}t|S)N)rCgetConsoleOutputbool)r outputrrr is_outputs zTransactionWrapper.is_outputcCs |jjS)N)rCZ getComment)r rrrcommentszTransactionWrapper.commentcCs |jjgS)N)rCrE)r rrrtidsszTransactionWrapper.tidscCsgS)Nr)r rrrperformed_withsz!TransactionWrapper.performed_withcsjj}fdd|DS)Ncsg|]}t|qSr)r ).0i)r rr sz/TransactionWrapper.packages..)rCZgetItems)r resultr)r rrUs zTransactionWrapper.packagescCsdd|jjDS)NcSsg|] }|dqS)rr)r^r_rrrr`sz-TransactionWrapper.output..)rCrW)r rrrrYszTransactionWrapper.outputcCsgS)Nr)r rrrerrorszTransactionWrapper.errorcCs|jj|k|_dS)N)rCrMaltered_gt_rpmdb)r Zrpmdbvrrrcompare_rpmdbvsz!TransactionWrapper.compare_rpmdbvN)r=r>r?altered_lt_rpmdbrcrr@rFrGrHrIrJrLrNrSrTrVrZr[r\r]rUrYrbrdrrrrrBs*            rBc@sheZdZddZddZeddZddZed d Zed d Z ed dZ eddZ ddZ dS)MergedTransactionWrappercCstjj|j|_dS)N)rPrQZMergedTransactionrC)r rDrrrrsz!MergedTransactionWrapper.__init__cCs|jj|jdS)N)rCmerge)r rDrrrrgszMergedTransactionWrapper.mergecCs |jjS)N)rCZ listUserIds)r rrrrTsz!MergedTransactionWrapper.loginuidcCs |jjS)N)rCZlistIds)r rrrr\szMergedTransactionWrapper.tidscCsdd|jjDS)NcSsg|]}t|tjjkqSr)rOrPrQrR)r^r_rrrr`sz8MergedTransactionWrapper.return_code..)rCZ listStates)r rrrrSsz$MergedTransactionWrapper.return_codecCs |jjS)N)rCZ listCmdlines)r rrrrGsz MergedTransactionWrapper.cmdlinecCs |jjS)N)rCZlistReleasevers)r rrrrH sz#MergedTransactionWrapper.releasevercCs |jjS)N)rCZ listComments)r rrrr[sz MergedTransactionWrapper.commentcCsdd|jjDS)NcSsg|] }|dqS)rr)r^r_rrrr`sz3MergedTransactionWrapper.output..)rCrW)r rrrrYszMergedTransactionWrapper.outputN) r=r>r?rrgr@rTr\rSrGrHr[rYrrrrrfs     rfc@seZdZd6ddZddZeddZedd Zed d Zed d Z eddZ ddZ ddZ eddZ ddZd7ddZd8ddZd d!Zd"d#Zd$d%Zd&d'Zd9d(d)Zd*d+Zd,d-Zd:d.d/Zd;d0d1Zd2d3Zd4d5ZdS)< SwdbInterfacer,cCs8t||_d|_d|_d|_d|_d|_||_g|_dS)N) strrH_rpm_group_envZ _addon_datar _db_dir_output)r Zdb_dirrHrrrrs zSwdbInterface.__init__cCs |jdS)N)close)r rrr__del__%szSwdbInterface.__del__cCs|jdkrt||_|jS)N)rjr)r rrrr8(s  zSwdbInterface.rpmcCs|jdkrt||_|jS)N)rkr)r rrrgroup.s  zSwdbInterface.groupcCs|jdkrt||_|jS)N)rlr)r rrrenv4s  zSwdbInterface.envcCstjj|jtjjjS)N)ospathjoinrmrPrQSwdbZdefaultDatabaseName)r rrrdbpath:szSwdbInterface.dbpathcCsZ|jsTytjj|j|_Wn.tk rH}ztt|WYdd}~XnX|jj|jS)z Lazy initialize Swdb object N) r rPrQrvrw RuntimeErrorrriinitTransaction)r Zexrrrr >s zSwdbInterface.swdbcCstjj||j}|jdS)N)rPrQZ Transformerrw transform)r Z input_dirZ transformerrrrrzKszSwdbInterface.transformc CsZy|`Wntk rYnXd|_d|_d|_|jrJ|jj|jjd|_g|_dS)N) _tidr-rjrkrlr ZcloseTransactionZ closeDatabasern)r rrrroOs  zSwdbInterface.closecCs |jjS)N)r ZgetPath)r rrrrt]szSwdbInterface.pathcCs |jjS)N)r Z resetDatabase)r rrrreset_dbaszSwdbInterface.reset_dbTcCs|jj}|sdSt|S)N)r ZgetLastTransactionrB)r complete_transactions_onlytrrrlastes zSwdbInterface.lastNrFcspgddD|jj}dd|D}rDfdd|D}xJt|D]>\}}|dkr`qN||d}|jj|jjkrNd|_d|_qNW|dddS) NcSsg|] }t|qSr)rO)r^r_rrrr`osz%SwdbInterface.old..cSsg|] }t|qSr)rB)r^r_rrrr`qscsg|]}|jkr|qSr)rF)r^r_)r\rrr`tsrrT)r ZlistTransactions enumeraterCrKrMrerc)r r\limitr}rar_rDZ prev_transr)r\roldms   zSwdbInterface.oldcCst|jjS)N)rBr Z getCurrent)r rrr get_currentszSwdbInterface.get_currentcCsB|jj|}|j|}tjj}|jj||||}|jtjj |S)zSet reason for package) r8Z_pkg_to_swdb_rpm_itemreporPrQZ#TransactionItemAction_REASON_CHANGEr ZaddItemr2rR)r r:r+rpm_itemZrepoidr)Ztirrr set_reasons   zSwdbInterface.set_reasoncCs|jjt|S)zGet repository of package)r Z getRPMRepori)r r:rrrrszSwdbInterface.repocCs*|jjt|}|dkr|St||}|S)zGet package data for packageN)r ZgetRPMTransactionItemrir )r r:rarrr package_datas  zSwdbInterface.package_datac Csfy|jjWn YnX|jjttjtjt||p>dtt j |}|jj |j ||_ |S)Nr,)r ryZbeginTransactionrOcalendarZtimegmtimeZgmtimerirZ getloginuidZ setReleaseverrHr{)r Z rpmdb_versionZ using_pkgsZtsisrGr[rFrrrbegs zSwdbInterface.begcCsN|jj}|j|j|j|jp"d|j|j|j|j |j |j |S)Nr) r Z createRPMItemZsetNamer!ZsetEpochr"Z setVersionr#Z setReleaser$ZsetArchr%)r Zporrrrpkg_to_swdb_rpm_items     z"SwdbInterface.pkg_to_swdb_rpm_itemcCsDt|dsdS|sdSx(|jD]}t|}|jjd|fq WdS)Nr{r)hasattr splitlinesrrnappend)r msglinerrrlog_scriptlet_outputs z"SwdbInterface.log_scriptlet_outputcCst|dsdS|dkrFtjj}x&|jD]}|jtjjkr&tjj}Pq&Wx |jD]\}}|j j ||qNWg|_|j j t t j t||dS)Nr{)rrPrQZTransactionState_DONEr8r1ZTransactionItemState_ERRORZTransactionState_ERRORrnr ZaddConsoleOutputLineZendTransactionrOrri)r rNrSerrorsZtsiZfile_descriptorrrrrends   zSwdbInterface.endcCs |jj|S)z{ Search for history transactions which contain specified packages al. la. "yum list". Returns transaction ids. )r ZsearchTransactionsByRPM)r ZpatternsZ ignore_caserrrsearchszSwdbInterface.searchcCs8|jj|j|jd}|tjjkr$dS|tjjkr4dSdS)z)Returns True if package is user installedrTFr)r resolveRPMTransactionItemReasonr!r%rPrQTransactionItemReason_USERTransactionItemReason_UNKNOWN)r r:r+rrruser_installeds   zSwdbInterface.user_installedcCsF|r|jj|j|j|}n|jj|j|jd}|tjjkrBtjj}|S)a2Get reason of package before transaction being undone. If package is already installed in the system, keep his reason. :param pkg: package being installed :param first_trans: id of first transaction being undone :param rollback: True if transaction is performing a rollbackrr)r rr!r%rPrQrr)r r:Z first_transZrollbackrarrrget_erased_reasons  zSwdbInterface.get_erased_reason)r,)T)NrF)Nr,)r,NN)T)r=r>r?rrpr@r8rqrrrwr rzrortr|rrrrrrrrrrrrrrrrrrhs0              rh)rrsrZlibdnf.transactionrPZ libdnf.utilsZdnf.i18nrZdnf.yumrZdnf.exceptionsrrqrrrobjectr rBrfrhrrrrs   M"__pycache__/history.cpython-36.pyc000064400000043306147205106300013107 0ustar003 ft`%:@sddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZmZGdddeZGd d d eZGd d d eZGd ddeZdS)N)ucd)misc) DatabaseError)GroupPersistorEnvironmentPersistorRPMTransactionc@sjeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ eddZeddZeddZeddZedd Zed!d"Zed#d$Zed%d&Zejd'd&Zed(d)Zejd*d)Zed+d,Zed-d.Zed/d0Zejd1d0Zed2d3Zd4d5Zed6d7Zd8d9Zed:d;Z edd?Z"d@S)ARPMTransactionItemWrappercCs|dk s t||_||_dS)N)AssertionError_swdb_item)selfswdbitemr/usr/lib/python3.6/history.py__init__#s z"RPMTransactionItemWrapper.__init__cCs|jjjS)N)r ZgetItemZtoStr)r rrr__str__(sz!RPMTransactionItemWrapper.__str__cCs |j|jkS)N)r )r otherrrr__lt__+sz RPMTransactionItemWrapper.__lt__cCs |j|jkS)N)r )r rrrr__eq__.sz RPMTransactionItemWrapper.__eq__cCs |jjS)N)r __hash__)r rrrr1sz"RPMTransactionItemWrapper.__hash__cCsdS)NTr)r patternrrrmatch4szRPMTransactionItemWrapper.matchcCs|jjdk S)N)r getRPMItem)r rrr is_package7sz$RPMTransactionItemWrapper.is_packagecCs|jjdk S)N)r getCompsGroupItem)r rrris_group:sz"RPMTransactionItemWrapper.is_groupcCs|jjdk S)N)r getCompsEnvironmentItem)r rrris_environment=sz(RPMTransactionItemWrapper.is_environmentcCs |jjS)N)r r)r rrr get_group@sz#RPMTransactionItemWrapper.get_groupcCs |jjS)N)r r)r rrrget_environmentCsz)RPMTransactionItemWrapper.get_environmentcCs|jjjS)N)r rZgetName)r rrrnameFszRPMTransactionItemWrapper.namecCs|jjjS)N)r rZgetEpoch)r rrrepochJszRPMTransactionItemWrapper.epochcCs|jjjS)N)r rZ getVersion)r rrrversionNsz!RPMTransactionItemWrapper.versioncCs|jjjS)N)r rZ getRelease)r rrrreleaseRsz!RPMTransactionItemWrapper.releasecCs|jjjS)N)r rZgetArch)r rrrarchVszRPMTransactionItemWrapper.archcCs*|jrdj|j|j|jSdj|j|jS)Nz{}:{}-{}z{}-{})r#formatr$r%)r rrrevrZszRPMTransactionItemWrapper.evrcCs|jjjS)N)r rZgetNEVRA)r rrrnevra`szRPMTransactionItemWrapper.nevracCs |jjS)N)r Z getAction)r rrractiondsz RPMTransactionItemWrapper.actioncCs|jj|dS)N)r Z setAction)r valuerrrr*hscCs |jjS)N)r Z getReason)r rrrreasonlsz RPMTransactionItemWrapper.reasoncCs |jj|S)N)r Z setReason)r r+rrrr,psc Cs$y |jjStk rdSXdS)N)r Z getActionNameAttributeError)r rrr action_namets z%RPMTransactionItemWrapper.action_namec Cs$y |jjStk rdSXdS)Nr-)r ZgetActionShortr.)r rrr action_short{s z&RPMTransactionItemWrapper.action_shortcCs |jjS)N)r getState)r rrrstateszRPMTransactionItemWrapper.statecCs|jj|dS)N)r setState)r r+rrrr2scCs |jjS)N)r getRepoid)r rrr from_reposz#RPMTransactionItemWrapper.from_repocCs|jjsdSd|jjS)Nr-@)r r4)r rrr ui_from_repos z&RPMTransactionItemWrapper.ui_from_repocCsdS)Nr)r rrr obsoletingsz$RPMTransactionItemWrapper.obsoletingcCs|jjj|S)N)r rpm get_reason)r rrrr:sz$RPMTransactionItemWrapper.get_reasoncCs|jjj|jS)N)r r9Z _swdb_ti_pkgr )r rrrpkgszRPMTransactionItemWrapper.pkgcCs|jjS)N)r;files)r rrrr<szRPMTransactionItemWrapper.filescCs|jS)N)r;)r rrr_activesz!RPMTransactionItemWrapper._activeN)#__name__ __module__ __qualname__rrrrrrrrrr r!propertyr"r#r$r%r&r(r)r*setterr,r/r0r2r5r7r8r:r;r<r=rrrrr "sB                r c@seZdZdZdZddZeddZeddZedd Z ed d Z ed d Z eddZ eddZ eddZeddZeddZeddZeddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(S))TransactionWrapperFcCs ||_dS)N)_trans)r transrrrrszTransactionWrapper.__init__cCs |jjS)N)rDgetId)r rrrtidszTransactionWrapper.tidcCs |jjS)N)rDZ getCmdline)r rrrcmdlineszTransactionWrapper.cmdlinecCs |jjS)N)rDZ getReleasever)r rrr releaseverszTransactionWrapper.releasevercCs |jjS)N)rDZ getDtBegin)r rrr beg_timestampsz TransactionWrapper.beg_timestampcCs |jjS)N)rDZgetDtEnd)r rrr end_timestampsz TransactionWrapper.end_timestampcCs |jjS)N)rDgetRpmdbVersionBegin)r rrrbeg_rpmdb_versionsz$TransactionWrapper.beg_rpmdb_versioncCs |jjS)N)rDgetRpmdbVersionEnd)r rrrend_rpmdb_versionsz$TransactionWrapper.end_rpmdb_versioncCst|jjtjjkS)N)intrDr1libdnf transactionTransactionItemState_DONE)r rrr return_codeszTransactionWrapper.return_codecCs |jjS)N)rDZ getUserId)r rrrloginuidszTransactionWrapper.loginuidcCs|jS)N)packages)r rrrdataszTransactionWrapper.datacCs|jj}t|S)N)rDgetConsoleOutputbool)r outputrrr is_outputs zTransactionWrapper.is_outputcCs |jjS)N)rDZ getComment)r rrrcommentszTransactionWrapper.commentcCs |jjgS)N)rDrF)r rrrtidsszTransactionWrapper.tidscCsgS)Nr)r rrrperformed_withsz!TransactionWrapper.performed_withcsjj}fdd|DS)Ncsg|]}t|qSr)r ).0i)r rr sz/TransactionWrapper.packages..)rDZgetItems)r resultr)r rrVs zTransactionWrapper.packagescCsdd|jjDS)NcSsg|] }|dqS)rr)r_r`rrrrasz-TransactionWrapper.output..)rDrX)r rrrrZszTransactionWrapper.outputcCsgS)Nr)r rrrerrorszTransactionWrapper.errorcCs|jj|k|_dS)N)rDrNaltered_gt_rpmdb)r Zrpmdbvrrrcompare_rpmdbvsz!TransactionWrapper.compare_rpmdbvN)r>r?r@altered_lt_rpmdbrdrrArGrHrIrJrKrMrOrTrUrWr[r\r]r^rVrZrcrerrrrrCs*            rCc@sheZdZddZddZeddZddZed d Zed d Z ed dZ eddZ ddZ dS)MergedTransactionWrappercCstjj|j|_dS)N)rQrRZMergedTransactionrD)r rErrrrsz!MergedTransactionWrapper.__init__cCs|jj|jdS)N)rDmerge)r rErrrrhszMergedTransactionWrapper.mergecCs |jjS)N)rDZ listUserIds)r rrrrUsz!MergedTransactionWrapper.loginuidcCs |jjS)N)rDZlistIds)r rrrr]szMergedTransactionWrapper.tidscCsdd|jjDS)NcSsg|]}t|tjjkqSr)rPrQrRrS)r_r`rrrrasz8MergedTransactionWrapper.return_code..)rDZ listStates)r rrrrTsz$MergedTransactionWrapper.return_codecCs |jjS)N)rDZ listCmdlines)r rrrrHsz MergedTransactionWrapper.cmdlinecCs |jjS)N)rDZlistReleasevers)r rrrrI sz#MergedTransactionWrapper.releasevercCs |jjS)N)rDZ listComments)r rrrr\sz MergedTransactionWrapper.commentcCsdd|jjDS)NcSsg|] }|dqS)rr)r_r`rrrrasz3MergedTransactionWrapper.output..)rDrX)r rrrrZszMergedTransactionWrapper.outputN) r>r?r@rrhrArUr]rTrHrIr\rZrrrrrgs     rgc@seZdZd6ddZddZeddZedd Zed d Zed d Z eddZ ddZ ddZ eddZ ddZd7ddZd8ddZd d!Zd"d#Zd$d%Zd&d'Zd9d(d)Zd*d+Zd,d-Zd:d.d/Zd;d0d1Zd2d3Zd4d5ZdS)< SwdbInterfacer-cCs8t||_d|_d|_d|_d|_d|_||_g|_dS)N) strrI_rpm_group_envZ _addon_datar _db_dir_output)r Zdb_dirrIrrrrs zSwdbInterface.__init__cCs |jdS)N)close)r rrr__del__%szSwdbInterface.__del__cCs|jdkrt||_|jS)N)rkr)r rrrr9(s  zSwdbInterface.rpmcCs|jdkrt||_|jS)N)rlr)r rrrgroup.s  zSwdbInterface.groupcCs|jdkrt||_|jS)N)rmr)r rrrenv4s  zSwdbInterface.envcCstjj|jtjjjS)N)ospathjoinrnrQrRSwdbZdefaultDatabaseName)r rrrdbpath:szSwdbInterface.dbpathcCsZ|jsTytjj|j|_Wn.tk rH}ztt|WYdd}~XnX|jj|jS)z Lazy initialize Swdb object N) r rQrRrwrx RuntimeErrorrrjinitTransaction)r Zexrrrr>s zSwdbInterface.swdbcCstjj||j}|jdS)N)rQrRZ Transformerrx transform)r Z input_dirZ transformerrrrr{KszSwdbInterface.transformc CsZy|`Wntk rYnXd|_d|_d|_|jrJ|jj|jjd|_g|_dS)N) _tidr.rkrlrmr ZcloseTransactionZ closeDatabasero)r rrrrpOs  zSwdbInterface.closecCs |jjS)N)rZgetPath)r rrrru]szSwdbInterface.pathcCs |jjS)N)rZ resetDatabase)r rrrreset_dbaszSwdbInterface.reset_dbTcCs|jj}|sdSt|S)N)rZgetLastTransactionrC)r complete_transactions_onlytrrrlastes zSwdbInterface.lastNrFcspgddD|jj}dd|D}rDfdd|D}xJt|D]>\}}|dkr`qN||d}|jj|jjkrNd|_d|_qNW|dddS) NcSsg|] }t|qSr)rP)r_r`rrrraosz%SwdbInterface.old..cSsg|] }t|qSr)rC)r_r`rrrraqscsg|]}|jkr|qSr)rG)r_r`)r]rrratsrrT)rZlistTransactions enumeraterDrLrNrfrd)r r]limitr~rbr`rEZ prev_transr)r]roldms   zSwdbInterface.oldcCst|jjS)N)rCrZ getCurrent)r rrr get_currentszSwdbInterface.get_currentcCsB|jj|}|j|}tjj}|jj||||}|jtjj |S)zSet reason for package) r9Z_pkg_to_swdb_rpm_itemreporQrRZ#TransactionItemAction_REASON_CHANGErZaddItemr3rS)r r;r,rpm_itemZrepoidr*Ztirrr set_reasons   zSwdbInterface.set_reasoncCs|jjt|S)zGet repository of package)rZ getRPMReporj)r r;rrrrszSwdbInterface.repocCs*|jjt|}|dkr|St||}|S)zGet package data for packageN)rZgetRPMTransactionItemrjr )r r;rbrrr package_datas  zSwdbInterface.package_datac Csfy|jjWn YnX|jjttjtjt||p>dtt j |}|jj |j ||_ |S)Nr-)rrzZbeginTransactionrPcalendarZtimegmtimeZgmtimerjrZ getloginuidZ setReleaseverrIr|)r Z rpmdb_versionZ using_pkgsZtsisrHr\rGrrrbegs zSwdbInterface.begcCsN|jj}|j|j|j|jp"d|j|j|j|j |j |j |S)Nr) rZ createRPMItemZsetNamer"ZsetEpochr#Z setVersionr$Z setReleaser%ZsetArchr&)r Zporrrrpkg_to_swdb_rpm_items     z"SwdbInterface.pkg_to_swdb_rpm_itemcCsDt|dsdS|sdSx(|jD]}t|}|jjd|fq WdS)Nr|r)hasattr splitlinesrroappend)r msglinerrrlog_scriptlet_outputs z"SwdbInterface.log_scriptlet_outputcCst|dsdS|dkrFtjj}x&|jD]}|jtjjkr&tjj}Pq&Wx |jD]\}}|j j ||qNWg|_|j j t t j t||dS)Nr|)rrQrRZTransactionState_DONEr9r2ZTransactionItemState_ERRORZTransactionState_ERRORrorZaddConsoleOutputLineZendTransactionrPrrj)r rOrTerrorsZtsiZfile_descriptorrrrrends   zSwdbInterface.endcCs |jj|S)z{ Search for history transactions which contain specified packages al. la. "yum list". Returns transaction ids. )rZsearchTransactionsByRPM)r ZpatternsZ ignore_caserrrsearchszSwdbInterface.searchcCs8|jj|j|jd}|tjjkr$dS|tjjkr4dSdS)z)Returns True if package is user installedrTFr)rresolveRPMTransactionItemReasonr"r&rQrRTransactionItemReason_USERTransactionItemReason_UNKNOWN)r r;r,rrruser_installeds   zSwdbInterface.user_installedcCsF|r|jj|j|j|}n|jj|j|jd}|tjjkrBtjj}|S)a2Get reason of package before transaction being undone. If package is already installed in the system, keep his reason. :param pkg: package being installed :param first_trans: id of first transaction being undone :param rollback: True if transaction is performing a rollbackrr)rrr"r&rQrRrr)r r;Z first_transZrollbackrbrrrget_erased_reasons  zSwdbInterface.get_erased_reason)r-)T)NrF)Nr-)r-NN)T)r>r?r@rrqrAr9rrrsrxrr{rprur}rrrrrrrrrrrrrrrrrris0              ri)rrtrZlibdnf.transactionrQZ libdnf.utilsZdnf.i18nrZdnf.yumrZdnf.exceptionsrrrrrrobjectr rCrgrirrrrs   M"__init__.py000064400000001412147205106300006651 0ustar00# Copyright (C) 2017 Red Hat, Inc. # # DNF database subpackage # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. group.py000064400000036206147205106300006257 0ustar00# -*- coding: utf-8 -*- # Copyright (C) 2017-2018 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # import libdnf.transaction import dnf.db.history import dnf.transaction import dnf.exceptions from dnf.i18n import _ from dnf.util import logger import rpm class PersistorBase(object): def __init__(self, history): assert isinstance(history, dnf.db.history.SwdbInterface), str(type(history)) self.history = history self._installed = {} self._removed = {} self._upgraded = {} self._downgraded = {} def __len__(self): return len(self._installed) + len(self._removed) + len(self._upgraded) + len(self._downgraded) def clean(self): self._installed = {} self._removed = {} self._upgraded = {} self._downgraded = {} def _get_obj_id(self, obj): raise NotImplementedError def _add_to_history(self, item, action): ti = self.history.swdb.addItem(item, "", action, libdnf.transaction.TransactionItemReason_USER) ti.setState(libdnf.transaction.TransactionItemState_DONE) def install(self, obj): self._installed[self._get_obj_id(obj)] = obj self._add_to_history(obj, libdnf.transaction.TransactionItemAction_INSTALL) def remove(self, obj): self._removed[self._get_obj_id(obj)] = obj self._add_to_history(obj, libdnf.transaction.TransactionItemAction_REMOVE) def upgrade(self, obj): self._upgraded[self._get_obj_id(obj)] = obj self._add_to_history(obj, libdnf.transaction.TransactionItemAction_UPGRADE) def downgrade(self, obj): self._downgraded[self._get_obj_id(obj)] = obj self._add_to_history(obj, libdnf.transaction.TransactionItemAction_DOWNGRADE) def new(self, obj_id, name, translated_name, pkg_types): raise NotImplementedError def get(self, obj_id): raise NotImplementedError def search_by_pattern(self, pattern): raise NotImplementedError class GroupPersistor(PersistorBase): def __iter__(self): items = self.history.swdb.getItems() items = [i for i in items if i.getCompsGroupItem()] return iter(items) def _get_obj_id(self, obj): return obj.getGroupId() def new(self, obj_id, name, translated_name, pkg_types): swdb_group = self.history.swdb.createCompsGroupItem() swdb_group.setGroupId(obj_id) if name is not None: swdb_group.setName(name) if translated_name is not None: swdb_group.setTranslatedName(translated_name) swdb_group.setPackageTypes(pkg_types) return swdb_group def get(self, obj_id): swdb_group = self.history.swdb.getCompsGroupItem(obj_id) if not swdb_group: return None swdb_group = swdb_group.getCompsGroupItem() return swdb_group def search_by_pattern(self, pattern): return self.history.swdb.getCompsGroupItemsByPattern(pattern) def get_package_groups(self, pkg_name): return self.history.swdb.getPackageCompsGroups(pkg_name) def is_removable_pkg(self, pkg_name): # for group removal and autoremove reason = self.history.swdb.resolveRPMTransactionItemReason(pkg_name, "", -2) if reason != libdnf.transaction.TransactionItemReason_GROUP: return False # TODO: implement lastTransId == -2 in libdnf package_groups = set(self.get_package_groups(pkg_name)) for group_id, group in self._removed.items(): for pkg in group.getPackages(): if pkg.getName() != pkg_name: continue if not pkg.getInstalled(): continue package_groups.remove(group_id) for group_id, group in self._installed.items(): for pkg in group.getPackages(): if pkg.getName() != pkg_name: continue if not pkg.getInstalled(): continue package_groups.add(group_id) if package_groups: return False return True class EnvironmentPersistor(PersistorBase): def __iter__(self): items = self.history.swdb.getItems() items = [i for i in items if i.getCompsEnvironmentItem()] return iter(items) def _get_obj_id(self, obj): return obj.getEnvironmentId() def new(self, obj_id, name, translated_name, pkg_types): swdb_env = self.history.swdb.createCompsEnvironmentItem() swdb_env.setEnvironmentId(obj_id) if name is not None: swdb_env.setName(name) if translated_name is not None: swdb_env.setTranslatedName(translated_name) swdb_env.setPackageTypes(pkg_types) return swdb_env def get(self, obj_id): swdb_env = self.history.swdb.getCompsEnvironmentItem(obj_id) if not swdb_env: return None swdb_env = swdb_env.getCompsEnvironmentItem() return swdb_env def search_by_pattern(self, pattern): return self.history.swdb.getCompsEnvironmentItemsByPattern(pattern) def get_group_environments(self, group_id): return self.history.swdb.getCompsGroupEnvironments(group_id) def is_removable_group(self, group_id): # for environment removal swdb_group = self.history.group.get(group_id) if not swdb_group: return False # TODO: implement lastTransId == -2 in libdnf group_environments = set(self.get_group_environments(group_id)) for env_id, env in self._removed.items(): for group in env.getGroups(): if group.getGroupId() != group_id: continue if not group.getInstalled(): continue group_environments.remove(env_id) for env_id, env in self._installed.items(): for group in env.getGroups(): if group.getGroupId() != group_id: continue if not group.getInstalled(): continue group_environments.add(env_id) if group_environments: return False return True class RPMTransaction(object): def __init__(self, history, transaction=None): self.history = history self.transaction = transaction if not self.transaction: try: self.history.swdb.initTransaction() except: pass self._swdb_ti_pkg = {} # TODO: close trans if needed def __iter__(self): # :api if self.transaction: items = self.transaction.getItems() else: items = self.history.swdb.getItems() items = [dnf.db.history.RPMTransactionItemWrapper(self.history, i) for i in items if i.getRPMItem()] return iter(items) def __len__(self): if self.transaction: items = self.transaction.getItems() else: items = self.history.swdb.getItems() items = [dnf.db.history.RPMTransactionItemWrapper(self.history, i) for i in items if i.getRPMItem()] return len(items) def _pkg_to_swdb_rpm_item(self, pkg): rpm_item = self.history.swdb.createRPMItem() rpm_item.setName(pkg.name) rpm_item.setEpoch(pkg.epoch or 0) rpm_item.setVersion(pkg.version) rpm_item.setRelease(pkg.release) rpm_item.setArch(pkg.arch) return rpm_item def new(self, pkg, action, reason=None, replaced_by=None): rpm_item = self._pkg_to_swdb_rpm_item(pkg) repoid = self.get_repoid(pkg) if reason is None: reason = self.get_reason(pkg) result = self.history.swdb.addItem(rpm_item, repoid, action, reason) if replaced_by: result.addReplacedBy(replaced_by) self._swdb_ti_pkg[result] = pkg return result def get_repoid(self, pkg): result = getattr(pkg, "_force_swdb_repoid", None) if result: return result return pkg.reponame def get_reason(self, pkg): """Get reason for package""" return self.history.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1) def get_reason_name(self, pkg): """Get reason for package""" return libdnf.transaction.TransactionItemReasonToString(self.get_reason(pkg)) def _add_obsoleted(self, obsoleted, replaced_by=None): obsoleted = obsoleted or [] for obs in obsoleted: ti = self.new(obs, libdnf.transaction.TransactionItemAction_OBSOLETED) if replaced_by: ti.addReplacedBy(replaced_by) def add_downgrade(self, new, old, obsoleted=None): ti_new = self.new(new, libdnf.transaction.TransactionItemAction_DOWNGRADE) ti_old = self.new(old, libdnf.transaction.TransactionItemAction_DOWNGRADED, replaced_by=ti_new) self._add_obsoleted(obsoleted, replaced_by=ti_new) def add_erase(self, old, reason=None): self.add_remove(old, reason) def add_install(self, new, obsoleted=None, reason=None): if reason is None: reason = libdnf.transaction.TransactionItemReason_USER ti_new = self.new(new, libdnf.transaction.TransactionItemAction_INSTALL, reason) self._add_obsoleted(obsoleted, replaced_by=ti_new) def add_reinstall(self, new, old, obsoleted=None): ti_new = self.new(new, libdnf.transaction.TransactionItemAction_REINSTALL) ti_old = self.new(old, libdnf.transaction.TransactionItemAction_REINSTALLED, replaced_by=ti_new) self._add_obsoleted(obsoleted, replaced_by=ti_new) def add_remove(self, old, reason=None): reason = reason or libdnf.transaction.TransactionItemReason_USER ti_old = self.new(old, libdnf.transaction.TransactionItemAction_REMOVE, reason) def add_upgrade(self, new, old, obsoleted=None): ti_new = self.new(new, libdnf.transaction.TransactionItemAction_UPGRADE) ti_old = self.new(old, libdnf.transaction.TransactionItemAction_UPGRADED, replaced_by=ti_new) self._add_obsoleted(obsoleted, replaced_by=ti_new) def _test_fail_safe(self, hdr, pkg): if pkg._from_cmdline: return 0 if pkg.repo.module_hotfixes: return 0 try: if hdr['modularitylabel'] and not pkg._is_in_active_module(): logger.critical(_("No available modular metadata for modular package '{}', " "it cannot be installed on the system").format(pkg)) return 1 except ValueError: return 0 return 0 def _populate_rpm_ts(self, ts): """Populate the RPM transaction set.""" modular_problems = 0 for tsi in self: try: if tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADE: hdr = tsi.pkg._header modular_problems += self._test_fail_safe(hdr, tsi.pkg) ts.addInstall(hdr, tsi, 'u') elif tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADED: ts.addErase(tsi.pkg.idx) elif tsi.action == libdnf.transaction.TransactionItemAction_INSTALL: hdr = tsi.pkg._header modular_problems += self._test_fail_safe(hdr, tsi.pkg) ts.addInstall(hdr, tsi, 'i') elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETE: hdr = tsi.pkg._header modular_problems += self._test_fail_safe(hdr, tsi.pkg) ts.addInstall(hdr, tsi, 'u') elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETED: ts.addErase(tsi.pkg.idx) elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALL: # note: in rpm 4.12 there should not be set # rpm.RPMPROB_FILTER_REPLACEPKG to work hdr = tsi.pkg._header modular_problems += self._test_fail_safe(hdr, tsi.pkg) ts.addReinstall(hdr, tsi) elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALLED: # Required when multiple packages with the same NEVRA marked as installed ts.addErase(tsi.pkg.idx) elif tsi.action == libdnf.transaction.TransactionItemAction_REMOVE: ts.addErase(tsi.pkg.idx) elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADE: hdr = tsi.pkg._header modular_problems += self._test_fail_safe(hdr, tsi.pkg) ts.addInstall(hdr, tsi, 'u') elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADED: ts.addErase(tsi.pkg.idx) elif tsi.action == libdnf.transaction.TransactionItemAction_REASON_CHANGE: pass else: raise RuntimeError("TransactionItemAction not handled: %s" % tsi.action) except rpm.error as e: raise dnf.exceptions.Error(_("An rpm exception occurred: %s" % e)) if modular_problems: raise dnf.exceptions.Error(_("No available modular metadata for modular package")) return ts @property def install_set(self): # :api result = set() for tsi in self: if tsi.action in dnf.transaction.FORWARD_ACTIONS: try: result.add(tsi.pkg) except KeyError: raise RuntimeError("TransactionItem is has no RPM attached: %s" % tsi) return result @property def remove_set(self): # :api result = set() for tsi in self: if tsi.action in dnf.transaction.BACKWARD_ACTIONS + [libdnf.transaction.TransactionItemAction_REINSTALLED]: try: result.add(tsi.pkg) except KeyError: raise RuntimeError("TransactionItem is has no RPM attached: %s" % tsi) return result def _rpm_limitations(self): """ Ensures all the members can be passed to rpm as they are to perform the transaction. """ src_installs = [pkg for pkg in self.install_set if pkg.arch == 'src'] if len(src_installs): return _("Will not install a source rpm package (%s).") % \ src_installs[0] return None def _get_items(self, action): return [tsi for tsi in self if tsi.action == action] history.py000064400000035045147205106300006624 0ustar00# -*- coding: utf-8 -*- # Copyright (C) 2009, 2012-2018 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # import calendar import os import time import libdnf.transaction import libdnf.utils from dnf.i18n import ucd from dnf.yum import misc from dnf.exceptions import DatabaseError from .group import GroupPersistor, EnvironmentPersistor, RPMTransaction class RPMTransactionItemWrapper(object): def __init__(self, swdb, item): assert item is not None self._swdb = swdb self._item = item def __str__(self): return self._item.getItem().toStr() def __lt__(self, other): return self._item < other._item def __eq__(self, other): return self._item == other._item def __hash__(self): return self._item.__hash__() def match(self, pattern): return True def is_package(self): return self._item.getRPMItem() is not None def is_group(self): return self._item.getCompsGroupItem() is not None def is_environment(self): return self._item.getCompsEnvironmentItem() is not None def get_group(self): return self._item.getCompsGroupItem() def get_environment(self): return self._item.getCompsEnvironmentItem() @property def name(self): return self._item.getRPMItem().getName() @property def epoch(self): return self._item.getRPMItem().getEpoch() @property def version(self): return self._item.getRPMItem().getVersion() @property def release(self): return self._item.getRPMItem().getRelease() @property def arch(self): return self._item.getRPMItem().getArch() @property def evr(self): if self.epoch: return "{}:{}-{}".format(self.epoch, self.version, self.release) return "{}-{}".format(self.version, self.release) @property def nevra(self): return self._item.getRPMItem().getNEVRA() @property def action(self): return self._item.getAction() @action.setter def action(self, value): self._item.setAction(value) @property def reason(self): return self._item.getReason() @reason.setter def reason(self, value): return self._item.setReason(value) @property def action_name(self): try: return self._item.getActionName() except AttributeError: return "" @property def action_short(self): try: return self._item.getActionShort() except AttributeError: return "" @property def state(self): return self._item.getState() @state.setter def state(self, value): self._item.setState(value) @property def from_repo(self): return self._item.getRepoid() def ui_from_repo(self): if not self._item.getRepoid(): return "" return "@" + self._item.getRepoid() @property def obsoleting(self): return None def get_reason(self): # TODO: get_history_reason return self._swdb.rpm.get_reason(self) @property def pkg(self): return self._swdb.rpm._swdb_ti_pkg[self._item] @property def files(self): return self.pkg.files @property def _active(self): return self.pkg class TransactionWrapper(object): altered_lt_rpmdb = False altered_gt_rpmdb = False def __init__(self, trans): self._trans = trans @property def tid(self): return self._trans.getId() @property def cmdline(self): return self._trans.getCmdline() @property def releasever(self): return self._trans.getReleasever() @property def beg_timestamp(self): return self._trans.getDtBegin() @property def end_timestamp(self): return self._trans.getDtEnd() @property def beg_rpmdb_version(self): return self._trans.getRpmdbVersionBegin() @property def end_rpmdb_version(self): return self._trans.getRpmdbVersionEnd() @property def return_code(self): return int(self._trans.getState() != libdnf.transaction.TransactionItemState_DONE) @property def loginuid(self): return self._trans.getUserId() @property def data(self): return self.packages @property def is_output(self): output = self._trans.getConsoleOutput() return bool(output) @property def comment(self): return self._trans.getComment() def tids(self): return [self._trans.getId()] def performed_with(self): return [] def packages(self): result = self._trans.getItems() return [RPMTransactionItemWrapper(self, i) for i in result] def output(self): return [i[1] for i in self._trans.getConsoleOutput()] def error(self): return [] def compare_rpmdbv(self, rpmdbv): self.altered_gt_rpmdb = self._trans.getRpmdbVersionEnd() != rpmdbv class MergedTransactionWrapper(TransactionWrapper): def __init__(self, trans): self._trans = libdnf.transaction.MergedTransaction(trans._trans) def merge(self, trans): self._trans.merge(trans._trans) @property def loginuid(self): return self._trans.listUserIds() def tids(self): return self._trans.listIds() @property def return_code(self): return [int(i != libdnf.transaction.TransactionItemState_DONE) for i in self._trans.listStates()] @property def cmdline(self): return self._trans.listCmdlines() @property def releasever(self): return self._trans.listReleasevers() @property def comment(self): return self._trans.listComments() def output(self): return [i[1] for i in self._trans.getConsoleOutput()] class SwdbInterface(object): def __init__(self, db_dir, releasever=""): # TODO: record all vars # TODO: remove relreasever from options self.releasever = str(releasever) self._rpm = None self._group = None self._env = None self._addon_data = None self._swdb = None self._db_dir = db_dir self._output = [] def __del__(self): self.close() @property def rpm(self): if self._rpm is None: self._rpm = RPMTransaction(self) return self._rpm @property def group(self): if self._group is None: self._group = GroupPersistor(self) return self._group @property def env(self): if self._env is None: self._env = EnvironmentPersistor(self) return self._env @property def dbpath(self): return os.path.join(self._db_dir, libdnf.transaction.Swdb.defaultDatabaseName) @property def swdb(self): """ Lazy initialize Swdb object """ if not self._swdb: # _db_dir == persistdir which is prepended with installroot already try: self._swdb = libdnf.transaction.Swdb(self.dbpath) except RuntimeError as ex: raise DatabaseError(str(ex)) self._swdb.initTransaction() # TODO: vars -> libdnf return self._swdb def transform(self, input_dir): transformer = libdnf.transaction.Transformer(input_dir, self.dbpath) transformer.transform() def close(self): try: del self._tid except AttributeError: pass self._rpm = None self._group = None self._env = None if self._swdb: self._swdb.closeTransaction() self._swdb.closeDatabase() self._swdb = None self._output = [] @property def path(self): return self.swdb.getPath() def reset_db(self): return self.swdb.resetDatabase() # TODO: rename to get_last_transaction? def last(self, complete_transactions_only=True): # TODO: complete_transactions_only t = self.swdb.getLastTransaction() if not t: return None return TransactionWrapper(t) # TODO: rename to: list_transactions? def old(self, tids=None, limit=0, complete_transactions_only=False): tids = tids or [] tids = [int(i) for i in tids] result = self.swdb.listTransactions() result = [TransactionWrapper(i) for i in result] # TODO: move to libdnf if tids: result = [i for i in result if i.tid in tids] # populate altered_lt_rpmdb and altered_gt_rpmdb for i, trans in enumerate(result): if i == 0: continue prev_trans = result[i-1] if trans._trans.getRpmdbVersionBegin() != prev_trans._trans.getRpmdbVersionEnd(): trans.altered_lt_rpmdb = True prev_trans.altered_gt_rpmdb = True return result[::-1] def get_current(self): return TransactionWrapper(self.swdb.getCurrent()) def set_reason(self, pkg, reason): """Set reason for package""" rpm_item = self.rpm._pkg_to_swdb_rpm_item(pkg) repoid = self.repo(pkg) action = libdnf.transaction.TransactionItemAction_REASON_CHANGE ti = self.swdb.addItem(rpm_item, repoid, action, reason) ti.setState(libdnf.transaction.TransactionItemState_DONE) return ti ''' def package(self, pkg): """Get SwdbPackage from package""" return self.swdb.package(str(pkg)) ''' def repo(self, pkg): """Get repository of package""" return self.swdb.getRPMRepo(str(pkg)) def package_data(self, pkg): """Get package data for package""" # trans item is returned result = self.swdb.getRPMTransactionItem(str(pkg)) if result is None: return result result = RPMTransactionItemWrapper(self, result) return result # def reason(self, pkg): # """Get reason for package""" # result = self.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1) # return result # TODO: rename to begin_transaction? def beg(self, rpmdb_version, using_pkgs, tsis, cmdline=None, comment=""): try: self.swdb.initTransaction() except: pass tid = self.swdb.beginTransaction( int(calendar.timegm(time.gmtime())), str(rpmdb_version), cmdline or "", int(misc.getloginuid()), comment) self.swdb.setReleasever(self.releasever) self._tid = tid return tid def pkg_to_swdb_rpm_item(self, po): rpm_item = self.swdb.createRPMItem() rpm_item.setName(po.name) rpm_item.setEpoch(po.epoch or 0) rpm_item.setVersion(po.version) rpm_item.setRelease(po.release) rpm_item.setArch(po.arch) return rpm_item def log_scriptlet_output(self, msg): if not hasattr(self, '_tid'): return if not msg: return for line in msg.splitlines(): line = ucd(line) # logging directly to database fails if transaction runs in a background process self._output.append((1, line)) ''' def _log_errors(self, errors): for error in errors: error = ucd(error) self.swdb.log_error(self._tid, error) ''' def end(self, end_rpmdb_version="", return_code=None, errors=None): if not hasattr(self, '_tid'): return # Failed at beg() time if return_code is None: # return_code/state auto-detection return_code = libdnf.transaction.TransactionState_DONE for tsi in self.rpm: if tsi.state == libdnf.transaction.TransactionItemState_ERROR: return_code = libdnf.transaction.TransactionState_ERROR break for file_descriptor, line in self._output: self.swdb.addConsoleOutputLine(file_descriptor, line) self._output = [] self.swdb.endTransaction( int(time.time()), str(end_rpmdb_version), return_code, ) # Closing and cleanup is done in the close() method. # It is important to keep data around after the transaction ends # because it's needed by plugins to report installed packages etc. # TODO: ignore_case, more patterns def search(self, patterns, ignore_case=True): """ Search for history transactions which contain specified packages al. la. "yum list". Returns transaction ids. """ return self.swdb.searchTransactionsByRPM(patterns) def user_installed(self, pkg): """Returns True if package is user installed""" reason = self.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1) if reason == libdnf.transaction.TransactionItemReason_USER: return True # if reason is not known, consider a package user-installed # because it was most likely installed via rpm if reason == libdnf.transaction.TransactionItemReason_UNKNOWN: return True return False def get_erased_reason(self, pkg, first_trans, rollback): """Get reason of package before transaction being undone. If package is already installed in the system, keep his reason. :param pkg: package being installed :param first_trans: id of first transaction being undone :param rollback: True if transaction is performing a rollback""" if rollback: # return the reason at the point of rollback; we're setting that reason result = self.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, first_trans) else: result = self.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1) # consider unknown reason as user-installed if result == libdnf.transaction.TransactionItemReason_UNKNOWN: result = libdnf.transaction.TransactionItemReason_USER return result