Make deb package versions a bit smarter

This commit is contained in:
K. Lange 2022-07-31 19:36:22 +09:00
parent bc413b6dae
commit 2793090d07
2 changed files with 27 additions and 2 deletions

View File

@ -229,8 +229,7 @@ deb: kuroko libkuroko.so
--license "MIT" \
--category "devel" \
-d "libc6 (>= $(LIBCMIN))" \
--version $(VERSION) \
--iteration 0 \
--version $(shell ./kuroko tools/deb-ver.krk) \
--directories $(libdir)/kuroko
rm -r $(DESTDIR)

26
tools/deb-ver.krk Normal file
View File

@ -0,0 +1,26 @@
'''
Generates a version string suitable for a Debian package
'''
import kuroko
import os
let version = kuroko.hexversion
# Extract version number components
let major = (version >> 24) & 0xFF
let minor = (version >> 16) & 0xFF
let patch = (version >> 8) & 0xFF
let level = (version >> 4) & 0xF
let serial = version & 0xF
# Map prerelease levels to strings
let levels = {0xa: 'a', 0xb: 'b', 0xc: 'rc'}
level = f'~{levels.get(level)}{serial}' if level in levels else ''
# Figure out what the package revision number should be;
# set this if you want something other than 1.
let revision = os.environ.get('KRK_PACKAGE_REVISION','1')
# Print a final version number
print(f'{major}.{minor}.{patch}{level}-{revision}')