All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target
@ 2019-02-15 21:07 Thomas De Schampheleire
  2019-02-15 21:07 ` [Buildroot] [PATCHv4 2/8] support/download/hg: implement source-check Thomas De Schampheleire
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:07 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Commit bf28a165d992681a85b43a886005e669b3cb579b removed the source-check
target to allow easier refactoring of the download infrastructure.
It was partly based on the fact that no-one really used this target.

However, it turns out that there _are_ good uses for it. In a work
environment where many people are submitting changes to a Buildroot
repository, one cannot always blindly trust every change. A typical case
of human error is when bumping the version of a package but forgetting to
upload the tarball to the internal BR2_PRIMARY_SITE or (in case of a
repository) pushing the new changesets to the repository.
If a user cannot directly push to the Buildroot repository but needs to
queue their change via an automatic validation system, that validation
system can use 'make source-check' on the relevant defconfigs to protect
against such errors. A full download would also be possible but takes
longer and unnecessarily uses internal network bandwidth.

With that use case in mind, this commit reintroduces the 'source-check'
target, but embedded in the current situation with a dl-wrapper.  The
changes to the wrapper are minimal (not considering additional indentation).
A new option '-C' means 'check only' and will be passed to the download
backends. If the backend supports the option, no download will happen. If it
does not, then the backend will actually perform a download as a means of
checking that the source exists (a form of graceful degradation). In neither
case, though, hash checking is performed (as the standard case is without
download thus without file to calculate hashes on).

Subsequent commits will actually implement -C in the backends.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 Makefile                    |   7 +++
 package/pkg-download.mk     |   6 +++
 package/pkg-generic.mk      |  14 ++++-
 support/download/dl-wrapper | 100 ++++++++++++++++++++----------------
 4 files changed, 82 insertions(+), 45 deletions(-)

v4: no changes

v3: (feedback Arnout Vandecappelle)
- remove tmpd at the end of dl-wrapper
- remove duplication between DOWNLOAD and SOURCE_CHECK macros

v2:
- add a trailing dot on all usage texts like for other options
- split off the reintroduction of BR2_SSH to a separate patch
- fix the source-check for scp: it seems there were some broken things in v1
- drop incomplete implementations for git/svn/bzr/cvs so it falls back
to actual download.

diff --git a/Makefile b/Makefile
index 0d2659c46e..9ae047bfc6 100644
--- a/Makefile
+++ b/Makefile
@@ -131,6 +131,7 @@ noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconf
 # (default target is to build), or when MAKECMDGOALS contains
 # something else than one of the nobuild_targets.
 nobuild_targets := source %-source \
+	source-check %-source-check %-all-source-check \
 	legal-info %-legal-info external-deps _external-deps \
 	clean distclean help show-targets graph-depends \
 	%-graph-depends %-show-depends %-show-version \
@@ -818,6 +819,9 @@ target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
 .PHONY: source
 source: $(foreach p,$(PACKAGES),$(p)-all-source)
 
+.PHONY: source-check
+source-check: $(foreach p,$(PACKAGES),$(p)-all-source-check)
+
 .PHONY: _external-deps external-deps
 _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
 external-deps:
@@ -1103,6 +1107,8 @@ help:
 	@echo '  <pkg>-dirclean         - Remove <pkg> build directory'
 	@echo '  <pkg>-reconfigure      - Restart the build from the configure step'
 	@echo '  <pkg>-rebuild          - Restart the build from the build step'
+	@echo '  <pkg>-source-check     - Check package for valid download URLs'
+	@echo '  <pkg>-all-source-check - Check package and its dependencies for valid download URLs'
 	$(foreach p,$(HELP_PACKAGES), \
 		@echo $(sep) \
 		@echo '$($(p)_NAME):' $(sep) \
@@ -1122,6 +1128,7 @@ help:
 	@echo
 	@echo 'Miscellaneous:'
 	@echo '  source                 - download all sources needed for offline-build'
+	@echo '  source-check           - check selected packages for valid download URLs'
 	@echo '  external-deps          - list external packages used'
 	@echo '  legal-info             - generate info about license compliance'
 	@echo '  printvars              - dump all the internal variables'
diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 7cd87c38ff..5384fc2af4 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -70,6 +70,7 @@ export BR_NO_CHECK_HASH_FOR =
 # 3) BR2_BACKUP_SITE if enabled, unless BR2_PRIMARY_SITE_ONLY is set
 #
 # Argument 1 is the source location
+# Argument 2 (optionally) provides extra arguments to pass to DL_WRAPPER
 #
 ################################################################################
 
@@ -92,6 +93,7 @@ endif
 define DOWNLOAD
 	$(Q)mkdir -p $($(PKG)_DL_DIR)
 	$(Q)$(EXTRA_ENV) $(FLOCK) $(DL_WRAPPER) \
+		$(2) \
 		-c '$($(PKG)_DL_VERSION)' \
 		-d '$($(PKG)_DL_DIR)' \
 		-D '$(DL_DIR)' \
@@ -106,3 +108,7 @@ define DOWNLOAD
 		-- \
 		$($(PKG)_DL_OPTS)
 endef
+
+define SOURCE_CHECK
+	$(call DOWNLOAD,$(1),-C)
+endef
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 6168b40e89..bc57956867 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -788,6 +788,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))
+
 $(1)-external-deps:
 	@for p in $$($(2)_SOURCE) $$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS) ; do \
 		echo `basename $$$$p` ; \
@@ -812,6 +816,9 @@ $(1)-rsync:		$$($(2)_TARGET_RSYNC)
 $(1)-source:
 $(1)-legal-source:
 
+$(1)-source-check:
+	test -d $$($(2)_OVERRIDE_SRCDIR)
+
 $(1)-external-deps:
 	@echo "file://$$($(2)_OVERRIDE_SRCDIR)"
 endif
@@ -846,6 +853,9 @@ $(1)-graph-rdepends: graph-depends-requirements
 $(1)-all-source:	$(1)-source
 $(1)-all-source:	$$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-source)
 
+$(1)-all-source-check:	$(1)-source-check
+$(1)-all-source-check:	$$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-source-check)
+
 $(1)-all-external-deps:	$(1)-external-deps
 $(1)-all-external-deps:	$$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-external-deps)
 
@@ -1044,6 +1054,7 @@ DL_TOOLS_DEPENDENCIES += $$(call extractor-dependency,$$($(2)_SOURCE))
 	$(1)-all-external-deps \
 	$(1)-all-legal-info \
 	$(1)-all-source \
+	$(1)-all-source-check \
 	$(1)-build \
 	$(1)-clean-for-rebuild \
 	$(1)-clean-for-reconfigure \
@@ -1068,7 +1079,8 @@ DL_TOOLS_DEPENDENCIES += $$(call extractor-dependency,$$($(2)_SOURCE))
 	$(1)-rsync \
 	$(1)-show-depends \
 	$(1)-show-version \
-	$(1)-source
+	$(1)-source \
+	$(1)-source-check
 
 ifneq ($$($(2)_SOURCE),)
 ifeq ($$($(2)_SITE),)
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index 3315bd410e..920699e51d 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -17,7 +17,7 @@
 # We want to catch any unexpected failure, and exit immediately.
 set -e
 
-export BR_BACKEND_DL_GETOPTS=":hc:d:o:n:N:H:ru:qf:e"
+export BR_BACKEND_DL_GETOPTS=":hc:Cd:o:n:N:H:ru:qf:e"
 
 main() {
     local OPT OPTARG
@@ -25,9 +25,10 @@ main() {
     local -a uris
 
     # Parse our options; anything after '--' is for the backend
-    while getopts ":c:d:D:o:n:N:H:rf:u:q" OPT; do
+    while getopts ":c:Cd:D:o:n:N:H:rf:u:q" OPT; do
         case "${OPT}" in
         c)  cset="${OPTARG}";;
+        C)  checkonly=-C;;
         d)  dl_dir="${OPTARG}";;
         D)  old_dl_dir="${OPTARG}";;
         o)  output="${OPTARG}";;
@@ -46,38 +47,40 @@ main() {
     # Forget our options, and keep only those for the backend
     shift $((OPTIND-1))
 
-    if [ -z "${output}" ]; then
-        error "no output specified, use -o\n"
-    fi
+    if [ -z "${checkonly}" ]; then
+        if [ -z "${output}" ]; then
+            error "no output specified, use -o\n"
+        fi
 
-    # Legacy handling: check if the file already exists in the global
-    # download directory. If it does, hard-link it. If it turns out it
-    # was an incorrect download, we'd still check it below anyway.
-    # If we can neither link nor copy, fallback to doing a download.
-    # NOTE! This is not atomic, is subject to TOCTTOU, but the whole
-    # dl-wrapper runs under an flock, so we're safe.
-    if [ ! -e "${output}" -a -e "${old_dl_dir}/${filename}" ]; then
-        ln "${old_dl_dir}/${filename}" "${output}" || \
-        cp "${old_dl_dir}/${filename}" "${output}" || \
-        true
-    fi
+        # Legacy handling: check if the file already exists in the global
+        # download directory. If it does, hard-link it. If it turns out it
+        # was an incorrect download, we'd still check it below anyway.
+        # If we can neither link nor copy, fallback to doing a download.
+        # NOTE! This is not atomic, is subject to TOCTTOU, but the whole
+        # dl-wrapper runs under an flock, so we're safe.
+        if [ ! -e "${output}" -a -e "${old_dl_dir}/${filename}" ]; then
+            ln "${old_dl_dir}/${filename}" "${output}" || \
+            cp "${old_dl_dir}/${filename}" "${output}" || \
+            true
+        fi
 
-    # If the output file already exists and:
-    # - there's no .hash file: do not download it again and exit promptly
-    # - matches all its hashes: do not download it again and exit promptly
-    # - fails at least one of its hashes: force a re-download
-    # - there's no hash (but a .hash file): consider it a hard error
-    if [ -e "${output}" ]; then
-        if support/download/check-hash ${quiet} "${hfile}" "${output}" "${output##*/}"; then
-            exit 0
-        elif [ ${?} -ne 2 ]; then
-            # Do not remove the file, otherwise it might get re-downloaded
-            # from a later location (i.e. primary -> upstream -> mirror).
-            # Do not print a message, check-hash already did.
-            exit 1
+        # If the output file already exists and:
+        # - there's no .hash file: do not download it again and exit promptly
+        # - matches all its hashes: do not download it again and exit promptly
+        # - fails at least one of its hashes: force a re-download
+        # - there's no hash (but a .hash file): consider it a hard error
+        if [ -e "${output}" ]; then
+            if support/download/check-hash ${quiet} "${hfile}" "${output}" "${output##*/}"; then
+                exit 0
+            elif [ ${?} -ne 2 ]; then
+                # Do not remove the file, otherwise it might get re-downloaded
+                # from a later location (i.e. primary -> upstream -> mirror).
+                # Do not print a message, check-hash already did.
+                exit 1
+            fi
+            rm -f "${output}"
+            warn "Re-downloading '%s'...\n" "${output##*/}"
         fi
-        rm -f "${output}"
-        warn "Re-downloading '%s'...\n" "${output##*/}"
     fi
 
     # 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}"
@@ -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,13 @@ main() {
         exit 1
     fi
 
+    # If we only need to check the presence of sources, stop here.
+    # No need to handle output files.
+    if [ -n "${checkonly}" ]; then
+        rm -rf "${tmpd}"
+        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")"
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 2/8] support/download/hg: implement source-check
  2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
@ 2019-02-15 21:07 ` Thomas De Schampheleire
  2019-02-15 21:07 ` [Buildroot] [PATCHv4 3/8] support/download/wget: " Thomas De Schampheleire
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:07 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Note: the implementation is different (better) than what used to be in
Buildroot before source-check was removed.

The original implementation:
    hg incoming --force -l1 <URL>
would only verify that the repository exists, not that the requested
revision is present.

An already better implementation is:
    hg incoming --force -l1 -r <revision> <URL>
but compared to the next solution it has a large resource consumption on the
local machine. In the background, the full repository is first downloaded.

The implemented solution is:
    hg identify -r <revision> <URL>
which operates directly on the remote repository.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 support/download/hg | 12 ++++++++++++
 1 file changed, 12 insertions(+)

v4: (feedback Yann E. Morin)
- use true/false as values to 'checkonly'
- always check revision, even if no source-check
- replace incorrect 'exit $?' by explicit 'exit 0'

v3: no changes

diff --git a/support/download/hg b/support/download/hg
index efb515fca5..8f7d1a5a90 100755
--- a/support/download/hg
+++ b/support/download/hg
@@ -7,6 +7,7 @@ set -e
 #
 # Options:
 #   -q          Be quiet.
+#   -C          Only check that the changeset exists in the remote repository.
 #   -o FILE     Generate archive in FILE.
 #   -u URI      Clone from repository at URI.
 #   -c CSET     Use changeset (or revision) CSET.
@@ -16,9 +17,11 @@ set -e
 #   HG       : the hg command to call
 
 verbose=
+checkonly=false
 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     case "${OPT}" in
     q)  verbose=-q;;
+    C)  checkonly=true;;
     o)  output="${OPTARG}";;
     u)  uri="${OPTARG}";;
     c)  cset="${OPTARG}";;
@@ -36,6 +39,15 @@ _hg() {
     eval ${HG} "${@}"
 }
 
+if ! _hg identify ${verbose} "${@}" --rev "'${cset}'" "'${uri}'" > /dev/null; then
+    printf "Commit '%s' does not exist in this repository\n." "${cset}"
+    exit 1
+fi
+
+if ${checkonly}; then
+    exit 0
+fi
+
 _hg clone ${verbose} "${@}" --noupdate "'${uri}'" "'${basename}'"
 
 _hg archive ${verbose} --repository "'${basename}'" --type tgz \
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 3/8] support/download/wget: implement source-check
  2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
  2019-02-15 21:07 ` [Buildroot] [PATCHv4 2/8] support/download/hg: implement source-check Thomas De Schampheleire
@ 2019-02-15 21:07 ` Thomas De Schampheleire
  2019-02-15 21:07 ` [Buildroot] [PATCHv4 4/8] support/download/file: " Thomas De Schampheleire
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:07 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 support/download/wget | 8 ++++++++
 1 file changed, 8 insertions(+)

v4: (feedback Yann E. Morin)
- use true/false as values to 'checkonly'
- replace incorrect 'exit $?' by explicit 'exit 0'

v3: no changes

diff --git a/support/download/wget b/support/download/wget
index c69e6071aa..277eab6660 100755
--- a/support/download/wget
+++ b/support/download/wget
@@ -7,6 +7,7 @@ set -e
 #
 # Options:
 #   -q          Be quiet.
+#   -C          Only check that the file exists remotely.
 #   -o FILE     Save into file FILE.
 #   -f FILENAME The filename of the tarball to get at URL
 #   -u URL      Download file at URL.
@@ -16,9 +17,11 @@ set -e
 #   WGET     : the wget command to call
 
 verbose=
+checkonly=false
 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     case "${OPT}" in
     q)  verbose=-q;;
+    C)  checkonly=true;;
     o)  output="${OPTARG}";;
     f)  filename="${OPTARG}";;
     u)  url="${OPTARG}";;
@@ -40,4 +43,9 @@ _wget() {
 # mirror
 [ -n "${encode}" ] && filename=${filename//\?/%3F}
 
+if ${checkonly}; then
+    _wget --spider ${verbose} "${@}" "'${url}/${filename}'"
+    exit 0
+fi
+
 _wget ${verbose} "${@}" -O "'${output}'" "'${url}/${filename}'"
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 4/8] support/download/file: implement source-check
  2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
  2019-02-15 21:07 ` [Buildroot] [PATCHv4 2/8] support/download/hg: implement source-check Thomas De Schampheleire
  2019-02-15 21:07 ` [Buildroot] [PATCHv4 3/8] support/download/wget: " Thomas De Schampheleire
@ 2019-02-15 21:07 ` Thomas De Schampheleire
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH Thomas De Schampheleire
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:07 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 support/download/file | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

v4:
- use true/false as values to 'checkonly' (Yann E. Morin)
- replace incorrect 'exit $?' by explicit 'exit 0' (Yann E. Morin)
- replace 'test -e' by 'test -f' which is more specific

v3: no changes

diff --git a/support/download/file b/support/download/file
index e52fcf2c8c..059a8dde4c 100755
--- a/support/download/file
+++ b/support/download/file
@@ -7,6 +7,7 @@ set -e
 #
 # Options:
 #   -q          Be quiet.
+#   -C          Only check that the source file exists.
 #   -o FILE     Copy to file FILE.
 #   -f FILE     Copy from basename file FILE.
 #   -u DIR      Copy from FILE in DIR.
@@ -20,9 +21,11 @@ set -e
 # Make 'cp' verbose by default, so it behaves a bit like the others.
 verbose=-v
 
+checkonly=false
 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     case "${OPT}" in
     q)  verbose=;;
+    C)  checkonly=true;;
     o)  output="${OPTARG}";;
     f)  file="${OPTARG}";;
     u)  dir="${OPTARG}";;
@@ -39,4 +42,12 @@ _localfiles() {
     eval ${LOCALFILES} "${@}"
 }
 
-_localfiles ${verbose} "'${dir##file://}/${file}'" "'${output}'"
+# Remove any scheme prefix
+dir="${dir##file://}"
+
+if ${checkonly}; then
+    test -f "'${dir}/${file}'"
+    exit 0
+fi
+
+_localfiles ${verbose} "'${dir}/${file}'" "'${output}'"
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH
  2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
                   ` (2 preceding siblings ...)
  2019-02-15 21:07 ` [Buildroot] [PATCHv4 4/8] support/download/file: " Thomas De Schampheleire
@ 2019-02-15 21:08 ` Thomas De Schampheleire
  2019-02-16 12:34   ` Yann E. MORIN
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 6/8] support/download/scp: implement source-check Thomas De Schampheleire
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:08 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

The BR2_SSH command was removed in commit
db9473bf6cd7bd12aa1f9faad0a917c973c33827 ("core/download: drop the SSH
command") but will be needed again to support 'source-check' for the scp
download backend.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 Config.in               | 4 ++++
 package/pkg-download.mk | 1 +
 2 files changed, 5 insertions(+)

v4: no changes
v3: no changes

diff --git a/Config.in b/Config.in
index d58d8dc04a..91d56907fe 100644
--- a/Config.in
+++ b/Config.in
@@ -136,6 +136,10 @@ config BR2_SCP
 	string "Secure copy (scp) command"
 	default "scp"
 
+config BR2_SSH
+	string "Secure shell (ssh) command"
+	default "ssh"
+
 config BR2_HG
 	string "Mercurial (hg) command"
 	default "hg"
diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 5384fc2af4..17d1ca99ee 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -15,6 +15,7 @@ export BZR := $(call qstrip,$(BR2_BZR))
 export GIT := $(call qstrip,$(BR2_GIT))
 export HG := $(call qstrip,$(BR2_HG))
 export SCP := $(call qstrip,$(BR2_SCP))
+export SSH := $(call qstrip,$(BR2_SSH))
 export LOCALFILES := $(call qstrip,$(BR2_LOCALFILES))
 
 DL_WRAPPER = support/download/dl-wrapper
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 6/8] support/download/scp: implement source-check
  2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
                   ` (3 preceding siblings ...)
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH Thomas De Schampheleire
@ 2019-02-15 21:08 ` Thomas De Schampheleire
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 7/8] support/download/svn: " Thomas De Schampheleire
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 8/8] support/download/{bzr, cvs, git}: highlight unimplemented source-check Thomas De Schampheleire
  6 siblings, 0 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:08 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

We use 'test -f' rather than 'ls' because 'test' is a mandatory POSIX
utility while 'ls' is not.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 support/download/scp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

v4: (feedback Yann E. Morin)
- use true/false as values to 'checkonly'
- replace incorrect 'exit $?' by explicit 'exit 0'
- use 'test -f' instead of 'ls' which is more certain to be present (POSIX
  mandatory utility)

v3: no changes

diff --git a/support/download/scp b/support/download/scp
index 80cf495c4e..52ccf06d6e 100755
--- a/support/download/scp
+++ b/support/download/scp
@@ -7,17 +7,21 @@ set -e
 #
 # Options:
 #   -q          Be quiet.
+#   -C          Only check that the file exists remotely.
 #   -o FILE     Copy to local file FILE.
 #   -f FILE     Copy from remote file FILE.
 #   -u URI      Download file at URI.
 #
 # Environment:
 #   SCP       : the scp command to call
+#   SSH       : the ssh command to use for checkonly
 
 verbose=
+checkonly=false
 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     case "${OPT}" in
     q)  verbose=-q;;
+    C)  checkonly=true;;
     o)  output="${OPTARG}";;
     f)  filename="${OPTARG}";;
     u)  uri="${OPTARG}";;
@@ -33,8 +37,19 @@ shift $((OPTIND-1)) # Get rid of our options
 _scp() {
     eval ${SCP} "${@}"
 }
+_ssh() {
+    eval ${SSH} "${@}"
+}
 
 # Remove any scheme prefix
 uri="${uri##scp://}"
 
+if ${checkonly}; then
+    # uri now looks like:  foo.example.org:some/directory
+    domain="${uri%%:*}"
+    path="${uri#*:}/${filename}"
+    _ssh ${verbose} "${@}" "'${domain}'" test -f "'${path}'" > /dev/null
+    exit 0
+fi
+
 _scp ${verbose} "${@}" "'${uri}/${filename}'" "'${output}'"
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 7/8] support/download/svn: implement source-check
  2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
                   ` (4 preceding siblings ...)
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 6/8] support/download/scp: implement source-check Thomas De Schampheleire
@ 2019-02-15 21:08 ` Thomas De Schampheleire
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 8/8] support/download/{bzr, cvs, git}: highlight unimplemented source-check Thomas De Schampheleire
  6 siblings, 0 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:08 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Suggested-by: "Yann E. Morin" <yann.morin.1998@free.fr>
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 support/download/svn | 12 ++++++++++++
 1 file changed, 12 insertions(+)

v4: new patch

diff --git a/support/download/svn b/support/download/svn
index 542b25c0a2..93984b6c45 100755
--- a/support/download/svn
+++ b/support/download/svn
@@ -7,6 +7,7 @@ set -e
 #
 # Options:
 #   -q          Be quiet.
+#   -C          Only check that the revision exists in the remote repository.
 #   -o FILE     Generate archive in FILE.
 #   -u URI      Checkout from repository at URI.
 #   -c REV      Use revision REV.
@@ -16,9 +17,11 @@ set -e
 #   SVN      : the svn command to call
 
 verbose=
+checkonly=false
 while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
     case "${OPT}" in
     q)  verbose=-q;;
+    C)  checkonly=true;;
     o)  output="${OPTARG}";;
     u)  uri="${OPTARG}";;
     c)  rev="${OPTARG}";;
@@ -36,6 +39,15 @@ _svn() {
     eval ${SVN} "${@}"
 }
 
+if ! _svn ls ${verbose} -r "'${rev}'" "'${uri}'" > /dev/null; then
+    printf "Revision '%s' does not exist in this repository\n." "${rev}"
+    exit 1
+fi
+
+if ${checkonly}; then
+    exit 0
+fi
+
 _svn export ${verbose} "${@}" "'${uri}@${rev}'" "'${basename}'"
 
 tar czf "${output}" "${basename}"
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 8/8] support/download/{bzr, cvs, git}: highlight unimplemented source-check
  2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
                   ` (5 preceding siblings ...)
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 7/8] support/download/svn: " Thomas De Schampheleire
@ 2019-02-15 21:08 ` Thomas De Schampheleire
  6 siblings, 0 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-15 21:08 UTC (permalink / raw)
  To: buildroot

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

For bzr, cvs and git, there is no method of checking whether the
revision exists remotely, without actually cloning the repository.
Therefore, there is no actual implementation for '-C' (checkonly) for these
download helpers. The script will fall back to the normal download logic,
which would effectively fail if the revision does not exist.

For completeness, mention this unimplemented feature in the usage text.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 support/download/bzr | 2 ++
 support/download/cvs | 2 ++
 support/download/git | 2 ++
 3 files changed, 6 insertions(+)

v4: remove 'svn' which now has an actual implementation

v3: no changes

diff --git a/support/download/bzr b/support/download/bzr
index 5289a421cd..278d8778af 100755
--- a/support/download/bzr
+++ b/support/download/bzr
@@ -7,6 +7,8 @@ set -e
 #
 # Options:
 #   -q          Be quiet
+#   -C          (unimplemented) Only check that the revision exists in the
+#               remote repository.
 #   -o FILE     Generate archive in FILE.
 #   -u URI      Clone from repository at URI.
 #   -c CSET     Use changeset (or revision) CSET.
diff --git a/support/download/cvs b/support/download/cvs
index 9d0dc3cb3a..d9a586293a 100755
--- a/support/download/cvs
+++ b/support/download/cvs
@@ -7,6 +7,8 @@ set -e
 #
 # Options:
 #   -q          Be quiet
+#   -C          (unimplemented) Only check that the revision exists in the
+#               remote repository.
 #   -o FILE     Generate archive in FILE.
 #   -u URI      Checkout from repository at URI.
 #   -c REV      Use revision REV.
diff --git a/support/download/git b/support/download/git
index 17ca04eb98..e9c02d6712 100755
--- a/support/download/git
+++ b/support/download/git
@@ -7,6 +7,8 @@ set -E
 #
 # Options:
 #   -q          Be quiet.
+#   -C          (unimplemented) Only check that the revision exists in the
+#               remote repository.
 #   -r          Clone and archive sub-modules.
 #   -o FILE     Generate archive in FILE.
 #   -u URI      Clone from repository at URI.
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH
  2019-02-15 21:08 ` [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH Thomas De Schampheleire
@ 2019-02-16 12:34   ` Yann E. MORIN
  2019-02-16 21:23     ` Thomas De Schampheleire
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2019-02-16 12:34 UTC (permalink / raw)
  To: buildroot

Thomas, All,

On 2019-02-15 22:08 +0100, Thomas De Schampheleire spake thusly:
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> 
> The BR2_SSH command was removed in commit
> db9473bf6cd7bd12aa1f9faad0a917c973c33827 ("core/download: drop the SSH
> command") but will be needed again to support 'source-check' for the scp
> download backend.

Rather than do a new commit, why did you not use "git revert"?

> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
>  Config.in               | 4 ++++
>  package/pkg-download.mk | 1 +
>  2 files changed, 5 insertions(+)
> 
> v4: no changes
> v3: no changes
> 
> diff --git a/Config.in b/Config.in
> index d58d8dc04a..91d56907fe 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -136,6 +136,10 @@ config BR2_SCP
>  	string "Secure copy (scp) command"
>  	default "scp"
>  
> +config BR2_SSH
> +	string "Secure shell (ssh) command"
> +	default "ssh"
> +
>  config BR2_HG
>  	string "Mercurial (hg) command"
>  	default "hg"
> diff --git a/package/pkg-download.mk b/package/pkg-download.mk
> index 5384fc2af4..17d1ca99ee 100644
> --- a/package/pkg-download.mk
> +++ b/package/pkg-download.mk
> @@ -15,6 +15,7 @@ export BZR := $(call qstrip,$(BR2_BZR))
>  export GIT := $(call qstrip,$(BR2_GIT))
>  export HG := $(call qstrip,$(BR2_HG))
>  export SCP := $(call qstrip,$(BR2_SCP))
> +export SSH := $(call qstrip,$(BR2_SSH))

To be noted: the commit you are (manually) reverting did not export SSH,
but now you do need to do so, because it will now be used from one of a
download backends, when the original use of SSH was done in Makefile
code.

Regards,
Yann E. MORIN.

>  export LOCALFILES := $(call qstrip,$(BR2_LOCALFILES))
>  
>  DL_WRAPPER = support/download/dl-wrapper
> -- 
> 2.19.2
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH
  2019-02-16 12:34   ` Yann E. MORIN
@ 2019-02-16 21:23     ` Thomas De Schampheleire
  2019-02-16 22:29       ` Yann E. MORIN
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas De Schampheleire @ 2019-02-16 21:23 UTC (permalink / raw)
  To: buildroot

El s?b., 16 feb. 2019 a las 13:34, Yann E. MORIN
(<yann.morin.1998@free.fr>) escribi?:
>
> Thomas, All,
>
> On 2019-02-15 22:08 +0100, Thomas De Schampheleire spake thusly:
> > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >
> > The BR2_SSH command was removed in commit
> > db9473bf6cd7bd12aa1f9faad0a917c973c33827 ("core/download: drop the SSH
> > command") but will be needed again to support 'source-check' for the scp
> > download backend.
>
> Rather than do a new commit, why did you not use "git revert"?

How does this make a difference when sending patches via email?

The background is that originally this change was put together with
the scp source-check implementation, which was based on the
implementation I had in my work repository, where BR2_SSH was not yet
removed. Only later I split this patch apart and didn't think of using
'git revert'.

>
> > Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> > ---
> >  Config.in               | 4 ++++
> >  package/pkg-download.mk | 1 +
> >  2 files changed, 5 insertions(+)
> >
> > v4: no changes
> > v3: no changes
> >
> > diff --git a/Config.in b/Config.in
> > index d58d8dc04a..91d56907fe 100644
> > --- a/Config.in
> > +++ b/Config.in
> > @@ -136,6 +136,10 @@ config BR2_SCP
> >       string "Secure copy (scp) command"
> >       default "scp"
> >
> > +config BR2_SSH
> > +     string "Secure shell (ssh) command"
> > +     default "ssh"
> > +
> >  config BR2_HG
> >       string "Mercurial (hg) command"
> >       default "hg"
> > diff --git a/package/pkg-download.mk b/package/pkg-download.mk
> > index 5384fc2af4..17d1ca99ee 100644
> > --- a/package/pkg-download.mk
> > +++ b/package/pkg-download.mk
> > @@ -15,6 +15,7 @@ export BZR := $(call qstrip,$(BR2_BZR))
> >  export GIT := $(call qstrip,$(BR2_GIT))
> >  export HG := $(call qstrip,$(BR2_HG))
> >  export SCP := $(call qstrip,$(BR2_SCP))
> > +export SSH := $(call qstrip,$(BR2_SSH))
>
> To be noted: the commit you are (manually) reverting did not export SSH,
> but now you do need to do so, because it will now be used from one of a
> download backends, when the original use of SSH was done in Makefile
> code.

Yes indeed, that is true.

Best regards,
Thomas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH
  2019-02-16 21:23     ` Thomas De Schampheleire
@ 2019-02-16 22:29       ` Yann E. MORIN
  0 siblings, 0 replies; 11+ messages in thread
From: Yann E. MORIN @ 2019-02-16 22:29 UTC (permalink / raw)
  To: buildroot

Thomas, All,

On 2019-02-16 22:23 +0100, Thomas De Schampheleire spake thusly:
> El s?b., 16 feb. 2019 a las 13:34, Yann E. MORIN
> (<yann.morin.1998@free.fr>) escribi?:
> > On 2019-02-15 22:08 +0100, Thomas De Schampheleire spake thusly:
> > > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> > >
> > > The BR2_SSH command was removed in commit
> > > db9473bf6cd7bd12aa1f9faad0a917c973c33827 ("core/download: drop the SSH
> > > command") but will be needed again to support 'source-check' for the scp
> > > download backend.
> >
> > Rather than do a new commit, why did you not use "git revert"?
> 
> How does this make a difference when sending patches via email?

git-revert prepares the git commit with appropriate information about
the revert:

    Revert "core/download: drop the SSH command"

    This reverts commit db9473bf6cd7bd12aa1f9faad0a917c973c33827.

And then you can amend the commit log to explain why it is reverted.

> The background is that originally this change was put together with
> the scp source-check implementation, which was based on the
> implementation I had in my work repository, where BR2_SSH was not yet
> removed. Only later I split this patch apart and didn't think of using
> 'git revert'.

OK, that explains it.

> > > +export SSH := $(call qstrip,$(BR2_SSH))
> > To be noted: the commit you are (manually) reverting did not export SSH,
> > but now you do need to do so, because it will now be used from one of a
> > download backends, when the original use of SSH was done in Makefile
> > code.
> Yes indeed, that is true.

And hence, as you are not reinstating the code exactly as it was prior
to the "reverted" commit, that should have been part of the commit log.

Anyway:

Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-02-16 22:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 21:07 [Buildroot] [PATCHv4 1/8] support/download: reintroduce 'source-check' target Thomas De Schampheleire
2019-02-15 21:07 ` [Buildroot] [PATCHv4 2/8] support/download/hg: implement source-check Thomas De Schampheleire
2019-02-15 21:07 ` [Buildroot] [PATCHv4 3/8] support/download/wget: " Thomas De Schampheleire
2019-02-15 21:07 ` [Buildroot] [PATCHv4 4/8] support/download/file: " Thomas De Schampheleire
2019-02-15 21:08 ` [Buildroot] [PATCHv4 5/8] Config.in: reintroduce BR2_SSH Thomas De Schampheleire
2019-02-16 12:34   ` Yann E. MORIN
2019-02-16 21:23     ` Thomas De Schampheleire
2019-02-16 22:29       ` Yann E. MORIN
2019-02-15 21:08 ` [Buildroot] [PATCHv4 6/8] support/download/scp: implement source-check Thomas De Schampheleire
2019-02-15 21:08 ` [Buildroot] [PATCHv4 7/8] support/download/svn: " Thomas De Schampheleire
2019-02-15 21:08 ` [Buildroot] [PATCHv4 8/8] support/download/{bzr, cvs, git}: highlight unimplemented source-check Thomas De Schampheleire

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.