Use dots in version

This commit is contained in:
Andrea Mazzoleni
2026-02-24 18:28:34 +01:00
parent 8639c8b479
commit 41e67f8beb
5 changed files with 25 additions and 40 deletions
+12 -6
View File
@@ -1,24 +1,30 @@
#!/bin/sh
#
if [ -d .git ]; then
# Get version from git tags, removing the 'v' prefix
VERSION=$(git describe --match 'v*' 2>/dev/null | sed 's/^v//')
fi
if [ -f .version ]; then
# Get version from the .version file
VERSION=$(cat .version)
fi
if [ -z "$VERSION" ] && [ -d .git ]; then
# Get version from git tags, removing the 'v' prefix
VERSION=$(git describe --match 'v*' 2>/dev/null | sed 's/^v//')
fi
if [ -z "$VERSION" ] && [ -d .git ]; then
# Fall back to short commit hash
VERSION=0-$(git rev-parse --short HEAD 2>/dev/null)
fi
if [ -z $VERSION ]; then
if [ -z "$VERSION" ]; then
# No version, but still use a number
VERSION="0"
fi
# Apply common rules to all outputs:
# 1. Replace "rc-" with "rc"
# 2. Replace "beta-" with "beta"
# 3. Replace all remaining dashes with "+"
VERSION=$(echo "$VERSION" | sed 's/rc-/rc/g; s/beta-/beta/g; s/-/+/g')
printf '%s' "$VERSION"
-3
View File
@@ -391,9 +391,6 @@ AC_ARG_VAR([TESTENV_SSSE3], [Test environment for SSSE3])
AC_ARG_VAR([TESTENV_SSE42], [Test environment for SSE42])
AC_ARG_VAR([TESTENV_AVX2], [Test environment for AVX2])
PACKAGE_VERSION_UNDERSCORE=`echo "$PACKAGE_VERSION" | sed 's/-/_/g'`
AC_SUBST([PACKAGE_VERSION_UNDERSCORE])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([pkg/snapraid.info pkg/control pkg/snapraid.spec])
AC_CONFIG_FILES([makeslackware.sh], [chmod a+x makeslackware.sh])
+4 -30
View File
@@ -21,7 +21,6 @@
set -euo pipefail
VERSION=@PACKAGE_VERSION@
VERSION_UNDERSCORE=@PACKAGE_VERSION_UNDERSCORE@
SPEC_FILE="@[email protected]"
if [[ ! -f "pkg/$SPEC_FILE" ]]; then
@@ -55,41 +54,16 @@ else
echo "$TARBALL already present in ~/rpmbuild/SOURCES"
fi
ORIGINAL_TARBALL="$RPMBUILD_DIR/SOURCES/@PACKAGE@-${VERSION}.tar.gz"
UNDERSCORE_TARBALL="$RPMBUILD_DIR/SOURCES/@PACKAGE@-${VERSION_UNDERSCORE}.tar.gz"
if [[ "$VERSION" == "$VERSION_UNDERSCORE" ]]; then
echo "Version does not contain '-', no repack needed."
else
if [[ ! -f "$UNDERSCORE_TARBALL" ]]; then
echo "Repacking tarball with underscore version..."
WORKDIR=$(mktemp -d)
tar -xzf "$ORIGINAL_TARBALL" -C "$WORKDIR"
mv "$WORKDIR/@PACKAGE@-${VERSION}" \
"$WORKDIR/@PACKAGE@-${VERSION_UNDERSCORE}"
tar -czf "$UNDERSCORE_TARBALL" -C "$WORKDIR" \
"@PACKAGE@-${VERSION_UNDERSCORE}"
rm -rf "$WORKDIR"
else
echo "Underscore tarball already exists."
fi
fi
# Copy spec file to SPECS directory (preserving the original filename)
cp "pkg/$SPEC_FILE" "$RPMBUILD_DIR/SPECS/"
echo "Building RPMs using rpmbuild -ba..."
rpmbuild -ba --nodeps --nocheck "$RPMBUILD_DIR/SPECS/$SPEC_FILE"
cp $RPMBUILD_DIR/RPMS/*/@PACKAGE@-${VERSION_UNDERSCORE}*.rpm .
cp $RPMBUILD_DIR/RPMS/*/@PACKAGE@-${VERSION}*.rpm .
echo "Package created: $RPMBUILD_DIR/RPMS/@PACKAGE@-${VERSION_UNDERSCORE}*.rpm"
echo "Package created: $RPMBUILD_DIR/RPMS/@PACKAGE@-${VERSION}*.rpm"
echo ""
echo "You can install the RPM with:"
echo " sudo dnf install @PACKAGE@-${VERSION_UNDERSCORE}*.rpm # Fedora"
echo " sudo rpm -ivh @PACKAGE@-${VERSION_UNDERSCORE}*.rpm # Others"
echo " sudo dnf install @PACKAGE@-${VERSION}*.rpm # Fedora"
echo " sudo rpm -ivh @PACKAGE@-${VERSION}*.rpm # Others"
+8
View File
@@ -1,3 +1,11 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
snapraid: snapraid (Disk array backup for many large rarely-changed files)
snapraid:
snapraid: SnapRAID is a backup program for disk arrays. It stores parity
+1 -1
View File
@@ -1,6 +1,6 @@
Name: @PACKAGE@
Summary: Disk array backup for many large rarely-changed files
Version: @PACKAGE_VERSION_UNDERSCORE@
Version: @PACKAGE_VERSION@
Release: 1%{?dist}
License: GPL-3.0-or-later
Group: Applications/System