}
} // namespace json
///////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////
namespace target
- { /////////////////////////////////////////////////////////////////
+ {
+ ///////////////////////////////////////////////////////////////////
+ namespace
+ {
+ SolvIdentFile::Data getUserInstalledFromHistory( const Pathname & historyFile_r )
+ {
+ SolvIdentFile::Data onSystemByUserList;
+ // go and parse it: 'who' must constain an '@', then it was installed by user request.
+ // 2009-09-29 07:25:19|install|lirc-remotes|0.8.5-3.2|x86_64|root@opensuse|InstallationImage|a204211eb0...
+ std::ifstream infile( historyFile_r.c_str() );
+ for( iostr::EachLine in( infile ); in; in.next() )
+ {
+ const char * ch( (*in).c_str() );
+ // start with year
+ if ( *ch < '1' || '9' < *ch )
+ continue;
+ const char * sep1 = ::strchr( ch, '|' ); // | after date
+ if ( !sep1 )
+ continue;
+ ++sep1;
+ // if logs an install or delete
+ bool installs = true;
+ if ( ::strncmp( sep1, "install|", 8 ) )
+ {
+ if ( ::strncmp( sep1, "remove |", 8 ) )
+ continue; // no install and no remove
+ else
+ installs = false; // remove
+ }
+ sep1 += 8; // | after what
+ // get the package name
+ const char * sep2 = ::strchr( sep1, '|' ); // | after name
+ if ( !sep2 || sep1 == sep2 )
+ continue;
+ (*in)[sep2-ch] = '\0';
+ IdString pkg( sep1 );
+ // we're done, if a delete
+ if ( !installs )
+ {
+ onSystemByUserList.erase( pkg );
+ continue;
+ }
+ // now guess whether user installed or not (3rd next field contains 'user@host')
+ if ( (sep1 = ::strchr( sep2+1, '|' )) // | after version
+ && (sep1 = ::strchr( sep1+1, '|' )) // | after arch
+ && (sep2 = ::strchr( sep1+1, '|' )) ) // | after who
+ {
+ (*in)[sep2-ch] = '\0';
+ if ( ::strchr( sep1+1, '@' ) )
+ {
+ // by user
+ onSystemByUserList.insert( pkg );
+ continue;
+ }
+ }
+ }
+ MIL << "onSystemByUserList found: " << onSystemByUserList.size() << endl;
+ return onSystemByUserList;
+ }
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
/** Helper for commit plugin execution.
* \ingroup g_RAII
TargetImpl::TargetImpl( const Pathname & root_r, bool doRebuild_r )
: _root( root_r )
, _requestedLocalesFile( home() / "RequestedLocales" )
- , _softLocksFile( home() / "SoftLocks" )
+ , _autoInstalledFile( home() / "AutoInstalled" )
, _hardLocksFile( Pathname::assertprefix( _root, ZConfig::instance().locksFile() ) )
{
_rpm.initDatabase( root_r, Pathname(), doRebuild_r );
cmd << " > '" << tmpsolv.path() << "'";
- MIL << "Executing: " << cmd << endl;
+ MIL << "Executing: " << cmd.str() << endl;
ExternalProgram prog( cmd.str(), ExternalProgram::Stderr_To_Stdout );
cmd << endl;
system.addSolv( rpmsolv );
}
+ sat::Pool::instance().rootDir( _root );
// (Re)Load the requested locales et al.
// If the requested locales are empty, we leave the pool untouched
satpool.setRequestedLocales( requestedLocales );
}
}
-#ifdef WITHSOFTLOCKS
{
- SoftLocksFile::Data softLocks( _softLocksFile.data() );
- if ( ! softLocks.empty() )
- {
- // Don't soft lock any installed item.
- for_( it, system.solvablesBegin(), system.solvablesEnd() )
- {
- softLocks.erase( it->ident() );
- }
- ResPool::instance().setAutoSoftLocks( softLocks );
- }
+ if ( ! PathInfo( _autoInstalledFile.file() ).isExist() )
+ {
+ // Initialize from history, if it does not exist
+ Pathname historyFile( Pathname::assertprefix( _root, ZConfig::instance().historyLogFile() ) );
+ if ( PathInfo( historyFile ).isExist() )
+ {
+ SolvIdentFile::Data onSystemByUser( getUserInstalledFromHistory( historyFile ) );
+ SolvIdentFile::Data onSystemByAuto;
+ for_( it, system.solvablesBegin(), system.solvablesEnd() )
+ {
+ IdString ident( (*it).ident() );
+ if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
+ onSystemByAuto.insert( ident );
+ }
+ _autoInstalledFile.setData( onSystemByAuto );
+ }
+ // on the fly removed any obsolete SoftLocks file
+ filesystem::unlink( home() / "SoftLocks" );
+ }
+ // read from AutoInstalled file
+ sat::StringQueue q;
+ for ( const auto & idstr : _autoInstalledFile.data() )
+ q.push( idstr.id() );
+ satpool.setAutoInstalled( q );
}
-#endif
if ( ZConfig::instance().apply_locks_file() )
{
const HardLocksFile::Data & hardLocks( _hardLocksFile.data() );
filesystem::assert_dir( home() );
// requested locales
_requestedLocalesFile.setLocales( pool_r.getRequestedLocales() );
-#ifdef WITHSOFTLOCKS
- // weak locks
+ // autoinstalled
{
- SoftLocksFile::Data newdata;
- pool_r.getActiveSoftLocks( newdata );
- _softLocksFile.setData( newdata );
+ SolvIdentFile::Data newdata;
+ for ( sat::Queue::value_type id : result.rTransaction().autoInstalled() )
+ newdata.insert( IdString(id) );
+ _autoInstalledFile.setData( newdata );
}
-#endif
// hard locks
if ( ZConfig::instance().apply_locks_file() )
{
}
}
}
+ packageCache.preloaded( true ); // try to avoid duplicate infoInCache CBs in commit
}
if ( miss )
std::string TargetImpl::targetDistributionRelease( const Pathname & root_r )
{ return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
+ std::string TargetImpl::targetDistributionFlavor() const
+ { return baseproductdata( _root ).registerFlavor(); }
+ // static version:
+ std::string TargetImpl::targetDistributionFlavor( const Pathname & root_r )
+ { return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
+
Target::DistributionLabel TargetImpl::distributionLabel() const
{
Target::DistributionLabel ret;