kameleon-builder 2.10.13 → 2.11.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.
- checksums.yaml +4 -4
- data/CHANGES +13 -0
- data/README.rst +20 -5
- data/RELEASING.md +41 -24
- data/completion/kameleon.bash +0 -2
- data/kameleon-builder.gemspec +1 -1
- data/lib/kameleon/cli.rb +2 -2
- data/lib/kameleon/recipe.rb +18 -13
- data/lib/kameleon/ui.rb +1 -1
- data/lib/kameleon/utils.rb +7 -2
- data/lib/kameleon/version.rb +1 -1
- metadata +11 -13
- data/.bumpversion.cfg +0 -16
- data/scripts/bumpversion.py +0 -184
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a474581cf9237053d9e97441871d3cfec86a5670aec656c05dfd93d699b6098
|
4
|
+
data.tar.gz: 4636916224c68d8637a71dd427975698669d11f7ca6ec9511ece3931853d33a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27159883626026bdb00254119ea6428eba91c1cf0bc0dd30dbb3af3ded154aee855ef4d4b780a901f84e7c2563874446f0a2ca4951d5b12eedb416c5085cac67
|
7
|
+
data.tar.gz: ab15e8247297ece98afa80cfe50ba9b8d53da227ca120a8613e729fbc03749b1e22a5a095d10b130023eb837fb582741e4a6f7c04f3d7cc0406e833ce1ad0a43
|
data/CHANGES
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
Kameleon CHANGELOG
|
2
2
|
==================
|
3
3
|
|
4
|
+
Version 2.10.14 → 2.11.0
|
5
|
+
------------------------
|
6
|
+
|
7
|
+
Released on May 4th 2025
|
8
|
+
|
9
|
+
- Enable command aliases in the definition of checkpoint actions.
|
10
|
+
- Enable command aliases with no args.
|
11
|
+
- Fix dependencies to progressbar and ruby-graphviz (the "ruby-" prefix matters!).
|
12
|
+
- Fix terminal width issue with latest Thor.
|
13
|
+
- Fix graphviz and progress bar dependencies.
|
14
|
+
- Rework README.rst and the documentation front page.
|
15
|
+
- Some other minor changes.
|
16
|
+
|
4
17
|
Version 2.10.13
|
5
18
|
---------------
|
6
19
|
|
data/README.rst
CHANGED
@@ -1,11 +1,26 @@
|
|
1
1
|
Kameleon appliance builder
|
2
2
|
==========================
|
3
3
|
|
4
|
-
Kameleon is a simple but powerful tool to generate customized
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
Kameleon is a simple but powerful tool to generate customized operating system
|
5
|
+
images, based on traceable recipes.
|
6
|
+
|
7
|
+
Thanks to Kameleon, one can write recipes that describe how to create, step by
|
8
|
+
step, customized operating systems in any desired target format, and then cook
|
9
|
+
them (build them), just like GNU make cooks sources using a Makefile to build
|
10
|
+
binary programs.
|
11
|
+
|
12
|
+
For instance, Kameleon can create custom operating system images for QEMU/KVM,
|
13
|
+
VirtualBox, docker, LXC or bootable ISO. It can support creating such images
|
14
|
+
for any machine architecture (x86, ARM64, PPC64, ... ).
|
15
|
+
|
16
|
+
In fact, since the Kameleon engine by itself is very generic by design, a lot
|
17
|
+
more can be done, because most of the specialization happens in the recipes,
|
18
|
+
written in Kameleon's powerful recipe language (YAML based DSL).
|
19
|
+
|
20
|
+
Kameleon was initially developed to improve reproducibility in computer science
|
21
|
+
and engineering, providing a tool that achieves complete *reconstructability*
|
22
|
+
of system images with cache, checkpointing and interactive breakpoint
|
23
|
+
mechanisms.
|
9
24
|
|
10
25
|
* Latest documentation: http://kameleon.imag.fr/getting_started.html
|
11
26
|
* Source code and issue tracker: https://github.com/oar-team/kameleon
|
data/RELEASING.md
CHANGED
@@ -11,21 +11,23 @@ Assuming work is done in the devel branch.
|
|
11
11
|
For stable releases:
|
12
12
|
--------------------
|
13
13
|
|
14
|
-
##
|
14
|
+
## Switch and update the master branch
|
15
15
|
```
|
16
|
-
git
|
17
|
-
git
|
16
|
+
git switch master
|
17
|
+
git pull -r
|
18
18
|
```
|
19
|
+
Do whatever changes needed in the code (possibly merging a branch or a pull request).
|
20
|
+
Commit.
|
19
21
|
|
20
|
-
##
|
21
|
-
|
22
|
-
|
22
|
+
## Update changelog
|
23
|
+
Edit the `CHANGES` file.
|
24
|
+
Commit.
|
23
25
|
|
24
26
|
## Bump version
|
25
|
-
|
27
|
+
Edit the `lib/kameleon/version.rb` file and bump the version.
|
28
|
+
Commit:
|
26
29
|
```
|
27
|
-
|
28
|
-
git push
|
30
|
+
git commit -m "v2.10.16 → v.2.10.17" lib/kameleon/version.rb
|
29
31
|
```
|
30
32
|
|
31
33
|
## Build gem
|
@@ -33,9 +35,28 @@ git push
|
|
33
35
|
gem build kameleon-builder.gemspec
|
34
36
|
```
|
35
37
|
|
38
|
+
## Test
|
39
|
+
Manually install:
|
40
|
+
```
|
41
|
+
gem install --user ./kameleon-builder-2.10.17.gem
|
42
|
+
```
|
43
|
+
Test, test, test.
|
44
|
+
|
45
|
+
## Tag
|
46
|
+
If everything is ok, tag:
|
47
|
+
```
|
48
|
+
git tag -s 'v2.10.17' -m 'v2.10.17'
|
49
|
+
```
|
50
|
+
|
51
|
+
## Push git push
|
52
|
+
```
|
53
|
+
git push
|
54
|
+
```
|
55
|
+
|
56
|
+
|
36
57
|
## Push to Ruby gem repository
|
37
58
|
```
|
38
|
-
|
59
|
+
gem push kameleon-builder-2.10.17.gem
|
39
60
|
```
|
40
61
|
|
41
62
|
Note: You need a rubygem account and the owner has to give you permissions so that you can push.
|
@@ -43,27 +64,23 @@ To do so, create an account on https://rubygems.org/ and ask an owner to do
|
|
43
64
|
the following command::
|
44
65
|
|
45
66
|
```
|
46
|
-
|
67
|
+
gem owner kameleon-builder -a your@email.com
|
47
68
|
```
|
48
69
|
|
49
70
|
That's all :)
|
50
71
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
## Move to the devel branch and rebase on master
|
72
|
+
## In case a release is buggy
|
73
|
+
Yank it to remove it from the rubygems index.
|
55
74
|
```
|
56
|
-
|
57
|
-
git rebase master
|
75
|
+
gem yank kameleon-builder -v 2.10.16
|
58
76
|
```
|
59
77
|
|
60
|
-
|
61
|
-
|
78
|
+
For developments:
|
79
|
+
-----------------
|
80
|
+
|
81
|
+
Changes can be tested by locally installing the gem after building it:
|
62
82
|
```
|
63
|
-
|
83
|
+
gem build kameleon-builder.gemspec && gem install --user ./kameleon-builder-2.10.17.gem
|
64
84
|
```
|
65
85
|
|
66
|
-
|
67
|
-
And same as above to build "devel" gem and use them locally, or push them if really wanted.
|
68
|
-
|
69
|
-
Up to the time to build a new stable version.
|
86
|
+
Using git branches, github pull requests, aso, is of course good.
|
data/completion/kameleon.bash
CHANGED
data/kameleon-builder.gemspec
CHANGED
@@ -30,9 +30,9 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.require_paths = ['lib']
|
31
31
|
|
32
32
|
s.add_dependency 'childprocess', '~> 4.0'
|
33
|
+
s.add_dependency 'progressbar', '~> 1.10'
|
33
34
|
s.add_dependency 'psych', '~> 5.0'
|
34
35
|
s.add_dependency 'ruby-graphviz', '~> 1.2'
|
35
|
-
s.add_dependency 'ruby-progressbar', '~> 1.10'
|
36
36
|
s.add_dependency 'table_print', '~> 1.5'
|
37
37
|
s.add_dependency 'thor', '~> 1.0'
|
38
38
|
|
data/lib/kameleon/cli.rb
CHANGED
@@ -2,7 +2,7 @@ require 'kameleon/engine'
|
|
2
2
|
require 'kameleon/recipe'
|
3
3
|
require 'kameleon/utils'
|
4
4
|
require 'tempfile'
|
5
|
-
require 'graphviz'
|
5
|
+
require 'graphviz' # ruby-graphviz gem (GraphViz class), not the graphviz gem (Graphviz module)
|
6
6
|
|
7
7
|
module Kameleon
|
8
8
|
|
@@ -157,7 +157,7 @@ module Kameleon
|
|
157
157
|
class_option :verbose, :type => :boolean, :default => Kameleon.default_values[:verbose],
|
158
158
|
:desc => "Enable verbose output for kameleon users"
|
159
159
|
class_option :debug, :type => :boolean, :default => Kameleon.default_values[:debug],
|
160
|
-
:desc => "Enable debug output for kameleon
|
160
|
+
:desc => "Enable debug output for kameleon developers"
|
161
161
|
class_option :script, :type => :boolean, :default => Kameleon.default_values[:script],
|
162
162
|
:desc => "Never prompt for user intervention",
|
163
163
|
:aliases => "-s"
|
data/lib/kameleon/recipe.rb
CHANGED
@@ -637,6 +637,9 @@ module Kameleon
|
|
637
637
|
|
638
638
|
def resolve_checkpoint()
|
639
639
|
(@checkpoint.keys - ["path"]).each do |key|
|
640
|
+
@checkpoint[key].map! do |cmd|
|
641
|
+
resolve_alias(cmd)
|
642
|
+
end.flatten!
|
640
643
|
@checkpoint[key].each do |cmd|
|
641
644
|
cmd.string_cmd = Utils.resolve_vars(cmd.string_cmd,
|
642
645
|
@checkpoint["path"],
|
@@ -648,32 +651,34 @@ module Kameleon
|
|
648
651
|
|
649
652
|
def resolve_alias(cmd)
|
650
653
|
name = cmd.key
|
651
|
-
if @aliases.keys.include?(name)
|
654
|
+
if @aliases.keys.include?(name)
|
652
655
|
Kameleon.ui.debug("Resolving alias '#{name}'")
|
653
656
|
aliases_cmd = @aliases.fetch(name).clone
|
654
657
|
aliases_cmd_str = aliases_cmd.to_yaml
|
655
|
-
|
656
|
-
args = []
|
658
|
+
yaml = YAML.unsafe_load(cmd.string_cmd)
|
659
|
+
args = []
|
660
|
+
if yaml.is_a?(Hash) # if cmd is an alias with no args, yaml is a String
|
661
|
+
args.push(yaml[name]).flatten! # convert args to array
|
662
|
+
end
|
657
663
|
expected_args_number = aliases_cmd_str.scan(/@\d+/).uniq.count
|
658
664
|
if expected_args_number != args.count
|
659
|
-
if
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
end
|
665
|
+
msg = if expected_args_number.zero?
|
666
|
+
"#{name} takes no arguments (#{args.count} given)"
|
667
|
+
else
|
668
|
+
"#{name} takes exactly #{expected_args_number} arguments (#{args.count} given)"
|
669
|
+
end
|
665
670
|
raise RecipeError, msg
|
666
671
|
end
|
667
672
|
aliases_cmd.map do |c|
|
668
673
|
nc = Command.new(c, cmd.microstep_name)
|
669
674
|
args.each_with_index do |arg, i|
|
670
|
-
nc.gsub!("@#{i+1}", arg)
|
675
|
+
nc.gsub!("@#{i + 1}", arg)
|
671
676
|
end
|
672
677
|
resolve_alias(nc)
|
673
|
-
end
|
674
|
-
elsif cmd.value.
|
678
|
+
end
|
679
|
+
elsif cmd.value.is_a?(Array)
|
675
680
|
Kameleon.ui.debug("Search for aliases in the sub-commands of '#{name}'")
|
676
|
-
cmd.value.map!{ |
|
681
|
+
cmd.value.map! { |c| resolve_alias(c) }.flatten!
|
677
682
|
cmd.remaster_string_cmd_from_value!
|
678
683
|
else
|
679
684
|
Kameleon.ui.debug("Leaf command '#{name}' is not an alias")
|
data/lib/kameleon/ui.rb
CHANGED
@@ -139,7 +139,7 @@ module Kameleon
|
|
139
139
|
spaces ? text.gsub(/#{spaces}/, '') : text
|
140
140
|
end
|
141
141
|
|
142
|
-
def word_wrap(text, line_width =
|
142
|
+
def word_wrap(text, line_width = Thor::Shell::Terminal.terminal_width)
|
143
143
|
strip_leading_spaces(text).split("\n").collect do |line|
|
144
144
|
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
|
145
145
|
end * "\n"
|
data/lib/kameleon/utils.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# The progressbar and ruby-progressbar gems are the same code from
|
2
|
+
# https://github.com/jfelchner/ruby-progressbar/tree/master
|
3
|
+
# Only the lib head file is named progressbar.rb vs. ruby-progressbar.rb.
|
4
|
+
# The progressbar gem is the one packaged as ruby-progressbar in Debian.
|
5
|
+
# Using that one (see gemspec) and require "progressbar" not "ruby-progessbar".
|
1
6
|
require 'progressbar'
|
2
7
|
|
3
8
|
module Kameleon
|
@@ -158,7 +163,7 @@ module Kameleon
|
|
158
163
|
end
|
159
164
|
unless recipes_hash.empty?
|
160
165
|
name_width = recipes_hash.map { |k| k['name'].size }.max
|
161
|
-
desc_width =
|
166
|
+
desc_width = Thor::Shell::Terminal.terminal_width - name_width - 3
|
162
167
|
desc_width = (80 - name_width - 3) if desc_width < 0
|
163
168
|
end
|
164
169
|
repo_str_old = nil
|
@@ -180,7 +185,7 @@ module Kameleon
|
|
180
185
|
if r["description"].to_s.length > desc_width - 4
|
181
186
|
r["description"] = r["description"][0..(desc_width - 4)] + "..."
|
182
187
|
end
|
183
|
-
Kameleon.ui.shell.say
|
188
|
+
Kameleon.ui.shell.say r["description"], :blue
|
184
189
|
end
|
185
190
|
end
|
186
191
|
|
data/lib/kameleon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kameleon-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salem Harrache
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2025-
|
15
|
+
date: 2025-05-04 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: childprocess
|
@@ -29,47 +29,47 @@ dependencies:
|
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '4.0'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
32
|
+
name: progressbar
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
35
|
- - "~>"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '1.10'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - "~>"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
44
|
+
version: '1.10'
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
46
|
+
name: psych
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '5.0'
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
58
|
+
version: '5.0'
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
|
-
name: ruby-
|
60
|
+
name: ruby-graphviz
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
63
|
- - "~>"
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '1.
|
65
|
+
version: '1.2'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '1.
|
72
|
+
version: '1.2'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: table_print
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +110,6 @@ executables:
|
|
110
110
|
extensions: []
|
111
111
|
extra_rdoc_files: []
|
112
112
|
files:
|
113
|
-
- ".bumpversion.cfg"
|
114
113
|
- ".editorconfig"
|
115
114
|
- ".env"
|
116
115
|
- ".gitignore"
|
@@ -148,7 +147,6 @@ files:
|
|
148
147
|
- lib/kameleon/utils.rb
|
149
148
|
- lib/kameleon/version.rb
|
150
149
|
- lib64
|
151
|
-
- scripts/bumpversion.py
|
152
150
|
- tests/helper.rb
|
153
151
|
- tests/issue76/fail.stdout
|
154
152
|
- tests/issue76/fail.yaml
|
data/.bumpversion.cfg
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
[bumpversion]
|
2
|
-
commit = True
|
3
|
-
tag = True
|
4
|
-
current_version = 2.10.13
|
5
|
-
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+))?
|
6
|
-
serialize =
|
7
|
-
{major}.{minor}.{patch}.{release}
|
8
|
-
{major}.{minor}.{patch}
|
9
|
-
|
10
|
-
[bumpversion:file:lib/kameleon/version.rb]
|
11
|
-
|
12
|
-
[bumpversion:part:release]
|
13
|
-
optional_value = gamma
|
14
|
-
values =
|
15
|
-
dev
|
16
|
-
gamma
|
data/scripts/bumpversion.py
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
# coding: utf-8
|
3
|
-
from __future__ import unicode_literals, print_function
|
4
|
-
import os
|
5
|
-
import re
|
6
|
-
|
7
|
-
from io import open
|
8
|
-
import datetime
|
9
|
-
import subprocess
|
10
|
-
|
11
|
-
from argparse import RawTextHelpFormatter, ArgumentParser, FileType
|
12
|
-
|
13
|
-
|
14
|
-
def generate_changelog_title(version):
|
15
|
-
version_title = "Version %s" % version
|
16
|
-
return version_title + "\n" + "-" * len(version_title)
|
17
|
-
|
18
|
-
|
19
|
-
def get_release_date():
|
20
|
-
dt = datetime.date.today()
|
21
|
-
if 4 <= dt.day <= 20 or 24 <= dt.day <= 30:
|
22
|
-
suffix = "th"
|
23
|
-
else:
|
24
|
-
suffix = ["st", "nd", "rd"][dt.day % 10 - 1]
|
25
|
-
return dt.strftime("%%B %%d%s %%Y" % suffix)
|
26
|
-
|
27
|
-
|
28
|
-
def bump_release_version(args):
|
29
|
-
"""Automated software release workflow
|
30
|
-
|
31
|
-
* Bumps the release version number (with .bumpversion.cfg)
|
32
|
-
* Preloads the correct changelog template for editing
|
33
|
-
* Builds a source distribution
|
34
|
-
* Sets release date
|
35
|
-
* Tags the release
|
36
|
-
|
37
|
-
You can run it like::
|
38
|
-
|
39
|
-
$ python bumpversion.py
|
40
|
-
|
41
|
-
which will create a 'release' version (Eg. 0.7.2-dev => 0.7.2).
|
42
|
-
|
43
|
-
"""
|
44
|
-
# Dry run 'bumpversion' to find out what the new version number
|
45
|
-
# would be. Useful side effect: exits if the working directory is not
|
46
|
-
# clean.
|
47
|
-
changelog = args.changelog.name
|
48
|
-
bumpver = subprocess.check_output(
|
49
|
-
['bumpversion', 'release', '--dry-run', '--verbose'],
|
50
|
-
stderr=subprocess.STDOUT)
|
51
|
-
m = re.search(r'Parsing version \'(\d+\.\d+\.\d+)\.dev\'', bumpver)
|
52
|
-
current_version = m.groups(0)[0] + ".dev"
|
53
|
-
m = re.search(r'New version will be \'(\d+\.\d+\.\d+)\'', bumpver)
|
54
|
-
release_version = m.groups(0)[0]
|
55
|
-
|
56
|
-
date = get_release_date()
|
57
|
-
|
58
|
-
current_version_title = generate_changelog_title(current_version)
|
59
|
-
release_version_title = generate_changelog_title(release_version)
|
60
|
-
changes = ""
|
61
|
-
with open(changelog) as fd:
|
62
|
-
changes += fd.read()
|
63
|
-
|
64
|
-
changes = changes.replace(current_version_title, release_version_title)\
|
65
|
-
.replace("**unreleased**", "Released on %s" % date)
|
66
|
-
|
67
|
-
with open(changelog, "w") as fd:
|
68
|
-
fd.write(changes)
|
69
|
-
|
70
|
-
# Tries to load the EDITOR environment variable, else falls back to vim
|
71
|
-
editor = os.environ.get('EDITOR', 'vim')
|
72
|
-
os.system("{} {}".format(editor, changelog))
|
73
|
-
|
74
|
-
subprocess.check_output(['gem', 'build', 'kameleon-builder.gemspec'])
|
75
|
-
|
76
|
-
# Have to add it so it will be part of the commit
|
77
|
-
subprocess.check_output(['git', 'add', changelog])
|
78
|
-
subprocess.check_output(
|
79
|
-
['git', 'commit', '-m', 'Changelog for {}'.format(release_version)])
|
80
|
-
|
81
|
-
# Really run bumpver to set the new release and tag
|
82
|
-
bv_args = ['bumpversion', 'release']
|
83
|
-
|
84
|
-
bv_args += ['--new-version', release_version]
|
85
|
-
|
86
|
-
subprocess.check_output(bv_args)
|
87
|
-
|
88
|
-
|
89
|
-
def bump_new_version(args):
|
90
|
-
"""Increment the version number to the next development version
|
91
|
-
|
92
|
-
* Bumps the development version number (with .bumpversion.cfg)
|
93
|
-
* Preloads the correct changelog template for editing
|
94
|
-
|
95
|
-
You can run it like::
|
96
|
-
|
97
|
-
$ python bumpversion.py newversion
|
98
|
-
|
99
|
-
which, by default, will create a 'patch' dev version (0.0.1 => 0.0.2-dev).
|
100
|
-
|
101
|
-
You can also specify a patch level (patch, minor, major) to change to::
|
102
|
-
|
103
|
-
$ python bumpversion.py newversion major
|
104
|
-
|
105
|
-
which will create a 'major' release (0.0.2 => 1.0.0-dev)."""
|
106
|
-
pass
|
107
|
-
# Dry run 'bumpversion' to find out what the new version number
|
108
|
-
# would be. Useful side effect: exits if the working directory is not
|
109
|
-
# clean.
|
110
|
-
changelog = args.changelog.name
|
111
|
-
part = args.part
|
112
|
-
bumpver = subprocess.check_output(
|
113
|
-
['bumpversion', part, '--dry-run', '--verbose'],
|
114
|
-
stderr=subprocess.STDOUT)
|
115
|
-
m = re.search(r'Parsing version \'(\d+\.\d+\.\d+)\'', bumpver)
|
116
|
-
current_version = m.groups(0)[0]
|
117
|
-
m = re.search(r'New version will be \'(\d+\.\d+\.\d+)\.dev\'', bumpver)
|
118
|
-
next_version = m.groups(0)[0] + ".dev"
|
119
|
-
|
120
|
-
current_version_title = generate_changelog_title(current_version)
|
121
|
-
next_version_title = generate_changelog_title(next_version)
|
122
|
-
|
123
|
-
next_release_template = "%s\n\n**unreleased**\n\n" % next_version_title
|
124
|
-
|
125
|
-
changes = ""
|
126
|
-
with open(changelog) as fd:
|
127
|
-
changes += fd.read()
|
128
|
-
|
129
|
-
changes = changes.replace(current_version_title,
|
130
|
-
next_release_template + current_version_title)
|
131
|
-
|
132
|
-
with open(changelog, "w") as fd:
|
133
|
-
fd.write(changes)
|
134
|
-
|
135
|
-
# Tries to load the EDITOR environment variable, else falls back to vim
|
136
|
-
editor = os.environ.get('EDITOR', 'vim')
|
137
|
-
os.system("{} {}".format(editor, changelog))
|
138
|
-
|
139
|
-
# Have to add it so it will be part of the commit
|
140
|
-
subprocess.check_output(['git', 'add', changelog])
|
141
|
-
subprocess.check_output(
|
142
|
-
['git', 'commit', '-m', 'Changelog for {}'.format(next_version)])
|
143
|
-
|
144
|
-
# Really run bumpver to set the new release and tag
|
145
|
-
bv_args = ['bumpversion', part, '--no-tag', '--new-version', next_version]
|
146
|
-
|
147
|
-
subprocess.check_output(bv_args)
|
148
|
-
|
149
|
-
|
150
|
-
def main():
|
151
|
-
'''Parse command-line arguments and execute bumpversion command.'''
|
152
|
-
|
153
|
-
parser = ArgumentParser(prog='bumpversion',
|
154
|
-
description='Bumpversion wrapper')
|
155
|
-
|
156
|
-
default_changelog = os.path.join(os.getcwd(), 'CHANGES')
|
157
|
-
|
158
|
-
subparsers = parser.add_subparsers(title='bumpversion wrapper commands')
|
159
|
-
# release command
|
160
|
-
release_doc = bump_release_version.__doc__
|
161
|
-
subparser = subparsers.add_parser("release",
|
162
|
-
description=release_doc,
|
163
|
-
formatter_class=RawTextHelpFormatter)
|
164
|
-
subparser.add_argument('--changelog', help='Project changelog',
|
165
|
-
type=FileType(),
|
166
|
-
default=default_changelog)
|
167
|
-
subparser.set_defaults(func=bump_release_version)
|
168
|
-
# newversion command
|
169
|
-
newversion_doc = bump_new_version.__doc__
|
170
|
-
subparser = subparsers.add_parser("newversion",
|
171
|
-
description=newversion_doc,
|
172
|
-
formatter_class=RawTextHelpFormatter)
|
173
|
-
subparser.add_argument('--changelog', help='Project changelog',
|
174
|
-
type=FileType(),
|
175
|
-
default=default_changelog)
|
176
|
-
subparser.add_argument('part', help='Part of the version to be bumped',
|
177
|
-
choices=['patch', 'minor', 'major'])
|
178
|
-
subparser.set_defaults(func=bump_new_version)
|
179
|
-
# Parse argv arguments
|
180
|
-
args = parser.parse_args()
|
181
|
-
args.func(args)
|
182
|
-
|
183
|
-
if __name__ == '__main__':
|
184
|
-
main()
|