sle2docker 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Changelog +11 -0
- data/LICENSE +20 -0
- data/README.md +114 -0
- data/Rakefile +18 -0
- data/bin/sle2docker +9 -0
- data/lib/sle2docker.rb +11 -0
- data/lib/sle2docker/builder.rb +102 -0
- data/lib/sle2docker/cli.rb +83 -0
- data/lib/sle2docker/exceptions.rb +9 -0
- data/lib/sle2docker/template.rb +21 -0
- data/lib/sle2docker/version.rb +5 -0
- data/lib/templates/SLE11SP2/config.sh +49 -0
- data/lib/templates/SLE11SP2/config.xml.erb +51 -0
- data/lib/templates/SLE11SP2/root/etc/resolv.conf +0 -0
- data/lib/templates/SLE11SP3/config.sh +49 -0
- data/lib/templates/SLE11SP3/config.xml.erb +45 -0
- data/lib/templates/SLE11SP3/root/etc/resolv.conf +0 -0
- data/lib/templates/SLE12/config.sh +49 -0
- data/lib/templates/SLE12/config.xml.erb +44 -0
- data/lib/templates/SLE12/root/etc/resolv.conf +0 -0
- data/sle2docker.gemspec +23 -0
- data/test/builder_test.rb +170 -0
- data/test/fixtures/sle11sp3_config.xml +45 -0
- data/test/fixtures/sle11sp3_smt_auth_config.xml +45 -0
- data/test/fixtures/sle11sp3_smt_no_auth_https_config.xml +45 -0
- data/test/fixtures/sle11sp3_smt_no_auth_no_https_config.xml +45 -0
- data/test/template_test.rb +30 -0
- data/test/test_helper.rb +44 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb963af94d7f7cc450726198692b2a3115fe03bc
|
4
|
+
data.tar.gz: dcaab3e0f989f15cfd31202edcc631e5285b258a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 904c4a1861c40735824e5a79995c30eaa4a055797b4287a7e898e1b8ebe24b88a3219db8f19a3ab63deb960b465dbc84472f4417f0e43bc3d7451178c65bf940
|
7
|
+
data.tar.gz: e69c0883939c6fc41a3cd62f656f09b177d33fbcf42a5d564db17a82cbfbe2d962f203daef48adfcf2a70be5b040f3ae3e21f207d476f6e71c0f2e5d3b53e2c9
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/Changelog
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Tue Sep 02 08:19:22 CEST 2014 Flavio Castelli <fcastelli@suse.com>
|
2
|
+
|
3
|
+
* Version 0.1.2: made template name case insensitive
|
4
|
+
|
5
|
+
Thu Aug 07 11:10:26 CEST 2014 Flavio Castelli <fcastelli@suse.com>
|
6
|
+
|
7
|
+
* Version 0.1.1: added SLE12 template
|
8
|
+
|
9
|
+
Tue Aug 05 16:58:21 CEST 2014 Flavio Castelli <fcastelli@suse.com>
|
10
|
+
|
11
|
+
* Release of the initial version 0.1.0
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Flavio Castelli
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
sle2docker is a convenience tool which creates SUSE Linux Enterprise images for
|
2
|
+
[Docker](http://docker.com).
|
3
|
+
|
4
|
+
The tool relies on [KIWI](https://github.com/openSUSE/kiwi) and Docker itself
|
5
|
+
to build the images.
|
6
|
+
|
7
|
+
Packages can be fetched either from SUSE Customer Center (SCC) or from a local
|
8
|
+
Subscription Management Tool (SMT).
|
9
|
+
|
10
|
+
Using DVD sources is currently unsupported.
|
11
|
+
|
12
|
+
# Requirements
|
13
|
+
|
14
|
+
Ruby is required to execute the sle2docker program.
|
15
|
+
|
16
|
+
Docker must be running on the system and the user invoking sle2docker must
|
17
|
+
have the rights to interact with it.
|
18
|
+
|
19
|
+
# Installation
|
20
|
+
|
21
|
+
The recommended way to install sle2docker is via zypper:
|
22
|
+
|
23
|
+
```
|
24
|
+
sudo zypper in rubygem-sle2docker
|
25
|
+
```
|
26
|
+
|
27
|
+
However sle2docker can be installed via gem:
|
28
|
+
|
29
|
+
```
|
30
|
+
sudo gem install --no-format-exec sle2docker
|
31
|
+
```
|
32
|
+
|
33
|
+
The `--no-format-exec` is recommended otherwise the `sle2docker` binary will
|
34
|
+
be prefixed with the ruby version installed on the system (eg: the binary on
|
35
|
+
SLE12 would be called `sle2docker.ruby2.1`).
|
36
|
+
|
37
|
+
# How it works
|
38
|
+
|
39
|
+
The sle2docker gem comes with a set of supported SLE templates. These are KIWI
|
40
|
+
source files which are filled with the informations provided by the user at
|
41
|
+
runtime.
|
42
|
+
|
43
|
+
The image creation happens inside of
|
44
|
+
[this](https://registry.hub.docker.com/u/opensuse/kiwi/)
|
45
|
+
Docker image. This has to be done because on recent systems (like SLE12) KIWI
|
46
|
+
cannot create SLE11 images. That happens because building a SLE11 systems
|
47
|
+
requires the `db45-utils` package to be installed on the host system; this
|
48
|
+
package is obsolete and is not available on SLE12.
|
49
|
+
|
50
|
+
The Docker image used by sle2docker is based on openSUSE and it's freely
|
51
|
+
downloadable from the [Docker Hub](https://registry.hub.docker.com/). The image
|
52
|
+
is built using Docker's build system by starting from the
|
53
|
+
[official openSUSE image](https://registry.hub.docker.com/_/opensuse/).
|
54
|
+
The `Dockerfile` used to create this image can be found inside of
|
55
|
+
[this](https://github.com/openSUSE/docker-containers) repository.
|
56
|
+
|
57
|
+
sle2docker automatically fetches the `opensuse/kiwi` image if not found on the
|
58
|
+
system.
|
59
|
+
|
60
|
+
# Usage
|
61
|
+
|
62
|
+
To build a template just use the following command:
|
63
|
+
|
64
|
+
```
|
65
|
+
sle2docker <template name>
|
66
|
+
```
|
67
|
+
|
68
|
+
A list of the available templates can be obtained by running:
|
69
|
+
|
70
|
+
```
|
71
|
+
sle2docker -l
|
72
|
+
```
|
73
|
+
|
74
|
+
## SUSE Customer Center integration
|
75
|
+
|
76
|
+
By default sle2docker downloads all the required packages from SUSE
|
77
|
+
Customer Center (SCC). Before the build starts sle2docker ask the user
|
78
|
+
his credentials. It is possible to start a build in a non interactive way by
|
79
|
+
using the following command:
|
80
|
+
|
81
|
+
```
|
82
|
+
sle2docker -u USERNAME -p PASSWORD TEMPLATE_NAME
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
## Subscription Management Tool integration
|
87
|
+
|
88
|
+
It is possible to download all the reuiqred packages from a local
|
89
|
+
Subscription Management Tool (SMT) instance:
|
90
|
+
|
91
|
+
```
|
92
|
+
sle2docker -s SMT_SERVER_HOSTNAME TEMPLATE_NAME
|
93
|
+
```
|
94
|
+
|
95
|
+
By default sle2docker assumes the contents of the SMT server are served over
|
96
|
+
HTTPS. To force the retrieval of the package over plain HTTP use the
|
97
|
+
following command:
|
98
|
+
|
99
|
+
```
|
100
|
+
sle2docker -s SMT_SERVER_HOSTNAME --disable-https TEMPLATE_NAME
|
101
|
+
```
|
102
|
+
|
103
|
+
By default sle2docker expects the SMT instance to not require any form of
|
104
|
+
authentication. However it is possible to specify the access credentials by
|
105
|
+
using the following command:
|
106
|
+
|
107
|
+
```
|
108
|
+
sle2docker -s SMT_SERVER_HOSTNAME -u USERNAME -p PASSWORD TEMPLATE_NAME
|
109
|
+
```
|
110
|
+
|
111
|
+
|
112
|
+
# License
|
113
|
+
|
114
|
+
sle2docker is released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rake/testtask'
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.pattern = 'test/**/*_test.rb'
|
10
|
+
test.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'yard'
|
15
|
+
YARD::Rake::YardocTask.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Yard not available. To generate documentation install it with: gem install yard"
|
18
|
+
end
|
data/bin/sle2docker
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative '../lib/sle2docker'
|
3
|
+
|
4
|
+
container = Sle2Docker::Cli.new.start()
|
5
|
+
puts "Container created, it can be imported by running the following command:"
|
6
|
+
puts " docker import - <desired image name> < #{container}"
|
7
|
+
puts "\nThen the '#{File.expand_path(File.join(File.dirname(container), '..'))}' directory and all its contents can be removed."
|
8
|
+
puts "Note well: KIWI created some of these files while running as root user, " +
|
9
|
+
"hence root privileges are required to remove them."
|
data/lib/sle2docker.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'io/console'
|
4
|
+
require 'optparse'
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
require_relative 'sle2docker/cli'
|
8
|
+
require_relative 'sle2docker/builder'
|
9
|
+
require_relative 'sle2docker/exceptions'
|
10
|
+
require_relative 'sle2docker/template'
|
11
|
+
require_relative 'sle2docker/version'
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Sle2Docker
|
2
|
+
class Builder
|
3
|
+
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
# Creates the actual Docker image using kiwi
|
9
|
+
#
|
10
|
+
# @param [String] template_dir
|
11
|
+
# @return [String] path to the image created by kiwi
|
12
|
+
def create(template_dir)
|
13
|
+
tmp_dir = Dir.mktmpdir("sle2docker")
|
14
|
+
tmp_template_dir = File.join(tmp_dir, "template")
|
15
|
+
result_dir = File.join(tmp_dir, "result")
|
16
|
+
|
17
|
+
FileUtils.cp_r(File.join(template_dir, "."), tmp_template_dir)
|
18
|
+
FileUtils.mkdir_p(result_dir)
|
19
|
+
|
20
|
+
template_file = find_template_file(tmp_template_dir)
|
21
|
+
if template_file.end_with?('.erb')
|
22
|
+
template = render_template(template_file)
|
23
|
+
File.open(File.join(tmp_template_dir, "config.xml"), "w") do |file|
|
24
|
+
file.write(template)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
docker_cmd = "docker run "
|
29
|
+
# ensure kiwi cache is persistent
|
30
|
+
docker_cmd += "-v /var/cache/kiwi:/var/cache/kiwi "
|
31
|
+
# share build dir
|
32
|
+
docker_cmd += "-v #{tmp_dir}:/#{tmp_dir} "
|
33
|
+
# required because kiwi needs to bind mount /proc while creating the image
|
34
|
+
docker_cmd += "--privileged "
|
35
|
+
# the image to use
|
36
|
+
docker_cmd += "opensuse/kiwi "
|
37
|
+
# kiwi directives
|
38
|
+
docker_cmd += "--build #{tmp_template_dir} --type docker -d #{result_dir}"
|
39
|
+
begin
|
40
|
+
puts "Starting build process inside of Docker container"
|
41
|
+
if !system(docker_cmd)
|
42
|
+
$stderr.printf("Something wrong happened during the build process\n")
|
43
|
+
exit(1)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
Dir[File.join(result_dir, "*.tbz")].first
|
47
|
+
end
|
48
|
+
|
49
|
+
# Looks for either config.xml or config.xml.erb inside of the template
|
50
|
+
# directory.
|
51
|
+
#
|
52
|
+
# Exits with an error if no file is found.
|
53
|
+
#
|
54
|
+
# @param [String] template_dir
|
55
|
+
# @return [String] full path to the template file
|
56
|
+
def find_template_file(template_dir)
|
57
|
+
template_file = File.join(template_dir, 'config.xml.erb')
|
58
|
+
|
59
|
+
if !File.exist?(template_file)
|
60
|
+
raise ConfigNotFoundError.new("Cannot find config.xml.erb file inside of #{template_dir}")
|
61
|
+
end
|
62
|
+
|
63
|
+
template_file
|
64
|
+
end
|
65
|
+
|
66
|
+
# Performs the rendering of config.xml.erb
|
67
|
+
#
|
68
|
+
# @param [String] template_file
|
69
|
+
# @return [String] rendered template
|
70
|
+
def render_template(template_file)
|
71
|
+
host = if @options[:smt_host]
|
72
|
+
@options[:smt_host]
|
73
|
+
else
|
74
|
+
"nu.novell.com"
|
75
|
+
end
|
76
|
+
|
77
|
+
username = @options[:username]
|
78
|
+
if !username && (!@options[:password].empty? || !@options[:smt_host])
|
79
|
+
puts "Enter #{@options[:smt_host] ? '' : 'NCC '}username:"
|
80
|
+
username = $stdin.gets.chomp
|
81
|
+
end
|
82
|
+
|
83
|
+
password = @options[:password]
|
84
|
+
if (username || !@options[:smt_host]) && password.empty?
|
85
|
+
puts "Enter #{@options[:smt_host] ? '' : 'NCC '}password:"
|
86
|
+
password = $stdin.noecho(&:gets).chomp
|
87
|
+
end
|
88
|
+
|
89
|
+
credentials = ""
|
90
|
+
if username || !password.empty?
|
91
|
+
credentials = "username='#{username}' password='#{password}'"
|
92
|
+
end
|
93
|
+
|
94
|
+
use_ncc = !@options[:smt_host]
|
95
|
+
|
96
|
+
enable_https = !@options[:disable_https]
|
97
|
+
|
98
|
+
ERB.new(File.read(template_file)).result(binding)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Sle2Docker
|
2
|
+
|
3
|
+
class Cli
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@options, @template_dir = parse_options()
|
7
|
+
end
|
8
|
+
|
9
|
+
def start
|
10
|
+
builder = Builder.new(@options)
|
11
|
+
builder.create(@template_dir)
|
12
|
+
rescue ConfigNotFoundError => e
|
13
|
+
$stderr.printf(e.message + "\n")
|
14
|
+
exit(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse_options()
|
20
|
+
options = {}
|
21
|
+
|
22
|
+
optparse = OptionParser.new do|opts|
|
23
|
+
opts.banner = "Usage: sle2docker [options] TEMPLATE"
|
24
|
+
|
25
|
+
options[:username] = nil
|
26
|
+
opts.on('-u', '--username USERNAME',
|
27
|
+
'Username required to access repositories' ) do |u|
|
28
|
+
options[:username] = u
|
29
|
+
end
|
30
|
+
|
31
|
+
options[:password] = ""
|
32
|
+
opts.on('-p', '--password PASSWORD',
|
33
|
+
'Password required to access repositories' ) do |p|
|
34
|
+
options[:password] = p
|
35
|
+
end
|
36
|
+
|
37
|
+
options[:smt_host] = nil
|
38
|
+
opts.on('-s', '--smt-host SMT_HOST',
|
39
|
+
'SMT machine hosting the repositories' ) do |smt_host|
|
40
|
+
options[:smt_host] = smt_host
|
41
|
+
end
|
42
|
+
|
43
|
+
options[:disable_https] = false
|
44
|
+
opts.on('--disable-https',
|
45
|
+
'Do not use HTTPS when accessing repositories' ) do
|
46
|
+
options[:disable_https] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('-l', '--list-templates', 'List the available templates' ) do
|
50
|
+
puts "Available templates:"
|
51
|
+
Template.list.each {|template| puts " - #{template}"}
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
opts.on('-h', '--help', 'Display this screen' ) do
|
57
|
+
puts opts
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on('-v', '--version', 'Display version' ) do
|
62
|
+
puts Sle2Docker::VERSION
|
63
|
+
exit
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
optparse.parse!
|
69
|
+
|
70
|
+
if ARGV.count != 1
|
71
|
+
$stderr.printf("Template not provided\n")
|
72
|
+
exit(1)
|
73
|
+
end
|
74
|
+
|
75
|
+
[options, Template.template_dir(ARGV[0])]
|
76
|
+
rescue TemplateNotFoundError => ex
|
77
|
+
$stderr.printf(ex.message + "\n")
|
78
|
+
$stderr.printf("To list the available templates use:\n")
|
79
|
+
$stderr.printf(" sle2docker -l\n")
|
80
|
+
exit(1)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sle2Docker
|
2
|
+
|
3
|
+
class Template
|
4
|
+
|
5
|
+
def self.list
|
6
|
+
Dir[File.expand_path('../../templates/*', __FILE__)].map do |dir|
|
7
|
+
File.basename(dir)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.template_dir(template_name)
|
12
|
+
dir = File.expand_path("../../templates/#{template_name.upcase}", __FILE__)
|
13
|
+
if !File.exists?(dir)
|
14
|
+
raise TemplateNotFoundError.new("Cannot find template with name #{template_name}")
|
15
|
+
end
|
16
|
+
dir
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#================
|
3
|
+
# FILE : config.sh
|
4
|
+
#----------------
|
5
|
+
# PROJECT : OpenSuSE KIWI Image System
|
6
|
+
# COPYRIGHT : (c) 2013 SUSE LLC
|
7
|
+
# :
|
8
|
+
# AUTHOR : Robert Schweikert <rjschwei@suse.com>
|
9
|
+
# :
|
10
|
+
# BELONGS TO : Operating System images
|
11
|
+
# :
|
12
|
+
# DESCRIPTION : configuration script for SUSE based
|
13
|
+
# : operating systems
|
14
|
+
# :
|
15
|
+
# :
|
16
|
+
# STATUS : BETA
|
17
|
+
#----------------
|
18
|
+
#======================================
|
19
|
+
# Functions...
|
20
|
+
#--------------------------------------
|
21
|
+
test -f /.kconfig && . /.kconfig
|
22
|
+
test -f /.profile && . /.profile
|
23
|
+
|
24
|
+
#======================================
|
25
|
+
# Greeting...
|
26
|
+
#--------------------------------------
|
27
|
+
echo "Configure image: [$kiwi_iname]..."
|
28
|
+
|
29
|
+
#======================================
|
30
|
+
# Setup baseproduct link
|
31
|
+
#--------------------------------------
|
32
|
+
suseSetupProduct
|
33
|
+
|
34
|
+
#======================================
|
35
|
+
# SuSEconfig
|
36
|
+
#--------------------------------------
|
37
|
+
suseConfig
|
38
|
+
|
39
|
+
#======================================
|
40
|
+
# Activate services
|
41
|
+
#--------------------------------------
|
42
|
+
suseActivateDefaultServices
|
43
|
+
|
44
|
+
#======================================
|
45
|
+
# Umount kernel filesystems
|
46
|
+
#--------------------------------------
|
47
|
+
baseCleanMount
|
48
|
+
|
49
|
+
exit 0
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<image schemaversion="6.1" name="sles-11-SP2-docker-guest">
|
4
|
+
<description type="system">
|
5
|
+
<author>Flavio Castelli</author>
|
6
|
+
<contact>fcastelli@suse.com</contact>
|
7
|
+
<specification>SLE 11 SP2 Docker image</specification>
|
8
|
+
</description>
|
9
|
+
<preferences>
|
10
|
+
<type image="docker" container="sles11sp2">
|
11
|
+
<machine>
|
12
|
+
<vmdisk/>
|
13
|
+
<vmnic interface="eth0" mode="veth"/>
|
14
|
+
</machine>
|
15
|
+
</type>
|
16
|
+
<version>1.0.0</version>
|
17
|
+
<packagemanager>zypper</packagemanager>
|
18
|
+
<rpm-check-signatures>false</rpm-check-signatures>
|
19
|
+
<rpm-force>true</rpm-force>
|
20
|
+
<locale>en_US</locale>
|
21
|
+
<keytable>us.map.gz</keytable>
|
22
|
+
<hwclock>utc</hwclock>
|
23
|
+
<timezone>US/Eastern</timezone>
|
24
|
+
</preferences>
|
25
|
+
<users group="root">
|
26
|
+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
|
27
|
+
</users>
|
28
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP2:Updates" <%= credentials %>>
|
29
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/repo/$RCE/SLES11-SP2-Updates/sle-11-x86_64<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
30
|
+
</repository>
|
31
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP2:Core" <%= credentials %>>
|
32
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/repo/$RCE/SLES11-SP2-Core/sle-11-x86_64<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
33
|
+
</repository>
|
34
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP1:Updates" <%= credentials %>>
|
35
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/repo/$RCE/SLES11-SP1-Updates/sle-11-x86_64<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
36
|
+
</repository>
|
37
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP1:Pool" <%= credentials %>>
|
38
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/repo/$RCE/SLES11-SP1-Pool/sle-11-x86_64<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
39
|
+
</repository>
|
40
|
+
<packages type="image">
|
41
|
+
<package name="coreutils"/>
|
42
|
+
<package name="iputils"/>
|
43
|
+
</packages>
|
44
|
+
<packages type="bootstrap">
|
45
|
+
<package name="filesystem"/>
|
46
|
+
<package name="glibc-locale"/>
|
47
|
+
<package name="libstdc++46"/>
|
48
|
+
<package name="libgcc46"/>
|
49
|
+
<package name="openssl-certs"/>
|
50
|
+
</packages>
|
51
|
+
</image>
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#================
|
3
|
+
# FILE : config.sh
|
4
|
+
#----------------
|
5
|
+
# PROJECT : OpenSuSE KIWI Image System
|
6
|
+
# COPYRIGHT : (c) 2013 SUSE LLC
|
7
|
+
# :
|
8
|
+
# AUTHOR : Robert Schweikert <rjschwei@suse.com>
|
9
|
+
# :
|
10
|
+
# BELONGS TO : Operating System images
|
11
|
+
# :
|
12
|
+
# DESCRIPTION : configuration script for SUSE based
|
13
|
+
# : operating systems
|
14
|
+
# :
|
15
|
+
# :
|
16
|
+
# STATUS : BETA
|
17
|
+
#----------------
|
18
|
+
#======================================
|
19
|
+
# Functions...
|
20
|
+
#--------------------------------------
|
21
|
+
test -f /.kconfig && . /.kconfig
|
22
|
+
test -f /.profile && . /.profile
|
23
|
+
|
24
|
+
#======================================
|
25
|
+
# Greeting...
|
26
|
+
#--------------------------------------
|
27
|
+
echo "Configure image: [$kiwi_iname]..."
|
28
|
+
|
29
|
+
#======================================
|
30
|
+
# Setup baseproduct link
|
31
|
+
#--------------------------------------
|
32
|
+
suseSetupProduct
|
33
|
+
|
34
|
+
#======================================
|
35
|
+
# SuSEconfig
|
36
|
+
#--------------------------------------
|
37
|
+
suseConfig
|
38
|
+
|
39
|
+
#======================================
|
40
|
+
# Activate services
|
41
|
+
#--------------------------------------
|
42
|
+
suseActivateDefaultServices
|
43
|
+
|
44
|
+
#======================================
|
45
|
+
# Umount kernel filesystems
|
46
|
+
#--------------------------------------
|
47
|
+
baseCleanMount
|
48
|
+
|
49
|
+
exit 0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<image schemaversion="6.1" name="sles-11-SP3-docker-guest">
|
4
|
+
<description type="system">
|
5
|
+
<author>Flavio Castelli</author>
|
6
|
+
<contact>fcastelli@suse.com</contact>
|
7
|
+
<specification>SLE 11 SP3 Docker image</specification>
|
8
|
+
</description>
|
9
|
+
<preferences>
|
10
|
+
<type image="docker" container="sles11sp3">
|
11
|
+
<machine>
|
12
|
+
<vmdisk/>
|
13
|
+
<vmnic interface="eth0" mode="veth"/>
|
14
|
+
</machine>
|
15
|
+
</type>
|
16
|
+
<version>1.0.0</version>
|
17
|
+
<packagemanager>zypper</packagemanager>
|
18
|
+
<rpm-check-signatures>false</rpm-check-signatures>
|
19
|
+
<rpm-force>true</rpm-force>
|
20
|
+
<locale>en_US</locale>
|
21
|
+
<keytable>us.map.gz</keytable>
|
22
|
+
<hwclock>utc</hwclock>
|
23
|
+
<timezone>US/Eastern</timezone>
|
24
|
+
</preferences>
|
25
|
+
<users group="root">
|
26
|
+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
|
27
|
+
</users>
|
28
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Updates" <%= credentials %>>
|
29
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/repo/$RCE/SLES11-SP3-Updates/sle-11-x86_64<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
30
|
+
</repository>
|
31
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Pool" <%= credentials %>>
|
32
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/repo/$RCE/SLES11-SP3-Pool/sle-11-x86_64<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
33
|
+
</repository>
|
34
|
+
<packages type="image">
|
35
|
+
<package name="coreutils"/>
|
36
|
+
<package name="iputils"/>
|
37
|
+
</packages>
|
38
|
+
<packages type="bootstrap">
|
39
|
+
<package name="filesystem"/>
|
40
|
+
<package name="glibc-locale"/>
|
41
|
+
<package name="libstdc++6"/>
|
42
|
+
<package name="libgcc_s1"/>
|
43
|
+
<package name="openssl-certs" />
|
44
|
+
</packages>
|
45
|
+
</image>
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#================
|
3
|
+
# FILE : config.sh
|
4
|
+
#----------------
|
5
|
+
# PROJECT : OpenSuSE KIWI Image System
|
6
|
+
# COPYRIGHT : (c) 2013 SUSE LLC
|
7
|
+
# :
|
8
|
+
# AUTHOR : Robert Schweikert <rjschwei@suse.com>
|
9
|
+
# :
|
10
|
+
# BELONGS TO : Operating System images
|
11
|
+
# :
|
12
|
+
# DESCRIPTION : configuration script for SUSE based
|
13
|
+
# : operating systems
|
14
|
+
# :
|
15
|
+
# :
|
16
|
+
# STATUS : BETA
|
17
|
+
#----------------
|
18
|
+
#======================================
|
19
|
+
# Functions...
|
20
|
+
#--------------------------------------
|
21
|
+
test -f /.kconfig && . /.kconfig
|
22
|
+
test -f /.profile && . /.profile
|
23
|
+
|
24
|
+
#======================================
|
25
|
+
# Greeting...
|
26
|
+
#--------------------------------------
|
27
|
+
echo "Configure image: [$kiwi_iname]..."
|
28
|
+
|
29
|
+
#======================================
|
30
|
+
# Setup baseproduct link
|
31
|
+
#--------------------------------------
|
32
|
+
suseSetupProduct
|
33
|
+
|
34
|
+
#======================================
|
35
|
+
# SuSEconfig
|
36
|
+
#--------------------------------------
|
37
|
+
suseConfig
|
38
|
+
|
39
|
+
#======================================
|
40
|
+
# Activate services
|
41
|
+
#--------------------------------------
|
42
|
+
suseActivateDefaultServices
|
43
|
+
|
44
|
+
#======================================
|
45
|
+
# Umount kernel filesystems
|
46
|
+
#--------------------------------------
|
47
|
+
baseCleanMount
|
48
|
+
|
49
|
+
exit 0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<image schemaversion="6.1" name="sle-12-docker-guest">
|
4
|
+
<description type="system">
|
5
|
+
<author>Flavio Castelli</author>
|
6
|
+
<contact>fcastelli@suse.com</contact>
|
7
|
+
<specification>SLE 12 docker container</specification>
|
8
|
+
</description>
|
9
|
+
<preferences>
|
10
|
+
<type image="docker" container="sle12">
|
11
|
+
<machine>
|
12
|
+
<vmdisk/>
|
13
|
+
<vmnic interface="eth0" mode="veth"/>
|
14
|
+
</machine>
|
15
|
+
</type>
|
16
|
+
<version>1.0.0</version>
|
17
|
+
<packagemanager>zypper</packagemanager>
|
18
|
+
<rpm-check-signatures>false</rpm-check-signatures>
|
19
|
+
<rpm-force>true</rpm-force>
|
20
|
+
<locale>en_US</locale>
|
21
|
+
<keytable>us.map.gz</keytable>
|
22
|
+
<hwclock>utc</hwclock>
|
23
|
+
<timezone>US/Eastern</timezone>
|
24
|
+
</preferences>
|
25
|
+
<users group="root">
|
26
|
+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
|
27
|
+
</users>
|
28
|
+
<repository type="rpm-md" imageinclude="true" alias="SLE12:Pool" >
|
29
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/SUSE:/Products:/SLE-12/images/repo/SLE-12-Server-POOL-x86_64-Media1/<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
30
|
+
</repository>
|
31
|
+
<repository type="rpm-md" imageinclude="true" alias="SLE12:Updates" >
|
32
|
+
<source path="http<%= "s" if enable_https %>://<%= host %>/SUSE:/Updates:/SLE-SERVER:/12:/x86_64/standard<%= "?credentials=NCCcredentials" if use_ncc %>"/>
|
33
|
+
</repository>
|
34
|
+
<packages type="image">
|
35
|
+
<package name="coreutils"/>
|
36
|
+
<package name="iputils"/>
|
37
|
+
</packages>
|
38
|
+
<packages type="bootstrap">
|
39
|
+
<package name="filesystem"/>
|
40
|
+
<package name="glibc-locale"/>
|
41
|
+
<package name="ca-certificates"/>
|
42
|
+
<package name="ca-certificates-mozilla"/>
|
43
|
+
</packages>
|
44
|
+
</image>
|
File without changes
|
data/sle2docker.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path("../lib/sle2docker/version", __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sle2docker"
|
7
|
+
s.version = Sle2Docker::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Flavio Castelli']
|
10
|
+
s.email = ['fcastelli@suse.com']
|
11
|
+
s.homepage = "https://github.com/SUSE/sle2docker"
|
12
|
+
s.summary = "Create SLE images for Docker"
|
13
|
+
s.description = "Quickly create SLE images for Docker using kiwi."
|
14
|
+
|
15
|
+
s.required_rubygems_version = ">= 1.3.6"
|
16
|
+
s.rubyforge_project = "sle2docker"
|
17
|
+
|
18
|
+
s.add_development_dependency "bundler"
|
19
|
+
s.add_development_dependency "yard"
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
22
|
+
s.require_path = 'lib'
|
23
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class BuilderTest < MiniTest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@options = {
|
7
|
+
:username => nil,
|
8
|
+
:password => '',
|
9
|
+
:smt_host => nil,
|
10
|
+
:disable_https => false
|
11
|
+
}
|
12
|
+
|
13
|
+
@template_file = File.join(Sle2Docker::Template.template_dir("SLE11SP3"),
|
14
|
+
"config.xml.erb")
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# testing render_template
|
19
|
+
|
20
|
+
def test_render_template_ncc_nothing_set
|
21
|
+
expected = read_fixture("sle11sp3_config.xml")
|
22
|
+
password = "fake password"
|
23
|
+
username = "test_user"
|
24
|
+
|
25
|
+
builder = Sle2Docker::Builder.new(@options)
|
26
|
+
|
27
|
+
$stdin = FakeStdin.new([username, password])
|
28
|
+
|
29
|
+
template = ""
|
30
|
+
stdout = capture(:stdout) do
|
31
|
+
template = builder.render_template(@template_file)
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_equal(expected, template)
|
35
|
+
stdout_expected_sequence = ["Enter NCC username:", "Enter NCC password:"]
|
36
|
+
assert_equal(stdout.split("\n"), stdout_expected_sequence)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_render_template_ncc_username_set
|
40
|
+
expected = read_fixture("sle11sp3_config.xml")
|
41
|
+
password = "fake password"
|
42
|
+
@options[:username] = "test_user"
|
43
|
+
|
44
|
+
builder = Sle2Docker::Builder.new(@options)
|
45
|
+
|
46
|
+
$stdin = FakeStdin.new([password])
|
47
|
+
|
48
|
+
template = ""
|
49
|
+
stdout = capture(:stdout) do
|
50
|
+
template = builder.render_template(@template_file)
|
51
|
+
end
|
52
|
+
|
53
|
+
assert_equal(expected, template)
|
54
|
+
assert_equal("Enter NCC password:", stdout.chomp)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_render_template_ncc_username_and_password_set
|
58
|
+
expected = read_fixture("sle11sp3_config.xml")
|
59
|
+
@options[:password] = "fake password"
|
60
|
+
@options[:username] = "test_user"
|
61
|
+
|
62
|
+
builder = Sle2Docker::Builder.new(@options)
|
63
|
+
|
64
|
+
template = ""
|
65
|
+
stdout = capture(:stdout) do
|
66
|
+
template = STDIN.stub(:gets, RuntimeError.new("Not expected!")) do
|
67
|
+
builder.render_template(@template_file)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_equal(expected, template)
|
72
|
+
assert stdout.empty?
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_render_template_smt_no_auth
|
76
|
+
expected = read_fixture("sle11sp3_smt_no_auth_https_config.xml")
|
77
|
+
@options[:smt_host] = "my_smt.local"
|
78
|
+
|
79
|
+
builder = Sle2Docker::Builder.new(@options)
|
80
|
+
|
81
|
+
template = ""
|
82
|
+
stdout = capture(:stdout) do
|
83
|
+
template = STDIN.stub(:gets, RuntimeError.new("Not expected!")) do
|
84
|
+
builder.render_template(@template_file)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
assert_equal(expected, template)
|
89
|
+
assert stdout.empty?
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_render_template_smt_no_auth_disable_https
|
93
|
+
expected = read_fixture("sle11sp3_smt_no_auth_no_https_config.xml")
|
94
|
+
@options[:smt_host] = "my_smt.local"
|
95
|
+
@options[:disable_https] = true
|
96
|
+
|
97
|
+
builder = Sle2Docker::Builder.new(@options)
|
98
|
+
|
99
|
+
template = ""
|
100
|
+
stdout = capture(:stdout) do
|
101
|
+
template = STDIN.stub(:gets, RuntimeError.new("Not expected!")) do
|
102
|
+
builder.render_template(@template_file)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_equal(expected, template)
|
107
|
+
assert stdout.empty?
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_render_template_smt_username_set
|
111
|
+
expected = read_fixture("sle11sp3_smt_auth_config.xml")
|
112
|
+
@options[:smt_host] = "my_smt.local"
|
113
|
+
@options[:disable_https] = true
|
114
|
+
@options[:username] = "test_user"
|
115
|
+
password = "fake password"
|
116
|
+
|
117
|
+
builder = Sle2Docker::Builder.new(@options)
|
118
|
+
|
119
|
+
$stdin = FakeStdin.new([password])
|
120
|
+
|
121
|
+
template = ""
|
122
|
+
stdout = capture(:stdout) do
|
123
|
+
template = builder.render_template(@template_file)
|
124
|
+
end
|
125
|
+
|
126
|
+
assert_equal(expected, template)
|
127
|
+
assert_equal("Enter password:", stdout.chomp)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_render_template_smt_password_set
|
131
|
+
expected = read_fixture("sle11sp3_smt_auth_config.xml")
|
132
|
+
@options[:smt_host] = "my_smt.local"
|
133
|
+
@options[:disable_https] = true
|
134
|
+
@options[:password] = "fake password"
|
135
|
+
username = "test_user"
|
136
|
+
|
137
|
+
builder = Sle2Docker::Builder.new(@options)
|
138
|
+
|
139
|
+
$stdin = FakeStdin.new([username])
|
140
|
+
|
141
|
+
template = ""
|
142
|
+
stdout = capture(:stdout) do
|
143
|
+
template = builder.render_template(@template_file)
|
144
|
+
end
|
145
|
+
|
146
|
+
assert_equal(expected, template)
|
147
|
+
assert_equal("Enter username:", stdout.chomp)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Testing find_template_file
|
151
|
+
|
152
|
+
def test_find_template_file
|
153
|
+
template = Sle2Docker::Template.list.first
|
154
|
+
template_dir = Sle2Docker::Template.template_dir(template)
|
155
|
+
builder = Sle2Docker::Builder.new(@options)
|
156
|
+
|
157
|
+
actual = builder.find_template_file(template_dir)
|
158
|
+
assert File.exist?(actual)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_find_template_file_raises_exception_on_missing_file
|
162
|
+
builder = Sle2Docker::Builder.new(@options)
|
163
|
+
|
164
|
+
assert_raises(Sle2Docker::ConfigNotFoundError) do
|
165
|
+
builder.find_template_file("/tmp")
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<image schemaversion="6.1" name="sles-11-SP3-docker-guest">
|
4
|
+
<description type="system">
|
5
|
+
<author>Flavio Castelli</author>
|
6
|
+
<contact>fcastelli@suse.com</contact>
|
7
|
+
<specification>SLE 11 SP3 Docker image</specification>
|
8
|
+
</description>
|
9
|
+
<preferences>
|
10
|
+
<type image="docker" container="sles11sp3">
|
11
|
+
<machine>
|
12
|
+
<vmdisk/>
|
13
|
+
<vmnic interface="eth0" mode="veth"/>
|
14
|
+
</machine>
|
15
|
+
</type>
|
16
|
+
<version>1.0.0</version>
|
17
|
+
<packagemanager>zypper</packagemanager>
|
18
|
+
<rpm-check-signatures>false</rpm-check-signatures>
|
19
|
+
<rpm-force>true</rpm-force>
|
20
|
+
<locale>en_US</locale>
|
21
|
+
<keytable>us.map.gz</keytable>
|
22
|
+
<hwclock>utc</hwclock>
|
23
|
+
<timezone>US/Eastern</timezone>
|
24
|
+
</preferences>
|
25
|
+
<users group="root">
|
26
|
+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
|
27
|
+
</users>
|
28
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Updates" username='test_user' password='fake password'>
|
29
|
+
<source path="https://nu.novell.com/repo/$RCE/SLES11-SP3-Updates/sle-11-x86_64?credentials=NCCcredentials"/>
|
30
|
+
</repository>
|
31
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Pool" username='test_user' password='fake password'>
|
32
|
+
<source path="https://nu.novell.com/repo/$RCE/SLES11-SP3-Pool/sle-11-x86_64?credentials=NCCcredentials"/>
|
33
|
+
</repository>
|
34
|
+
<packages type="image">
|
35
|
+
<package name="coreutils"/>
|
36
|
+
<package name="iputils"/>
|
37
|
+
</packages>
|
38
|
+
<packages type="bootstrap">
|
39
|
+
<package name="filesystem"/>
|
40
|
+
<package name="glibc-locale"/>
|
41
|
+
<package name="libstdc++6"/>
|
42
|
+
<package name="libgcc_s1"/>
|
43
|
+
<package name="openssl-certs" />
|
44
|
+
</packages>
|
45
|
+
</image>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<image schemaversion="6.1" name="sles-11-SP3-docker-guest">
|
4
|
+
<description type="system">
|
5
|
+
<author>Flavio Castelli</author>
|
6
|
+
<contact>fcastelli@suse.com</contact>
|
7
|
+
<specification>SLE 11 SP3 Docker image</specification>
|
8
|
+
</description>
|
9
|
+
<preferences>
|
10
|
+
<type image="docker" container="sles11sp3">
|
11
|
+
<machine>
|
12
|
+
<vmdisk/>
|
13
|
+
<vmnic interface="eth0" mode="veth"/>
|
14
|
+
</machine>
|
15
|
+
</type>
|
16
|
+
<version>1.0.0</version>
|
17
|
+
<packagemanager>zypper</packagemanager>
|
18
|
+
<rpm-check-signatures>false</rpm-check-signatures>
|
19
|
+
<rpm-force>true</rpm-force>
|
20
|
+
<locale>en_US</locale>
|
21
|
+
<keytable>us.map.gz</keytable>
|
22
|
+
<hwclock>utc</hwclock>
|
23
|
+
<timezone>US/Eastern</timezone>
|
24
|
+
</preferences>
|
25
|
+
<users group="root">
|
26
|
+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
|
27
|
+
</users>
|
28
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Updates" username='test_user' password='fake password'>
|
29
|
+
<source path="http://my_smt.local/repo/$RCE/SLES11-SP3-Updates/sle-11-x86_64"/>
|
30
|
+
</repository>
|
31
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Pool" username='test_user' password='fake password'>
|
32
|
+
<source path="http://my_smt.local/repo/$RCE/SLES11-SP3-Pool/sle-11-x86_64"/>
|
33
|
+
</repository>
|
34
|
+
<packages type="image">
|
35
|
+
<package name="coreutils"/>
|
36
|
+
<package name="iputils"/>
|
37
|
+
</packages>
|
38
|
+
<packages type="bootstrap">
|
39
|
+
<package name="filesystem"/>
|
40
|
+
<package name="glibc-locale"/>
|
41
|
+
<package name="libstdc++6"/>
|
42
|
+
<package name="libgcc_s1"/>
|
43
|
+
<package name="openssl-certs" />
|
44
|
+
</packages>
|
45
|
+
</image>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<image schemaversion="6.1" name="sles-11-SP3-docker-guest">
|
4
|
+
<description type="system">
|
5
|
+
<author>Flavio Castelli</author>
|
6
|
+
<contact>fcastelli@suse.com</contact>
|
7
|
+
<specification>SLE 11 SP3 Docker image</specification>
|
8
|
+
</description>
|
9
|
+
<preferences>
|
10
|
+
<type image="docker" container="sles11sp3">
|
11
|
+
<machine>
|
12
|
+
<vmdisk/>
|
13
|
+
<vmnic interface="eth0" mode="veth"/>
|
14
|
+
</machine>
|
15
|
+
</type>
|
16
|
+
<version>1.0.0</version>
|
17
|
+
<packagemanager>zypper</packagemanager>
|
18
|
+
<rpm-check-signatures>false</rpm-check-signatures>
|
19
|
+
<rpm-force>true</rpm-force>
|
20
|
+
<locale>en_US</locale>
|
21
|
+
<keytable>us.map.gz</keytable>
|
22
|
+
<hwclock>utc</hwclock>
|
23
|
+
<timezone>US/Eastern</timezone>
|
24
|
+
</preferences>
|
25
|
+
<users group="root">
|
26
|
+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
|
27
|
+
</users>
|
28
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Updates" >
|
29
|
+
<source path="https://my_smt.local/repo/$RCE/SLES11-SP3-Updates/sle-11-x86_64"/>
|
30
|
+
</repository>
|
31
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Pool" >
|
32
|
+
<source path="https://my_smt.local/repo/$RCE/SLES11-SP3-Pool/sle-11-x86_64"/>
|
33
|
+
</repository>
|
34
|
+
<packages type="image">
|
35
|
+
<package name="coreutils"/>
|
36
|
+
<package name="iputils"/>
|
37
|
+
</packages>
|
38
|
+
<packages type="bootstrap">
|
39
|
+
<package name="filesystem"/>
|
40
|
+
<package name="glibc-locale"/>
|
41
|
+
<package name="libstdc++6"/>
|
42
|
+
<package name="libgcc_s1"/>
|
43
|
+
<package name="openssl-certs" />
|
44
|
+
</packages>
|
45
|
+
</image>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
|
3
|
+
<image schemaversion="6.1" name="sles-11-SP3-docker-guest">
|
4
|
+
<description type="system">
|
5
|
+
<author>Flavio Castelli</author>
|
6
|
+
<contact>fcastelli@suse.com</contact>
|
7
|
+
<specification>SLE 11 SP3 Docker image</specification>
|
8
|
+
</description>
|
9
|
+
<preferences>
|
10
|
+
<type image="docker" container="sles11sp3">
|
11
|
+
<machine>
|
12
|
+
<vmdisk/>
|
13
|
+
<vmnic interface="eth0" mode="veth"/>
|
14
|
+
</machine>
|
15
|
+
</type>
|
16
|
+
<version>1.0.0</version>
|
17
|
+
<packagemanager>zypper</packagemanager>
|
18
|
+
<rpm-check-signatures>false</rpm-check-signatures>
|
19
|
+
<rpm-force>true</rpm-force>
|
20
|
+
<locale>en_US</locale>
|
21
|
+
<keytable>us.map.gz</keytable>
|
22
|
+
<hwclock>utc</hwclock>
|
23
|
+
<timezone>US/Eastern</timezone>
|
24
|
+
</preferences>
|
25
|
+
<users group="root">
|
26
|
+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/>
|
27
|
+
</users>
|
28
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Updates" >
|
29
|
+
<source path="http://my_smt.local/repo/$RCE/SLES11-SP3-Updates/sle-11-x86_64"/>
|
30
|
+
</repository>
|
31
|
+
<repository type="rpm-md" imageinclude="true" alias="SLES11:SP3:Pool" >
|
32
|
+
<source path="http://my_smt.local/repo/$RCE/SLES11-SP3-Pool/sle-11-x86_64"/>
|
33
|
+
</repository>
|
34
|
+
<packages type="image">
|
35
|
+
<package name="coreutils"/>
|
36
|
+
<package name="iputils"/>
|
37
|
+
</packages>
|
38
|
+
<packages type="bootstrap">
|
39
|
+
<package name="filesystem"/>
|
40
|
+
<package name="glibc-locale"/>
|
41
|
+
<package name="libstdc++6"/>
|
42
|
+
<package name="libgcc_s1"/>
|
43
|
+
<package name="openssl-certs" />
|
44
|
+
</packages>
|
45
|
+
</image>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class TemplateTest < MiniTest::Test
|
4
|
+
|
5
|
+
def test_list
|
6
|
+
actual = Sle2Docker::Template.list
|
7
|
+
expected = ['SLE11SP2', 'SLE11SP3', 'SLE12']
|
8
|
+
assert_equal expected.sort, actual.sort
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_complain_when_requested_template_does_not_exist
|
12
|
+
assert_raises(Sle2Docker::TemplateNotFoundError)do
|
13
|
+
Sle2Docker::Template.template_dir("foo")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_find_existing_template
|
18
|
+
dir = Sle2Docker::Template.template_dir(Sle2Docker::Template.list.first)
|
19
|
+
assert File.exist?(dir)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_find_should_be_case_insensitive
|
23
|
+
dir = Sle2Docker::Template.template_dir(
|
24
|
+
Sle2Docker::Template.list.first.downcase)
|
25
|
+
assert File.exist?(dir)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path('../../lib/sle2docker',__FILE__)
|
2
|
+
require 'bundler/setup' # Use bundled environment for testing
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class Object
|
7
|
+
def capture(stream)
|
8
|
+
begin
|
9
|
+
stream = stream.to_s
|
10
|
+
eval "$#{stream} = StringIO.new"
|
11
|
+
yield
|
12
|
+
result = eval("$#{stream}").string
|
13
|
+
ensure
|
14
|
+
eval("$#{stream} = #{stream.upcase}")
|
15
|
+
end
|
16
|
+
result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class MiniTest::Test
|
21
|
+
|
22
|
+
def read_fixture(name)
|
23
|
+
File.read(File.expand_path("../fixtures/#{name}", __FILE__))
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
class FakeStdin
|
29
|
+
|
30
|
+
# @param [Array[String]] fake_input
|
31
|
+
def initialize(fake_input)
|
32
|
+
@fake_input = fake_input.reverse
|
33
|
+
end
|
34
|
+
|
35
|
+
def gets()
|
36
|
+
@fake_input.pop
|
37
|
+
end
|
38
|
+
|
39
|
+
def noecho()
|
40
|
+
yield(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sle2docker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Flavio Castelli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Quickly create SLE images for Docker using kiwi.
|
42
|
+
email:
|
43
|
+
- fcastelli@suse.com
|
44
|
+
executables:
|
45
|
+
- sle2docker
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Changelog
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/sle2docker
|
55
|
+
- lib/sle2docker.rb
|
56
|
+
- lib/sle2docker/builder.rb
|
57
|
+
- lib/sle2docker/cli.rb
|
58
|
+
- lib/sle2docker/exceptions.rb
|
59
|
+
- lib/sle2docker/template.rb
|
60
|
+
- lib/sle2docker/version.rb
|
61
|
+
- lib/templates/SLE11SP2/config.sh
|
62
|
+
- lib/templates/SLE11SP2/config.xml.erb
|
63
|
+
- lib/templates/SLE11SP2/root/etc/resolv.conf
|
64
|
+
- lib/templates/SLE11SP3/config.sh
|
65
|
+
- lib/templates/SLE11SP3/config.xml.erb
|
66
|
+
- lib/templates/SLE11SP3/root/etc/resolv.conf
|
67
|
+
- lib/templates/SLE12/config.sh
|
68
|
+
- lib/templates/SLE12/config.xml.erb
|
69
|
+
- lib/templates/SLE12/root/etc/resolv.conf
|
70
|
+
- sle2docker.gemspec
|
71
|
+
- test/builder_test.rb
|
72
|
+
- test/fixtures/sle11sp3_config.xml
|
73
|
+
- test/fixtures/sle11sp3_smt_auth_config.xml
|
74
|
+
- test/fixtures/sle11sp3_smt_no_auth_https_config.xml
|
75
|
+
- test/fixtures/sle11sp3_smt_no_auth_no_https_config.xml
|
76
|
+
- test/template_test.rb
|
77
|
+
- test/test_helper.rb
|
78
|
+
homepage: https://github.com/SUSE/sle2docker
|
79
|
+
licenses: []
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.3.6
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project: sle2docker
|
97
|
+
rubygems_version: 2.0.3
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Create SLE images for Docker
|
101
|
+
test_files: []
|
102
|
+
has_rdoc:
|