Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

on version strings for debian packages #22

Closed
jessereynolds opened this issue Jul 27, 2014 · 9 comments
Closed

on version strings for debian packages #22

jessereynolds opened this issue Jul 27, 2014 · 9 comments
Labels

Comments

@jessereynolds
Copy link
Member

In the omnibus3 branch we've changed the flapjack software definition so that it pulls flapjack from github, rather than from rubygems.org. This has the advantage that we can now build flapjack packages from master, or any tag, without having to first publish the tagged version on rubygems.org.

But the version identifier needs some changes. Here's some points identified when discussing this with @Hobbsee, @ali-graham:

VERSION[~VERSIONMOD][~TIMESTAMP-SHA1]-DEBIAN_REVISION

  • when building from a prerelease tag, eg a release candidate, insert ~ before the first alpha char, eg tag v1.0.0rc3 => 1.0.0~rc3 - this is so the release candidate sorts earlier than the full release of 1.0.0 (so that installing 1.0.0 over the top of 1.0.0rc3 would work)
  • ~TIMESTAMP-SHA1 should be included when building from a branch name or commit sha1. It's not to be included when building from a tag. The SHA1 part is the first 7 chars of the SHA-1 hash of the commit being built from
  • for branches, the version string needs to be fetched from Flapjack::VERSION (which will correspond to the previous release unless the version has been bumped in readiness for a new version}. So, if a timestamp and sha-1 is present, it means the version doesn't correspond to a tag, but rather an arbitrary commit.
  • TIMESTAMP is the time the build commences, UTC (not applicable when building from a tag)

I think this is going to require a wrapper script in omnibus-flapjack that calculates the version string to use, and then runs the docker build command with it set up in env vars:

eg:

$ package_build master
=>
FLAPJACK_BUILD_REF="9c027de"
FLAPJACK_PACKAGE_VERSION="1.0.0~rc3~20140724T180446-9c027de-1"
...
$ package_build v1.0.0rc3
=>
FLAPJACK_BUILD_REF="v1.0.0rc3"
FLAPJACK_PACKAGE_VERSION="1.0.0~rc3-1"
...
$ package_build 75a209e
=>
FLAPJACK_BUILD_REF="75a209e"
FLAPJACK_PACKAGE_VERSION="1.0.0~rc2~20140724T180446-75a209e-1"

The flapjack version string can be retrieved by the wrapper script like so:

ruby -e 'load "lib/flapjack/version.rb" ; puts Flapjack::VERSION'
@auxesis
Copy link
Member

auxesis commented Jul 27, 2014

👍

@jessereynolds
Copy link
Member Author

omnibus won't let me have ~ in the version string as it uses git to cache builds and tries to make a tag name including the ~, which don't work. the error:

git --git-dir=/var/cache/omnibus/cache/install_path/opt/flapjack \
  --work-tree=/opt/flapjack tag -f \
  "flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1"

fatal: 'flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1' 
  is not a valid tag name.

raw output:

      [Builder: flapjack] I | Build succeeded! (215.66244961s)
     [Software: flapjack] I | Caching build
                          I | $ git --git-dir=/var/cache/omnibus/cache/install_path/opt/flapjack --work-tree=/opt/flapjack add -A -f
                          I | $ git --git-dir=/var/cache/omnibus/cache/install_path/opt/flapjack --work-tree=/opt/flapjack commit -q -m "Backup of flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1"
                          I | $ git --git-dir=/var/cache/omnibus/cache/install_path/opt/flapjack --work-tree=/opt/flapjack tag -f "flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1"
/var/lib/gems/1.9.1/gems/mixlib-shellout-1.4.0/lib/mixlib/shellout.rb:257:in `invalid!': Expected process to exit with [0], but received '128' (Mixlib::ShellOut::ShellCommandFailed)
---- Begin output of git --git-dir=/var/cache/omnibus/cache/install_path/opt/flapjack --work-tree=/opt/flapjack tag -f "flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1" ----
STDOUT:
STDERR: fatal: 'flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1' is not a valid tag name.
---- End output of git --git-dir=/var/cache/omnibus/cache/install_path/opt/flapjack --work-tree=/opt/flapjack tag -f "flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1" ----
Ran git --git-dir=/var/cache/omnibus/cache/install_path/opt/flapjack --work-tree=/opt/flapjack tag -f "flapjack-1.0.0~rc3~20140727T125000-9b1e831-1-d21c5f83ca481acd784f15b0429044339e88d6b59918af056029f825766e8ee1" returned 128
    from /var/lib/gems/1.9.1/gems/mixlib-shellout-1.4.0/lib/mixlib/shellout.rb:244:in `error!'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/util.rb:77:in `shellout!'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/install_path_cache.rb:85:in `incremental'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/software.rb:623:in `execute_build'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/software.rb:451:in `build_me'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/project.rb:95:in `block in build_me'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/project.rb:94:in `each'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/project.rb:94:in `build_me'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/cli.rb:72:in `build'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/cli/base.rb:33:in `dispatch'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/cli/deprecated.rb:128:in `dispatch'
    from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/lib/omnibus/cli.rb:41:in `execute!'
    from /var/lib/gems/1.9.1/bundler/gems/omnibus-ruby-5ad405c915e4/bin/omnibus:11:in `<top (required)>'
    from bin/omnibus:16:in `load'
    from bin/omnibus:16:in `<main>'

@ghost
Copy link

ghost commented Jul 28, 2014

Hmm, I wonder if it's possible to escape the string being passed for the tag, and if omnibus would accept a patch for doing so?

@jessereynolds
Copy link
Member Author

Yeah i was thinking of doing something similar.

@ghost
Copy link

ghost commented Jul 28, 2014

git help check-ref-format doesn't seem to specify any allowed escaping. 😦

@jessereynolds
Copy link
Member Author

It might need to be a simple-minded character substitution, or removal

@jessereynolds
Copy link
Member Author

Issue #283 for this created in omnibus

@jessereynolds
Copy link
Member Author

reversed tilde works (∽) - U+223d - http://www.fileformat.info/info/unicode/char/223d/index.htm

jesse@heart-of-gold git $ git tag apricot~sausage
fatal: 'apricot~sausage' is not a valid tag name.
jesse@heart-of-gold git $ git tag apricot∽sausage

@jessereynolds
Copy link
Member Author

~ working now with current omnibus master.

deb created like so:

docker run --rm -i -t -e "FLAPJACK_BUILD_REF=6ba5794" \
  -e "FLAPJACK_PACKAGE_VERSION=1.0.0~rc3~20140729T222700-6ba5794-1" \
  flapjack/omnibus-ubuntu bash -c \
  "cd omnibus-flapjack ; \
  git pull ; \
  bundle install --binstubs ; \
  bin/omnibus build --log-level=info flapjack ; \
  bash"

deb installs like so:

vagrant@flapjack-test:~$ sudo dpkg -i /vagrant/flapjack_1.0.0~rc3~20140729T222700-6ba5794-1-1_amd64.deb
Selecting previously unselected package flapjack.
(Reading database ... 51095 files and directories currently installed.)
Unpacking flapjack (from .../flapjack_1.0.0~rc3~20140729T222700-6ba5794-1-1_amd64.deb) ...
Setting up flapjack (1.0.0~rc3~20140729T222700-6ba5794-1-1) ...
Creating /etc/flapjack/flapjack_config.yaml
Creating /etc/init.d/redis-flapjack
Creating /etc/init.d/flapjack
Creating /etc/init.d/flapjack-nagios-receiver
Creating /etc/init.d/flapper
Setting paths
Starting redis-flapjack
Starting redis-server: redis-server.
Starting flapjack
Flapjack starting...Daemon has started successfully
 done.
Thank you for installing flapjack!
Flapjack should now be running. Visit http://localhost:3080/
vagrant@flapjack-test:~$ ps aufx | grep flapjack
vagrant   1454  0.0  0.0  11676   944 pts/0    S+   22:53   0:00              \_ grep --color=auto flapjack
flapjack  1436  0.2  0.1  38144  1740 ?        Ssl  22:50   0:00 /opt/flapjack/embedded/bin/redis-server 127.0.0.1:6380
root      1449  0.2  7.4 189084 75580 ?        Sl   22:50   0:00 /opt/flapjack/embedded/bin/ruby /opt/flapjack/bin/flapjack server start

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants