fix(nwipe): version replacement

This commit is contained in:
desertwitch
2026-02-18 07:55:35 +01:00
parent 3200381771
commit ecea0be3bd

View File

@@ -5,16 +5,27 @@
################################################################################
NWIPE_VERSION = $(call qstrip,$(BR2_PACKAGE_NWIPE_GIT_REVISION))
# Default Git repository URL (never empty).
NWIPE_SITE = https://github.com/martijnvanbrummelen/nwipe.git
ifneq ($(call qstrip,$(BR2_PACKAGE_NWIPE_SITE)),)
NWIPE_SITE = $(call qstrip,$(BR2_PACKAGE_NWIPE_SITE))
endif
NWIPE_DEPENDENCIES = ncurses parted dmidecode coreutils libconfig
NWIPE_SITE_METHOD = git
NWIPE_DEPENDENCIES = ncurses parted dmidecode coreutils libconfig
ifneq ($(call qstrip,$(BR2_PACKAGE_NWIPE_SITE)),)
NWIPE_SITE = $(call qstrip,$(BR2_PACKAGE_NWIPE_SITE))
else
NWIPE_SITE = https://github.com/martijnvanbrummelen/nwipe.git
endif
################################################################################
# Architecture safeguard
################################################################################
define CHECK_SUPPORTED_ARCH
@case "$(BR2_ARCH)" in \
i686|x86_64) ;; \
*) echo "Unsupported architecture: $(BR2_ARCH)"; exit 1 ;; \
esac
endef
NWIPE_PRE_CONFIGURE_HOOKS += CHECK_SUPPORTED_ARCH
################################################################################
# SHREDOS version.txt and banner updater. Updates the nwipe version which
@@ -25,44 +36,32 @@ NWIPE_DEPENDENCIES = ncurses parted dmidecode coreutils libconfig
SHREDOS_VERSION_FILE = board/shredos/fsoverlay/etc/shredos/version.txt
ifeq ($(BR2_PACKAGE_NWIPE),y)
ifeq ($(BR2_PACKAGE_NWIPE_VERSION_GIT_REVISION),y)
# Take first 7 characters of the git revision and append suffix
NWIPE_VERSION_BANNER := $(shell printf "%.7s-commit-dev" "$(BR2_PACKAGE_NWIPE_GIT_REVISION)")
else
# If version contains a dot, treat it as a release tag
ifneq ($(findstring .,$(NWIPE_VERSION)),)
NWIPE_VERSION_BANNER := $(NWIPE_VERSION)
else
# Otherwise assume it is a development version by hash
NWIPE_VERSION_BANNER := $(shell printf "%.7s-commit-dev" "$(NWIPE_VERSION)")
endif
endif
# Normalize x86_64 to x86-64 for version
NWIPE_VARCH := $(if $(filter x86_64,$(BR2_ARCH)),x86-64,$(BR2_ARCH))
define NWIPE_UPDATE_VERSION_TXT
@if [ -n "$(NWIPE_VERSION_BANNER)" ]; then \
echo "Updating version.txt and nwipe banner with Nwipe version: $(NWIPE_VERSION_BANNER)"; \
sed -i 's/\(.*_\)[^_]*$$/\1$(NWIPE_VERSION_BANNER)/' $(SHREDOS_VERSION_FILE); \
fi
@echo "Updating version.txt: arch=$(NWIPE_VARCH) banner=$(NWIPE_VERSION_BANNER)"
@sed -i "s/\(.*_\)\(x86-64\|i686\)_.*$$/\1$(NWIPE_VARCH)_$(NWIPE_VERSION_BANNER)/" \
$(SHREDOS_VERSION_FILE)
@grep -q "$(NWIPE_VARCH)_$(NWIPE_VERSION_BANNER)" $(SHREDOS_VERSION_FILE) || \
{ echo "ERROR: Failed to update version.txt - unexpected format in file?"; exit 1; }
endef
NWIPE_PRE_CONFIGURE_HOOKS += NWIPE_UPDATE_VERSION_TXT
######
################################################################################
# Version architecture nwipe banner updater (pre-build)
################################################################################
define NWIPE_INITSH
@echo "Updating version.txt and nwipe banner with architecture: $(BR2_ARCH)"
@if [ "$(BR2_ARCH)" = "i686" ]; then \
sed -i 's/\(^.*_\)\(x86-64\|i686\)\(_.*\)/\1i686\3/' $(SHREDOS_VERSION_FILE); \
elif [ "$(BR2_ARCH)" = "x86_64" ]; then \
sed -i 's/\(^.*_\)\(x86-64\|i686\)\(_.*\)/\1x86-64\3/' $(SHREDOS_VERSION_FILE); \
else \
echo "Unsupported architecture: $(BR2_ARCH)"; \
exit 1; \
fi
define NWIPE_INIT_BUILD
(cd $(@D) && \
cp ../../../package/nwipe/002-nwipe-banner-patch.sh . && \
./002-nwipe-banner-patch.sh && \
@@ -72,7 +71,7 @@ endef
# Pre-configure hook, as a post-patch hook would not get triggered on a package
# reconfigure, and possibly also taint the sources directory with the generated
# autogen files (which should not be there).
NWIPE_PRE_CONFIGURE_HOOKS += NWIPE_INITSH
NWIPE_PRE_CONFIGURE_HOOKS += NWIPE_INIT_BUILD
$(eval $(autotools-package))