Skip to content

Commit dc4ec6d

Browse files
committed
depends: create a hostid and buildid and add option for salts
These add very simple sanity checks to ensure that the build/host toolchains have not changed since the last run. If they have, all ids will change and packages will be rebuilt. For more complicated usage (like parsing dpkg), HOST_ID_SALT/BUILD_ID_SALT may be used to introduce arbitrary data to the ids.
1 parent a914968 commit dc4ec6d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

depends/Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ BASEDIR = $(CURDIR)
1515
HASH_LENGTH:=11
1616
DOWNLOAD_CONNECT_TIMEOUT:=10
1717
DOWNLOAD_RETRIES:=3
18+
HOST_ID_SALT ?= salt
19+
BUILD_ID_SALT ?= salt
1820

1921
host:=$(BUILD)
2022
ifneq ($(HOST),)
@@ -73,6 +75,20 @@ include builders/$(build_os).mk
7375
include builders/default.mk
7476
include packages/packages.mk
7577

78+
build_id_string:=$(BUILD_ID_SALT)
79+
build_id_string+=$(shell $(build_CC) --version 2>/dev/null)
80+
build_id_string+=$(shell $(build_AR) --version 2>/dev/null)
81+
build_id_string+=$(shell $(build_CXX) --version 2>/dev/null)
82+
build_id_string+=$(shell $(build_RANLIB) --version 2>/dev/null)
83+
build_id_string+=$(shell $(build_STRIP) --version 2>/dev/null)
84+
85+
$(host_arch)_$(host_os)_id_string:=$(HOST_ID_SALT)
86+
$(host_arch)_$(host_os)_id_string+=$(shell $(host_CC) --version 2>/dev/null)
87+
$(host_arch)_$(host_os)_id_string+=$(shell $(host_AR) --version 2>/dev/null)
88+
$(host_arch)_$(host_os)_id_string+=$(shell $(host_CXX) --version 2>/dev/null)
89+
$(host_arch)_$(host_os)_id_string+=$(shell $(host_RANLIB) --version 2>/dev/null)
90+
$(host_arch)_$(host_os)_id_string+=$(shell $(host_STRIP) --version 2>/dev/null)
91+
7692
qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages)
7793
qt_native_packages_$(NO_QT) = $(qt_native_packages)
7894
wallet_packages_$(NO_WALLET) = $(wallet_packages)
@@ -90,7 +106,7 @@ include funcs.mk
90106

91107
toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin)
92108
final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
93-
final_build_id+=$(shell echo -n $(final_build_id_long) | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
109+
final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
94110
$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
95111
$(AT)rm -rf $(@D)
96112
$(AT)mkdir -p $(@D)

depends/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ The following can be set when running make: make FOO=bar
3838
NO_WALLET: Don't download/build/cache libs needed to enable the wallet
3939
NO_UPNP: Don't download/build/cache packages needed for enabling upnp
4040
DEBUG: disable some optimizations and enable more runtime checking
41+
HOST_ID_SALT: Optional salt to use when generating host package ids
42+
BUILD_ID_SALT: Optional salt to use when generating build package ids
4143

4244
If some packages are not built, for example `make NO_WALLET=1`, the appropriate
4345
options will be passed to bitcoin's configure. In this case, `--disable-wallet`.

depends/funcs.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ define int_get_build_id
3939
$(eval $(1)_dependencies += $($(1)_$(host_arch)_$(host_os)_dependencies) $($(1)_$(host_os)_dependencies))
4040
$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($($(1)_type)_native_toolchain) $($(1)_dependencies)))
4141
$(foreach dep,$($(1)_all_dependencies),$(eval $(1)_build_id_deps+=$(dep)-$($(dep)_version)-$($(dep)_recipe_hash)))
42-
$(eval $(1)_build_id_long:=$(1)-$($(1)_version)-$($(1)_recipe_hash)-$(release_type) $($(1)_build_id_deps))
42+
$(eval $(1)_build_id_long:=$(1)-$($(1)_version)-$($(1)_recipe_hash)-$(release_type) $($(1)_build_id_deps) $($($(1)_type)_id_string))
4343
$(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH)))
4444
final_build_id_long+=$($(package)_build_id_long)
4545

0 commit comments

Comments
 (0)