Module: Yast::InstserverDialogsInclude

Defined in:
src/include/instserver/dialogs.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) CDdevices



923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
# File 'src/include/instserver/dialogs.rb', line 923

def CDdevices
  cds = Convert.convert(
    SCR.Read(path(".probe.cdrom")),
    :from => "any",
    :to   => "list <map>"
  )
  ret = []

  Builtins.foreach(cds) do |cd|
    dev = Ops.get_string(cd, "dev_name", "")
    model = Ops.get_string(cd, "model", "")
    if dev != nil && dev != "" && model != nil
      ret = Builtins.add(
        ret,
        Item(Id(dev), Ops.add(model, Builtins.sformat(" (%1)", dev)))
      )
    end
  end if cds != nil

  deep_copy(ret)
end

- (Object) CDPopup(msg, iso)

CD Popup

Parameters:

  • string

    popup message

  • boolean

    true if ISO

Returns:

  • (Object)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'src/include/instserver/dialogs.rb', line 34

def CDPopup(msg, iso)
  if iso
    f = UI.AskForExistingFile(
      Ops.get_string(Instserver.ServerSettings, "iso-dir", ""),
      "*.iso",
      msg
    )
    Builtins.y2milestone("file: %1", f)
    if f != nil
      return deep_copy(f)
    else
      return ""
    end
  else
    pop = Popup.AnyQuestion3(
      _("Change Media"),
      msg,
      Label.ContinueButton, # `yes
      Label.CancelButton, # `no
      Label.SkipButton, # `retry
      :focus_yes
    )
    if pop == :no
      return :abort
    elsif pop == :retry
      Builtins.y2debug("skipping media")
      return :skip
    end
  end

  nil
end

- (Object) code10(content_file)



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'src/include/instserver/dialogs.rb', line 118

def code10(content_file)
  content_file = deep_copy(content_file)
  # ask for an addon only when the product is pre-CODE10
  ret = true

  product_lower = Builtins.tolower(
    Ops.get_string(content_file, "PRODUCT", "")
  )
  if product_lower == ""
    # code11
    product_lower = Builtins.tolower(
      Ops.get_string(content_file, "NAME", "")
    )
  end

  version_str = Ops.get_string(content_file, "VERSION", "")

  Builtins.y2milestone("product: %1", product_lower)
  Builtins.y2milestone("version: %1", version_str)

  version_major = 0
  version_minor = 0

  if Builtins.issubstring(version_str, ".")
    parts = Builtins.splitstring(version_str, ".")

    version_major = Builtins.tointeger(Ops.get(parts, 0, "0"))
    version_minor = Builtins.tointeger(Ops.get(parts, 1, "0"))
  else
    version_major = Builtins.tointeger(version_str)
  end

  if version_major == nil
    Builtins.y2warning("version_major is nil, setting to 0")
    version_major = 0
  end

  if version_minor == nil
    Builtins.y2warning("version_minor is nil, setting to 0")
    version_minor = 0
  end

  Builtins.y2milestone("major version number: %1", version_major)
  Builtins.y2milestone("minor version number: %1", version_minor)

  version = Ops.add(Ops.multiply(100, version_major), version_minor)
  Builtins.y2milestone("version: %1", version)

  # SUSE Linux <= 10.0
  if product_lower == "suse linux" && Ops.less_or_equal(version, 1000) ||
      # SLES or CORE == 9
      (product_lower == "suse sles" || product_lower == "suse core") &&
        version == 900 ||
      product_lower == "suse sles 9 service-pack" ||
      product_lower == "open enterprise server" && version == 0 ||
      product_lower == "suse sles" && Ops.less_or_equal(version, 800)
    ret = false
  end

  Builtins.y2milestone("CODE10 product: %1", ret)

  ret
end

- (Object) CopyCDs(dir, stype, iso, promptmore, cddrive)

Copy CDs to local disk

Parameters:

  • string

    directory

  • symbol

    source type

  • boolean

    true if copying using ISO files

  • boolean

    prompt for additional CDs.

Returns:

  • (Object)


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
# File 'src/include/instserver/dialogs.rb', line 190

def CopyCDs(dir, stype, iso, promptmore, cddrive)
  # free mount point
  SCR.Execute(path(".target.umount"), Installation.sourcedir)

  default_device = cddrive
  mount_options = iso ? "-oloop,ro " : ""

  # CD is mounted. Check contents.
  cdpath = Installation.sourcedir

  current_cd = 1
  total_cds = 1
  standalone = true
  standalone_product = true
  baseproduct = false
  base = ""
  basever = ""
  prompt_string = ""
  prompt_totalcds = 0
  medianames = []
  failed = false
  cds_copied = false
  code10_source = false

  media_id = ""

  restart = false

  pop = :none

  # content file at first CD must be preserved (#171157)
  content_first_CD = ""

  # Loop for all CDs
  while true
    msg = ""
    if !baseproduct && standalone && Builtins.size(medianames) == 0
      # %1 is the current cd number
      if !iso
        msg = Builtins.sformat(
          _("Insert CD %1 then press continue."),
          current_cd
        )
      else
        msg = Builtins.sformat(
          _("Select ISO image %1 then press continue."),
          current_cd
        )
      end
    else
      # %2 is the product name and version
      cd_prompt = _("Insert CD %1 of %2.")
      iso_prompt = _("Select ISO image %1 of %2.")
      prompt_for_cd = 0

      if promptmore || !standalone && !baseproduct && !restart
        prompt_for_cd = current_cd
      else
        prompt_for_cd = Ops.add(prompt_totalcds, current_cd)
      end

      if !iso
        if Builtins.size(medianames) == 0
          msg = Builtins.sformat(cd_prompt, prompt_for_cd, prompt_string)
        else
          m = ""
          Builtins.y2milestone(
            "medianames: %1, totalcds: %2",
            Builtins.size(medianames),
            total_cds
          )
          if Ops.greater_than(Builtins.size(medianames), 1)
            Builtins.y2milestone("all media names available")
            m = Ops.get_string(
              medianames,
              Ops.subtract(prompt_for_cd, 1),
              ""
            )
          else
            prompt_string = Builtins.substring(
              Builtins.regexpsub(
                Ops.get_string(medianames, 0, ""),
                "(.*)CD.",
                "\\1CD%1"
              ),
              7,
              Builtins.size(Ops.get_string(medianames, 0, ""))
            )
            m = Builtins.sformat(prompt_string, prompt_for_cd)
          end
          # popup request, %1 is CD medium name
          msg = Builtins.sformat(_("Insert\n%1"), m)
        end
      else
        if Builtins.size(medianames) == 0
          msg = Builtins.sformat(iso_prompt, prompt_for_cd, prompt_string)
        else
          m = ""
          Builtins.y2milestone(
            "medianames: %1, totalcds: %2",
            Builtins.size(medianames),
            total_cds
          )
          if Ops.greater_than(Builtins.size(medianames), 1)
            Builtins.y2milestone("all media names available")
            m = Ops.get_string(
              medianames,
              Ops.subtract(prompt_for_cd, 1),
              ""
            )
          else
            prompt_string = Builtins.regexpsub(
              Ops.get_string(medianames, 0, ""),
              "(.*)CD.",
              "\\1CD%1"
            )
            Builtins.y2debug("prompt string: %1)", prompt_string)
            m = Builtins.sformat(prompt_string, prompt_for_cd)
          end
          # popup request, %1 is ISO name
          msg = Builtins.sformat(_("Select %1"), m)
        end
      end
    end


    if iso
      default_device = Convert.to_string(CDPopup(msg, iso))
      if default_device == ""
        Builtins.y2debug(
          "total_cds: %1, current_cd: %2",
          total_cds,
          current_cd
        )
        if total_cds == current_cd
          failed = !cds_copied
          break
        else
          current_cd = Ops.add(current_cd, 1)
          next
        end
      end
    else
      pop = Convert.to_symbol(CDPopup(msg, iso))
      if pop == :skip
        if total_cds == current_cd
          break
        else
          current_cd = Ops.add(current_cd, 1)
          next
        end
      elsif pop == :abort
        return :abort
      end
    end

    # try to mount device
    if SCR.Execute(
        path(".target.mount"),
        [default_device, Installation.sourcedir],
        mount_options
      ) == false
      # cant mount /dev/cdrom popup
      Builtins.y2error("mount faild")
      next
    end
    Builtins.y2debug("mounted cdrom")

    media = ReadMediaFile(
      Builtins.sformat("%1/media.%2/media", cdpath, current_cd)
    )
    Builtins.y2milestone("media: %1", media)
    content = {}

    # remove empty string at the end if it's present
    if Ops.greater_or_equal(Builtins.size(media), 1) &&
        Ops.get(media, Ops.subtract(Builtins.size(media), 1)) == ""
      media = Builtins.remove(media, Ops.subtract(Builtins.size(media), 1))
      Builtins.y2milestone("media: %1", media)
    end

    if Builtins.size(media) == 0 ||
        media_id != Ops.get(media, 1, "") && media_id != ""
      Builtins.y2warning("wrong CD or non suse CD")
      SCR.Execute(path(".target.umount"), Installation.sourcedir)
      next
    else
      # media names at the end of file
      if Builtins.tointeger(Ops.get(media, 2, "-1")) == nil &&
          Ops.greater_than(Builtins.size(media), 3)
        Ops.set(
          media,
          2,
          Builtins.sformat("%1", Ops.subtract(Builtins.size(media), 2))
        )
        Builtins.y2milestone(
          "Setting media number to %1",
          Ops.get(media, 2)
        )
      end

      content = ReadContentFile(Ops.add(cdpath, "/content"))
      Builtins.y2milestone("Content file: %1", content)
      # don't rewrite the already read content file,
      # content file from CORE9 would rewrite already read file from SLES9
      if current_cd == 1 && content_first_CD == ""
        Builtins.y2milestone(
          "Reading content file %1",
          Ops.add(cdpath, "/content")
        )
        content_first_CD = Convert.to_string(
          SCR.Read(path(".target.string"), Ops.add(cdpath, "/content"))
        )
        Builtins.y2debug("content file: %1", content_first_CD)
      end
      if Ops.get(media, 2, "") != "" &&
          Ops.get(media, 2, "") != "doublesided"
        total_cds = Builtins.tointeger(Ops.get(media, 2, "-1"))
        Builtins.y2milestone("total_cds: %1", total_cds)
        media_id = Ops.get(media, 1, "")
      end

      Builtins.y2debug("base: %1 basever: %2", base, basever)

      # Bug 47599: CD2 of SP1 not copied
      if Ops.get_string(content, "PRODUCT", "dummy") != base &&
          Ops.get_string(content, "VERSION", "dummy") != basever &&
          !standalone
        #  Check if this CD set is based on the base product (CORE)
        if Ops.get_string(content, "BASEPRODUCT", "dummy") != base &&
            Ops.get_string(content, "BASEVERSION", "dummy") != basever
          SCR.Execute(path(".target.umount"), Installation.sourcedir)
          next
        end
      end

      Builtins.foreach(media) do |m|
        if Builtins.substring(m, 0, 5) == "MEDIA"
          m = Builtins.substring(m, 7)

          if !Builtins.contains(medianames, m)
            medianames = Builtins.add(medianames, m)
          end
        end
      end
      Builtins.y2milestone("medianames: %1", medianames)
    end


    distprod = Ops.get_string(content, "LABEL", "")
    flags = Ops.get_string(content, "FLAGS", "")
    flaglist = Builtins.splitstring(flags, " ")

    # Detect SP
    if Builtins.contains(flaglist, "SP")
      Instserver.is_service_pack = true
    else
      Instserver.is_service_pack = false
    end

    Builtins.y2milestone(
      "Service Pack detected: %1",
      Instserver.is_service_pack
    )

    l = Builtins.splitstring(distprod, " ")
    distprod = Builtins.mergestring(l, "-")
    tgt = Builtins.sformat("%1/%2/CD%3", dir, distprod, current_cd)
    Builtins.y2milestone("tgt: %1", tgt)

    cmds = []

    # Copy stuff here.
    # Now, we check if this product on the CD is based on some other product. If
    # yes, then it will be copied into  a sub-directory and not in the requested
    # root.

    code10_source = code10(content)
    Builtins.y2milestone("CODE10 repository: %1", code10_source)

    # This product is based on some other product
    if Builtins.tolower(Ops.get_string(content, "BASEPRODUCT", "")) != "" &&
        Ops.get_string(content, "BASEVERSION", "") != ""
      Builtins.y2milestone("products: %1", Instserver.products)
      Builtins.y2milestone(
        "product require base product: %1, version: %2",
        Ops.get_string(content, "BASEPRODUCT", ""),
        Ops.get_string(content, "BASEVERSION", "")
      )

      found = false
      Builtins.foreach(Instserver.products) do |prod|
        if !found
          cont_file = Ops.add(
            Ops.add(Ops.add(dir, "/"), Ops.get_string(prod, "name", "")),
            "/content"
          )
          if Ops.less_than(SCR.Read(path(".target.size"), cont_file), 0)
            cont_file = Ops.add(
              Ops.add(Ops.add(dir, "/"), Ops.get_string(prod, "name", "")),
              "/CD1/content"
            )
          end

          found = true if IsBaseProduct(content, cont_file)
        end
      end 


      if !found &&
          Ops.greater_or_equal(
            SCR.Read(
              path(".target.size"),
              Ops.add(Installation.sourcedir, "/yast")
            ),
            0
          )
        # check also subdirectories
        cmd = Builtins.sformat(
          "cd %1; find -maxdepth 1 -type d",
          Ops.add(Installation.sourcedir, "/yast")
        )
        Builtins.y2milestone("find command: %1", cmd)
        out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))

        dirs = Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")

        # remove unusable items
        dirs = Builtins.filter(dirs) { |d| d != "." && d != "" }
        Builtins.y2milestone("found product subdirectories: %1", dirs)

        Builtins.foreach(dirs) do |d|
          cont_file = Ops.add(
            Ops.add(Ops.add(Installation.sourcedir, "/yast/"), d),
            "/content"
          )
          Builtins.y2milestone("Trying content file: %1", cont_file)
          found = true if IsBaseProduct(content, cont_file)
        end
      end

      if !found
        # try to search in the base directory (NLD9 workaround)
        cont_file = Ops.add(Installation.sourcedir, "/content")

        if IsBaseProduct(content, cont_file)
          found = true
          Builtins.y2milestone(
            "Base product has been found in the base direcory (file %1)",
            cont_file
          )
        end
      end

      Builtins.y2milestone("products; %1", Instserver.products)

      # code10 add-on is a standalone repository
      if !found && !code10_source
        # add-on medium (e.g. service pack) doesn't match configured repository
        Report.LongError(
          Builtins.sformat(
            _(
              "The medium requires product %1, which is not provided\n" +
                "by the current repository.\n" +
                "\n" +
                "Select the base product medium first."
            ),
            Ops.get_string(content, "BASEPRODUCT", "")
          )
        )
        media_id = ""
        medianames = []
        next
      end

      base = Ops.get_string(content, "BASEPRODUCT", "") # i.e. SUSE CORE
      basever = Ops.get_string(content, "BASEVERSION", "") # i.e. 9


      # code10 is always standalone product
      standalone = code10_source
      # remember for the finalizing
      standalone_product = code10_source

      if code10_source
        if total_cds == 1
          tgt = Builtins.sformat("%1/", dir)
        else
          tgt = Builtins.sformat("%1/CD%2", dir, current_cd)
        end
      end

      Builtins.y2milestone("tgt: %1", tgt)
      SCR.Execute(path(".target.mkdir"), tgt)
      Builtins.y2debug(
        "config=%1, products=%2",
        Instserver.Config,
        Instserver.products
      )

      # and its not a base product
      baseproduct = false

      # No media names, so we have to create the string for media request
      if Builtins.size(medianames) == 0
        prompt_string = Ops.get_string(content, "LABEL", "")
      end

      prompt_totalcds = total_cds

      if current_cd == 1
        proddata = {
          "standalone"  => false,
          "baseproduct" => false,
          "name"        => distprod,
          "SP"          => Instserver.is_service_pack
        }
        Instserver.products = Builtins.add(Instserver.products, proddata)
      end

      # Create product dir
      SCR.Execute(path(".target.mkdir"), tgt)
      Builtins.y2debug(
        "config=%1, products=%2",
        Instserver.Config,
        Instserver.products
      )
    elsif Ops.get_string(content, "PRODUCT", "dummy") == base &&
        Ops.get_string(content, "VERSION", "dummy") == basever
      Builtins.y2milestone("Product is base.")
      if current_cd == 1
        proddata = {
          "standalone"  => true,
          "baseproduct" => true,
          "name"        => distprod,
          "SP"          => Instserver.is_service_pack
        }
        Instserver.products = Builtins.add(Instserver.products, proddata)
      end
      standalone = true
      baseproduct = true
      SCR.Execute(path(".target.mkdir"), tgt)
      Builtins.y2debug(
        "config=%1, products=%2",
        Instserver.Config,
        Instserver.products
      )
    else
      Builtins.y2milestone("")
      if current_cd == 1
        proddata = {
          "standalone"  => true,
          "baseproduct" => true,
          "name"        => distprod,
          "SP"          => Instserver.is_service_pack
        }
        Instserver.products = Builtins.add(Instserver.products, proddata)
      end
      standalone = true
      baseproduct = true
      if Builtins.size(medianames) == 0
        prompt_string = Ops.get_string(content, "LABEL", "")
      end
      # else, we create CD1, CD2, etc. (for code10 always)
      if stype == :onedir && !code10_source
        tgt = Builtins.sformat("%1/", dir)
      else
        tgt = Builtins.sformat("%1/CD%2", dir, current_cd)
      end
      Builtins.y2milestone("tgt: %1", tgt)
      SCR.Execute(path(".target.mkdir"), tgt)
      Builtins.y2debug(
        "config=%1, products=%2",
        Instserver.Config,
        Instserver.products
      )
    end

    Popup.ShowFeedback(
      _("Copying CD contents to local directory"),
      _("This may take a while...")
    )

    # Do actual copying of data
    if Instserver.test
      cmds = Builtins.add(
        cmds,
        Builtins.sformat("cp -pR %1/media.%2 %3", cdpath, current_cd, tgt)
      )
      cmds = Builtins.add(
        cmds,
        Builtins.sformat("cp  %1/content %2", cdpath, tgt)
      )
    else
      cmds = Builtins.add(
        cmds,
        Builtins.sformat(
          "cd %1 && tar cf - . | (cd %2  && tar xBf -)",
          cdpath,
          tgt
        )
      )
    end


    files = []
    # Link files
    if !standalone && current_cd == 1
      if promptmore
        files = ["driverupdate", "linux"]
      else
        files = ["control.xml", "content", "media.1", "boot"]
      end
      cmds = Convert.convert(
        Builtins.union(cmds, Instserver.createLinks(dir, distprod, files)),
        :from => "list",
        :to   => "list <string>"
      )
    end

    if Ops.greater_than(Builtins.size(cmds), 0)
      aborted = false

      Builtins.foreach(cmds) do |cmd|
        Builtins.y2milestone("executing command: %1", cmd)
        res = Convert.to_integer(SCR.Execute(path(".target.bash"), cmd))
        if res != 0
          Builtins.y2milestone(
            "aborting: command %1 failed, exit=%2",
            cmd,
            res
          )

          # close the progress popup
          Popup.ClearFeedback

          # TODO: report more details (stderr)
          Report.Error(_("Error while moving repository content."))
          aborted = true

          raise Break
        end
      end

      if aborted
        # unmount the repository
        SCR.Execute(path(".target.umount"), Installation.sourcedir)
        return :abort
      end

      cmds = []
      cds_copied = true
    end

    # check if there is a new rescue image on the first additional CD
    if promptmore && current_cd == 1 &&
        Ops.greater_than(
          SCR.Read(path(".target.size"), Ops.add(tgt, "/boot")),
          0
        ) &&
        Ops.add(dir, "/") != tgt
      Builtins.y2milestone("Found new 'boot' directory")

      # workaround for flat directory structure (NLD9) - preserve the original content
      move = Builtins.sformat(
        "cd %1; test -d boot -a ! -L boot && mv -b boot boot.old && ln -s boot.old boot",
        dir
      )
      SCR.Execute(path(".target.bash"), move)

      # remember the old "root" file (parse the link)
      linktgt = LinkTarget(Ops.add(dir, "/boot"))
      Builtins.y2milestone("link target: %1", linktgt)

      # remove the old "boot" link
      SCR.Execute(
        path(".target.bash"),
        Builtins.sformat("rm -rf %1/boot", dir)
      )

      # if there are "root" and "rescue" images both then just create a new link
      if Ops.greater_than(
          SCR.Read(path(".target.size"), Ops.add(tgt, "/boot/rescue")),
          0
        ) &&
          Ops.greater_than(
            SCR.Read(path(".target.size"), Ops.add(tgt, "/boot/root")),
            0
          )
        files = ["boot"]
        cmds = Convert.convert(
          Builtins.union(cmds, Instserver.createLinks(dir, distprod, files)),
          :from => "list",
          :to   => "list <string>"
        )
        Builtins.foreach(cmds) do |cmd|
          Builtins.y2debug("executing command: %1", cmd)
          SCR.Execute(path(".target.bash"), cmd)
        end
        cmds = []
      else
        mkdir = Builtins.sformat("mkdir %1/boot", dir)
        SCR.Execute(path(".target.bash"), mkdir)

        relprod = Builtins.substring(tgt, Ops.add(Builtins.size(dir), 1))
        Builtins.y2milestone("relative target: %1", relprod)

        # link the new content there (link every file/directory)
        linkcommand = Builtins.sformat(
          "cd %1/boot; ln -s ../%2/boot/* .",
          dir,
          relprod
        )
        SCR.Execute(path(".target.bash"), linkcommand)

        # add missing links from the original product
        linkcommand = Builtins.sformat(
          "cd %1/boot; ln -s ../%2/* .",
          dir,
          linktgt
        )
        SCR.Execute(path(".target.bash"), linkcommand)

        # recreate the index file
        SCR.Execute(
          path(".target.bash"),
          Builtins.sformat(
            "rm -f %1/boot/directory.yast; cd %1/boot; ls | grep -v -e '^\\.$' -e '^\\.\\.$' > %1/boot/directory.yast",
            dir
          )
        )
      end
    end


    Popup.ClearFeedback

    SCR.Execute(path(".target.umount"), Installation.sourcedir)

    Builtins.y2milestone(
      "total_cds: %1, current_cd: %2, standalone: %3, baseproduct: %4, promptmore: %5, is_service_pack: %6",
      total_cds,
      current_cd,
      standalone,
      baseproduct,
      promptmore,
      Instserver.is_service_pack
    )

    if total_cds == current_cd && !standalone && !baseproduct && !promptmore
      Builtins.y2milestone("Restarting media counter...")

      # ask for the base product
      restart = true
      current_cd = 1
      media_id = ""
      total_cds = 1
      prompt_totalcds = 0
      medianames = []

      prompt_string = base
    elsif total_cds == current_cd && (standalone || baseproduct)
      break
    elsif total_cds == current_cd && promptmore
      break
    else
      current_cd = Ops.add(current_cd, 1)
      Builtins.y2milestone("next cd: %1", current_cd)
    end
    Instserver.standalone = standalone
  end
  return :abort if failed

  if content_first_CD != "" && !code10_source
    Builtins.y2milestone("writing content file from the 1st CD...")
    SCR.Execute(path(".target.remove"), Ops.add(dir, "/content"))
    SCR.Write(
      path(".target.string"),
      Ops.add(dir, "/content"),
      content_first_CD
    )
  end

  if !code10_source
    Builtins.y2milestone("creating new root directory.yast....")
    SCR.Execute(
      path(".target.bash"),
      Builtins.sformat(
        "rm -f %1/directory.yast; cd %1; ls -p | grep -v -e '^\\.$' -e '^\\.\\.$' -e 'directory.yast' > %1/directory.yast",
        dir
      )
    )

    Builtins.y2milestone("standalone_product: %1", standalone_product)

    # refresh MD5SUMS only when it's a standalone product and number of CDs > 1
    if standalone_product && Ops.greater_than(total_cds, 1)
      # recreate MD5SUM files
      out = Convert.to_map(
        SCR.Execute(
          path(".target.bash_output"),
          Builtins.sformat("find %1 -type f -name MD5SUMS", dir)
        )
      )
      Builtins.foreach(
        Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")
      ) do |file|
        if file != ""
          md5dir = Builtins.substring(
            file,
            0,
            Builtins.search(file, "/MD5SUMS")
          )
          # don't change MD5SUMS in product description directory,
          # SHA1 sum of the file is in _signed_ content file
          if md5dir == nil || md5dir == "" ||
              Builtins.issubstring(file, "/setup/descr")
            next
          end

          SCR.Execute(path(".target.remove"), file)

          command = Builtins.sformat("cd %1; md5sum * > MD5SUMS", md5dir)
          Builtins.y2milestone("Command: %1", command)
          SCR.Execute(path(".target.bash"), command, { "LANG" => "C" })
        end
      end
    end
  end

  :next
end

- (Object) FtpDialog

Ftp dialog

Returns:

  • dialog result



1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
# File 'src/include/instserver/dialogs.rb', line 1576

def FtpDialog
  # firewall widget using CWM
  fw_settings = {
    "services"        => ["service:vsftpd"],
    "display_details" => true
  }

  fw_cwm_widget = CWMFirewallInterfaces.CreateOpenFirewallWidget(
    fw_settings
  )

  # Instserver configure2 dialog caption
  caption = _("Installation Server -- FTP")

  ftproot = Ops.get_string(Instserver.ServerSettings, "ftproot", "/srv/ftp")
  ftpalias = Ops.get_string(Instserver.ServerSettings, "ftpalias", "")
  # Instserver nfs dialog contents
  contents = HVSquash(
    VBox(
      Left(
        TextEntry(Id(:ftproot), _("&FTP Server Root Directory:"), ftproot)
      ),
      Left(TextEntry(Id(:ftpalias), _("&Directory Alias:"), ftpalias)),
      VSpacing(1),
      Ops.get_term(fw_cwm_widget, "custom_widget", Empty())
    )
  )


  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "ftp", "ftp"),
    Label.BackButton,
    Label.NextButton
  )

  # install packages before calling SuSEFirewall::Read()
  # to read the service definition file
  if !Instserver.InstallFTPPackages
    Builtins.y2error("FTP server package is not installed, cannot continue")
    return :abort
  end

  # initialize the firewall widget (set the current value)
  CWMFirewallInterfaces.OpenFirewallInit(fw_cwm_widget, "")

  ret = nil
  event = {}

  while true
    event = UI.WaitForEvent
    ret = Ops.get(event, "ID")

    ftproot = Convert.to_string(UI.QueryWidget(Id(:ftproot), :Value))
    ftpalias = Convert.to_string(UI.QueryWidget(Id(:ftpalias), :Value))

    # abort?
    if ret == :abort || ret == :cancel
      if ReallyAbort()
        break
      else
        next
      end
    elsif ret == :back
      break
    elsif ret == :next
      r = false
      Ops.set(Instserver.ServerSettings, "ftproot", ftproot)
      Ops.set(Instserver.ServerSettings, "ftpalias", ftpalias)
      if !Ops.get_boolean(Instserver.ServerSettings, "dry", false)
        # store the firewall setting, (activation is in SetupFTP())
        CWMFirewallInterfaces.OpenFirewallStore(fw_cwm_widget, "", event)
        r = Instserver.SetupFTP(
          Ops.get_string(Instserver.ServerSettings, "directory", ""),
          ftproot,
          ftpalias
        )
        if !r
          Popup.Error(_("Error occurred while configuring FTP."))
          ret = :back
          break
        end
      end
      Instserver.modified = true
      break
    end

    # handle the events, enable/disable the button, show the popup if the firewall button has been clicked
    CWMFirewallInterfaces.OpenFirewallHandle(fw_cwm_widget, "", event)
  end

  deep_copy(ret)
end

- (Object) HttpDialog

Http dialog

Returns:

  • dialog result



1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
# File 'src/include/instserver/dialogs.rb', line 1673

def HttpDialog
  # Instserver configure2 dialog caption
  caption = _("Installation Server -- HTTP")

  # firewall widget using CWM
  fw_settings = {
    "services"        => ["service:apache2"],
    "display_details" => true
  }

  fw_cwm_widget = CWMFirewallInterfaces.CreateOpenFirewallWidget(
    fw_settings
  )

  _alias = Ops.get_string(Instserver.ServerSettings, "alias", "")
  # Instserver nfs dialog contents
  contents = HVSquash(
    VBox(
      Left(TextEntry(Id(:alias), _("&Directory Alias"), _alias)),
      VSpacing(1),
      Ops.get_term(fw_cwm_widget, "custom_widget", Empty())
    )
  )


  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.add(
      Ops.get_string(@HELPS, "http", "http"),
      Ops.get_string(fw_cwm_widget, "help", "")
    ),
    Label.BackButton,
    Label.NextButton
  )

  # initialize the firewall widget (set the current value)
  CWMFirewallInterfaces.OpenFirewallInit(fw_cwm_widget, "")

  ret = nil
  event = {}

  # install packages before calling SuSEFirewall::Read()
  # to read the service definition file
  if !Instserver.InstallHTTPPackages
    Builtins.y2error(
      "HTTP server package is not installed, cannot continue"
    )
    return :abort
  end

  while true
    event = UI.WaitForEvent
    ret = Ops.get(event, "ID")

    # abort?
    if ret == :abort || ret == :cancel
      if ReallyAbort()
        break
      else
        next
      end
    elsif ret == :back
      break
    elsif ret == :next
      _alias = Convert.to_string(UI.QueryWidget(Id(:alias), :Value))
      Ops.set(Instserver.ServerSettings, "alias", _alias)
      if !Ops.get_boolean(Instserver.ServerSettings, "dry", false)
        # store the firewall setting, (activation is in SetupHTTP())
        CWMFirewallInterfaces.OpenFirewallStore(fw_cwm_widget, "", event)

        if !Instserver.SetupHTTP(
            Ops.get_string(Instserver.ServerSettings, "directory", ""),
            _alias
          )
          Popup.Error(_("Error creating HTTPD configuration."))
          ret = :back
          break
        end
      end
      Instserver.modified = true
      break
    end

    # handle the events, enable/disable the button, show the popup if button clicked
    CWMFirewallInterfaces.OpenFirewallHandle(fw_cwm_widget, "", event)
  end

  deep_copy(ret)
end

- (Object) initialize_instserver_dialogs(include_target)



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'src/include/instserver/dialogs.rb', line 11

def initialize_instserver_dialogs(include_target)
  Yast.import "UI"

  textdomain "instserver"

  Yast.import "Installation"
  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "Wizard"
  Yast.import "Instserver"
  Yast.import "CWMFirewallInterfaces"
  Yast.import "String"
  Yast.import "Report"

  Yast.include include_target, "instserver/helps.rb"
  Yast.include include_target, "instserver/routines.rb"
  Yast.include include_target, "instserver/complex.rb"
end

- (Object) IsBaseProduct(content, cont_file)



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'src/include/instserver/dialogs.rb', line 85

def IsBaseProduct(content, cont_file)
  content = deep_copy(content)
  ret = false
  basecontent = ReadContentFile(cont_file)

  Builtins.y2milestone("using content file: %1", cont_file)
  Builtins.y2milestone("content: %1", content)
  Builtins.y2milestone("basecontent: %1", basecontent)

  basecontent = {} if basecontent == nil

  if Builtins.tolower(Ops.get_string(content, "BASEPRODUCT", "")) ==
      Builtins.tolower(Ops.get_string(basecontent, "BASEPRODUCT", "")) &&
      Ops.get_string(content, "BASEVERSION", "") ==
        Ops.get_string(basecontent, "BASEVERSION", "") ||
      # or it's a service pack for maintained product (e.g. NLD)
      # compare BASEPRODUCT and PRODUCT in that case
      !Builtins.haskey(basecontent, "BASEPRODUCT") &&
        !Builtins.haskey(basecontent, "BASEVERSION") &&
        Builtins.tolower(Ops.get_string(content, "BASEPRODUCT", "")) ==
          Builtins.tolower(Ops.get_string(basecontent, "PRODUCT", "")) &&
        Ops.get_string(content, "BASEVERSION", "") ==
          Ops.get_string(basecontent, "VERSION", "")
    # Same base product => OK
    ret = true
    Builtins.y2milestone("found matching base product")
  end

  ret
end

- (Object) LinkTarget(source)



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'src/include/instserver/dialogs.rb', line 67

def LinkTarget(source)
  ret = ""

  command = Ops.add("ls -l ", source)
  res = Convert.to_map(SCR.Execute(path(".target.bash_output"), command))
  out = Builtins.splitstring(Ops.get_string(res, "stdout", ""), "\n")

  if Ops.greater_than(Builtins.size(out), 0)
    line = Ops.get(out, 0, "")

    ret = Builtins.regexpsub(line, "^l.* -> (.*)", "\\1")
  end

  Builtins.y2milestone("Target of %1: %2", source, ret)

  ret
end

- (Object) MediaDialog

Repository configuration dialog

Returns:

  • dialog result



947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
# File 'src/include/instserver/dialogs.rb', line 947

def MediaDialog
  # Instserver configuration dialog caption
  caption = _("Repository Configuration")

  isodir = Ops.get_string(Instserver.ServerSettings, "iso-dir", "")
  cddevs = CDdevices()
  iso = Builtins.size(cddevs) == 0

  # Instserver configure1 dialog contents
  contents = HVSquash(
    VBox(
      RadioButtonGroup(
        Id(:rbg),
        VBox(
          Left(
            RadioButton(
              Id(:disk),
              Opt(:notify),
              _("Read &CD or DVD Medium"),
              iso == false
            )
          ),
          HBox(
            HSpacing(3),
            ComboBox(Id(:drive), _("Data &Source"), cddevs),
            HStretch()
          ),
          VSpacing(1),
          Left(
            RadioButton(
              Id(:iso),
              Opt(:notify),
              _("Use &ISO Images"),
              iso == true
            )
          )
        )
      ),
      VSquash(
        HBox(
          HSpacing(3),
          TextEntry(Id(:isodir), _("Di&rectory with CD Images:"), isodir),
          VBox(
            VSpacing(),
            Bottom(PushButton(Id(:select_dir), _("Select &Directory")))
          )
        )
      )
    )
  )

  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "initial2", ""),
    Label.BackButton,
    Label.NextButton
  )

  UI.ChangeWidget(Id(:isodir), :Enabled, iso)
  UI.ChangeWidget(Id(:select_dir), :Enabled, iso)

  # disable CD widgets when there is no drive detected
  if Builtins.size(cddevs) == 0
    UI.ChangeWidget(Id(:disk), :Enabled, false)
    UI.ChangeWidget(Id(:drive), :Enabled, false)
  end

  ret = nil
  while true
    ret = UI.UserInput

    # abort?
    if ret == :abort || ret == :cancel
      if ReallyAbort()
        break
      else
        next
      end
    elsif ret == :back
      break
    elsif ret == :disk || ret == :iso
      iso = Convert.to_boolean(UI.QueryWidget(Id(:iso), :Value))
      UI.ChangeWidget(Id(:isodir), :Enabled, iso)
      UI.ChangeWidget(Id(:select_dir), :Enabled, iso)
      UI.ChangeWidget(Id(:drive), :Enabled, !iso)
    elsif ret == :select_dir
      new_dir = UI.AskForExistingDirectory(isodir, _("Select Directory"))
      if new_dir != nil
        UI.ChangeWidget(Id(:isodir), :Value, Convert.to_string(new_dir))
      end
      next
    elsif ret == :next
      iso2 = Convert.to_boolean(UI.QueryWidget(Id(:iso), :Value))
      dir = Ops.get_string(Instserver.Config, "directory", "")
      target = Ops.add(
        Ops.add(
          Ops.get_string(Instserver.ServerSettings, "directory", ""),
          "/"
        ),
        dir
      )

      if dir == ""
        Popup.Error(_("Installation server name missing."))
        next
      end

      Ops.set(
        Instserver.ServerSettings,
        "iso-dir",
        Convert.to_string(UI.QueryWidget(Id(:isodir), :Value))
      )

      selecteddrive = Convert.to_string(UI.QueryWidget(Id(:drive), :Value))
      ret2 = :none

      if SCR.Read(path(".target.size"), Ops.add(target, "/content")) != -1
        Popup.Message(
          _("Contents already exist in this directory.\nNot copying CDs.")
        )
        ret2 = :next
      else
        ret2 = Convert.to_symbol(
          CopyCDs(target, :onedir, iso2, false, selecteddrive)
        )
      end

      if ret2 == :next
        # ask for an addon only when the product is pre-CODE10
        ask_for_addon = false

        if Ops.greater_than(
            SCR.Read(path(".target.size"), Ops.add(target, "/content")),
            0
          )
          content_file = ReadContentFile(Ops.add(target, "/content"))
          Builtins.y2debug("Parsed content file: %1", content_file)

          ask_for_addon = !code10(content_file)
        end

        Builtins.y2milestone("ask_for_addon: %1", ask_for_addon)

        # for translators: popup question (prefer more shorter lines than few long lines)
        while ask_for_addon &&
            Popup.YesNo(
              _(
                "Add an additional product (Service Pack, Additional\nPackage CD, etc.) to the repository?"
              )
            ) == true
          CopyCDs(target, :onedir, iso2, true, selecteddrive)
        end
      end

      if ret2 == :next
        content = {}
        contentpath = Builtins.sformat("%1/content", target)

        Instserver.createOrderFiles(target)

        if Ops.greater_than(SCR.Read(path(".target.size"), contentpath), 0)
          content = ReadContentFile(contentpath)
        else
          Builtins.y2milestone("cannot read %1", contentpath)
          # try CD1 subdir if the previous attempt has failed
          contentpath = Builtins.sformat("%1/CD1/content", target)

          if Ops.greater_than(
              SCR.Read(path(".target.size"), contentpath),
              0
            )
            content = ReadContentFile(contentpath)
          else
            Builtins.y2error(
              "cant read content file, something nasty happened: %1",
              contentpath
            )
          end
        end

        Builtins.y2debug("content: %1", content)
        Instserver.Config = Convert.convert(
          Builtins.union(Instserver.Config, content),
          :from => "map",
          :to   => "map <string, any>"
        )
      else
        # copying has been aborted, remove the repository
        cmd = Ops.add("/bin/rm -rf ", target)
        Builtins.y2milestone("Removing directory %1", target)

        if SCR.Execute(path(".target.bash"), cmd) != 0
          Builtins.y2error("Cannot remove directory %1", target)
        end

        Instserver.Config = {}
      end

      Instserver.UpdateConfig
      Instserver.modified = true
      break
    else
      Builtins.y2error("unexpected retcode: %1", ret)
      next
    end
  end

  deep_copy(ret)
end

- (Object) NfsDialog

NFS dialog

Returns:

  • dialog result



1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
# File 'src/include/instserver/dialogs.rb', line 1476

def NfsDialog
  # Instserver configure2 dialog caption
  caption = _("Installation Server -- NFS")

  nfsoptions = "ro,root_squash,sync,no_subtree_check"
  wildcard = "*"

  # firewall widget using CWM
  fw_settings = {
    "services"        => ["service:nfs-kernel-server"],
    "display_details" => true
  }

  fw_cwm_widget = CWMFirewallInterfaces.CreateOpenFirewallWidget(
    fw_settings
  )

  # Instserver nfs dialog contents
  contents = HVSquash(
    VBox(
      Left(TextEntry(Id(:wildcard), _("&Host Wild Card"), wildcard)),
      VSpacing(0.5),
      Left(TextEntry(Id(:nfsoptions), _("&Options"), nfsoptions)),
      VSpacing(1),
      Ops.get_term(fw_cwm_widget, "custom_widget", Empty())
    )
  )


  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.add(
      Ops.get_string(@HELPS, "nfs", "nfs"),
      Ops.get_string(fw_cwm_widget, "help", "")
    ),
    Label.BackButton,
    Label.NextButton
  )

  # initialize the firewall widget (set the current value)
  CWMFirewallInterfaces.OpenFirewallInit(fw_cwm_widget, "")

  ret = nil
  event = {}

  while true
    event = UI.WaitForEvent
    ret = Ops.get(event, "ID")

    # abort?
    if ret == :abort || ret == :cancel
      if ReallyAbort()
        break
      else
        next
      end
    elsif ret == :back
      break
    elsif ret == :next
      r = false
      nfsoptions = Convert.to_string(
        UI.QueryWidget(Id(:nfsoptions), :Value)
      )
      wildcard = Convert.to_string(UI.QueryWidget(Id(:wildcard), :Value))
      if !Ops.get_boolean(Instserver.ServerSettings, "dry", false)
        # store the firewall setting, (activation is in SetupNFS())
        CWMFirewallInterfaces.OpenFirewallStore(fw_cwm_widget, "", event)

        r = Instserver.SetupNFS(
          Ops.get_string(Instserver.ServerSettings, "directory", ""),
          Ops.add(
            Ops.add(
              Ops.add(wildcard, "("),
              Builtins.deletechars(nfsoptions, " ")
            ),
            ")"
          )
        )
        if !r
          Popup.Error(_("Error occurred while configuring NFS."))
          next
        end
      end
      Instserver.modified = true


      break
    end

    # handle the events, enable/disable the button, show the popup if button clicked
    CWMFirewallInterfaces.OpenFirewallHandle(fw_cwm_widget, "", event)
  end

  deep_copy(ret)
end

- (Object) ServerDialog

Server dialog

Returns:

  • dialog result



1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
# File 'src/include/instserver/dialogs.rb', line 1345

def ServerDialog
  # Instserver server dialog caption
  caption = _("Initial Setup -- Initial Setup")

  dir = Ops.get_string(
    Instserver.ServerSettings,
    "directory",
    "/srv/install"
  )
  dry = Ops.get_boolean(Instserver.ServerSettings, "dry", false)
  source = Ops.get_symbol(Instserver.ServerSettings, "service", :http)

  c1 = HBox(
    VBox(
      Left(
        CheckBox(
          Id(:dry),
          Opt(:notify),
          _("Do Not Configure Any Net&work Services")
        )
      ),
      VSquash(
        HBox(
          TextEntry(Id(:dir), _("Di&rectory to Contain Repositories:"), dir),
          VBox(
            VSpacing(),
            Bottom(PushButton(Id(:select_dir), _("Select &Directory")))
          )
        )
      )
    )
  )

  buttons = VBox(
    # radio button label
    Left(
      RadioButton(
        Id(:http),
        _("&Configure as HTTP Repository"),
        source == :http
      )
    ),
    # radio button label
    Left(
      RadioButton(
        Id(:ftp),
        _("&Configure as FTP Repository"),
        source == :ftp
      )
    ),
    # radio button label
    Left(
      RadioButton(
        Id(:nfs),
        _("&Configure as NFS Repository"),
        source == :nfs
      )
    )
  )

  # Instserver configure2 dialog contents
  contents = HVSquash(
    VBox(RadioButtonGroup(Id(:service), buttons), VSpacing(1), c1)
  )

  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "server", "server"),
    Label.BackButton,
    Label.NextButton
  )

  ret = nil
  while true
    dry = Convert.to_boolean(UI.QueryWidget(Id(:dry), :Value))
    if dry
      UI.ChangeWidget(Id(:service), :Enabled, false)
    else
      UI.ChangeWidget(Id(:service), :Enabled, true)
    end

    ret = UI.UserInput

    source = Convert.to_symbol(UI.QueryWidget(Id(:service), :CurrentButton))
    dir = Convert.to_string(UI.QueryWidget(Id(:dir), :Value))

    # abort?
    if ret == :abort || ret == :cancel
      if ReallyAbort()
        break
      else
        next
      end
    elsif ret == :select_dir
      new_dir = UI.AskForExistingDirectory(dir, _("Select Directory"))
      if new_dir != nil
        UI.ChangeWidget(Id(:dir), :Value, Convert.to_string(new_dir))
      end
      next
    elsif ret == :back
      break
    elsif ret == :next
      r = false
      if dir == ""
        Popup.Error(
          _("Directory path for the installation server missing.")
        )
        next
      end
      Ops.set(Instserver.ServerSettings, "service", source)
      Ops.set(Instserver.ServerSettings, "dry", dry)
      Ops.set(Instserver.ServerSettings, "directory", dir)
      Instserver.modified = true
      if dry
        ret = :next
      else
        ret = source
      end
      break
    elsif ret != :dry
      Builtins.y2error("unexpected retcode: %1", ret)
      next
    end
  end

  deep_copy(ret)
end

- (Object) SourceConfigDialog

Repository configuration dialog

Returns:

  • dialog result



1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
# File 'src/include/instserver/dialogs.rb', line 1160

def SourceConfigDialog
  # Instserver configuration dialog caption
  caption = _("Repository Configuration")

  dir = Ops.get_string(Instserver.Config, "directory", "")
  slp = Ops.get_boolean(Instserver.Config, "slp", false)

  # Instserver configure1 dialog contents
  contents = HVSquash(
    VBox(
      Left(TextEntry(Id(:dir), _("Repository &Name:"), dir)),
      VSpacing(1),
      Left(
        CheckBox(
          Id(:slp),
          _("A&nnounce as Installation Service with SLP"),
          slp
        )
      )
    )
  )

  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "initial", ""),
    Label.BackButton,
    Label.NextButton
  )

  current = deep_copy(Instserver.Config)

  ret = nil
  while true
    ret = UI.UserInput
    dir = Convert.to_string(UI.QueryWidget(Id(:dir), :Value))
    target = Ops.add(
      Ops.add(
        Ops.get_string(Instserver.ServerSettings, "directory", ""),
        "/"
      ),
      dir
    )

    # abort?
    if ret == :abort || ret == :cancel
      if ReallyAbort()
        break
      else
        next
      end
    elsif ret == :back
      break
    elsif ret == :next
      if dir == ""
        Popup.Error(_("Installation server name missing."))
        next
      elsif dir !=
          Builtins.filterchars(
            dir,
            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-."
          ) ||
          Ops.greater_than(Builtins.size(dir), 127)
        errmsg = _("Invalid repository name.")
        Popup.Error(errmsg)
        next
      elsif dir != Ops.get_string(Instserver.Config, "name", "") &&
          Builtins.haskey(Instserver.Configs, dir)
        # an error message - entered repository name already exists
        Popup.Error(
          Builtins.sformat(
            _("Repository '%1' already exists,\nenter another name."),
            dir
          )
        )
        next
      # create directory only for a new repository
      elsif Instserver.Config == {}
        mkdircmd = Ops.add("mkdir -p ", target)

        Builtins.y2debug("executing: %1", mkdircmd)
        if SCR.Execute(path(".target.bash"), mkdircmd) != 0
          Popup.Error(
            Builtins.sformat(
              _(
                "Error while creating <tt>repository</tt> directory.\n" +
                  "Verify that the directory \n" +
                  " %1 \n" +
                  "is writable and try again.\n"
              ),
              Ops.get_string(Instserver.ServerSettings, "directory", "")
            )
          )
          next
        end
      end

      # check if the repository has been already removed (bnc#187280)
      if Builtins.contains(Instserver.to_delete, dir)
        Builtins.y2milestone("Repository %1 has been marked to delete", dir)

        # confirm removal of a repository, the action is done immediately and cannot be reverted
        confirm = Builtins.sformat(
          _(
            "Repository '%1' has been marked to delete.\n" +
              "When adding a new repository with the same name\n" +
              "the old content must deleted right now.\n" +
              "\n" +
              "Really delete the old content and create it from scratch?"
          ),
          dir
        )

        if Popup.YesNo(confirm)
          Builtins.y2milestone("Removing the old repository")
          rmdir = Ops.add(
            Ops.add(
              Ops.get_string(Instserver.ServerSettings, "directory", ""),
              "/"
            ),
            dir
          )
          rm = Builtins.sformat("rm -rf '%1'", String.Quote(rmdir))

          Builtins.y2milestone("Executing: %1", rm)
          SCR.Execute(path(".target.bash"), rm)

          # remove it from to_delete list, it has just been deleted
          Instserver.to_delete = Builtins.filter(Instserver.to_delete) do |del|
            del != dir
          end

          Builtins.y2milestone(
            "Updated list of removed repositories: %1",
            Instserver.to_delete
          )
        else
          Builtins.y2milestone("Not removing the old repository")
          next
        end
      end


      if dir != Ops.get_string(Instserver.Config, "name", "") &&
          Ops.get_string(Instserver.Config, "name", "") != ""
        # mark the directory content for moving at write
        Instserver.renamed = Builtins.add(
          Instserver.renamed,
          Ops.get_string(Instserver.Config, "name", ""),
          dir
        )

        # remove the old configuration in Instserver::UpdateConfig()
        Ops.set(
          Instserver.Config,
          "old_name",
          Ops.get_string(Instserver.Config, "name", "")
        )
      end

      slp = Convert.to_boolean(UI.QueryWidget(Id(:slp), :Value))

      Ops.set(Instserver.Config, "name", dir)
      Ops.set(Instserver.Config, "directory", dir)
      Ops.set(Instserver.Config, "slp", slp)

      if current != {}
        # update modified repository now, the workflow has in this case only one step
        Instserver.UpdateConfig
        Instserver.modified = true
      end

      break
    else
      Builtins.y2error("unexpected retcode: %1", ret)
      next
    end
  end

  deep_copy(ret)
end