• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-online-update-configuration / 15114789086

13 Sep 2024 08:18AM UTC coverage: 9.73% (-0.05%) from 9.777%
15114789086

push

github

lslezak
Clean merge of SP7

101 of 1038 relevant lines covered (9.73%)

0.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.12
/src/modules/OnlineUpdateConfiguration.rb
1
# encoding: utf-8
2

3
# ***************************************************************************
4
#
5
# Copyright (c) 2006 - 2012 Novell, Inc.
6
# All Rights Reserved.
7
#
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of version 2 of the GNU General Public License as
10
# published by the Free Software Foundation.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, contact Novell, Inc.
19
#
20
# To contact Novell about this file by physical or electronic mail,
21
# you may find current contact information at www.novell.com
22
#
23
# ***************************************************************************
24
# File:    modules/OnlineUpdateConfiguration.ycp
25
# Package: Online Update Configuration
26
# Summary: Online Update Configuration
27
# Authors: J. Daniel Schmidt <jdsn@suse.de>
28
#
29
# $Id: OnlineUpdateConfiguration.ycp 1 2008-09-10 09:45:05Z jdsn $
30
require "yast"
1✔
31
require "online-update-configuration/zypp_config"
1✔
32

33
module Yast
1✔
34
  class OnlineUpdateConfigurationClass < Module
1✔
35
    attr_reader :zypp_config
1✔
36

37
    def main
1✔
38
      Yast.import "Pkg"
5✔
39

40
      Yast.import "Package"
5✔
41
      Yast.import "URL"
5✔
42

43
      textdomain "online-update-configuration"
5✔
44

45
      @zypp_config = ZyppConfig.new
5✔
46

47
      @enableAOU = false
5✔
48
      @skipInteractivePatches = true
5✔
49
      @autoAgreeWithLicenses = false
5✔
50
      @includeRecommends = false
5✔
51
      @use_deltarpm = zypp_config.use_deltarpm?
5✔
52
      @updateInterval = :weekly
5✔
53
      @currentCategories = []
5✔
54
      @OUCmodified = false
5✔
55

56

57
      @onlineUpdateScript = "/usr/lib/YaST2/bin/online_update"
5✔
58

59
      @cronFileName = "opensuse.org-online_update"
5✔
60
      @cronMonthlyFile = Ops.add("/etc/cron.monthly/", @cronFileName)
5✔
61
      @cronWeeklyFile = Ops.add("/etc/cron.weekly/", @cronFileName)
5✔
62
      @cronDailyFile = Ops.add("/etc/cron.daily/", @cronFileName)
5✔
63

64
      @currentUpdateRepo = ""
5✔
65
      @defaultUpdateRepo = ""
5✔
66
      @allUpdateRepos = []
5✔
67
      @defaultRegistrationURL = ""
5✔
68

69
      # cache the base product details
70
      @baseProductDetail = {}
5✔
71

72
      @Intervals = {
73
        :daily   => { :name => "daily", :trans => _("daily") },
5✔
74
        :weekly  => { :name => "weekly", :trans => _("weekly") },
75
        :monthly => { :name => "monthly", :trans => _("monthly") }
76
      }
77

78
      @defaultCategories = {
79
        #translators: this name is a (technical) category for an update package
80
        "yast"        => Item(
5✔
81
          Id("yast"),
82
          _("Packagemanager and YaST")
83
        ),
84
        #translators: this name is a (technical) category for an update package
85
        "security"    => Item(
86
          Id("security"),
87
          _("Security")
88
        ),
89
        #translators: this name is a (technical) category for an update package
90
        "recommended" => Item(
91
          Id("recommended"),
92
          _("Recommended")
93
        ),
94
        #translators: this name is a (technical) category for an update package
95
        "optional"    => Item(
96
          Id("optional"),
97
          _("Optional")
98
        ),
99
        #translators: this name is a (technical) category for an update package: Document, meaning Documentation
100
        "document"    => Item(
101
          Id("document"),
102
          _("Document")
103
        ),
104
        #translators: this name is a (technical) category for an update package
105
        "other"       => Item(
106
          Id("other"),
107
          _("Other")
108
        )
109
      }
110
    end
111

112
    # fetchBaseProductDetails
113
    # get the details of the base product to find its default update Source or registration server
114
    # the found base product will be saved in the cache variable  baseProductDetail
115
    #
116
    # @return true if a base product is found, else false
117
    def fetchBaseProductDetails
1✔
118
      Builtins.y2milestone("Searching base product details.")
×
119

120
      # fetch product details about installed products
121
      productDetail = Pkg.ResolvableProperties("", :product, "")
×
122
      @baseProductDetail = {}
×
123

124
      #FIXME START
125
      #FIXME: 1) pkg-bindings return only addon products for openSUSE (bnc#449844)
126
      #FIXME: 2) the product definition does not contain update URLS (bnc#449842)
127
      #FIXME: If either of these remain unfixed the following two lines need to be uncommented,
128
      #FIXME: otherwise restoring of the default update repo is only possible via NCC registration
129
      # productDetail[0, "category"]="base";
130
      # productDetail[0, "update_urls"] = ["http://download.opensuse.org/update/11.2/"];
131
      #FIXME END
132

133
      Builtins.y2debug("All installed products are: %1", productDetail)
×
134
      Builtins.y2debug("Now looking for the base product")
×
135

136
      # filter the map to find the one any only base product
137
      productDetail = Builtins.filter(productDetail) do |oneProduct|
×
138
        Ops.get_string(oneProduct, "category", "unknown") == "base"
×
139
      end
140

141
      Builtins.y2debug("All installed base products are: %1", productDetail)
×
142
      if Ops.less_than(Builtins.size(productDetail), 1)
×
143
        Builtins.y2error("Could not find any base product.")
×
144
        @baseProductDetail = {}
×
145
        return false
×
146
      elsif Ops.greater_than(Builtins.size(productDetail), 1)
×
147
        Builtins.y2error(
×
148
          "Found more than one base product. This is a severe problem as there may only be one base product."
149
        )
150
        Builtins.y2error(
×
151
          "This system seems to be broken. However the first found product will be used."
152
        )
153
      else
154
        Builtins.y2milestone("Found exactly one base product.")
×
155
      end
156

157
      @baseProductDetail = Ops.get(productDetail, 0, {})
×
158
      Builtins.y2milestone("Found a base product: %1", @baseProductDetail)
×
159

160
      true
×
161
    end
162

163
    # compareUpdateURLs
164
    # compare two URLs - only the scheme, hostname and path will be compared, a trailing slash will be ignored
165
    # @return true if urls match
166
    def compareUpdateURLs(url1, url2, allowEmpty)
1✔
167
      Builtins.y2debug("Comparing two urls.")
×
168
      return false if url1 == "" && url2 == "" && !allowEmpty
×
169

170
      url1map = URL.Parse(url1)
×
171
      url2map = URL.Parse(url2)
×
172

173
      # removing trailing slash
174
      if Builtins.regexpmatch(Ops.get_string(url1map, "path", ""), "/$")
×
175
        Ops.set(
×
176
          url1map,
177
          "path",
178
          Builtins.regexpsub(
179
            Ops.get_string(url1map, "path", ""),
180
            "(.*)/$",
181
            "\\1"
182
          )
183
        )
184
      end
185
      if Builtins.regexpmatch(Ops.get_string(url2map, "path", ""), "/$")
×
186
        Ops.set(
×
187
          url2map,
188
          "path",
189
          Builtins.regexpsub(
190
            Ops.get_string(url2map, "path", ""),
191
            "(.*)/$",
192
            "\\1"
193
          )
194
        )
195
      end
196

197
      if Builtins.tolower(Ops.get_string(url1map, "scheme", "X")) ==
×
198
          Builtins.tolower(Ops.get_string(url2map, "scheme", "Y")) &&
199
          Builtins.tolower(Ops.get_string(url1map, "host", "X")) ==
200
            Builtins.tolower(Ops.get_string(url2map, "host", "Y")) &&
201
          Ops.get_string(url1map, "path", "X") ==
202
            Ops.get_string(url2map, "path", "Y")
203
        return true
×
204
      end
205

206
      false
×
207
    end
208

209

210
    # fetchBaseProductURLs
211
    # fetches the default update repo URL and the registration server URL and saves them in the global variables
212
    #
213
    # @return true if successfull
214
    def fetchBaseProductURLs
1✔
215
      defUp = ""
×
216
      defReg = ""
×
217

218
      if @defaultUpdateRepo == nil || @defaultUpdateRepo == ""
×
219
        Builtins.y2milestone("Looking for default update repo.")
×
220
        fetchBaseProductDetails
×
221
      end
222

223
      if @baseProductDetail == nil || @baseProductDetail == {}
×
224
        Builtins.y2error(
×
225
          "Could not find any details about the base product and thus no default update repo."
226
        )
227
        return false
×
228
      else
229
        # handle default update repository
230
        updateURLs = Ops.get_list(@baseProductDetail, "update_urls", [])
×
231
        @allUpdateRepos = deep_copy(updateURLs)
×
232

233
        if Ops.less_than(Builtins.size(updateURLs), 1)
×
234
          Builtins.y2error(
×
235
            "Base product does not provide a default update repository."
236
          )
237
          defUp = ""
×
238
        elsif Builtins.size(updateURLs) == 1
×
239
          Builtins.y2milestone("Found exactly one default update URL.")
×
240
          defUp = Ops.get(updateURLs, 0, "")
×
241
        else
242
          Builtins.y2milestone(
×
243
            "Found multiple default update repositories. Will pick one as default."
244
          )
245
          # first looking for opensuse.org update repos
246
          filteredUpdateURLs = Builtins.filter(updateURLs) do |oneURL|
×
247
            Builtins.regexpmatch(oneURL, ".opensuse.org")
×
248
          end
249

250
          if Ops.less_than(Builtins.size(filteredUpdateURLs), 1)
×
251
            filteredUpdateURLs = Builtins.filter(updateURLs) do |oneURL|
×
252
              Builtins.regexpmatch(oneURL, ".novell.com")
×
253
            end
254
          end
255

256
          if Ops.less_than(Builtins.size(filteredUpdateURLs), 1)
×
257
            # no opensuse.org or novell.com update repo found
258
            Builtins.y2milestone("Will use the first found update repository.")
×
259
            defUp = Ops.get(updateURLs, 0, "")
×
260
          elsif Builtins.size(filteredUpdateURLs) == 1
×
261
            Builtins.y2milestone(
×
262
              "Will use default opensuse.org resp. novell.com update repository."
263
            )
264
            defUp = Ops.get(filteredUpdateURLs, 0, "")
×
265
          else
266
            Builtins.y2milestone(
×
267
              "After filtering still multiple cadidates remain as default update repository."
268
            )
269
            Builtins.y2milestone(
×
270
              "Will now use the first found update repository."
271
            )
272
            defUp = Ops.get(filteredUpdateURLs, 0, "")
×
273
          end
274
        end
275

276
        # handle default registration server
277
        registerURLs = Ops.get_list(@baseProductDetail, "register_urls", [])
×
278
        if Ops.less_than(Builtins.size(registerURLs), 1)
×
279
          Builtins.y2error("No default registration URL found.")
×
280
          defReg = ""
×
281
        elsif Builtins.size(registerURLs) == 1
×
282
          Builtins.y2milestone("Found exactly one registration URL.")
×
283
          defReg = Ops.get(registerURLs, 0, "")
×
284
        else
285
          Builtins.y2milestone(
×
286
            "Found multiple registration URLs. Will pick one as default."
287
          )
288
          # first looking for novell.com registration URLs
289
          filteredRegisterURLs = Builtins.filter(registerURLs) do |oneURL|
×
290
            Builtins.regexpmatch(oneURL, ".novell.com")
×
291
          end
292

293
          if Ops.less_than(Builtins.size(filteredRegisterURLs), 1)
×
294
            filteredRegisterURLs = Builtins.filter(registerURLs) do |oneURL|
×
295
              Builtins.regexpmatch(oneURL, ".opensuse.org")
×
296
            end
297
          end
298

299
          if Ops.less_than(Builtins.size(filteredRegisterURLs), 1)
×
300
            # no opensuse.org or novell.com update repo found
301
            Builtins.y2milestone("Will use the first found registration URL.")
×
302
            defReg = Ops.get(registerURLs, 0, "")
×
303
          elsif Builtins.size(filteredRegisterURLs) == 1
×
304
            Builtins.y2milestone(
×
305
              "Will use default novell.com resp. opensuse.org registration URL."
306
            )
307
            defReg = Ops.get(filteredRegisterURLs, 0, "")
×
308
          else
309
            Builtins.y2milestone(
×
310
              "After filtering still multiple cadidates remain as default registration URL."
311
            )
312
            Builtins.y2milestone(
×
313
              "Will now use the first found registration URL."
314
            )
315
            defReg = Ops.get(filteredRegisterURLs, 0, "")
×
316
          end
317
        end
318
      end
319

320
      @defaultUpdateRepo = defUp
×
321
      @defaultRegistrationURL = defReg
×
322
      logUpdateRepoMap = URL.Parse(@defaultUpdateRepo)
×
323
      if Ops.get_string(logUpdateRepoMap, "pass", "") != nil &&
×
324
          Ops.get_string(logUpdateRepoMap, "pass", "") != ""
325
        Ops.set(logUpdateRepoMap, "pass", "--a-password-is-set--")
×
326
      end
327
      logUpdateRepo = URL.Build(logUpdateRepoMap)
×
328

329
      Builtins.y2milestone(
×
330
        "Found default update repository is: %1",
331
        logUpdateRepo
332
      )
333
      Builtins.y2milestone(
×
334
        "Using this default registration URL: %1",
335
        @defaultRegistrationURL
336
      )
337
      Builtins.y2milestone(
×
338
        "This registration URL will not be written to the system. The registration module itself will offer to change the default registration URL. Here the URL is used just to find out if this product can be registered."
339
      )
340

341
      true
×
342
    end
343

344
    # fetchCurrentUpdateRepoURL
345
    # returns the currentUpdateRepoURL or and updates the global variable that caches this value
346
    def fetchCurrentUpdateRepoURL
1✔
347
      curUp = ""
×
348

349
      if Ops.less_than(Builtins.size(@allUpdateRepos), 1)
×
350
        Builtins.y2error(
×
351
          "No current update repos found to compare the default update repo with."
352
        )
353
        curUp = ""
×
354
      else
355
        allCurrentRepos = Pkg.SourceGetCurrent(true)
×
356
        if Ops.less_than(Builtins.size(allCurrentRepos), 1)
×
357
          Builtins.y2milestone("No current sources found.")
×
358
          curUp = ""
×
359
        else
360
          foundUpdateRepo = []
×
361

362
          Builtins.foreach(allCurrentRepos) do |repoID|
×
363
            repoURL = Pkg.SourceURL(repoID)
×
364
            Builtins.foreach(@allUpdateRepos) do |upRepo|
×
365
              if compareUpdateURLs(repoURL, upRepo, false)
×
366
                foundUpdateRepo = Builtins.add(foundUpdateRepo, repoURL)
×
367
              end
368
            end
369
          end
370

371
          if Ops.less_than(Builtins.size(foundUpdateRepo), 1)
×
372
            Builtins.y2milestone("Could not find any update repo in the system")
×
373
          elsif Builtins.size(foundUpdateRepo) == 1
×
374
            Builtins.y2milestone("Found exactly one update repo.")
×
375
            curUp = Ops.get(foundUpdateRepo, 0, "")
×
376
            # found an update repo in the system that is provided by the product as well - so it is the default
377
            @defaultUpdateRepo = curUp
×
378
          else
379
            Builtins.y2milestone(
×
380
              "Found multiple update repos. Will only use the first one."
381
            )
382
            curUp = Ops.get(foundUpdateRepo, 0, "")
×
383
            # found an update repo in the system that is provided by the product as well - so it is the default
384
            @defaultUpdateRepo = curUp
×
385
          end
386
        end
387
      end
388

389
      @currentUpdateRepo = curUp
×
390
      Builtins.y2milestone("Current update repo is: %1", @currentUpdateRepo)
×
391
      curUp
×
392
    end
393

394

395

396
    def setUpdateRepo(updateRepo)
1✔
397
      Builtins.y2milestone(
×
398
        "User wants to set the default update repo to: %1",
399
        updateRepo
400
      )
401

402
      # create map for new source
403
      newSrcMap = {
×
404
        "enabled"     => true,
405
        "autorefresh" => true,
406
        "name"        => "Default-Update-Repository",
407
        "alias"       => "Default-Update-Repository",
408
        "base_urls"   => [updateRepo],
409
        "priority"    => 20
410
      }
411

412
      Builtins.y2milestone("Adding new update repository.")
×
413
      newSrcID = Pkg.RepositoryAdd(newSrcMap)
×
414
      if newSrcID != nil
×
415
        Builtins.y2milestone(
×
416
          "Successfully added the default update repository to the system."
417
        )
418
        @currentUpdateRepo = updateRepo
×
419
      else
420
        Builtins.y2error(
×
421
          "Could not add the default update repository to the system."
422
        )
423
      end
424

425
      Builtins.y2milestone("Saving all source changes to the system.")
×
426
      Pkg.SourceSaveAll
×
427

428
      true
×
429
    end
430

431
    def intervalSymbolToString(intervalSym, strType)
1✔
432
      i = Ops.get(@Intervals, intervalSym, {})
1✔
433
      Ops.get(i, strType, "none")
1✔
434
    end
435

436
    def intervalStringToSymbol(intervalStr)
1✔
437
      result = :none
4✔
438
      Builtins.foreach(@Intervals) do |sym, i|
4✔
439
        result = sym if Ops.get(i, :name, "none") == intervalStr
12✔
440
        nil
12✔
441
      end
442
      result
4✔
443
    end
444

445
    # remove all online update cronjobs
446
    #
447
    def removeOnlineUpdateCronjobs
1✔
448
      SCR.Execute(path(".target.remove"), @cronMonthlyFile)
×
449
      SCR.Execute(path(".target.remove"), @cronWeeklyFile)
×
450
      SCR.Execute(path(".target.remove"), @cronDailyFile)
×
451

452
      nil
×
453
    end
454

455
    # setup cronjob for an automatic online update
456
    # @param interval [Symbol] for the interval `daily, `weekly, `monthly
457
    # @return true if successful
458
    def setOnlineUpdateCronjob(interval)
1✔
459
      cronSel = ""
×
460
      if interval == :monthly
×
461
        cronSel = @cronMonthlyFile
×
462
      elsif interval == :weekly
×
463
        cronSel = @cronWeeklyFile
×
464
      elsif interval == :daily
×
465
        cronSel = @cronDailyFile
×
466
      end
467

468
      removeOnlineUpdateCronjobs
×
469

470
      if Convert.to_boolean(
×
471
          SCR.Execute(path(".target.symlink"), @onlineUpdateScript, cronSel)
472
        )
473
        Builtins.y2milestone("Setting up online update cron job at %1", cronSel)
×
474
        return true
×
475
      else
476
        Builtins.y2error(
×
477
          "Could not create online update cron job at %1",
478
          cronSel
479
        )
480
        return false
×
481
      end
482

483
      true
×
484
    end
485

486

487

488

489
    # Read()
490
    def Read
1✔
491
      # just for documentation: defaultUpdateRepo for 11.1 should be "http://download.opensuse.org/update/11.1/"
492

493
      if fetchBaseProductDetails
×
494
        Builtins.y2milestone("Fetched base product detail information")
×
495
      else
496
        Builtins.y2error("Could not fetch base product details information.")
×
497
      end
498

499
      # read base URLs from the base product
500
      fetchBaseProductURLs
×
501
      # this will update the default update repo as well - so do it once here
502
      foo = fetchCurrentUpdateRepoURL
×
503

504
      interM = Convert.to_integer(
×
505
        SCR.Read(path(".target.size"), @cronMonthlyFile)
506
      )
507
      interW = Convert.to_integer(
×
508
        SCR.Read(path(".target.size"), @cronWeeklyFile)
509
      )
510
      interD = Convert.to_integer(
×
511
        SCR.Read(path(".target.size"), @cronDailyFile)
512
      )
513

514
      if Ops.greater_or_equal(interD, 0)
×
515
        @updateInterval = :daily
×
516
      elsif Ops.greater_or_equal(interW, 0)
×
517
        @updateInterval = :weekly
×
518
      elsif Ops.greater_or_equal(interM, 0)
×
519
        @updateInterval = :monthly
×
520
      else
521
        @updateInterval = :weekly
×
522
      end
523

524
      # enableAOU is not read from sysconfig! this is only to deactivate it temporarily
525
      # only the fact that a cronjob exists makes this setting true
526
      @enableAOU = Ops.greater_or_equal(interD, 0) ||
×
527
        Ops.greater_or_equal(interW, 0) ||
528
        Ops.greater_or_equal(interM, 0)
529
      @skipInteractivePatches = Convert.to_string(
×
530
        SCR.Read(
531
          path(
532
            ".sysconfig.automatic_online_update.AOU_SKIP_INTERACTIVE_PATCHES"
533
          )
534
        )
535
      ) == "true" ? true : false
×
536
      @autoAgreeWithLicenses = Convert.to_string(
×
537
        SCR.Read(
538
          path(
539
            ".sysconfig.automatic_online_update.AOU_AUTO_AGREE_WITH_LICENSES"
540
          )
541
        )
542
      ) == "true" ? true : false
×
543
      @includeRecommends = Convert.to_string(
×
544
        SCR.Read(
545
          path(".sysconfig.automatic_online_update.AOU_INCLUDE_RECOMMENDS")
546
        )
547
      ) == "true" ? true : false
×
548
      patchCategories = Convert.to_string(
×
549
        SCR.Read(
550
          path(".sysconfig.automatic_online_update.AOU_PATCH_CATEGORIES")
551
        )
552
      )
553

554
      @currentCategories = Builtins.splitstring(patchCategories, " ")
×
555
      @currentCategories = Builtins.filter(@currentCategories) do |s|
×
556
        s != nil && s != ""
×
557
      end
558

559
      nil
×
560
    end
561

562

563
    # Import()
564
    def Import(settings)
1✔
565
      settings = deep_copy(settings)
4✔
566
      @enableAOU = false
4✔
567
      @skipInteractivePatches = true
4✔
568
      @updateInterval = :weekly
4✔
569

570
      @enableAOU = Ops.get_boolean(
4✔
571
        settings,
572
        "enable_automatic_online_update",
573
        @enableAOU
574
      )
575
      @skipInteractivePatches = Ops.get_boolean(
4✔
576
        settings,
577
        "skip_interactive_patches",
578
        @skipInteractivePatches
579
      )
580
      @autoAgreeWithLicenses = Ops.get_boolean(
4✔
581
        settings,
582
        "auto_agree_with_licenses",
583
        @autoAgreeWithLicenses
584
      )
585
      @includeRecommends = Ops.get_boolean(
4✔
586
        settings,
587
        "include_recommends",
588
        @includeRecommends
589
      )
590
      @use_deltarpm = settings.fetch('use_deltarpm', @use_deltarpm)
4✔
591

592
      @currentCategories = get_category_filter(settings["category_filter"])
4✔
593

594
      getInterval = Ops.get_string(settings, "update_interval", "")
4✔
595

596
      @enableAOU = false if @enableAOU == nil
4✔
597
      @updateInterval = intervalStringToSymbol(getInterval)
4✔
598
      # fall back to weekly in error case
599
      @updateInterval = :weekly if @updateInterval == :none
4✔
600

601
      true
4✔
602
    end
603

604
    # Write()
605
    def Write
1✔
606
      SCR.Write(
×
607
        path(".sysconfig.automatic_online_update.AOU_ENABLE_CRONJOB"),
608
        @enableAOU == true ? "true" : "false"
×
609
      )
610
      SCR.Write(
×
611
        path(".sysconfig.automatic_online_update.AOU_SKIP_INTERACTIVE_PATCHES"),
612
        @skipInteractivePatches == true ? "true" : "false"
×
613
      )
614
      SCR.Write(
×
615
        path(".sysconfig.automatic_online_update.AOU_AUTO_AGREE_WITH_LICENSES"),
616
        @autoAgreeWithLicenses == true ? "true" : "false"
×
617
      )
618
      SCR.Write(
×
619
        path(".sysconfig.automatic_online_update.AOU_INCLUDE_RECOMMENDS"),
620
        @includeRecommends == true ? "true" : "false"
×
621
      )
622
      @use_deltarpm ? zypp_config.activate_deltarpm : zypp_config.deactivate_deltarpm
×
623
      catConf = ""
×
624
      if Ops.greater_than(Builtins.size(@currentCategories), 0)
×
625
        catConf = Builtins.mergestring(@currentCategories, " ")
×
626
      end
627
      SCR.Write(
×
628
        path(".sysconfig.automatic_online_update.AOU_PATCH_CATEGORIES"),
629
        catConf
630
      )
631

632
      if @enableAOU
×
633
        Builtins.y2milestone(
×
634
          "Enabling automatic online update with interval: %1",
635
          @updateInterval
636
        )
637
        return setOnlineUpdateCronjob(@updateInterval)
×
638
      else
639
        Builtins.y2milestone("Automatic online update is disabled.")
×
640
        removeOnlineUpdateCronjobs
×
641
        return true
×
642
      end
643

644
      true
×
645
    end
646

647

648

649
    # AutoYaST interface function: Export()
650
    # @return [Hash] with the settings
651
    def Export
1✔
652
      return {} if !@enableAOU
1✔
653

654
      {
655
        "enable_automatic_online_update" => @enableAOU,
1✔
656
        "skip_interactive_patches"       => @skipInteractivePatches,
657
        "auto_agree_with_licenses"       => @autoAgreeWithLicenses,
658
        "include_recommends"             => @includeRecommends,
659
        "use_deltarpm"                  => @use_deltarpm,
660
        "update_interval"                => intervalSymbolToString(
661
          @updateInterval,
662
          :name
663
        ),
664
        "category_filter"                => @currentCategories
665
      }
666
    end
667

668
    publish :variable => :enableAOU, :type => "boolean"
1✔
669
    publish :variable => :skipInteractivePatches, :type => "boolean"
1✔
670
    publish :variable => :autoAgreeWithLicenses, :type => "boolean"
1✔
671
    publish :variable => :includeRecommends, :type => "boolean"
1✔
672
    publish :variable => :use_deltarpm, :type => "boolean"
1✔
673
    publish :variable => :updateInterval, :type => "symbol"
1✔
674
    publish :variable => :currentCategories, :type => "list <string>"
1✔
675
    publish :variable => :OUCmodified, :type => "boolean"
1✔
676
    publish :variable => :currentUpdateRepo, :type => "string"
1✔
677
    publish :variable => :defaultUpdateRepo, :type => "string"
1✔
678
    publish :variable => :allUpdateRepos, :type => "list <string>"
1✔
679
    publish :variable => :defaultRegistrationURL, :type => "string"
1✔
680
    publish :variable => :Intervals, :type => "map <symbol, map <symbol, string>>"
1✔
681
    publish :variable => :defaultCategories, :type => "map <string, term>"
1✔
682
    publish :function => :compareUpdateURLs, :type => "boolean (string, string, boolean)"
1✔
683
    publish :function => :fetchBaseProductURLs, :type => "boolean ()"
1✔
684
    publish :function => :fetchCurrentUpdateRepoURL, :type => "string ()"
1✔
685
    publish :function => :setUpdateRepo, :type => "boolean (string)"
1✔
686
    publish :function => :intervalSymbolToString, :type => "string (symbol, symbol)"
1✔
687
    publish :function => :intervalStringToSymbol, :type => "symbol (string)"
1✔
688
    publish :function => :setOnlineUpdateCronjob, :type => "boolean (symbol)"
1✔
689
    publish :function => :Read, :type => "void ()"
1✔
690
    publish :function => :Import, :type => "boolean (map)"
1✔
691
    publish :function => :Write, :type => "boolean ()"
1✔
692
    publish :function => :Export, :type => "map ()"
1✔
693

694
  private
1✔
695

696
    def get_category_filter(category_filter)
1✔
697
      case category_filter
4✔
698
      when Array
699
        category_filter
2✔
700
      when Hash
701
        category_filter.fetch("category", [])
1✔
702
      else
703
        []
1✔
704
      end
705
    end
706

707
  end
708

709
  OnlineUpdateConfiguration = OnlineUpdateConfigurationClass.new
1✔
710
  OnlineUpdateConfiguration.main
1✔
711
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc