[LEDE-DEV] [PATCH] base-files: sysupgrade. Added the ability to use URL as source

Felix Fietkau nbd at nbd.name
Mon Jul 4 04:07:29 PDT 2016


On 2016-07-04 12:42, adron at yapic.net wrote:
> From: Sergey Sergeev <adron at yapic.net>
> 
> I did not encapsulate the logic in get_image() because too much code
> (like dd if=...) expects to work with the file instead of url. And
> use get_image would lead to repeated data reloads from url.
> 
> Signed-off-by: Sergey Sergeev <adron at yapic.net>
> ---
>  package/base-files/files/sbin/sysupgrade | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
> index 2f441f8..4391e95 100755
> --- a/package/base-files/files/sbin/sysupgrade
> +++ b/package/base-files/files/sbin/sysupgrade
> @@ -101,6 +101,26 @@ EOF
>  # prevent messages from clobbering the tarball when using stdout
>  [ "$CONF_BACKUP" = "-" ] && export VERBOSE=0
>  
> +wget_if_URL(){
> +	local sed_head='^.*\('
> +	local url_pattern='\(https\?\|ftp\)://[^ ]*'
> +	local sed_tail='\).*$'
> +	local url=$(echo "$ARGV" | sed -ne "s#$sed_head$url_pattern$sed_tail#\1#p")
> +	[ -z "$url" ] && return 1
This looks a bit convoluted, and there's no need to call sed or
subshells here. Why not just use something like this:

case "$ARGV" in
	http://*) ...
esac

- Felix



More information about the Lede-dev mailing list