Extend userland-fetch with a --keep option to not delete files, and add a "gmake fetch" action to just download and verify (not remove) files
| | |
| | | URL_SUFFIXES = $(subst COMPONENT_ARCHIVE_URL_,, \ |
| | | $(filter COMPONENT_ARCHIVE_URL_%, $(.VARIABLES))) |
| | | |
| | | # Argument to "userland-fetch" script that causes it to download and verify |
| | | # files, but not to remove mismatches; good to save traffic when initially |
| | | # fetching a new archive just to learn what checksum to expect in Makefile. |
| | | #FETCH_KEEP ?= --keep |
| | | FETCH_KEEP ?= |
| | | |
| | | # Template for download rules. |
| | | define download-rules |
| | | ifdef COMPONENT_ARCHIVE_URL$(1) |
| | |
| | | ARCHIVES += $$(COMPONENT_ARCHIVE$(1)) |
| | | CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1)) |
| | | |
| | | fetch:: FETCH_KEEP=--keep |
| | | fetch:: $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)) |
| | | |
| | | download:: $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)) |
| | | |
| | | $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ) |
| | | $$(FETCH) --file $$@ \ |
| | | $$(FETCH) $$(FETCH_KEEP) --file $$@ \ |
| | | $$(COMPONENT_ARCHIVE_URL$(1):%=--url %) \ |
| | | $$(COMPONENT_ARCHIVE_HASH$(1):%=--hash %) \ |
| | | $$(COMPONENT_SIG_URL$(1):%=--sigurl %) \ |
| | |
| | | user_agent_arg = None |
| | | file_arg = None |
| | | link_arg = False |
| | | keep_arg = False |
| | | hash_arg = None |
| | | url_arg = None |
| | | search_list = list() |
| | | |
| | | try: |
| | | opts, args = getopt.getopt(sys.argv[1:], "a:f:h:ls:u:", |
| | | ["file=", "link", "hash=", "search=", "url=", |
| | | opts, args = getopt.getopt(sys.argv[1:], "a:f:h:lks:u:", |
| | | ["file=", "link", "keep", "hash=", "search=", "url=", |
| | | "user-agent="]) |
| | | except getopt.GetoptError, err: |
| | | print str(err) |
| | |
| | | file_arg = arg |
| | | elif opt in [ "-l", "--link" ]: |
| | | link_arg = True |
| | | elif opt in [ "-k", "--keep" ]: |
| | | keep_arg = True |
| | | elif opt in [ "-h", "--hash" ]: |
| | | hash_arg = arg |
| | | elif opt in [ "-s", "--search" ]: |
| | |
| | | print " actual: %s" % realhash |
| | | print " payload: %s" % payloadhash |
| | | |
| | | try: |
| | | os.remove(name) |
| | | except OSError: |
| | | pass |
| | | if keep_arg == False: |
| | | try: |
| | | print "\nWARN: Removing the corrupt downloaded file" |
| | | os.remove(name) |
| | | except OSError: |
| | | pass |
| | | else: |
| | | print "\nINFO: Keeping the downloaded file because asked to" |
| | | |
| | | sys.exit(1) |
| | | |