Skip to content

Commit

Permalink
[api][webui] Add packages to import_from_package
Browse files Browse the repository at this point in the history
Create also Packages and PackageGroups when importing a xml from package
in the `Kiwi::Image#import_from_package` method.

Pair-programmed by @DavidKang and @Ana06.
  • Loading branch information
Ana06 committed Jul 18, 2017
1 parent 40962d4 commit ce7f736
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/api/app/models/kiwi/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ def self.build_from_xml(xml_string, md5)
new_image.repositories.build(attributes)
order += 1
end
package_groups = xml["packages"]
package_groups = [xml["packages"]] if xml["packages"].is_a?(Hash)
package_groups.each do |package_group_xml|
attributes = {
kiwi_type: package_group_xml['type'],
profiles: package_group_xml['profiles '],
pattern_type: package_group_xml['patternType']
}
package_group = Kiwi::PackageGroup.new(attributes)
package_group_xml['package'].each do |package|
attributes = {
name: package['name'],
arch: package['arch'],
replaces: package['replaces']
}
attributes['bootinclude'] = package['bootinclude'] == 'true' if package.key?('bootinclude')
attributes['bootdelete'] = package['bootdelete'] == 'true' if package.key?('bootdelete')
package_group.packages.build(attributes)
end
new_image.package_groups << package_group
end
new_image
end

Expand Down
19 changes: 19 additions & 0 deletions src/api/spec/models/kiwi/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@
replaceable: false,
username: nil
)
expect(subject.package_groups.first).to have_attributes(
kiwi_type: 'image',
pattern_type: 'onlyRequired',
profiles: nil
)
expect(subject.package_groups.first.packages.first).to have_attributes(
name: 'e2fsprogs',
arch: nil,
replaces: nil,
bootinclude: nil,
bootdelete: nil
)
expect(subject.package_groups.first.packages.last).to have_attributes(
name: 'gfxboot-devel',
arch: nil,
replaces: nil,
bootinclude: true,
bootdelete: nil
)
end
end

Expand Down

0 comments on commit ce7f736

Please sign in to comment.