@@ -1522,7 +1522,7 @@ void modify_repos_by_option( Zypper & zypper, const RepoServiceCommonSelectOptio
15221522 RepoInfoSet toModify = collect_repos_by_option ( zypper, selectOpts );
15231523 for_ ( it, toModify.begin (), toModify.end () )
15241524 {
1525- modify_repo ( zypper, it->alias (), commonOpts, repoProps );
1525+ modify_repo ( zypper, it->alias (), std::string (), commonOpts, repoProps );
15261526 }
15271527}
15281528
@@ -1531,7 +1531,7 @@ void modify_repos_by_option( Zypper & zypper, const RepoServiceCommonSelectOptio
15311531
15321532
15331533
1534- void modify_repo ( Zypper & zypper, const std::string & alias, const RepoServiceCommonOptions &commonOpts, const RepoProperties &repoProps )
1534+ void modify_repo ( Zypper & zypper, const std::string & alias, const std::string &newBaseUrl, const RepoServiceCommonOptions &commonOpts, const RepoProperties &repoProps )
15351535{
15361536 // enable/disable repo
15371537 const TriBool &enable = commonOpts._enable ;
@@ -1582,7 +1582,7 @@ void modify_repo( Zypper & zypper, const std::string & alias, const RepoServiceC
15821582 if ( gpgCheck != RepoInfo::GpgCheck::indeterminate )
15831583 {
15841584 if ( repo.setGpgCheck ( gpgCheck ) )
1585- changed_gpgcheck = true ;
1585+ changed_gpgcheck = true ;
15861586 }
15871587
15881588 if ( prio >= 1 )
@@ -1600,8 +1600,19 @@ void modify_repo( Zypper & zypper, const std::string & alias, const RepoServiceC
16001600 if ( !name.empty () )
16011601 repo.setName ( name );
16021602
1603+ if ( !newBaseUrl.empty () )
1604+ {
1605+ Url url = make_url ( newBaseUrl );
1606+ if ( !url.isValid () )
1607+ {
1608+ zypper.setExitCode (ZYPPER_EXIT_ERR_INVALID_ARGS);
1609+ return ;
1610+ }
1611+ repo.setBaseUrl ( url );
1612+ }
1613+
16031614 if ( changed_enabled || changed_autoref || changed_prio
1604- || changed_keeppackages || changed_gpgcheck || !name.empty () )
1615+ || changed_keeppackages || changed_gpgcheck || !name.empty () || !newBaseUrl. empty () )
16051616 {
16061617 std::string volatileNote; // service repos changes may be volatile
16071618 std::string volatileNoteIfPlugin; // plugin service repos changes may be volatile
@@ -1665,6 +1676,12 @@ void modify_repo( Zypper & zypper, const std::string & alias, const RepoServiceC
16651676 zypper.out ().info ( str::Format (_ (" Name of repository '%s' has been set to '%s'." )) % alias % name, volatileNote );
16661677 }
16671678
1679+ if ( !newBaseUrl.empty () )
1680+ {
1681+ if ( !volatileNote.empty () ) didVolatileChanges = true ;
1682+ zypper.out ().info ( str::Format (_ (" Baseurl of repository '%s' has been set to '%s'." )) % alias % newBaseUrl, volatileNote );
1683+ }
1684+
16681685 if ( didVolatileChanges )
16691686 {
16701687 zypper.out ().warning ( volatileServiceRepoChange ( repo ) );
0 commit comments