Module: Yast::AutoinstallAutopartInclude
- Defined in:
- ../../src/include/autoinstall/autopart.rb
Instance Method Summary (collapse)
- - (Object) add_cylinder_info(conf, gap)
- - (Object) add_part_recursive(ps, g)
- - (Object) AddFilesysData(st_map, xml_map)
- - (Object) AddSubvolData(st_map, xml_map)
- - (Object) distribute_space(rest, weights, added, ps)
- - (Object) do_weighting(ps, g)
- - (Object) find_matching_disk(disks, target, conf)
- - (Object) find_matching_partition_size(gap, nr)
- - (Object) get_gap_info(disk, pd, add_exist_linux)
-
- (Object) get_gaps(start, _end, pd, part, add_exist_linux)
Collect gap information.
- - (Object) get_perfect_list(ps, g)
- - (Object) GetAllPartitions(device)
- - (Object) GetNoneLinuxPartitions(device)
- - (Object) initialize_autoinstall_autopart(include_target)
- - (Object) normalize_gaps(ps, g)
-
- (Hash) preprocess_partition_config(xmlflex)
Read partition data from XML control file.
- - (Object) process_partition_data(dev, solution)
- - (Boolean) propose_default_fs?(partition)
- - (Boolean) raw_partition?(partition)
- - (Object) remove_possible_partitions(disk, pm)
- - (Object) try_add_boot(conf, disk)
- - (Object) try_resize_windows(disk)
Instance Method Details
- (Object) add_cylinder_info(conf, gap)
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 1341 1342 1343 1344 1345 1346 1347 1348 1349 |
# File '../../src/include/autoinstall/autopart.rb', line 1249 def add_cylinder_info(conf, gap) conf = deep_copy(conf) gap = deep_copy(gap) big_cyl = 4 * 1024 * 1024 * 1024 cyl_size = Ops.get_integer(gap, "cyl_size", 1) # // FIXME: Why is sorting needed here? # conf["partitions"] = # sort( map a, map b, conf["partitions"]:[], # ``({ # if( a["max_cyl"]:big_cyl != b["max_cyl"]:big_cyl ) # return( a["max_cyl"]:big_cyl < b["max_cyl"]:big_cyl ); # else # return( a["size"]:0 > b["size"]:0 ); # })); Builtins.y2milestone("parts %1", Ops.get_list(conf, "partitions", [])) sum = 0 Ops.set( conf, "partitions", Builtins.maplist(Ops.get_list(conf, "partitions", [])) do |p| sum = Ops.add(sum, Ops.get_integer(p, "pct", 0)) Ops.set( p, "cylinders", Ops.divide( Ops.subtract(Ops.add(Ops.get_integer(p, "size", 0), cyl_size), 1), cyl_size ) ) # p["cylinders"] = (p["size"]:0)/cyl_size; mg = find_matching_partition_size( gap, Ops.get_integer(p, "usepart", 0) ) if mg != {} # need next two lines because of #284102 # FIXME: check problems with resizing Ops.set(p, "cylinders", Ops.get_integer(mg, "cylinders", 0)) Ops.set(p, "size", Ops.get_integer(mg, "size", 0)) if Ops.less_than( Ops.get_integer(p, "usepart", 0), Ops.get_integer(gap, "max_primary", 0) ) Ops.set(p, "partition_type", "primary") end end Ops.set(p, "cylinders", 1) if Ops.get_integer(p, "cylinders", 0) == 0 deep_copy(p) end ) Builtins.y2milestone("sum %1", sum) Builtins.y2milestone("parts %1", Ops.get_list(conf, "partitions", [])) if Ops.greater_than(sum, 100) rest = Ops.subtract(sum, 100) Ops.set( conf, "partitions", Builtins.maplist(Ops.get_list(conf, "partitions", [])) do |p| if Builtins.haskey(p, "pct") pct = Ops.get_integer(p, "pct", 0) diff = Ops.divide( Ops.add(Ops.multiply(rest, pct), Ops.divide(sum, 2)), sum ) sum = Ops.subtract(sum, pct) rest = Ops.subtract(rest, diff) Ops.set(p, "pct", Ops.subtract(pct, diff)) end deep_copy(p) end ) end Ops.set( conf, "partitions", Builtins.maplist(Ops.get_list(conf, "partitions", [])) do |p| if Builtins.haskey(p, "pct") cyl = Ops.multiply( Ops.divide(Ops.get_integer(gap, "sum", 0), 100), Ops.get_integer(p, "pct", 0) ) cyl = Ops.divide(Ops.add(cyl, Ops.divide(cyl_size, 2)), cyl_size) cyl = 1 if cyl == 0 Ops.set(p, "want_cyl", cyl) end if Ops.greater_than(Ops.get_integer(p, "max", 0), 0) cyl = Ops.divide( Ops.subtract(Ops.add(Ops.get_integer(p, "max", 0), cyl_size), 1), cyl_size ) Ops.set(p, "size_max_cyl", cyl) if Ops.greater_than(Ops.get_integer(p, "want_cyl", 0), cyl) Ops.set(p, "want_cyl", cyl) end end deep_copy(p) end ) Builtins.y2milestone("parts %1", Ops.get_list(conf, "partitions", [])) deep_copy(conf) end |
- (Object) add_part_recursive(ps, g)
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 1670 1671 1672 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 |
# File '../../src/include/autoinstall/autopart.rb', line 1589 def add_part_recursive(ps, g) ps = deep_copy(ps) g = deep_copy(g) Builtins.y2milestone( "add_part_recursive partition index %1", Ops.get_integer(g, "procpart", 0) ) Builtins.y2milestone("add_part_recursive partitions %1", ps) Builtins.y2milestone("add_part_recursive gap %1", g) # creation_needed indicates the case, that we do not # create a single partition but are reusing some creation_needed = false Builtins.foreach( Convert.convert(ps, :from => "list", :to => "list <map>") ) do |p| creation_needed = true if Ops.get_boolean(p, "create", true) == true end Builtins.y2milestone( "add_part_recursive creation is needed? %1", creation_needed ) lg = Builtins.eval(g) gindex = 0 pindex = Ops.get_integer(lg, "procpart", 0) part = Ops.get_map(ps, pindex, {}) Ops.set(lg, "procpart", Ops.add(pindex, 1)) Builtins.y2milestone("working on partition %1", part) Builtins.foreach(Ops.get_list(lg, "gap", [])) do |e| Builtins.y2milestone("add_part_recursive start: gap section %1", e) # speed up partitioning calculation (bnc#620212) reuseCondition = true if Ops.get_boolean(part, "create", true) == false && Builtins.haskey(part, "partition_nr") && Ops.get_integer(part, "partition_nr", 0) != Ops.get_integer(e, "nr", 0) Builtins.y2milestone( "gap can't be used. %1 != %2", Ops.get_integer(part, "partition_nr", 0), Ops.get_integer(e, "nr", 0) ) reuseCondition = false end primary = Ops.get_string(part, "partition_type", "none") == "primary" if reuseCondition && Ops.less_or_equal( Ops.get_integer(part, "max_cyl", 0), Ops.get_integer(e, "end", 0) ) && Ops.less_or_equal( Ops.get_integer(part, "cylinders", 0), Ops.get_integer(e, "cylinders", 0) ) && (!creation_needed || !Ops.get_boolean(e, "extended", false) && Ops.greater_than( Builtins.size(Ops.get_list(lg, "free_pnr", [])), 0 ) || primary && Ops.greater_than(Ops.get_integer(e, "created", 0), 0) && Ops.get_boolean(e, "extended", false) && Ops.greater_than( Builtins.size(Ops.get_list(lg, "free_pnr", [])), 0 ) || !primary && Ops.get_boolean(e, "extended", false) && Ops.greater_than( Builtins.size(Ops.get_list(lg, "ext_pnr", [])), 0 )) llg = Builtins.eval(lg) if Ops.get_boolean(e, "exists", false) Ops.set(llg, ["gap", gindex, "cylinders"], 0) else Ops.set( llg, ["gap", gindex, "cylinders"], Ops.subtract( Ops.get_integer(llg, ["gap", gindex, "cylinders"], 0), Ops.get_integer(part, "cylinders", 0) ) ) end addl = [pindex] if Ops.get_boolean(e, "exists", false) || Ops.get_boolean(e, "reuse", false) addl = Builtins.add(addl, Ops.get_integer(e, "nr", 0)) elsif Ops.get_boolean(e, "extended", false) && !primary addl = Builtins.add(addl, Ops.get_integer(llg, ["ext_pnr", 0], 5)) Ops.set( llg, "ext_pnr", Builtins.remove( Convert.convert( Ops.get(llg, "ext_pnr") { [0] }, :from => "any", :to => "list <const integer>" ), 0 ) ) else addl = Builtins.add(addl, Ops.get_integer(llg, ["free_pnr", 0], 1)) Ops.set( llg, "free_pnr", Builtins.remove( Convert.convert( Ops.get(llg, "free_pnr") { [0] }, :from => "any", :to => "list <const integer>" ), 0 ) ) end Ops.set( llg, ["gap", gindex, "added"], Builtins.add(Ops.get_list(llg, ["gap", gindex, "added"], []), addl) ) if Ops.less_than(Ops.add(pindex, 1), Builtins.size(ps)) add_part_recursive(ps, llg) else ng = normalize_gaps(ps, llg) val = do_weighting(ps, ng) Builtins.y2milestone( "add_part_recursive val %1 cur_weight %2 size %3", val, @cur_weight, Builtins.size(@cur_gap) ) if Ops.greater_than(val, @cur_weight) || Builtins.size(@cur_gap) == 0 @cur_weight = val @cur_gap = Builtins.eval(ng) end end end gindex = Ops.add(gindex, 1) end nil end |
- (Object) AddFilesysData(st_map, xml_map)
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File '../../src/include/autoinstall/autopart.rb', line 55 def AddFilesysData(st_map, xml_map) st_map = deep_copy(st_map) xml_map = deep_copy(xml_map) ret = AddSubvolData(st_map, xml_map) if Ops.get_boolean(ret, "format", false) && !Builtins.isempty(Ops.get_string(xml_map, "mkfs_options", "")) Ops.set( ret, "mkfs_options", Ops.get_string(xml_map, "mkfs_options", "") ) Builtins.y2milestone( "AddFilesysData mkfs_options:%1", Ops.get_string(ret, "mkfs_options", "") ) end deep_copy(ret) end |
- (Object) AddSubvolData(st_map, xml_map)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File '../../src/include/autoinstall/autopart.rb', line 23 def AddSubvolData(st_map, xml_map) st_map = deep_copy(st_map) xml_map = deep_copy(xml_map) ret = deep_copy(st_map) if Ops.get_symbol(ret, "used_fs", :unknown) == :btrfs Builtins.y2milestone("AddSubvolData st:%1", st_map) Builtins.y2milestone("AddSubvolData xml:%1", xml_map) if Builtins.haskey(xml_map, "subvolumes") sv_prep = "" if FileSystems.default_subvol != "" sv_prep = Ops.add(FileSystems.default_subvol, "/") end Ops.set( ret, "subvol", Builtins.maplist(Ops.get_list(xml_map, "subvolumes", [])) do |s| if !Builtins.isempty(sv_prep) && Builtins.substring(s, 0, Builtins.size(sv_prep)) != sv_prep s = Ops.add(sv_prep, s) end { "name" => s, "create" => true } end ) end if Builtins.haskey(ret, "subvolumes") ret = Builtins.remove(ret, "subvolumes") end Builtins.y2milestone("AddSubvolData ret:%1", ret) end deep_copy(ret) end |
- (Object) distribute_space(rest, weights, added, ps)
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 |
# File '../../src/include/autoinstall/autopart.rb', line 1915 def distribute_space(rest, weights, added, ps) weights = deep_copy(weights) added = deep_copy(added) ps = deep_copy(ps) diff_sum = 0 sum = 0 index = 0 pindex = 0 Builtins.y2milestone("rest %1 weights %2 added %3", rest, weights, added) Builtins.foreach( Convert.convert(added, :from => "list", :to => "list <list>") ) do |p| pindex = Ops.get_integer(p, 0, 0) if Ops.get_integer(ps, [pindex, "size_max_cyl"], 0) == 0 || Ops.get_boolean(ps, [pindex, "grow"], false) || Ops.greater_than( Ops.get_integer(ps, [pindex, "size_max_cyl"], 0), Ops.get_integer(p, 2, 0) ) sum = Ops.add(sum, Ops.get_integer(weights, index, 0)) end index = Ops.add(index, 1) end index = 0 Builtins.y2milestone("sum %1 rest %2 added %3", sum, rest, added) Builtins.foreach( Convert.convert(added, :from => "list", :to => "list <list>") ) do |p| pindex = Ops.get_integer(p, 0, 0) if Builtins.size(p) == 3 && Ops.greater_than(sum, 0) && (Ops.get_integer(ps, [pindex, "size_max_cyl"], 0) == 0 || Ops.get_boolean(ps, [pindex, "grow"], false) || Ops.greater_than( Ops.get_integer(ps, [pindex, "size_max_cyl"], 0), Ops.get_integer(p, 2, 0) )) diff = Ops.divide( Ops.add( Ops.multiply(rest, Ops.get_integer(weights, index, 0)), Ops.divide(sum, 2) ), sum ) if Ops.greater_than( Ops.get_integer(ps, [pindex, "size_max_cyl"], 0), 0 ) && !Ops.get_boolean(ps, [pindex, "grow"], false) && Ops.greater_than( diff, Ops.subtract( Ops.get_integer(ps, [pindex, "size_max_cyl"], 0), Ops.get_integer(p, 2, 0) ) ) diff = Ops.subtract( Ops.get_integer(ps, [pindex, "size_max_cyl"], 0), Ops.get_integer(p, 2, 0) ) end sum = Ops.subtract(sum, Ops.get_integer(weights, index, 0)) rest = Ops.subtract(rest, diff) Ops.set( added, [index, 2], Ops.add(Ops.get_integer(added, [index, 2], 0), diff) ) diff_sum = Ops.add(diff_sum, diff) Builtins.y2milestone( "sum %1 rest %2 diff %3 added %4", sum, rest, diff, Ops.get_list(added, index, []) ) end index = Ops.add(index, 1) end ret = { "added" => added, "diff" => diff_sum } Builtins.y2milestone("ret (distribute_space) %1", ret) deep_copy(ret) end |
- (Object) do_weighting(ps, g)
1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 |
# File '../../src/include/autoinstall/autopart.rb', line 1997 def do_weighting(ps, g) ps = deep_copy(ps) g = deep_copy(g) Builtins.y2milestone("do_weighting gap %1", Ops.get_list(g, "gap", [])) ret = 0 index = 0 ret = 0 if @cur_mode == :free if @cur_mode == :reuse ret = Ops.subtract(ret, 100) elsif @cur_mode == :resize ret = Ops.subtract(ret, 1000) elsif @cur_mode == :desparate ret = Ops.subtract(ret, 1000000) end Builtins.y2milestone("weight after mode ret %1", ret) Builtins.foreach(Ops.get_list(g, "gap", [])) do |e| Builtins.y2milestone("added %1", Ops.get_list(e, "added", [])) if !Ops.get_boolean(e, "exists", false) && Ops.greater_than(Ops.get_integer(e, "cylinders", 0), 0) ret = Ops.subtract(ret, 5) if Ops.less_than( Ops.get_integer(e, "cylinders", 0), Ops.divide(Ops.get_integer(g, "disk_cyl", 0), 20) ) ret = Ops.subtract(ret, 10) end Builtins.y2milestone("weight (cyl) %1", ret) end Builtins.y2milestone("weight after gaps %1", ret) Builtins.foreach(Ops.get_list(e, "added", [])) do |p| index = Ops.get_integer(p, 0, 0) # bnc#613366 - an existing swap partition can accidently be reused # if( e["exists"]:false && ps[index,"mount"]:""=="swap" && # e["swap"]:false ) # { # ret = ret + 100; # y2milestone( "weight after swap reuse %1", ret ); # } if Ops.greater_than(Ops.get_integer(ps, [index, "want_cyl"], 0), 0) diff = Ops.subtract( Ops.get_integer(ps, [index, "want_cyl"], 0), Ops.get_integer(p, 2, 0) ) normdiff = Ops.divide( Ops.multiply(diff, 100), Ops.get_integer(p, 2, 0) ) if Ops.less_than(diff, 0) normdiff = Ops.unary_minus(normdiff) elsif Ops.greater_than(diff, 0) normdiff = Ops.divide(normdiff, 10) end ret = Ops.subtract(ret, normdiff) ret = Ops.add( ret, Ops.divide( Ops.multiply( Ops.get_integer(ps, [index, "want_cyl"], 0), Ops.get_integer(g, "cyl_size", 1) ), 100 * 1024 * 1024 ) ) Builtins.y2milestone("after pct parts %1", ret) end if Ops.get_integer(ps, [index, "size"], 0) == 0 ret = Ops.add( ret, Ops.divide( Ops.multiply( Ops.get_integer(p, 2, 0), Ops.get_integer(g, "cyl_size", 1) ), 50 * 1024 * 1024 ) ) Builtins.y2milestone("after maximizes parts %1", ret) end if Ops.greater_than( Ops.get_integer(ps, [index, "size_max_cyl"], 0), 0 ) && Ops.less_than( Ops.get_integer(ps, [index, "size_max_cyl"], 0), Ops.get_integer(p, 2, 0) ) diff = Ops.subtract( Ops.get_integer(p, 2, 0), Ops.get_integer(ps, [index, "size_max_cyl"], 0) ) normdiff = Ops.divide( Ops.multiply(diff, 100), Ops.get_integer(ps, [index, "size_max_cyl"], 0) ) ret = Ops.subtract(ret, normdiff) Builtins.y2milestone("after maximal size %1", ret) end end # if( e["cylinders"]:0 > 0 ) # { # y2milestone("ret (before rounding): %1", ret); # ret = ret - (e["cylinders"]:0 * g["cyl_size"]:1) / (1024*1024*1024); # y2milestone("weight (after rounding): %1", ret); # } if e.fetch("extended", false) ret -= 1 ret -= 100 if e.fetch("added",[]).empty? else index=0 ps.each do |p| if p.key?("partition_nr") ad = e.fetch("added",[]).find { |li| li[0]==index } if ad && ad[1]!=p["partition_nr"] Builtins.y2milestone("do_weighting part num mismatch add:%1 ps:%2", ad, p) ret -= 100 end end index += 1 end ret -=10 if g.fetch("free_pnr",[]).size<1 end end Builtins.y2milestone("do_weighting weight: %1", ret) ret end |
- (Object) find_matching_disk(disks, target, conf)
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 |
# File '../../src/include/autoinstall/autopart.rb', line 317 def find_matching_disk(disks, target, conf) disks = deep_copy(disks) target = deep_copy(target) conf = deep_copy(conf) solutions = {} @cur_weight = -100000 @cur_gap = {} Builtins.foreach(disks) do |k| e = Ops.get_map(target, k, {}) pd = deep_copy(conf) Builtins.y2milestone("processing disk %1", k) Builtins.y2milestone("parts %1", Ops.get_list(conf, "partitions", [])) tc = try_add_boot(conf, e) @cur_mode = :free if !Ops.get_boolean(tc, "prefer_remove", false) gap = get_gap_info(e, pd, false) tc = add_cylinder_info(tc, gap) l = get_perfect_list(Ops.get_list(tc, "partitions", []), gap) if Ops.greater_than(Builtins.size(l), 0) Ops.set(solutions, k, Builtins.eval(l)) Ops.set(solutions, [k, "disk"], Builtins.eval(e)) end @cur_mode = :reuse egap = get_gap_info(e, pd, true) if Ops.greater_than( Builtins.size(Ops.get_list(egap, "gap", [])), Builtins.size(Ops.get_list(gap, "gap", [])) ) tc = add_cylinder_info(tc, egap) l = get_perfect_list(Ops.get_list(tc, "partitions", []), egap) if Ops.greater_than(Builtins.size(l), 0) && (!Builtins.haskey(solutions, k) || Builtins.haskey(l, "weight") && Ops.greater_than( Ops.get_integer(l, "weigth", 0), Ops.get_integer(solutions, [k, "weigth"], 0) )) Builtins.y2milestone("solution reuse existing") Ops.set(solutions, k, Builtins.eval(l)) Ops.set(solutions, [k, "disk"], Builtins.eval(e)) end end @cur_mode = :resize rw = try_resize_windows(e) if Ops.greater_than( Builtins.size(Builtins.filter(Ops.get_list(rw, "partitions", [])) do |p| Builtins.haskey(p, "winfo") end), 0 ) egap = get_gap_info(rw, pd, true) tc = add_cylinder_info(tc, egap) l = get_perfect_list(Ops.get_list(tc, "partitions", []), egap) if Ops.greater_than(Builtins.size(l), 0) && (!Builtins.haskey(solutions, k) || Builtins.haskey(l, "weight") && Ops.greater_than( Ops.get_integer(l, "weigth", 0), Ops.get_integer(solutions, [k, "weigth"], 0) )) Builtins.y2milestone("solution resizing windows") Ops.set(solutions, k, Builtins.eval(l)) Ops.set(solutions, [k, "disk"], Builtins.eval(rw)) end end else @cur_mode = :free rp = remove_possible_partitions(e, tc) gap = get_gap_info(rp, pd, false) tc = add_cylinder_info(tc, gap) l = get_perfect_list(Ops.get_list(tc, "partitions", []), gap) if Ops.greater_than(Builtins.size(l), 0) Ops.set(solutions, k, Builtins.eval(l)) Ops.set(solutions, [k, "disk"], Builtins.eval(rp)) end end end ret = {} if Ops.greater_than(Builtins.size(solutions), 0) Builtins.foreach(solutions) do |k, e| Builtins.y2milestone( "disk %1 weight %2", k, Ops.get_integer(e, "weight", 0) ) end disks2 = Builtins.maplist(solutions) { |k, e| k } disks2 = Builtins.sort(disks2) do |a, b| Ops.greater_than( Ops.get_integer(solutions, [a, "weight"], 0), Ops.get_integer(solutions, [b, "weight"], 0) ) end Builtins.y2milestone("sorted disks %1", disks2) ret = Ops.get(solutions, Ops.get(disks2, 0, ""), {}) Ops.set(ret, "device", Ops.get(disks2, 0, "")) end deep_copy(ret) end |
- (Object) find_matching_partition_size(gap, nr)
1241 1242 1243 1244 1245 1246 1247 1248 |
# File '../../src/include/autoinstall/autopart.rb', line 1241 def find_matching_partition_size(gap, nr) gap = deep_copy(gap) mg = Builtins.filter(Ops.get_list(gap, "gap", [])) do |g| Ops.get_integer(g, "nr", -1) == nr && Ops.get_boolean(g, "reuse", false) end Builtins.y2milestone("usepart partition: %1", Ops.get_map(mg, 0, {})) Ops.get_map(mg, 0, {}) end |
- (Object) get_gap_info(disk, pd, add_exist_linux)
2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 |
# File '../../src/include/autoinstall/autopart.rb', line 2325 def get_gap_info(disk, pd, add_exist_linux) disk = deep_copy(disk) pd = deep_copy(pd) ret = {} gap = [] plist = Builtins.filter(Ops.get_list(disk, "partitions", [])) do |p| !Ops.get_boolean(p, "delete", false) end plist = Builtins.sort(plist) do |a, b| Ops.less_than( Ops.get_integer(a, ["region", 0], 0), Ops.get_integer(b, ["region", 0], 0) ) end exist_pnr = Builtins.sort(Builtins.maplist(plist) do |e| Ops.get_integer(e, "nr", 0) end) max_prim = Partitions.MaxPrimary(Ops.get_string(disk, "label", "msdos")) has_ext = Partitions.HasExtended(Ops.get_string(disk, "label", "msdos")) # check if we support extended partitions if has_ext # see if disk has an extended already ext = Ops.get(Builtins.filter(plist) do |p| Ops.get_symbol(p, "type", :primary) == :extended end, 0, {}) Ops.set(ret, "extended_possible", Builtins.size(ext) == 0) if Ops.greater_than(Builtins.size(ext), 0) gap = get_gaps( Ops.get_integer(ext, ["region", 0], 0), Ops.subtract( Ops.add( Ops.get_integer(ext, ["region", 0], 0), Ops.get_integer(ext, ["region", 1], 1) ), 1 ), pd, Builtins.filter(plist) do |p| Ops.greater_than(Ops.get_integer(p, "nr", 0), max_prim) end, add_exist_linux ) gap = Builtins.maplist(gap) do |e| Ops.set(e, "extended", true) deep_copy(e) end plist = Builtins.filter(plist) do |p| Ops.less_or_equal(Ops.get_integer(p, "nr", 0), max_prim) end end else Ops.set(ret, "extended_possible", false) end gap = Convert.convert( Builtins.union( gap, get_gaps( 0, Ops.subtract(Ops.get_integer(disk, "cyl_count", 1), 1), pd, plist, add_exist_linux ) ), :from => "list", :to => "list <map>" ) av_size = 0 gap = Builtins.maplist(gap) do |e| Ops.set( e, "cylinders", Ops.add( Ops.subtract( Ops.get_integer(e, "end", 0), Ops.get_integer(e, "start", 0) ), 1 ) ) Ops.set( e, "size", Ops.multiply( Ops.get_integer(e, "cylinders", 0), Ops.get_integer(disk, "cyl_size", 1) ) ) av_size = Ops.add(av_size, Ops.get_integer(e, "size", 0)) deep_copy(e) end gap = Builtins.maplist(gap) do |e| Ops.set( e, "sizepct", Ops.divide( Ops.divide(Ops.multiply(Ops.get_integer(e, "size", 0), 201), 2), av_size ) ) Ops.set(e, "sizepct", 1) if Ops.get_integer(e, "sizepct", 0) == 0 deep_copy(e) end Ops.set(ret, "cyl_size", Ops.get_integer(disk, "cyl_size", 1)) Ops.set(ret, "disk_cyl", Ops.get_integer(disk, "cyl_count", 1)) Ops.set(ret, "max_primary", Ops.get_integer(disk, "max_primary", 0)) Ops.set(ret, "sum", av_size) max_pnr = max_prim pnr = 1 free_pnr = [] Builtins.y2milestone("exist_pnr %1", exist_pnr) while Ops.less_or_equal(pnr, max_pnr) if !Builtins.contains(exist_pnr, pnr) free_pnr = Builtins.add(free_pnr, pnr) end pnr = Ops.add(pnr, 1) end Ops.set(ret, "extended_possible", false) if Builtins.isempty(free_pnr) Ops.set(ret, "free_pnr", free_pnr) ext_pnr = [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 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 ] max_logical = Ops.get_integer(disk, "max_logical", 15) ext_pnr = Builtins.filter(ext_pnr) do |i| Ops.less_or_equal(i, max_logical) end if Ops.less_than( max_logical, 63 ) if !Ops.get_boolean(ret, "extended_possible", false) if !has_ext ext_pnr = [] else maxext = Ops.get_integer( exist_pnr, Ops.subtract(Builtins.size(exist_pnr), 1), 4 ) pnr = 5 while Ops.less_or_equal(pnr, maxext) ext_pnr = Builtins.remove(ext_pnr, 0) pnr = Ops.add(pnr, 1) end end end Ops.set(ret, "ext_pnr", ext_pnr) Ops.set(ret, "gap", Builtins.sort(gap) do |a, b| Ops.less_than( Ops.get_integer(a, "start", 0), Ops.get_integer(b, "start", 0) ) end) Builtins.y2milestone("ret %1", ret) deep_copy(ret) end |
- (Object) get_gaps(start, _end, pd, part, add_exist_linux)
Collect gap information
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 |
# File '../../src/include/autoinstall/autopart.rb', line 2256 def get_gaps(start, _end, pd, part, add_exist_linux) pd = deep_copy(pd) part = deep_copy(part) Builtins.y2milestone("partitions: %1", Ops.get_list(pd, "partitions", [])) usepart_p = Builtins.maplist(Ops.get_list(pd, "partitions", [])) do |pa| Ops.get_integer(pa, "usepart", 0) end reuse = Builtins.filter(usepart_p) { |i| i != 0 } Builtins.y2milestone("reuse: %1", reuse) Builtins.y2milestone( "start %1 end %2 add_exist %3", start, _end, add_exist_linux ) ret = [] entry = {} Builtins.foreach(part) do |p| s = Ops.get_integer(p, ["region", 0], 0) e = Ops.subtract(Ops.add(s, Ops.get_integer(p, ["region", 1], 1)), 1) entry = {} Builtins.y2milestone("Getting gap from part: %1", p) Builtins.y2milestone("start %1 s %2 e %3", start, s, e) if Ops.less_than(start, s) Ops.set(entry, "start", start) Ops.set(entry, "end", Ops.subtract(s, 1)) ret = Builtins.add(ret, Builtins.eval(entry)) end if add_exist_linux && (Ops.get_integer(p, "fsid", 0) == Partitions.fsid_native || Ops.get_integer(p, "fsid", 0) == Partitions.fsid_swap) Ops.set( entry, "swap", Ops.get_integer(p, "fsid", 0) == Partitions.fsid_swap ) Ops.set(entry, "start", s) Ops.set(entry, "end", e) Ops.set(entry, "exists", true) Ops.set(entry, "nr", Ops.get_integer(p, "nr", 0)) ret = Builtins.add(ret, entry) end if Builtins.contains(reuse, Ops.get_integer(p, "nr", 0)) # This partition is to be used as specified in the control file Ops.set( entry, "swap", Ops.get_integer(p, "fsid", 0) == Partitions.fsid_swap ) Ops.set(entry, "start", s) Ops.set(entry, "end", e) Ops.set(entry, "exists", true) Ops.set(entry, "reuse", true) Ops.set(entry, "nr", Ops.get_integer(p, "nr", 0)) ret = Builtins.add(ret, entry) end start = Ops.add(e, 1) end if Ops.less_than(start, _end) entry = {} Ops.set(entry, "start", start) Ops.set(entry, "end", _end) ret = Builtins.add(ret, entry) end Builtins.y2milestone("ret %1", ret) deep_copy(ret) end |
- (Object) get_perfect_list(ps, g)
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 1473 1474 1475 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 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 |
# File '../../src/include/autoinstall/autopart.rb', line 1350 def get_perfect_list(ps, g) ps = ps.reject { |p| p.fetch("partition_nr",1)==0 } g = deep_copy(g) Builtins.y2milestone("requested partitions %1", ps) Builtins.y2milestone("calculated gaps %1", g) ps = Builtins.maplist( Convert.convert(ps, :from => "list", :to => "list <map>") ) do |partition| if Ops.get_boolean(partition, "resize", false) # this is a cylinder correction for resized partitions # bnc#580842 Ops.set( partition, "cylinders", Ops.get_integer(partition, ["region", 1], 0) ) Builtins.y2milestone( "cylinder correction to %1", Ops.get_integer(partition, "cylinders", 0) ) end deep_copy(partition) end Builtins.foreach( Convert.convert(ps, :from => "list", :to => "list <map>") ) do |rp| if Ops.get_boolean(rp, "resize", false) new_cyl_size = 0 cyl_size_change = 0 old_end = 0 new_end = 0 Ops.set(g, "gap", Builtins.maplist(Ops.get_list(g, "gap", [])) do |gap| Builtins.y2milestone("working on gap %1", gap) if new_cyl_size != 0 Ops.set( gap, "cylinders", Ops.add(Ops.get_integer(gap, "cylinders", 0), cyl_size_change) ) Ops.set( gap, "start", Ops.subtract(Ops.get_integer(gap, "start", 0), cyl_size_change) ) Ops.set( gap, "size", Ops.add( Ops.get_integer(gap, "size", 0), Ops.multiply( cyl_size_change, Ops.get_integer(g, "cyl_size", 0) ) ) ) Builtins.y2milestone( "changing gap because of a resize of a previous partition gap is now: cyl=%1 start=%2 size=%3", Ops.get_integer(gap, "cylinders", 0), Ops.get_integer(gap, "start", 0), Ops.get_integer(gap, "size", 0) ) new_cyl_size = 0 elsif Ops.get_integer(gap, "nr", -1) == Ops.get_integer(rp, "partition_nr", -2) new_cyl_size = Ops.get_integer(rp, "cylinders", 0) cyl_size_change = Ops.subtract( Ops.get_integer(gap, "cylinders", 0), new_cyl_size ) old_end = Ops.get_integer(gap, "end", 0) Builtins.y2milestone( "partition resize cyl_size_change=%1", cyl_size_change ) Ops.set(gap, "cylinders", new_cyl_size) #gap["size"] = gap["size"]:0 + cyl_size_change * g["cyl_size"]:0; Ops.set( gap, "size", Ops.multiply(new_cyl_size, Ops.get_integer(g, "cyl_size", 0)) ) Ops.set( gap, "end", Ops.subtract( Ops.add(Ops.get_integer(gap, "start", 0), new_cyl_size), 1 ) ) new_end = Ops.get_integer(gap, "end", 0) Builtins.y2milestone("changing gap to %1", gap) end deep_copy(gap) end) if new_cyl_size != 0 new_gap = {} Ops.set(new_gap, "cylinders", cyl_size_change) Ops.set( new_gap, "size", Ops.multiply(cyl_size_change, Ops.get_integer(g, "cyl_size", 0)) ) Ops.set(new_gap, "start", Ops.add(new_end, 1)) Ops.set(new_gap, "end", old_end) Ops.set( new_gap, "size", Ops.add( Ops.subtract( Ops.get_integer(new_gap, "end", 0), Ops.get_integer(new_gap, "start", 0) ), 1 ) ) Ops.set(g, "gap", Builtins.add(Ops.get_list(g, "gap", []), new_gap)) Builtins.y2milestone("added new gap after shrinking %1", new_gap) end end end # If gaps are available # AND ( # extended partitions are possible and there are # primaries left and number of requested partitions(+1) is less than all available # primaries and logical slots # OR # extended is not possible and number of requested partitions is less than all # available primaries and logical slots ) new_ps = ps.count { |p| p.fetch("create", true) } reuse_ps = ps.count { |p| p.fetch("partition_nr",0)==p.fetch("usepart",-1) } free_pnr = g.fetch("free_pnr",[]).size if g.fetch("extended_possible",false) free_pnr -= 1 free_pnr += g.fetch("ext_pnr",[]).size end Builtins.y2milestone( "get_perfect_list: size(ps):%1 new_ps:%2 reuse_ps:%3 sum_free:%4", ps.size, new_ps, reuse_ps, free_pnr ) if (new_ps>0||reuse_ps>0) && g.fetch("gap", []).size>0 && new_ps<=free_pnr lg = Builtins.eval(g) # prepare local gap var Ops.set(lg, "gap", Builtins.maplist(Ops.get_list(lg, "gap", [])) do |e| Ops.set(e, "orig_cyl", Ops.get_integer(e, "cylinders", 0)) Ops.set(e, "added", []) deep_copy(e) end) Ops.set(lg, "procpart", 0) lp = Builtins.eval(ps) add_prim = Builtins.size( Builtins.filter( Convert.convert(ps, :from => "list", :to => "list <map>") ) do |up| (Ops.get_string(up, "partition_type", "none") == "primary" || Builtins.contains( Ops.get_list(lg, "free_pnr", []), Ops.get_integer(up, "partition_nr", 0) )) && Ops.get_boolean(up, "create", true) end ) Builtins.y2milestone( "get_perfect_list new_ps:%1 add_prim:%2 free_prim:%3", new_ps, add_prim, Builtins.size(Ops.get_list(g, "free_pnr", [])) ) if g.fetch("extended_possible",false) && g.fetch("free_pnr",[]).size>0 && add_prim<g.fetch("free_pnr",[]).size && new_ps>add_prim Builtins.y2milestone("creating extended") index = 0 Builtins.foreach(Ops.get_list(lg, "gap", [])) do |e| if !Ops.get_boolean(e, "exists", false) gap = Builtins.eval(lg) Ops.set( gap, ["gap", index, "created"], Ops.get_integer(gap, ["free_pnr", 0], 1) ) Ops.set( gap, "free_pnr", Builtins.remove( Convert.convert( Ops.get(gap, "free_pnr") { [1] }, :from => "any", :to => "list <const integer>" ), 0 ) ) Ops.set(gap, ["gap", index, "extended"], true) Ops.set(gap, "extended_possible", false) add_part_recursive(ps, gap) end index = Ops.add(index, 1) end end if Ops.less_or_equal( new_ps, Ops.add( Builtins.size(Ops.get_list(g, "free_pnr", [])), Builtins.size(Ops.get_list(g, "ext_pnr", [])) ) ) Builtins.y2milestone("not creating extended now") add_part_recursive(ps, lg) end end ret = {} if @cur_gap.size>0 ret["weight"] = @cur_weight ret["solution"] = @cur_gap ret["partitions"] = ps elsif ps.size==0 ret["weight"] = 0 ret["solution"] = [] ret["partitions"] = [] end Builtins.y2milestone( "ret weight %1", Ops.get_integer(ret, "weight", -1000000) ) Builtins.y2milestone( "ret solution %1", Ops.get_list(ret, ["solution", "gap"], []) ) deep_copy(ret) end |
- (Object) GetAllPartitions(device)
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File '../../src/include/autoinstall/autopart.rb', line 106 def GetAllPartitions(device) ret = [] Builtins.foreach(Storage.GetTargetMap) do |dev, disk| if Storage.IsRealDisk(disk) && dev == device l = Builtins.maplist(Ops.get_list(disk, "partitions", [])) do |p| Ops.get_integer(p, "nr", 0) end ret = Convert.convert( Builtins.union(ret, l), :from => "list", :to => "list <integer>" ) end end Builtins.y2milestone("All Partitions ret=%1", ret) deep_copy(ret) end |
- (Object) GetNoneLinuxPartitions(device)
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File '../../src/include/autoinstall/autopart.rb', line 76 def GetNoneLinuxPartitions(device) ret = [] Builtins.foreach(Storage.GetTargetMap) do |dev, disk| if Storage.IsRealDisk(disk) && dev == device l = Builtins.filter(Ops.get_list(disk, "partitions", [])) do |p| !Ops.get_boolean(p, "delete", false) && !Ops.get_boolean(p, "format", false) && !Partitions.IsLinuxPartition(Ops.get_integer(p, "fsid", 0)) end l = Builtins.filter(l) do |p| !Builtins.contains( [:xfs, :ext2, :ext3, :ext4, :jfs, :reiser], Ops.get_symbol(p, "used_fs", :unknown) ) end l = Builtins.filter(l) do |p| !FileSystems.IsSystemMp(Ops.get_string(p, "mount", ""), false) end if Ops.greater_than(Builtins.size(l), 0) ln = Builtins.maplist(l) { |p| Ops.get_integer(p, "nr", 0) } ret = Builtins.union(ret, ln) end end end Builtins.y2milestone("GetNoneLinuxPartitions ret=%1", ret) deep_copy(ret) end |
- (Object) initialize_autoinstall_autopart(include_target)
11 12 13 14 15 16 17 18 19 20 21 |
# File '../../src/include/autoinstall/autopart.rb', line 11 def initialize_autoinstall_autopart(include_target) textdomain "autoinst" Yast.import "FileSystems" Yast.import "Partitions" Yast.import "Arch" @cur_mode = :free @cur_weight = -10000 @cur_gap = {} end |
- (Object) normalize_gaps(ps, g)
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 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 |
# File '../../src/include/autoinstall/autopart.rb', line 1736 def normalize_gaps(ps, g) ps = deep_copy(ps) g = deep_copy(g) Builtins.y2milestone("normalize_gaps: gap %1", g) gindex = 0 pindex = 0 Builtins.foreach(Ops.get_list(g, "gap", [])) do |e| Builtins.y2milestone("gap section %1", e) if Ops.get_boolean(e, "exists", false) if Ops.greater_than(Builtins.size(Ops.get_list(e, "added", [])), 0) && Builtins.size(Ops.get_list(e, ["added", 0], [])) == 2 Ops.set( e, ["added", 0], Builtins.add( Ops.get_list(e, ["added", 0], []), Ops.get_integer(e, "orig_cyl", 1) ) ) end else rest = Ops.get_integer(e, "cylinders", 0) needed = 0 tidx = 0 Builtins.foreach(Ops.get_list(e, "added", [])) do |p| tidx = Ops.get_integer(p, 0, 0) if Ops.greater_than( Ops.get_integer(ps, [tidx, "want_cyl"], 0), Ops.get_integer(ps, [tidx, "cylinders"], 0) ) needed = Ops.subtract( Ops.add(needed, Ops.get_integer(ps, [tidx, "want_cyl"], 0)), Ops.get_integer(ps, [tidx, "cylinders"], 0) ) end end Builtins.y2milestone("needed %1 rest %2", needed, rest) if Ops.greater_than(needed, rest) tr = [] weight = Builtins.maplist(Ops.get_list(e, "added", [])) do |l| idx = Ops.get_integer(l, 0, 0) d = Ops.subtract( Ops.get_integer(ps, [idx, "want_cyl"], 0), Ops.get_integer(ps, [idx, "cylinders"], 0) ) if Ops.greater_than(d, 0) l = Builtins.add(l, Ops.get_integer(ps, [idx, "cylinders"], 0)) end tr = Builtins.add(tr, l) Ops.greater_than(d, 0) ? d : 0 end Builtins.y2milestone("tr %1", tr) r = {} r = distribute_space(rest, weight, tr, ps) Ops.set( g, ["gap", gindex, "added"], Builtins.eval(Ops.get_list(r, "added", [])) ) Ops.set( g, ["gap", gindex, "cylinders"], Ops.subtract( Ops.get_integer(e, "cylinders", 0), Ops.get_integer(r, "diff", 0) ) ) Builtins.y2milestone( "partly satisfy %1 cyl %2", Ops.get_list(g, ["gap", gindex, "added"], []), Ops.get_integer(g, ["gap", gindex, "cylinders"], 0) ) else Ops.set( g, ["gap", gindex, "cylinders"], Ops.subtract(Ops.get_integer(e, "cylinders", 0), needed) ) end pindex = 0 Builtins.foreach(Ops.get_list(g, ["gap", gindex, "added"], [])) do |p| if Ops.less_than(Builtins.size(p), 3) tidx = Ops.get_integer(p, 0, 0) if Ops.greater_than( Ops.get_integer(ps, [tidx, "want_cyl"], 0), Ops.get_integer(ps, [tidx, "cylinders"], 0) ) p = Builtins.add(p, Ops.get_integer(ps, [tidx, "want_cyl"], 0)) else p = Builtins.add(p, Ops.get_integer(ps, [tidx, "cylinders"], 0)) end Ops.set(g, ["gap", gindex, "added", pindex], p) Builtins.y2milestone( "satisfy p %1 cyl %2", p, Ops.get_integer(e, "cylinders", 0) ) end pindex = Ops.add(pindex, 1) end Builtins.y2milestone( "added %1", Ops.get_list(g, ["gap", gindex, "added"], []) ) end gindex = Ops.add(gindex, 1) end gindex = 0 Builtins.foreach(Ops.get_list(g, "gap", [])) do |e| if !Ops.get_boolean(e, "exists", false) && Ops.greater_than(Ops.get_integer(e, "cylinders", 0), 0) weight = Builtins.maplist(Ops.get_list(e, "added", [])) do |l| Ops.get_integer(ps, [Ops.get_integer(l, 0, 0), "size"], 0) == 0 ? 1 : 0 end if Builtins.find(weight) { |l| Ops.greater_than(l, 0) } != nil r = {} r = distribute_space( Ops.get_integer(e, "cylinders", 0), weight, Ops.get_list(e, "added", []), ps ) Ops.set( g, ["gap", gindex, "added"], Builtins.eval(Ops.get_list(r, "added", [])) ) Ops.set( g, ["gap", gindex, "cylinders"], Ops.subtract( Ops.get_integer(e, "cylinders", 0), Ops.get_integer(r, "diff", 0) ) ) Builtins.y2milestone( "increase max p %1 cyl %2", Ops.get_list(g, ["gap", gindex, "added"], []), Ops.get_integer(g, ["gap", gindex, "cylinders"], 0) ) end end gindex = Ops.add(gindex, 1) end gindex = 0 # makes trouble on small harddisks # foreach( map e, g["gap"]:[], # ``{ # if( !e["exists"]:false && e["cylinders"]:0>0 && # e["cylinders"]:0 < g["disk_cyl"]:0/20 ) # { # list weight = maplist( list l, e["added"]:[], ``(l[2]:0) ); # map r = $[]; # r = distribute_space( e["cylinders"]:0, weight, e["added"]:[], ps ); # g["gap",gindex,"added"] = eval(r["added"]:[]); # g["gap",gindex,"cylinders"] = e["cylinders"]:0 - r["diff"]:0; # y2milestone( "close small gap p %1 cyl %2", g["gap",gindex,"added"]:[], # g["gap",gindex,"cylinders"]:0 ); # } # gindex = gindex + 1; # }); Builtins.foreach(g.fetch("gap",[])) do |e| if !e.fetch("exists",false) && e.fetch("added",[]).size>1 Builtins.y2milestone( "normalize_gaps old added %1", e.fetch("added",[])) sdd = Builtins.sort(e.fetch("added",[])) do |a, b| a.fetch(1,0)<=b.fetch(1,0) end Ops.set(g, ["gap", gindex, "added"], sdd) Builtins.y2milestone( "normalize_gaps sort added %1", Ops.get_list(g, ["gap", gindex, "added"], []) ) end gindex += 1 end Builtins.y2milestone("normalize_gaps ret %1", g) deep_copy(g) end |
- (Hash) preprocess_partition_config(xmlflex)
Read partition data from XML control file
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 181 182 183 184 185 186 187 188 189 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 |
# File '../../src/include/autoinstall/autopart.rb', line 141 def preprocess_partition_config(xmlflex) xmlflex = deep_copy(xmlflex) Builtins.y2debug("xml input: %1", xmlflex) tm = Storage.GetTargetMap partitioning = Builtins.maplist(xmlflex) do |d| dlabel = d.fetch("disklabel", "msdos") Builtins.foreach(["keep_partition_id", "keep_partition_num"]) do |key| num = [] nlist2 = Builtins.splitstring(Ops.get_string(d, key, ""), ",") Builtins.foreach(nlist2) do |n| num = Builtins.union(num, [Builtins.tointeger(n)]) end Ops.set(d, key, num) end fsys = [] nlist = Builtins.splitstring( Ops.get_string(d, "keep_partition_fsys", ""), "," ) Builtins.foreach(nlist) do |n| fs = FileSystems.FsToSymbol(n) fsys = Builtins.union(fsys, [fs]) if fs != :none end Ops.set(d, "keep_partition_fsys", fsys) user_partitions = Ops.get_list(d, "partitions", []) if Builtins.size(user_partitions) == 0 Builtins.y2milestone( "no partitions specified, creating default scheme" ) root = {} Ops.set(root, "mount", "/") Ops.set(root, "size", "max") swap = {} Ops.set(swap, "mount", "swap") Ops.set(swap, "size", "auto") user_partitions = Builtins.add(user_partitions, swap) user_partitions = Builtins.add(user_partitions, root) end partitions = [] Builtins.foreach(user_partitions) do |partition| if Builtins.haskey(partition, "maxsize") Ops.set( partition, "max", humanStringToByte(Ops.get_string(partition, "maxsize", ""), true) ) end if Ops.get_string(partition, "size", "") != "" s = Ops.get_string(partition, "size", "") if Builtins.tolower(s) == "auto" Ops.set(partition, "size", -1) elsif Builtins.tolower(s) == "suspend" Ops.set(partition, "size", -2) elsif Builtins.tolower(s) == "max" Ops.set(partition, "size", 0) else Ops.set(partition, "size", humanStringToByte(s, true)) end end if Ops.less_or_equal(Ops.get_integer(partition, "size", 0), -1) && Ops.get_string(partition, "mount", "") == "swap" Ops.set( partition, "size", Ops.multiply( 1024 * 1024, Partitions.SwapSizeMb( 0, Ops.get_integer(partition, "size", 0) == -2 ) ) ) end if Ops.get_string(partition, "mount", "") == Partitions.BootMount if Ops.get_integer(partition, "size", 0) == -1 Ops.set(partition, "size", Partitions.MinimalNeededBootsize) end if Ops.get_integer(partition, "filesystem_id", 0) == 0 Ops.set(partition, "filesystem_id", Partitions.FsidBoot(dlabel)) end #partition["max_cyl"] = Partitions::BootCyl(); end #Setting default filesystem if it has not been a part of autoinst.xml #Bug 880569 if propose_default_fs?(partition) if partition["mount"] == Partitions.BootMount partition["filesystem"] = Partitions.DefaultBootFs else partition["filesystem"] = Partitions.DefaultFs end end # Do not format raw partitions partition["format"] = false if raw_partition?(partition) if Ops.get_integer(partition, "size", 0) == -1 Ops.set(partition, "size", 0) end if Ops.get_symbol(partition, "used_by_type", :UB_NONE) == :UB_LVM Ops.set(partition, "filesystem_id", Partitions.fsid_lvm) elsif Ops.get_symbol(partition, "used_by_type", :UB_NONE) == :UB_MD Ops.set(partition, "filesystem_id", Partitions.fsid_raid) end if Builtins.haskey(partition, "filesystem_id") Ops.set( partition, "fsid", Ops.get_integer( partition, "filesystem_id", Partitions.fsid_native ) ) end Builtins.y2debug("partition: %1", partition) partitions = Builtins.add(partitions, partition) end if Ops.get_symbol(d, "type", :CT_UNKNONW) != :CT_LVM Ops.set(d, "partitions", partitions) end deep_copy(d) end Builtins.y2milestone("conf: %1", partitioning) deep_copy(partitioning) end |
- (Object) process_partition_data(dev, solution)
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 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 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 1157 1158 1159 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 |
# File '../../src/include/autoinstall/autopart.rb', line 417 def process_partition_data(dev, solution) solution = deep_copy(solution) disk = Ops.get_map(solution, "disk", {}) partitions = [] value = "" mapvalue = {} remove_boot = false if Ops.greater_than( Builtins.size( Builtins.filter(Ops.get_list(solution, "partitions", [])) do |e| Ops.get_string(e, "mount", "") == Partitions.BootMount && Ops.get_boolean(e, "auto_added", false) end ), 0 ) Builtins.foreach(Ops.get_list(solution, ["solution", "gap"], [])) do |e| Builtins.foreach(Ops.get_list(e, "added", [])) do |a| pindex = Ops.get_integer(a, 0, 0) if Ops.get_string(solution, ["partitions", pindex, "mount"], "") == "/" && Ops.greater_than( Ops.get_integer(disk, "cyl_count", 0), Partitions.BootCyl ) && Ops.less_or_equal( Ops.get_integer(e, "end", 0), Partitions.BootCyl ) remove_boot = true end end end end index = 0 if remove_boot Builtins.foreach(Ops.get_list(solution, ["solution", "gap"], [])) do |e| nlist = [] Builtins.foreach(Ops.get_list(e, "added", [])) do |a| pindex = Ops.get_integer(a, 0, 0) if Ops.get_string(solution, ["partitions", pindex, "mount"], "") == Partitions.BootMount rest = Ops.get_integer(a, 2, 0) Builtins.y2milestone( "remove unneeded %3 %1 cyl %2", Ops.get_list(e, "added", []), rest, Partitions.BootMount ) nlist2 = Builtins.filter(Ops.get_list(e, "added", [])) do |l| Ops.get_integer(l, 0, 0) != pindex end if Ops.greater_than(Builtins.size(nlist2), 0) && !Ops.get_boolean(e, "exists", false) weight = Builtins.maplist(nlist2) do |l| Ops.get_integer(l, 2, 0) end r = {} r = distribute_space( rest, weight, nlist2, Ops.get_list(solution, "partitions", []) ) nlist2 = Builtins.eval(Ops.get_list(r, "added", [])) Ops.set( solution, ["solution", "gap", index, "cylinders"], Ops.subtract( Ops.get_integer(e, "cylinders", 0), Ops.get_integer(r, "diff", 0) ) ) end Ops.set( solution, ["solution", "gap", index, "added"], Builtins.eval(nlist2) ) Builtins.y2milestone( "remove unneeded %2 %1", Ops.get_list(e, "added", []), Partitions.BootMount ) end pindex = Ops.add(pindex, 1) end index = Ops.add(index, 1) end end index = 0 Builtins.foreach(Ops.get_list(solution, ["solution", "gap"], [])) do |e| if !Ops.get_boolean(e, "exists", false) && Ops.greater_than(Ops.get_integer(e, "cylinders", 0), 0) increase = 0 weight = Builtins.maplist(Ops.get_list(e, "added", [])) do |l| Ops.get_boolean( solution, ["partitions", Ops.get_integer(l, 0, 0), "grow"], false ) ? 1 : 0 end if Builtins.find(weight) { |l| Ops.greater_than(l, 0) } != nil r = {} r = distribute_space( Ops.get_integer(e, "cylinders", 0), weight, Ops.get_list(e, "added", []), Ops.get_list(solution, "partitions", []) ) Ops.set( solution, ["solution", "gap", index, "added"], Builtins.eval(Ops.get_list(r, "added", [])) ) Ops.set( solution, ["solution", "gap", index, "cylinders"], Ops.subtract( Ops.get_integer(e, "cylinders", 0), Ops.get_integer(r, "diff", 0) ) ) Builtins.y2milestone( "increase increasable p %1 cyl %2", Ops.get_list(solution, ["solution", "gap", index, "added"], []), Ops.get_integer( solution, ["solution", "gap", index, "cylinders"], 0 ) ) end end index = Ops.add(index, 1) end Builtins.foreach(Ops.get_list(solution, ["solution", "gap"], [])) do |e| if Ops.get_boolean(e, "exists", false) index2 = 0 pindex = Ops.get_integer(e, ["added", 0, 0], 0) mount = Ops.get_string(solution, ["partitions", pindex, "mount"], "") # integer fsid = Partitions::fsid_native; fsid = Ops.get_integer( disk, ["partitions", pindex, "fsid"], Partitions.fsid_native ) if Ops.get_symbol(disk, ["partitions", pindex, "type"], :primary) != :primary fsid = Ops.get_integer( disk, ["partitions", Ops.add(pindex, 1), "fsid"], Partitions.fsid_native ) end fsid = Partitions.fsid_swap if mount == "swap" if Ops.get_integer(solution, ["partitions", pindex, "fsid"], 0) != 0 fsid = Ops.get_integer(solution, ["partitions", pindex, "fsid"], 0) end Builtins.foreach(Ops.get_list(disk, "partitions", [])) do |p| if !Ops.get_boolean(p, "delete", false) && Ops.get_integer(p, "nr", 0) == Ops.get_integer(e, ["added", 0, 1], 0) Ops.set( p, "format", Ops.get_boolean( solution, ["partitions", pindex, "format"], true ) ) if Ops.get_boolean( solution, ["partitions", pindex, "resize"], false ) == true Ops.set(p, "resize", true) Ops.set( p, "region", Ops.get_list(solution, ["partitions", pindex, "region"], []) ) end Ops.set(p, "mount", mount) if Ops.get_boolean(e, "reuse", false) Ops.set( p, "used_fs", Ops.get_symbol( solution, ["partitions", pindex, "filesystem"], Ops.get_symbol(p, "detected_fs") { Partitions.DefaultFs } ) ) else Ops.set( p, "used_fs", Ops.get_symbol(solution, ["partitions", pindex, "filesystem"]) do Partitions.DefaultFs end ) end p = AddFilesysData( p, Ops.get_map(solution, ["partitions", pindex], {}) ) value = Ops.get_string( solution, ["partitions", pindex, "fstopt"], "" ) if Ops.greater_than(Builtins.size(value), 0) Ops.set(p, "fstopt", value) else Ops.set(p, "fstopt", FileSystems.DefaultFstabOptions(p)) end mapvalue = Ops.get_map( solution, ["partitions", pindex, "fs_options"], {} ) if Ops.greater_than(Builtins.size(mapvalue), 0) Ops.set(p, "fs_options", mapvalue) end value = Ops.get_string( solution, ["partitions", pindex, "label"], "" ) mb = Ops.get_symbol( solution, ["partitions", pindex, "mountby"], :no_mb ) Ops.set(p, "mountby", mb) if mb != :no_mb if Ops.greater_than(Builtins.size(value), 0) Ops.set(p, "label", value) end if Ops.get_boolean( solution, ["partitions", pindex, "loop_fs"], false ) || Ops.get_boolean( solution, ["partitions", pindex, "crypt_fs"], false ) #p["loop_fs"] = solution["partitions",pindex,"crypt_fs"]:false; Ops.set( p, "enc_type", Ops.get_symbol( solution, ["partitions", pindex, "enc_type"], :twofish ) ) Storage.SetCryptPwd( Ops.get_string(p, "device", ""), Ops.get_string( solution, ["partitions", pindex, "crypt_key"], "" ) ) #p["crypt"] = solution["partitions",pindex,"crypt"]:"twofish256"; end if Ops.get_integer(p, "fsid", 0) != fsid Ops.set(p, "change_fsid", true) Ops.set(p, "ori_fsid", Ops.get_integer(p, "fsid", 0)) Ops.set(p, "fsid", fsid) end if Ops.get_string( solution, ["partitions", pindex, "lvm_group"], "" ) != "" Ops.set(p, "used_fs", :unknown) Ops.set(p, "fsid", Partitions.fsid_lvm) Ops.set(p, "format", false) Ops.set( p, "lvm_group", Ops.get_string( solution, ["partitions", pindex, "lvm_group"], "" ) ) Ops.set(p, "mount", "") Ops.set(p, "fstype", "Linux LVM") elsif Ops.get_string( solution, ["partitions", pindex, "raid_name"], "" ) != "" Ops.set(p, "used_fs", :unknown) Ops.set(p, "fsid", Partitions.fsid_raid) Ops.set(p, "format", false) Ops.set( p, "raid_name", Ops.get_string( solution, ["partitions", pindex, "raid_name"], "" ) ) Ops.set( p, "raid_type", Ops.get_string( solution, ["partitions", pindex, "raid_type"], "raid" ) ) Ops.set(p, "mount", "") Ops.set(p, "fstype", "Linux RAID") end Ops.set(disk, ["partitions", index2], p) Builtins.y2milestone("reuse auto partition %1", p) end index2 = Ops.add(index2, 1) end else region = [ Ops.get_integer(e, "start", 0), Ops.add( Ops.subtract( Ops.get_integer(e, "end", 0), Ops.get_integer(e, "start", 0) ), 1 ) ] part = {} if Ops.get_boolean(e, "extended", false) && Ops.greater_than(Ops.get_integer(e, "created", 0), 0) while Ops.less_or_equal( Ops.get_integer( e, ["added", 0, 1], Ops.add(Ops.get_integer(disk, "max_primary", 4), 1) ), Ops.get_integer(disk, "max_primary", 4) ) pindex = Ops.get_integer(e, ["added", 0, 0], 0) mount = Ops.get_string( solution, ["partitions", pindex, "mount"], "" ) fsid = Partitions.fsid_native fsid = Partitions.fsid_swap if mount == "swap" Ops.set( part, "format", Ops.get_boolean( solution, ["partitions", pindex, "format"], true ) ) if Ops.get_integer( solution, ["partitions", pindex, "filesystem_id"], 0 ) != 0 fsid = Ops.get_integer( solution, ["partitions", pindex, "filesystem_id"], 0 ) if !Builtins.haskey( Ops.get_map(solution, ["partitions", pindex], {}), "filesystem" ) Ops.set(part, "format", false) end Builtins.y2milestone( "partition id %1 format %2 part %3", fsid, Ops.get_boolean(part, "format", false), Ops.get_map(solution, ["partitions", pindex], {}) ) end Ops.set(part, "create", true) Ops.set(part, "nr", Ops.get_integer(e, "created", 0)) Ops.set( part, "device", Storage.GetDeviceName(dev, Ops.get_integer(part, "nr", -1)) ) Ops.set(part, "region", region) Ops.set( part, ["region", 1], Ops.get_integer(e, ["added", 0, 2], 0) ) Ops.set( region, 0, Ops.add( Ops.get_integer(region, 0, 0), Ops.get_integer(part, ["region", 1], 0) ) ) Ops.set( region, 1, Ops.subtract( Ops.get_integer(region, 1, 0), Ops.get_integer(part, ["region", 1], 0) ) ) Ops.set(part, "type", :primary) Ops.set(part, "mount", mount) mb = Ops.get_symbol( solution, ["partitions", pindex, "mountby"], :no_mb ) Ops.set(part, "mountby", mb) if mb != :no_mb Ops.set( part, "used_fs", Ops.get_symbol( solution, ["partitions", pindex, "filesystem"], mount == "swap" ? :swap : Partitions.DefaultFs ) ) value = Ops.get_string( solution, ["partitions", pindex, "fstopt"], "" ) if Ops.greater_than(Builtins.size(value), 0) Ops.set(part, "fstopt", value) else Ops.set(part, "fstopt", FileSystems.DefaultFstabOptions(part)) end part = AddFilesysData( part, Ops.get_map(solution, ["partitions", pindex], {}) ) mapvalue = Ops.get_map( solution, ["partitions", pindex, "fs_options"], {} ) if Ops.greater_than(Builtins.size(mapvalue), 0) Ops.set(part, "fs_options", mapvalue) end if Ops.get_boolean( solution, ["partitions", pindex, "loop_fs"], false ) || Ops.get_boolean( solution, ["partitions", pindex, "crypt_fs"], false ) Ops.set( part, "enc_type", Ops.get_symbol( solution, ["partitions", pindex, "enc_type"], :twofish ) ) Storage.SetCryptPwd( Ops.get_string(part, "device", ""), Ops.get_string( solution, ["partitions", pindex, "crypt_key"], "" ) ) end value = Ops.get_string( solution, ["partitions", pindex, "label"], "" ) if Ops.greater_than(Builtins.size(value), 0) Ops.set(part, "label", value) end Ops.set(part, "fsid", fsid) Ops.set(part, "fstype", Partitions.FsIdToString(fsid)) if Ops.get_string( solution, ["partitions", pindex, "lvm_group"], "" ) != "" Ops.set(part, "used_fs", :unknown) Ops.set(part, "fsid", Partitions.fsid_lvm) Ops.set(part, "format", false) Ops.set( part, "lvm_group", Ops.get_string( solution, ["partitions", pindex, "lvm_group"], "" ) ) Ops.set(part, "mount", "") Ops.set(part, "fstype", "Linux LVM") elsif Ops.get_string( solution, ["partitions", pindex, "raid_name"], "" ) != "" Ops.set(part, "used_fs", :unknown) Ops.set(part, "fsid", Partitions.fsid_raid) Ops.set(part, "format", false) Ops.set( part, "raid_name", Ops.get_string( solution, ["partitions", pindex, "raid_name"], "" ) ) Ops.set( part, "raid_type", Ops.get_string( solution, ["partitions", pindex, "raid_type"], "raid" ) ) Ops.set(part, "mount", "") Ops.set(part, "fstype", "Linux RAID") end Builtins.y2milestone( "process_partition_data auto partition %1", part ) partitions = Builtins.add(partitions, part) Ops.set(e, "created", Ops.get_integer(e, ["added", 0, 1], 0)) Ops.set( e, "added", Builtins.remove(Ops.get_list(e, "added", []), 0) ) part = {} end Ops.set(part, "create", true) Ops.set(part, "nr", Ops.get_integer(e, "created", 0)) Ops.set( part, "device", Storage.GetDeviceName(dev, Ops.get_integer(part, "nr", -1)) ) Ops.set(part, "region", Builtins.eval(region)) Ops.set(part, "type", :extended) Ops.set(part, "fsid", Partitions.fsid_extended_win) Ops.set( part, "fstype", Partitions.FsIdToString(Ops.get_integer(part, "fsid", 0)) ) Ops.set( part, "size_k", Ops.divide( Ops.multiply( Ops.get_integer(region, 1, 0), Ops.get_integer(disk, "cyl_size", 0) ), 1024 ) ) Builtins.y2milestone("extended auto partition %1", part) partitions = Builtins.add(partitions, Builtins.eval(part)) end Builtins.foreach(Ops.get_list(e, "added", [])) do |a| part = {} pindex = Ops.get_integer(a, 0, 0) mount = Ops.get_string( solution, ["partitions", pindex, "mount"], "" ) fsid = Partitions.fsid_native Ops.set( part, "format", Ops.get_boolean(solution, ["partitions", pindex, "format"], true) ) fsid = Partitions.fsid_swap if mount == "swap" if Ops.get_integer( solution, ["partitions", pindex, "filesystem_id"], 0 ) != 0 fsid = Ops.get_integer( solution, ["partitions", pindex, "filesystem_id"], 0 ) if !Builtins.haskey( Ops.get_map(solution, ["partitions", pindex], {}), "filesystem" ) Ops.set(part, "format", false) end Builtins.y2milestone( "partition id %1 format %2 part %3", fsid, Ops.get_boolean(part, "format", false), Ops.get_map(solution, ["partitions", pindex], {}) ) end Ops.set(part, "create", true) Ops.set(part, "nr", Ops.get_integer(a, 1, 0)) Ops.set( part, "device", Storage.GetDeviceName(dev, Ops.get_integer(part, "nr", 0)) ) Ops.set(region, 1, Ops.get_integer(a, 2, 0)) Ops.set(part, "region", Builtins.eval(region)) Ops.set( region, 0, Ops.add( Ops.get_integer(region, 0, 0), Ops.get_integer(region, 1, 0) ) ) Ops.set(part, "type", :primary) if Ops.get_boolean(e, "extended", false) Ops.set(part, "type", :logical) end Ops.set(part, "mount", mount) mb = Ops.get_symbol( solution, ["partitions", pindex, "mountby"], :no_mb ) Ops.set(part, "mountby", mb) if mb != :no_mb Ops.set( part, "used_fs", Ops.get_symbol( solution, ["partitions", pindex, "filesystem"], mount == "swap" ? :swap : Partitions.DefaultFs ) ) value = Ops.get_string( solution, ["partitions", pindex, "fstopt"], "" ) if Ops.greater_than(Builtins.size(value), 0) Ops.set(part, "fstopt", value) else Ops.set(part, "fstopt", FileSystems.DefaultFstabOptions(part)) end part = AddFilesysData( part, Ops.get_map(solution, ["partitions", pindex], {}) ) mapvalue = Ops.get_map( solution, ["partitions", pindex, "fs_options"], {} ) if Ops.greater_than(Builtins.size(mapvalue), 0) Ops.set(part, "fs_options", mapvalue) end if Ops.get_boolean( solution, ["partitions", pindex, "loop_fs"], false ) || Ops.get_boolean( solution, ["partitions", pindex, "crypt_fs"], false ) #part["loop_fs"] = solution["partitions",pindex,"crypt_fs"]:false; Ops.set( part, "enc_type", Ops.get_symbol( solution, ["partitions", pindex, "enc_type"], :twofish ) ) Storage.SetCryptPwd( Ops.get_string(part, "device", ""), Ops.get_string( solution, ["partitions", pindex, "crypt_key"], "" ) ) #part["crypt"] = solution["partitions",pindex,"crypt"]:"twofish256"; end value = Ops.get_string( solution, ["partitions", pindex, "label"], "" ) if Ops.greater_than(Builtins.size(value), 0) Ops.set(part, "label", value) end Ops.set(part, "fsid", fsid) Ops.set(part, "fstype", Partitions.FsIdToString(fsid)) if Ops.get_string(solution, ["partitions", pindex, "lvm_group"], "") != "" Ops.set(part, "used_fs", :unknown) Ops.set(part, "fsid", Partitions.fsid_lvm) Ops.set(part, "format", false) Ops.set( part, "lvm_group", Ops.get_string( solution, ["partitions", pindex, "lvm_group"], "" ) ) Ops.set(part, "mount", "") Ops.set(part, "fstype", "Linux LVM") elsif Ops.get_string( solution, ["partitions", pindex, "raid_name"], "" ) != "" Ops.set(part, "used_fs", :unknown) Ops.set(part, "fsid", Partitions.fsid_raid) Ops.set(part, "format", false) Ops.set( part, "raid_name", Ops.get_string( solution, ["partitions", pindex, "raid_name"], "" ) ) Ops.set( part, "raid_type", Ops.get_string( solution, ["partitions", pindex, "raid_type"], "raid" ) ) Ops.set(part, "mount", "") Ops.set(part, "fstype", "Linux RAID") end Builtins.y2milestone("auto partition %1", part) partitions = Builtins.add(partitions, Builtins.eval(part)) if Ops.add(Ops.get_integer(a, 1, 0), 1) == Ops.get_integer(e, "created", 0) && Ops.get_boolean(e, "extended", false) part = {} ext_region = [ Ops.get_integer(region, 0, 0), Ops.add( Ops.subtract( Ops.get_integer(e, "end", 0), Ops.get_integer(region, 0, 0) ), 1 ) ] Ops.set(part, "create", true) Ops.set(part, "nr", Ops.get_integer(e, "created", 0)) Ops.set( part, "device", Storage.GetDeviceName(dev, Ops.get_integer(part, "nr", -1)) ) Ops.set(part, "region", ext_region) Ops.set(part, "type", :extended) Ops.set(part, "fsid", Partitions.fsid_extended_win) Ops.set( part, "fstype", Partitions.FsIdToString(Ops.get_integer(part, "fsid", 0)) ) Builtins.y2milestone("extended auto partition %1", part) partitions = Builtins.add(partitions, Builtins.eval(part)) end end partitions = Builtins.sort(partitions) do |a, b| Ops.less_than( Ops.get_integer(a, "nr", 0), Ops.get_integer(b, "nr", 0) ) end end end Ops.set( disk, "partitions", Builtins.union(Ops.get_list(disk, "partitions", []), partitions) ) Builtins.y2milestone("disk %1", disk) deep_copy(disk) end |
- (Boolean) propose_default_fs?(partition)
125 126 127 128 129 130 131 |
# File '../../src/include/autoinstall/autopart.rb', line 125 def propose_default_fs?(partition) valid_fsids = [Partitions.fsid_gpt_boot, Partitions.fsid_native] (!partition.has_key?("filesystem") || partition["filesystem"] == :none) && valid_fsids.include?(partition["filesystem_id"]) end |
- (Boolean) raw_partition?(partition)
133 134 135 136 137 138 |
# File '../../src/include/autoinstall/autopart.rb', line 133 def raw_partition?(partition) valid_fsids = [Partitions.fsid_bios_grub, Partitions.fsid_prep_chrp_boot, Partitions.fsid_gpt_prep] valid_fsids.include?(partition["filesystem_id"]) end |
- (Object) remove_possible_partitions(disk, pm)
2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 |
# File '../../src/include/autoinstall/autopart.rb', line 2122 def remove_possible_partitions(disk, pm) disk = deep_copy(disk) pm = deep_copy(pm) remove_special_partitions = Ops.get_boolean( pm, "remove_special_partitions", false ) keep_partition_num = Ops.get_list(pm, "keep_partition_num", []) keep_partition_id = Ops.get_list(pm, "keep_partition_id", []) keep_partition_fsys = Ops.get_list(pm, "keep_partition_fsys", []) # Special partitions nodelpart = [18, 222, 257] # Handle <usepart> which is analog to create=false and partition_nr>0 Builtins.foreach(Ops.get_list(pm, "partitions", [])) do |p| if Ops.get_integer(p, "usepart", 0) != 0 keep_partition_num = Builtins.add( keep_partition_num, Ops.get_integer(p, "usepart", 0) ) end end ret = deep_copy(disk) Ops.set( ret, "partitions", Builtins.maplist(Ops.get_list(ret, "partitions", [])) do |p| fsid = Ops.get_integer(p, "fsid", 0) if (remove_special_partitions || !Builtins.contains(nodelpart, fsid)) && Ops.get_symbol(p, "type", :primary) != :extended && !Builtins.contains( keep_partition_num, Ops.get_integer(p, "nr", 0) ) && !Builtins.contains(keep_partition_id, fsid) && !Builtins.contains( keep_partition_fsys, Ops.get_symbol(p, "used_fs", :none) ) Ops.set(p, "delete", true) if Builtins.haskey(p, "raid_name") Ops.set(p, "old_raid_name", Ops.get_string(p, "raid_name", "")) p = Builtins.remove(p, "raid_name") end end deep_copy(p) end ) max_prim = Partitions.MaxPrimary(Ops.get_string(disk, "label", "msdos")) # delete extended if no logical remain if Ops.greater_than( Builtins.size(Builtins.filter(Ops.get_list(ret, "partitions", [])) do |p| Ops.get_symbol(p, "type", :primary) == :extended end), 0 ) && Builtins.size(Builtins.filter(Ops.get_list(ret, "partitions", [])) do |p| Ops.greater_than(Ops.get_integer(p, "nr", 0), max_prim) && !Ops.get_boolean(p, "delete", false) end) == 0 Ops.set( ret, "partitions", Builtins.maplist(Ops.get_list(ret, "partitions", [])) do |p| if Ops.get_symbol(p, "type", :primary) == :extended Ops.set(p, "delete", true) end deep_copy(p) end ) end Builtins.y2milestone("after removal: %1", ret) deep_copy(ret) end |
- (Object) try_add_boot(conf, disk)
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 |
# File '../../src/include/autoinstall/autopart.rb', line 272 def try_add_boot(conf, disk) conf = deep_copy(conf) disk = deep_copy(disk) dlabel = disk.fetch("label", "") root = Ops.greater_than( Builtins.size(Builtins.filter(Ops.get_list(conf, "partitions", [])) do |e| Ops.get_string(e, "mount", "") == "/" end), 0 ) tc = Builtins.eval(conf) if !@planHasBoot && root && (Ops.greater_than( Ops.get_integer(disk, "cyl_count", 0), Partitions.BootCyl ) || Arch.ia64 || Arch.ppc || Arch.sparc) pb = {} if !Arch.ppc Ops.set(pb, "mount", Partitions.BootMount) Ops.set(pb, "fsys", Partitions.DefaultBootFs) end Ops.set(pb, "size", Partitions.MinimalNeededBootsize) Ops.set(pb, "filesystem", Partitions.DefaultBootFs) Ops.set(pb, "fsid", Partitions.FsidBoot(dlabel)) # FIXME: might be useless Ops.set(pb, "filesystem_id", Partitions.FsidBoot(dlabel)) Ops.set(pb, "id", Partitions.FsidBoot(dlabel)) # FIXME: might be useless Ops.set(pb, "format", false) if raw_partition?(pb) Ops.set(pb, "auto_added", true) Ops.set(pb, "type", :primary) # FIXME: might be useless Ops.set(pb, "partition_type", "primary") Ops.set(pb, "nr", 1) #pb["max_cyl"] = Partitions::BootCyl(); #tc["partitions"] = add( tc["partitions"]:[], pb ); Ops.set( tc, "partitions", Builtins.merge([pb], Ops.get_list(tc, "partitions", [])) ) Builtins.y2milestone("boot added automagically pb %1", pb) end deep_copy(tc) end |
- (Object) try_resize_windows(disk)
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 |
# File '../../src/include/autoinstall/autopart.rb', line 2200 def try_resize_windows(disk) disk = deep_copy(disk) cyl_size = Ops.get_integer(disk, "cyl_size", 1) win = {} ret = Builtins.eval(disk) Ops.set( ret, "partitions", Builtins.maplist(Ops.get_list(ret, "partitions", [])) do |p| fsid = Ops.get_integer(p, "fsid", 0) if Partitions.IsDosPartition(fsid) psize = Ops.multiply( Ops.subtract( Ops.add( Ops.get_integer(p, ["region", 0], 0), Ops.get_integer(p, ["region", 1], 1) ), 1 ), cyl_size ) win = Storage.GetFreeSpace( Ops.get_string(p, "device", ""), :fat32, false ) Builtins.y2milestone("win=%1", win) if win != nil && Ops.greater_than(psize, 300 * 1024 * 1024) Ops.set(p, "winfo", win) Ops.set( p, ["region", 1], Ops.divide( Ops.subtract( Ops.add(Ops.get_integer(win, "new_size", 0), cyl_size), 1 ), cyl_size ) ) Builtins.y2milestone("win part %1", p) end end deep_copy(p) end ) deep_copy(ret) end |