Skip to content

Commit 3393215

Browse files
committed
Merge pull request #6136
235b3a7 depends: sanity-check sources and cached builds (Cory Fields)
2 parents a538126 + 235b3a7 commit 3393215

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

depends/Makefile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ include funcs.mk
9191
toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin)
9292
final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
9393
final_build_id+=$(shell echo -n $(final_build_id_long) | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))
94-
$(host_prefix)/.stamp_$(final_build_id): | $(native_packages) $(packages)
94+
$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
9595
$(AT)rm -rf $(@D)
9696
$(AT)mkdir -p $(@D)
97-
$(AT)echo copying packages: $|
97+
$(AT)echo copying packages: $^
9898
$(AT)echo to: $(@D)
99-
$(AT)cd $(@D); $(foreach package,$|, tar xf $($(package)_cached); )
99+
$(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
100100
$(AT)touch $@
101101

102102
$(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id)
@@ -121,13 +121,41 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
121121
$< > $@
122122
$(AT)touch $@
123123

124-
install: $(host_prefix)/share/config.site
125-
download-one: $(all_sources)
124+
125+
define check_or_remove_cached
126+
mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \
127+
$(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \
128+
( rm -f $($(package)_cached_checksum); \
129+
if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi )
130+
endef
131+
132+
define check_or_remove_sources
133+
mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \
134+
$(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \
135+
( if test -f $($(package)_all_sources); then echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; fi; \
136+
rm -f $($(package)_all_sources) $($(1)_fetched))
137+
endef
138+
139+
check-packages:
140+
@$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));)
141+
check-sources:
142+
@$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));)
143+
144+
$(host_prefix)/share/config.site: check-packages
145+
146+
check-packages: check-sources
147+
148+
install: check-packages $(host_prefix)/share/config.site
149+
150+
151+
download-one: check-sources $(all_sources)
152+
126153
download-osx:
127154
@$(MAKE) -s HOST=x86_64-apple-darwin11 download-one
128155
download-linux:
129156
@$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one
130157
download-win:
131158
@$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
132159
download: download-osx download-linux download-win
133-
.PHONY: install cached download-one download-osx download-linux download-win download
160+
161+
.PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources

depends/README.packages

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ These variables are optional:
3030
Names of any other packages that this one depends on.
3131
$(package)_patches:
3232
Filenames of any patches needed to build the package
33-
33+
$(package)_extra_sources:
34+
Any extra files that will be fetched via $(package)_fetch_cmds. These are
35+
specified so that they can be fetched and verified via 'make download'.
3436

3537
Build Variables:
3638
After defining the main identifiers, build variables may be added or customized

depends/funcs.mk

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ $(1)_staging_prefix_dir:=$$($(1)_staging_dir)$($($(1)_type)_prefix)
5353
$(1)_extract_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)
5454
$(1)_download_dir:=$(base_download_dir)/$(1)-$($(1)_version)
5555
$(1)_build_dir:=$$($(1)_extract_dir)/$$($(1)_build_subdir)
56+
$(1)_cached_checksum:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz.hash
5657
$(1)_patch_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)/.patches-$($(1)_build_id)
5758
$(1)_prefixbin:=$($($(1)_type)_prefix)/bin/
5859
$(1)_cached:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz
60+
$(1)_all_sources=$($(1)_file_name) $($(1)_extra_sources)
5961

6062
#stamps
61-
$(1)_fetched=$$($(1)_source_dir)/download-stamps/.stamp_fetched-$(1)-$($(1)_file_name)
63+
$(1)_fetched=$(SOURCES_PATH)/download-stamps/.stamp_fetched-$(1)-$($(1)_file_name).hash
6264
$(1)_extracted=$$($(1)_extract_dir)/.stamp_extracted
6365
$(1)_preprocessed=$$($(1)_extract_dir)/.stamp_preprocessed
6466
$(1)_cleaned=$$($(1)_extract_dir)/.stamp_cleaned
@@ -154,7 +156,10 @@ endef
154156
define int_add_cmds
155157
$($(1)_fetched):
156158
$(AT)mkdir -p $$(@D) $(SOURCES_PATH)
159+
$(AT)rm -f $$@
160+
$(AT)touch $$@
157161
$(AT)cd $$(@D); $(call $(1)_fetch_cmds,$(1))
162+
$(AT)cd $($(1)_source_dir); $(foreach source,$($(1)_all_sources),$(build_SHA256SUM) $(source) >> $$(@);)
158163
$(AT)touch $$@
159164
$($(1)_extracted): | $($(1)_fetched)
160165
$(AT)echo Extracting $(1)...
@@ -195,10 +200,12 @@ $($(1)_cached): | $($(1)_dependencies) $($(1)_postprocessed)
195200
$(AT)rm -rf $$(@D) && mkdir -p $$(@D)
196201
$(AT)mv $$($(1)_staging_dir)/$$(@F) $$(@)
197202
$(AT)rm -rf $($(1)_staging_dir)
203+
$($(1)_cached_checksum): $($(1)_cached)
204+
$(AT)cd $$(@D); $(build_SHA256SUM) $$(<F) > $$(@)
198205

199206
.PHONY: $(1)
200-
$(1): | $($(1)_cached)
201-
.SECONDARY: $($(1)_postprocessed) $($(1)_staged) $($(1)_built) $($(1)_configured) $($(1)_preprocessed) $($(1)_extracted) $($(1)_fetched)
207+
$(1): | $($(1)_cached_checksum)
208+
.SECONDARY: $($(1)_cached) $($(1)_postprocessed) $($(1)_staged) $($(1)_built) $($(1)_configured) $($(1)_preprocessed) $($(1)_extracted) $($(1)_fetched)
202209

203210
endef
204211

depends/packages/native_cctools.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ $(package)_clang_download_path=http://llvm.org/releases/$($(package)_clang_versi
99
$(package)_clang_download_file=clang+llvm-$($(package)_clang_version)-amd64-Ubuntu-12.04.2.tar.gz
1010
$(package)_clang_file_name=clang-llvm-$($(package)_clang_version)-amd64-Ubuntu-12.04.2.tar.gz
1111
$(package)_clang_sha256_hash=60d8f69f032d62ef61bf527857ebb933741ec3352d4d328c5516aa520662dab7
12+
$(package)_extra_sources=$($(package)_clang_file_name)
13+
1214
define $(package)_fetch_cmds
1315
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \
1416
$(call fetch_file,$(package),$($(package)_clang_download_path),$($(package)_clang_download_file),$($(package)_clang_file_name),$($(package)_clang_sha256_hash))

0 commit comments

Comments
 (0)