summaryrefslogtreecommitdiff
path: root/other/version-sync
blob: 3fb1aa8030d6166965834bd7d1936d662f4ea028 (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
#!/bin/sh

set -eu

SOURCE_DIR=$1
MAJOR=$2
MINOR=$3
PATCH=$4

VER="$MAJOR.$MINOR.$PATCH"

update() {
  file="$SOURCE_DIR/$1"
  expr="$2"

  sed -e "$expr" "$file" > "$file.updated-version"
  if diff "$file" "$file.updated-version"; then
    rm "$file.updated-version"
  else
    mv "$file.updated-version" "$file"
  fi
}

update 'configure.ac' 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/'

update 'toxcore/tox.api.h' 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/'
update 'toxcore/tox.api.h' 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/'