boxgrinder-build 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/LICENSE +165 -0
  2. data/README +4 -0
  3. data/appliances/jeos.appl +22 -0
  4. data/appliances/meta.appl +41 -0
  5. data/bin/boxgrinder +23 -0
  6. data/docs/examples/appliances/appliances-appliance/appliances-appliance.appl +6 -0
  7. data/docs/examples/appliances/appliances-appliance/appliances-appliance.pp +16 -0
  8. data/docs/examples/appliances/minimal-appliance/minimal-appliance.appl +2 -0
  9. data/docs/examples/appliances/minimal-appliance/minimal-appliance.pp +16 -0
  10. data/docs/examples/appliances/mix-appliance/mix-appliance.appl +9 -0
  11. data/docs/examples/appliances/mix-appliance/mix-appliance.pp +16 -0
  12. data/docs/examples/appliances/packages-appliance/packages-appliance.appl +6 -0
  13. data/docs/examples/appliances/packages-appliance/packages-appliance.pp +16 -0
  14. data/docs/node-info/pom.xml +31 -0
  15. data/docs/node-info/src/main/webapp/META-INF/MANIFEST.MF +3 -0
  16. data/docs/node-info/src/main/webapp/WEB-INF/web.xml +7 -0
  17. data/docs/node-info/src/main/webapp/index.jsp +70 -0
  18. data/extras/sign-rpms +12 -0
  19. data/lib/boxgrinder-build/appliance-kickstart.rb +159 -0
  20. data/lib/boxgrinder-build/appliance.rb +52 -0
  21. data/lib/boxgrinder-build/boxgrinder.rb +92 -0
  22. data/lib/boxgrinder-build/erb/appliance.ks.erb +44 -0
  23. data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +92 -0
  24. data/lib/boxgrinder-build/helpers/aws-helper.rb +75 -0
  25. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +86 -0
  26. data/lib/boxgrinder-build/helpers/rake-helper.rb +71 -0
  27. data/lib/boxgrinder-build/helpers/release-helper.rb +135 -0
  28. data/lib/boxgrinder-build/helpers/ssh-helper.rb +140 -0
  29. data/lib/boxgrinder-build/images/ec2-image.rb +301 -0
  30. data/lib/boxgrinder-build/images/raw-image.rb +137 -0
  31. data/lib/boxgrinder-build/images/vmware-image.rb +214 -0
  32. data/lib/boxgrinder-build/models/ssh-config.rb +44 -0
  33. data/lib/boxgrinder-build/validators/appliance-config-parameter-validator.rb +37 -0
  34. data/lib/boxgrinder-build/validators/appliance-definition-validator.rb +89 -0
  35. data/lib/boxgrinder-build/validators/appliance-dependency-validator.rb +163 -0
  36. data/lib/boxgrinder-build/validators/appliance-validator.rb +84 -0
  37. data/lib/boxgrinder-build/validators/aws-validator.rb +58 -0
  38. data/lib/boxgrinder-build/validators/config-validator.rb +67 -0
  39. data/lib/boxgrinder-build/validators/ssh-validator.rb +35 -0
  40. data/lib/boxgrinder-build/validators/validator.rb +91 -0
  41. data/lib/boxgrinder-build.rb +48 -0
  42. data/lib/progressbar/progressbar.rb +236 -0
  43. data/src/README.vmware +38 -0
  44. data/src/base.repo +4 -0
  45. data/src/base.vmdk +19 -0
  46. data/src/base.vmx +45 -0
  47. data/src/ec2/fstab_32bit +8 -0
  48. data/src/ec2/fstab_64bit +8 -0
  49. data/src/ec2/ifcfg-eth0 +7 -0
  50. data/src/ec2/rc_local +32 -0
  51. data/src/f12/yum.conf +24 -0
  52. data/src/motd.init +21 -0
  53. data/src/oddthesis/RPM-GPG-KEY-oddthesis +30 -0
  54. data/src/oddthesis/oddthesis.repo +23 -0
  55. metadata +197 -0
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README ADDED
@@ -0,0 +1,4 @@
1
+ Look here!
2
+ ==========
3
+
4
+ http://www.jboss.org/stormgrind/projects/boxgrinder/build.html
@@ -0,0 +1,22 @@
1
+ name: jeos
2
+ summary: Just Enough Operating System based on latest Fedora
3
+ packages:
4
+ includes:
5
+ - bash
6
+ - kernel
7
+ - grub
8
+ - e2fsprogs
9
+ - passwd
10
+ - policycoreutils
11
+ - chkconfig
12
+ - rootfiles
13
+ - yum
14
+ - vim-minimal
15
+ - acpid
16
+ - dhclient
17
+ - iputils
18
+ - generic-logos
19
+ - openssh-server
20
+ - openssh-clients
21
+ - mkinitrd
22
+
@@ -0,0 +1,41 @@
1
+ name: meta
2
+ summary: Environment for building new appliances using BoxGrinder
3
+ hardware:
4
+ memory: 1024
5
+ partitions:
6
+ - root: "/"
7
+ size: 10
8
+ appliances:
9
+ - jeos
10
+ packages:
11
+ includes:
12
+ - git
13
+ - wget
14
+ - gnupg2
15
+ - make
16
+ - gcc-c++
17
+ - expect
18
+ - rpmdevtools
19
+ - java-1.6.0-openjdk-devel
20
+ - autoconf
21
+ - createrepo
22
+ - appliance-tools
23
+ - yum-utils
24
+ - libdnet-devel
25
+ - libdnet
26
+ - libicu-devel
27
+ - httpd-devel
28
+ - glib2-devel
29
+ - ruby-devel
30
+ - ruby-libguestfs
31
+ - guestfish
32
+ - gdb
33
+ - qemu-stable
34
+ - zlib-devel
35
+ - SDL-devel
36
+ - rubygem-rake
37
+ - which
38
+ - sudo
39
+ - zlib-devel
40
+ - SDL-devel
41
+ - boxgrinder-environment
data/bin/boxgrinder ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # JBoss, Home of Professional Open Source
4
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
5
+ # by the @authors tag. See the copyright.txt in the distribution for a
6
+ # full listing of individual contributors.
7
+ #
8
+ # This is free software; you can redistribute it and/or modify it
9
+ # under the terms of the GNU Lesser General Public License as
10
+ # published by the Free Software Foundation; either version 2.1 of
11
+ # the License, or (at your option) any later version.
12
+ #
13
+ # This software is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this software; if not, write to the Free
20
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
22
+
23
+ require 'boxgrinder-build'
@@ -0,0 +1,6 @@
1
+
2
+ summary: This is a appliance with multiple appliances
3
+
4
+ appliances:
5
+ - minimal-appliance
6
+ - packages-appliance
@@ -0,0 +1,16 @@
1
+ # Modules used by the appliance
2
+ import "appliance_base"
3
+ import "banners"
4
+ import "firewall"
5
+ import "ssh"
6
+
7
+ # Information about our appliance
8
+ $appliance_name = "<%= appliance_summary %>"
9
+ $appliance_version = "<%= appliance_version %>"
10
+
11
+ # Configuration
12
+ appliance_base::setup{$appliance_name:}
13
+ appliance_base::enable_updates{$appliance_name:}
14
+ banners::all{$appliance_name:}
15
+ firewall::setup{$appliance_name: status=>"disabled"}
16
+ ssh::setup{$appliance_name:}
@@ -0,0 +1,2 @@
1
+
2
+ summary: This is a appliance with minimal package set
@@ -0,0 +1,16 @@
1
+ # Modules used by the appliance
2
+ import "appliance_base"
3
+ import "banners"
4
+ import "firewall"
5
+ import "ssh"
6
+
7
+ # Information about our appliance
8
+ $appliance_name = "<%= appliance_summary %>"
9
+ $appliance_version = "<%= appliance_version %>"
10
+
11
+ # Configuration
12
+ appliance_base::setup{$appliance_name:}
13
+ appliance_base::enable_updates{$appliance_name:}
14
+ banners::all{$appliance_name:}
15
+ firewall::setup{$appliance_name: status=>"disabled"}
16
+ ssh::setup{$appliance_name:}
@@ -0,0 +1,9 @@
1
+
2
+ summary: This is a appliance with additional packages and appliances
3
+
4
+ appliances:
5
+ - packages-appliance
6
+
7
+ packages:
8
+ - texlive-latex
9
+ - subversion
@@ -0,0 +1,16 @@
1
+ # Modules used by the appliance
2
+ import "appliance_base"
3
+ import "banners"
4
+ import "firewall"
5
+ import "ssh"
6
+
7
+ # Information about our appliance
8
+ $appliance_name = "<%= appliance_summary %>"
9
+ $appliance_version = "<%= appliance_version %>"
10
+
11
+ # Configuration
12
+ appliance_base::setup{$appliance_name:}
13
+ appliance_base::enable_updates{$appliance_name:}
14
+ banners::all{$appliance_name:}
15
+ firewall::setup{$appliance_name: status=>"disabled"}
16
+ ssh::setup{$appliance_name:}
@@ -0,0 +1,6 @@
1
+
2
+ summary: This is a appliance with additional packages
3
+
4
+ packages:
5
+ - mc
6
+ - subversion
@@ -0,0 +1,16 @@
1
+ # Modules used by the appliance
2
+ import "appliance_base"
3
+ import "banners"
4
+ import "firewall"
5
+ import "ssh"
6
+
7
+ # Information about our appliance
8
+ $appliance_name = "<%= appliance_summary %>"
9
+ $appliance_version = "<%= appliance_version %>"
10
+
11
+ # Configuration
12
+ appliance_base::setup{$appliance_name:}
13
+ appliance_base::enable_updates{$appliance_name:}
14
+ banners::all{$appliance_name:}
15
+ firewall::setup{$appliance_name: status=>"disabled"}
16
+ ssh::setup{$appliance_name:}
@@ -0,0 +1,31 @@
1
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
+ <modelVersion>4.0.0</modelVersion>
4
+ <groupId>org.jboss.cloud</groupId>
5
+ <artifactId>node-info</artifactId>
6
+ <packaging>war</packaging>
7
+ <version>1.0-SNAPSHOT</version>
8
+ <name>JBoss-Cloud node info</name>
9
+ <url>http://oddthesis.org/</url>
10
+ <dependencies>
11
+ <dependency>
12
+ <groupId>junit</groupId>
13
+ <artifactId>junit</artifactId>
14
+ <version>3.8.1</version>
15
+ <scope>test</scope>
16
+ </dependency>
17
+ </dependencies>
18
+ <developers>
19
+ <developer>
20
+ <name>Marek Goldmann</name>
21
+ <url>http://ordinarythoughts.org/</url>
22
+ </developer>
23
+ </developers>
24
+ <organization>
25
+ <name>JBoss</name>
26
+ <url>http://jboss.org/</url>
27
+ </organization>
28
+ <build>
29
+ <finalName>node-info</finalName>
30
+ </build>
31
+ </project>
@@ -0,0 +1,3 @@
1
+ Manifest-Version: 1.0
2
+ Class-Path:
3
+
@@ -0,0 +1,7 @@
1
+ <!DOCTYPE web-app PUBLIC
2
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
3
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
4
+
5
+ <web-app>
6
+ <display-name>Archetype Created Web Application</display-name>
7
+ </web-app>
@@ -0,0 +1,70 @@
1
+ <%@page contentType="text/html"
2
+ import="java.net.*,java.util.*,java.io.*"%>
3
+
4
+ <html>
5
+ <head>
6
+ <title>JBoss-Cloud node info</title>
7
+ </head>
8
+ <body>
9
+
10
+ <%
11
+ //borrowed from jmx-console
12
+
13
+ String bindAddress = "";
14
+ String serverName = "";
15
+ try {
16
+ bindAddress = System.getProperty("jboss.bind.address", "");
17
+ serverName = System.getProperty("jboss.server.name", "");
18
+ } catch (SecurityException se) {
19
+ }
20
+
21
+ String hostname = "";
22
+ try {
23
+ hostname = InetAddress.getLocalHost().getHostName();
24
+ } catch (IOException e) {
25
+ }
26
+
27
+ String hostInfo = hostname;
28
+ if (!bindAddress.equals("")) {
29
+ hostInfo = hostInfo + " (" + bindAddress + ")";
30
+ }
31
+ %>
32
+
33
+
34
+ <table>
35
+ <%
36
+ if (bindAddress.length() > 0) {
37
+ %>
38
+ <tr>
39
+ <td>JBoss Address:</td>
40
+ <td><%=bindAddress%></td>
41
+ </tr>
42
+
43
+ <%
44
+ }
45
+ if (serverName.length() > 0) {
46
+ %>
47
+ <tr>
48
+ <td>JBoss profile:</td>
49
+ <td><%=serverName%></td>
50
+ </tr>
51
+ <%
52
+ }
53
+ %>
54
+ <tr>
55
+ <td>Server name:</td>
56
+ <td><%=request.getServerName()%></td>
57
+ </tr>
58
+ <tr>
59
+ <td>Server port:</td>
60
+ <td><%=request.getServerPort()%></td>
61
+ </tr>
62
+ <tr>
63
+ <td>Remote address:</td>
64
+ <td><%=request.getRemoteAddr()%></td>
65
+ </tr>
66
+
67
+ </table>
68
+
69
+ </body>
70
+ </html>
data/extras/sign-rpms ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/expect -f
2
+
3
+ set password [lindex $argv 0]
4
+
5
+ foreach package [lrange $argv 1 end] {
6
+ spawn -noecho rpm --resign $package
7
+ expect -exact "Enter pass phrase: "
8
+ send "$password\r"
9
+ #expect -re "$package"
10
+ }
11
+
12
+ expect eof
@@ -0,0 +1,159 @@
1
+ # JBoss, Home of Professional Open Source
2
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
3
+ # by the @authors tag. See the copyright.txt in the distribution for a
4
+ # full listing of individual contributors.
5
+ #
6
+ # This is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Lesser General Public License as
8
+ # published by the Free Software Foundation; either version 2.1 of
9
+ # the License, or (at your option) any later version.
10
+ #
11
+ # This software is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this software; if not, write to the Free
18
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20
+
21
+ require "fileutils"
22
+ require 'rake/tasklib'
23
+ require 'yaml'
24
+ require 'erb'
25
+
26
+ module BoxGrinder
27
+
28
+ class ApplianceKickstart < Rake::TaskLib
29
+
30
+ def initialize( config, appliance_config, options = {} )
31
+ @config = config
32
+ @appliance_config = appliance_config
33
+ @log = options[:log] || Logger.new(STDOUT)
34
+
35
+ define_tasks
36
+ end
37
+
38
+ def build_definition
39
+ definition = { }
40
+
41
+ definition['partitions'] = @appliance_config.hardware.partitions.values
42
+ definition['name'] = @appliance_config.name
43
+ definition['arch'] = @appliance_config.hardware.arch
44
+ definition['appliance_names'] = @appliance_config.appliances
45
+ definition['repos'] = []
46
+
47
+ appliance_definition = @appliance_config.definition
48
+
49
+ if SUPPORTED_DESKTOP_TYPES.include?( appliance_definition['desktop'] )
50
+ definition['graphical'] = true
51
+
52
+ # default X package groups
53
+ definition['packages'] = [ "@base-x", "@base", "@core", "@fonts", "@input-methods", "@admin-tools", "@dial-up", "@hardware-support", "@printing" ]
54
+
55
+ #selected desktop environment
56
+ definition['packages'] += [ "@#{appliance_definition['desktop']}-desktop" ]
57
+ else
58
+ definition['graphical'] = false
59
+ definition['packages'] = []
60
+ end
61
+
62
+ definition['packages'] += @appliance_config.packages
63
+
64
+ # defautlt filesystem
65
+ definition['fstype'] = "ext3"
66
+
67
+ # fix for F12; this is needed because of selinux management in appliance-creator
68
+ if @appliance_config.os.name.eql?("fedora")
69
+ case @appliance_config.os.version.to_s
70
+ when "12" then
71
+ definition['packages'].push "system-config-firewall-base"
72
+ # default filesystem for fedora 12
73
+ #definition['fstype'] = "ext4"
74
+ when "11" then
75
+ definition['packages'].push "lokkit"
76
+ end
77
+ end
78
+
79
+ definition['root_password'] = @appliance_config.os.password
80
+
81
+ def definition.method_missing(sym, *args)
82
+ self[ sym.to_s ]
83
+ end
84
+
85
+ cost = 40
86
+
87
+ for repo in valid_repos + @appliance_config.repos
88
+
89
+ if repo.keys.include?('mirrorlist')
90
+ urltype = 'mirrorlist'
91
+ else
92
+ urltype = 'baseurl'
93
+ end
94
+
95
+ url = repo[urltype].gsub( /#ARCH#/, @appliance_config.hardware.arch )
96
+
97
+ repo_def = "repo --name=#{repo['name']} --cost=#{cost} --#{urltype}=#{url}"
98
+ repo_def += " --excludepkgs=#{repo['excludes'].join(',')}" unless repo['excludes'].nil? or repo['excludes'].empty?
99
+
100
+ definition['repos'] << repo_def
101
+
102
+ cost += 1
103
+ end
104
+
105
+ definition
106
+ end
107
+
108
+ def define_tasks
109
+ directory @appliance_config.path.dir.raw.build
110
+
111
+ file @appliance_config.path.file.raw.config => @appliance_config.path.dir.raw.build do
112
+ File.open( @appliance_config.path.file.raw.config, "w") {|f| f.write( @appliance_config.to_yaml ) } unless File.exists?( @appliance_config.path.file.raw.config )
113
+ end
114
+
115
+ task "appliance:#{@appliance_config.name}:config" do
116
+ if File.exists?( @appliance_config.path.file.raw.config )
117
+ unless @appliance_config.eql?( YAML.load_file( @appliance_config.path.file.raw.config ) )
118
+ FileUtils.rm_rf appliance_build_dir
119
+ end
120
+ end
121
+ end
122
+
123
+ file @appliance_config.path.file.raw.kickstart => [ @appliance_config.path.file.raw.config ] do
124
+ template = File.dirname( __FILE__ ) + "/erb/appliance.ks.erb"
125
+ kickstart = ERB.new( File.read( template ) ).result( build_definition.send( :binding ) )
126
+ File.open( @appliance_config.path.file.raw.kickstart, 'w' ) {|f| f.write( kickstart ) }
127
+ end
128
+
129
+ #desc "Build kickstart for #{File.basename( @appliance_config.name, '-appliance' )} appliance"
130
+ task "appliance:#{@appliance_config.name}:kickstart" => [ "appliance:#{@appliance_config.name}:config", @appliance_config.path.file.raw.kickstart ]
131
+
132
+ end
133
+
134
+ def valid_repos
135
+ os_repos = REPOS[@appliance_config.os.name][@appliance_config.os.version]
136
+
137
+ repos = Array.new
138
+
139
+ for type in [ "base", "updates" ]
140
+ unless os_repos[type].nil?
141
+
142
+ mirrorlist = os_repos[type]['mirrorlist']
143
+ baseurl = os_repos[type]['baseurl']
144
+
145
+ name = "#{@appliance_config.os.name}-#{@appliance_config.os.version}-#{type}"
146
+
147
+ if mirrorlist.nil?
148
+ repos.push({ "name" => name, "baseurl" => baseurl })
149
+ else
150
+ repos.push({ "name" => name, "mirrorlist" => mirrorlist })
151
+ end
152
+ end
153
+ end
154
+
155
+ repos
156
+ end
157
+ end
158
+
159
+ end