File 0001-Add-option-to-disable-swap-creation.patch of Package yast2-storage

From bcdcbadae56566470c49edb2f9989d6b925ab718 Mon Sep 17 00:00:00 2001
From: Martin Koegler <martin.koegler@chello.at>
Date: Fri, 18 Dec 2015 18:16:15 +0100
Subject: [PATCH] Add option to disable swap creation

---
 src/modules/StorageProposal.rb | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/modules/StorageProposal.rb b/src/modules/StorageProposal.rb
index b9d7d26..1c6b1cd 100644
--- a/src/modules/StorageProposal.rb
+++ b/src/modules/StorageProposal.rb
@@ -65,6 +65,7 @@ module Yast
 
       @proposal_home = false
       @proposal_home_fs = :xfs
+      @proposal_swap = true
       @proposal_lvm = false
       @proposal_encrypt = false
       @proposal_root_fs = :btrfs
@@ -142,6 +143,14 @@ module Yast
       Builtins.y2milestone("SetProposalSnapshots val: %1", val)
     end
 
+    def GetProposalSwap()
+      @proposal_swap
+    end
+
+    def SetProposalSwap(val)
+      @proposal_swap = val
+      Builtins.y2milestone("SetProposalSwap val: %1", val)
+    end
 
     def GetProposalSuspend
       @proposal_suspend
@@ -179,15 +188,17 @@ module Yast
         SetProposalRootFs(Partitions.DefaultFs())
         SetProposalHomeFs(Partitions.DefaultHomeFs())
         SetProposalSnapshots(Ops.get_boolean(@cfg_xml, "prop_snapshots", false))
+        SetProposalSwap(Ops.get_boolean(@cfg_xml, "need_swap", true))
       end
       Builtins.y2milestone(
-        "SetProposalDefault home: %1 lvm: %2 encypt: %3 home_only: %4 snapshots: %5 suspend: %6 root_fs: %7 home_fs: %8",
+        "SetProposalDefault home: %1 lvm: %2 encypt: %3 home_only: %4 snapshots: %5 suspend: %6 swap: %7 root_fs: %8 home_fs: %9",
         @proposal_home,
         @proposal_lvm,
         @proposal_encrypt,
         home_only,
         @proposal_snapshots,
         @proposal_suspend,
+        @proposal_swap,
         @proposal_root_fs,
         @proposal_home_fs
       )
@@ -289,6 +300,10 @@ module Yast
         tmp = ProductFeatures.GetFeature("partitioning", "proposal_snapshots")
         Ops.set(@cfg_xml, "prop_snapshots", tmp == "" || tmp == true ? true : false)
 
+        # GetBooleanFeature cannot distinguish between missing and false
+        tmp = ProductFeatures.GetFeature("partitioning", "need_swap")
+        Ops.set(@cfg_xml, "need_swap", tmp == "" || tmp == true ? true : false)
+
         itmp = ProductFeatures.GetIntegerFeature(
           "partitioning",
           "btrfs_increase_percentage"
@@ -3530,6 +3545,9 @@ module Yast
         disk,
         partitions
       )
+      if !GetProposalSwap()
+        return ret
+      end
       swaps = Builtins.filter(partitions) do |p|
         Ops.get_symbol(p, "type", :unknown) != :free &&
           !Ops.get_boolean(p, "delete", false) &&
@@ -3901,7 +3919,7 @@ module Yast
       conf = { "partitions" => [] }
       swap_sizes = []
       avail_size = get_avail_size_mb(Ops.get_list(disk, "partitions", []))
-      if !have_swap
+      if !have_swap && GetProposalSwap()
         swap_sizes = get_swap_sizes(avail_size)
         swap = {
           "mount"       => "swap",
@@ -3988,7 +4006,7 @@ module Yast
         )
         ps1 = do_flexible_disk_conf(disk, conf, false, false)
       end
-      if !have_swap
+      if !have_swap && GetProposalSwap()
         diff = Ops.subtract(
           Ops.get(swap_sizes, 0, 256),
           Ops.get(swap_sizes, 1, 256)
@@ -4770,7 +4788,7 @@ module Yast
                 )
               end
             end
-            if !have_swap
+            if !have_swap && GetProposalSwap()
               swap_sizes = get_swap_sizes(avail_size)
               swap = {
                 "mount"       => "swap",
@@ -4869,7 +4887,7 @@ module Yast
               )
               ps1 = do_flexible_disk_conf(disk, conf, have_boot, mode == :reuse)
             end
-            if !have_swap
+            if !have_swap && GetProposalSwap()
               diff = Ops.subtract(
                 Ops.get(swap_sizes, 0, 256),
                 Ops.get(swap_sizes, 1, 256)
@@ -5964,7 +5982,7 @@ module Yast
           modify_vm(
             Ops.get_map(ret, ["target", vg_key], {}),
             opts,
-            Builtins.size(r) == 0
+            Builtins.size(r) == 0 && GetProposalSwap()
           )
         )
         Ops.set(ret, ["target", sol_disk], Ops.get_map(solution, sol_disk, {}))
@@ -6088,7 +6106,7 @@ module Yast
         Ops.set(
           ret,
           ["target", vg_key],
-          modify_vm(vg, opts, Builtins.size(r) == 0)
+          modify_vm(vg, opts, Builtins.size(r) == 0 && GetProposalSwap())
         )
         Ops.set(ret, ["target", ddev], disk)
         Ops.set(
-- 
2.6.2