Enhancement: Fixes #489, build - implement proper versioning

This commit is contained in:
Rory Fewell
2025-06-27 04:20:01 +01:00
parent 2ac5c45bff
commit ff247e3f6c
17 changed files with 203 additions and 148 deletions

View File

@@ -19,13 +19,6 @@ include(../../packaging/cmake-inc/packaging/CMakeLists.txt)
# Set up variables
#
set(OUT_PATH_RELEASE ${CMAKE_BINARY_DIR}/release)
set(GENTAG_TOOL ${REPO_ROOT}/tools/bldutils/gentag/gentag.sh)
execute_process(
COMMAND bash ${GENTAG_TOOL}
WORKING_DIRECTORY ${PROJECT_ROOT}
OUTPUT_VARIABLE REL_BUILD_TAG
)
if (${WINTC_SKU} MATCHES "^xpclient-(.+)")
set(REL_SKU_NAME "Microsoft Windows XP")

View File

@@ -1,6 +1,18 @@
[Version]
PrettyName=@REL_PRETTY_NAME@
SkuPrettyName=@REL_PRETTY_NAME@
SkuName=@REL_SKU_NAME@
SkuEdition=@REL_SKU_EDITION@
SkuTagline=@REL_SKU_TAGLINE@
BuildTag=@REL_BUILD_TAG@
VersionMajor=@WINTC_VER_MAJOR@
VersionMinor=@WINTC_VER_MINOR@
VersionBuild=@WINTC_VER_BUILD@
VersionDatetime=@WINTC_VER_DATETIME@
BuildBranch=@WINTC_VER_BRANCH@
BuildDatestamp=@WINTC_VER_DATESTAMP@
BuildHash=@WINTC_VER_HASH@
BuildUser=@WINTC_VER_USER@
BuildTag=@WINTC_VER_TAG@
VersionString=@WINTC_VER_PROJECT@

View File

@@ -236,7 +236,18 @@ fi
build_subdir="fre"
build_type="free"
cur_arch=`uname -m | xargs echo -n`
tag=`${SH_GENTAG}`
. $SH_GENTAG >/dev/null 2>&1
export WINTC_VER_MAJOR
export WINTC_VER_MINOR
export WINTC_VER_BUILD
export WINTC_VER_DATETIME
export WINTC_VER_BRANCH
export WINTC_VER_DATESTAMP
export WINTC_VER_HASH
export WINTC_VER_USER
export WINTC_VER_TAG
if [[ $OPT_CHECKED -eq 1 ]]
then
@@ -244,7 +255,7 @@ then
build_type="checked"
fi
echo "buildall: Doing full system build for ${tag} (${cur_arch}, ${DIST_ID}-${DIST_ID_EXT}) (${build_type})"
echo "buildall: Doing full system build for ${WINTC_VER_TAG} (${cur_arch}, ${DIST_ID}-${DIST_ID_EXT}) (${build_type})"
# Handle output dir for packaging
#
@@ -252,7 +263,7 @@ if [[ $OPT_SKIP_PACKAGING -eq 0 ]]
then
if [[ "${OPT_OUTPUT_DIR}" == "" ]]
then
OPT_OUTPUT_DIR="${CURDIR}/xptc/${tag}/${DIST_ID}/${DIST_ID_EXT}/${cur_arch}/${build_subdir}"
OPT_OUTPUT_DIR="${CURDIR}/xptc/${WINTC_VER_TAG}/${DIST_ID}/${DIST_ID_EXT}/${cur_arch}/${build_subdir}"
mkdir -p "${OPT_OUTPUT_DIR}"
fi
@@ -283,4 +294,4 @@ do
build_component "${rel_target_dir}"
done {targets_fd}<"${OPT_BUILDLIST}"
echo "buildall: Build complete for ${tag} (${build_type})"
echo "buildall: Build complete for ${WINTC_VER_TAG} (${build_type})"

View File

@@ -86,13 +86,14 @@ if (NOT ${WINTC_SKU} IN_LIST WINTC_VALID_SKUS)
)
endif()
# Define func for importing constants from a file
# Define func for importing constants from text like
#
function(wintc_source_vars SOURCE_PATH)
file(STRINGS ${SOURCE_PATH} sourceLines)
foreach(line ${sourceLines})
# VAR1=some value
# VAR2=36
# ...
#
function(wintc_source_vars SOURCE_LINES)
foreach(line ${SOURCE_LINES})
if (${line} STREQUAL "")
continue()
endif()
@@ -103,3 +104,29 @@ function(wintc_source_vars SOURCE_PATH)
set(${varIdentifier} ${varValue} PARENT_SCOPE)
endforeach()
endfunction()
# Import version information
#
if (DEFINED ENV{WINTC_VER_TAG})
set(WINTC_VER_MAJOR $ENV{WINTC_VER_MAJOR})
set(WINTC_VER_MINOR $ENV{WINTC_VER_MINOR})
set(WINTC_VER_BUILD $ENV{WINTC_VER_BUILD})
set(WINTC_VER_DATETIME $ENV{WINTC_VER_DATETIME})
set(WINTC_VER_BRANCH $ENV{WINTC_VER_BRANCH})
set(WINTC_VER_DATESTAMP $ENV{WINTC_VER_DATESTAMP})
set(WINTC_VER_HASH $ENV{WINTC_VER_HASH})
set(WINTC_VER_USER $ENV{WINTC_VER_USER})
set(WINTC_VER_TAG $ENV{WINTC_VER_TAG})
else()
execute_process(
COMMAND bash ${REPO_ROOT}/tools/bldutils/gentag/gentag.sh
WORKING_DIRECTORY ${REPO_ROOT}
OUTPUT_VARIABLE version_lines
)
string(REPLACE "\n" ";" version_lines ${version_lines})
wintc_source_vars("${version_lines}")
endif()
set(WINTC_VER_PROJECT "${WINTC_VER_MAJOR}.${WINTC_VER_MINOR}.${WINTC_VER_BUILD}.${WINTC_VER_DATETIME}")

View File

@@ -1,6 +1,6 @@
# Maintainer: Rory Fewell <roryf@oddmatics.uk>
pkgname="@PROJECT_NAME@"
pkgver="@PROJECT_VERSION@"
pkgver="@WINTC_VER_PROJECT@"
pkgrel=1
pkgdesc="@PROJECT_DESCRIPTION@"
arch="@ALPINE_ARCHITECTURE@"

View File

@@ -1,5 +1,5 @@
pkgname="@ALT_PROJECT_NAME@"
pkgver="@PROJECT_VERSION@"
pkgver="@WINTC_VER_PROJECT@"
pkgrel=1
pkgdesc="@PROJECT_DESCRIPTION@"
arch=("@ARCH_ARCHITECTURE@")

View File

@@ -1,5 +1,5 @@
name: @ALT_PROJECT_NAME@
version: "@PROJECT_VERSION@"
version: "@WINTC_VER_PROJECT@"
origin: wintc/@ALT_PROJECT_NAME@
comment: @PROJECT_DESCRIPTION@
arch: @CMAKE_SYSTEM_PROCESSOR@

View File

@@ -1,5 +1,5 @@
Package: @PROJECT_NAME@
Version: @PROJECT_VERSION@
Version: @WINTC_VER_PROJECT@
Maintainer: @PROJECT_MAINTAINER@
Architecture: @DEB_ARCHITECTURE@
Section: @DEB_SECTION@

View File

@@ -1,5 +1,5 @@
Name: @ALT_PROJECT_NAME@
Version: @PROJECT_VERSION@
Version: @WINTC_VER_PROJECT@
Release: 1
Summary: @PROJECT_DESCRIPTION@
BuildArch: @RPM_ARCHITECTURE@

View File

@@ -5,4 +5,4 @@ export XBPS_DEPENDENCIES="@XBPS_DEPENDENCIES@"
export XBPS_DESC="@PROJECT_DESCRIPTION@"
export XBPS_LICENSE="@XBPS_LICENCE@"
export XBPS_MAINTAINER="@PROJECT_MAINTAINER@"
export XBPS_PKGVER="@ALT_PROJECT_NAME@-@PROJECT_VERSION@_1"
export XBPS_PKGVER="@ALT_PROJECT_NAME@-@WINTC_VER_PROJECT@_1"

View File

@@ -5,6 +5,30 @@
#include <glib.h>
//
// PUBLIC ENUMS
//
enum
{
WINTC_VER_PRETTY_NAME,
WINTC_VER_NAME,
WINTC_VER_SKU,
WINTC_VER_SKU_TAGLINE,
WINTC_VER_MAJOR,
WINTC_VER_MINOR,
WINTC_VER_BUILD,
WINTC_VER_DATETIME,
WINTC_VER_BRANCH,
WINTC_VER_DATESTAMP,
WINTC_VER_HASH,
WINTC_VER_USER,
WINTC_VER_TAG,
WINTC_VER_PROJECT
};
//
// PUBLIC FUNCTIONS
//
@@ -17,38 +41,13 @@
gboolean wintc_build_is_debug(void);
/**
* Retrieves the 'pretty name' of the installed version of WinTC.
* Queries information related to the installed version of WinTC.
*
* @return The 'pretty name' of the installed version of WinTC.
* @param query_id The ID of the version property to query.
* @return The string value corresponding to the query ID.
*/
const gchar* wintc_build_get_pretty_name(void);
/**
* Retrieves the edition of the installed version of WinTC.
*
* @return The edition of the installed version of WinTC.
*/
const gchar* wintc_build_get_sku_edition(void);
/**
* Retrieves the name of the installed version of WinTC.
*
* @return The name of the installed version of WinTC.
*/
const gchar* wintc_build_get_sku_name(void);
/**
* Retrieves the build tag identifying the installed version of WinTC.
*
* @return The WinTC build tag.
*/
const gchar* wintc_build_get_tag(void);
/**
* Retrieves the tagline of the installed version of WinTC.
*
* @return The tagline of the installed version of WinTC.
*/
const gchar* wintc_build_get_tagline(void);
const gchar* wintc_build_query(
guint query_id
);
#endif

View File

@@ -8,20 +8,53 @@
//
static const gchar* S_KEYFILE_GROUP = "Version";
//
// FORWARD DECLARATIONS
//
gboolean ensure_keyfile(void);
gchar* get_keyfile_entry(
const gchar* key
);
//
// STATIC DATA
//
static gboolean s_keyfile_loaded;
static GKeyFile* s_keyfile_version;
//
// FORWARD DECLARATIONS
//
gboolean ensure_keyfile(void);
gchar* get_keyfile_entry(
const gchar* key,
const gchar* default_str
);
static const gchar* S_KEYS[] = {
"SkuPrettyName",
"SkuName",
"SkuEdition",
"SkuTagline",
"VersionMajor",
"VersionMinor",
"VersionBuild",
"VersionDatetime",
"BuildBranch",
"BuildDatestamp",
"BuildHash",
"BuildUser",
"BuildTag",
"VersionString"
};
static const gchar* S_DEFAULT_VALUES[] = {
"Unknown System",
"Unknown System",
"",
"",
"0",
"0",
"0",
"0",
"unknown",
"000000-0000",
"unknown",
"unknown",
"no tag",
"0.0.0.0"
};
static gchar* S_VALUES[G_N_ELEMENTS(S_KEYS)] = { 0 };
//
// PUBLIC FUNCTIONS
@@ -35,64 +68,41 @@ gboolean wintc_build_is_debug(void)
#endif
}
const gchar* wintc_build_get_pretty_name(void)
const gchar* wintc_build_query(
guint query_id
)
{
static gchar* pretty_name = NULL;
if (!pretty_name)
if (query_id >= G_N_ELEMENTS(S_KEYS))
{
pretty_name = get_keyfile_entry("PrettyName", "Unknown System");
g_critical("comgtk: version query for %d is invalid", query_id);
return NULL;
}
return pretty_name;
}
const gchar* wintc_build_get_sku_edition(void)
{
static gchar* skued = NULL;
if (!skued)
// Does a value exist already?
//
if (S_VALUES[query_id])
{
skued = get_keyfile_entry("SkuEdition", "");
return S_VALUES[query_id];
}
return skued;
}
const gchar* wintc_build_get_sku_name(void)
{
static gchar* skuname = NULL;
if (!skuname)
// Attempt to load from key file
//
if (ensure_keyfile())
{
skuname = get_keyfile_entry("SkuName", "Unknown System");
S_VALUES[query_id] =
g_key_file_get_string(
s_keyfile_version,
S_KEYFILE_GROUP,
S_KEYS[query_id],
NULL
);
return S_VALUES[query_id];
}
return skuname;
}
const gchar* wintc_build_get_tag(void)
{
static gchar* build_tag = NULL;
if (!build_tag)
{
build_tag = get_keyfile_entry("BuildTag", "no tag");
}
return build_tag;
}
const gchar* wintc_build_get_tagline(void)
{
static gchar* skuver = NULL;
if (!skuver)
{
skuver = get_keyfile_entry("SkuTagline", "");
}
return skuver;
// Otherwise return default value
//
return S_DEFAULT_VALUES[query_id];
}
//
@@ -124,21 +134,3 @@ gboolean ensure_keyfile(void)
return s_keyfile_loaded;
}
gchar* get_keyfile_entry(
const gchar* key,
const gchar* default_str
)
{
if (ensure_keyfile())
{
return g_key_file_get_string(
s_keyfile_version,
S_KEYFILE_GROUP,
key,
NULL
);
}
return g_strdup_printf("%s", default_str);
}

View File

@@ -118,7 +118,7 @@ void wintc_sh_about(
wintc_widget_printf(
label_kernel,
kernel_info.release,
wintc_build_get_tag(),
wintc_build_query(WINTC_VER_TAG),
wintc_build_is_debug() ? " (Debug)" : ""
);
wintc_widget_printf(

View File

@@ -154,15 +154,15 @@ static void wintc_cpl_sysdm_page_general_constructed(
gtk_label_set_text(
GTK_LABEL(label_skuname),
wintc_build_get_sku_name()
wintc_build_query(WINTC_VER_NAME)
);
gtk_label_set_text(
GTK_LABEL(label_skued),
wintc_build_get_sku_edition()
wintc_build_query(WINTC_VER_SKU)
);
gtk_label_set_text(
GTK_LABEL(label_skuver),
wintc_build_get_tagline()
wintc_build_query(WINTC_VER_SKU_TAGLINE)
);
gtk_label_set_text(
GTK_LABEL(label_reguser),

View File

@@ -274,7 +274,7 @@ static gboolean wintc_desktop_window_draw(
s_tag =
g_strdup_printf(
"For testing purposes only. Build %s",
wintc_build_get_tag()
wintc_build_query(WINTC_VER_TAG)
);
}

View File

@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.12)
# Import colour scheme and theme metadata
#
wintc_source_vars(${PROJECT_ROOT}/scheme)
wintc_source_vars(${PROJECT_ROOT}/theme)
file(STRINGS ${PROJECT_ROOT}/scheme scheme_lines)
file(STRINGS ${PROJECT_ROOT}/theme theme_lines)
wintc_source_vars("${scheme_lines}")
wintc_source_vars("${theme_lines}")
# Import dir constants
#
@@ -67,4 +70,4 @@ install(DIRECTORY ${PROJECT_ROOT}/xfwm4 DESTINATION ${THEME_PROJECT_INSTALL_PATH
install(DIRECTORY ${PROJECT_ROOT}/Resources DESTINATION ${THEME_PROJECT_INSTALL_PATH})
install(DIRECTORY ${CMAKE_BINARY_DIR}/composed DESTINATION ${THEME_PROJECT_INSTALL_PATH}/Resources)
wintc_configure_and_install_packaging()
wintc_configure_and_install_packaging()

View File

@@ -1,11 +1,17 @@
#/bin/bash
#/usr/bin/env bash
# Set up some defaults for the tag
#
cur_branch='unknown'
cur_datestamp=`date +%y%m%d-%H%M | xargs echo -n`
cur_hash='unknown'
cur_user=`whoami | xargs echo -n`
WINTC_VER_MAJOR=1
WINTC_VER_MINOR=0
WINTC_VER_BUILD=0
WINTC_VER_DATETIME=`date +%y%m%d%H%M | xargs echo -n`
WINTC_VER_BRANCH='unknown'
WINTC_VER_DATESTAMP=`date +%y%m%d-%H%M | xargs echo -n`
WINTC_VER_HASH='unknown'
WINTC_VER_USER=`whoami | xargs echo -n`
# Check we're in a git repo, if the user has downloaded as ZIP from jithub then
# we won't have any metadata
@@ -14,12 +20,24 @@ git status >/dev/null 2>&1
if [[ $? -eq 0 ]]
then
cur_branch=`git branch --show-current | xargs echo -n`
cur_hash=`git rev-parse --short HEAD | xargs echo -n`
WINTC_VER_BUILD=`git log master --oneline | wc -l | xargs echo -n`
WINTC_VER_BRANCH=`git branch --show-current | xargs echo -n`
WINTC_VER_HASH=`git rev-parse --short HEAD | xargs echo -n`
fi
# Construct and output the tag now
# Construct the tag
#
tag="${cur_hash}.${cur_branch}(${cur_user}).${cur_datestamp}"
WINTC_VER_TAG="${WINTC_VER_HASH}.${WINTC_VER_BRANCH}(${WINTC_VER_USER}).${WINTC_VER_DATESTAMP}"
echo -n "${tag}"
# Output (for CMake, shell scripts can source vars)
echo "WINTC_VER_MAJOR=${WINTC_VER_MAJOR}"
echo "WINTC_VER_MINOR=${WINTC_VER_MINOR}"
echo "WINTC_VER_BUILD=${WINTC_VER_BUILD}"
echo "WINTC_VER_DATETIME=${WINTC_VER_DATETIME}"
echo "WINTC_VER_BRANCH=${WINTC_VER_BRANCH}"
echo "WINTC_VER_DATESTAMP=${WINTC_VER_DATESTAMP}"
echo "WINTC_VER_HASH=${WINTC_VER_HASH}"
echo "WINTC_VER_USER=${WINTC_VER_USER}"
echo "WINTC_VER_TAG=${WINTC_VER_TAG}"