kameleon-builder 2.10.13 → 2.11.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98949549d6db81a6e1f992d047d98cb1996422a1fafd974395983511f1a0fac0
4
- data.tar.gz: 238e4bacb28a1061fb8ea65477949013357619501b40ceb28784e44feea51b26
3
+ metadata.gz: d699fb75c8ca9e69eacee74eeca23bea5c26101bc19d3c81a032b3bf4b5ae0bf
4
+ data.tar.gz: 6b754a2ad8424e8d3a449e9bced4fb432a2f0c7515a71ff7054c1dd89e676d35
5
5
  SHA512:
6
- metadata.gz: 9d44ab789cd681b54a6db3b7377e52e6ba66acc76391a02397f87df1d1b33f66492a454eb3902bbf76aba8a07041000803001ca1cff7448b0d0d8a7260780671
7
- data.tar.gz: 448f0ebb4d031e99f11edbf8608628c24698a17f1da187557c6695fef21c8038d3b83ba9bb6727e30fd2fef568236d4d51efffbc7a121db7b4368ca7eafa4db4
6
+ metadata.gz: a8ca8308b765564530dae62c57ad66cee6388a3da027b88459f104ab9ee62a6d962989f9a86871225390246d9ba3e9de0c77a5818c2493f415c9d8c01fcbd4d8
7
+ data.tar.gz: a0223ab407812953ab4e35c8143427b30af6a64e9f491b845314a3b2964ef3085941b05f39deb0e7ed1c13d26c07e1de25e857bf1b270372265863811fffede6
data/CHANGES CHANGED
@@ -1,6 +1,28 @@
1
1
  Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
+ Version 2.11.1
5
+ ------------------------
6
+
7
+ Released on November 23rd 2025
8
+
9
+ - Fix dependency name for ruby-progressbar (to please Debian).
10
+ - Bump version of childprocess (to please Debian).
11
+ - Fix process execution: remove buggy/useless call to source the default bashrc.
12
+
13
+ Version 2.10.14 → 2.11.0
14
+ ------------------------
15
+
16
+ Released on May 4th 2025
17
+
18
+ - Enable command aliases in the definition of checkpoint actions.
19
+ - Enable command aliases with no args.
20
+ - Fix dependencies to progressbar and ruby-graphviz (the "ruby-" prefix matters!).
21
+ - Fix terminal width issue with latest Thor.
22
+ - Fix graphviz and progress bar dependencies.
23
+ - Rework README.rst and the documentation front page.
24
+ - Some other minor changes.
25
+
4
26
  Version 2.10.13
5
27
  ---------------
6
28
 
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 appliances. With
5
- Kameleon, you make your recipe that describes how to create step by step your
6
- own distribution. At start Kameleon is used to create custom kvm, LXC,
7
- VirtualBox, iso images, ..., but as it is designed to be very generic you can
8
- probably do a lot more than that.
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
- ## Merge devel into master:
14
+ ## Switch and update the master branch
15
15
  ```
16
- git checkout master
17
- git merge devel
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
- ## Fix anything needed
21
- Should be no conflict but...
22
- Make sure changelog is up to date.
22
+ ## Update changelog
23
+ Edit the `CHANGES` file.
24
+ Commit.
23
25
 
24
26
  ## Bump version
25
- ***Warning*** Make sure that there is no dirty file (not committed) before the following.
27
+ Edit the `lib/kameleon/version.rb` file and bump the version.
28
+ Commit:
26
29
  ```
27
- ./scripts/bumpversion.py release # will do 2.7.0.dev -> 2.7.0 + git tag + changelog
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
- gem push kameleon-builder-2.7.0.gem
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
- gem owner kameleon-builder -a your@email.com
67
+ gem owner kameleon-builder -a your@email.com
47
68
  ```
48
69
 
49
70
  That's all :)
50
71
 
51
- For devel releases:
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
- git checkout devel
57
- git rebase master
75
+ gem yank kameleon-builder -v 2.10.16
58
76
  ```
59
77
 
60
- ## Prepare the new version
61
- Create the new devel version (e.g. 2.7.0 dev)
78
+ For developments:
79
+ -----------------
80
+
81
+ Changes can be tested by locally installing the gem after building it:
62
82
  ```
63
- ./scripts/bumpversion.py newversion patch # 2.6.7 -> 2.7.0.dev
83
+ gem build kameleon-builder.gemspec && gem install --user ./kameleon-builder-2.10.17.gem
64
84
  ```
65
85
 
66
- At this point, do work, commit, and so on.
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.
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env bash
2
-
3
1
  _kameleon() {
4
2
  COMPREPLY=()
5
3
  local i=1
@@ -29,12 +29,12 @@ Gem::Specification.new do |s|
29
29
  s.test_files = s.files.grep(%r{^(tests|s|features)/})
30
30
  s.require_paths = ['lib']
31
31
 
32
- s.add_dependency 'childprocess', '~> 4.0'
32
+ s.add_dependency 'childprocess', '~> 5.1'
33
+ s.add_dependency 'ruby-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
- s.add_dependency 'thor', '~> 1.0'
37
+ s.add_dependency 'thor', '~> 1.3'
38
38
 
39
39
  s.requirements << 'git'
40
40
  s.requirements << 'graphviz'
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 developpers"
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"
@@ -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
- args = YAML.unsafe_load(cmd.string_cmd)[name]
656
- args = [].push(args).flatten # convert args to array
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 args.length == 0
660
- msg = "#{name} takes no arguments (#{args.count} given)"
661
- else
662
- msg = "#{name} takes exactly #{expected_args_number} arguments"
663
- " (#{args.count} given)"
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.kind_of?(Array)
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!{ |cmd| resolve_alias(cmd) }.flatten!
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")
@@ -49,10 +49,8 @@ module Kameleon
49
49
  ## Changing the default bashrc if the cache is activated
50
50
  @cache = Kameleon::Persistent_cache.instance
51
51
 
52
- @shell_cmd = "source #{@default_bashrc_file} 2> /dev/null; "\
53
- "#{@cmd} --rcfile #{@bashrc_file}"
54
- @interactive_shell_cmd = "source #{@default_bashrc_file} 2> /dev/null; "\
55
- "#{@interactive_cmd} --rcfile #{@bashrc_file}"
52
+ @shell_cmd = "#{@cmd} --rcfile #{@bashrc_file}"
53
+ @interactive_shell_cmd = "#{@interactive_cmd} --rcfile #{@bashrc_file}"
56
54
 
57
55
  Kameleon.ui.debug("Initialize shell (#{self})")
58
56
  # Injecting all variables of the options and assign the variables
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 = @shell.terminal_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"
@@ -1,4 +1,10 @@
1
- require 'progressbar'
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
+ # On Debian, the ruby-progressbar is installed, but patched in order to provide
5
+ # not only ruby-progressbar.rb but also progressbar.rb (same content)
6
+ # Using ruby-progessbar that seems more frequently used.
7
+ require 'ruby-progressbar'
2
8
 
3
9
  module Kameleon
4
10
  module Utils
@@ -158,7 +164,7 @@ module Kameleon
158
164
  end
159
165
  unless recipes_hash.empty?
160
166
  name_width = recipes_hash.map { |k| k['name'].size }.max
161
- desc_width = Kameleon.ui.shell.terminal_width - name_width - 3
167
+ desc_width = Thor::Shell::Terminal.terminal_width - name_width - 3
162
168
  desc_width = (80 - name_width - 3) if desc_width < 0
163
169
  end
164
170
  repo_str_old = nil
@@ -180,7 +186,7 @@ module Kameleon
180
186
  if r["description"].to_s.length > desc_width - 4
181
187
  r["description"] = r["description"][0..(desc_width - 4)] + "..."
182
188
  end
183
- Kameleon.ui.shell.say sprintf("%-#{desc_width}s", r["description"]), :blue
189
+ Kameleon.ui.shell.say r["description"], :blue
184
190
  end
185
191
  end
186
192
 
@@ -1,3 +1,3 @@
1
1
  module Kameleon
2
- VERSION = '2.10.13'
2
+ VERSION = '2.11.1'
3
3
  end
data/lib64 CHANGED
@@ -1 +1 @@
1
- ./lib
1
+ lib
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.10.13
4
+ version: 2.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salem Harrache
@@ -9,10 +9,9 @@ authors:
9
9
  - Cristan Ruiz
10
10
  - Pierre Neyron
11
11
  - Bruno Bzeznik
12
- autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2025-03-26 00:00:00.000000000 Z
14
+ date: 2025-11-24 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: childprocess
@@ -20,56 +19,56 @@ dependencies:
20
19
  requirements:
21
20
  - - "~>"
22
21
  - !ruby/object:Gem::Version
23
- version: '4.0'
22
+ version: '5.1'
24
23
  type: :runtime
25
24
  prerelease: false
26
25
  version_requirements: !ruby/object:Gem::Requirement
27
26
  requirements:
28
27
  - - "~>"
29
28
  - !ruby/object:Gem::Version
30
- version: '4.0'
29
+ version: '5.1'
31
30
  - !ruby/object:Gem::Dependency
32
- name: psych
31
+ name: ruby-progressbar
33
32
  requirement: !ruby/object:Gem::Requirement
34
33
  requirements:
35
34
  - - "~>"
36
35
  - !ruby/object:Gem::Version
37
- version: '5.0'
36
+ version: '1.10'
38
37
  type: :runtime
39
38
  prerelease: false
40
39
  version_requirements: !ruby/object:Gem::Requirement
41
40
  requirements:
42
41
  - - "~>"
43
42
  - !ruby/object:Gem::Version
44
- version: '5.0'
43
+ version: '1.10'
45
44
  - !ruby/object:Gem::Dependency
46
- name: ruby-graphviz
45
+ name: psych
47
46
  requirement: !ruby/object:Gem::Requirement
48
47
  requirements:
49
48
  - - "~>"
50
49
  - !ruby/object:Gem::Version
51
- version: '1.2'
50
+ version: '5.0'
52
51
  type: :runtime
53
52
  prerelease: false
54
53
  version_requirements: !ruby/object:Gem::Requirement
55
54
  requirements:
56
55
  - - "~>"
57
56
  - !ruby/object:Gem::Version
58
- version: '1.2'
57
+ version: '5.0'
59
58
  - !ruby/object:Gem::Dependency
60
- name: ruby-progressbar
59
+ name: ruby-graphviz
61
60
  requirement: !ruby/object:Gem::Requirement
62
61
  requirements:
63
62
  - - "~>"
64
63
  - !ruby/object:Gem::Version
65
- version: '1.10'
64
+ version: '1.2'
66
65
  type: :runtime
67
66
  prerelease: false
68
67
  version_requirements: !ruby/object:Gem::Requirement
69
68
  requirements:
70
69
  - - "~>"
71
70
  - !ruby/object:Gem::Version
72
- version: '1.10'
71
+ version: '1.2'
73
72
  - !ruby/object:Gem::Dependency
74
73
  name: table_print
75
74
  requirement: !ruby/object:Gem::Requirement
@@ -90,14 +89,14 @@ dependencies:
90
89
  requirements:
91
90
  - - "~>"
92
91
  - !ruby/object:Gem::Version
93
- version: '1.0'
92
+ version: '1.3'
94
93
  type: :runtime
95
94
  prerelease: false
96
95
  version_requirements: !ruby/object:Gem::Requirement
97
96
  requirements:
98
97
  - - "~>"
99
98
  - !ruby/object:Gem::Version
100
- version: '1.0'
99
+ version: '1.3'
101
100
  description: Kameleon is a tool to build system appliances, possibly from scratch
102
101
  email:
103
102
  - salem@harrache.info
@@ -110,7 +109,6 @@ executables:
110
109
  extensions: []
111
110
  extra_rdoc_files: []
112
111
  files:
113
- - ".bumpversion.cfg"
114
112
  - ".editorconfig"
115
113
  - ".env"
116
114
  - ".gitignore"
@@ -148,7 +146,6 @@ files:
148
146
  - lib/kameleon/utils.rb
149
147
  - lib/kameleon/version.rb
150
148
  - lib64
151
- - scripts/bumpversion.py
152
149
  - tests/helper.rb
153
150
  - tests/issue76/fail.stdout
154
151
  - tests/issue76/fail.yaml
@@ -178,7 +175,6 @@ homepage: http://kameleon.imag.fr/
178
175
  licenses:
179
176
  - GPL-2.0-or-later
180
177
  metadata: {}
181
- post_install_message:
182
178
  rdoc_options: []
183
179
  require_paths:
184
180
  - lib
@@ -195,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
191
  requirements:
196
192
  - git
197
193
  - graphviz
198
- rubygems_version: 3.2.5
199
- signing_key:
194
+ rubygems_version: 3.6.7
200
195
  specification_version: 4
201
196
  summary: The mindful appliance builder
202
197
  test_files:
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
@@ -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()