Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package suseconnect-ng for openSUSE:Factory checked in at 2022-01-09 22:49:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/suseconnect-ng (Old) and /work/SRC/openSUSE:Factory/.suseconnect-ng.new.1892 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "suseconnect-ng" Sun Jan 9 22:49:56 2022 rev:5 rq:944747 version:0.0.5~git0.bbb5544 Changes: -------- --- /work/SRC/openSUSE:Factory/suseconnect-ng/suseconnect-ng.changes 2021-12-08 22:09:22.818874530 +0100 +++ /work/SRC/openSUSE:Factory/.suseconnect-ng.new.1892/suseconnect-ng.changes 2022-01-09 22:50:05.563279689 +0100 @@ -1,0 +2,28 @@ +Fri Jan 07 13:45:50 UTC 2022 - jan.s...@zerebecki.de + +- Update to version 0.0.5~git0.bbb5544: + * Switch from rubygem-ffi to fiddle + * Cleanup services during migration (bsc#1161891) + * Allow non-root users to see usage text + * Add option to not fail dup as much + * Move APIVersion declaration to file where it is used + * Add flag to enable/disable hwinfo test + * Add ARM cluster count to hwinfo and fix test + * Simplify parsing JSON error response + * Add --gpg-auto-import-keys for zypper ref + * Rename main.go to logging.go + * Fix typo + * Remove init() from the connect package + * Move CFG variable declaration to config.go + * Move AppName const to the file where it is used + * Use testing.Helper() in test helpers + * Add ppc64le support + * Disable UUID test + * Add test tools to BuildRequires + * Ignore UUID errors + * Run basic hwinfo sanity test on build service + * Update code comments to match shim behavior. + * Remove dependency on systemd + * Only run httputil DumpResponse when needed + +------------------------------------------------------------------- Old: ---- connect-ng-0.0.4~git0.64b80e9.tar.xz New: ---- connect-ng-0.0.5~git0.bbb5544.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ suseconnect-ng.spec ++++++ --- /var/tmp/diff_new_pack.EpoAF7/_old 2022-01-09 22:50:06.223280278 +0100 +++ /var/tmp/diff_new_pack.EpoAF7/_new 2022-01-09 22:50:06.227280282 +0100 @@ -1,7 +1,7 @@ # # spec file for package suseconnect-ng # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,8 +19,11 @@ %global provider_prefix github.com/SUSE/connect-ng %global import_path %{provider_prefix} +# set this to 1 to enable hwinfo test in %check +%global test_hwinfo 0 + Name: suseconnect-ng -Version: 0.0.4~git0.64b80e9 +Version: 0.0.5~git0.bbb5544 Release: 0 URL: https://github.com/SUSE/connect-ng License: LGPL-2.1-or-later @@ -32,6 +35,18 @@ BuildRequires: golang-packaging BuildRequires: ruby-devel BuildRequires: zypper +%if 0%{?test_hwinfo} +%global test_hwinfo_args -test-hwinfo +# packages required only for hwinfo tests +%ifarch %ix86 ia64 x86_64 %arm aarch64 +BuildRequires: dmidecode +%endif +%ifarch s390x +BuildRequires: s390-tools +%endif +BuildRequires: systemd +%endif # test_hwinfo + Obsoletes: SUSEConnect < 0.3.99 Provides: SUSEConnect = 0.3.99 Obsoletes: zypper-migration-plugin < 0.99 @@ -52,12 +67,12 @@ %ifarch s390x Requires: s390-tools %endif -Requires: systemd Requires: zypper # lscpu is only used on those %ifarch x86_64 aarch64 Requires: util-linux %endif +Recommends: systemd %description This package provides a command line tool for connecting a @@ -84,7 +99,6 @@ Summary: Ruby bindings for libsuseconnect library. Group: System/Management Requires: libsuseconnect -Requires: rubygem(ffi) %description -n suseconnect-ruby-bindings This package provides bindings needed to use libsuseconnect from Ruby scripts. @@ -124,7 +138,7 @@ rm -rf %buildroot/usr/share/go %check -%gotest -v %import_path/internal/connect +%gotest -v %import_path/internal/connect %{?test_hwinfo_args} %gotest -v %import_path/suseconnect make -C %_builddir/go/src/%import_path gofmt ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.EpoAF7/_old 2022-01-09 22:50:06.271280321 +0100 +++ /var/tmp/diff_new_pack.EpoAF7/_new 2022-01-09 22:50:06.271280321 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/SUSE/connect-ng.git</param> - <param name="changesrevision">64b80e975c8dc30cdcfc9d42787e4cae229e0a3c</param></service></servicedata> + <param name="changesrevision">ab5463a6e9a53d6f3ca1387937709a81786c989a</param></service></servicedata> (No newline at EOF) ++++++ connect-ng-0.0.4~git0.64b80e9.tar.xz -> connect-ng-0.0.5~git0.bbb5544.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/FETCH_HEAD new/connect-ng-0.0.5~git0.bbb5544/.git/FETCH_HEAD --- old/connect-ng-0.0.4~git0.64b80e9/.git/FETCH_HEAD 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/FETCH_HEAD 2022-01-07 12:37:57.000000000 +0100 @@ -1 +1 @@ -64b80e975c8dc30cdcfc9d42787e4cae229e0a3c branch 'main' of https://github.com/SUSE/connect-ng +bbb554428d31dac294f7be84805cfb4ecd42f6bf branch 'main' of https://github.com/SUSE/connect-ng diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/ORIG_HEAD new/connect-ng-0.0.5~git0.bbb5544/.git/ORIG_HEAD --- old/connect-ng-0.0.4~git0.64b80e9/.git/ORIG_HEAD 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/ORIG_HEAD 2022-01-07 12:37:57.000000000 +0100 @@ -1 +1 @@ -64b80e975c8dc30cdcfc9d42787e4cae229e0a3c +bbb554428d31dac294f7be84805cfb4ecd42f6bf Binary files old/connect-ng-0.0.4~git0.64b80e9/.git/index and new/connect-ng-0.0.5~git0.bbb5544/.git/index differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/logs/HEAD new/connect-ng-0.0.5~git0.bbb5544/.git/logs/HEAD --- old/connect-ng-0.0.4~git0.64b80e9/.git/logs/HEAD 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/logs/HEAD 2022-01-07 12:37:57.000000000 +0100 @@ -9,3 +9,6 @@ dacdd3b7623fda3a69fb5cfc271c8ef4048891ba 19e761bb2dee186b48f7f9318bdbaba8a6e6ad4d jan_osc <jan_osc@localhost.(none)> 1630104398 +0200 merge origin/main: Fast-forward 19e761bb2dee186b48f7f9318bdbaba8a6e6ad4d 64b80e975c8dc30cdcfc9d42787e4cae229e0a3c jan_osc <jan_osc@localhost.(none)> 1638369078 +0100 merge origin/main: Fast-forward 64b80e975c8dc30cdcfc9d42787e4cae229e0a3c 64b80e975c8dc30cdcfc9d42787e4cae229e0a3c jan_osc <jan_osc@localhost.(none)> 1638369078 +0100 reset: moving to main +64b80e975c8dc30cdcfc9d42787e4cae229e0a3c bbb554428d31dac294f7be84805cfb4ecd42f6bf jan_osc <jan_osc@localhost.(none)> 1640305348 +0100 merge origin/main: Fast-forward +bbb554428d31dac294f7be84805cfb4ecd42f6bf bbb554428d31dac294f7be84805cfb4ecd42f6bf jan_osc <jan_osc@localhost.(none)> 1640305348 +0100 reset: moving to main +bbb554428d31dac294f7be84805cfb4ecd42f6bf bbb554428d31dac294f7be84805cfb4ecd42f6bf jan_osc <jan_osc@localhost.(none)> 1641563150 +0100 reset: moving to main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/logs/refs/heads/main new/connect-ng-0.0.5~git0.bbb5544/.git/logs/refs/heads/main --- old/connect-ng-0.0.4~git0.64b80e9/.git/logs/refs/heads/main 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/logs/refs/heads/main 2022-01-07 12:37:57.000000000 +0100 @@ -7,3 +7,4 @@ ebef3b7c52fcde65172254107c52dd5e86b13c1e dacdd3b7623fda3a69fb5cfc271c8ef4048891ba jan_osc <jan_osc@localhost.(none)> 1627376447 +0200 merge origin/main: Fast-forward dacdd3b7623fda3a69fb5cfc271c8ef4048891ba 19e761bb2dee186b48f7f9318bdbaba8a6e6ad4d jan_osc <jan_osc@localhost.(none)> 1630104398 +0200 merge origin/main: Fast-forward 19e761bb2dee186b48f7f9318bdbaba8a6e6ad4d 64b80e975c8dc30cdcfc9d42787e4cae229e0a3c jan_osc <jan_osc@localhost.(none)> 1638369078 +0100 merge origin/main: Fast-forward +64b80e975c8dc30cdcfc9d42787e4cae229e0a3c bbb554428d31dac294f7be84805cfb4ecd42f6bf jan_osc <jan_osc@localhost.(none)> 1640305348 +0100 merge origin/main: Fast-forward diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/logs/refs/remotes/origin/main new/connect-ng-0.0.5~git0.bbb5544/.git/logs/refs/remotes/origin/main --- old/connect-ng-0.0.4~git0.64b80e9/.git/logs/refs/remotes/origin/main 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/logs/refs/remotes/origin/main 2022-01-07 12:37:57.000000000 +0100 @@ -6,3 +6,4 @@ ebef3b7c52fcde65172254107c52dd5e86b13c1e dacdd3b7623fda3a69fb5cfc271c8ef4048891ba jan_osc <jan_osc@localhost.(none)> 1627376447 +0200 fetch --tags: fast-forward dacdd3b7623fda3a69fb5cfc271c8ef4048891ba 19e761bb2dee186b48f7f9318bdbaba8a6e6ad4d jan_osc <jan_osc@localhost.(none)> 1630104398 +0200 fetch --tags: fast-forward 19e761bb2dee186b48f7f9318bdbaba8a6e6ad4d 64b80e975c8dc30cdcfc9d42787e4cae229e0a3c jan_osc <jan_osc@localhost.(none)> 1638369078 +0100 fetch --tags: fast-forward +64b80e975c8dc30cdcfc9d42787e4cae229e0a3c bbb554428d31dac294f7be84805cfb4ecd42f6bf jan_osc <jan_osc@localhost.(none)> 1640305347 +0100 fetch --tags: fast-forward Binary files old/connect-ng-0.0.4~git0.64b80e9/.git/objects/pack/pack-09db1516e74d0ddf8aca34679775296fe1a703b6.idx and new/connect-ng-0.0.5~git0.bbb5544/.git/objects/pack/pack-09db1516e74d0ddf8aca34679775296fe1a703b6.idx differ Binary files old/connect-ng-0.0.4~git0.64b80e9/.git/objects/pack/pack-09db1516e74d0ddf8aca34679775296fe1a703b6.pack and new/connect-ng-0.0.5~git0.bbb5544/.git/objects/pack/pack-09db1516e74d0ddf8aca34679775296fe1a703b6.pack differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/refs/heads/main new/connect-ng-0.0.5~git0.bbb5544/.git/refs/heads/main --- old/connect-ng-0.0.4~git0.64b80e9/.git/refs/heads/main 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/refs/heads/main 2022-01-07 12:37:57.000000000 +0100 @@ -1 +1 @@ -64b80e975c8dc30cdcfc9d42787e4cae229e0a3c +bbb554428d31dac294f7be84805cfb4ecd42f6bf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/refs/remotes/origin/main new/connect-ng-0.0.5~git0.bbb5544/.git/refs/remotes/origin/main --- old/connect-ng-0.0.4~git0.64b80e9/.git/refs/remotes/origin/main 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/refs/remotes/origin/main 2022-01-07 12:37:57.000000000 +0100 @@ -1 +1 @@ -64b80e975c8dc30cdcfc9d42787e4cae229e0a3c +bbb554428d31dac294f7be84805cfb4ecd42f6bf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/.git/refs/tags/v0.0.5 new/connect-ng-0.0.5~git0.bbb5544/.git/refs/tags/v0.0.5 --- old/connect-ng-0.0.4~git0.64b80e9/.git/refs/tags/v0.0.5 1970-01-01 01:00:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/.git/refs/tags/v0.0.5 2022-01-07 12:37:57.000000000 +0100 @@ -0,0 +1 @@ +aae5d12b0f684e7aff092c5a5ae0c37b7e78fd79 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/Dockerfile.yast new/connect-ng-0.0.5~git0.bbb5544/Dockerfile.yast --- old/connect-ng-0.0.4~git0.64b80e9/Dockerfile.yast 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/Dockerfile.yast 2022-01-07 12:37:57.000000000 +0100 @@ -1,7 +1,5 @@ FROM registry.opensuse.org/yast/head/containers/yast-ruby:latest -RUN zypper --no-gpg-checks --non-interactive install 'rubygem(ffi)' - RUN rm -r /usr/lib64/ruby/gems/*/gems/suse-connect-* # invalidate github cache diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/api.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/api.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/api.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/api.go 2022-01-07 12:37:57.000000000 +0100 @@ -5,11 +5,6 @@ "net/http" ) -const ( - // APIVersion is the SCC API version - APIVersion = "v4" -) - // announceSystem announces a system to SCC // https://scc.suse.com/connect/v4/documentation#/subscriptions/post_subscriptions_systems // The body parameter is produced by makeSysInfoBody() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/config.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/config.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/config.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/config.go 2022-01-07 12:37:57.000000000 +0100 @@ -11,6 +11,11 @@ "strings" ) +var ( + // CFG is the global struct for config + CFG = NewConfig() +) + const ( defaultConfigPath = "/etc/SUSEConnect" defaultBaseURL = "https://scc.suse.com" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/connection.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/connection.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/connection.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/connection.go 2022-01-07 12:37:57.000000000 +0100 @@ -11,6 +11,11 @@ "time" ) +const ( + appName = "SUSEConnect-ng" + sccAPIVersion = "v4" +) + type authType int const ( @@ -25,28 +30,28 @@ // parseError returns the error message from a SCC error response func parseError(body io.Reader) string { - var m map[string]interface{} - dec := json.NewDecoder(body) - if err := dec.Decode(&m); err == nil { - if errMsg, ok := m["localized_error"].(string); ok { - return errMsg - } - if errMsg, ok := m["error"].(string); ok { - return errMsg - } + var errResp struct { + Error string `json:"error"` + LocalizedError string `json:"localized_error"` } - return "" + if err := json.NewDecoder(body).Decode(&errResp); err != nil { + return "" + } + if errResp.LocalizedError != "" { + return errResp.LocalizedError + } + return errResp.Error } func addHeaders(req *http.Request) { req.Header.Add("Content-Type", "application/json") - accept := "application/json,application/vnd.scc.suse.com." + APIVersion + "+json" + accept := "application/json,application/vnd.scc.suse.com." + sccAPIVersion + "+json" req.Header.Add("Accept", accept) if CFG.Language != "" { req.Header.Add("Accept-Language", CFG.Language) } // REVISIT "Accept-Encoding" - disable gzip commpression on debug? - req.Header.Add("User-Agent", AppName+"/"+GetShortenedVersion()) + req.Header.Add("User-Agent", appName+"/"+GetShortenedVersion()) } func addAuthHeader(req *http.Request, auth authType) error { @@ -105,16 +110,21 @@ } req.URL.RawQuery = values.Encode() - reqBlob, _ := httputil.DumpRequestOut(req, true) - Debug.Printf("%s\n", reqBlob) + if isLoggerEnabled(Debug) { + reqBlob, _ := httputil.DumpRequestOut(req, true) + Debug.Printf("%s\n", reqBlob) + } resp, err := httpclient.Do(req) if err != nil { return nil, err } defer resp.Body.Close() - respBlob, _ := httputil.DumpResponse(resp, true) - Debug.Printf("%s\n", respBlob) + + if isLoggerEnabled(Debug) { + respBlob, _ := httputil.DumpResponse(resp, true) + Debug.Printf("%s\n", respBlob) + } if !successCode(resp.StatusCode) { errMsg := parseError(resp.Body) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/helpers_test.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/helpers_test.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/helpers_test.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/helpers_test.go 2022-01-07 12:37:57.000000000 +0100 @@ -3,20 +3,20 @@ import ( "os" "path/filepath" - "runtime" "testing" ) func readTestFile(name string, t *testing.T) []byte { + t.Helper() data, err := os.ReadFile(filepath.Join("../../testdata", name)) if err != nil { - _, filename, num, _ := runtime.Caller(1) - t.Fatalf("\n%s:%d: %s", filepath.Base(filename), num, err) + t.Fatal(err) } return data } func createTestCredentials(username, password string, t *testing.T) { + t.Helper() if username == "" { username = "test" } @@ -26,7 +26,6 @@ CFG.FsRoot = t.TempDir() err := writeSystemCredentials(username, password) if err != nil { - _, filename, num, _ := runtime.Caller(1) - t.Fatalf("\n%s:%d: %s", filepath.Base(filename), num, err) + t.Fatal(err) } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/hwinfo.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/hwinfo.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/hwinfo.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/hwinfo.go 2022-01-07 12:37:57.000000000 +0100 @@ -19,12 +19,14 @@ archX86 = "x86_64" archARM = "aarch64" archS390 = "s390x" + archPPC = "ppc64le" ) type hwinfo struct { Hostname string `json:"hostname"` Cpus int `json:"cpus"` Sockets int `json:"sockets"` + Clusters int `json:"-"` Hypervisor string `json:"hypervisor"` Arch string `json:"arch"` UUID string `json:"uuid"` @@ -41,25 +43,23 @@ hw.CloudProvider = cloudProvider() var lscpuM map[string]string - if hw.Arch == archX86 || hw.Arch == archARM { + if hw.Arch == archX86 || hw.Arch == archARM || hw.Arch == archPPC { if lscpuM, err = lscpu(); err != nil { return hwinfo{}, err } hw.Cpus, _ = strconv.Atoi(lscpuM["CPU(s)"]) hw.Sockets, _ = strconv.Atoi(lscpuM["Socket(s)"]) - if hw.UUID, err = uuid(); err != nil { - return hwinfo{}, err - } + hw.UUID, _ = uuid() // ignore error to match original } - if hw.Arch == archX86 { + if hw.Arch == archX86 || hw.Arch == archPPC { hw.Hypervisor = lscpuM["Hypervisor vendor"] } if hw.Arch == archARM { - if hw.Hypervisor, err = hypervisor(); err != nil { - return hwinfo{}, err - } + hw.Clusters, _ = strconv.Atoi(lscpuM["Cluster(s)"]) + // ignore errors to avoid failing on systems without systemd + hw.Hypervisor, _ = hypervisor() } if hw.Arch == archS390 { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/hwinfo_test.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/hwinfo_test.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/hwinfo_test.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/hwinfo_test.go 2022-01-07 12:37:57.000000000 +0100 @@ -1,10 +1,13 @@ package connect import ( + "flag" "net" "testing" ) +var testHwinfo = flag.Bool("test-hwinfo", false, "") + func TestLscpu2mapPhysical(t *testing.T) { m := lscpu2map(readTestFile("lscpu_phys.txt", t)) @@ -121,3 +124,33 @@ } } } + +func TestGetHwinfo(t *testing.T) { + if !*testHwinfo { + t.SkipNow() + } + hw, err := getHwinfo() + t.Logf("HW info: %+v", hw) + if err != nil { + t.Fatalf("getHwinfo() failed: %s", err) + } + if hw.Hostname == "" { + t.Error(`Hostname=="", expected not empty`) + } + // reading UUID requires root access which is not available in build env + // if hw.UUID == "" { + // t.Errorf(`UUID=="", expected not empty`) + // } + if hw.Cpus == 0 { + t.Error("Cpus==0, expected>0") + } + if hw.Sockets == 0 { + // on ARM clusters, lscpu can return "Socket(s): -" if DMI is not accessible + // this parses to hw.Sockets == 0 so we need to skip this test in those cases + if hw.Arch == archARM && hw.Clusters > 0 { + t.Log("Reading number of sockets failed on ARM cluster (DMI not accessible?). Check skipped.") + } else { + t.Error("Sockets==0, expected>0") + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/logging.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/logging.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/logging.go 1970-01-01 01:00:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/logging.go 2022-01-07 12:37:57.000000000 +0100 @@ -0,0 +1,38 @@ +package connect + +import ( + "fmt" + "io" + "log" + "os" +) + +var ( + // Debug logger for debugging output + Debug = log.New(io.Discard, "", 0) + // Info logger for standard info output + Info = log.New(os.Stdout, "", 0) + // QuietOut is used to simplify --quiet option + QuietOut = log.New(io.Discard, "", 0) +) + +// EnableDebug turns on debugging output +func EnableDebug() { + Debug.SetOutput(os.Stderr) +} + +func isLoggerEnabled(l *log.Logger) bool { + return l.Writer() != io.Discard +} + +func greenText(text string) string { + return fmt.Sprintf("\x1b[32m%s\x1b[0m", text) +} + +func redText(text string) string { + return fmt.Sprintf("\x1b[31m%s\x1b[0m", text) +} + +func bold(text string) string { + return fmt.Sprintf("\x1b[1m%s\x1b[0m", text) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/main.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/main.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/main.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/main.go 1970-01-01 01:00:00.000000000 +0100 @@ -1,47 +0,0 @@ -package connect - -import ( - "fmt" - "io" - "log" - "os" -) - -const ( - // AppName holds the name of this SUSE connect client - AppName = "SUSEConnect-ng" // REVISIT -) - -var ( - // CFG is the global struct for config - CFG = NewConfig() - // Debug logger for debugging output - Debug *log.Logger - // Info logger for standard info output - Info *log.Logger - // QuietOut is used to simplify --quiet option - QuietOut *log.Logger -) - -func init() { - Debug = log.New(io.Discard, "", 0) - Info = log.New(os.Stdout, "", 0) - QuietOut = log.New(io.Discard, "", 0) -} - -// EnableDebug turns on debugging output -func EnableDebug() { - Debug.SetOutput(os.Stderr) -} - -func greenText(text string) string { - return fmt.Sprintf("\x1b[32m%s\x1b[0m", text) -} - -func redText(text string) string { - return fmt.Sprintf("\x1b[31m%s\x1b[0m", text) -} - -func bold(text string) string { - return fmt.Sprintf("\x1b[1m%s\x1b[0m", text) -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/system.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/system.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/system.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/system.go 2022-01-07 12:37:57.000000000 +0100 @@ -2,7 +2,6 @@ import ( "bytes" - "fmt" "io" "os" "os/exec" @@ -94,7 +93,7 @@ } // remove all suse services from zypper - services, err := installedServices() + services, err := InstalledServices() if err != nil { return err } @@ -104,7 +103,7 @@ // on the configuration (e.g. listen on https but API // returns URL with http). if !strings.Contains(service.URL, CFG.BaseURL) { - fmt.Printf("%s not in %s\n", CFG.BaseURL, service.URL) + Debug.Printf("%s not in %s\n", CFG.BaseURL, service.URL) continue } if err := removeService(service.Name); err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/internal/connect/zypper.go new/connect-ng-0.0.5~git0.bbb5544/internal/connect/zypper.go --- old/connect-ng-0.0.4~git0.64b80e9/internal/connect/zypper.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/internal/connect/zypper.go 2022-01-07 12:37:57.000000000 +0100 @@ -99,7 +99,8 @@ return products.Products, nil } -func installedServices() ([]Service, error) { +// InstalledServices returns list of services installed on the system +func InstalledServices() ([]Service, error) { args := []string{"--xmlout", "--non-interactive", "services", "-d"} // Don't fail when zypper exits with 6 (no repositories) output, err := zypperRun(args, []int{zypperOK, zypperErrNoRepos}) @@ -255,12 +256,15 @@ } // RefreshRepos runs zypper to refresh all repositories -func RefreshRepos(version string, force bool, quiet bool, verbose bool, nonInteractive bool) error { +func RefreshRepos(version string, force, quiet, verbose, nonInteractive, importKeys bool) error { args := []string{"ref"} flags := zypperFlags(version, quiet, verbose, nonInteractive, false) if force { args = append(args, "-f") } + if importKeys { + args = append(args, "--gpg-auto-import-keys") + } args = append(flags, args...) _, err := zypperRun(args, []int{zypperOK}) return err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/suseconnect/migration.go new/connect-ng-0.0.5~git0.bbb5544/suseconnect/migration.go --- old/connect-ng-0.0.4~git0.64b80e9/suseconnect/migration.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/suseconnect/migration.go 2022-01-07 12:37:57.000000000 +0100 @@ -49,21 +49,23 @@ func migrationMain() { var ( - debug bool - verbose bool - quiet bool - nonInteractive bool - noSnapshots bool - noSelfUpdate bool - breakMySystem bool - query bool - disableRepos bool - migrationNum int - fsRoot string - toProduct string - from multiArg - repo multiArg - download multiArg // using multiArg here to make flags simpler to visit + debug bool + verbose bool + quiet bool + nonInteractive bool + noSnapshots bool + noSelfUpdate bool + breakMySystem bool + query bool + disableRepos bool + autoImportKeys bool + failDupOnlyOnFatalErrors bool + migrationNum int + fsRoot string + toProduct string + from multiArg + repo multiArg + download multiArg // using multiArg here to make flags simpler to visit ) flag.Usage = func() { @@ -85,6 +87,8 @@ flag.BoolVar(&breakMySystem, "break-my-system", false, "") flag.BoolVar(&query, "query", false, "") flag.BoolVar(&disableRepos, "disable-repos", false, "") + flag.BoolVar(&autoImportKeys, "gpg-auto-import-keys", false, "") + flag.BoolVar(&failDupOnlyOnFatalErrors, "strict-errors-dist-migration", false, "") flag.IntVar(&migrationNum, "migration", 0, "") flag.StringVar(&fsRoot, "root", "", "") flag.StringVar(&toProduct, "product", "", "") @@ -190,7 +194,7 @@ // This is only necessary, if we run with --root option echo := connect.SetSystemEcho(true) - if err := connect.RefreshRepos("", false, quiet, verbose, nonInteractive); err != nil { + if err := connect.RefreshRepos("", false, quiet, verbose, nonInteractive, autoImportKeys); err != nil { fmt.Println("repository refresh failed, exiting") os.Exit(1) } @@ -310,7 +314,8 @@ dupArgs := zypperDupArgs() fsInconsistent, err := applyMigration(migration, systemProducts, - quiet, verbose, nonInteractive, disableRepos, dupArgs) + quiet, verbose, nonInteractive, disableRepos, + failDupOnlyOnFatalErrors, dupArgs) if err != nil { fmt.Println(err) @@ -543,6 +548,14 @@ return nil } +// checks if given service is provided by SUSE +func isSUSEService(service connect.Service) bool { + return strings.Contains(service.URL, connect.CFG.BaseURL) || + strings.Contains(service.URL, "plugin:/susecloud") || + strings.Contains(service.URL, "plugin:susecloud") || + strings.Contains(service.URL, "susecloud.net") +} + // updates system records in SCC/SMT // adds/removes services to match target state // disables obsolete repos @@ -550,6 +563,9 @@ func migrateSystem(migration connect.MigrationPath, forceDisableRepos bool) (string, error) { var baseProductVersion string + systemServices, _ := connect.InstalledServices() + migratedServices := connect.NewStringSet() + for _, p := range migration { msg := "Upgrading product " + p.FriendlyName QuietOut.Println(msg) @@ -585,6 +601,19 @@ if interrupted { return baseProductVersion, fmt.Errorf("%s: %v", msg, ErrInterrupted) } + // mark OLD service as migrated to skip it from cleanup step below + migratedServices.Add(service.ObsoletedName) + } + // remove SUSE services which don't have migration available (bsc#1161891) + for _, s := range systemServices { + if isSUSEService(s) && !migratedServices.Contains(s.Name) { + msg := "Removing service " + s.Name + " (no migration available)" + VerboseOut.Println(msg) + err := connect.MigrationRemoveService(s.Name) + if err != nil { + return baseProductVersion, fmt.Errorf("%s: %v", msg, err) + } + } } return baseProductVersion, nil } @@ -599,9 +628,25 @@ return false } +func isFatalZypperError(code int) bool { + // In zypper any return code == 0 or >= 100 is considered success. + // Any return code different from 0 and < 100 is treated as an + // error we care for. Return codes >= 100 indicates an issue + // like 'new kernel needs reboot of the system' or similar which + // cam be ignored in the scope of migrating + if code == 0 || code >= 100 { + // Treat the following exit codes as error + // 104 - ZYPPER_EXIT_INF_CAP_NOT_FOUND + // 105 - ZYPPER_EXIT_ON_SIGNAL + // 106 - ZYPPER_EXIT_INF_REPOS_SKIPPED + return code == 104 || code == 105 || code == 106 + } + return true +} + // returns fs_inconsistent flag func applyMigration(migration connect.MigrationPath, systemProducts []connect.Product, - quiet, verbose, nonInteractive, forceDisableRepos bool, + quiet, verbose, nonInteractive, forceDisableRepos, failDupOnlyOnFatalErrors bool, dupArgs []string) (bool, error) { fsInconsistent := false @@ -635,7 +680,7 @@ } echo := connect.SetSystemEcho(true) - if err := connect.RefreshRepos(baseProductVersion, true, false, false, false); err != nil { + if err := connect.RefreshRepos(baseProductVersion, true, false, false, false, false); err != nil { return fsInconsistent, fmt.Errorf("Refresh of repositories failed: %v", err) } if interrupted { @@ -644,9 +689,16 @@ err = connect.DistUpgrade(baseProductVersion, quiet, verbose, nonInteractive, dupArgs) connect.SetSystemEcho(echo) - // TODO: export connect.zypperErrCommit (8)? - if err != nil && err.(connect.ZypperError).ExitCode == 8 { - fsInconsistent = true + if err != nil { + ze := err.(connect.ZypperError) + // TODO: export connect.zypperErrCommit (8)? + if ze.ExitCode == 8 { + fsInconsistent = true + } + // ignore some non-fatal errors + if failDupOnlyOnFatalErrors && !isFatalZypperError(ze.ExitCode) { + err = nil + } } if interrupted { return fsInconsistent, ErrInterrupted @@ -682,7 +734,7 @@ wanted := connect.NewStringSet("auto-agree-with-licenses", "l", "allow-vendor-change", "no-allow-vendor-change", "debug-solver", "recommends", "no-recommends", - "replacefiles:", "details", "download", + "replacefiles", "details", "download", "download-only", "from", "repo") args := []string{} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/suseconnect/migrationUsage.txt new/connect-ng-0.0.5~git0.bbb5544/suseconnect/migrationUsage.txt --- old/connect-ng-0.0.4~git0.64b80e9/suseconnect/migrationUsage.txt 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/suseconnect/migrationUsage.txt 2022-01-07 12:37:57.000000000 +0100 @@ -10,6 +10,9 @@ --from REPO Restrict upgrade to specified repository -r, --repo REPO Load only the specified repository -l, --auto-agree-with-licenses Automatically say 'yes' to third party license confirmation prompt + --gpg-auto-import-keys Automatically trust and import new repository signing keys + --strict-errors-dist-migration + Handle only breaking distro migration errors --debug-solver Create solver test case for debugging --recommends Install also recommended packages --no-recommends Do not install recommended packages diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/suseconnect/suseconnect.go new/connect-ng-0.0.5~git0.bbb5544/suseconnect/suseconnect.go --- old/connect-ng-0.0.4~git0.64b80e9/suseconnect/suseconnect.go 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/suseconnect/suseconnect.go 2022-01-07 12:37:57.000000000 +0100 @@ -77,11 +77,11 @@ flag.StringVar(&email, "email", "", "") flag.StringVar(&email, "e", "", "") + flag.Parse() if os.Geteuid() != 0 { fmt.Fprintln(os.Stderr, "Root privileges are required to register products and change software repositories.") os.Exit(1) } - flag.Parse() if debug { connect.EnableDebug() } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/suseconnect-ng.spec new/connect-ng-0.0.5~git0.bbb5544/suseconnect-ng.spec --- old/connect-ng-0.0.4~git0.64b80e9/suseconnect-ng.spec 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/suseconnect-ng.spec 2022-01-07 12:37:57.000000000 +0100 @@ -18,6 +18,9 @@ %global provider_prefix github.com/SUSE/connect-ng %global import_path %{provider_prefix} +# set this to 1 to enable hwinfo test in %check +%global test_hwinfo 0 + Name: suseconnect-ng Version: 0.0.3~git112.d4980ea Release: 0 @@ -31,6 +34,18 @@ BuildRequires: go >= 1.16 BuildRequires: zypper BuildRequires: ruby-devel +%if 0%{?test_hwinfo} +%global test_hwinfo_args -test-hwinfo +# packages required only for hwinfo tests +%ifarch %ix86 ia64 x86_64 %arm aarch64 +BuildRequires: dmidecode +%endif +%ifarch s390x +BuildRequires: s390-tools +%endif +BuildRequires: systemd +%endif # test_hwinfo + Obsoletes: SUSEConnect < 0.3.99 Provides: SUSEConnect = 0.3.99 Obsoletes: zypper-migration-plugin < 0.99 @@ -51,12 +66,12 @@ %ifarch s390x Requires: s390-tools %endif -Requires: systemd Requires: zypper # lscpu is only used on those %ifarch x86_64 aarch64 Requires: util-linux %endif +Recommends: systemd %description This package provides a command line tool for connecting a @@ -82,7 +97,6 @@ Summary: Ruby bindings for libsuseconnect library. Group: System/Management Requires: libsuseconnect -Requires: rubygem(ffi) %description -n suseconnect-ruby-bindings This package provides bindings needed to use libsuseconnect from Ruby scripts. @@ -121,7 +135,7 @@ rm -rf %buildroot/usr/share/go %check -%gotest -v %import_path/internal/connect +%gotest -v %import_path/internal/connect %{?test_hwinfo_args} %gotest -v %import_path/suseconnect make -C %_builddir/go/src/%import_path gofmt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/yast/README.md new/connect-ng-0.0.5~git0.bbb5544/yast/README.md --- old/connect-ng-0.0.4~git0.64b80e9/yast/README.md 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/yast/README.md 2022-01-07 12:37:57.000000000 +0100 @@ -32,7 +32,7 @@ YaST passes strings and hashes as parameters. The hashes will be converted to JSON and passed on to libsuseconnect as strings. -Southbound the shim uses the Ruby [FFI](https://github.com/ffi/ffi) (Foreign Function Interface) gem to interface with the C library provided by libsuseconnect. Libsuseconnect will return JSON with the results or error details if there was a problem. The shim will raise an exception if there was an error. Otherwise the results will be returned in whatever form YaST is expecting. +Southbound the shim uses the Ruby [Fiddle](https://github.com/ruby/fiddle) FFI (Foreign Function Interface) extension to interface with the C library provided by libsuseconnect. Libsuseconnect will return JSON with the results or error details if there was a problem. The shim will raise an exception if there was an error. Otherwise the results will be returned in whatever form YaST is expecting. Note that generic OpenStruct is used for most structures instead of specific classes like in Ruby SUSEConnect. This should not be a problem because most SUSEConnect structures are anyway based on OpenStruct. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/logger.rb new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/logger.rb --- old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/logger.rb 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/logger.rb 2022-01-07 12:37:57.000000000 +0100 @@ -1,6 +1,6 @@ require 'logger' require 'singleton' -require 'ffi' +require 'fiddle' module SUSE module Connect @@ -28,23 +28,26 @@ GoConnect.set_log_callback(LogLine) end - LogLine = ::FFI::Function.new(:void, [:int, :string]) do |level, message| - log = GlobalLogger.instance.log - case level - when LL_DEBUG - log.debug(message) - when LL_INFO - log.info(message) - when LL_WARNING - log.warn(message) - when LL_ERROR - log.error(message) - when LL_FATAL - log.fatal(message) - else - raise 'unknown log level, msg=#{message}' + LogLine = Class.new(Fiddle::Closure) { + def call(level, message) + log = GlobalLogger.instance.log + message = message.to_s + case level + when LL_DEBUG + log.debug(message) + when LL_INFO + log.info(message) + when LL_WARNING + log.warn(message) + when LL_ERROR + log.error(message) + when LL_FATAL + log.fatal(message) + else + raise 'unknown log level, msg=#{message}' + end end - end + }.new(Fiddle::TYPE_VOID, [Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP]) end # Module provides access to specific logging. To set logging see GlobalLogger. # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/package_search.rb new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/package_search.rb --- old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/package_search.rb 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/package_search.rb 2022-01-07 12:37:57.000000000 +0100 @@ -2,8 +2,7 @@ module SUSE module Connect - # Enable connect and zypper extensions/scripts to search packages for a - # certain product + # Enable extensions/scripts to search packages for a certain product class PackageSearch class << self include SUSE::Toolkit::ShimUtils @@ -15,7 +14,7 @@ # @param product [SUSE::Connect::Zypper::Product] product to base search on # @param config_params [<Hash>] overwrites from the config file # - # @return [Array< <Hash>>] Returns all matched packages or an empty array if no matches where found + # @return [Array< OpenStruct >] Returns all matched packages or an empty array if no matches where found def search(query, product: nil, config_params: {}) # NOTE: product and config_params above are named parameters unlike the rest of # Connect interface diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/status.rb new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/status.rb --- old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/status.rb 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/status.rb 2022-01-07 12:37:57.000000000 +0100 @@ -6,7 +6,6 @@ # and subscriptions as known by registration server. # At first it collects all installed products from the system, then it gets its `activations` # from the registration server. This information is merged and printed out. - # rubocop:disable ClassLength class Status include SUSE::Toolkit::ShimUtils diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/yast.rb new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/yast.rb --- old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/connect/yast.rb 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/connect/yast.rb 2022-01-07 12:37:57.000000000 +0100 @@ -1,41 +1,39 @@ require 'json' -require 'ffi' +require 'fiddle/import' require 'suse/toolkit/shim_utils' -# TODO -# - review comments on ruby shim functions (e.g. return types) - module Stdio - extend FFI::Library - ffi_lib FFI::Platform::LIBC - attach_function :free, [ :pointer ], :void + extend Fiddle::Importer + dlload 'libc.so.6' + typealias 'pointer', 'void*' + extern 'void free(pointer)' end module GoConnect - extend FFI::Library - ffi_lib 'suseconnect' - - callback :log_line, [:int, :string], :void - attach_function :set_log_callback, [:log_line], :void - - attach_function :announce_system, [:string, :string], :pointer - attach_function :update_system, [:string, :string], :pointer - attach_function :credentials, [:string], :pointer - attach_function :create_credentials_file, [:string, :string, :string], :pointer - attach_function :curlrc_credentials, [], :pointer - attach_function :show_product, [:string, :string], :pointer - attach_function :activated_products, [:string], :pointer - attach_function :activate_product, [:string, :string, :string], :pointer - attach_function :get_config, [:string], :pointer - attach_function :write_config, [:string], :pointer - attach_function :update_certificates, [], :pointer - attach_function :list_installer_updates, [:string, :string], :pointer - attach_function :system_migrations, [:string, :string], :pointer - attach_function :offline_system_migrations, [:string, :string, :string], :pointer - attach_function :upgrade_product, [:string, :string], :pointer - attach_function :synchronize, [:string, :string], :pointer - attach_function :system_activations, [:string], :pointer - attach_function :search_package, [:string, :string, :string], :pointer + extend Fiddle::Importer + dlload 'libsuseconnect.so' + typealias 'string', 'char*' + + #callback type: void log_line(int, string) + extern 'void set_log_callback(void*)' + extern 'string announce_system(string, string)' + extern 'string update_system(string, string)' + extern 'string credentials(string)' + extern 'string create_credentials_file(string, string, string)' + extern 'string curlrc_credentials()' + extern 'string show_product(string, string)' + extern 'string activated_products(string)' + extern 'string activate_product(string, string, string)' + extern 'string get_config(string)' + extern 'string write_config(string)' + extern 'string update_certificates()' + extern 'string list_installer_updates(string, string)' + extern 'string system_migrations(string, string)' + extern 'string offline_system_migrations(string, string, string)' + extern 'string upgrade_product(string, string)' + extern 'string synchronize(string, string)' + extern 'string system_activations(string)' + extern 'string search_package(string, string, string)' end module SUSE @@ -56,7 +54,7 @@ # Additionally, distro_target should be set to avoid calls to Zypper. # Returns the system credentials from SCC. # - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # @param [String] distro_target desired distro target # # @return [Array <String>] SCC / system credentials - login and password tuple @@ -67,7 +65,7 @@ end # Updates the systems hardware info on the server - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # @param [String] distro_target desired distro target def update_system(client_params = {}, distro_target = nil) _set_verify_callback(client_params[:verify_callback]) @@ -76,15 +74,15 @@ end # Activates a product on SCC / the registration server. - # Expects product_ident parameter to be a hash identifying the product. + # Expects product parameter to identify the product. # Requires a token / regcode except for free products/extensions. # Returns a service object for the activated product. # # @param [OpenStruct] product with identifier, arch and version defined - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # @param [String] email email to which this activation should be connected to # - # @return [Service] Service + # @return [OpenStruct] Service object as openstruct def activate_product(product, client_params = {}, email = nil) _set_verify_callback(client_params[:verify_callback]) jsn_params = JSON.generate(client_params) @@ -93,15 +91,15 @@ end # Upgrades a product on SCC / the registration server. - # Expects product_ident parameter to be a hash identifying the new product. + # Expects product parameter to identify the product. # Token / regcode is not required. The new product needs to be available to the regcode the old # product was registered with, or be a free product. # Returns a service object for the new activated product. # # @param [OpenStruct] product with identifier, arch and version defined - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # - # @return [Service] Service + # @return [OpenStruct] Service object as openstruct def upgrade_product(product, client_params = {}) _set_verify_callback(client_params[:verify_callback]) jsn_params = JSON.generate(client_params) @@ -110,22 +108,22 @@ end # Downgrades a product on SCC / the registration server. - # Expects product_ident parameter to be a hash identifying the new product. + # Expects product parameter to identify the product. # Token / regcode is not required. The new product needs to be available to the regcode the old # product was registered with, or be a free product. # Returns a service object for the new activated product. # # @param [OpenStruct] product with identifier, arch and version defined - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # - # @return [Service] Service + # @return [OpenStruct] Service object as openstruct alias_method :downgrade_product, :upgrade_product # Synchronize activated system products with registration server. # This will remove obsolete activations on the server after all installed products went through a downgrade(). # # @param [OpenStruct] products - list of activated system products with identifier, arch and version defined - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config def synchronize(products, client_params = {}) _set_verify_callback(client_params[:verify_callback]) jsn_params = JSON.generate(client_params) @@ -152,12 +150,12 @@ end # Lists all available products for a system. - # Accepts a parameter product_ident, which scopes the result set down to all + # Accepts a parameter product, which scopes the result set down to all # products for the system that are extensions to the specified product. # Gets the list from SCC and returns them. # # @param [OpenStruct] product to list extensions for - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # # @return [OpenStruct] {Product} from registration server with all extensions included def show_product(product, client_params = {}) @@ -173,7 +171,7 @@ # be upgraded. # # @param [Array <OpenStruct>] the list of currently installed {Product}s in the system - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # # @return [Array <Array <OpenStruct>>] the list of possible migration paths for the given {Product}s, # where a migration path is an array of OpenStruct objects with the attributes @@ -192,7 +190,7 @@ # # @param installed_products [Array <OpenStruct>] the list of currently installed {Product}s in the system # @param target_base_product [OpenStruct] the {Product} that the system wants to upgrade to - # @param client_params [Hash] parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config # # @return [Array <Array <OpenStruct>>] the list of possible migration paths for the given {Product}s, # where a migration path is an array of OpenStruct objects with the attributes @@ -207,8 +205,8 @@ # List available Installer-Updates repositories for the given product # - # @param [Remote::Product] list repositories for this product - # @param [Hash] client_params parameters to instantiate {Client} + # @param [OpenStruct] list repositories for this product + # @param [Hash] client_params parameters to override SUSEConnect config # # @return [Array <OpenStruct>] list of Installer-Updates repositories def list_installer_updates(product, client_params = {}) @@ -219,11 +217,8 @@ end # Writes the config file with the given parameters, overwriting any existing contents - # Only persistent connection parameters (url, insecure) are written by this method - # Regcode, language, debug etc are not - # @param [Hash] client_params - # - :insecure [Boolean] - # - :url [String] + # Attributes not defined in client_params will not be modified + # @param [Hash] client_params parameters to override SUSEConnect config def write_config(client_params = {}) jsn_params = JSON.generate(client_params) _process_result(GoConnect.write_config(jsn_params)) @@ -248,7 +243,7 @@ end # Provides access to current system status in terms of activated products - # @param [Hash] client_params parameters to instantiate {Client} + # @param [Hash] client_params parameters to override SUSEConnect config def status(client_params) _set_verify_callback(client_params[:verify_callback]) Status.new(client_params) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/toolkit/shim_utils.rb new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/toolkit/shim_utils.rb --- old/connect-ng-0.0.4~git0.64b80e9/yast/lib/suse/toolkit/shim_utils.rb 2021-12-01 15:16:00.000000000 +0100 +++ new/connect-ng-0.0.5~git0.bbb5544/yast/lib/suse/toolkit/shim_utils.rb 2022-01-07 12:37:57.000000000 +0100 @@ -1,6 +1,9 @@ module SUSE module Toolkit + # This module implements common boilerplate for wrapping libsuseconnect + # functions and creating ruby interfaces. module ShimUtils + # lambda used to handle SSL cert validation errors @@verify_callback = nil def _set_verify_callback(f) @@ -15,8 +18,8 @@ end def _consume_str(ptr) - s = ptr.get_string(0) - Stdio.free(ptr) + s = ptr.to_s() + Stdio.free(ptr.to_i) return s end