summaryrefslogtreecommitdiff
path: root/version
blob: 7d7a8b40fed568bc6bd396f35bb13e6a4e8872fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#! /usr/bin/env bash

# Manage build2 toolchain version.
#
# Usage: etc/version
#
usage="usage: etc/version"

# No max, always >=.
#
# NOTE: also update in 'bdep new'?
#
build2_min=0.10.0
bpkg_min=0.10.0

#ver=0.12.0-a.0.z
ver=0.11.0
mods=(libstd-modules libbutl libbutl.bash libbpkg libbbot bpkg)

#odb_ver=2.5.0-b.16.z
odb_ver=2.5.0-b.15
odb_mods=(libodb libodb-sqlite libodb-pgsql)

#xml_ver=1.1.0-b.8.z
xml_ver=1.1.0-b.7
xml_mods=(libstudxml)

# @@ NOTE: libpkgconf version constraint in build2 is updated manually.
# @@ NOTE: libcmark version constraint in brep is updated manually.

all=(libstd-modules libbutl libbutl.bash build2 libbpkg bpkg bpkg-rep bdep libbbot bbot brep build2-toolchain msvc-linux openssl-agent buildos)

# In manifests for alpha/beta we use an exact match. For snapshots -- snapshot
# range. Otherwise an X.Y.* range.
#
function constraint () # <ver>
{
  local mj mn pt ab pr r

  mj="$(echo "$1" | sed -re 's/([^.]+)\..*/\1/')"
  mn="$(echo "$1" | sed -re 's/[^.]+\.([^.]+)\..*/\1/')"
  pt="$(echo "$1" | sed -re 's/[^.]+\.[^.]+\.([^.-]+).*/\1/')"
  ab="$(echo "$1" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-([ab]).*/\1/p')"
  pr="$(echo "$1" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-[ab]\.([^.+]+).*/\1/p')"

  if [ -n "$ab" ]; then
    if [[ $1 == *.z ]]; then
      r="[$mj.$mn.$pt-$ab.$pr.1 $mj.$mn.$pt-$ab.$(($pr+1)))"
    else
      r="^$1"
    fi
  else
    #r="[$mj.$mn.0 $mj.$(($mn+1)).0-); $mj.$mn.X"
    r="^$mj.$mn.$pt"
  fi

  echo "$r"
}

dep="$(constraint "$ver")"
odb_dep="$(constraint "$odb_ver")"
xml_dep="$(constraint "$xml_ver")"

function process () #
{
  # Manifest.
  #
  sed -i -re "s/^(version:).*/\1 $ver/"                      manifest
  sed -i -re "s/^(depends: \* build2) .*/\1 >= $build2_min/" manifest
  sed -i -re "s/^(depends: \* bpkg) .*/\1 >= $bpkg_min/"     manifest

  local m
  for m in "${mods[@]}"; do
    sed -i -re "s/^(depends: $m) .*/\1 $dep/" manifest
  done

  for m in "${odb_mods[@]}"; do
    sed -i -re "s/^(depends: $m) .*/\1 $odb_dep/" manifest
  done

  for m in "${xml_mods[@]}"; do
    sed -i -re "s/^(depends: $m) .*/\1 $xml_dep/" manifest
  done

  # cli.sh
  #
  if [ -f doc/cli.sh ]; then
    sed -i -re "s/^version=.*/version=$ver/" doc/cli.sh
  fi
}

for m in "${all[@]}"; do
  cd "$m"
  process
  cd ..
done

# Configuration version.
#
# Note: also in the install/prepare script.
#
mj="$(echo "$ver" | sed -re 's/([^.]+)\..*/\1/')"
mn="$(echo "$ver" | sed -re 's/[^.]+\.([^.]+)\..*/\1/')"
ab="$(echo "$ver" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-([ab]).*/\1/p')"
pr="$(echo "$ver" | sed -n -re 's/[^.]+\.[^.]+\.[^.-]+-[ab]\.([^.+]+).*/\1/p')"

cver="$mj.$mn"

if [ -n "$ab" ]; then
  cver="$cver-$ab.$pr"
fi

cd build2-toolchain

for m in build*.sh; do
  sed -i -re "s/cver=\".+\"/cver=\"$cver\"/" $m
done

for m in build*.bat; do
  sed -i -re "s/\"cver=.+\"/\"cver=$cver\"/" $m
done

cd ..