From f48571c358cb517b3898c49ae3f0e4e681b51785 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Fri, 2 May 2025 10:14:43 +0900 Subject: [PATCH 01/10] Introduce dynamic versioning with gen-build-version.sh Generates version strings from the latest Git commit hash when inside a Git work tree, or from .tarball-version when building from a release archive. With the --dist option, omits the commit hash for distribution builds. Automatically generates .tarball-version during 'make dist' and includes it in the tarball. --- .gitignore | 1 + Makefile.am | 10 ++++++- autogen.sh | 17 +++++++++++ build-aux/gen-build-version.sh | 52 ++++++++++++++++++++++++++++++++++ configure.ac | 3 +- src/Makefile.am | 12 +++++++- src/lharc.c | 6 ++-- src/version.h.in | 1 + 8 files changed, 97 insertions(+), 5 deletions(-) create mode 100755 autogen.sh create mode 100755 build-aux/gen-build-version.sh create mode 100644 src/version.h.in diff --git a/.gitignore b/.gitignore index 0cd0943..2d1b934 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ olddoc/Makefile olddoc/Makefile.in .deps/ src/lha +src/version.h src/Makefile src/Makefile.in stamp-h1 diff --git a/Makefile.am b/Makefile.am index e4ea6ef..fac87e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,13 @@ ## Process this file with automake to produce Makefile.in AUTOMAKE_OPTIONS = foreign -EXTRA_DIST = README.md README.jp.md header.doc.md header.doc.jp Hacking_of_LHa +EXTRA_DIST = README.md README.jp.md header.doc.md header.doc.jp Hacking_of_LHa autogen.sh build-aux/gen-build-version.sh SUBDIRS= man olddoc src tests + +.tarball-version: + sh $(top_srcdir)/build-aux/gen-build-version.sh --dist > .tarball-version + +pre-configure: .tarball-version + +dist-hook: .tarball-version + mv .tarball-version $(distdir) diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..99fd77a --- /dev/null +++ b/autogen.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Exit on error +set -e + +# Check for dependencies +if ! command -v git &>/dev/null; then + echo "git is required but not found. Exiting." + exit 1 +fi + +# Run autoreconf to generate configure script +autoreconf --force --install --symlink + +# Run configure +mkdir build 2>/dev/null || true +cd build && ../configure "$@" diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh new file mode 100755 index 0000000..a2435ec --- /dev/null +++ b/build-aux/gen-build-version.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Print version string derived from Git or .tarball-version +# If called with --dist, generate .tarball-version with simplified version + +set -e + +top_srcdir=$(dirname $0)/.. + +VERSION_PREFIX="1.14i-ac" + +# Use Git info to generate full version +if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + IS_INSIDE_WORK_TREE=true + DATE=$(git log -1 --date=format:"%Y%m%d" --pretty=format:"%cd") + HASH=$(git rev-parse --short=7 HEAD) + + DIRTY="" + if ! git diff --quiet || ! git diff --cached --quiet; then + DIRTY="-dirty" + echo "Warning: repository is dirty (has uncommitted changes)" >&2 + fi +fi + +# --dist: output version for .tarball-version and exit +if test "$1" = "--dist"; then + if test x"$DIRTY" != x; then + exit 1 + fi + + if test "$IS_INSIDE_WORK_TREE" = true; then + echo "${VERSION_PREFIX}${DATE}" + exit 0 + else + echo "Error: not inside a Git repository" >&2 + exit 1 + fi +fi + +# Use .tarball-version if present +if test -f $top_srcdir/.tarball-version; then + cat $top_srcdir/.tarball-version + exit 0 +fi + +if test "$IS_INSIDE_WORK_TREE" = true; then + echo "${VERSION_PREFIX}${DATE}-${HASH}${DIRTY}" + exit 0 +fi + +# Fallback if nothing is available +echo "${VERSION_PREFIX}unknown" +exit 1 diff --git a/configure.ac b/configure.ac index 834fa3e..f78fa32 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,6 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([LHa for UNIX], 1.14i-ac20220213, jca02266@gmail.com, lha) +m4_define([VERSION_STRING], m4_esyscmd_s([build-aux/gen-build-version.sh --dist])) +AC_INIT([LHa for UNIX], VERSION_STRING, [jca02266@gmail.com], [lha]) AC_DEFINE_UNQUOTED(LHA_CONFIGURE_OPTIONS, "$ac_configure_args", [specified options for the configure script.]) AC_CANONICAL_HOST diff --git a/src/Makefile.am b/src/Makefile.am index 22cb686..b46e013 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,7 +5,17 @@ lha_SOURCES = append.c bitio.c crcio.c dhuf.c extract.c header.c huf.c \ lhext.c lhlist.c maketbl.c maketree.c patmatch.c shuf.c slide.c \ util.c getopt_long.c getopt_long.h \ pm2.c pm2hist.c pm2tree.c \ - support_utf8.c + support_utf8.c version.h.in lha_LDADD = @LIBOBJS@ EXTRA_DIST = lhdir.h fnmatch.h AM_CPPFLAGS=$(DEF_KCODE) $(SUPPORT_LZHUFF_METHOD) + +BUILT_SOURCES = version.h +CLEANFILES = version.h + +version.h: FORCE + @echo "Generating version.h..." + @BUILD_VERSION=`sh $(top_srcdir)/build-aux/gen-build-version.sh`; \ + sed "s|@BUILD_VERSION@|$$BUILD_VERSION|" $(srcdir)/version.h.in > $@ + +FORCE: diff --git a/src/lharc.c b/src/lharc.c index d2ec135..74116e2 100644 --- a/src/lharc.c +++ b/src/lharc.c @@ -726,14 +726,16 @@ main(argc, argv) /* ------------------------------------------------------------------------ */ +#include "version.h" + static void print_version() { /* macro PACKAGE_NAME, PACKAGE_VERSION and PLATFORM are defined in config.h by configure script */ fprintf(stdout, "%s version %s (%s)\n", - PACKAGE_NAME, PACKAGE_VERSION, PLATFORM); - + PACKAGE_NAME, BUILD_VERSION, PLATFORM); + if (strlen(LHA_CONFIGURE_OPTIONS) != 0) fprintf(stdout, " configure options: %s\n", LHA_CONFIGURE_OPTIONS); } diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 0000000..ef34241 --- /dev/null +++ b/src/version.h.in @@ -0,0 +1 @@ +#define BUILD_VERSION "@BUILD_VERSION@" From f87f4fdde2c0f3234ad88ada183ddd3cbc2d756e Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Mon, 5 May 2025 11:06:44 +0900 Subject: [PATCH 02/10] Use unified git log call to extract DATE and HASH Simplifies version generation by replacing separate git commands with a single git log call. Also adds OUTPUT_FOR_DIST flag. --- build-aux/gen-build-version.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh index a2435ec..8afc97b 100755 --- a/build-aux/gen-build-version.sh +++ b/build-aux/gen-build-version.sh @@ -8,11 +8,16 @@ top_srcdir=$(dirname $0)/.. VERSION_PREFIX="1.14i-ac" +# command line switch +if test "$1" = "--dist"; then + OUTPUT_FOR_DIST=true +fi + # Use Git info to generate full version if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then IS_INSIDE_WORK_TREE=true - DATE=$(git log -1 --date=format:"%Y%m%d" --pretty=format:"%cd") - HASH=$(git rev-parse --short=7 HEAD) + set -- $(git log -1 --date=format:"%Y%m%d" --pretty=format:"%cd %h") + DATE=$1 HASH=$2 DIRTY="" if ! git diff --quiet || ! git diff --cached --quiet; then @@ -22,7 +27,7 @@ if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then fi # --dist: output version for .tarball-version and exit -if test "$1" = "--dist"; then +if test "$OUTPUT_FOR_DIST" = true; then if test x"$DIRTY" != x; then exit 1 fi From ac9caa321fa29c7d738da64d3463e8d0ce5908d0 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Mon, 5 May 2025 11:32:04 +0900 Subject: [PATCH 03/10] Regenerate configure and refine .tarball-version handling for reproducible builds - dist-hook now forcibly regenerates .tarball-version using gen-build-version.sh --dist, ensuring consistent PACKAGE_VERSION for distribution builds. - Invokes autoconf with --force to always update configure script during dist. - Moves .tarball-version generation logic directly into dist-hook for clarity. - gen-build-version.sh prioritizes existing non-empty .tarball-version early for reproducibility. - gen-build-version.sh now checks for non-empty .tarball-version early using `-s`, to avoid mistakenly using an empty file that may briefly exist during `make dist`. --- Makefile.am | 14 +++++++------- build-aux/gen-build-version.sh | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index fac87e4..52812d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,10 +4,10 @@ AUTOMAKE_OPTIONS = foreign EXTRA_DIST = README.md README.jp.md header.doc.md header.doc.jp Hacking_of_LHa autogen.sh build-aux/gen-build-version.sh SUBDIRS= man olddoc src tests -.tarball-version: - sh $(top_srcdir)/build-aux/gen-build-version.sh --dist > .tarball-version - -pre-configure: .tarball-version - -dist-hook: .tarball-version - mv .tarball-version $(distdir) +## Re-run autoconf to regenerate configure and update PACKAGE_VERSION via .tarball-version +dist-hook: + rm -f $(top_srcdir)/.tarball-version 2>/dev/null + cd $(top_srcdir) && \ + build-aux/gen-build-version.sh --dist > .tarball-version && \ + $(AUTOCONF) --force + mv $(top_srcdir)/.tarball-version $(distdir) diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh index 8afc97b..5c6433f 100755 --- a/build-aux/gen-build-version.sh +++ b/build-aux/gen-build-version.sh @@ -13,6 +13,12 @@ if test "$1" = "--dist"; then OUTPUT_FOR_DIST=true fi +# Use .tarball-version if present +if test -s $top_srcdir/.tarball-version; then + cat $top_srcdir/.tarball-version + exit 0 +fi + # Use Git info to generate full version if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then IS_INSIDE_WORK_TREE=true @@ -41,12 +47,6 @@ if test "$OUTPUT_FOR_DIST" = true; then fi fi -# Use .tarball-version if present -if test -f $top_srcdir/.tarball-version; then - cat $top_srcdir/.tarball-version - exit 0 -fi - if test "$IS_INSIDE_WORK_TREE" = true; then echo "${VERSION_PREFIX}${DATE}-${HASH}${DIRTY}" exit 0 From 642501bc1d06a84fac7e01019e9cbed2e8309d78 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Tue, 6 May 2025 11:17:08 +0900 Subject: [PATCH 04/10] gen-build-version.sh: support -o option and simplify output logic This improves clarity, reproducibility, and avoids issues where an empty `.tarball-version` file might be created and read within the same `make dist` process. - Add `-o ` option to write the generated version string directly to the specified file, replacing the use of shell redirection (`> .tarball-version`) in Makefile. - Suppress stdout when `-o` is used to avoid duplicate or premature outputs. - Restore fallback to `.tarball-version` only when `-o` is not specified and no Git info is available. - Extract version output logic into a unified `output_version` function. - Move Git working tree checks into `check_git_clean_for_dist` helper for --dist validation. - Update `Makefile.am` to use `-o .tarball-version`, preventing race conditions where an empty `.tarball-version` file might be created and read within the same `make dist` process. --- Makefile.am | 3 +- build-aux/gen-build-version.sh | 80 ++++++++++++++++++++-------------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Makefile.am b/Makefile.am index 52812d9..860f228 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,8 +6,7 @@ SUBDIRS= man olddoc src tests ## Re-run autoconf to regenerate configure and update PACKAGE_VERSION via .tarball-version dist-hook: - rm -f $(top_srcdir)/.tarball-version 2>/dev/null cd $(top_srcdir) && \ - build-aux/gen-build-version.sh --dist > .tarball-version && \ + build-aux/gen-build-version.sh --dist -o .tarball-version && \ $(AUTOCONF) --force mv $(top_srcdir)/.tarball-version $(distdir) diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh index 5c6433f..9a95de8 100755 --- a/build-aux/gen-build-version.sh +++ b/build-aux/gen-build-version.sh @@ -7,17 +7,55 @@ set -e top_srcdir=$(dirname $0)/.. VERSION_PREFIX="1.14i-ac" +OUTPUT_FOR_DIST=false +OUTPUT_FILE= -# command line switch -if test "$1" = "--dist"; then - OUTPUT_FOR_DIST=true -fi +while [ $# -gt 0 ]; do + case "$1" in + --dist) + OUTPUT_FOR_DIST=true + shift + ;; + -o) + OUTPUT_FILE="$2" + shift 2 + ;; + *) + echo "Usage: $0 [--dist] [-o ]" >&2 + exit 1 + ;; + esac +done -# Use .tarball-version if present -if test -s $top_srcdir/.tarball-version; then - cat $top_srcdir/.tarball-version - exit 0 -fi +# Ensure we are inside a clean Git work tree for --dist +check_git_clean_for_dist() { + if test x"$DIRTY" != x; then + echo "Error: working tree is dirty; commit or stash changes before running with --dist" >&2 + exit 1 + fi + + if test "$IS_INSIDE_WORK_TREE" != true; then + echo "Error: not inside a Git repository" >&2 + exit 1 + fi +} + +output_version() { + if test x"$OUTPUT_FILE" = x && test -f $top_srcdir/.tarball-version; then + version=$(cat $top_srcdir/.tarball-version) + elif test "$OUTPUT_FOR_DIST" = true; then + check_git_clean_for_dist + version="${VERSION_PREFIX}${DATE}" + else + version="${VERSION_PREFIX}${DATE}-${HASH}${DIRTY}" + fi + + if test x"$OUTPUT_FILE" != x; then + echo $version > $OUTPUT_FILE + else + echo $version + fi +} # Use Git info to generate full version if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then @@ -32,26 +70,4 @@ if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then fi fi -# --dist: output version for .tarball-version and exit -if test "$OUTPUT_FOR_DIST" = true; then - if test x"$DIRTY" != x; then - exit 1 - fi - - if test "$IS_INSIDE_WORK_TREE" = true; then - echo "${VERSION_PREFIX}${DATE}" - exit 0 - else - echo "Error: not inside a Git repository" >&2 - exit 1 - fi -fi - -if test "$IS_INSIDE_WORK_TREE" = true; then - echo "${VERSION_PREFIX}${DATE}-${HASH}${DIRTY}" - exit 0 -fi - -# Fallback if nothing is available -echo "${VERSION_PREFIX}unknown" -exit 1 +output_version From 212f4c8ac537305d5365a1c6ceed84070d953316 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Tue, 6 May 2025 11:49:56 +0900 Subject: [PATCH 05/10] clarify comment to reflect current behavior --- build-aux/gen-build-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh index 9a95de8..f8e7ce5 100755 --- a/build-aux/gen-build-version.sh +++ b/build-aux/gen-build-version.sh @@ -1,6 +1,6 @@ #!/bin/sh # Print version string derived from Git or .tarball-version -# If called with --dist, generate .tarball-version with simplified version +# If called with --dist, output a simplified version string (written to file if -o is used) set -e From 0e7541ddf9b3236699c274aec320b11a3623a89e Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Tue, 6 May 2025 12:06:11 +0900 Subject: [PATCH 06/10] Prevent unnecessary overwriting of version.h when no changes are detected --- src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index b46e013..5004a93 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,7 @@ CLEANFILES = version.h version.h: FORCE @echo "Generating version.h..." @BUILD_VERSION=`sh $(top_srcdir)/build-aux/gen-build-version.sh`; \ - sed "s|@BUILD_VERSION@|$$BUILD_VERSION|" $(srcdir)/version.h.in > $@ + sed "s|@BUILD_VERSION@|$$BUILD_VERSION|" $(srcdir)/version.h.in > $@.tmp + if cmp -s $@.tmp $@; then rm -f $@.tmp; else mv $@.tmp $@; fi FORCE: From cd4c50dc59ca9a1f48504a5ef92238c35d8153a3 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Tue, 6 May 2025 12:12:05 +0900 Subject: [PATCH 07/10] Ensure build can proceed with uncommitted changes by adding --verify option to gen-build-version.sh - Modified `configure.ac` to allow the build to proceed without breaking even if there are uncommitted changes. - Added the `--verify` option to check if the Git repository is clean before generating the version string, only when the option is specified. - Updated `dist-hook` in `Makefile.am` to include the `--verify` option. --- Makefile.am | 2 +- build-aux/gen-build-version.sh | 9 ++++++++- src/Makefile.am | 2 +- src/version.h.in | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 860f228..21e8ca1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,6 @@ SUBDIRS= man olddoc src tests ## Re-run autoconf to regenerate configure and update PACKAGE_VERSION via .tarball-version dist-hook: cd $(top_srcdir) && \ - build-aux/gen-build-version.sh --dist -o .tarball-version && \ + build-aux/gen-build-version.sh --dist --verify -o .tarball-version && \ $(AUTOCONF) --force mv $(top_srcdir)/.tarball-version $(distdir) diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh index f8e7ce5..3ae5c3c 100755 --- a/build-aux/gen-build-version.sh +++ b/build-aux/gen-build-version.sh @@ -16,6 +16,10 @@ while [ $# -gt 0 ]; do OUTPUT_FOR_DIST=true shift ;; + --verify) + VERIFY=true + shift + ;; -o) OUTPUT_FILE="$2" shift 2 @@ -44,7 +48,6 @@ output_version() { if test x"$OUTPUT_FILE" = x && test -f $top_srcdir/.tarball-version; then version=$(cat $top_srcdir/.tarball-version) elif test "$OUTPUT_FOR_DIST" = true; then - check_git_clean_for_dist version="${VERSION_PREFIX}${DATE}" else version="${VERSION_PREFIX}${DATE}-${HASH}${DIRTY}" @@ -70,4 +73,8 @@ if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then fi fi +if test "$VERIFY" = true; then + check_git_clean_for_dist +fi + output_version diff --git a/src/Makefile.am b/src/Makefile.am index 5004a93..38d6b7d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,6 +17,6 @@ version.h: FORCE @echo "Generating version.h..." @BUILD_VERSION=`sh $(top_srcdir)/build-aux/gen-build-version.sh`; \ sed "s|@BUILD_VERSION@|$$BUILD_VERSION|" $(srcdir)/version.h.in > $@.tmp - if cmp -s $@.tmp $@; then rm -f $@.tmp; else mv $@.tmp $@; fi + @if cmp -s $@.tmp $@; then rm -f $@.tmp; else mv $@.tmp $@; fi FORCE: diff --git a/src/version.h.in b/src/version.h.in index ef34241..aef7168 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -1 +1,2 @@ +/**/ #define BUILD_VERSION "@BUILD_VERSION@" From 97da08d76ac2a643a2ff526f6ee992d3ab82e4a9 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Tue, 6 May 2025 13:04:38 +0900 Subject: [PATCH 08/10] Rename --verify to --check-clean for clarity --- Makefile.am | 2 +- build-aux/gen-build-version.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 21e8ca1..ef4e57e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,6 @@ SUBDIRS= man olddoc src tests ## Re-run autoconf to regenerate configure and update PACKAGE_VERSION via .tarball-version dist-hook: cd $(top_srcdir) && \ - build-aux/gen-build-version.sh --dist --verify -o .tarball-version && \ + build-aux/gen-build-version.sh --dist --check-clean -o .tarball-version && \ $(AUTOCONF) --force mv $(top_srcdir)/.tarball-version $(distdir) diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh index 3ae5c3c..8a8b5aa 100755 --- a/build-aux/gen-build-version.sh +++ b/build-aux/gen-build-version.sh @@ -16,8 +16,8 @@ while [ $# -gt 0 ]; do OUTPUT_FOR_DIST=true shift ;; - --verify) - VERIFY=true + --check-clean) + CHECK_CLEAN=true shift ;; -o) @@ -73,7 +73,7 @@ if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then fi fi -if test "$VERIFY" = true; then +if test "$CHECK_CLEAN" = true; then check_git_clean_for_dist fi From de3fb2579d4cc7082d942860f85fc017ec592aaa Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Tue, 6 May 2025 13:08:32 +0900 Subject: [PATCH 09/10] Rename --dist to --package to better reflect intent and improve readability --- Makefile.am | 2 +- build-aux/gen-build-version.sh | 20 ++++++++++---------- configure.ac | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.am b/Makefile.am index ef4e57e..4d45d8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,6 @@ SUBDIRS= man olddoc src tests ## Re-run autoconf to regenerate configure and update PACKAGE_VERSION via .tarball-version dist-hook: cd $(top_srcdir) && \ - build-aux/gen-build-version.sh --dist --check-clean -o .tarball-version && \ + build-aux/gen-build-version.sh --package --check-clean -o .tarball-version && \ $(AUTOCONF) --force mv $(top_srcdir)/.tarball-version $(distdir) diff --git a/build-aux/gen-build-version.sh b/build-aux/gen-build-version.sh index 8a8b5aa..970443f 100755 --- a/build-aux/gen-build-version.sh +++ b/build-aux/gen-build-version.sh @@ -1,19 +1,19 @@ #!/bin/sh # Print version string derived from Git or .tarball-version -# If called with --dist, output a simplified version string (written to file if -o is used) +# If called with --package, output a simplified package version string (written to file if -o is used) set -e top_srcdir=$(dirname $0)/.. VERSION_PREFIX="1.14i-ac" -OUTPUT_FOR_DIST=false +OUTPUT_FOR_PACKAGE=false OUTPUT_FILE= while [ $# -gt 0 ]; do case "$1" in - --dist) - OUTPUT_FOR_DIST=true + --package) + OUTPUT_FOR_PACKAGE=true shift ;; --check-clean) @@ -25,16 +25,16 @@ while [ $# -gt 0 ]; do shift 2 ;; *) - echo "Usage: $0 [--dist] [-o ]" >&2 + echo "Usage: $0 [--package] [-o ]" >&2 exit 1 ;; esac done -# Ensure we are inside a clean Git work tree for --dist -check_git_clean_for_dist() { +# Ensure we are inside a clean Git work tree for --package +check_git_clean_for_package() { if test x"$DIRTY" != x; then - echo "Error: working tree is dirty; commit or stash changes before running with --dist" >&2 + echo "Error: working tree is dirty; commit or stash changes before running with packaging" >&2 exit 1 fi @@ -47,7 +47,7 @@ check_git_clean_for_dist() { output_version() { if test x"$OUTPUT_FILE" = x && test -f $top_srcdir/.tarball-version; then version=$(cat $top_srcdir/.tarball-version) - elif test "$OUTPUT_FOR_DIST" = true; then + elif test "$OUTPUT_FOR_PACKAGE" = true; then version="${VERSION_PREFIX}${DATE}" else version="${VERSION_PREFIX}${DATE}-${HASH}${DIRTY}" @@ -74,7 +74,7 @@ if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then fi if test "$CHECK_CLEAN" = true; then - check_git_clean_for_dist + check_git_clean_for_package fi output_version diff --git a/configure.ac b/configure.ac index f78fa32..2faa9c7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -m4_define([VERSION_STRING], m4_esyscmd_s([build-aux/gen-build-version.sh --dist])) +m4_define([VERSION_STRING], m4_esyscmd_s([build-aux/gen-build-version.sh --package])) AC_INIT([LHa for UNIX], VERSION_STRING, [jca02266@gmail.com], [lha]) AC_DEFINE_UNQUOTED(LHA_CONFIGURE_OPTIONS, "$ac_configure_args", [specified options for the configure script.]) From 7ea6d2b84183e9d406806ba168fd33e5bd02d8ea Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Tue, 6 May 2025 13:18:14 +0900 Subject: [PATCH 10/10] Drop unnecessary comment --- src/version.h.in | 1 - 1 file changed, 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index aef7168..ef34241 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -1,2 +1 @@ -/**/ #define BUILD_VERSION "@BUILD_VERSION@"