tetra 0.43.0 → 0.44.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +1 -1
- data/README.md +2 -2
- data/SPECIAL_CASES.md +8 -8
- data/integration-tests/build-commons.sh +5 -6
- data/lib/template/gitignore +1 -1
- data/lib/template/{output → packages}/CONTENTS +0 -0
- data/lib/template/packages/kit/CONTENTS +3 -0
- data/lib/tetra.rb +14 -14
- data/lib/tetra/commands/generate_all.rb +7 -11
- data/lib/tetra/commands/{generate_package_archive.rb → generate_archive.rb} +3 -3
- data/lib/tetra/commands/{generate_kit_spec.rb → generate_kit.rb} +5 -2
- data/lib/tetra/commands/generate_script.rb +18 -0
- data/lib/tetra/commands/{generate_package_spec.rb → generate_spec.rb} +3 -3
- data/lib/tetra/git.rb +0 -8
- data/lib/tetra/main.rb +9 -15
- data/lib/tetra/packages/archivable.rb +26 -0
- data/lib/tetra/{package.rb → packages/built_package.rb} +11 -25
- data/lib/tetra/{glue_kit_item.rb → packages/glue_kit_item.rb} +14 -15
- data/lib/tetra/{jar_kit_item.rb → packages/jar_kit_item.rb} +13 -15
- data/lib/tetra/{kit.rb → packages/kit.rb} +0 -0
- data/lib/tetra/{maven_kit_item.rb → packages/maven_kit_item.rb} +13 -13
- data/lib/tetra/packages/scriptable.rb +48 -0
- data/lib/tetra/{spec_generator.rb → packages/speccable.rb} +12 -22
- data/lib/tetra/project.rb +19 -10
- data/lib/tetra/version.rb +1 -1
- data/spec/lib/archivable_spec.rb +36 -0
- data/spec/lib/{package_spec.rb → built_package_spec.rb} +4 -4
- data/spec/lib/git_spec.rb +0 -6
- data/spec/lib/glue_kit_item_spec.rb +1 -1
- data/spec/lib/maven_kit_item_spec.rb +2 -2
- data/spec/lib/project_spec.rb +8 -0
- data/spec/lib/{script_generator_spec.rb → scriptable_spec.rb} +8 -11
- data/spec/lib/{spec_generator_spec.rb → speccable.rb} +11 -20
- metadata +20 -20
- data/lib/tetra/archiver.rb +0 -31
- data/lib/tetra/commands/generate_kit_archive.rb +0 -18
- data/lib/tetra/commands/generate_package_script.rb +0 -18
- data/lib/tetra/script_generator.rb +0 -58
- data/spec/lib/archiver_spec.rb +0 -50
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -68,11 +68,11 @@ Fourth, you need to show `tetra` how to build your package by running appropriat
|
|
68
68
|
Note that we used `tetra mvn package` instead of `mvn package`: this will use of the Maven copy we put in `kit/` and the repository in `kit/m2`.
|
69
69
|
Also note that this being a dry-run build, sources will be brought back to their original state after `tetra finish`, as this ensures build repeatability.
|
70
70
|
|
71
|
-
Finally, generate build scripts, spec files and tarballs in the `
|
71
|
+
Finally, generate build scripts, spec files and tarballs in the `packages/` directory:
|
72
72
|
|
73
73
|
tetra generate-all
|
74
74
|
|
75
|
-
Note that `tetra` will generate files for the commons-collections package and all binary-only build-time dependencies
|
75
|
+
Note that `tetra` will generate files for the commons-collections package and all binary-only build-time dependencies in the `kit/` folder.
|
76
76
|
|
77
77
|
## In-depth information
|
78
78
|
|
data/SPECIAL_CASES.md
CHANGED
@@ -8,17 +8,16 @@ If your build fails for whatever reason, abort it with `tetra finish --abort`. `
|
|
8
8
|
|
9
9
|
You can do any manual changes to spec and build.sh files and regenerate them later, `tetra` will reconcile changes with a [three-way merge](http://en.wikipedia.org/wiki/Three-way_merge#Three-way_merge) and alert about any conflicts. You can generate single files with the following commands:
|
10
10
|
|
11
|
-
* `tetra generate-
|
12
|
-
* `tetra generate-
|
13
|
-
* `tetra generate-
|
14
|
-
* `tetra generate-
|
15
|
-
* `tetra generate-package-spec`: (re)generates the package spec;
|
11
|
+
* `tetra generate-script`: (re)generates the `build.sh` file from the latest bash history (assumes `tetra dry-run` and `tetra finish` have been used);
|
12
|
+
* `tetra generate-archive`: (re)generates the package tarball;
|
13
|
+
* `tetra generate-spec`: (re)generates the package spec;
|
14
|
+
* `tetra generate-kit`: (re)generates all kit tarballs and specs;
|
16
15
|
|
17
16
|
## Kit sources
|
18
17
|
|
19
18
|
Your kit packages are basically binary blobs. If its sources are needed for proper packaging, for example to comply with the GPL, some extra steps are needed.
|
20
19
|
|
21
|
-
If you use Maven, most (~90%) sources can be automatically downloaded:
|
20
|
+
If you use Maven, most (~90%) of the sources can be automatically downloaded:
|
22
21
|
|
23
22
|
tetra download-maven-source-jars
|
24
23
|
|
@@ -62,12 +61,13 @@ Other build tools are currently unsupported but will be added in the future. You
|
|
62
61
|
|
63
62
|
## [OBS](build.opensuse.org) integration
|
64
63
|
|
65
|
-
If you want to submit
|
64
|
+
If you want to submit your package to OBS, you can do so by copying contents of the `packages` and `packages/kit` in proper OBS project directories.
|
66
65
|
|
67
66
|
Packages will rebuild cleanly in OBS because no Internet access is needed - all files were already downloaded during dry-run and are included in the kit.
|
68
67
|
|
69
|
-
Note that
|
68
|
+
Note that packages in `kit` are only needed at build time only by OBS, no end user should ever install them, so you can place them in non-public repositories.
|
70
69
|
|
70
|
+
Also note that you can mix and match packages from `kit` with other `tetra`-built packages, even from other users, as they are designed to be immutable and will not break your builds.
|
71
71
|
|
72
72
|
## Gotchas
|
73
73
|
|
@@ -20,13 +20,12 @@ cd commons-collections-3.2.1-src/
|
|
20
20
|
tetra mvn package -DskipTests
|
21
21
|
tetra finish
|
22
22
|
|
23
|
-
tetra generate-kit
|
24
|
-
tetra generate-
|
25
|
-
tetra generate-
|
26
|
-
tetra generate-
|
27
|
-
# simulate tetra generate-package-script
|
23
|
+
tetra generate-kit
|
24
|
+
tetra generate-archive
|
25
|
+
tetra generate-spec
|
26
|
+
# simulate tetra generate-script
|
28
27
|
cd ../..
|
29
|
-
cat >
|
28
|
+
cat >packages/commons-collections/build.sh <<"EOF"
|
30
29
|
#!/bin/bash
|
31
30
|
PROJECT_PREFIX=`readlink -e .`
|
32
31
|
cd .
|
data/lib/template/gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
*.tetra_user_edited
|
2
|
-
|
2
|
+
packages/**/*.tar.xz
|
File without changes
|
data/lib/tetra.rb
CHANGED
@@ -23,7 +23,6 @@ require "zip"
|
|
23
23
|
require "tetra/version"
|
24
24
|
require "tetra/logger"
|
25
25
|
require "tetra/git"
|
26
|
-
require "tetra/script_generator"
|
27
26
|
require "tetra/project"
|
28
27
|
require "tetra/pom"
|
29
28
|
require "tetra/version_matcher"
|
@@ -33,28 +32,29 @@ require "tetra/source_getter"
|
|
33
32
|
require "tetra/kit_runner"
|
34
33
|
require "tetra/ant_runner"
|
35
34
|
require "tetra/maven_runner"
|
36
|
-
require "tetra/spec_generator"
|
37
|
-
require "tetra/archiver"
|
38
|
-
require "tetra/maven_kit_item"
|
39
|
-
require "tetra/jar_kit_item"
|
40
|
-
require "tetra/glue_kit_item"
|
41
|
-
require "tetra/kit"
|
42
|
-
require "tetra/package"
|
43
35
|
require "tetra/kit_checker"
|
44
36
|
|
37
|
+
# internal, package related
|
38
|
+
require "tetra/packages/archivable"
|
39
|
+
require "tetra/packages/speccable"
|
40
|
+
require "tetra/packages/scriptable"
|
41
|
+
require "tetra/packages/maven_kit_item"
|
42
|
+
require "tetra/packages/jar_kit_item"
|
43
|
+
require "tetra/packages/glue_kit_item"
|
44
|
+
require "tetra/packages/kit"
|
45
|
+
require "tetra/packages/built_package"
|
46
|
+
|
45
47
|
# internal, UI
|
46
48
|
require "tetra/commands/base"
|
47
|
-
|
48
49
|
require "tetra/commands/ant"
|
49
50
|
require "tetra/commands/download_maven_source_jars"
|
50
51
|
require "tetra/commands/dry_run"
|
51
52
|
require "tetra/commands/finish"
|
52
53
|
require "tetra/commands/generate_all"
|
53
|
-
require "tetra/commands/
|
54
|
-
require "tetra/commands/
|
55
|
-
require "tetra/commands/
|
56
|
-
require "tetra/commands/
|
57
|
-
require "tetra/commands/generate_package_spec"
|
54
|
+
require "tetra/commands/generate_kit"
|
55
|
+
require "tetra/commands/generate_archive"
|
56
|
+
require "tetra/commands/generate_script"
|
57
|
+
require "tetra/commands/generate_spec"
|
58
58
|
require "tetra/commands/get_pom"
|
59
59
|
require "tetra/commands/get_source"
|
60
60
|
require "tetra/commands/init"
|
@@ -10,20 +10,16 @@ module Tetra
|
|
10
10
|
checking_exceptions do
|
11
11
|
project = Tetra::Project.new(".")
|
12
12
|
ensure_dry_running(false, project) do
|
13
|
-
|
13
|
+
GenerateKitCommand.new(@invocation_path).execute
|
14
14
|
|
15
|
-
|
15
|
+
GenerateScriptCommand.new(@invocation_path).execute
|
16
16
|
|
17
|
-
|
18
|
-
script_command.execute
|
17
|
+
GenerateArchiveCommand.new(@invocation_path).execute
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
archive_command.filter = filter
|
25
|
-
archive_command.pom = pom
|
26
|
-
archive_command.execute
|
19
|
+
command = GenerateSpecCommand.new(@invocation_path)
|
20
|
+
command.filter = filter
|
21
|
+
command.pom = pom
|
22
|
+
command.execute
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Tetra
|
4
|
-
# tetra generate-
|
5
|
-
class
|
4
|
+
# tetra generate-archive
|
5
|
+
class GenerateArchiveCommand < Tetra::BaseCommand
|
6
6
|
def execute
|
7
7
|
checking_exceptions do
|
8
8
|
project = Tetra::Project.new(".")
|
9
9
|
ensure_dry_running(false, project) do
|
10
|
-
result_path = Tetra::
|
10
|
+
result_path = Tetra::BuiltPackage.new(project).to_archive
|
11
11
|
print_generation_result(project, result_path)
|
12
12
|
end
|
13
13
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Tetra
|
4
|
-
# tetra generate-kit
|
5
|
-
class
|
4
|
+
# tetra generate-kit
|
5
|
+
class GenerateKitCommand < Tetra::BaseCommand
|
6
6
|
def execute
|
7
7
|
checking_exceptions do
|
8
8
|
project = Tetra::Project.new(".")
|
@@ -10,6 +10,9 @@ module Tetra
|
|
10
10
|
Tetra::Kit.new(project).items.each do |item|
|
11
11
|
result_path, conflict_count = item.to_spec
|
12
12
|
print_generation_result(project, result_path, conflict_count)
|
13
|
+
|
14
|
+
result_path = item.to_archive
|
15
|
+
print_generation_result(project, result_path)
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Tetra
|
4
|
+
# tetra generate-script
|
5
|
+
class GenerateScriptCommand < Tetra::BaseCommand
|
6
|
+
def execute
|
7
|
+
checking_exceptions do
|
8
|
+
project = Tetra::Project.new(".")
|
9
|
+
ensure_dry_running(false, project) do
|
10
|
+
history = File.join(Dir.home, ".bash_history")
|
11
|
+
result_path, conflict_count =
|
12
|
+
Tetra::BuiltPackage.new(project).to_script(history)
|
13
|
+
print_generation_result(project, result_path, conflict_count)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Tetra
|
4
|
-
# tetra generate-
|
5
|
-
class
|
4
|
+
# tetra generate-spec
|
5
|
+
class GenerateSpecCommand < Tetra::BaseCommand
|
6
6
|
option %w(-f --filter), "FILTER", "filter files to be installed by this spec", default: "*.jar"
|
7
7
|
parameter "[POM]", "a pom file path", default: "pom.xml"
|
8
8
|
|
@@ -11,7 +11,7 @@ module Tetra
|
|
11
11
|
project = Tetra::Project.new(".")
|
12
12
|
ensure_dry_running(false, project) do
|
13
13
|
result_path, conflict_count =
|
14
|
-
Tetra::
|
14
|
+
Tetra::BuiltPackage.new(project, pom, filter).to_spec
|
15
15
|
print_generation_result(project, result_path, conflict_count)
|
16
16
|
end
|
17
17
|
end
|
data/lib/tetra/git.rb
CHANGED
@@ -53,14 +53,6 @@ module Tetra
|
|
53
53
|
Dir.chdir(@directory) do
|
54
54
|
log.debug "committing with message: #{message}"
|
55
55
|
|
56
|
-
# rename all .gitignore files by default as
|
57
|
-
# they prevent snapshotting
|
58
|
-
Find.find(".") do |file|
|
59
|
-
next unless file =~ /\.gitignore$/
|
60
|
-
|
61
|
-
FileUtils.mv(file, "#{file}_disabled_by_tetra")
|
62
|
-
end
|
63
|
-
|
64
56
|
`git rm -r --cached --ignore-unmatch .`
|
65
57
|
`git add .`
|
66
58
|
`git commit -m "#{message}"`
|
data/lib/tetra/main.rb
CHANGED
@@ -34,33 +34,27 @@ module Tetra
|
|
34
34
|
)
|
35
35
|
|
36
36
|
subcommand(
|
37
|
-
"generate-kit
|
38
|
-
"Create or refresh the kit
|
39
|
-
Tetra::
|
37
|
+
"generate-kit",
|
38
|
+
"Create or refresh the kit spec and archive files",
|
39
|
+
Tetra::GenerateKitCommand
|
40
40
|
)
|
41
41
|
|
42
42
|
subcommand(
|
43
|
-
"generate-
|
44
|
-
"Create or refresh the kit spec files",
|
45
|
-
Tetra::GenerateKitSpecCommand
|
46
|
-
)
|
47
|
-
|
48
|
-
subcommand(
|
49
|
-
"generate-package-script",
|
43
|
+
"generate-script",
|
50
44
|
"Create or refresh the package build.sh file",
|
51
|
-
Tetra::
|
45
|
+
Tetra::GenerateScriptCommand
|
52
46
|
)
|
53
47
|
|
54
48
|
subcommand(
|
55
|
-
"generate-
|
49
|
+
"generate-archive",
|
56
50
|
"Create or refresh the package tarball",
|
57
|
-
Tetra::
|
51
|
+
Tetra::GenerateArchiveCommand
|
58
52
|
)
|
59
53
|
|
60
54
|
subcommand(
|
61
|
-
"generate-
|
55
|
+
"generate-spec",
|
62
56
|
"Create or refresh the package spec file",
|
63
|
-
Tetra::
|
57
|
+
Tetra::GenerateSpecCommand
|
64
58
|
)
|
65
59
|
|
66
60
|
subcommand(
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Tetra
|
4
|
+
# adds methods to generate a tarball from a package object
|
5
|
+
module Archivable
|
6
|
+
include Logging
|
7
|
+
|
8
|
+
# generates an archive and returns its name
|
9
|
+
# this will archive source_paths starting from source_dir in
|
10
|
+
# destination_dir/name/name.tar.xz
|
11
|
+
def _to_archive(project, name, source_dir, source_paths, destination_dir)
|
12
|
+
full_destination_dir = File.join(project.full_path, destination_dir, name)
|
13
|
+
log.debug "creating #{full_destination_dir}"
|
14
|
+
FileUtils.mkdir_p(full_destination_dir)
|
15
|
+
|
16
|
+
project.from_directory(source_dir) do
|
17
|
+
destination_path = File.join(full_destination_dir, "#{name}.tar.xz")
|
18
|
+
log.debug "tarring to #{destination_path}"
|
19
|
+
|
20
|
+
`tar -cJf #{destination_path} #{source_paths.join(" ")}`
|
21
|
+
|
22
|
+
destination_path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module Tetra
|
4
4
|
# represents a Java project packaged in Tetra
|
5
|
-
class
|
5
|
+
class BuiltPackage
|
6
6
|
extend Forwardable
|
7
|
-
include
|
7
|
+
include Archivable
|
8
|
+
include Speccable
|
9
|
+
include Scriptable
|
8
10
|
|
9
11
|
def_delegator :@project, :name, :name
|
10
|
-
|
11
12
|
def_delegator :@kit, :items, :kit_items
|
12
|
-
|
13
13
|
def_delegator :@pom, :license_name, :license
|
14
14
|
def_delegator :@pom, :url
|
15
15
|
def_delegator :@pom, :group_id
|
@@ -17,26 +17,11 @@ module Tetra
|
|
17
17
|
def_delegator :@pom, :version
|
18
18
|
def_delegator :@pom, :runtime_dependency_ids
|
19
19
|
|
20
|
-
# implement to_spec
|
21
|
-
attr_reader :spec_dir
|
22
|
-
|
23
|
-
# implement to_archive
|
24
|
-
include Archiver
|
25
|
-
attr_reader :source_dir
|
26
|
-
attr_reader :source_paths
|
27
|
-
attr_reader :destination_dir
|
28
|
-
|
29
20
|
def initialize(project, pom_path = nil, filter = nil)
|
30
21
|
@project = project
|
31
22
|
@kit = Tetra::Kit.new(project)
|
32
23
|
@pom = pom_path.nil? ? nil : Tetra::Pom.new(pom_path)
|
33
24
|
@filter = filter
|
34
|
-
|
35
|
-
@spec_dir = "src"
|
36
|
-
|
37
|
-
@source_dir = "src"
|
38
|
-
@source_paths = ["*"]
|
39
|
-
@destination_dir = name
|
40
25
|
end
|
41
26
|
|
42
27
|
# a short summary from the POM
|
@@ -65,15 +50,16 @@ module Tetra
|
|
65
50
|
.sub(/\.+$/, "")
|
66
51
|
end
|
67
52
|
|
68
|
-
|
69
|
-
|
53
|
+
def to_archive
|
54
|
+
_to_archive(@project, name, "src", ["*"], @project.packages_dir)
|
55
|
+
end
|
70
56
|
|
71
|
-
def
|
72
|
-
name
|
57
|
+
def to_spec
|
58
|
+
_to_spec(@project, name, "package.spec", @project.packages_dir)
|
73
59
|
end
|
74
60
|
|
75
|
-
def
|
76
|
-
|
61
|
+
def to_script(history)
|
62
|
+
_to_script(@project, history)
|
77
63
|
end
|
78
64
|
end
|
79
65
|
end
|
@@ -4,21 +4,14 @@ module Tetra
|
|
4
4
|
# represents a prebuilt package dependency from a jar file
|
5
5
|
# in a kit
|
6
6
|
class GlueKitItem
|
7
|
-
|
8
|
-
include
|
7
|
+
include Archivable
|
8
|
+
include Speccable
|
9
|
+
|
9
10
|
attr_reader :project
|
10
11
|
attr_reader :package_name
|
11
|
-
attr_reader :spec_dir
|
12
|
-
attr_reader :template_spec_name
|
13
12
|
attr_reader :conflicts
|
14
|
-
|
15
|
-
# implement to_archive
|
16
|
-
include Archiver
|
17
13
|
attr_reader :source_dir
|
18
14
|
attr_reader :source_paths
|
19
|
-
attr_reader :destination_dir
|
20
|
-
|
21
|
-
# template-specific attributes
|
22
15
|
attr_reader :provides_symbol
|
23
16
|
attr_reader :provides_version
|
24
17
|
attr_reader :install_dir
|
@@ -26,17 +19,23 @@ module Tetra
|
|
26
19
|
def initialize(project, source_paths)
|
27
20
|
@project = project
|
28
21
|
@package_name = "kit-item-glue-#{project.name}"
|
29
|
-
@spec_dir = "kit"
|
30
|
-
@template_spec_name = "kit_item.spec"
|
31
22
|
@conflicts = true
|
32
|
-
|
33
|
-
@source_dir = File.join("kit")
|
23
|
+
@source_dir = "kit"
|
34
24
|
@source_paths = source_paths
|
35
|
-
@destination_dir = @package_name
|
36
25
|
|
37
26
|
@provides_symbol = "tetra-glue"
|
38
27
|
@provides_version = "#{project.name}-#{project.version}"
|
39
28
|
@install_dir = ""
|
40
29
|
end
|
30
|
+
|
31
|
+
def to_archive
|
32
|
+
_to_archive(@project, @package_name, @source_dir,
|
33
|
+
@source_paths, @project.kit_packages_dir)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_spec
|
37
|
+
_to_spec(@project, @package_name, "kit_item.spec",
|
38
|
+
@project.kit_packages_dir)
|
39
|
+
end
|
41
40
|
end
|
42
41
|
end
|