Hello community,

here is the log from the commit of package linuxrc for openSUSE:Factory checked 
in at 2020-06-05 20:07:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/linuxrc (Old)
 and      /work/SRC/openSUSE:Factory/.linuxrc.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "linuxrc"

Fri Jun  5 20:07:24 2020 rev:285 rq:811147 version:7.0.17

Changes:
--------
--- /work/SRC/openSUSE:Factory/linuxrc/linuxrc.changes  2020-05-16 
22:23:45.752956438 +0200
+++ /work/SRC/openSUSE:Factory/.linuxrc.new.3606/linuxrc.changes        
2020-06-05 20:09:41.645637954 +0200
@@ -1,0 +2,7 @@
+Wed Jun 3 12:56:12 UTC 2020 - [email protected]
+
+- merge gh#openSUSE/linuxrc#224
+- replace $releasever in URLs, similar to libzypp (bsc#1171018)
+- 7.0.17
+
+--------------------------------------------------------------------

Old:
----
  linuxrc-7.0.16.tar.xz

New:
----
  linuxrc-7.0.17.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ linuxrc.spec ++++++
--- /var/tmp/diff_new_pack.9RFRXR/_old  2020-06-05 20:09:42.865641890 +0200
+++ /var/tmp/diff_new_pack.9RFRXR/_new  2020-06-05 20:09:42.869641903 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           linuxrc
-Version:        7.0.16
+Version:        7.0.17
 Release:        0
 Summary:        SUSE Installation Program
 License:        GPL-3.0+

++++++ linuxrc-7.0.16.tar.xz -> linuxrc-7.0.17.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/VERSION new/linuxrc-7.0.17/VERSION
--- old/linuxrc-7.0.16/VERSION  2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/VERSION  2020-06-03 14:56:12.000000000 +0200
@@ -1 +1 @@
-7.0.16
+7.0.17
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/changelog new/linuxrc-7.0.17/changelog
--- old/linuxrc-7.0.16/changelog        2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/changelog        2020-06-03 14:56:12.000000000 +0200
@@ -1,3 +1,7 @@
+2020-06-03:    7.0.17
+       - merge gh#openSUSE/linuxrc#224
+       - replace $releasever in URLs, similar to libzypp (bsc#1171018)
+
 2020-05-14:    7.0.16
        - merge gh#openSUSE/linuxrc#223
        - udevadm is in /usr/bin (bsc#1171587)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/global.h new/linuxrc-7.0.17/global.h
--- old/linuxrc-7.0.16/global.h 2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/global.h 2020-06-03 14:56:12.000000000 +0200
@@ -265,7 +265,6 @@
 typedef struct {
   char *str;
   instmode_t scheme;
-  instmode_t orig_scheme;
   char *server;
   char *share;
   char *path;
@@ -299,6 +298,16 @@
     char *model;
     char *unique_id;
   } used;
+  struct {
+    /*
+     * The original values of some url components that might get modified in 
url_set().
+     */
+    instmode_t scheme;
+    char *server;
+    char *share;
+    char *path;
+    char *instsys;
+  } orig;
 } url_t;
 
 
@@ -494,6 +503,7 @@
   char *serial;                        /**< serial console parameters, e.g. 
ttyS0,38400 or ttyS1,9600n8 */
   char *product;               /**< product name */
   char *product_dir;           /**< product specific dir component (e.g. 
'suse') */
+  char *releasever;            /**< product version, to be used for replacing 
$releasever in zypp */
   int kbdtimeout;              /**< keyboard timeout (in s) */
   int escdelay;                        /**< timeout to differ esc from 
function keys */
   int loglevel;                        /**< set kernel log level */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/linuxrc.c new/linuxrc-7.0.17/linuxrc.c
--- old/linuxrc-7.0.16/linuxrc.c        2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/linuxrc.c        2020-06-03 14:56:12.000000000 +0200
@@ -856,6 +856,8 @@
 
   config.platform_name=get_platform_name();
 
+  util_get_releasever();
+
   LXRC_WAIT
 
   if(util_check_exist("/sbin/mount.smbfs")) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/url.c new/linuxrc-7.0.17/url.c
--- old/linuxrc-7.0.16/url.c    2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/url.c    2020-06-03 14:56:12.000000000 +0200
@@ -93,6 +93,9 @@
 static int is_signed(char *file, int check);
 static unsigned url_scheme_attr(instmode_t scheme, char *attr_name);
 static void url_add_query_string(char **buf, int n, url_t *url);
+static char *url_replace_vars(char *url);
+static void url_replace_vars_with_backup(char **str, char **backup);
+
 
 // mapping of URL schemes to internal constants
 static struct {
@@ -553,7 +556,7 @@
     }
   }
 
-  url->orig_scheme = url->scheme;
+  url->orig.scheme = url->scheme;
 
   /* adjust some url schemes to support autoyast syntax */
   fixup_url_disk(url);
@@ -658,52 +661,71 @@
 
   log_debug("url = %s\n", url->str);
 
-  if(config.debug >= 2) {
-    log_debug(
-      "  scheme = %s (%d), orig scheme = %s (%d)",
-      url_scheme2name(url->scheme), url->scheme,
-      url_scheme2name(url->orig_scheme), url->orig_scheme
-    );
-    if(url->server) log_debug(", server = \"%s\"", url->server);
-    if(url->port) log_debug(", port = %u", url->port);
-    if(url->path) log_debug(", path = \"%s\"", url->path);
+  url_replace_vars_with_backup(&url->server, &url->orig.server);
+  url_replace_vars_with_backup(&url->share, &url->orig.share);
+  url_replace_vars_with_backup(&url->path, &url->orig.path);
+  url_replace_vars_with_backup(&url->instsys, &url->orig.instsys);
+
+  if(config.debug >= 2) url_log(url);
+
+  return url;
+}
+
+
+/*
+ * Detailed log of parsed url components.
+ */
+void url_log(url_t *url)
+{
+  int i;
+  slist_t *sl;
+
+  log_debug(
+    "  scheme = %s (%d), orig scheme = %s (%d)",
+    url_scheme2name(url->scheme), url->scheme,
+    url_scheme2name(url->orig.scheme), url->orig.scheme
+  );
+  if(url->server) log_debug(", server = \"%s\"", url->server);
+  if(url->orig.server) log_debug(", server (orig) = \"%s\"", url->orig.server);
+  if(url->port) log_debug(", port = %u", url->port);
+  if(url->path) log_debug(", path = \"%s\"", url->path);
+  if(url->orig.path) log_debug(", path (orig) = \"%s\"", url->orig.path);
+  log_debug("\n");
+
+  if(url->user || url->password) {
+    i = 0;
+    if(url->user) log_debug("%c user = \"%s\"", i++ ? ',' : ' ', url->user);
+    if(url->password) log_debug("%c password = \"%s\"", i++ ? ',' : ' ', 
url->password);
     log_debug("\n");
+  }
 
-    if(url->user || url->password) {
-      i = 0;
-      if(url->user) log_debug("%c user = \"%s\"", i++ ? ',' : ' ', url->user);
-      if(url->password) log_debug("%c password = \"%s\"", i++ ? ',' : ' ', 
url->password);
-      log_debug("\n");
-    }
-
-    if(url->share || url->domain || url->device) {
-      i = 0;
-      if(url->share) log_debug("%c share = \"%s\"", i++ ? ',' : ' ', 
url->share);
-      if(url->domain) log_debug("%c domain = \"%s\"", i++ ? ',' : ' ', 
url->domain);
-      if(url->device) log_debug("%c device = \"%s\"", i++ ? ',' : ' ', 
url->device);
-      log_debug("\n");
-    }
-
-    log_debug(
-      "  network = %u, blockdev = %u, mountable = %u, file = %u, dir = %u, all 
= %u, quiet = %u\n",
-      url->is.network, url->is.blockdev, url->is.mountable, url->is.file, 
url->is.dir,
-      url->search_all, url->quiet
-    );
+  if(url->share || url->domain || url->device) {
+    i = 0;
+    if(url->share) log_debug("%c share = \"%s\"", i++ ? ',' : ' ', url->share);
+    if(url->orig.share) log_debug("%c share (orig) = \"%s\"", i++ ? ',' : ' ', 
url->orig.share);
+    if(url->domain) log_debug("%c domain = \"%s\"", i++ ? ',' : ' ', 
url->domain);
+    if(url->device) log_debug("%c device = \"%s\"", i++ ? ',' : ' ', 
url->device);
+    log_debug("\n");
+  }
 
-    if(url->instsys) log_debug("  instsys = %s\n", url->instsys);
+  log_debug(
+    "  network = %u, blockdev = %u, mountable = %u, file = %u, dir = %u, all = 
%u, quiet = %u\n",
+    url->is.network, url->is.blockdev, url->is.mountable, url->is.file, 
url->is.dir,
+    url->search_all, url->quiet
+  );
 
-    if(url->query) {
-      log_debug("  query:\n");
-      for(sl = url->query; sl; sl = sl->next) {
-        log_debug("    %s = \"%s\"\n", sl->key, sl->value);
-      }
-    }
+  if(url->instsys) log_debug("  instsys = %s\n", url->instsys);
+  if(url->orig.instsys) log_debug("  instsys (orig) = %s\n", 
url->orig.instsys);
 
-    log_debug("url (zypp format) = %s\n", url_print(url, 4));
-    log_debug("url (ay format) = %s\n", url_print(url, 5));
+  if(url->query) {
+    log_debug("  query:\n");
+    for(sl = url->query; sl; sl = sl->next) {
+      log_debug("    %s = \"%s\"\n", sl->key, sl->value);
+    }
   }
 
-  return url;
+  log_debug("url (zypp format) = %s\n", url_print(url, 4));
+  log_debug("url (ay format) = %s\n", url_print(url, 5));
 }
 
 
@@ -973,13 +995,19 @@
 
 
 /*
- * according to zypp/media/MediaManager.h
+ * Construct URL suitable for zypp.
+ *
+ * See
+ *   - 
https://doc.opensuse.org/projects/libzypp/HEAD/classzypp_1_1media_1_1MediaManager.html#MediaAccessUrl
+ * for URL scheme documentation.
+ *
+ * This builds a URL without zypp variables replaced.
  */
 char *url_print_zypp(url_t *url)
 {
   static char *buf = NULL, *s;
   char *path = NULL, *file = NULL;
-  int q = 0, scheme;
+  int q = 0;
 
   // log_info("start buf = %p\n", buf);
   // LXRC_WAIT
@@ -991,8 +1019,12 @@
   }
 
   str_copy(&buf, NULL);
+  int scheme = url->scheme;
 
-  str_copy(&path, url->path);
+  /* prefer original values (without zypp variables replaced) */
+  char *server = url->orig.server ?: url->server;
+  char *share = url->orig.share ?: url->share;
+  str_copy(&path, url->orig.path ?: url->path);
 
   if(url->is.file && path) {
     if((file = strrchr(path, '/')) && *file) {
@@ -1003,8 +1035,6 @@
     }
   }
 
-  scheme = url->scheme;
-
   if(scheme == inst_disk) {
     scheme = url->is.cdrom ? inst_cdrom : inst_hd;
   }
@@ -1023,7 +1053,7 @@
 
   strprintf(&buf, "%s:", url_scheme2name(scheme));
 
-  if(url->domain || url->user || url->password || url->server || url->port) {
+  if(url->domain || url->user || url->password || server || url->port) {
     strprintf(&buf, "%s//", buf);
     if(url->domain) strprintf(&buf, "%s%s;", buf, url->domain);
     if(url->user) {
@@ -1037,18 +1067,18 @@
       curl_free(s);
     }
     if(url->user || url->password) strprintf(&buf, "%s@", buf);
-    if(url->server) {
-      if(strchr(url->server, ':')) {
-        strprintf(&buf, "%s[%s]", buf, url->server);
+    if(server) {
+      if(strchr(server, ':')) {
+        strprintf(&buf, "%s[%s]", buf, server);
       }
       else {
-        strprintf(&buf, "%s%s", buf, url->server);
+        strprintf(&buf, "%s%s", buf, server);
       }
     }
     if(url->port) strprintf(&buf, "%s:%u", buf, url->port);
   }
 
-  if(url->share) strprintf(&buf, "%s/%s", buf, url->share);
+  if(share) strprintf(&buf, "%s/%s", buf, share);
   if(path) {
     strprintf(&buf, "%s/%s%s",
       buf,
@@ -1135,10 +1165,10 @@
     if(url->used.device) {
       strprintf(&buf, "%s%s", buf, short_dev(url->used.device));
     }
-    else if(url->orig_scheme == inst_usb) {
+    else if(url->orig.scheme == inst_usb) {
       strprintf(&buf, "usb:/");
     }
-    else if(url->orig_scheme == inst_label) {
+    else if(url->orig.scheme == inst_label) {
       slist_t *sl;
       strprintf(&buf, "label://");
       if((sl = slist_getentry(url->query, "label"))) {
@@ -1244,6 +1274,11 @@
     slist_free(url->query);
     slist_free(url->file_list);
 
+    free(url->orig.server);
+    free(url->orig.share);
+    free(url->orig.path);
+    free(url->orig.instsys);
+
     free(url);
   }
 
@@ -3887,3 +3922,54 @@
     closedir(d);
   }
 }
+
+
+/*
+ * Replace zypp variables in string.
+ *
+ * Return new string.
+ *
+ * The returned value is a copy of the passed argument and must be freed later.
+ *
+ * Currently only $releasever and ${releasever} are replaced.
+ */
+char *url_replace_vars(char *str)
+{
+  static char *vars[] = { "${releasever}", "$releasever" };
+  char *res = NULL;
+
+  str_copy(&res, str);
+
+  if(!config.releasever) return res;
+
+  for(int i = 0; i < sizeof vars / sizeof *vars; i++) {
+    int len = strlen(vars[i]);
+    char *s;
+    if((s = strstr(res, vars[i]))) {
+      s[len - 1] = 0;
+      s[0] = 0;
+      strprintf(&res, "%s%s%s", res, config.releasever, s + len);
+    }
+  }
+
+  return res;
+}
+
+
+/*
+ * Replace zypp variables and store a backup of the original string.
+ */
+void url_replace_vars_with_backup(char **str, char **backup)
+{
+  if(!*str) return;
+
+  char *new_str = url_replace_vars(*str);
+
+  if(!strcmp(new_str, *str)) {
+    free(new_str);
+  }
+  else {
+    *backup = *str;
+    *str = new_str;
+  }
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/url.h new/linuxrc-7.0.17/url.h
--- old/linuxrc-7.0.16/url.h    2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/url.h    2020-06-03 14:56:12.000000000 +0200
@@ -51,6 +51,7 @@
 
 void url_read(url_data_t *url_data);
 url_t *url_set(char *str);
+void url_log(url_t *url);
 url_t *url_free(url_t *url);
 void url_cleanup(void);
 url_data_t *url_data_new(void);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/util.c new/linuxrc-7.0.17/util.c
--- old/linuxrc-7.0.16/util.c   2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/util.c   2020-06-03 14:56:12.000000000 +0200
@@ -1120,6 +1120,9 @@
   sprintf(buf, "product = \"%s\"", config.product);
   slist_append_str(&sl0, buf);
 
+  sprintf(buf, "release version: %s", config.releasever ?: "unset");
+  slist_append_str(&sl0, buf);
+
   sprintf(buf,
     "memory (MB): total %lld, free %lld (%lld), ramdisk %lld",
     (long long) config.memoryXXX.total >> 20,
@@ -3194,6 +3197,28 @@
 }
 
 
+/*
+ * Read product version from /usr/lib/os-release.
+ *
+ * The product version is used for replacing $releasever in URLs.
+ */
+void util_get_releasever()
+{
+  file_t *f0, *f;
+
+  f0 = file_read_file("/usr/lib/os-release", kf_none);
+
+  for(f = f0; f; f = f->next) {
+    if(!strcmp(f->key_str, "VERSION_ID")) {
+      str_copy(&config.releasever, f->value);
+      break;
+    }
+  }
+
+  file_free_file(f0);
+}
+
+
 /*
  * Rename SCSI devices so that usb and firewire devices are last.
  */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/linuxrc-7.0.16/util.h new/linuxrc-7.0.17/util.h
--- old/linuxrc-7.0.16/util.h   2020-05-14 10:32:49.000000000 +0200
+++ new/linuxrc-7.0.17/util.h   2020-06-03 14:56:12.000000000 +0200
@@ -82,6 +82,7 @@
 int util_is_mountable(char *file);
 void util_set_serial_console(char *str);
 void util_set_product_dir(char *prod);
+void util_get_releasever(void);
 
 void scsi_rename(void);
 


Reply via email to