tetra 0.45.0 → 0.46.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +3 -0
- data/README.md +1 -1
- data/SPECIAL_CASES.md +9 -8
- data/integration-tests/build-obs.sh +6 -8
- data/lib/template/{kit_item.spec → kit.spec} +8 -11
- data/lib/template/package.spec +1 -3
- data/lib/template/packages/CONTENTS +0 -2
- data/lib/tetra.rb +0 -3
- data/lib/tetra/ant_runner.rb +1 -1
- data/lib/tetra/commands/generate_kit.rb +5 -6
- data/lib/tetra/commands/get_pom.rb +1 -1
- data/lib/tetra/commands/list_kit_missing_sources.rb +1 -1
- data/lib/tetra/maven_runner.rb +2 -6
- data/lib/tetra/maven_website.rb +1 -1
- data/lib/tetra/packages/archivable.rb +3 -3
- data/lib/tetra/packages/built_package.rb +4 -3
- data/lib/tetra/packages/kit.rb +16 -58
- data/lib/tetra/packages/scriptable.rb +15 -15
- data/lib/tetra/pom_getter.rb +1 -1
- data/lib/tetra/project.rb +4 -8
- data/lib/tetra/version.rb +1 -1
- data/lib/tetra/version_matcher.rb +14 -13
- data/spec/lib/archivable_spec.rb +1 -1
- data/spec/lib/built_package_spec.rb +1 -3
- data/spec/lib/kit_spec.rb +18 -38
- metadata +3 -9
- data/lib/template/packages/kit/CONTENTS +0 -3
- data/lib/tetra/packages/glue_kit_item.rb +0 -41
- data/lib/tetra/packages/jar_kit_item.rb +0 -44
- data/lib/tetra/packages/maven_kit_item.rb +0 -66
- data/spec/lib/glue_kit_item_spec.rb +0 -31
- data/spec/lib/maven_kit_item_spec.rb +0 -76
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -72,7 +72,7 @@ Finally, generate build scripts, spec files and tarballs in the `packages/` dire
|
|
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 in the `
|
75
|
+
Note that `tetra` will generate files for the commons-collections package and all binary-only build-time dependencies in the `packages/` folder.
|
76
76
|
|
77
77
|
## In-depth information
|
78
78
|
|
data/SPECIAL_CASES.md
CHANGED
@@ -11,11 +11,11 @@ You can do any manual changes to spec and build.sh files and regenerate them lat
|
|
11
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
12
|
* `tetra generate-archive`: (re)generates the package tarball;
|
13
13
|
* `tetra generate-spec`: (re)generates the package spec;
|
14
|
-
* `tetra generate-kit`: (re)generates
|
14
|
+
* `tetra generate-kit`: (re)generates the kit tarball and spec;
|
15
15
|
|
16
16
|
## Kit sources
|
17
17
|
|
18
|
-
Your kit
|
18
|
+
Your kit package is basically a binary blob. If its sources are needed for proper packaging, for example to comply with the GPL, some extra steps are needed.
|
19
19
|
|
20
20
|
If you use Maven, most (~90%) of the sources can be automatically downloaded:
|
21
21
|
|
@@ -55,26 +55,27 @@ Other build tools are currently unsupported but will be added in the future. You
|
|
55
55
|
|
56
56
|
## [OBS](build.opensuse.org) integration
|
57
57
|
|
58
|
-
If you want to submit your package to OBS, you can do so by copying contents of the `packages`
|
58
|
+
If you want to submit your package to OBS, you can do so by copying contents of the `packages` in a proper OBS project directory.
|
59
59
|
|
60
60
|
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.
|
61
61
|
|
62
|
-
Note that
|
63
|
-
|
64
|
-
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.
|
62
|
+
Note that the kit packages is only needed at build time by OBS, no end user should ever install it, so you can place it in a non-public project/repository if you so wish.
|
65
63
|
|
66
64
|
## Gotchas
|
67
65
|
|
68
66
|
* `tetra` internally uses `git` to keep track of files, any tetra project is actually also a `git` repo. Feel free to navigate it, you can commit, push and pull as long as the `tetra` tags are preserved. You can also delete commits and tags, effectively rewinding tetra history (just make sure to delete all tags pointing to a certain commit when you discard it);
|
69
67
|
* some Maven plugins like the Eclipse Project ones ([Tycho](https://www.eclipse.org/tycho/)) will save data in `/tmp` downloaded from the Internet and will produce errors if this data is not there during offline builds. One way to work around that is to force Java to use a kit subdirectory as `/tmp`. Add the following option to `tetra mvn` during your build:
|
70
68
|
|
71
|
-
-
|
69
|
+
-Djava.io.tmpdir=<full path to project>/kit/tmp
|
72
70
|
|
73
71
|
Use the following option in `mvn` in your build.sh file to make it reproducible:
|
74
72
|
|
75
|
-
-
|
73
|
+
-Djava.io.tmpdir=$PROJECT_PREFIX/kit/tmp
|
76
74
|
|
77
75
|
* Tycho builds may also require NSS, so if you get NSS errors be sure to add `mozilla-nss` or an equivalent package in a BuildRequires: line;
|
76
|
+
* some badly designed testsuites might not work in OBS. If you are using `tetra mvn` you can add the following option to disable them:
|
77
|
+
|
78
|
+
-DskipTests=true
|
78
79
|
|
79
80
|
* if you want to be 100% sure your package builds without network access, you can use scripts in the `utils/` folder to create a special `nonet` user that cannot use the Internet and retry the build from that user.
|
80
81
|
|
@@ -8,14 +8,12 @@
|
|
8
8
|
set -e
|
9
9
|
|
10
10
|
OBS_HOST=obs-client
|
11
|
-
OBS_PROJECT_DIR=/home/silvio/obs/home\:SilvioMoioli
|
11
|
+
OBS_PROJECT_DIR=/home/silvio/obs/home\:SilvioMoioli\:tetra-test
|
12
12
|
|
13
|
-
scp -r commons/
|
13
|
+
scp -r commons-collections/packages/* $OBS_HOST:/$OBS_PROJECT_DIR
|
14
14
|
ssh -t $OBS_HOST <<EOF
|
15
|
-
cd $OBS_PROJECT_DIR/commons-kit
|
16
|
-
osc build -k
|
17
|
-
cd
|
18
|
-
osc build -k
|
19
|
-
cd ../commons-fileupload/ &&\
|
20
|
-
osc build -k../rpms -p../rpms
|
15
|
+
cd $OBS_PROJECT_DIR/commons-collections-kit &&\
|
16
|
+
osc build -k../../rpms -p../../rpms &&\
|
17
|
+
cd $OBS_PROJECT_DIR/commons-collections &&\
|
18
|
+
osc build -k../../rpms -p../../rpms
|
21
19
|
EOF
|
@@ -12,21 +12,19 @@
|
|
12
12
|
# license that conforms to the Open Source Definition (Version 1.9)
|
13
13
|
# published by the Open Source Initiative.
|
14
14
|
|
15
|
-
Name: <%=
|
16
|
-
Version:
|
15
|
+
Name: <%= name %>
|
16
|
+
Version: <%= version %>
|
17
17
|
Release: 1
|
18
18
|
License: SUSE-NonFree
|
19
|
-
Summary: Build-time dependency of project "<%=
|
19
|
+
Summary: Build-time dependency of project "<%= project_name %>"
|
20
20
|
Url: https://github.com/SilvioMoioli/tetra
|
21
21
|
Group: Development/Libraries/Java
|
22
22
|
Source0: %{name}.tar.xz
|
23
23
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
24
24
|
BuildArch: noarch
|
25
25
|
BuildRequires: xz
|
26
|
-
Provides:
|
27
|
-
|
28
|
-
Conflicts: otherproviders(<%= provides_symbol %>)
|
29
|
-
<% end %>
|
26
|
+
Provides: tetra-kit
|
27
|
+
Conflicts: otherproviders(tetra-kit)
|
30
28
|
|
31
29
|
%description
|
32
30
|
This package has been automatically created by tetra in order to
|
@@ -42,12 +40,11 @@ thus it should never be installed on end users' systems.
|
|
42
40
|
|
43
41
|
%install
|
44
42
|
export NO_BRP_CHECK_BYTECODE_VERSION=true
|
45
|
-
install -d -m 0755 %{buildroot}%{_datadir}/tetra
|
46
|
-
cp -a * %{buildroot}%{_datadir}/tetra
|
43
|
+
install -d -m 0755 %{buildroot}%{_datadir}/tetra/
|
44
|
+
cp -a * %{buildroot}%{_datadir}/tetra/
|
47
45
|
|
48
46
|
%files
|
49
47
|
%defattr(-,root,root)
|
50
|
-
%{_datadir}/tetra
|
51
|
-
%{_datadir}/tetra/<%= install_dir %>
|
48
|
+
%{_datadir}/tetra/
|
52
49
|
|
53
50
|
%changelog
|
data/lib/template/package.spec
CHANGED
@@ -27,9 +27,7 @@ Source1: build.sh
|
|
27
27
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
28
28
|
BuildRequires: xz
|
29
29
|
BuildRequires: java-devel
|
30
|
-
|
31
|
-
BuildRequires: <%= item.provides_symbol %> == <%= item.provides_version %>
|
32
|
-
<% end %>
|
30
|
+
BuildRequires: <%= kit_name %> == <%= kit_version %>
|
33
31
|
BuildArch: noarch
|
34
32
|
Provides: mvn(<%= group_id %>:<%= artifact_id %>) == <%= version %>
|
35
33
|
Requires: java
|
data/lib/tetra.rb
CHANGED
@@ -38,9 +38,6 @@ require "tetra/kit_checker"
|
|
38
38
|
require "tetra/packages/archivable"
|
39
39
|
require "tetra/packages/speccable"
|
40
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
41
|
require "tetra/packages/kit"
|
45
42
|
require "tetra/packages/built_package"
|
46
43
|
|
data/lib/tetra/ant_runner.rb
CHANGED
@@ -7,7 +7,7 @@ module Tetra
|
|
7
7
|
|
8
8
|
# runs ant in a subprocess
|
9
9
|
def ant(options)
|
10
|
-
run_executable("#{get_ant_commandline(@project.full_path)} #{options.join(
|
10
|
+
run_executable("#{get_ant_commandline(@project.full_path)} #{options.join(' ')}")
|
11
11
|
end
|
12
12
|
|
13
13
|
# returns a command line for running Ant from the specified
|
@@ -7,13 +7,12 @@ module Tetra
|
|
7
7
|
checking_exceptions do
|
8
8
|
project = Tetra::Project.new(".")
|
9
9
|
ensure_dry_running(false, project) do
|
10
|
-
Tetra::Kit.new(project)
|
11
|
-
|
12
|
-
|
10
|
+
kit = Tetra::Kit.new(project)
|
11
|
+
result_path, conflict_count = kit.to_spec
|
12
|
+
print_generation_result(project, result_path, conflict_count)
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
14
|
+
result_path = kit.to_archive
|
15
|
+
print_generation_result(project, result_path)
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -25,7 +25,7 @@ module Tetra
|
|
25
25
|
puts "#{format_path(path, project)} written, #{text_status}"
|
26
26
|
else
|
27
27
|
puts "#{name}'s pom not found. Try:"
|
28
|
-
puts "http://google.com/#q=#{URI.encode(pom_getter.cleanup_name(name) +
|
28
|
+
puts "http://google.com/#q=#{URI.encode(pom_getter.cleanup_name(name) + ' pom')}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -12,7 +12,7 @@ module Tetra
|
|
12
12
|
puts "Some source files were not found in these archives:"
|
13
13
|
kit_checker.unsourced_archives.each do |archive|
|
14
14
|
percentage = 100.0 * archive[:unsourced_class_names].length / archive[:class_names].length
|
15
|
-
puts "#{format_path(archive[:archive], project)} (~#{format(
|
15
|
+
puts "#{format_path(archive[:archive], project)} (~#{format('%.2f', percentage)}% missing)"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/tetra/maven_runner.rb
CHANGED
@@ -21,11 +21,7 @@ module Tetra
|
|
21
21
|
def get_effective_pom(pom_path)
|
22
22
|
effective_pom_path = "#{pom_path}.effective"
|
23
23
|
success = mvn(["help:effective-pom", "-f#{pom_path}", "-Doutput=#{File.split(effective_pom_path)[1]}"])
|
24
|
-
if success
|
25
|
-
effective_pom_path
|
26
|
-
else
|
27
|
-
nil
|
28
|
-
end
|
24
|
+
effective_pom_path if success
|
29
25
|
end
|
30
26
|
|
31
27
|
# returns a command line for running Maven from the specified
|
@@ -38,7 +34,7 @@ module Tetra
|
|
38
34
|
repo_path = File.join(prefix, "kit", "m2")
|
39
35
|
config_path = File.join(prefix, "kit", "m2", "settings.xml")
|
40
36
|
|
41
|
-
"#{mvn_path} -Dmaven.repo.local=#{repo_path} -s#{config_path} #{options.join(
|
37
|
+
"#{mvn_path} -Dmaven.repo.local=#{repo_path} -s#{config_path} #{options.join(' ')}"
|
42
38
|
else
|
43
39
|
fail ExecutableNotFoundError, "mvn"
|
44
40
|
end
|
data/lib/tetra/maven_website.rb
CHANGED
@@ -51,7 +51,7 @@ module Tetra
|
|
51
51
|
|
52
52
|
# downloads a POM from a search.maven.com search result
|
53
53
|
def download_pom(group_id, artifact_id, version)
|
54
|
-
path = "#{group_id.gsub(
|
54
|
+
path = "#{group_id.gsub('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.pom"
|
55
55
|
log.debug("downloading #{path}...")
|
56
56
|
(RestClient.get "http://search.maven.org/remotecontent", params: { filepath: path }).to_s
|
57
57
|
end
|
@@ -6,9 +6,9 @@ module Tetra
|
|
6
6
|
include Logging
|
7
7
|
|
8
8
|
# generates an archive and returns its name
|
9
|
-
# this will archive
|
9
|
+
# this will archive files in source_dir in
|
10
10
|
# destination_dir/name/name.tar.xz
|
11
|
-
def _to_archive(project, name, source_dir,
|
11
|
+
def _to_archive(project, name, source_dir, destination_dir)
|
12
12
|
full_destination_dir = File.join(project.full_path, destination_dir, name)
|
13
13
|
log.debug "creating #{full_destination_dir}"
|
14
14
|
FileUtils.mkdir_p(full_destination_dir)
|
@@ -17,7 +17,7 @@ module Tetra
|
|
17
17
|
destination_path = File.join(full_destination_dir, "#{name}.tar.xz")
|
18
18
|
log.debug "tarring to #{destination_path}"
|
19
19
|
|
20
|
-
`tar -cJf #{destination_path}
|
20
|
+
`tar -cJf #{destination_path} *`
|
21
21
|
|
22
22
|
destination_path
|
23
23
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Tetra
|
4
|
-
# represents a Java project packaged in
|
4
|
+
# represents a Java project packaged in tetra
|
5
5
|
class BuiltPackage
|
6
6
|
extend Forwardable
|
7
7
|
include Archivable
|
@@ -9,7 +9,8 @@ module Tetra
|
|
9
9
|
include Scriptable
|
10
10
|
|
11
11
|
def_delegator :@project, :name, :name
|
12
|
-
def_delegator :@kit, :
|
12
|
+
def_delegator :@kit, :name, :kit_name
|
13
|
+
def_delegator :@kit, :version, :kit_version
|
13
14
|
def_delegator :@pom, :license_name, :license
|
14
15
|
def_delegator :@pom, :url
|
15
16
|
def_delegator :@pom, :group_id
|
@@ -51,7 +52,7 @@ module Tetra
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def to_archive
|
54
|
-
_to_archive(@project, name, "src",
|
55
|
+
_to_archive(@project, name, "src", @project.packages_dir)
|
55
56
|
end
|
56
57
|
|
57
58
|
def to_spec
|
data/lib/tetra/packages/kit.rb
CHANGED
@@ -1,73 +1,31 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Tetra
|
4
|
-
#
|
4
|
+
# a packaged set of binary build-time dependencies
|
5
5
|
class Kit
|
6
|
-
|
6
|
+
extend Forwardable
|
7
|
+
include Archivable
|
8
|
+
include Speccable
|
9
|
+
|
10
|
+
attr_reader :name
|
11
|
+
attr_reader :version
|
12
|
+
def_delegator :@project, :name, :project_name
|
7
13
|
|
8
14
|
def initialize(project)
|
9
15
|
@project = project
|
10
|
-
end
|
11
|
-
|
12
|
-
def items
|
13
|
-
managed_items = maven_kit_items + jar_kit_items
|
14
|
-
|
15
|
-
managed_items + glue_kit_items(managed_items)
|
16
|
-
end
|
17
16
|
|
18
|
-
|
19
|
-
@project.
|
20
|
-
files_in_dir = {}
|
21
|
-
poms = []
|
22
|
-
Find.find(".") do |file|
|
23
|
-
dir = File.dirname(file)
|
24
|
-
if files_in_dir.key?(dir)
|
25
|
-
files_in_dir[dir] << file
|
26
|
-
else
|
27
|
-
files_in_dir[dir] = [file]
|
28
|
-
end
|
29
|
-
|
30
|
-
if file =~ /\.pom$/
|
31
|
-
log.debug "pom found in #{file}"
|
32
|
-
poms << file
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
poms.map do |pom|
|
37
|
-
Tetra::MavenKitItem.new(@project, pom, files_in_dir[File.dirname(pom)])
|
38
|
-
end
|
39
|
-
end
|
17
|
+
@name = "#{project.name}-kit"
|
18
|
+
@version = "#{project.version}"
|
40
19
|
end
|
41
20
|
|
42
|
-
def
|
43
|
-
@project
|
44
|
-
|
45
|
-
child.to_s =~ /.jar$/
|
46
|
-
end.sort.map do |jar|
|
47
|
-
Tetra::JarKitItem.new(@project, jar)
|
48
|
-
end
|
49
|
-
end
|
21
|
+
def to_archive
|
22
|
+
_to_archive(@project, name, "kit",
|
23
|
+
@project.packages_dir)
|
50
24
|
end
|
51
25
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
Pathname.new(File.join(item.source_dir, e)).cleanpath
|
56
|
-
end
|
57
|
-
end.flatten
|
58
|
-
|
59
|
-
unmanaged_files = []
|
60
|
-
|
61
|
-
@project.from_directory do
|
62
|
-
Find.find("kit") do |file|
|
63
|
-
pathname = Pathname.new(file)
|
64
|
-
if !managed_files.include?(pathname) && !File.directory?(pathname)
|
65
|
-
unmanaged_files << pathname.relative_path_from(Pathname.new("kit"))
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
[Tetra::GlueKitItem.new(@project, unmanaged_files)]
|
26
|
+
def to_spec
|
27
|
+
_to_spec(@project, name, "kit.spec",
|
28
|
+
@project.packages_dir)
|
71
29
|
end
|
72
30
|
end
|
73
31
|
end
|
@@ -8,14 +8,14 @@ module Tetra
|
|
8
8
|
maven_runner = Tetra::MavenRunner.new(project)
|
9
9
|
|
10
10
|
project.from_directory do
|
11
|
-
history_lines = File.readlines(history_path).map
|
11
|
+
history_lines = File.readlines(history_path).map(&:strip)
|
12
12
|
relevant_lines =
|
13
13
|
history_lines
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
.reverse
|
15
|
+
.take_while { |e| e.match(/tetra +dry-run/).nil? }
|
16
|
+
.reverse
|
17
|
+
.take_while { |e| e.match(/tetra +finish/).nil? }
|
18
|
+
.select { |e| e.match(/^#/).nil? }
|
19
19
|
|
20
20
|
script_lines = [
|
21
21
|
"#!/bin/bash",
|
@@ -23,15 +23,15 @@ module Tetra
|
|
23
23
|
"PROJECT_PREFIX=`readlink -e .`",
|
24
24
|
"cd #{project.latest_dry_run_directory}"
|
25
25
|
] +
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
relevant_lines.map do |line|
|
27
|
+
if line =~ /tetra +mvn/
|
28
|
+
line.gsub(/tetra +mvn/, "#{maven_runner.get_maven_commandline('$PROJECT_PREFIX', ['-o'])}")
|
29
|
+
elsif line =~ /tetra +ant/
|
30
|
+
line.gsub(/tetra +ant/, "#{ant_runner.get_ant_commandline('$PROJECT_PREFIX')}")
|
31
|
+
else
|
32
|
+
line
|
33
|
+
end
|
34
|
+
end
|
35
35
|
|
36
36
|
new_content = script_lines.join("\n") + "\n"
|
37
37
|
|
data/lib/tetra/pom_getter.rb
CHANGED
@@ -45,7 +45,7 @@ module Tetra
|
|
45
45
|
result = results.first
|
46
46
|
unless result.nil?
|
47
47
|
log.info("pom.xml for #{file} found on search.maven.org for sha1 #{sha1}\
|
48
|
-
(#{result[
|
48
|
+
(#{result['g']}:#{result['a']}:#{result['v']})"
|
49
49
|
)
|
50
50
|
group_id, artifact_id, version = site.get_maven_id_from result
|
51
51
|
return site.download_pom(group_id, artifact_id, version), :found_via_sha1
|
data/lib/tetra/project.rb
CHANGED
@@ -25,10 +25,6 @@ module Tetra
|
|
25
25
|
"packages"
|
26
26
|
end
|
27
27
|
|
28
|
-
def kit_packages_dir
|
29
|
-
File.join(packages_dir, "kit")
|
30
|
-
end
|
31
|
-
|
32
28
|
# finds the project directory up in the tree, like git does
|
33
29
|
def self.find_project_dir(starting_dir)
|
34
30
|
result = starting_dir
|
@@ -44,8 +40,8 @@ module Tetra
|
|
44
40
|
# returns true if the specified directory is a valid tetra project
|
45
41
|
def self.project?(dir)
|
46
42
|
File.directory?(File.join(dir, "src")) &&
|
47
|
-
|
48
|
-
|
43
|
+
File.directory?(File.join(dir, "kit")) &&
|
44
|
+
File.directory?(File.join(dir, ".git"))
|
49
45
|
end
|
50
46
|
|
51
47
|
# inits a new project directory structure
|
@@ -217,8 +213,8 @@ module Tetra
|
|
217
213
|
FileUtils.mv(file, new_location)
|
218
214
|
|
219
215
|
link_target = Pathname.new(new_location)
|
220
|
-
|
221
|
-
|
216
|
+
.relative_path_from(Pathname.new(file).split.first)
|
217
|
+
.to_s
|
222
218
|
|
223
219
|
File.symlink(link_target, file)
|
224
220
|
result << [file, new_location]
|
data/lib/tetra/version.rb
CHANGED
@@ -26,24 +26,25 @@ module Tetra
|
|
26
26
|
# - score weighs differently on chunk index (first chunks are most important)
|
27
27
|
# - lowest score wins
|
28
28
|
def best_match(my_version, their_versions)
|
29
|
-
log.debug("version comparison: #{my_version} vs #{their_versions.join(
|
29
|
+
log.debug("version comparison: #{my_version} vs #{their_versions.join(', ')}")
|
30
30
|
|
31
31
|
my_chunks = my_version.split(/[\.\-\_ ~,]/)
|
32
32
|
their_chunks_hash = Hash[
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
their_versions.map do |their_version|
|
34
|
+
their_chunks_for_version = (
|
35
|
+
if !their_version.nil?
|
36
|
+
their_version.split(/[\.\-\_ ~,]/)
|
37
|
+
else
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
)
|
41
|
+
chunks_count = [my_chunks.length - their_chunks_for_version.length, 0].max
|
42
|
+
their_chunks_for_version += [nil] * chunks_count
|
43
|
+
[their_version, their_chunks_for_version]
|
44
|
+
end
|
44
45
|
]
|
45
46
|
|
46
|
-
max_chunks_length = ([my_chunks.length] + their_chunks_hash.values.map
|
47
|
+
max_chunks_length = ([my_chunks.length] + their_chunks_hash.values.map(&:length)).max
|
47
48
|
|
48
49
|
scoreboard = []
|
49
50
|
their_versions.each do |their_version|
|
data/spec/lib/archivable_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Tetra::Archivable do
|
|
26
26
|
FileUtils.touch("kit_test")
|
27
27
|
end
|
28
28
|
|
29
|
-
instance._to_archive(@project, "test-package", "kit",
|
29
|
+
instance._to_archive(@project, "test-package", "kit", @project.packages_dir)
|
30
30
|
|
31
31
|
@project.from_directory do
|
32
32
|
expect(`tar -Jtf packages/test-package/test-package.tar.xz`.split).to include("kit_test")
|
@@ -50,9 +50,7 @@ describe Tetra::BuiltPackage do
|
|
50
50
|
expect(spec_lines).to include("License: The Apache Software License, Version 2.0\n")
|
51
51
|
expect(spec_lines).to include("Summary: Nailgun is a client, protocol, and server for running Java\n")
|
52
52
|
expect(spec_lines).to include("Url: http://martiansoftware.com/nailgun\n")
|
53
|
-
expect(spec_lines).to include("BuildRequires:
|
54
|
-
da39a3ee5e6b4b0d3255bfef95601890afd80709\n")
|
55
|
-
expect(spec_lines).to include("BuildRequires: tetra-glue == test-project-2\n")
|
53
|
+
expect(spec_lines).to include("BuildRequires: test-project-kit == 2\n")
|
56
54
|
expect(spec_lines).to include("Provides: mvn(com.martiansoftware:nailgun-all) == 0.9.1\n")
|
57
55
|
expect(spec_lines).to include("cp -a out/test3.jar %{buildroot}%{_javadir}/test3.jar\n")
|
58
56
|
end
|
data/spec/lib/kit_spec.rb
CHANGED
@@ -7,61 +7,41 @@ describe Tetra::Kit do
|
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
create_mock_project
|
10
|
-
|
11
|
-
@project.dry_run
|
12
|
-
@project.finish(false)
|
13
|
-
|
14
|
-
@kit = Tetra::Kit.new(@project)
|
15
10
|
end
|
16
11
|
|
17
12
|
after(:each) do
|
18
13
|
delete_mock_project
|
19
14
|
end
|
20
15
|
|
21
|
-
|
22
|
-
|
23
|
-
@project.from_directory(File.join("kit", "m2")) do
|
24
|
-
maven_kit_item_path = File.join(".", "com", "company",
|
25
|
-
"project", "artifact", "1.0")
|
26
|
-
FileUtils.mkdir_p(maven_kit_item_path)
|
16
|
+
let(:instance) { Tetra::Kit.new(@project) }
|
17
|
+
let(:package_name) { instance.name }
|
27
18
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
File.join(maven_kit_item_path, "artifact-1.0.sha1")
|
32
|
-
]
|
19
|
+
describe "#to_spec" do
|
20
|
+
it "generates a specfile" do
|
21
|
+
expect(instance.to_spec).to be_truthy
|
33
22
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
23
|
+
@project.from_directory do
|
24
|
+
spec_lines = File.readlines(File.join("packages", package_name, "#{package_name}.spec"))
|
37
25
|
|
38
|
-
|
39
|
-
expect(
|
26
|
+
expect(spec_lines).to include("Conflicts: otherproviders(tetra-kit)\n")
|
27
|
+
expect(spec_lines).to include("Provides: tetra-kit\n")
|
40
28
|
end
|
41
29
|
end
|
42
30
|
end
|
43
31
|
|
44
|
-
describe "#
|
45
|
-
it "
|
46
|
-
@project.from_directory(File.join("kit", "
|
47
|
-
FileUtils.touch("
|
32
|
+
describe "#to_archive" do
|
33
|
+
it "generates an archive" do
|
34
|
+
@project.from_directory(File.join("kit", "m2")) do
|
35
|
+
FileUtils.touch("kit.content")
|
48
36
|
end
|
49
37
|
|
50
|
-
|
51
|
-
expect(
|
52
|
-
end
|
53
|
-
end
|
38
|
+
expected_filename = File::SEPARATOR + "#{package_name}.tar.xz"
|
39
|
+
expect(instance.to_archive).to end_with(expected_filename)
|
54
40
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
FileUtils.touch(File.join("jars", "test1.jar"))
|
59
|
-
FileUtils.touch("test2.jar")
|
41
|
+
@project.from_directory do
|
42
|
+
contents = `tar --list -f packages/#{package_name}/#{package_name}.tar.xz`.split
|
43
|
+
expect(contents).to include("m2/kit.content")
|
60
44
|
end
|
61
|
-
|
62
|
-
actual_glue_kit_items = @kit.glue_kit_items(@kit.jar_kit_items).first
|
63
|
-
expect(actual_glue_kit_items.source_paths).not_to include(Pathname.new("test1.jar"))
|
64
|
-
expect(actual_glue_kit_items.source_paths).to include(Pathname.new("test2.jar"))
|
65
45
|
end
|
66
46
|
end
|
67
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tetra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.46.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -163,13 +163,12 @@ files:
|
|
163
163
|
- integration-tests/build-obs.sh
|
164
164
|
- integration-tests/commons-collections-3.2.1-src.zip
|
165
165
|
- lib/template/gitignore
|
166
|
+
- lib/template/kit.spec
|
166
167
|
- lib/template/kit/CONTENTS
|
167
168
|
- lib/template/kit/jars/CONTENTS
|
168
169
|
- lib/template/kit/m2/settings.xml
|
169
|
-
- lib/template/kit_item.spec
|
170
170
|
- lib/template/package.spec
|
171
171
|
- lib/template/packages/CONTENTS
|
172
|
-
- lib/template/packages/kit/CONTENTS
|
173
172
|
- lib/template/src/CONTENTS
|
174
173
|
- lib/tetra.rb
|
175
174
|
- lib/tetra/ant_runner.rb
|
@@ -198,10 +197,7 @@ files:
|
|
198
197
|
- lib/tetra/maven_website.rb
|
199
198
|
- lib/tetra/packages/archivable.rb
|
200
199
|
- lib/tetra/packages/built_package.rb
|
201
|
-
- lib/tetra/packages/glue_kit_item.rb
|
202
|
-
- lib/tetra/packages/jar_kit_item.rb
|
203
200
|
- lib/tetra/packages/kit.rb
|
204
|
-
- lib/tetra/packages/maven_kit_item.rb
|
205
201
|
- lib/tetra/packages/scriptable.rb
|
206
202
|
- lib/tetra/packages/speccable.rb
|
207
203
|
- lib/tetra/pom.rb
|
@@ -230,10 +226,8 @@ files:
|
|
230
226
|
- spec/lib/archivable_spec.rb
|
231
227
|
- spec/lib/built_package_spec.rb
|
232
228
|
- spec/lib/git_spec.rb
|
233
|
-
- spec/lib/glue_kit_item_spec.rb
|
234
229
|
- spec/lib/kit_checker_spec.rb
|
235
230
|
- spec/lib/kit_spec.rb
|
236
|
-
- spec/lib/maven_kit_item_spec.rb
|
237
231
|
- spec/lib/maven_runner_spec.rb
|
238
232
|
- spec/lib/maven_website_spec.rb
|
239
233
|
- spec/lib/pom_getter_spec.rb
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Tetra
|
4
|
-
# represents a prebuilt package dependency from a jar file
|
5
|
-
# in a kit
|
6
|
-
class GlueKitItem
|
7
|
-
include Archivable
|
8
|
-
include Speccable
|
9
|
-
|
10
|
-
attr_reader :project
|
11
|
-
attr_reader :package_name
|
12
|
-
attr_reader :conflicts
|
13
|
-
attr_reader :source_dir
|
14
|
-
attr_reader :source_paths
|
15
|
-
attr_reader :provides_symbol
|
16
|
-
attr_reader :provides_version
|
17
|
-
attr_reader :install_dir
|
18
|
-
|
19
|
-
def initialize(project, source_paths)
|
20
|
-
@project = project
|
21
|
-
@package_name = "kit-item-glue-#{project.name}"
|
22
|
-
@conflicts = true
|
23
|
-
@source_dir = "kit"
|
24
|
-
@source_paths = source_paths
|
25
|
-
|
26
|
-
@provides_symbol = "tetra-glue"
|
27
|
-
@provides_version = "#{project.name}-#{project.version}"
|
28
|
-
@install_dir = ""
|
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
|
40
|
-
end
|
41
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Tetra
|
4
|
-
# represents a prebuilt package dependency from a jar file
|
5
|
-
# in a kit
|
6
|
-
class JarKitItem
|
7
|
-
include Archivable
|
8
|
-
include Speccable
|
9
|
-
|
10
|
-
attr_reader :project
|
11
|
-
attr_reader :package_name
|
12
|
-
attr_reader :conflicts
|
13
|
-
attr_reader :source_dir
|
14
|
-
attr_reader :source_paths
|
15
|
-
attr_reader :provides_symbol
|
16
|
-
attr_reader :provides_version
|
17
|
-
attr_reader :install_dir
|
18
|
-
|
19
|
-
def initialize(project, path)
|
20
|
-
_, name = Pathname.new(path).split
|
21
|
-
hash = Digest::SHA1.file(path).hexdigest
|
22
|
-
short_hash = hash.slice(0, 5)
|
23
|
-
|
24
|
-
@project = project
|
25
|
-
@package_name = "kit-item-#{name.to_s.gsub(".", "-")}-#{short_hash}"
|
26
|
-
@conflicts = false
|
27
|
-
@source_dir = File.join("kit", "jars")
|
28
|
-
@source_paths = [path]
|
29
|
-
@provides_symbol = "tetra-jar(#{name})"
|
30
|
-
@provides_version = hash
|
31
|
-
@install_dir = "jars"
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_archive
|
35
|
-
_to_archive(@project, @package_name, @source_dir,
|
36
|
-
@source_paths, @project.kit_packages_dir)
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_spec
|
40
|
-
_to_spec(@project, @package_name, "kit_item.spec",
|
41
|
-
@project.kit_packages_dir)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Tetra
|
4
|
-
# represents a prebuilt package dependency from a Maven local repo
|
5
|
-
# in a kit
|
6
|
-
class MavenKitItem
|
7
|
-
include Archivable
|
8
|
-
include Speccable
|
9
|
-
|
10
|
-
attr_reader :project
|
11
|
-
attr_reader :package_name
|
12
|
-
attr_reader :conflicts
|
13
|
-
attr_reader :source_dir
|
14
|
-
attr_reader :source_paths
|
15
|
-
attr_reader :provides_symbol
|
16
|
-
attr_reader :provides_version
|
17
|
-
attr_reader :install_dir
|
18
|
-
|
19
|
-
def initialize(project, pom, source_paths)
|
20
|
-
path, _ = path_split(pom)
|
21
|
-
rest, version = path_split(path)
|
22
|
-
group_directory, artifact_id = path_split(rest)
|
23
|
-
group_id = path_to_group(group_directory)
|
24
|
-
hash = Digest::SHA1.hexdigest(source_paths.to_s)
|
25
|
-
short_hash = hash.slice(0, 5)
|
26
|
-
|
27
|
-
@project = project
|
28
|
-
@package_name = "kit-item-#{artifact_id}-#{short_hash}"
|
29
|
-
@conflicts = false
|
30
|
-
|
31
|
-
@provides_symbol = "tetra-mvn(#{group_id}:#{artifact_id}:#{version})"
|
32
|
-
@provides_version = hash
|
33
|
-
@install_dir = "m2"
|
34
|
-
|
35
|
-
@source_dir = File.join("kit", "m2")
|
36
|
-
@source_paths = source_paths
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_archive
|
40
|
-
_to_archive(@project, @package_name, @source_dir,
|
41
|
-
@source_paths, @project.kit_packages_dir)
|
42
|
-
end
|
43
|
-
|
44
|
-
def to_spec
|
45
|
-
_to_spec(@project, @package_name, "kit_item.spec",
|
46
|
-
@project.kit_packages_dir)
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
# splits a path string into a [head, tail] string couple
|
52
|
-
def path_split(path)
|
53
|
-
Pathname.new(path).split.map { |e| e.to_s }
|
54
|
-
end
|
55
|
-
|
56
|
-
# transforms a path into a Maven group
|
57
|
-
def path_to_group(path)
|
58
|
-
splits = path_split(path)
|
59
|
-
if splits[0] == "."
|
60
|
-
return splits[1]
|
61
|
-
else
|
62
|
-
return "#{path_to_group(splits[0])}.#{splits[1]}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe Tetra::GlueKitItem do
|
6
|
-
include Tetra::Mockers
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
create_mock_project
|
10
|
-
end
|
11
|
-
|
12
|
-
after(:each) do
|
13
|
-
delete_mock_project
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:instance) { Tetra::GlueKitItem.new(@project, []) }
|
17
|
-
|
18
|
-
describe "#to_spec" do
|
19
|
-
it "generates a specfile" do
|
20
|
-
expect(instance.to_spec).to be_truthy
|
21
|
-
|
22
|
-
@project.from_directory do
|
23
|
-
package_name = instance.package_name
|
24
|
-
spec_lines = File.readlines(File.join("packages", "kit", package_name, "#{package_name}.spec"))
|
25
|
-
|
26
|
-
expect(spec_lines).to include("Conflicts: otherproviders(tetra-glue)\n")
|
27
|
-
expect(spec_lines).to include("Provides: tetra-glue == test-project-0\n")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe Tetra::MavenKitItem do
|
6
|
-
include Tetra::Mockers
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
create_mock_project
|
10
|
-
end
|
11
|
-
|
12
|
-
after(:each) do
|
13
|
-
delete_mock_project
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:group_id) { "com.company.project" }
|
17
|
-
let(:artifact_id) { "artifact" }
|
18
|
-
let(:version) { "1.0" }
|
19
|
-
let(:dir) { File.join(group_id.gsub(".", File::SEPARATOR), artifact_id, version) }
|
20
|
-
let(:pom) { File.join(dir, "#{artifact_id}-#{version}.pom") }
|
21
|
-
let(:jar) { File.join(dir, "#{artifact_id}.jar") }
|
22
|
-
let(:hash) { Digest::SHA1.hexdigest([pom, jar].to_s) }
|
23
|
-
let(:short_hash) { hash.slice(0, 5) }
|
24
|
-
let(:package_name) { "kit-item-#{artifact_id}-#{short_hash}" }
|
25
|
-
let(:maven_kit_item) { Tetra::MavenKitItem.new(@project, pom, [pom, jar]) }
|
26
|
-
|
27
|
-
describe "#provides_symbol" do
|
28
|
-
it "returns the sepec Provides: symbol" do
|
29
|
-
expect(maven_kit_item.provides_symbol).to eq("tetra-mvn(com.company.project:artifact:1.0)")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#provides_version" do
|
34
|
-
it "returns the spec Provides: version" do
|
35
|
-
expect(maven_kit_item.provides_version).to eq(hash)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#to_spec" do
|
40
|
-
it "generates a specfile" do
|
41
|
-
expect(maven_kit_item.to_spec).to be_truthy
|
42
|
-
|
43
|
-
@project.from_directory do
|
44
|
-
spec_lines = File.readlines(File.join("packages", "kit", package_name, "#{package_name}.spec"))
|
45
|
-
|
46
|
-
expect(spec_lines).to include("# spec file for a build-time dependency of project \"test-project\"\n")
|
47
|
-
expect(spec_lines).to include("Name: #{package_name}\n")
|
48
|
-
expect(spec_lines).to include("Summary: Build-time dependency of project \"test-project\"\n")
|
49
|
-
expect(spec_lines).to include("Provides: tetra-mvn(#{group_id}:#{artifact_id}:#{version}) == #{hash}\n")
|
50
|
-
|
51
|
-
expect(spec_lines).to include("install -d -m 0755 %{buildroot}%{_datadir}/tetra/m2\n")
|
52
|
-
expect(spec_lines).to include("cp -a * %{buildroot}%{_datadir}/tetra/m2\n")
|
53
|
-
expect(spec_lines).to include("%{_datadir}/tetra/m2\n")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "#to_archive" do
|
59
|
-
it "generates an archive" do
|
60
|
-
@project.from_directory(File.join("kit", "m2")) do
|
61
|
-
FileUtils.mkdir_p(dir)
|
62
|
-
FileUtils.touch(pom)
|
63
|
-
FileUtils.touch(jar)
|
64
|
-
end
|
65
|
-
|
66
|
-
expected_filename = File::SEPARATOR + "#{package_name}.tar.xz"
|
67
|
-
expect(maven_kit_item.to_archive).to end_with(expected_filename)
|
68
|
-
|
69
|
-
@project.from_directory do
|
70
|
-
contents = `tar -Jtf packages/kit/#{package_name}/#{package_name}.tar.xz`.split
|
71
|
-
expect(contents).to include("com/company/project/artifact/1.0/artifact-1.0.pom")
|
72
|
-
expect(contents).to include("com/company/project/artifact/1.0/artifact.jar")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|