tetra 1.2.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +11 -0
- data/Gemfile.lock +24 -2
- data/README.md +11 -16
- data/SPECIAL_CASES.md +15 -2
- data/lib/template/kit.spec +2 -0
- data/lib/template/package.spec +2 -2
- data/lib/tetra.rb +4 -1
- data/lib/tetra/facades/bash.rb +6 -2
- data/lib/tetra/facades/git.rb +35 -20
- data/lib/tetra/facades/process_runner.rb +2 -0
- data/lib/tetra/facades/tar.rb +14 -0
- data/lib/tetra/facades/unzip.rb +14 -0
- data/lib/tetra/packages/package.rb +2 -1
- data/lib/tetra/project.rb +25 -88
- data/lib/tetra/project_initer.rb +90 -0
- data/lib/tetra/ui/change_sources_subcommand.rb +32 -0
- data/lib/tetra/ui/dry_run_subcommand.rb +5 -4
- data/lib/tetra/ui/generate_all_subcommand.rb +0 -2
- data/lib/tetra/ui/generate_spec_subcommand.rb +1 -0
- data/lib/tetra/ui/init_subcommand.rb +25 -4
- data/lib/tetra/ui/main.rb +6 -6
- data/lib/tetra/ui/patch_subcommand.rb +2 -2
- data/lib/tetra/ui/subcommand.rb +1 -1
- data/lib/tetra/version.rb +1 -1
- data/spec/data/commons-collections-3.2.1-src.tar.gz +0 -0
- data/{integration-tests → spec/data}/commons-collections-3.2.1-src.zip +0 -0
- data/spec/lib/coarse/dry_run_subcommand_spec.rb +31 -0
- data/spec/lib/coarse/generate_all_subcommand_spec.rb +128 -0
- data/spec/lib/coarse/generate_spec_subcommand_spec.rb +29 -0
- data/spec/lib/coarse/init_subcommand_spec.rb +85 -0
- data/spec/lib/coarse/main_spec.rb +19 -0
- data/spec/lib/{ant_spec.rb → fine/ant_spec.rb} +0 -0
- data/spec/lib/{git_spec.rb → fine/git_spec.rb} +54 -6
- data/spec/lib/{kit_package_spec.rb → fine/kit_package_spec.rb} +0 -0
- data/spec/lib/{kit_spec.rb → fine/kit_spec.rb} +0 -0
- data/spec/lib/{maven_website_spec.rb → fine/maven_website_spec.rb} +0 -0
- data/spec/lib/{mvn_spec.rb → fine/mvn_spec.rb} +0 -0
- data/spec/lib/{package_spec.rb → fine/package_spec.rb} +7 -0
- data/spec/lib/{pom_getter_spec.rb → fine/pom_getter_spec.rb} +0 -0
- data/spec/lib/{pom_spec.rb → fine/pom_spec.rb} +0 -0
- data/spec/lib/{project_spec.rb → fine/project_spec.rb} +1 -39
- data/spec/lib/{scriptable_spec.rb → fine/scriptable_spec.rb} +0 -0
- data/spec/lib/{speccable_spec.rb → fine/speccable_spec.rb} +0 -0
- data/spec/lib/fine/tar_spec.rb +22 -0
- data/spec/lib/fine/unzip_spec.rb +22 -0
- data/spec/lib/{version_matcher_spec.rb → fine/version_matcher_spec.rb} +0 -0
- data/spec/spec_helper.rb +19 -2
- data/tetra.gemspec +1 -0
- metadata +45 -19
- data/integration-tests/build-commons.sh +0 -30
- data/lib/template/gitignore +0 -2
- data/lib/tetra/ui/generate_archive_subcommand.rb +0 -16
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Development environment
|
2
|
+
|
3
|
+
To develop tetra, you will need:
|
4
|
+
* to install Bundler. On SUSE distros, use `sudo zypper in rubygem-bundler`;
|
5
|
+
* to get development dependencies: `bundle install`;
|
6
|
+
|
7
|
+
To install a development version of tetra use:
|
8
|
+
|
9
|
+
```
|
10
|
+
sudo rake install
|
11
|
+
```
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tetra (1.
|
4
|
+
tetra (1.2.2)
|
5
5
|
clamp
|
6
6
|
json_pure
|
7
7
|
open4
|
@@ -11,9 +11,30 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: http://rubygems.org/
|
13
13
|
specs:
|
14
|
-
|
14
|
+
aruba (0.6.2)
|
15
|
+
childprocess (>= 0.3.6)
|
16
|
+
cucumber (>= 1.1.1)
|
17
|
+
rspec-expectations (>= 2.7.0)
|
18
|
+
builder (3.2.2)
|
19
|
+
childprocess (0.5.6)
|
20
|
+
ffi (~> 1.0, >= 1.0.11)
|
21
|
+
clamp (1.0.0)
|
22
|
+
cucumber (2.0.0)
|
23
|
+
builder (>= 2.1.2)
|
24
|
+
cucumber-core (~> 1.1.3)
|
25
|
+
diff-lcs (>= 1.1.3)
|
26
|
+
gherkin (~> 2.12)
|
27
|
+
multi_json (>= 1.7.5, < 2.0)
|
28
|
+
multi_test (>= 0.1.2)
|
29
|
+
cucumber-core (1.1.3)
|
30
|
+
gherkin (~> 2.12.0)
|
15
31
|
diff-lcs (1.2.5)
|
32
|
+
ffi (1.9.8)
|
33
|
+
gherkin (2.12.2)
|
34
|
+
multi_json (~> 1.3)
|
16
35
|
json_pure (1.8.2)
|
36
|
+
multi_json (1.11.0)
|
37
|
+
multi_test (0.1.2)
|
17
38
|
open4 (1.3.4)
|
18
39
|
rake (10.4.2)
|
19
40
|
rspec (3.2.0)
|
@@ -36,6 +57,7 @@ PLATFORMS
|
|
36
57
|
ruby
|
37
58
|
|
38
59
|
DEPENDENCIES
|
60
|
+
aruba
|
39
61
|
rake
|
40
62
|
rspec
|
41
63
|
tetra!
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ You need:
|
|
12
12
|
|
13
13
|
* [Ruby 1.9.2](https://www.ruby-lang.org/en/) or later;
|
14
14
|
* [git](http://git-scm.com/);
|
15
|
-
* bash;
|
15
|
+
* some basic Unix commands: bash, unzip, tar;
|
16
16
|
* a JDK that can compile whatever software you need to package;
|
17
17
|
* Fedora only: packages to compile native gems, use `yum install ruby-devel gcc-c++ zlib-devel`;
|
18
18
|
|
@@ -24,9 +24,9 @@ Install `tetra` via RubyGems:
|
|
24
24
|
|
25
25
|
Building a package with `tetra` is quite unusual — this is a deliberate choice, so don't worry. Basic steps are:
|
26
26
|
|
27
|
-
* `tetra init`
|
28
|
-
*
|
29
|
-
* execute `tetra dry-run`, which will open a bash subshell.
|
27
|
+
* `tetra init <package name> package_sources.tar.gz` to initialize the project and unpack original sources;
|
28
|
+
* if anything other than `ant` and `mvn` is needed in order to build the project, add it to the `kit/` directory in binary form;
|
29
|
+
* execute `tetra dry-run`, which will open a bash subshell. Build your project, and when you are done conclude by exiting the subshell with `Ctrl+D`;
|
30
30
|
* execute `tetra generate-all`: tetra will scaffold spec files and tarballs.
|
31
31
|
|
32
32
|
Done!
|
@@ -38,25 +38,20 @@ During the dry-run `tetra`:
|
|
38
38
|
- keeps track of changed files, in particular produced jars, which are included in the spec's `%files` section;
|
39
39
|
- saves files downloaded from the Internet (eg. by Maven) and packs them to later allow networkless builds.
|
40
40
|
|
41
|
-
Note that with `tetra` you are not building all dependencies from source - build dependencies are aggregated in a binary-only "
|
41
|
+
Note that with `tetra` you are not building all dependencies from source - build dependencies are aggregated in a binary-only "kit" package. This is typically sufficient to fulfill open source licenses and to have a repeatable, networkless build.
|
42
42
|
|
43
43
|
## A commons-collections walkthrough
|
44
44
|
|
45
|
-
First,
|
45
|
+
First, grab the sources:
|
46
46
|
|
47
|
-
|
48
|
-
cd commons-collections
|
49
|
-
tetra init
|
47
|
+
wget http://archive.apache.org/dist/commons/collections/source/commons-collections4-4.0-src.tar.gz
|
50
48
|
|
51
|
-
Second,
|
49
|
+
Second, ceate a new `tetra` project named `commons-collections` based on those sources:
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
tar xf commons-collections4-4.0-src.tar.gz
|
56
|
-
rm commons-collections4-4.0-src.tar.gz
|
57
|
-
cd commons-collections4-4.0-src/
|
51
|
+
tetra init commons-collections commons-collections4-4.0-src.tar.gz
|
52
|
+
cd commons-collections/src/commons-collections4-4.0-src
|
58
53
|
|
59
|
-
Third, you need to show `tetra` how to build your package. Run `tetra dry-run` a new subshell will open, in there do anything you would normally do to build the package:
|
54
|
+
Third, you need to show `tetra` how to build your package. Run `tetra dry-run` and a new subshell will open, in there do anything you would normally do to build the package (in this case, run Maven):
|
60
55
|
|
61
56
|
tetra dry-run
|
62
57
|
|
data/SPECIAL_CASES.md
CHANGED
@@ -13,7 +13,6 @@ You can edit any file generated by tetra - regenerating it later will not overwr
|
|
13
13
|
You can generate single files with the following commands:
|
14
14
|
|
15
15
|
* `tetra generate-script`: (re)generates the `build.sh` file from commands used in the latest successful dry-run;
|
16
|
-
* `tetra generate-archive`: (re)generates the package tarball;
|
17
16
|
* `tetra generate-spec`: (re)generates the package spec;
|
18
17
|
* `tetra generate-kit`: (re)generates the kit tarball and spec;
|
19
18
|
|
@@ -23,7 +22,7 @@ If you need to modify your project's sources for whatever reason, feel free to d
|
|
23
22
|
|
24
23
|
After that you can retry the dry-run and spec generation: tetra will take care of creating patch files and adding `%patch` instructions for you.
|
25
24
|
|
26
|
-
In case you want to swap sources completely
|
25
|
+
In case you want to swap sources with a completely new archive, discarding all previous patches use `tetra change-sources <archive> "my message"`.
|
27
26
|
|
28
27
|
## Ant builds
|
29
28
|
|
@@ -92,9 +91,23 @@ Packages will rebuild cleanly in OBS because no Internet access is needed - all
|
|
92
91
|
|
93
92
|
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.
|
94
93
|
|
94
|
+
## Packaging software without a source archive
|
95
|
+
|
96
|
+
If your package sources do not ship in a source archive you can use `tetra init --no-sources <package_name>` to start a tetra project without sources. This is in general not recommended but it might be needed if your package sources are shipped in a format other than tar or zip, or it is distributed in multiple files, etc. Note that most version control systems allow you to export a checkout of a certain version in tarball form - this is recommended in tetra (and RPM in general) over using raw source files.
|
97
|
+
|
98
|
+
Then you can add sources manually by:
|
99
|
+
* placing the archives in `packages/<project name>`
|
100
|
+
* unpacking them in `src`
|
101
|
+
* running `tetra change-sources --no-archive`.
|
102
|
+
|
103
|
+
`tetra` assumes that sources in `packages/<project name>` and `src` match, except for patches as described above - it is your responsibility to keep them in sync.
|
104
|
+
|
105
|
+
Note that most version control systems are able to produce an archive from a specific revision, using that is recommended over checking out raw files for `tetra` use.
|
106
|
+
|
95
107
|
## Gotchas
|
96
108
|
|
97
109
|
* `tetra` internally uses `git` to keep track of files, any tetra project is actually also a `git` repo. Feel free to use it as any ordinary git repo, including pushing to a remote repo, rebasing, merging or using GitHub's pull requests. Just make sure any `tetra: ` comments are preserved;
|
110
|
+
* `tetra` will commit in its `git` repo the `src` and `kit` directories during dry-run and any generated `spec` file. You are free to commit other files but it's not strictly necessary (eg. generated tarballs);
|
98
111
|
* 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 `mvn` during your build:
|
99
112
|
|
100
113
|
-Djava.io.tmpdir=<full path to project>/kit/tmp
|
data/lib/template/kit.spec
CHANGED
@@ -23,6 +23,7 @@ Source0: %{name}.tar.xz
|
|
23
23
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
24
24
|
BuildArch: noarch
|
25
25
|
BuildRequires: xz
|
26
|
+
BuildRequires: fdupes
|
26
27
|
Provides: tetra-kit
|
27
28
|
Conflicts: otherproviders(tetra-kit)
|
28
29
|
|
@@ -42,6 +43,7 @@ thus it should never be installed on end users' systems.
|
|
42
43
|
export NO_BRP_CHECK_BYTECODE_VERSION=true
|
43
44
|
install -d -m 0755 %{buildroot}%{_datadir}/tetra/
|
44
45
|
cp -a * %{buildroot}%{_datadir}/tetra/
|
46
|
+
%fdupes -s %{buildroot}%{_datadir}/tetra/
|
45
47
|
|
46
48
|
%files
|
47
49
|
%defattr(-,root,root)
|
data/lib/template/package.spec
CHANGED
@@ -22,7 +22,7 @@ License: <%= license %>
|
|
22
22
|
Summary: <%= summary %>
|
23
23
|
Url: <%= url %>
|
24
24
|
Group: Development/Libraries/Java
|
25
|
-
Source0:
|
25
|
+
Source0: <%= src_archive %>
|
26
26
|
Source1: build.sh
|
27
27
|
<% patches.to_enum.with_index.each do |patch, i| %>
|
28
28
|
Patch<%= i %>: <%= patch %>
|
@@ -46,7 +46,7 @@ Requires: mvn(<%= dependency_id[0] %>:<%= dependency_id[1] %>) <% if depen
|
|
46
46
|
%>
|
47
47
|
|
48
48
|
%prep
|
49
|
-
%setup -q -n src
|
49
|
+
%setup -q -c -n src
|
50
50
|
<% patches.to_enum.with_index.each do |patch, i| %>
|
51
51
|
%patch<%= i %> -p2
|
52
52
|
<% end %>
|
data/lib/tetra.rb
CHANGED
@@ -30,9 +30,12 @@ require "tetra/facades/git"
|
|
30
30
|
require "tetra/facades/ant"
|
31
31
|
require "tetra/facades/mvn"
|
32
32
|
require "tetra/facades/bash"
|
33
|
+
require "tetra/facades/unzip"
|
34
|
+
require "tetra/facades/tar"
|
33
35
|
|
34
36
|
# main internal classes
|
35
37
|
require "tetra/version"
|
38
|
+
require "tetra/project_initer"
|
36
39
|
require "tetra/project"
|
37
40
|
require "tetra/pom"
|
38
41
|
require "tetra/kit"
|
@@ -51,11 +54,11 @@ require "tetra/ui/subcommand"
|
|
51
54
|
require "tetra/ui/dry_run_subcommand"
|
52
55
|
require "tetra/ui/generate_all_subcommand"
|
53
56
|
require "tetra/ui/generate_kit_subcommand"
|
54
|
-
require "tetra/ui/generate_archive_subcommand"
|
55
57
|
require "tetra/ui/generate_script_subcommand"
|
56
58
|
require "tetra/ui/generate_spec_subcommand"
|
57
59
|
require "tetra/ui/get_pom_subcommand"
|
58
60
|
require "tetra/ui/init_subcommand"
|
59
61
|
require "tetra/ui/move_jars_to_kit_subcommand"
|
60
62
|
require "tetra/ui/patch_subcommand"
|
63
|
+
require "tetra/ui/change_sources_subcommand"
|
61
64
|
require "tetra/ui/main"
|
data/lib/tetra/facades/bash.rb
CHANGED
@@ -29,8 +29,12 @@ module Tetra
|
|
29
29
|
bashrc_file.write(bashrc_content)
|
30
30
|
bashrc_file.flush
|
31
31
|
|
32
|
-
run_interactive("bash --rcfile #{bashrc_file.path}")
|
33
|
-
File.read(history_file)
|
32
|
+
run_interactive("bash --rcfile #{bashrc_file.path} -i")
|
33
|
+
history = File.read(history_file)
|
34
|
+
log.debug "history contents:"
|
35
|
+
log.debug history
|
36
|
+
|
37
|
+
history.split("\n").map(&:strip)
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
data/lib/tetra/facades/git.rb
CHANGED
@@ -43,15 +43,17 @@ module Tetra
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
# adds all files in the
|
47
|
-
# removes all files not in the
|
46
|
+
# adds all files in the specified directories,
|
47
|
+
# removes all files not in the specified directories,
|
48
48
|
# commits with message
|
49
|
-
def
|
50
|
-
|
51
|
-
log.debug "committing with message: #{message}"
|
49
|
+
def commit_directories(directories, message)
|
50
|
+
log.debug "committing with message: #{message}"
|
52
51
|
|
53
|
-
|
54
|
-
|
52
|
+
Dir.chdir(@directory) do
|
53
|
+
directories.each do |directory|
|
54
|
+
run("git rm -r --cached --ignore-unmatch #{directory}")
|
55
|
+
run("git add #{directory}")
|
56
|
+
end
|
55
57
|
run("git commit --allow-empty -F -", false, message)
|
56
58
|
end
|
57
59
|
end
|
@@ -65,20 +67,22 @@ module Tetra
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
# reverts
|
69
|
-
def
|
70
|
+
# reverts multiple directories' contents as per specified id
|
71
|
+
def revert_directories(directories, id)
|
70
72
|
Dir.chdir(@directory) do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
73
|
+
directories.each do |directory|
|
74
|
+
# reverts added and modified files, both in index and working tree
|
75
|
+
run("git checkout -f #{id} -- #{directory}")
|
76
|
+
|
77
|
+
# compute the list of deleted files
|
78
|
+
files_in_commit = run("git ls-tree --name-only -r #{id} -- #{directory}").split("\n")
|
79
|
+
files_in_head = run("git ls-tree --name-only -r HEAD -- #{directory}").split("\n")
|
80
|
+
files_added_after_head = run("git ls-files -o -- #{directory}").split("\n")
|
81
|
+
files_to_delete = files_in_head - files_in_commit + files_added_after_head
|
82
|
+
|
83
|
+
files_to_delete.each do |file|
|
84
|
+
FileUtils.rm_rf(file)
|
85
|
+
end
|
82
86
|
end
|
83
87
|
end
|
84
88
|
end
|
@@ -91,6 +95,17 @@ module Tetra
|
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
98
|
+
# renames git special files to 'disable' them
|
99
|
+
def disable_special_files(path)
|
100
|
+
Dir.chdir(File.join(@directory, path)) do
|
101
|
+
Find.find(".") do |file|
|
102
|
+
next unless file =~ /\.git(ignore)?$/
|
103
|
+
|
104
|
+
FileUtils.mv(file, "#{file}_disabled_by_tetra")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
94
109
|
# 3-way merges the git file at path with the one in new_path
|
95
110
|
# assuming they have a common ancestor at the specified id
|
96
111
|
# returns the conflict count
|
@@ -36,7 +36,9 @@ module Tetra
|
|
36
36
|
|
37
37
|
# runs an interactive executable in a subshell
|
38
38
|
def run_interactive(command)
|
39
|
+
log.debug "running `#{command}`"
|
39
40
|
success = system({}, command)
|
41
|
+
log.debug "`#{command}` exited with success #{success}"
|
40
42
|
fail ExecutionFailed.new(command, $CHILD_STATUS, nil, nil) unless success
|
41
43
|
end
|
42
44
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Tetra
|
4
|
+
# encapsulates unzip
|
5
|
+
class Tar
|
6
|
+
include ProcessRunner
|
7
|
+
|
8
|
+
# decompresses a file in a target directory
|
9
|
+
def decompress(tarfile, directory)
|
10
|
+
result = run("tar xvf #{tarfile} --directory #{directory}")
|
11
|
+
result.strip if result != ""
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Tetra
|
4
|
+
# encapsulates unzip
|
5
|
+
class Unzip
|
6
|
+
include ProcessRunner
|
7
|
+
|
8
|
+
# decompresses a file in a target directory
|
9
|
+
def decompress(zipfile, directory)
|
10
|
+
result = run("unzip #{zipfile} -d #{directory}")
|
11
|
+
result.strip if result != ""
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -9,7 +9,8 @@ module Tetra
|
|
9
9
|
|
10
10
|
attr_reader :patches
|
11
11
|
|
12
|
-
def_delegator :@project, :name
|
12
|
+
def_delegator :@project, :name
|
13
|
+
def_delegator :@project, :src_archive
|
13
14
|
def_delegator :@kit, :name, :kit_name
|
14
15
|
def_delegator :@kit, :version, :kit_version
|
15
16
|
def_delegator :@pom, :license_name, :license
|
data/lib/tetra/project.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
module Tetra
|
4
4
|
# encapsulates a Tetra project directory
|
5
5
|
class Project
|
6
|
+
include ProjectIniter
|
6
7
|
include Logging
|
7
8
|
|
8
9
|
# path of the project template files
|
@@ -39,53 +40,6 @@ module Tetra
|
|
39
40
|
result
|
40
41
|
end
|
41
42
|
|
42
|
-
# returns true if the specified directory is a valid tetra project
|
43
|
-
def self.project?(dir)
|
44
|
-
File.directory?(File.join(dir, "src")) &&
|
45
|
-
File.directory?(File.join(dir, "kit")) &&
|
46
|
-
File.directory?(File.join(dir, ".git"))
|
47
|
-
end
|
48
|
-
|
49
|
-
# inits a new project directory structure
|
50
|
-
def self.init(dir, include_bundled_software = true)
|
51
|
-
Dir.chdir(dir) do
|
52
|
-
Tetra::Git.new(".").init
|
53
|
-
|
54
|
-
FileUtils.mkdir_p("src")
|
55
|
-
FileUtils.mkdir_p("kit")
|
56
|
-
|
57
|
-
# populate the project with templates and commit it
|
58
|
-
project = Project.new(".")
|
59
|
-
|
60
|
-
project.template_files(include_bundled_software).each do |source, destination|
|
61
|
-
FileUtils.cp_r(File.join(TEMPLATE_PATH, source), destination)
|
62
|
-
end
|
63
|
-
|
64
|
-
project.commit_whole_directory(".", "Template files added")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# returns a hash that maps filenames that should be copied from TEMPLATE_PATH
|
69
|
-
# to the value directory
|
70
|
-
def template_files(include_bundled_software)
|
71
|
-
result = {
|
72
|
-
"kit" => ".",
|
73
|
-
"packages" => ".",
|
74
|
-
"src" => ".",
|
75
|
-
"gitignore" => ".gitignore"
|
76
|
-
}
|
77
|
-
|
78
|
-
if include_bundled_software
|
79
|
-
Dir.chdir(TEMPLATE_PATH) do
|
80
|
-
Dir.glob(File.join("bundled", "*")).each do |file|
|
81
|
-
result[file] = "kit"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
result
|
87
|
-
end
|
88
|
-
|
89
43
|
# checks whether there were edits to src/
|
90
44
|
# since last mark
|
91
45
|
def src_patched?
|
@@ -100,7 +54,7 @@ module Tetra
|
|
100
54
|
def dry_run
|
101
55
|
current_directory = Pathname.new(Dir.pwd).relative_path_from(Pathname.new(@full_path))
|
102
56
|
|
103
|
-
|
57
|
+
@git.commit_directories(%w(src kit), "Dry-run started\n\ntetra: dry-run-started: #{current_directory}")
|
104
58
|
end
|
105
59
|
|
106
60
|
# returns true iff we are currently dry-running
|
@@ -119,52 +73,33 @@ module Tetra
|
|
119
73
|
changed_files = @git.changed_files("src", start_id)
|
120
74
|
|
121
75
|
# revert to pre-dry-run status
|
122
|
-
@git.
|
76
|
+
@git.revert_directories(["src"], start_id)
|
123
77
|
|
124
78
|
# prepare commit comments
|
125
79
|
comments = ["Dry run finished\n", "tetra: dry-run-finished"]
|
126
80
|
comments += changed_files.map { |f| "tetra: file-changed: #{f}" }
|
127
81
|
comments += build_script_lines.map { |l| "tetra: build-script-line: #{l}" }
|
128
82
|
|
129
|
-
# if this is the first dry-run, mark sources as tarball
|
130
|
-
comments << "tetra: sources-tarball" if first_dry_run
|
131
|
-
|
132
83
|
# commit end of dry run
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
# returns true if this is the first dry-run
|
137
|
-
def first_dry_run
|
138
|
-
@git.latest_id("tetra: dry-run-finished").nil?
|
84
|
+
@git.commit_directories(["kit"], comments.join("\n"))
|
139
85
|
end
|
140
86
|
|
141
87
|
# ends a dry-run assuming the build went wrong
|
142
|
-
# reverts
|
88
|
+
# reverts src/ and kit/ directories
|
143
89
|
def abort
|
144
|
-
@git.
|
90
|
+
@git.revert_directories(%w(src kit), @git.latest_id("tetra: dry-run-started"))
|
145
91
|
@git.undo_last_commit
|
146
92
|
end
|
147
93
|
|
148
|
-
# commits all files in the directory
|
149
|
-
def commit_whole_directory(directory, *comments)
|
150
|
-
# rename all .gitignore files that might have slipped in
|
151
|
-
from_directory("src") do
|
152
|
-
Find.find(".") do |file|
|
153
|
-
next unless file =~ /\.gitignore$/
|
154
|
-
|
155
|
-
FileUtils.mv(file, "#{file}_disabled_by_tetra")
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
@git.commit_whole_directory(directory, comments.join("\n"))
|
160
|
-
end
|
161
|
-
|
162
94
|
# commits files in the src/ dir as a patch or tarball update
|
163
|
-
def commit_sources(message, new_tarball
|
95
|
+
def commit_sources(message, new_tarball)
|
164
96
|
from_directory do
|
165
|
-
comments =
|
166
|
-
|
167
|
-
|
97
|
+
comments = "#{message}\n"
|
98
|
+
if new_tarball
|
99
|
+
comments << "\ntetra: sources-tarball"
|
100
|
+
@git.disable_special_files("src")
|
101
|
+
end
|
102
|
+
@git.commit_directories(["src"], comments)
|
168
103
|
end
|
169
104
|
end
|
170
105
|
|
@@ -237,16 +172,6 @@ module Tetra
|
|
237
172
|
.sort
|
238
173
|
end
|
239
174
|
|
240
|
-
# archives a tarball of src/ in packages/
|
241
|
-
# the latest commit marked as tarball is taken as the version
|
242
|
-
def archive_sources
|
243
|
-
from_directory do
|
244
|
-
id = @git.latest_id("tetra: sources-tarball")
|
245
|
-
destination_path = File.join(full_path, packages_dir, name, "#{name}.tar.xz")
|
246
|
-
@git.archive("src", id, destination_path)
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
175
|
# archives a tarball of kit/ in packages/
|
251
176
|
# the latest commit marked as dry-run-finished is taken as the version
|
252
177
|
def archive_kit
|
@@ -257,6 +182,18 @@ module Tetra
|
|
257
182
|
end
|
258
183
|
end
|
259
184
|
|
185
|
+
# returns the name of the source archive file, if any
|
186
|
+
def src_archive
|
187
|
+
from_directory do
|
188
|
+
Find.find(File.join("packages", name)) do |file|
|
189
|
+
if File.file?(file) && file.match(/\.(spec)|(sh)|(patch)$/).nil?
|
190
|
+
return File.basename(file)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
nil
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
260
197
|
# generates patches of src/ in packages/
|
261
198
|
# the latest commit marked as tarball is taken as the base version,
|
262
199
|
# other commits are assumed to be patches on top
|