Skip to content

Commit

Permalink
inst_upgrade_urls.rb client fixes
Browse files Browse the repository at this point in the history
- remove old repositories (repo files) to avoid loading old
  SLE11 repositories when refreshing a registered service
  (bnc#880971)

- remove old services to get rid of the old NCC service

(Note: everything is backed up into /var/adm/backup/upgrade/zypp
directory)

- 3.1.88
  • Loading branch information
lslezak committed Jun 3, 2014
1 parent fa4375f commit aead408
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
12 changes: 12 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,15 @@
-------------------------------------------------------------------
Tue Jun 3 13:53:15 UTC 2014 - lslezak@suse.cz

- inst_upgrade_urls.rb client:
- remove old repositories (repo files) to avoid loading old
SLE11 repositories when refreshing a registered service
(bnc#880971)
- remove old services to get rid of the old NCC service
(Note: everything is backed up into /var/adm/backup/upgrade/zypp
directory)
- 3.1.88

-------------------------------------------------------------------
Thu May 29 08:23:21 UTC 2014 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.1.87
Version: 3.1.88
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
58 changes: 54 additions & 4 deletions src/clients/inst_upgrade_urls.rb
Expand Up @@ -18,8 +18,13 @@
# To contact Novell about this file by physical or electronic mail, you may find
# current contact information at www.novell.com.
# ------------------------------------------------------------------------------

require "fileutils"

module Yast
class InstUpgradeUrlsClient < Client
include Yast::Logger

def main
Yast.import "Pkg"
Yast.import "UI"
Expand Down Expand Up @@ -80,6 +85,9 @@ def main

@repos_to_remove = []

# repositories for removal (the repo files will be removed directly)
@repo_files_to_remove = []

@repos_to_add = []

@id_to_url = {}
Expand Down Expand Up @@ -123,6 +131,8 @@ def main
Pkg.TargetInitialize(Installation.destdir)
# bnc #429080
Pkg.TargetLoad
# Note: does not work when a repository is already registered
# in pkg-bindings!
Pkg.SourceStartManager(false)

@current_repos_list = Pkg.SourceGetCurrent(
Expand Down Expand Up @@ -561,7 +571,7 @@ def ToggleStatus(repo_map)
if status == @REPO_REMOVED
status = @REPO_ENABLED
elsif status == @REPO_ENABLED
status = @REPO_DISABLED
status = @REPO_DISABLED
# disabled
else
status = @REPO_REMOVED
Expand Down Expand Up @@ -808,6 +818,27 @@ def AdjustRepoSettings(new_repo, id)

# Removes selected repositories
def IUU_RemoveRepositories
if !@repo_files_to_remove.empty?
backup_dir = File.join(Installation.destdir, "var/adm/backup/upgrade/zypp/repos.d")

::FileUtils.mkdir_p(backup_dir) unless File.exist?(backup_dir)

@repo_files_to_remove.each do |repo|
log.info "Removing repository: #{repo}"

path = File.join(Installation.destdir, "etc/zypp/repos.d", "#{repo["alias"]}.repo")
if File.exist?(path)
log.info "Moving file #{path} to #{backup_dir}"
::FileUtils.mv(path, backup_dir)
end
end

# force reloading the libzypp repomanager to notice the removed files
Pkg.TargetFinish
Pkg.TargetInitialize(Installation.destdir)
Pkg.TargetLoad
end

return if Builtins.size(@repos_to_remove) == 0

Progress.Title(_("Removing unused repositories..."))
Expand All @@ -829,6 +860,18 @@ def IUU_RemoveRepositories
nil
end

def remove_services
service_files = Dir[File.join(Installation.destdir, "/etc/zypp/services.d/*.service")]

if !service_files.empty?
backup_dir = File.join(Installation.destdir, "var/adm/backup/upgrade/zypp/services.d")
::FileUtils.mkdir_p(backup_dir) unless File.exist?(backup_dir)

log.info "Moving #{service_files} to #{backup_dir}"
::FileUtils.mv(service_files, backup_dir)
end
end

def InsertCorrectMediaHandler(url, name)
if !Builtins.regexpmatch(url, "^cd:/") &&
!Builtins.regexpmatch(url, "^dvd:/")
Expand Down Expand Up @@ -1113,6 +1156,7 @@ def AddOrRemoveRepositories
@repos_to_add = []
@id_to_url = {}
@repos_to_add_disabled = []
@repo_files_to_remove = []

# bnc #400823
@do_not_remove = Ops.get(Pkg.SourceGetCurrent(false), 0, 0)
Expand Down Expand Up @@ -1151,16 +1195,18 @@ def AddOrRemoveRepositories
@repos_to_remove = Builtins.add(@repos_to_remove, current_medianr)
Builtins.y2milestone("Repository to remove: %1", current_medianr)
end
end
end

# Repository should be removed (not added)
elsif Ops.get_string(one_source, "new_status", "") == @REPO_REMOVED
if Ops.get_string(one_source, "initial_url_status", "") == @REPO_REMOVED
Builtins.y2milestone("Repository has been already removed")
Builtins.y2milestone("Repository not loaded or already removed")
# repository is not known to pkg-bindings, remove the repo file directly
@repo_files_to_remove << one_source
else
@repos_to_remove = Builtins.add(@repos_to_remove, current_medianr)
Builtins.y2milestone("Repository to remove: %1", current_medianr)
end
end

# Repositry will be added in disabled state
# BNC #583155
Expand Down Expand Up @@ -1220,6 +1266,10 @@ def AddOrRemoveRepositories

PackageCallbacks.RegisterEmptyProgressCallbacks

# (re)move old services - there is no UI for services,
# but we really need to get rid of the old NCC service...
remove_services

IUU_RemoveRepositories()

# Add repositories in enabled state
Expand Down

0 comments on commit aead408

Please sign in to comment.