-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathupdate-version.sh
More file actions
69 lines (56 loc) · 2.22 KB
/
Copy pathupdate-version.sh
File metadata and controls
69 lines (56 loc) · 2.22 KB
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
#!/bin/bash
# update-version.sh — Bump the sc0710 driver version to today's date.
#
# Version format: YYYY.MM.DD-REV
# - If no version exists for today, starts at revision 1.
# - If a version for today already exists, increments the revision.
#
# Files updated:
# ./version — canonical version string (YYYY.MM.DD-REV)
# ./dkms.conf — PACKAGE_VERSION="YYYY.MM.DD.REV"
# ./lib/sc0710-version.h — C header consumed by the kernel module
#
# The kernel module reads the version from lib/sc0710-version.h (modinfo, dmesg).
# Rebuild after bumping: make, dkms build, or sc0710-cli --update
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VERSION_FILE="${SCRIPT_DIR}/version"
DKMS_FILE="${SCRIPT_DIR}/dkms.conf"
SYNC_HEADER="${SCRIPT_DIR}/scripts/sync-version-header.sh"
TODAY=$(date +%Y.%m.%d)
# Read current version from the version file
if [[ ! -f "$VERSION_FILE" ]]; then
echo "Error: ${VERSION_FILE} not found." >&2
exit 1
fi
CURRENT=$(head -n 1 "$VERSION_FILE" | tr -d '[:space:]')
echo "Current version: ${CURRENT}"
# Extract the date portion and revision from the current version (format: YYYY.MM.DD-REV)
CURRENT_DATE="${CURRENT%-*}"
CURRENT_REV="${CURRENT##*-}"
if [[ "$CURRENT_DATE" == "$TODAY" ]]; then
# Same date — increment revision
NEW_REV=$(( CURRENT_REV + 1 ))
else
# New date — start at revision 1
NEW_REV=1
fi
NEW_VERSION="${TODAY}-${NEW_REV}"
# dkms.conf uses dots instead of a dash before the revision
NEW_DKMS_VERSION="${TODAY}.${NEW_REV}"
echo "New version: ${NEW_VERSION}"
# Update the version file
echo "$NEW_VERSION" > "$VERSION_FILE"
# Update dkms.conf — replace the PACKAGE_VERSION line
sed -i "s/^PACKAGE_VERSION=.*/PACKAGE_VERSION=\"${NEW_DKMS_VERSION}\"/" "$DKMS_FILE"
# Sync C header used by the kernel module (modinfo version, boot message)
bash "$SYNC_HEADER"
echo ""
echo "Updated:"
echo " ${VERSION_FILE} -> ${NEW_VERSION}"
echo " ${DKMS_FILE} -> PACKAGE_VERSION=\"${NEW_DKMS_VERSION}\""
echo " lib/sc0710-version.h -> ${NEW_VERSION}"
echo ""
echo "Rebuild the module for modinfo/dmesg to show the new version:"
echo " make"
echo " sudo sc0710-cli --update # installed systems"