summaryrefslogtreecommitdiff
path: root/examples/ruby/parse2.rb
blob: 373077c244586fc4c5d5e058e539a018cd112ea0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/ruby

require 'zypp'
include Zypp

tmp_cache_path = TmpDir.new()
tmp_raw_cache_path = TmpDir.new()
tmp_known_repos_path = TmpDir.new()

opts = RepoManagerOptions.new()
opts.repoCachePath = tmp_cache_path.path()
opts.repoRawCachePath = tmp_raw_cache_path.path()
opts.knownReposPath = tmp_known_repos_path.path()

repo_manager = RepoManager.new(opts)

repo_info = RepoInfo.new()

repo_info.set_alias("factorytest")
repo_info.set_name("Test Repo for Factory.")
repo_info.set_enabled(true)
repo_info.set_autorefresh(false)
# repo_info.add_base_url("ftp://dist.suse.de/install/stable-x86/")
# repo_info.add_base_url("http://software.opensuse.org/download/home:/Arvin42/openSUSE_Factory/")
repo_info.add_base_url("file:///suse/aschnell/tmp")

repo_manager.add_repository(repo_info)

res_pool_manager = ResPoolManager.new()

repos = repo_manager.known_repositories()
repos.each do | repo |
    repo_manager.refresh_metadata(repo)
    repo_manager.build_cache(repo)
    rep = repo_manager.create_from_cache(repo)
    store = rep.resolvables()
    res_pool_manager.insert(store)
end

pool = res_pool_manager.accessor()
# puts pool.class

pool.each do | p |

    # puts p.class
    r = p.resolvable
    # puts r.class
    puts "#{r.kind} #{r.name} #{r.edition.to_s} #{r.arch.to_s}"
    puts "  Summary: #{r.summary}"
    puts "  Size: #{r.size}"
    puts "  Vendor: #{r.vendor}"
    puts "  Buildtime: #{r.buildtime}"

    d = r.dep(Dep.PROVIDES)
    # puts d.class
    d.each do | x |
	# puts y.class
	puts "  Provides: #{x.to_s}"
    end

    puts

end