All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCHv2 2/8] support/download: reintroduce 'source-check' target
Date: Sat, 9 Feb 2019 17:47:24 +0100	[thread overview]
Message-ID: <2d4ae398-9060-1a6a-7567-71b0166db297@mind.be> (raw)
In-Reply-To: <20190204180553.18394-3-patrickdepinguin@gmail.com>

 Hi Thomas,

 As mentioned in the developer meeting, I agree that your use case is important
enough to bring source-check back. I do still have some feedback on the
implementation.

On 04/02/2019 19:05, Thomas De Schampheleire wrote:
[snip]
> +define SOURCE_CHECK
> +	$(Q)mkdir -p $($(PKG)_DL_DIR)
> +	$(Q)$(EXTRA_ENV) $(FLOCK) $(DL_WRAPPER) \
> +		-C \

 Except for the -C, this is identical to the DOWNLOAD macro and should stay that
way. So I'd propose to add a second argument to DOWNLOAD in which you can pass -C.

> +		-c '$($(PKG)_DL_VERSION)' \
> +		-d '$($(PKG)_DL_DIR)' \
> +		-D '$(DL_DIR)' \
> +		-f '$(notdir $(1))' \
> +		-H '$($(PKG)_HASH_FILE)' \
> +		-n '$($(PKG)_BASENAME_RAW)' \
> +		-N '$($(PKG)_RAWNAME)' \
> +		-o '$($(PKG)_DL_DIR)/$(notdir $(1))' \
> +		$(if $($(PKG)_GIT_SUBMODULES),-r) \
> +		$(DOWNLOAD_URIS) \
> +		$(QUIET) \
> +		-- \
> +		$($(PKG)_DL_OPTS)
> +endef
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index f5cab2b9c2..707996e384 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -780,6 +780,10 @@ $(1)-legal-source:	$$($(2)_TARGET_ACTUAL_SOURCE)
>  endif # actual sources != sources
>  endif # actual sources != ""
>  
> +$(1)-source-check: PKG=$(2)
> +$(1)-source-check:
> +	$$(foreach p,$$($(2)_ALL_DOWNLOADS),$$(call SOURCE_CHECK,$$(p))$$(sep))

 Hm, I wonder if the pre/post download hooks shouldn't be called as well... We
don't have any in-tree consumers of them, so it's hard to be sure.

[snip]
>  
>      # Look through all the uris that we were given to download the package
> @@ -127,7 +130,7 @@ main() {
>                  -f "${filename}" \
>                  -u "${uri}" \
>                  -o "${tmpf}" \
> -                ${quiet} ${recurse} -- "${@}"
> +                ${quiet} ${recurse} ${checkonly} -- "${@}"
>          then
>              # cd back to keep path coherence
>              cd "${OLDPWD}"

 Hm, I wonder if this is the correct semantics for source-check. It will check
if the package can be found in any of the URLs, but in practice, don't you want
to to be in the first one only? For the primary case, yhou'll pass PRIMARY_ONLY
of course; but if you use it to check if the upstream URL is still correct, then
you want it to fail if you can't get it there. Of course, you can do that by
clearing the SECONDARY. But is there ever any reason to check if the package
exists at any of the URLs?

 That said, special-casing the checkonly here again will only make the control
flow even more complicated...

> @@ -138,19 +141,21 @@ main() {
>          # cd back to free the temp-dir, so we can remove it later
>          cd "${OLDPWD}"
>  
> -        # Check if the downloaded file is sane, and matches the stored hashes
> -        # for that file
> -        if support/download/check-hash ${quiet} "${hfile}" "${tmpf}" "${output##*/}"; then
> -            rc=0
> -        else
> -            if [ ${?} -ne 3 ]; then
> -                rm -rf "${tmpd}"
> -                continue
> +        if [ -z "${checkonly}" ]; then
> +            # Check if the downloaded file is sane, and matches the stored hashes
> +            # for that file
> +            if support/download/check-hash ${quiet} "${hfile}" "${tmpf}" "${output##*/}"; then
> +                rc=0
> +            else
> +                if [ ${?} -ne 3 ]; then
> +                    rm -rf "${tmpd}"
> +                    continue
> +                fi
> +
> +                # the hash file exists and there was no hash to check the file
> +                # against
> +                rc=1
>              fi
> -
> -            # the hash file exists and there was no hash to check the file
> -            # against
> -            rc=1
>          fi
>          download_and_check=1
>          break
> @@ -163,6 +168,12 @@ main() {
>          exit 1
>      fi
>  
> +    # If we only need to check the presence of sources, stop here.
> +    # No need to handle output files.

 So, without the subsequent patches, it actually *will* have downloaded
something (and even with the subsequent patches it will have done that for
git/svn/...). So shouldn't the downloaded file be removed again? I'm not sure
though...

 Regards,
 Arnout

> +    if [ -n "${checkonly}" ]; then
> +        exit 0
> +    fi
> +
>      # tmp_output is in the same directory as the final output, so we can
>      # later move it atomically.
>      tmp_output="$(mktemp "${output}.XXXXXX")"
> 

  reply	other threads:[~2019-02-09 16:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 18:05 [Buildroot] [PATCHv2 0/8] fix scp and reintroduce source-check target Thomas De Schampheleire
2019-02-04 18:05 ` [Buildroot] [PATCHv2 1/8] support/download/scp: fix download with scheme prefix 'scp://' Thomas De Schampheleire
2019-02-05 19:33   ` Peter Korsgaard
2019-02-18 22:20   ` Peter Korsgaard
2019-02-04 18:05 ` [Buildroot] [PATCHv2 2/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
2019-02-09 16:47   ` Arnout Vandecappelle [this message]
2019-02-09 20:08     ` Thomas De Schampheleire
2019-02-04 18:05 ` [Buildroot] [PATCHv2 3/8] support/download/hg: implement source-check Thomas De Schampheleire
2019-02-04 18:05 ` [Buildroot] [PATCHv2 4/8] support/download/wget: " Thomas De Schampheleire
2019-02-04 18:05 ` [Buildroot] [PATCHv2 5/8] support/download/file: " Thomas De Schampheleire
2019-02-04 18:05 ` [Buildroot] [PATCHv2 6/8] Config.in: reintroduce BR2_SSH Thomas De Schampheleire
2019-02-04 18:05 ` [Buildroot] [PATCHv2 7/8] support/download/scp: implement source-check Thomas De Schampheleire
2019-02-09 16:48   ` Arnout Vandecappelle
2019-02-09 20:16     ` Thomas De Schampheleire
2019-02-04 18:05 ` [Buildroot] [PATCHv2 8/8] support/download/{bzr, cvs, git, svn}: highlight unimplemented source-check Thomas De Schampheleire
2019-02-04 18:24 ` [Buildroot] [PATCHv2 0/8] fix scp and reintroduce source-check target Thomas Petazzoni
2019-02-04 18:41   ` Thomas De Schampheleire

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2d4ae398-9060-1a6a-7567-71b0166db297@mind.be \
    --to=arnout@mind.be \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.