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 2023-03-25 18:55:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/suseconnect-ng (Old) and /work/SRC/openSUSE:Factory/.suseconnect-ng.new.31432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "suseconnect-ng" Sat Mar 25 18:55:06 2023 rev:18 rq:1074142 version:1.1.0~git0.e3c41e60892e Changes: -------- --- /work/SRC/openSUSE:Factory/suseconnect-ng/suseconnect-ng.changes 2022-12-20 20:20:53.662012208 +0100 +++ /work/SRC/openSUSE:Factory/.suseconnect-ng.new.31432/suseconnect-ng.changes 2023-03-25 18:55:20.834661065 +0100 @@ -1,0 +2,21 @@ +Fri Mar 17 10:34:15 UTC 2023 - msab...@suse.com + +- Update to version 1.1.0~git0.e3c41e60892e: + * Bump to v1.1.0 + +------------------------------------------------------------------- +Tue Mar 14 10:10:09 UTC 2023 - msab...@suse.com + +- Update to version 1.0.0~git23.406b219ccc9e: + * Added MemTotal detection for HwInfo + * move 'ExcludeArch' out of the if block + +------------------------------------------------------------------- +Wed Mar 08 10:44:59 UTC 2023 - tschm...@suse.com + +- Update to version 1.0.0~git19.b225bc3: + * Make keepalive on SUMA systems exit without error (bsc#1207876) + * Update README.md + * Add deactivate API to ruby bindings (bsc#1202705) + +------------------------------------------------------------------- Old: ---- connect-ng-1.0.0~git14.17a7901.tar.xz New: ---- connect-ng-1.1.0~git0.e3c41e60892e.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ suseconnect-ng.spec ++++++ --- /var/tmp/diff_new_pack.qid8AA/_old 2023-03-25 18:55:21.234663156 +0100 +++ /var/tmp/diff_new_pack.qid8AA/_new 2023-03-25 18:55:21.238663177 +0100 @@ -1,7 +1,7 @@ # # spec file for package suseconnect-ng # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -23,11 +23,11 @@ %bcond_with hwinfo Name: suseconnect-ng -Version: 1.0.0~git14.17a7901 +Version: 1.1.0~git0.e3c41e60892e Release: 0 URL: https://github.com/SUSE/connect-ng -License: LGPL-2.1-or-later Summary: Utility to register a system with the SUSE Customer Center +License: LGPL-2.1-or-later Group: System/Management Source: connect-ng-%{version}.tar.xz Source1: %name-rpmlintrc @@ -42,10 +42,10 @@ BuildRequires: ruby-devel BuildRequires: zypper +ExcludeArch: %ix86 s390 ppc64 %if %{with hwinfo} %global test_hwinfo_args -test-hwinfo -ExcludeArch: %ix86 s390 ppc64 # packages required only for hwinfo tests %ifarch ia64 x86_64 %arm aarch64 BuildRequires: dmidecode @@ -56,8 +56,8 @@ BuildRequires: systemd %endif -Obsoletes: SUSEConnect < 1.0.0 -Provides: SUSEConnect = 1.0.0 +Obsoletes: SUSEConnect < 1.1.0 +Provides: SUSEConnect = 1.1.0 Obsoletes: zypper-migration-plugin < 0.99 Provides: zypper-migration-plugin = 0.99 Obsoletes: zypper-search-packages-plugin < 0.99 @@ -95,8 +95,8 @@ %package -n libsuseconnect Summary: C interface to suseconnect-ng -Group: System/Management # the CLI is not used by libsuseconnect but it has the same dependencies and it's easier to keep one list above +Group: System/Management Requires: suseconnect-ng %description -n libsuseconnect ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.qid8AA/_old 2023-03-25 18:55:21.282663407 +0100 +++ /var/tmp/diff_new_pack.qid8AA/_new 2023-03-25 18:55:21.286663428 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/SUSE/connect-ng.git</param> - <param name="changesrevision">17a79019a857c17bd114523b699f2ba97da398a8</param></service></servicedata> + <param name="changesrevision">472bdddd7894f8ddbf002143d472b5052a84d633</param></service></servicedata> (No newline at EOF) ++++++ connect-ng-1.0.0~git14.17a7901.tar.xz -> connect-ng-1.1.0~git0.e3c41e60892e.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/.gitignore new/connect-ng-1.1.0~git0.e3c41e60892e/.gitignore --- old/connect-ng-1.0.0~git14.17a7901/.gitignore 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/.gitignore 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -out -internal/connect/version.txt -connect-ruby diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/README.md new/connect-ng-1.1.0~git0.e3c41e60892e/README.md --- old/connect-ng-1.0.0~git14.17a7901/README.md 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/README.md 2023-03-17 11:32:31.000000000 +0100 @@ -1,5 +1,8 @@ # SUSEConnect-ng +[](https://build.opensuse.org/package/show/systemsmanagement:SCC/suseconnect-ng) + + SUSEConnect-ng is a work-in-progress project to rewrite [SUSEConnect](https://github.com/SUSE/connect) in Golang. SUSEConnect is a command line tool for connecting a client system to the SUSE Customer Center. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/internal/connect/client.go new/connect-ng-1.1.0~git0.e3c41e60892e/internal/connect/client.go --- old/connect-ng-1.0.0~git14.17a7901/internal/connect/client.go 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/internal/connect/client.go 2023-03-17 11:32:31.000000000 +0100 @@ -338,6 +338,17 @@ return systemActivations() } +// DeactivateProduct deactivates given product in SMT/SCC +// returns Service to be removed from zypper +func DeactivateProduct(product Product) (Service, error) { + return deactivateProduct(product) +} + +// DeregisterSystem deletes current system in SMT/SCC +func DeregisterSystem() error { + return deregisterSystem() +} + // InstallerUpdates returns an array of Installer-Updates repositories for the given product func InstallerUpdates(product Product) ([]Repo, error) { return installerUpdates(product) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/internal/connect/hwinfo.go new/connect-ng-1.1.0~git0.e3c41e60892e/internal/connect/hwinfo.go --- old/connect-ng-1.0.0~git14.17a7901/internal/connect/hwinfo.go 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/internal/connect/hwinfo.go 2023-03-17 11:32:31.000000000 +0100 @@ -3,6 +3,7 @@ import ( "bufio" "bytes" + "io" "net" "os" "regexp" @@ -31,6 +32,7 @@ Arch string `json:"arch"` UUID string `json:"uuid"` CloudProvider string `json:"cloud_provider"` + MemTotal int `json:"mem_total,omitempty"` } func getHwinfo() (hwinfo, error) { @@ -42,6 +44,11 @@ hw.Hostname = hostname() hw.CloudProvider = cloudProvider() + // Include memory information if possible. + if mem := systemMemory(); mem > 0 { + hw.MemTotal = mem + } + var lscpuM map[string]string if hw.Arch == archX86 || hw.Arch == archARM || hw.Arch == archPPC { if lscpuM, err = lscpu(); err != nil { @@ -269,3 +276,40 @@ } return m } + +// Returns the parsed value for the given file. The implementation has been +// split from `systemMemory` so testing it is easier, but bear in mind that +// these two are coupled. +func parseMeminfo(file io.Reader) int { + scanner := bufio.NewScanner(file) + for scanner.Scan() { + fields := strings.Fields(scanner.Text()) + if len(fields) < 2 || fields[0] != "MemTotal:" { + continue + } + + val, err := strconv.Atoi(fields[1]) + if err != nil { + Debug.Printf("could not obtain memory information for this system: %v", err) + return 0 + } + return val / 1024 + } + + Debug.Print("could not obtain memory information for this system") + return 0 +} + +// Returns an integer with the amount of megabytes of total memory (i.e. +// `MemTotal` in /proc/meminfo). It will return 0 if this information could not +// be extracted for whatever reason. +func systemMemory() int { + file, err := os.Open("/proc/meminfo") + if err != nil { + Debug.Print("'/proc/meminfo' could not be read!") + return 0 + } + defer file.Close() + + return parseMeminfo(file) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/internal/connect/hwinfo_test.go new/connect-ng-1.1.0~git0.e3c41e60892e/internal/connect/hwinfo_test.go --- old/connect-ng-1.0.0~git14.17a7901/internal/connect/hwinfo_test.go 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/internal/connect/hwinfo_test.go 2023-03-17 11:32:31.000000000 +0100 @@ -1,6 +1,7 @@ package connect import ( + "bytes" "flag" "net" "testing" @@ -154,3 +155,26 @@ } } } + +func TestParseMeminfo(t *testing.T) { + var tests = []struct { + file string + value int + }{ + {"MemTotal: 16297236 kB", 15915}, + {"MemTotal:", 0}, + {"MemSomething: 16297236 kB", 0}, + {"Malformed 16297236 kB", 0}, + {"MemTotal: notanumber kB", 0}, + {"wubalubadubdub", 0}, + {"", 0}, + } + + for _, v := range tests { + buff := bytes.NewBufferString(v.file) + val := parseMeminfo(buff) + if val != v.value { + t.Errorf("Expecting '%v', got '%v'", v.value, val) + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/libsuseconnect/libsuseconnect.go new/connect-ng-1.1.0~git0.e3c41e60892e/libsuseconnect/libsuseconnect.go --- old/connect-ng-1.0.0~git14.17a7901/libsuseconnect/libsuseconnect.go 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/libsuseconnect/libsuseconnect.go 2023-03-17 11:32:31.000000000 +0100 @@ -84,6 +84,18 @@ return C.CString("{}") } +//export deactivate_system +func deactivate_system(clientParams *C.char) *C.char { + loadConfig(C.GoString(clientParams)) + + err := connect.DeregisterSystem() + if err != nil { + return C.CString(errorToJSON(err)) + } + + return C.CString("{}") +} + //export credentials func credentials(path *C.char) *C.char { creds, err := connect.ReadCredentials(C.GoString(path)) @@ -164,6 +176,26 @@ if err != nil { return C.CString(errorToJSON(err)) } + return C.CString(string(jsn)) +} + +//export deactivate_product +func deactivate_product(clientParams, product *C.char) *C.char { + loadConfig(C.GoString(clientParams)) + + var p connect.Product + err := json.Unmarshal([]byte(C.GoString(product)), &p) + if err != nil { + return C.CString(errorToJSON(connect.JSONError{Err: err})) + } + service, err := connect.DeactivateProduct(p) + if err != nil { + return C.CString(errorToJSON(err)) + } + jsn, err := json.Marshal(service) + if err != nil { + return C.CString(errorToJSON(err)) + } return C.CString(string(jsn)) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/suseconnect/suseconnect.go new/connect-ng-1.1.0~git0.e3c41e60892e/suseconnect/suseconnect.go --- old/connect-ng-1.0.0~git14.17a7901/suseconnect/suseconnect.go 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/suseconnect/suseconnect.go 2023-03-17 11:32:31.000000000 +0100 @@ -147,6 +147,9 @@ exitOnError(err) fmt.Println(output) } else if keepAlive { + if isSumaManaged() { + os.Exit(0) + } err := connect.SendKeepAlivePing() exitOnError(err) } else if statusText { @@ -174,7 +177,7 @@ } else if connect.URLDefault() && token == "" && product == "" { flag.Usage() os.Exit(1) - } else if fileExists("/etc/sysconfig/rhn/systemid") { + } else if isSumaManaged() { fmt.Println("This system is managed by SUSE Manager / Uyuni, do not use SUSEconnect.") os.Exit(1) } else { @@ -273,3 +276,7 @@ } return true } + +func isSumaManaged() bool { + return fileExists("/etc/sysconfig/rhn/systemid") +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/suseconnect-ng.spec new/connect-ng-1.1.0~git0.e3c41e60892e/suseconnect-ng.spec --- old/connect-ng-1.0.0~git14.17a7901/suseconnect-ng.spec 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/suseconnect-ng.spec 2023-03-17 11:32:31.000000000 +0100 @@ -41,10 +41,10 @@ BuildRequires: zypper BuildRequires: ruby-devel +ExcludeArch: %ix86 s390 ppc64 %if %{with hwinfo} %global test_hwinfo_args -test-hwinfo -ExcludeArch: %ix86 s390 ppc64 # packages required only for hwinfo tests %ifarch ia64 x86_64 %arm aarch64 BuildRequires: dmidecode @@ -56,8 +56,8 @@ %endif -Obsoletes: SUSEConnect < 1.0.0 -Provides: SUSEConnect = 1.0.0 +Obsoletes: SUSEConnect < 1.1.0 +Provides: SUSEConnect = 1.1.0 Obsoletes: zypper-migration-plugin < 0.99 Provides: zypper-migration-plugin = 0.99 Obsoletes: zypper-search-packages-plugin < 0.99 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/connect-ng-1.0.0~git14.17a7901/yast/lib/suse/connect/yast.rb new/connect-ng-1.1.0~git0.e3c41e60892e/yast/lib/suse/connect/yast.rb --- old/connect-ng-1.0.0~git14.17a7901/yast/lib/suse/connect/yast.rb 2022-12-13 13:53:04.000000000 +0100 +++ new/connect-ng-1.1.0~git0.e3c41e60892e/yast/lib/suse/connect/yast.rb 2023-03-17 11:32:31.000000000 +0100 @@ -12,12 +12,14 @@ extern 'void free_string(string)' extern 'string announce_system(string, string)' extern 'string update_system(string, string)' + extern 'string deactivate_system(string)' extern 'string credentials(string)' extern 'string create_credentials_file(string, 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 deactivate_product(string, string)' extern 'string get_config(string)' extern 'string write_config(string)' extern 'string update_certificates()' @@ -68,6 +70,14 @@ _process_result(GoConnect.update_system(jsn_params, distro_target)) end + # Deactivates the system in SCC / the registration server. + # @param [Hash] client_params parameters to override SUSEConnect config + def deactivate_system(client_params = {}) + _set_verify_callback(client_params[:verify_callback]) + jsn_params = JSON.generate(client_params) + _process_result(GoConnect.deactivate_system(jsn_params)) + end + # Activates a product on SCC / the registration server. # Expects product parameter to identify the product. # Requires a token / regcode except for free products/extensions. @@ -85,6 +95,21 @@ _process_result(GoConnect.activate_product(jsn_params, jsn_product, email)) end + # Deactivates a product on SCC / the registration server. + # Expects product parameter to identify the product. + # Returns a service object for the deactivated product. + # + # @param [OpenStruct] product with identifier, arch and version defined + # @param [Hash] client_params parameters to override SUSEConnect config + # + # @return [OpenStruct] Service object as openstruct + def deactivate_product(product, client_params = {}) + _set_verify_callback(client_params[:verify_callback]) + jsn_params = JSON.generate(client_params) + jsn_product = JSON.generate(product.to_h) + _process_result(GoConnect.deactivate_product(jsn_params, jsn_product)) + end + # Upgrades a product on SCC / the registration server. # Expects product parameter to identify the product. # Token / regcode is not required. The new product needs to be available to the regcode the old