[rtems-source-builder commit] sb: Add a download option --with-release-url /--without-release-url.

Chris Johns chrisj at rtems.org
Thu Mar 10 05:35:15 UTC 2016


Module:    rtems-source-builder
Branch:    4.11
Commit:    58a8fd8b5fd384cc92bd7d4fa97dcede5fb1b81b
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=58a8fd8b5fd384cc92bd7d4fa97dcede5fb1b81b

Author:    Chris Johns <chrisj at rtems.org>
Date:      Thu Mar 10 16:19:58 2016 +1100

sb: Add a download option --with-release-url/--without-release-url.

The default without the option is to prepend the release URL to the URL
list to download from the RTEMS FTP site first if the RSB is released. This
option can force the RTEMS FTP to be tried first when not a release,
or you can supply a different URL to download from or you can request
no RTEMS URL is tried first. Eg:

 --with-release-url
 --with-release-url=file://opt/local/cache
 --without-release-url

Move the RTEMS release URL to the default.mc file. Change the URL
to the RTEMS FTP server and do not use the https method of access.

The option's with_arg call was cleaned up to make sense.

Remove the log's raw output of an extra space.

Some download error message formating was cleaned up.

Closes #2636.

---

 rtems/config/rtems-urls.bset  |  5 -----
 source-builder/defaults.mc    |  3 +++
 source-builder/sb/download.py | 30 ++++++++++++++++++++++--------
 source-builder/sb/log.py      |  2 +-
 source-builder/sb/options.py  |  8 +++-----
 5 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/rtems/config/rtems-urls.bset b/rtems/config/rtems-urls.bset
index 13fb517..91e4bad 100644
--- a/rtems/config/rtems-urls.bset
+++ b/rtems/config/rtems-urls.bset
@@ -13,8 +13,3 @@
 %define rtems_gcc_patches      %{rtems_git_tools}/gcc
 %define rtems_newlib_patches   %{rtems_git_tools}/newlib
 %define rtems_gdb_patches      %{rtems_git_tools}/gdb
-
-#
-# Releases paths on the FTP server.
-#
-%define rtems_release_url https://ftp.rtems.org/pub/rtems/releases/%{rtems_version}
diff --git a/source-builder/defaults.mc b/source-builder/defaults.mc
index 44fa838..c65fa22 100644
--- a/source-builder/defaults.mc
+++ b/source-builder/defaults.mc
@@ -54,6 +54,9 @@ _host:               triplet, required, ''
 _build:              triplet, required, ''
 _target:             none,    optional, ''
 
+# RTEMS release URL
+rtems_release_url:   none,    none,     'ftp://ftp.rtems.org/pub/rtems/releases/%{rtems_version}'
+
 # The user
 _uid:                none,    convert,  '%(%{__id_u} -n)'
 
diff --git a/source-builder/sb/download.py b/source-builder/sb/download.py
index d218a9e..9facf06 100644
--- a/source-builder/sb/download.py
+++ b/source-builder/sb/download.py
@@ -336,7 +336,7 @@ def _http_downloader(url, local, config, opts):
         _chunk = None
         _last_percent = 200.0
         _last_msg = ''
-        _wipe_output = False
+        _have_status_output = False
         try:
             try:
                 _in = None
@@ -367,17 +367,16 @@ def _http_downloader(url, local, config, opts):
                         extras = (len(_last_msg) - len(_msg))
                         log.stdout_raw('%s%s' % (_msg, ' ' * extras + '\b' * extras))
                         _last_msg = _msg
+                        _have_status_output = True
                     _chunk = _in.read(_chunk_size)
                     if not _chunk:
                         break
                     _out.write(_chunk)
                     _have += len(_chunk)
-                if _wipe_output:
-                    log.stdout_raw('\r%s\r' % (' ' * len(_last_msg)))
-                else:
-                    log.stdout_raw('\n')
+                log.stdout_raw('\n\r')
             except:
-                log.stdout_raw('\n')
+                if _have_status_output:
+                    log.stdout_raw('\n\r')
                 raise
         except IOError as err:
             log.notice('download: %s: error: %s' % (url, str(err)))
@@ -557,11 +556,26 @@ def get_file(url, local, opts, config):
         raise error.general('source not found: %s' % (path.host(local)))
     #
     # Check if a URL has been provided on the command line. If the package is
-    # release push to the start the RTEMS URL.
+    # released push to the start the RTEMS URL unless overrided by the command
+    # line option --with-release-url. The variant --without-release-url can
+    # override the released check.
     #
     url_bases = opts.urls()
+    rtems_release_url_value = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources')
+    rtems_release_url = None
     if version.released():
-        rtems_release_url = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources')
+        rtems_release_url = rtems_release_url_value
+    with_rel_url = opts.with_arg('release-url')
+    if with_rel_url[0] == 'with_release-url':
+        if with_rel_url[1] == 'yes':
+            rtems_release_url = rtems_release_url_value
+        elif with_rel_url[1] == 'no':
+            pass
+        else:
+            rtems_release_url = with_rel_url[1]
+    elif with_rel_url[0] == 'without_release-url' and with_rel_url[1] == 'no':
+        rtems_release_url = rtems_release_url_value
+    if rtems_release_url is not None:
         log.trace('release url: %s' % (rtems_release_url))
         #
         # If the URL being fetched is under the release path do not add the
diff --git a/source-builder/sb/log.py b/source-builder/sb/log.py
index cc92dd3..b0a9001 100755
--- a/source-builder/sb/log.py
+++ b/source-builder/sb/log.py
@@ -62,7 +62,7 @@ def _output(text = os.linesep, log = None):
         sys.stdout.flush()
 
 def stdout_raw(text = os.linesep):
-    print(text, end=' ')
+    print(text, end = '')
     sys.stdout.flush()
 
 def stderr(text = os.linesep, log = None):
diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py
index cddc880..ba1eff0 100644
--- a/source-builder/sb/options.py
+++ b/source-builder/sb/options.py
@@ -460,7 +460,9 @@ class command_line:
             return None
         return self.parse_args(arg)
 
-    def with_arg(self, label):
+    def with_arg(self, label, default = 'not-found'):
+        # the default if there is no option for without.
+        result = default
         for pre in ['with', 'without']:
             arg_str = '--%s-%s' % (pre, label)
             arg_label = '%s_%s' % (pre, label)
@@ -471,10 +473,6 @@ class command_line:
                 else:
                     result = arg[1]
                 break
-            if pre == 'with':
-                result = 'yes'
-            else:
-                result = 'no'
         return [arg_label, result]
 
     def get_config_files(self, config):



More information about the vc mailing list