Skip to content

Instantly share code, notes, and snippets.

@vmoravec
Created January 10, 2014 15:51
Show Gist options
  • Save vmoravec/8356857 to your computer and use it in GitHub Desktop.
Save vmoravec/8356857 to your computer and use it in GitHub Desktop.
Find why it maps false
AddOnProduct.add_on_products = Builtins.maplist( AddOnProduct.add_on_products) do |prod|
media = Ops.get_string(prod, "media_url", "")
pth = Ops.get_string(prod, "product_dir", "/")
if String.StartsWith(media, "relurl://")
base = AddOnProduct.GetBaseProductURL
media = AddOnProduct.GetAbsoluteURL(base, media)
Builtins.y2milestone("relurl changed to %1", media)
end
Ops.set(@sources, media, Ops.get(@sources, media, {}))
# set addon specific sig-handling
AddOnProduct.SetSignatureCallbacks(
Ops.get_string(prod, "product", "")
)
srcid = -1
begin
url = AddOnProduct.SetRepoUrlAlias(
media,
Ops.get_string(prod, "alias", ""),
Ops.get_string(prod, "name", "")
)
srcid = Pkg.SourceCreate(url, pth)
if (srcid == -1 || srcid == nil) &&
!Ops.get_boolean(prod, "ask_on_error", false)
# error report
Report.Error(_("Failed to add add-on product."))
elsif (srcid == -1 || srcid == nil) &&
Ops.get_boolean(prod, "ask_on_error", false)
Ops.set(
prod,
"ask_on_error",
Popup.ContinueCancel(
Builtins.sformat(
_("Make the add-on \"%1\" available via \"%2\"."),
Ops.get_string(prod, "product", ""),
media
)
)
)
end
Ops.set(@sources, [media, pth], srcid)
Builtins.y2milestone("New source ID: %1", srcid)
# bugzilla #260613
AddOnProduct.Integrate(srcid) if srcid != -1
# reset to global sig-handling
AutoinstGeneral.SetSignatureHandling
end while Ops.get(@sources, [media, pth], -1) == -1 &&
Ops.get_boolean(prod, "ask_on_error", false) == true
Ops.set(prod, "media", Ops.get(@sources, [media, pth], -1))
# Adjust "name", bnc #434708
if srcid != nil && srcid != -1
repos = Pkg.SourceEditGet
found_at = -1
counter = -1
Builtins.foreach(repos) do |one_repo|
counter = Ops.add(counter, 1)
if Ops.get_integer(one_repo, "SrcId", -1) == srcid
found_at = counter
raise Break
end
end
if found_at != -1
name = Ops.get_string(repos, [found_at, "name"], "")
# Possibility to set name in control file, bnc #433981
if Builtins.haskey(prod, "name")
name = Ops.get_string(prod, "name", "")
Builtins.y2milestone("Preferred name: %1", name)
# Or use the one returned by Pkg::RepositoryScan
else
repos_at_url = Pkg.RepositoryScan(media)
# [ ["Product Name", "Path" ] ]
Builtins.foreach(repos_at_url) do |one_repo|
if Ops.get(one_repo, 1, "") == pth
name = Ops.get(one_repo, 0, "")
raise Break
end
end
Builtins.y2milestone("Preferred name: %1", name)
end
Ops.set(repos, [found_at, "name"], name)
Pkg.SourceEditSet(repos)
end
end
if Ops.get_string(prod, "product", "") != ""
Builtins.y2milestone(
"Installing product: %1",
Ops.get_string(prod, "product", "")
)
Pkg.ResolvableInstall(Ops.get_string(prod, "product", ""), :product)
else
Builtins.y2warning("No product to install")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment