Skip to content

Commit 63440b3

Browse files
authored
Merge pull request #53 from plattfot/52/configure_version_at_build_time
Configure version at build time
2 parents 54cf58c + 230ec84 commit 63440b3

8 files changed

Lines changed: 79 additions & 90 deletions

File tree

‎.github/workflows/makefile.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ jobs:
2121
run: mkdir -p build/{usr/bin,usr/lib,etc}
2222
- name: Build and install
2323
run: make install PREFIX=build
24+
- name: Smoke test baksnapper
25+
run: ./build/usr/bin/baksnapper --version
26+
- name: Smoke test baksnapperd
27+
run: ./build/usr/bin/baksnapperd --version
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- SPDX-FileCopyrightText: 2025 Fredrik Salomonsson <plattfot@posteo.net> -->
2+
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
3+
### Changed
4+
- Set version in scripts using meson/make. [#52](https://github.com/plattfot/baksnapper/issues/52)

‎Makefile‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ $(PREFIX_BIN) $(PREFIX_LIB)/systemd/system $(PREFIX_ETC)/baksnapper/example:
3030
.PHONY: install bin systemd etc
3131
install: bin systemd
3232

33+
__root_dir=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
34+
__version=$(shell $(__root_dir)build-aux/version)
3335
bin: | $(PREFIX_BIN)
34-
@install baksnapper.sh $|/baksnapper
35-
@install baksnapperd.sh $|/baksnapperd
36+
@sed 's/@VERSION@/${__version}/' baksnapper.sh > $|/baksnapper
37+
@chmod 744 $|/baksnapper
38+
@sed 's/@VERSION@/${__version}/' baksnapperd.sh > $|/baksnapperd
39+
@chmod 744 $|/baksnapperd
3640

3741
systemd: etc | $(PREFIX_LIB)/systemd/system
3842
@install --mode=644 systemd/baksnapper@.timer $|/

‎baksnapper.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Fredrik "PlaTFooT" Salomonsson
127127
EOF
128128

129129
read -rd '' version <<EOF
130-
baksnapper (baksnapper) 2.5.0
130+
baksnapper (baksnapper) @VERSION@
131131
Copyright (C) 2015-2025 Fredrik Salomonsson
132132
Copyright (C) 2021 Nathan Dehnel
133133
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.

‎baksnapperd-denotebak.sh‎

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# SPDX-License-Identifier: GPL-3.0-or-later
88

99
read -rd '' version <<EOF
10-
baksnapperd-denotebak (baksnapper) 2.4.0
10+
baksnapperd-denotebak (baksnapper) @VERSION@
1111
Copyright (C) 2025 Fredrik Salomonsson
1212
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
1313
This is free software: you are free to change and redistribute it.

‎baksnapperd.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# SPDX-License-Identifier: GPL-3.0-or-later
1010

1111
read -rd '' version <<EOF
12-
baksnapperd (baksnapper) 2.4.0
12+
baksnapperd (baksnapper) @VERSION@
1313
Copyright (C) 2015-2025 Fredrik Salomonsson
1414
Copyright (C) 2021-2022 Nathan Dehnel
1515
Copyright (C) 2023 Juergen Gleiss

‎build-aux/version‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
#
55
# SPDX-License-Identifier: GPL-3.0-or-later
66

7-
major=2
8-
minor=5
9-
patch=0
10-
11-
version=$major.$minor.$patch
7+
version=2.5.0
128

139
read -rd '' help <<EOF
1410
Usage: $0 [OPTIONS...]
@@ -43,19 +39,20 @@ do
4339
key=$1
4440
case $key in
4541
-s|--short)
46-
version=$major.$minor
42+
result=${version%.*}
4743
shift
4844
;;
4945
-M|--major)
50-
version=$major
46+
result=${version%%.*}
5147
shift
5248
;;
5349
-m|--minor)
54-
version=$minor
50+
short=${version%.*}
51+
result=${short#*.}
5552
shift
5653
;;
5754
-p|--patch)
58-
version=$patch
55+
result=${version##*.}
5956
shift
6057
;;
6158
-h|--help)
@@ -69,4 +66,4 @@ case $key in
6966
esac
7067
done
7168

72-
echo $version
69+
echo "${result:-$version}"

0 commit comments

Comments
 (0)