summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-boot/grub/Manifest40
-rw-r--r--sys-boot/grub/files/1.99-call_proper_grub_probe.patch12
-rw-r--r--sys-boot/grub/files/1.99-do_not_stat_so_often.patch65
-rw-r--r--sys-boot/grub/files/1.99-improve_devmapper.patch279
-rw-r--r--sys-boot/grub/files/1.99-stat_root_device_properly-p1.patch21
-rw-r--r--sys-boot/grub/files/1.99-stat_root_device_properly-p2.patch21
-rw-r--r--sys-boot/grub/files/formilux/0002_all_save-default-entry-on-mbr.patch105
-rw-r--r--sys-boot/grub/files/formilux/0003_all_add-grub-mbr-default3.patch197
-rw-r--r--sys-boot/grub/files/formilux/0004_all_add-support-for-the-savemap-keyword.patch117
-rw-r--r--sys-boot/grub/files/formilux/0005_all_update-default_entry-according-to-the-savemap.patch40
-rw-r--r--sys-boot/grub/files/formilux/0006_all_add-support-for-savedefault-savemap.patch27
-rw-r--r--sys-boot/grub/files/formilux/0007_all_update-the-savemap-upon-user-action-or-fallback.patch77
-rw-r--r--sys-boot/grub/files/formilux/0008_all_documentation-savemap.patch292
-rw-r--r--sys-boot/grub/files/formilux/0009_all_sample-config-files-using-savemap.patch102
-rw-r--r--sys-boot/grub/files/formilux/0010_all_print-a-dot-for-each-disk-I-O-in-debug-mode.patch47
-rw-r--r--sys-boot/grub/files/formilux/0011_all_add-a-debug-message-booting-image-now-just-before.patch12
-rw-r--r--sys-boot/grub/files/grub.default36
-rw-r--r--sys-boot/grub/grub-0.97-r10.ebuild294
-rw-r--r--sys-boot/grub/grub-0.97-r12.ebuild289
19 files changed, 2063 insertions, 10 deletions
diff --git a/sys-boot/grub/Manifest b/sys-boot/grub/Manifest
index f6a661f5..75b114e5 100644
--- a/sys-boot/grub/Manifest
+++ b/sys-boot/grub/Manifest
@@ -1,10 +1,30 @@
-AUX grub-0.97-gpt.patch 10682 RMD160 53dd38d52f2b38fb28dfb670d6fd27e47a562bbb SHA1 6057a076110d469fb63e56e57711d281221f9b42 SHA256 5e38046cfb727420e5b4b19d71c7fb4ddff22cbcc356c9f888763b0c1963d389
-AUX grub-1.95-build.patch 522 RMD160 eec01af7250a0883604530f321b154c575b14c41 SHA1 6f93b47a212ed0b3fb807bcf96e04792fa196ba1 SHA256 26d45247376f1e42b4197088161146173ea5bee3800282a707b331c49aed6ccf
-AUX grub-1.96-genkernel.patch 298 RMD160 3acae46d0c9a6b0c97960728751c679e32f0521d SHA1 b496e4486a546cfb72b81b27d8642c7d2e5123cb SHA256 8cbbaf1db68c39dfcc30b59779d820e9e9dca7ef957431791cdc0fc24e258eaf
-AUX grub.conf.gentoo 627 RMD160 d90fb4373bad476f98ec9c5065d6cdfd9e3b706f SHA1 004f2fc04605ec9190de0a87e7df8bbc33daff89 SHA256 914b15af252210a32776196437cd8013e10e57d5780e66877ef3fe9a2b4b9776
-DIST grub-0.97-patches-1.7.tar.bz2 31190 RMD160 f72f956c36d07e914bb7b4512ff9c88349123ab0 SHA1 6c5e011a8a55fc986abc84c43d59266a42f2ac9c SHA256 6dfb17ff874ce8f737211a728c319a133b90e3633a80daf5ef370c15ee625389
-DIST grub-0.97-patches-1.9.tar.bz2 51809 RMD160 a745902212dbd22f4d9f0bb0d563ffd44b429eaa SHA1 1d9da2df8bccef9821ebbbc2f5c5353dbd90bf4d SHA256 6b8445c9260803f059031cbe7475a45fee6499fc2dbd911288af6169455c4028
-DIST grub-0.97.tar.gz 971783 RMD160 7fb5674edf0c950bd38e94f85ff1e2909aa741f0 SHA1 2580626c4579bd99336d3af4482c346c95dac4fb SHA256 4e1d15d12dbd3e9208111d6b806ad5a9857ca8850c47877d36575b904559260b
-DIST splash.xpm.gz 33856 RMD160 2fead61f91c368429e80936248bb02af2bdf15ff SHA1 98e679f9698be43426f971f89a088c053e8c804a SHA256 b95600f777331b0dd31d51c68f60f0e846e4c8b628857a41165f4e6b30e6acaf
-EBUILD grub-0.97-r6.ebuild 8857 RMD160 75b99aead16428487f3d3a5c970b7a29e87bc561 SHA1 b05b78cef0e3cb484f00e6d1408fd2fda179bea3 SHA256 c37efeef73e947919a019d94e6ed66f106372dc4d27a030daf080a61647206a4
-EBUILD grub-0.97-r9.ebuild 8860 RMD160 681b0548cba74e4503a5248b1441737cd269b6b1 SHA1 617961f7c2820494a75b79a304a24e4ce35152c6 SHA256 18db2b78c2b640a29bfa348fe1bcb5f48858d469b58874ceb5fdc2fba0e38190
+AUX 1.99-call_proper_grub_probe.patch 536 SHA256 0e27b4ba6a0deedef2f65822e3b76aea4a817cb7219b01c29c8f682c450bd5e8 SHA512 db4188ed7e5ed3a736580cb17b3a41b984e81d65036254e699a3cba409cfdcbe342341a467c2e01d351800f70ec1b4c61c0fd23c2c4c5fbdf9949a16b43c4d4b WHIRLPOOL eda7dece32b1c3f74227b4f0e53e8846e30f0d56239c512ae17d852fa36825294b314d2c1af8d10807cf345201e31e37762fd556f2c2390ae9de9327129a8df0
+AUX 1.99-do_not_stat_so_often.patch 1731 SHA256 a33fdbcab7fa4ad66b26598d9a6f1703f419229058c1e9c9c14edb6272783727 SHA512 66c0e7ea45228b1b58fd842316c35ce708a4fc3170f255165dc90073ea109a7e7f34a0673bca3f8228c392fbd9470cf36984e9e3d9de59c4cd6974ddf05da1b5 WHIRLPOOL bb8e382e4822a03028340092e67ccfc84f5608a4600b329b85c1b325b01d6c0476223e0e102b0948e4ea4cf7cbf310c56468f3c703a72edb5383b8eda30f7f8d
+AUX 1.99-improve_devmapper.patch 7134 SHA256 b12624944d129820966146d55693b325d48d5d56901727142e386be082661778 SHA512 21d73e2d7f6e065f254a1cc55675e45fe5d1e345f44d8de648395bcd41750324641e84c807839aa06261095ec229a8928290f609d0558d7c897764881305de46 WHIRLPOOL 5e168f740d81e20122acbe1cbfb37cbcb09ba27d1ed2edc537825664107aa416aae5d87ffb96207768a186ba2309e64925a9b9d0f67163fcee7568408e4bac59
+AUX 1.99-stat_root_device_properly-p1.patch 698 SHA256 1facf84e5195eb98b390e43e0a0d6f791e9500ef678b025e95f96d5a2769da5a SHA512 bb2b88d9c5ff6a37292c98ddc1e655076781ac485a5625d09f3cac596ba3aac4b06f9fb0fd250146dd3be1f9e0328085d3a6c52137a4ab5dd3961c53ba87e0ec WHIRLPOOL 92e0cd474b2277876037e602ed47b76b62fe2becc98a0704c9de7ca318f97d89c5a137473fbc558eeea7fed907e49293a61ae3c0a914ec365b2558db37cd4e04
+AUX 1.99-stat_root_device_properly-p2.patch 621 SHA256 431876459562c0aae6e854a97eeaf0cacdad8ceb5477788a4d691e4e6fa613eb SHA512 6953a5a7c48cd38ab41f60d3c4ef8fbeb413408fc749feca7cfffa0413e370c298f3fe3b6a01e457ec376524c9d40536258f7c0fde1e76991774291571117f76 WHIRLPOOL b94e253e2169e8b3a958cb49db81a86aa7d35de29b3fdfc9c58121f18496dcf440b4abe7b07c6d952f3f2172155958100b60795d96485108f874fa163d8c1883
+AUX formilux/0002_all_save-default-entry-on-mbr.patch 2915 SHA256 7177b8f2c75886cf5f97cf623ab4b86bb7818effc4472f2f8f208b4269663d7a SHA512 85a37c85bfa5b46e4f6df5e0a4d1ec2bbee51c0773cfde16677e145c5d3f7678b8087ba8624a46f48a0874910799de492224d124bfb0e6fcaf6aa643a53671d9 WHIRLPOOL 3a038809cae93b412bf712b2f76070b35d58ffb48e09c8d3729a6466e8dca03a7c08afdbf2c72520aa3551cfd48af27ac8bb0ad0cbf88e35bdb11717cfb23a6c
+AUX formilux/0003_all_add-grub-mbr-default3.patch 6097 SHA256 3bc1c5488bd8e9b9038374b62bf88d0c4eedd2a32a2e8bf63c8a52039a4f8164 SHA512 4720ce4bd2266f46d124849c845569660f398309428aea0f22bbd91d0cf6b478da4115d5c536e35953b09f788a1dcae375172db21cb87ad120268787f2f8ef26 WHIRLPOOL b49e110f6b418f1660cbf430ad9517ffcac88aa468c4da2cce2d757c4cafd743f69a5b64a146ea479fa633f6a6f5de1de774cbb792feead705b8423eb37280b1
+AUX formilux/0004_all_add-support-for-the-savemap-keyword.patch 2751 SHA256 9bed3175a97b1b35d4e4c08901d3b3c73ddb3b255736dd3165da1e9c0defc885 SHA512 f6a43fe01076af6e912f72678346c51b5f49d169cefc03b38d1a69ab947c00a6422819f4261fd66c5b537dd04dacfd91e42846726a13f3487d2087863d033c33 WHIRLPOOL 13cd9c09ae9daa4610231a358eb3756e7ecc582a419ae9990052a055513fd7c67398e9ae2cbc072d70f6e364b1288c1cbc87003ed1fe7d8967d9ed5cc864f81a
+AUX formilux/0005_all_update-default_entry-according-to-the-savemap.patch 1122 SHA256 e4b5ba5a63e0f2de7fdedd11497211f655b3cda491c6041f019b9d19577ee987 SHA512 5ec06d89455093882b71bfa75519c7ed4efba4435a81a0aa686b7d07a4f14e7d15d00f2d6ae7e4fbc4811887b47c7a872587fafc7494a23eb9aa3d550e6f7ba1 WHIRLPOOL 8330c85c2dd26a16ea56d727bcaf5d4ab70bf8a007842db4c61229514e3b197ffc711ca801fa3a33b096775d3cc0323c851ae671b626cc7b0b47364bf992dd4c
+AUX formilux/0006_all_add-support-for-savedefault-savemap.patch 948 SHA256 0935390c75a40cd6c61032cbebd7914b19665dd23c65ad018ad94fe3a6a79606 SHA512 5cfa6d8da38935a7e299ead6a73e668b35e85d417c17f9d3145866ff35fc2e3e6827c5d04b3ef3a4fe145ddf0451f924b7a7cc08dd7e89dbd52f57333b90dff6 WHIRLPOOL 53f8e90f4eeb7bbb0f1332b19ab65344a282702f6b2760f4620bc9863d79ea4255a7b0f73072e8287e8678a613e3d23acfc7129589cf91755fda46af266dfce6
+AUX formilux/0007_all_update-the-savemap-upon-user-action-or-fallback.patch 2445 SHA256 2d1bc81b7afced1d151e2e1fe328397547ad1f97c865b7c02283ca31b8d40de5 SHA512 1d20ae475424d9035757243b4618edf8057b744eb9bd240fec30bf046b3ea20c5db65d8a3c8ebe90309e7d8d3d5735ffdb4f5c9643747e7980609d451c9e9fc7 WHIRLPOOL a6794f70590d3ae42ae3aa03aec1154b9435f9333c11454fc3c6b97009f90ad6b894425428e25ebc20a9c5762c88a2632061f5bef0703c8e1a0f609e3097fae8
+AUX formilux/0008_all_documentation-savemap.patch 10770 SHA256 da81461e3128fed1c53415bc12c493866f773bbf2305f73f13db5bc6156ee739 SHA512 34c37af4a860da842c0f21a836948a5fa8cb6d9d60efc35d1934bbd7f51b0ca1134ace0abb3957ae8eade0a3497c7f422cbe1aec43288c57fbcb0be1ff38668d WHIRLPOOL 9f3fc6d9e35b61b492a929d4afd09784bcda5ffd29da4400e3b86d2abd506a27edcb985a29b6591267157bb44b5d984696391b199d802bd6a1698bcbe49d987a
+AUX formilux/0009_all_sample-config-files-using-savemap.patch 2750 SHA256 226287798b8669d069638d2df6918a028e5c7462794ae0febba70813e2efac9f SHA512 dddbffc392f2d78fec604a86a34981b76ab8ed44faafec11f56c692458e4416478e79a6d66649c13f174125fd69b1b5657f15ebbc4f6214cb79e60081ed42251 WHIRLPOOL 0d4eb2ad32a1e09a376419425e5a5a2007f5397fdd0eecec5f1cea22ee1feb559b698e6d41105958aea7c7d74cf4856060d84e4d9b8e5bd2306b6a9097805c28
+AUX formilux/0010_all_print-a-dot-for-each-disk-I-O-in-debug-mode.patch 1386 SHA256 93bea20c2b4676b893d1de6ac25d10bb83df7c8ac2f1f0e67fc2e5ece1193a7e SHA512 847fbfc25dc506ac88704daaf24bfce827d9a0b5abdcda16cea4e0ac738e9088322852917cd486f98a66eac38c63913760e8b82e84b4b5d1fe3944953f6805af WHIRLPOOL 731cff1039cf136c25e4b3eccf276f6a36817850c65d5a59f2783770332e540c7153409fa09b17105a73f525652737bc824b60b70e0e9948e3a342c0b3ef47c3
+AUX formilux/0011_all_add-a-debug-message-booting-image-now-just-before.patch 483 SHA256 02ed78b94fb1e24b8c4c7df7f9182fad099bf1c420237cda39a490ea96dfa57e SHA512 7752719293b80fff6a5aa99f785e238b14dd42158afb50726dc1eb4e5ddc413172c6d310c782ecc2def7cf325b4020d2be788510621a9b4501c73cec33517f5d WHIRLPOOL 2e1e4d107586fdf02555dfbe80e62b372ef20125a389a9f005050dffb8bb4767c77e2d5312d64edb8b576e24b878ffd2913214604487532c294c63b246e20bc2
+AUX grub-0.97-gpt.patch 10682 SHA256 5e38046cfb727420e5b4b19d71c7fb4ddff22cbcc356c9f888763b0c1963d389 SHA512 2fe10c839c4c575750f7eeb29953c00f232771a3143687aac21e3b90585ec59d6f7c0346db80c0aa3c18d27799d301711d6f995f6781ce8a148c7ce59004e1aa WHIRLPOOL 22b3d12124115ec78fff2b3699c44d3b2c0bb84bec673e36d66e73c9da89137d237b1c7681b671ce89b06b2f4d78f9999eca98f43aa284d2b610713fc4161226
+AUX grub-1.95-build.patch 522 SHA256 26d45247376f1e42b4197088161146173ea5bee3800282a707b331c49aed6ccf SHA512 50ed75d48d317cf3db2f6666c4690e347f226d6619c933ed3d94c8d515b9710426cc3b2871a51ac892b9d42bdf77a2434c2d36dd8f76742b4dc849a6de7ec7f8 WHIRLPOOL df1b2482d0af05b3e6a681a567f3d77eca0b997b20fd4b84a5fbb50c6bf440e363d7a2dd4a8d98108261a3cacb2b548fec337823ae95ad43e44fd05b52af419e
+AUX grub-1.96-genkernel.patch 298 SHA256 8cbbaf1db68c39dfcc30b59779d820e9e9dca7ef957431791cdc0fc24e258eaf SHA512 c92ec8d8a67e1411ffc716cee923cdc84ad4ac209a34b2599475ee7488d61b2115dbd02359370d4aa94c7225f62460da11933a73c3c4c6152cbb188aa855fe2b WHIRLPOOL 4f4a6e3f4451df9574abcc42ccbf6dafd603bbc7d90d46f72830b217e10db6007075af4db040c834ef7200173063f630c7160f13d5ea8545fce6fbef10b60cd1
+AUX grub.conf.gentoo 627 SHA256 914b15af252210a32776196437cd8013e10e57d5780e66877ef3fe9a2b4b9776 SHA512 5ee586c151b025a153867d2854b73e2e18a6af38e9d65069b7114a55af776803ba947b4901b0806e79fa8f36aeac90daad608b9ec2a4a8526301d1beb36e4ef3 WHIRLPOOL fcaef85cd7c2c446c882874cf4ec8a2241d1fc97720973a0a0cd1add259da599d4dae4d0b429ba2dff0307ed2d4598d5939cbc1b11127a0dedb3a54249ec9f81
+AUX grub.default 1229 SHA256 1ca3065f28c72043036fdc19565e66b1315928c725765463b2c6037e04deb1c5 SHA512 61854b630885aaee47182a1a8b42f18460261210c8891b8bc4cd8c49e787edd332b9c66c37c3d65228937b612bb9925c4398f1981fa80be01c7a75a51ada2fd3 WHIRLPOOL ec83659ffca38b08f97ac3b272fa64794a13c11c5b153f901a5f38c28d616751c5876e445e21367e58e60ae28cb241499229df697f8deeff8e6f9487d35ab4d5
+DIST grub-0.97-patches-1.12.tar.bz2 55811 SHA256 80cedf74d29e334182d8fb906035d2c365b96b6e8a09bbe800f44f98c828ac97
+DIST grub-0.97-patches-1.14.tar.bz2 52916 SHA256 5c7ca31fd9b2123471daf2e46a1936c4044ad0c12e353d9d3d8c3f83a1c7a0e5 SHA512 d9a8d420fd5a36f181ca608f9b70be90f9d82cee66c8484636fda5085290586071b5d9379d917e8141b993ffc4777859cd02971c916d6167dca6f50d83282c26 WHIRLPOOL 60abd5087e85d9969784b9f5a100934606a76da03b665533d9d4d1d13f4e2d15de233a71e67a32d18a5fbfe128c2c8bf04c0d4451de24e6ca4fbd8dd862e23ea
+DIST grub-0.97-patches-1.7.tar.bz2 31190 SHA256 6dfb17ff874ce8f737211a728c319a133b90e3633a80daf5ef370c15ee625389
+DIST grub-0.97-patches-1.9.tar.bz2 51809 SHA256 6b8445c9260803f059031cbe7475a45fee6499fc2dbd911288af6169455c4028
+DIST grub-0.97.tar.gz 971783 SHA256 4e1d15d12dbd3e9208111d6b806ad5a9857ca8850c47877d36575b904559260b SHA512 c2bc9ffc8583aeae71cee9ddcc4418969768d4e3764d47307da54f93981c0109fb07d84b061b3a3628bd00ba4d14a54742bc04848110eb3ae8ca25dbfbaabadb WHIRLPOOL 0ad7f5dc035e2a3ad5fd29b6388f06fd12a8cc694117b4cbd42b5302433aa522db23566222d35219fe17fb95edb5090553156198507f70208eda5d858fd52dd5
+DIST splash.xpm.gz 33856 SHA256 b95600f777331b0dd31d51c68f60f0e846e4c8b628857a41165f4e6b30e6acaf SHA512 5ae1f786f7d46a95a7061068d5b2b3ad64607c7b190d6f28379508c5dce67e26308325bfd637542a84855dfcf1ea3d143947326fdb189a6a8972208d3ead23da WHIRLPOOL d95b7b588ea8ac7c2c8c53eb8057aef21c825da6411afe3b7e864c606aeffaaebce8ae41ce3e979f277bd6b48a9e82a1f2ea8afc836213b56523d8a854227d7b
+EBUILD grub-0.97-r10.ebuild 9487 SHA256 a6dc3e35c7e76990b16bc8195fd9d598f2c66061752a7d9970cd8a4635bf8ef2 SHA512 8bf7e206d5a4c627640edbfc2401d7b5bf15fa67f7e823df2590f9b543fce6c0ca4120168710266e10cf39ac36af9a91e39fc444ed7a3eb5511f8a5c4feabe2b WHIRLPOOL 7ab4df65228f473141725bbe932d5dc2983d800e3e43d554218e915773943f5e5d2798608537048a449a026b8e1b30dd2d0a77a549c57b9bdd0b888d7095b486
+EBUILD grub-0.97-r12.ebuild 9287 SHA256 4b8e80dac1fbd7e98db79d1e44aef9380f4412787ac9cbc4d9531b030ecdbb65 SHA512 d289cbb0f0477c01ce697b81cac60e49ac68238a19083a128606c3894d49c901d8ee2cb32e28dccc095dea7e88d633ca1ac1d35373af0def584211d340f21459 WHIRLPOOL fd34a8b8ac8d369596328c40cac5aeb1645b9cc1ad3ea4d939e6d66c35a00b569d43452ee878ff52f6b9b38270039b334ca4e19918a308c2e77ca23caa954d16
+EBUILD grub-0.97-r6.ebuild 8857 SHA256 c37efeef73e947919a019d94e6ed66f106372dc4d27a030daf080a61647206a4 SHA512 01f2bf353aa90b5027cdcc002aa005305122628f0a8f4f4159850a512f37c6d37d861c87cf7b98721985ab87fe3b11f36760b396a48db9815919fcaa4b30c8be WHIRLPOOL 25494c4f42b41668f1a122651b5952572830cc58375c0ddd103273d1b4957157f01afe2ac2dc8d27e3ac8f1e15fc0105a09ef137cc9638b81687fa4c6e3a10c2
+EBUILD grub-0.97-r9.ebuild 8860 SHA256 18db2b78c2b640a29bfa348fe1bcb5f48858d469b58874ceb5fdc2fba0e38190 SHA512 6da5ff55ca4da435af8870f4a9198bd7fc54fab2800744534a5d70914a0c1f47757e035aa864e6bf06684ad581fd41ce3eabfee556291829de98c161239fdf8e WHIRLPOOL 9914122685c3c5a88528db6b233d34a5c1d4e0b91e8ef5bfbf7aa2957f2656b46f2beefc7af8cb9ee361d256399e6d2f1d2b4438ecc4339120864a31551e4534
diff --git a/sys-boot/grub/files/1.99-call_proper_grub_probe.patch b/sys-boot/grub/files/1.99-call_proper_grub_probe.patch
new file mode 100644
index 00000000..6d65b5f8
--- /dev/null
+++ b/sys-boot/grub/files/1.99-call_proper_grub_probe.patch
@@ -0,0 +1,12 @@
+diff -urN grub-1.99/util/grub.d/30_os-prober.in grub-1.99.new/util/grub.d/30_os-prober.in
+--- grub-1.99/util/grub.d/30_os-prober.in 2010-12-25 18:13:57.000000000 +0100
++++ grub-1.99.new/util/grub.d/30_os-prober.in 2011-08-28 12:35:40.965038455 +0200
+@@ -168,7 +168,7 @@
+ done
+ ;;
+ macosx)
+- OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
++ OSXUUID="`${grub_probe} --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
+ osx_entry xnu_kernel 32
+ osx_entry xnu_kernel64 64
+ ;;
diff --git a/sys-boot/grub/files/1.99-do_not_stat_so_often.patch b/sys-boot/grub/files/1.99-do_not_stat_so_often.patch
new file mode 100644
index 00000000..ca8a0239
--- /dev/null
+++ b/sys-boot/grub/files/1.99-do_not_stat_so_often.patch
@@ -0,0 +1,65 @@
+--- grub-core/kern/emu/getroot.c 2011-05-18 07:35:47 +0000
++++ grub-core/kern/emu/getroot.c 2011-05-21 05:03:55 +0000
+@@ -358,7 +358,7 @@
+
+ if (S_ISLNK (st.st_mode)) {
+ #ifdef __linux__
+- if (strcmp (dir, "mapper") == 0) {
++ if (strcmp (dir, "mapper") == 0 || strcmp (dir, "/dev/mapper") == 0) {
+ /* Follow symbolic links under /dev/mapper/; the canonical name
+ may be something like /dev/dm-0, but the names under
+ /dev/mapper/ are more human-readable and so we prefer them if
+@@ -609,20 +609,27 @@
+
+ if (os_dev)
+ {
+- if (stat (os_dev, &st) >= 0)
+- dev = st.st_rdev;
+- else
++ char *tmp = os_dev;
++ os_dev = canonicalize_file_name (os_dev);
++ free (tmp);
++ }
++
++ if (os_dev)
++ {
++ if (strncmp (os_dev, "/dev/dm-", sizeof ("/dev/dm-") - 1) != 0)
++ return os_dev;
++ if (stat (os_dev, &st) < 0)
+ grub_util_error ("cannot stat `%s'", os_dev);
+ free (os_dev);
+- }
+- else
+- {
+- if (stat (dir, &st) >= 0)
+- dev = st.st_dev;
+- else
+- grub_util_error ("cannot stat `%s'", dir);
+- }
+-
++ dev = st.st_rdev;
++ return grub_find_device ("/dev/mapper", dev);
++ }
++
++ if (stat (dir, &st) < 0)
++ grub_util_error ("cannot stat `%s'", dir);
++
++ dev = st.st_dev;
++
+ #ifdef __CYGWIN__
+ /* Cygwin specific function. */
+ os_dev = grub_find_device (dir, dev);
+
+--- grub-core/kern/emu/hostdisk.c 2011-05-18 07:35:47 +0000
++++ grub-core/kern/emu/hostdisk.c 2011-05-21 05:03:55 +0000
+@@ -1408,7 +1408,8 @@
+ if (tree)
+ dm_tree_free (tree);
+ free (path);
+- char *ret = grub_find_device (NULL, (major << 8) | minor);
++ char *ret = grub_find_device ("/dev/mapper",
++ (major << 8) | minor);
+ return ret;
+ }
+
+
diff --git a/sys-boot/grub/files/1.99-improve_devmapper.patch b/sys-boot/grub/files/1.99-improve_devmapper.patch
new file mode 100644
index 00000000..5f0a930e
--- /dev/null
+++ b/sys-boot/grub/files/1.99-improve_devmapper.patch
@@ -0,0 +1,279 @@
+--- grub-core/kern/emu/getroot.c 2011-04-21 09:26:29 +0000
++++ grub-core/kern/emu/getroot.c 2011-05-18 07:35:47 +0000
+@@ -34,6 +34,10 @@
+ #include <stdint.h>
+ #include <grub/util/misc.h>
+
++#ifdef HAVE_DEVICE_MAPPER
++# include <libdevmapper.h>
++#endif
++
+ #ifdef __GNU__
+ #include <hurd.h>
+ #include <hurd/lookup.h>
+@@ -634,32 +638,65 @@
+ }
+
+ static int
+-grub_util_is_dmraid (const char *os_dev)
++grub_util_is_lvm (const char *os_dev)
+ {
+- if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/isw_", 16))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/hpt37x_", 19))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/hpt45x_", 19))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/via_", 16))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/lsi_", 16))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/pdc_", 16))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/jmicron_", 20))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/asr_", 16))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/sil_", 16))
+- return 1;
+- else if (! strncmp (os_dev, "/dev/mapper/ddf1_", 17))
+- return 1;
+-
+- return 0;
++ if ((strncmp ("/dev/mapper/", os_dev, 12) != 0))
++ return 0;
++
++#ifdef HAVE_DEVICE_MAPPER
++ {
++ struct dm_tree *tree;
++ uint32_t maj, min;
++ struct dm_tree_node *node = NULL;
++ const char *node_uuid;
++ struct stat st;
++
++ if (stat (os_dev, &st) < 0)
++ return 0;
++
++ tree = dm_tree_create ();
++ if (! tree)
++ {
++ grub_printf ("Failed to create tree\n");
++ grub_dprintf ("hostdisk", "dm_tree_create failed\n");
++ return 0;
++ }
++
++ maj = major (st.st_rdev);
++ min = minor (st.st_rdev);
++
++ if (! dm_tree_add_dev (tree, maj, min))
++ {
++ grub_dprintf ("hostdisk", "dm_tree_add_dev failed\n");
++ dm_tree_free (tree);
++ return 0;
++ }
++
++ node = dm_tree_find_node (tree, maj, min);
++ if (! node)
++ {
++ grub_dprintf ("hostdisk", "dm_tree_find_node failed\n");
++ dm_tree_free (tree);
++ return 0;
++ }
++ node_uuid = dm_tree_node_get_uuid (node);
++ if (! node_uuid)
++ {
++ grub_dprintf ("hostdisk", "%s has no DM uuid\n", os_dev);
++ dm_tree_free (tree);
++ return 0;
++ }
++ if (strncmp (node_uuid, "LVM-", 4) != 0)
++ {
++ dm_tree_free (tree);
++ return 0;
++ }
++ dm_tree_free (tree);
++ return 1;
++ }
++#else
++ return 1;
++#endif /* HAVE_DEVICE_MAPPER */
+ }
+
+ int
+@@ -671,13 +708,11 @@
+ return GRUB_DEV_ABSTRACTION_NONE;
+
+ /* Check for LVM. */
+- if (!strncmp (os_dev, "/dev/mapper/", 12)
+- && ! grub_util_is_dmraid (os_dev)
+- && strncmp (os_dev, "/dev/mapper/mpath", 17) != 0)
++ if (grub_util_is_lvm (os_dev))
+ return GRUB_DEV_ABSTRACTION_LVM;
+
+ /* Check for RAID. */
+- if (!strncmp (os_dev, "/dev/md", 7))
++ if (!strncmp (os_dev, "/dev/md", 7) && ! grub_util_device_is_mapped (os_dev))
+ return GRUB_DEV_ABSTRACTION_RAID;
+ #endif
+
+
+=== modified file 'grub-core/kern/emu/hostdisk.c'
+--- grub-core/kern/emu/hostdisk.c 2011-05-09 16:59:35 +0000
++++ grub-core/kern/emu/hostdisk.c 2011-05-18 07:35:47 +0000
+@@ -24,6 +24,7 @@
+ #include <grub/err.h>
+ #include <grub/emu/misc.h>
+ #include <grub/emu/hostdisk.h>
++#include <grub/emu/getroot.h>
+ #include <grub/misc.h>
+ #include <grub/i18n.h>
+ #include <grub/list.h>
+@@ -331,18 +332,23 @@
+ return GRUB_ERR_NONE;
+ }
+
++int
++grub_util_device_is_mapped (const char *dev)
++{
+ #ifdef HAVE_DEVICE_MAPPER
+-static int
+-device_is_mapped (const char *dev)
+-{
+ struct stat st;
+
++ if (!grub_device_mapper_supported ())
++ return 0;
++
+ if (stat (dev, &st) < 0)
+ return 0;
+
+ return dm_is_dm_major (major (st.st_rdev));
++#else
++ return 0;
++#endif /* HAVE_DEVICE_MAPPER */
+ }
+-#endif /* HAVE_DEVICE_MAPPER */
+
+ #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
+ /* FIXME: geom actually gives us the whole container hierarchy.
+@@ -418,7 +424,7 @@
+ # endif /* !defined(HAVE_DIOCGDINFO) */
+
+ # ifdef HAVE_DEVICE_MAPPER
+- if (grub_device_mapper_supported () && device_is_mapped (dev)) {
++ if (grub_util_device_is_mapped (dev)) {
+ struct dm_task *task = NULL;
+ grub_uint64_t start, length;
+ char *target_type, *params, *space;
+@@ -1149,6 +1155,54 @@
+ return ret;
+ }
+
++#ifdef HAVE_DEVICE_MAPPER
++static int
++grub_util_get_dm_node_linear_info (const char *dev,
++ int *maj, int *min)
++{
++ struct dm_task *dmt;
++ void *next = NULL;
++ uint64_t length, start;
++ char *target, *params;
++ char *ptr;
++ int major, minor;
++
++ dmt = dm_task_create(DM_DEVICE_TABLE);
++ if (!dmt)
++ return 0;
++
++ if (!dm_task_set_name(dmt, dev))
++ return 0;
++ dm_task_no_open_count(dmt);
++ if (!dm_task_run(dmt))
++ return 0;
++ next = dm_get_next_target(dmt, next, &start, &length,
++ &target, &params);
++ if (grub_strcmp (target, "linear") != 0)
++ return 0;
++ major = grub_strtoul (params, &ptr, 10);
++ if (grub_errno)
++ {
++ grub_errno = GRUB_ERR_NONE;
++ return 0;
++ }
++ if (*ptr != ':')
++ return 0;
++ ptr++;
++ minor = grub_strtoul (ptr, 0, 10);
++ if (grub_errno)
++ {
++ grub_errno = GRUB_ERR_NONE;
++ return 0;
++ }
++ if (maj)
++ *maj = major;
++ if (min)
++ *min = minor;
++ return 1;
++}
++#endif
++
+ static char *
+ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st)
+ {
+@@ -1325,9 +1379,39 @@
+ node = NULL;
+ goto devmapper_out;
+ }
+- else if (strncmp (node_uuid, "DMRAID-", 7) != 0)
+- {
++ if (strncmp (node_uuid, "LVM-", 4) == 0)
++ {
++ grub_dprintf ("hostdisk", "%s is an LVM\n", path);
++ node = NULL;
++ goto devmapper_out;
++ }
++ if (strncmp (node_uuid, "mpath-", 6) == 0)
++ {
++ /* Multipath partitions have partN-mpath-* UUIDs, and are
++ linear mappings so are handled by
++ grub_util_get_dm_node_linear_info. Multipath disks are not
++ linear mappings and must be handled specially. */
++ grub_dprintf ("hostdisk", "%s is a multipath disk\n", path);
++ mapper_name = dm_tree_node_get_name (node);
++ goto devmapper_out;
++ }
++ if (strncmp (node_uuid, "DMRAID-", 7) != 0)
++ {
++ int major, minor;
++ const char *node_name;
+ grub_dprintf ("hostdisk", "%s is not DM-RAID\n", path);
++
++ if ((node_name = dm_tree_node_get_name (node))
++ && grub_util_get_dm_node_linear_info (node_name,
++ &major, &minor))
++ {
++ if (tree)
++ dm_tree_free (tree);
++ free (path);
++ char *ret = grub_find_device (NULL, (major << 8) | minor);
++ return ret;
++ }
++
+ node = NULL;
+ goto devmapper_out;
+ }
+
+--- include/grub/emu/misc.h 2010-12-02 13:26:46 +0000
++++ include/grub/emu/misc.h 2011-05-18 07:35:47 +0000
+@@ -54,6 +54,8 @@
+
+ char *grub_make_system_path_relative_to_its_root (const char *path)
+ __attribute__ ((warn_unused_result));
++int
++grub_util_device_is_mapped (const char *dev);
+
+ void * EXPORT_FUNC(xmalloc) (grub_size_t size) __attribute__ ((warn_unused_result));
+ void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) __attribute__ ((warn_unused_result));
+
diff --git a/sys-boot/grub/files/1.99-stat_root_device_properly-p1.patch b/sys-boot/grub/files/1.99-stat_root_device_properly-p1.patch
new file mode 100644
index 00000000..fc14c536
--- /dev/null
+++ b/sys-boot/grub/files/1.99-stat_root_device_properly-p1.patch
@@ -0,0 +1,21 @@
+--- grub-core/kern/emu/getroot.c 2011-05-21 05:03:55 +0000
++++ grub-core/kern/emu/getroot.c 2011-06-23 17:50:41 +0000
+@@ -616,13 +616,15 @@
+
+ if (os_dev)
+ {
+- if (strncmp (os_dev, "/dev/dm-", sizeof ("/dev/dm-") - 1) != 0)
++ int dm = (strncmp (os_dev, "/dev/dm-", sizeof ("/dev/dm-") - 1) == 0);
++ int root = (strcmp (os_dev, "/dev/root") == 0);
++ if (!dm && !root)
+ return os_dev;
+ if (stat (os_dev, &st) < 0)
+ grub_util_error ("cannot stat `%s'", os_dev);
+ free (os_dev);
+ dev = st.st_rdev;
+- return grub_find_device ("/dev/mapper", dev);
++ return grub_find_device (dm ? "/dev/mapper" : "/dev", dev);
+ }
+
+ if (stat (dir, &st) < 0)
+
diff --git a/sys-boot/grub/files/1.99-stat_root_device_properly-p2.patch b/sys-boot/grub/files/1.99-stat_root_device_properly-p2.patch
new file mode 100644
index 00000000..aa7fd186
--- /dev/null
+++ b/sys-boot/grub/files/1.99-stat_root_device_properly-p2.patch
@@ -0,0 +1,21 @@
+--- grub-core/kern/emu/getroot.c 2011-06-23 17:50:41 +0000
++++ grub-core/kern/emu/getroot.c 2011-06-24 02:32:54 +0000
+@@ -620,11 +620,13 @@
+ int root = (strcmp (os_dev, "/dev/root") == 0);
+ if (!dm && !root)
+ return os_dev;
+- if (stat (os_dev, &st) < 0)
+- grub_util_error ("cannot stat `%s'", os_dev);
++ if (stat (os_dev, &st) >= 0)
++ {
++ free (os_dev);
++ dev = st.st_rdev;
++ return grub_find_device (dm ? "/dev/mapper" : "/dev", dev);
++ }
+ free (os_dev);
+- dev = st.st_rdev;
+- return grub_find_device (dm ? "/dev/mapper" : "/dev", dev);
+ }
+
+ if (stat (dir, &st) < 0)
+
diff --git a/sys-boot/grub/files/formilux/0002_all_save-default-entry-on-mbr.patch b/sys-boot/grub/files/formilux/0002_all_save-default-entry-on-mbr.patch
new file mode 100644
index 00000000..33ed0fcb
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0002_all_save-default-entry-on-mbr.patch
@@ -0,0 +1,105 @@
+diff --git a/stage2/builtins.c b/stage2/builtins.c
+index 17d7459..cb7e648 100644
+--- a/stage2/builtins.c
++++ b/stage2/builtins.c
+@@ -3549,6 +3549,8 @@ savedefault_func (char *arg, int flags)
+ /* Clear the cache. */
+ buf_track = -1;
+ }
++ else
++ put_new_entryno_to_mbr(tmp_drive, entryno);
+
+ fail:
+ saved_drive = tmp_drive;
+diff --git a/stage2/disk_io.c b/stage2/disk_io.c
+index 698d6ba..7e0f689 100644
+--- a/stage2/disk_io.c
++++ b/stage2/disk_io.c
+@@ -1887,3 +1887,57 @@ grub_close (void)
+ if (fsys_table[fsys_type].close_func != 0)
+ (*(fsys_table[fsys_type].close_func)) ();
+ }
++
++#ifndef STAGE1_5
++int
++read_entryno_from_mbr(int drive, char *sector)
++{
++ /* drive must be a hard disk and stage1_5 must be right after the MBR */
++ if (!(drive & 0x80))
++ return 0;
++ if (!rawread(drive, 2, 0, SECTOR_SIZE, sector))
++ return 0;
++ /* sanity checks */
++ if (sector[STAGE2_VER_MAJ_OFFS] != COMPAT_VERSION_MAJOR ||
++ sector[STAGE2_VER_MAJ_OFFS+1] != COMPAT_VERSION_MINOR ||
++ *(unsigned *)&sector[STAGE2_INSTALLPART] != 0xFFFFFF ||
++ grub_memcmp(&sector[STAGE2_VER_STR_OFFS], version_string,
++ sizeof(VERSION))) {
++#if 0
++ printf("read: sec=%d %d %d %s=%s(%d)\n",
++ sector[STAGE2_VER_MAJ_OFFS], sector[STAGE2_VER_MAJ_OFFS+1],
++ sector[STAGE2_INSTALLPART], &sector[STAGE2_VER_STR_OFFS],
++ version_string, sizeof(VERSION));
++#endif
++ return 0;
++ }
++ return 1;
++}
++
++/* Get saved_entryno from the MBR */
++void
++get_saved_entryno_from_mbr(int drive)
++{
++ char sector[SECTOR_SIZE];
++
++ errnum = ERR_NONE;
++ if (!read_entryno_from_mbr(drive, sector))
++ return 0;
++ /* get it from the saved_entryno place */
++ saved_entryno = *(unsigned*)&sector[STAGE2_SAVED_ENTRYNO];
++}
++
++/* Put entryno into the MBR. Returns 1 if done, otherwise 0 (error...) */
++int
++put_new_entryno_to_mbr(int drive, unsigned entryno)
++{
++ char sector[SECTOR_SIZE];
++
++ errnum = ERR_NONE;
++ if (!read_entryno_from_mbr(saved_drive, sector))
++ return 0;
++ *(unsigned *)&sector[STAGE2_SAVED_ENTRYNO] = entryno;
++ rawwrite (drive, 2, sector);
++ return !errnum;
++}
++#endif /* STAGE1_5 */
+diff --git a/stage2/shared.h b/stage2/shared.h
+index 7d9432b..7532980 100644
+--- a/stage2/shared.h
++++ b/stage2/shared.h
+@@ -965,6 +965,11 @@ int grub_seek (int offset);
+ /* Close a file. */
+ void grub_close (void);
+
++#ifndef STAGE1_5
++void get_saved_entryno_from_mbr(int drive);
++int put_new_entryno_to_mbr(int drive, unsigned entryno);
++#endif
++
+ /* List the contents of the directory that was opened with GRUB_OPEN,
+ printing all completions. */
+ int dir (char *dirname);
+diff --git a/stage2/stage2.c b/stage2/stage2.c
+index 0ca3f02..2851d72 100644
+--- a/stage2/stage2.c
++++ b/stage2/stage2.c
+@@ -918,6 +918,9 @@ cmain (void)
+
+ grub_close ();
+ }
++ else
++ get_saved_entryno_from_mbr(saved_drive);
++
+ errnum = ERR_NONE;
+
+ do
diff --git a/sys-boot/grub/files/formilux/0003_all_add-grub-mbr-default3.patch b/sys-boot/grub/files/formilux/0003_all_add-grub-mbr-default3.patch
new file mode 100644
index 00000000..d6521be6
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0003_all_add-grub-mbr-default3.patch
@@ -0,0 +1,197 @@
+diff --git a/util/Makefile.am b/util/Makefile.am
+index 2e04711..127e857 100644
+--- a/util/Makefile.am
++++ b/util/Makefile.am
+@@ -1,4 +1,5 @@
+ bin_PROGRAMS = mbchk
++sbin_PROGRAMS = grub-mbr-default
+ sbin_SCRIPTS = grub-install grub-md5-crypt grub-terminfo \
+ grub-set-default
+ noinst_SCRIPTS = grub-image mkbimage
+@@ -7,6 +8,9 @@ EXTRA_DIST = mkbimage
+
+ # XXX: Need to search for a header file in docs, because of multiboot.h.
+ AM_CFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/docs
++INCLUDES = -I$(top_srcdir)/stage2 -I$(top_srcdir)/stage1
+
+ mbchk_SOURCES = mbchk.c
+ mbchk_LDADD = ../lib/libcommon.a
++
++grub_mbr_default_SOURCES = grub-mbr-default.c
+diff --git a/util/grub-mbr-default.c b/util/grub-mbr-default.c
+new file mode 100644
+index 0000000..6664b77
+--- /dev/null
++++ b/util/grub-mbr-default.c
+@@ -0,0 +1,171 @@
++/*
++ * grub-mbr-default - a boot entry validation tool for the GRUB bootloader.
++ *
++ * Copyright (C) 2005,2007 Willy Tarreau
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <stage1.h>
++#include <config.h>
++
++/* from stage2/shared.h */
++#define STAGE2_VER_MAJ_OFFS 0x6
++#define STAGE2_INSTALLPART 0x8
++#define STAGE2_SAVED_ENTRYNO 0xc
++#define STAGE2_STAGE2_ID 0x10
++#define STAGE2_FORCE_LBA 0x11
++#define STAGE2_VER_STR_OFFS 0x12
++#define SECTOR_SIZE 0x200
++
++
++void usage(char *name);
++void error(int err, char *msg);
++void die(int err, char *msg);
++
++void error(int err, char *msg) {
++ perror(msg);
++ exit(err);
++}
++
++void die(int err, char *msg) {
++ fprintf(stderr, "%s\n", msg);
++ exit(err);
++}
++
++void usage(char *name) {
++ char *n;
++ n = strrchr(name, '/');
++ if (n)
++ name = n + 1;
++
++ fprintf(stderr,
++ "%s: validate last boot entry in GRUB MBR.\n"
++ "Usage:\n"
++ "\t%s [-q] <device>\n"
++ "\t\tshows what next boot entry will be used on device <device>.\n"
++ "\t\tThe -q argument makes the program quiet.\n"
++ "\n\t%s [-q] <device> <entry>\n"
++ "\t\tsets next boot entry to <entry> on device <device>.\n"
++ "\n\t%s [-q] <device> <-round>\n"
++ "\t\tsets next boot entry to (current-1) rounded to <round>.\n"
++ "\t\tThis permits to revalidate the first entry in a series of\n"
++ "\t\t<round> retries leading to a successful boot.\n"
++ "", name, name, name, name);
++
++ exit(1);
++}
++
++int main(int argc, char **argv) {
++ char sector[SECTOR_SIZE];
++ char *device, *progname;
++ int fd, readonly, quiet, stop;
++ int entryno, new_entryno;
++
++ progname = argv[0];
++
++ argc--; argv++;
++ quiet = stop = new_entryno = 0;
++ while (argc && !stop && **argv == '-') {
++ switch (argv[0][1]) {
++ case 'q':
++ quiet = 1;
++ break;
++ case '-':
++ stop = 1;
++ break;
++ default:
++ usage(progname);
++ }
++ argc--; argv++;
++ }
++
++ if (argc < 1)
++ usage(progname);
++
++ device = argv[0];
++ readonly = (argc < 2);
++ if (!readonly)
++ new_entryno = atoi(argv[1]);
++
++ fd = open(device, readonly ? O_RDONLY : O_RDWR);
++ if (fd < 0)
++ error(1, "Failed to open the device :");
++
++ if (lseek(fd, SECTOR_SIZE * 2, SEEK_SET) < 0)
++ error(2, "Cannot seek to the sector :");
++
++ if (read(fd, sector, SECTOR_SIZE) != SECTOR_SIZE)
++ error(2, "Read error or partial read :");
++
++ /* sanity checks */
++ if (sector[STAGE2_VER_MAJ_OFFS] != COMPAT_VERSION_MAJOR ||
++ sector[STAGE2_VER_MAJ_OFFS+1] != COMPAT_VERSION_MINOR ||
++ *(unsigned *)&sector[STAGE2_INSTALLPART] != 0xFFFFFF) {
++ die(3, "Aborting: GRUB MBR signature not found.");
++ }
++
++ if (!quiet)
++ printf("Found GRUB %c%c%c%c MBR signature.\n",
++ sector[STAGE2_VER_STR_OFFS],
++ sector[STAGE2_VER_STR_OFFS+1],
++ sector[STAGE2_VER_STR_OFFS+2],
++ sector[STAGE2_VER_STR_OFFS+3]
++ );
++
++ entryno = *(unsigned *)&sector[STAGE2_SAVED_ENTRYNO];
++ if (readonly) {
++ if (!quiet)
++ printf("Next boot will use entry #");
++ printf("%d\n", entryno);
++ exit(0);
++ }
++
++ /* This needs some explanation: the 'savedefault fallback' config statement
++ * saves the next entry number before booting the current one. So assuming
++ * the configuration uses consecutive fallbacks, the current entry number
++ * equals the saved entry number minus 1. This mode allows one to dedicate
++ * several entries to a number of retries, so that if entry 2 fails because
++ * of power failure, a strictly equivalent entry 3 gives it a second chance
++ * to boot. If entry 3 succeeds and if it is a backup of entry 2, we must
++ * validate 2 and not 3. This is what is provided here when new_entryno is
++ * negative. It reflects the opposite of the number of consecutive equivalent
++ * entries in the configuration file. For instance, if each entry is doubled,
++ * then new_entryno should be -2.
++ */
++
++ if (new_entryno < 0)
++ new_entryno = (entryno - 1) - (entryno - 1) % (-new_entryno);
++
++ *(unsigned *)&sector[STAGE2_SAVED_ENTRYNO] = new_entryno;
++
++ if (lseek(fd, SECTOR_SIZE * 2, SEEK_SET) < 0)
++ error(4, "Cannot seek to the sector :");
++
++ if (write(fd, sector, SECTOR_SIZE) != SECTOR_SIZE)
++ error(4, "Write error :");
++
++ if (!quiet)
++ printf("Next boot entry changed to #%d\n", new_entryno);
++ close(fd);
++ exit(0);
++}
diff --git a/sys-boot/grub/files/formilux/0004_all_add-support-for-the-savemap-keyword.patch b/sys-boot/grub/files/formilux/0004_all_add-support-for-the-savemap-keyword.patch
new file mode 100644
index 00000000..f33787f9
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0004_all_add-support-for-the-savemap-keyword.patch
@@ -0,0 +1,117 @@
+diff --git a/stage2/builtins.c b/stage2/builtins.c
+index cb7e648..765deaa 100644
+--- a/stage2/builtins.c
++++ b/stage2/builtins.c
+@@ -61,6 +61,8 @@ int default_entry = 0;
+ /* The fallback entry. */
+ int fallback_entryno;
+ int fallback_entries[MAX_FALLBACK_ENTRIES];
++/* the save map. Ends with saved == -1 */
++struct savemap savemap[MAX_SAVEMAP];
+ /* The number of current entry. */
+ int current_entryno;
+ /* The address for Multiboot command-line buffer. */
+@@ -100,6 +102,7 @@ init_config (void)
+ password = 0;
+ fallback_entryno = -1;
+ fallback_entries[0] = -1;
++ savemap[0].saved = -1;
+ grub_timeout = -1;
+ }
+
+@@ -1364,6 +1367,59 @@ static struct builtin builtin_fallback =
+ };
+
+
++/* savemap */
++static int
++savemap_func (char *arg, int flags)
++{
++ int i = 0;
++ int saved, backup, real;
++
++ while (*arg)
++ {
++ if (! safe_parse_maxint (&arg, &saved))
++ return 1;
++ if (*arg++ != ':')
++ return 1;
++ if (! safe_parse_maxint (&arg, &real))
++ return 1;
++ if (*arg++ != ':')
++ return 1;
++ if (! safe_parse_maxint (&arg, &backup))
++ return 1;
++
++ savemap[i].saved = saved;
++ savemap[i].real = real;
++ savemap[i].backup = backup;
++
++ i++;
++
++ if (i == MAX_SAVEMAP)
++ break;
++
++ arg = skip_to (0, arg);
++ }
++
++ if (i < MAX_SAVEMAP)
++ savemap[i].saved = -1;
++
++ return 0;
++}
++
++static struct builtin builtin_savemap =
++{
++ "savemap",
++ savemap_func,
++ BUILTIN_MENU,
++#if 0
++ "savemap SAVED:REAL:NEXT...",
++ "Define a boot sequence trying several images. Boot attemps on"
++ " id SAVED will be mapped to id REAL, and will be retried upon"
++ " next boot on id NEXT in case of failure."
++ " To be used with savedefault savemap."
++#endif
++};
++
++
+ /* find */
+ /* Search for the filename ARG in all of partitions. */
+ static int
+@@ -5069,6 +5125,7 @@ struct builtin *builtin_table[] =
+ &builtin_root,
+ &builtin_rootnoverify,
+ &builtin_savedefault,
++ &builtin_savemap,
+ #ifdef SUPPORT_SERIAL
+ &builtin_serial,
+ #endif /* SUPPORT_SERIAL */
+diff --git a/stage2/shared.h b/stage2/shared.h
+index 7532980..b7b5fc6 100644
+--- a/stage2/shared.h
++++ b/stage2/shared.h
+@@ -595,6 +595,7 @@ extern void assign_device_name (int drive, const char *device);
+
+ #ifndef STAGE1_5
+ /* GUI interface variables. */
++# define MAX_SAVEMAP 16
+ # define MAX_FALLBACK_ENTRIES 8
+ extern int fallback_entries[MAX_FALLBACK_ENTRIES];
+ extern int fallback_entryno;
+@@ -845,6 +846,15 @@ struct builtin
+ /* All the builtins are registered in this. */
+ extern struct builtin *builtin_table[];
+
++struct savemap {
++ int saved;
++ int real;
++ int backup;
++};
++
++extern struct savemap savemap[MAX_SAVEMAP];
++extern int backup_entry;
++
+ /* The constants for kernel types. */
+ typedef enum
+ {
diff --git a/sys-boot/grub/files/formilux/0005_all_update-default_entry-according-to-the-savemap.patch b/sys-boot/grub/files/formilux/0005_all_update-default_entry-according-to-the-savemap.patch
new file mode 100644
index 00000000..9d08fa3a
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0005_all_update-default_entry-according-to-the-savemap.patch
@@ -0,0 +1,40 @@
+diff --git a/stage2/builtins.c b/stage2/builtins.c
+index 765deaa..a5e4d62 100644
+--- a/stage2/builtins.c
++++ b/stage2/builtins.c
+@@ -63,6 +63,8 @@ int fallback_entryno;
+ int fallback_entries[MAX_FALLBACK_ENTRIES];
+ /* the save map. Ends with saved == -1 */
+ struct savemap savemap[MAX_SAVEMAP];
++/* the entry which will be used by 'savedefault savemap' */
++int backup_entry;
+ /* The number of current entry. */
+ int current_entryno;
+ /* The address for Multiboot command-line buffer. */
+@@ -99,6 +101,7 @@ void
+ init_config (void)
+ {
+ default_entry = 0;
++ backup_entry = 0;
+ password = 0;
+ fallback_entryno = -1;
+ fallback_entries[0] = -1;
+@@ -806,7 +809,18 @@ default_func (char *arg, int flags)
+ #ifndef SUPPORT_DISKLESS
+ if (grub_strcmp (arg, "saved") == 0)
+ {
++ int i;
++
+ default_entry = saved_entryno;
++ for (i = 0; i < MAX_SAVEMAP && savemap[i].saved != -1; i++)
++ {
++ if (savemap[i].saved == default_entry)
++ {
++ default_entry = savemap[i].real;
++ backup_entry = savemap[i].backup;
++ break;
++ }
++ }
+ return 0;
+ }
+ #endif /* SUPPORT_DISKLESS */
diff --git a/sys-boot/grub/files/formilux/0006_all_add-support-for-savedefault-savemap.patch b/sys-boot/grub/files/formilux/0006_all_add-support-for-savedefault-savemap.patch
new file mode 100644
index 00000000..bb610bd5
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0006_all_add-support-for-savedefault-savemap.patch
@@ -0,0 +1,27 @@
+diff --git a/stage2/builtins.c b/stage2/builtins.c
+index a5e4d62..9b0cf5e 100644
+--- a/stage2/builtins.c
++++ b/stage2/builtins.c
+@@ -3549,6 +3549,8 @@ savedefault_func (char *arg, int flags)
+
+ entryno = fallback_entries[index];
+ }
++ else if (grub_memcmp (arg, "savemap", sizeof ("savemap") - 1) == 0)
++ entryno = backup_entry;
+ else if (! safe_parse_maxint (&arg, &entryno))
+ return 1;
+ }
+@@ -3637,10 +3639,11 @@ static struct builtin builtin_savedefault =
+ "savedefault",
+ savedefault_func,
+ BUILTIN_CMDLINE,
+- "savedefault [NUM | `fallback']",
++ "savedefault [NUM | `fallback' | 'savemap']",
+ "Save the current entry as the default boot entry if no argument is"
+ " specified. If a number is specified, this number is saved. If"
+- " `fallback' is used, next fallback entry is saved."
++ " `fallback' is used, next fallback entry is saved. If 'savemap'"
++ " is used, next boot will follow the save map."
+ };
+
+
diff --git a/sys-boot/grub/files/formilux/0007_all_update-the-savemap-upon-user-action-or-fallback.patch b/sys-boot/grub/files/formilux/0007_all_update-the-savemap-upon-user-action-or-fallback.patch
new file mode 100644
index 00000000..307b7b56
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0007_all_update-the-savemap-upon-user-action-or-fallback.patch
@@ -0,0 +1,77 @@
+diff --git a/stage2/stage2.c b/stage2/stage2.c
+index 2851d72..be0ae4a 100644
+--- a/stage2/stage2.c
++++ b/stage2/stage2.c
+@@ -482,8 +482,26 @@ restart:
+
+ if (config_entries)
+ {
++ /* If the user presses Enter, he explicitly wants to set the
++ * current boot image to this one, which includes resetting
++ * the next default boot. In this case, we look for the first
++ * entry in the savemap for which the mapped entry matches the
++ * selected one.
++ */
+ if ((c == '\n') || (c == '\r') || (c == 6))
+- break;
++ {
++ int i;
++ for (i = 0; i < MAX_SAVEMAP && savemap[i].saved != -1; i++)
++ {
++ if (savemap[i].real == first_entry + entryno)
++ {
++ default_entry = first_entry + entryno;
++ backup_entry = savemap[i].backup;
++ break;
++ }
++ }
++ break;
++ }
+ }
+ else
+ {
+@@ -742,7 +760,24 @@ restart:
+ /* Set CURRENT_ENTRYNO for the command "savedefault". */
+ if (config_entries)
+ current_entryno = first_entry + entryno;
+-
++
++ /* check if we are booting something different from the default image.
++ * This may be caused by user action, of fallback because of an image
++ * not found. In both cases, we must update the backup image.
++ */
++ if (current_entryno != default_entry)
++ {
++ int i;
++ for (i = 0; i < MAX_SAVEMAP && savemap[i].saved != -1; i++)
++ {
++ if (savemap[i].real == current_entryno)
++ {
++ default_entry = current_entryno;
++ backup_entry = savemap[i].backup;
++ break;
++ }
++ }
++ }
+ if (run_script (cur_entry, heap))
+ {
+ if (fallback_entryno >= 0)
+@@ -1064,6 +1099,18 @@ cmain (void)
+ }
+ else
+ default_entry = 0;
++
++ for (i = 0; i < MAX_SAVEMAP && savemap[i].saved != -1; i++)
++ {
++ if (savemap[i].real == default_entry)
++ {
++ default_entry = savemap[i].real;
++ backup_entry = savemap[i].backup;
++ break;
++ }
++ }
++ if (backup_entry >= num_entries)
++ backup_entry = default_entry;
+ }
+
+ if (is_preset)
diff --git a/sys-boot/grub/files/formilux/0008_all_documentation-savemap.patch b/sys-boot/grub/files/formilux/0008_all_documentation-savemap.patch
new file mode 100644
index 00000000..f421efd5
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0008_all_documentation-savemap.patch
@@ -0,0 +1,292 @@
+diff --git a/docs/boot-states.fig b/docs/boot-states.fig
+new file mode 100644
+index 0000000..6e85e5b
+--- /dev/null
++++ b/docs/boot-states.fig
+@@ -0,0 +1,286 @@
++#FIG 3.2 Produced by xfig version 3.2.5-alpha5
++Portrait
++Center
++Metric
++A4
++100.00
++Single
++-2
++1200 2
++0 32 #d7d7d7
++6 2250 1125 3150 1350
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2700 1237 450 112 2250 1125 3150 1350
++4 1 0 45 -1 18 8 0.0000 4 120 420 2700 1305 0: img1\001
++-6
++6 2250 1575 3150 1800
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2700 1687 450 112 2250 1575 3150 1800
++4 1 0 45 -1 18 8 0.0000 4 120 420 2700 1755 1: img1\001
++-6
++6 4050 1125 4950 1350
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 4500 1237 450 112 4050 1125 4950 1350
++4 1 0 45 -1 18 8 0.0000 4 120 420 4500 1305 2: img2\001
++-6
++6 4050 1575 4950 1800
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 4500 1687 450 112 4050 1575 4950 1800
++4 1 0 45 -1 18 8 0.0000 4 120 420 4500 1755 3: img2\001
++-6
++6 4050 2025 4950 2250
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 4500 2137 450 112 4050 2025 4950 2250
++4 1 0 45 -1 18 8 0.0000 4 120 420 4500 2205 4: img1\001
++-6
++6 4050 3150 4950 3375
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 4500 3262 450 112 4050 3150 4950 3375
++4 1 0 45 -1 18 8 0.0000 4 120 570 4500 3330 244: img2\001
++-6
++6 4050 3600 4950 3825
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 4500 3712 450 112 4050 3600 4950 3825
++4 1 0 45 -1 18 8 0.0000 4 120 570 4500 3780 245: img2\001
++-6
++6 4050 4050 4950 4275
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 4500 4162 450 112 4050 4050 4950 4275
++4 1 0 45 -1 18 8 0.0000 4 120 570 4500 4230 246: img1\001
++-6
++6 4050 4500 4950 4725
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 4500 4612 450 112 4050 4500 4950 4725
++4 1 0 45 -1 18 8 0.0000 4 120 570 4500 4680 247: img1\001
++-6
++6 2250 4500 3150 4725
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2700 4612 450 112 2250 4500 3150 4725
++4 1 0 45 -1 18 8 0.0000 4 120 570 2700 4680 243: img2\001
++-6
++6 2250 4050 3150 4275
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2700 4162 450 112 2250 4050 3150 4275
++4 1 0 45 -1 18 8 0.0000 4 120 570 2700 4230 242: img2\001
++-6
++6 2250 3600 3150 3825
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2700 3712 450 112 2250 3600 3150 3825
++4 1 0 45 -1 18 8 0.0000 4 120 570 2700 3780 241: img1\001
++-6
++6 2250 3150 3150 3375
++1 2 0 1 0 7 50 -1 20 0.000 1 0.0000 2700 3262 450 112 2250 3150 3150 3375
++4 1 0 45 -1 18 8 0.0000 4 120 570 2700 3330 240: img1\001
++-6
++2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
++ 450 5175 900 5175 900 5265 450 5265 450 5175
++2 1 0 1 26 7 49 -1 -1 0.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 450 5220 900 5220
++2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
++ 450 5355 900 5355 900 5445 450 5445 450 5355
++2 1 0 1 14 7 49 -1 -1 0.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 450 5400 900 5400
++2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
++ 450 5535 900 5535 900 5625 450 5625 450 5535
++2 1 0 1 5 7 49 -1 -1 0.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 450 5580 900 5580
++2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
++ 450 5715 900 5715 900 5805 450 5805 450 5715
++2 1 0 1 0 7 49 -1 -1 0.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 450 5760 900 5760
++2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
++ 2250 5175 2700 5175 2700 5265 2250 5265 2250 5175
++2 1 0 1 31 7 49 -1 -1 0.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 2250 5220 2700 5220
++2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
++ 2250 5355 2700 5355 2700 5445 2250 5445 2250 5355
++2 1 0 1 1 7 49 -1 -1 0.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 2250 5400 2700 5400
++2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
++ 2250 5535 2700 5535 2700 5625 2250 5625 2250 5535
++2 1 0 1 4 7 49 -1 -1 0.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 2250 5580 2700 5580
++2 1 0 1 11 7 50 -1 -1 4.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 5580 2430 5580 2205
++2 1 3 1 11 7 50 -1 -1 4.000 0 0 -1 0 0 2
++ 855 2475 6525 2475
++2 1 0 1 11 7 50 -1 -1 4.000 0 0 -1 1 0 2
++ 1 1 1.00 60.00 120.00
++ 5580 2520 5580 2745
++2 2 0 1 0 32 50 -1 20 0.000 0 0 -1 0 0 5
++ 4050 5175 7020 5175 7020 5670 4050 5670 4050 5175
++3 0 0 1 5 7 46 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 4410 1125 4365 945 4140 900 3330 900 3015 1125
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 5 7 46 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 3150 1215 3420 1170 3375 990 3105 1170
++ 0.000 1.000 1.000 0.000
++3 0 0 1 5 7 46 -1 -1 0.000 0 1 0 3
++ 1 1 1.00 60.00 120.00
++ 3150 1665 3285 1485 3105 1305
++ 0.000 1.000 0.000
++3 0 0 1 5 7 46 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4905 2115 5355 1575 5175 1350 4905 1305
++ 0.000 1.000 1.000 0.000
++3 0 0 1 5 7 46 -1 -1 0.000 0 1 0 3
++ 1 1 1.00 60.00 120.00
++ 4905 1620 5085 1485 4815 1305
++ 0.000 1.000 0.000
++3 0 0 1 14 7 47 -1 -1 0.000 0 1 0 2
++ 1 1 1.00 60.00 120.00
++ 2700 1350 2700 1575
++ 0.000 0.000
++3 0 0 1 14 7 47 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 2745 1800 2925 1935 3510 1890 3735 1215 4050 1215
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 14 7 47 -1 -1 0.000 0 1 0 2
++ 1 1 1.00 60.00 120.00
++ 4500 1350 4500 1575
++ 0.000 0.000
++3 0 0 1 14 7 47 -1 -1 0.000 0 1 0 2
++ 1 1 1.00 60.00 120.00
++ 4500 1800 4500 2025
++ 0.000 0.000
++3 0 0 1 0 7 45 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 1440 1710 1575 1710 1755 1620 1980 1665 2250 1665
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 0 7 45 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 1440 1260 1575 1260 1755 1170 1980 1215 2250 1215
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 0 7 45 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 5850 1215 5625 1215 5445 1170 5265 1215 4950 1215
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 0 7 45 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 5850 1699 5625 1699 5445 1654 5265 1699 4950 1699
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 26 7 45 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 1665 810 2565 810 2745 990 2745 1125
++ 0.000 1.000 1.000 0.000
++3 0 0 1 26 7 45 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 1665 585 3600 585 4545 810 4545 1125
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 43 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 2475 1800 2250 2025 2025 3150 2025 3600 2295 4095
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 1 7 43 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4275 1350 3825 1575 3600 3105 4095 3690
++ 0.000 1.000 1.000 0.000
++3 0 0 1 4 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 3161 3237 3431 3192 3386 3012 3116 3192
++ 0.000 1.000 1.000 0.000
++3 0 0 1 4 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 3105 4140 3555 3600 3375 3375 3105 3330
++ 0.000 1.000 1.000 0.000
++3 0 0 1 4 7 44 -1 -1 0.000 0 1 0 3
++ 1 1 1.00 60.00 120.00
++ 3105 3645 3285 3510 3015 3330
++ 0.000 1.000 0.000
++3 0 0 1 4 7 44 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 3150 4590 3285 4590 3555 3735 3825 3240 4050 3240
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 4 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4950 3237 5220 3192 5175 3012 4905 3192
++ 0.000 1.000 1.000 0.000
++3 0 0 1 4 7 44 -1 -1 0.000 0 1 0 3
++ 1 1 1.00 60.00 120.00
++ 4905 3645 5085 3510 4815 3330
++ 0.000 1.000 0.000
++3 0 0 1 4 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4905 4095 5220 3600 5175 3375 4905 3330
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4140 4230 4095 4275 4095 4455 4140 4545
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4140 3780 4095 3825 4095 4005 4140 4095
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4140 3330 4095 3375 4095 3555 4140 3645
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 5
++ 1 1 1.00 60.00 120.00
++ 2700 4725 2925 4950 3510 4545 3780 4095 4050 4140
++ 0.000 1.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 6
++ 1 1 1.00 60.00 120.00
++ 4320 4725 4095 4950 2250 4950 2025 4725 2025 4275 2250 4185
++ 0.000 1.000 1.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 2385 4230 2340 4275 2340 4455 2385 4545
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 2385 3780 2340 3825 2340 4005 2385 4095
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 44 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 2430 3330 2340 3375 2340 3555 2385 3645
++ 0.000 1.000 1.000 0.000
++3 0 0 1 31 7 45 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 1665 2835 2565 2835 2745 3015 2745 3150
++ 0.000 1.000 1.000 0.000
++3 0 0 1 31 7 45 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 1665 2610 3600 2610 4275 2835 4500 3150
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 43 -1 -1 0.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4690 1800 5355 2295 5355 3825 4950 4185
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 50 -1 -1 4.000 0 1 0 4
++ 1 1 1.00 60.00 120.00
++ 4365 2250 4230 2745 3510 3600 3150 3735
++ 0.000 1.000 1.000 0.000
++3 0 0 1 1 7 50 -1 -1 4.000 0 1 0 7
++ 1 1 1.00 60.00 120.00
++ 3150 1260 3330 1350 3465 1575 3555 2295 3600 2970 3510 3420
++ 3150 3690
++ 0.000 1.000 1.000 1.000 1.000 1.000 0.000
++3 0 0 1 4 7 50 -1 -1 4.000 0 1 0 9
++ 1 1 1.00 60.00 120.00
++ 4455 4725 4365 4860 4005 4995 2970 5040 2070 4950 1935 4725
++ 1755 4050 1800 3465 2250 3285
++ 0.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
++ 0.000
++4 2 0 45 -1 18 6 0.0000 4 105 1050 1350 1755 update-boot-image:1\001
++4 2 0 45 -1 18 6 0.0000 4 105 1020 1350 1260 switch-boot-image:1\001
++4 0 0 45 -1 18 6 0.0000 4 105 1020 5895 1260 switch-boot-image:2\001
++4 0 0 45 -1 18 6 0.0000 4 105 1050 5895 1755 update-boot-image:2\001
++4 2 0 45 -1 18 6 0.0000 4 120 1500 1575 855 Select img1 from Menu (v0.7)\001
++4 2 0 45 -1 18 6 0.0000 4 120 1500 1575 630 Select img2 from Menu (v0.7)\001
++4 2 0 45 -1 18 6 0.0000 4 120 1500 1575 2655 Select img2 from Menu (v1.0)\001
++4 2 0 45 -1 18 6 0.0000 4 120 1500 1575 2880 Select img1 from Menu (v1.0)\001
++4 0 0 45 -1 18 6 0.0000 4 120 900 990 5265 menu entry (v0.7)\001
++4 0 0 45 -1 18 6 0.0000 4 120 930 990 5445 savedefault (v0.7)\001
++4 0 0 45 -1 18 6 0.0000 4 120 1005 990 5625 validate-boot (v0.7)\001
++4 0 0 45 -1 18 6 0.0000 4 105 1035 990 5805 unchanged programs\001
++4 0 0 45 -1 18 6 0.0000 4 120 900 2790 5265 menu entry (v1.0)\001
++4 0 0 45 -1 18 6 0.0000 4 120 930 2790 5445 savedefault (v1.0)\001
++4 0 0 45 -1 18 6 0.0000 4 120 1005 2790 5625 validate-boot (v1.0)\001
++4 0 0 45 -1 18 6 0.0000 4 90 840 5670 2385 version 0.7 & 1.0\001
++4 0 0 45 -1 18 6 0.0000 4 105 795 5670 2610 version 1.0 only\001
++4 0 5 45 -1 18 6 0.0000 4 90 675 5220 2025 validate-boot\001
++4 1 14 45 -1 18 6 0.0000 4 90 600 3015 2070 savedefault\001
++4 2 1 45 -1 18 6 0.0000 4 90 600 3960 4770 savedefault\001
++4 0 4 45 -1 18 6 0.0000 4 90 675 4365 4995 validate-boot\001
++4 2 0 45 -1 12 6 0.0000 4 75 2820 6930 5310 savemap 240:0:241 244:1:245 241:0:242 242:1:243\001
++4 2 0 45 -1 12 6 0.0000 4 60 2340 6930 5445 243:1:246 245:1:246 246:0:247 247:0:242\001
++4 2 0 45 -1 12 6 0.0000 4 60 2340 6930 5580 0:0:241 1:0:242 2:1:245 3:1:246 4:0:241\001
diff --git a/sys-boot/grub/files/formilux/0009_all_sample-config-files-using-savemap.patch b/sys-boot/grub/files/formilux/0009_all_sample-config-files-using-savemap.patch
new file mode 100644
index 00000000..fbe44726
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0009_all_sample-config-files-using-savemap.patch
@@ -0,0 +1,102 @@
+diff --git a/docs/menu-hda.lst b/docs/menu-hda.lst
+new file mode 100644
+index 0000000..b34ce07
+--- /dev/null
++++ b/docs/menu-hda.lst
+@@ -0,0 +1,45 @@
++#
++# boot last working image by default, and allow one failure
++#
++
++hiddenmenu
++
++serial --unit=0 --speed=9600
++terminal --timeout=3 console serial
++
++# Here comes the mapping between saved entries and usable entries. All
++# unexpected entries should be mapped to any image in order not to loop.
++# Old entries 0..3 are remapped too.
++savemap 240:0:241 244:1:245 241:0:242 242:1:243 243:1:246 245:1:246 246:0:247 247:0:242 0:0:241 1:0:242 2:1:245 3:1:246 4:0:241
++
++default saved
++timeout 3
++fallback 0 1 2
++
++# image 0
++title Image 1
++ root (hd0,1)
++ savedefault savemap
++ kernel /sys/active/kernel.img root=/dev/ram0 ro auto quiet console=ttyS0,9600 panic=1 hdb=noprobe ide1=noprobe flash=hda2 img=0
++ initrd /sys/active/initrd.img
++
++# image 1
++title Image 2
++ root (hd0,1)
++ savedefault savemap
++ kernel /sys/backup/kernel.img root=/dev/ram0 ro auto quiet console=ttyS0,9600 panic=1 hdb=noprobe ide1=noprobe flash=hda2 img=1
++ initrd /sys/backup/initrd.img
++
++# image 2
++title Maintenance Kernel
++ root (hd0,0)
++ kernel /boot/firmware/firmware.img quiet console=ttyS0,9600 panic=1 hdb=noprobe ide1=noprobe flash=hda2 img=2
++
++# image 3
++title Reboot
++ reboot
++
++# image 4
++title Halt
++ halt
++
+diff --git a/docs/menu-hdc.lst b/docs/menu-hdc.lst
+new file mode 100644
+index 0000000..2da4e7f
+--- /dev/null
++++ b/docs/menu-hdc.lst
+@@ -0,0 +1,45 @@
++#
++# boot last working image by default, and allow one failure
++#
++
++hiddenmenu
++
++serial --unit=0 --speed=9600
++terminal --timeout=3 console serial
++
++# Here comes the mapping between saved entries and usable entries. All
++# unexpected entries should be mapped to any image in order not to loop.
++# Old entries 0..3 are remapped too.
++savemap 240:0:241 244:1:245 241:0:242 242:1:243 243:1:246 245:1:246 246:0:247 247:0:242 0:0:241 1:0:242 2:1:245 3:1:246 4:0:241
++
++default saved
++timeout 3
++fallback 0 1 2
++
++# image 0
++title Image 1
++ root (hd0,1)
++ savedefault savemap
++ kernel /sys/active/kernel.img root=/dev/ram0 ro auto quiet console=ttyS0,9600 panic=1 ide0=noprobe hdd=noprobe flash=hdc2 img=0
++ initrd /sys/active/initrd.img
++
++# image 1
++title Image 2
++ root (hd0,1)
++ savedefault savemap
++ kernel /sys/backup/kernel.img root=/dev/ram0 ro auto quiet console=ttyS0,9600 panic=1 ide0=noprobe hdd=noprobe flash=hdc2 img=1
++ initrd /sys/backup/initrd.img
++
++# image 2
++title Maintenance Kernel
++ root (hd0,0)
++ kernel /boot/firmware/firmware.img quiet console=ttyS0,9600 panic=1 ide0=noprobe hdd=noprobe flash=hdc2 img=2
++
++# image 3
++title Reboot
++ reboot
++
++# image 4
++title Halt
++ halt
++
diff --git a/sys-boot/grub/files/formilux/0010_all_print-a-dot-for-each-disk-I-O-in-debug-mode.patch b/sys-boot/grub/files/formilux/0010_all_print-a-dot-for-each-disk-I-O-in-debug-mode.patch
new file mode 100644
index 00000000..3e728f1e
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0010_all_print-a-dot-for-each-disk-I-O-in-debug-mode.patch
@@ -0,0 +1,47 @@
+diff --git a/stage2/disk_io.c b/stage2/disk_io.c
+index 7e0f689..e60b5a5 100644
+--- a/stage2/disk_io.c
++++ b/stage2/disk_io.c
+@@ -142,6 +142,7 @@ rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *bu
+ {
+ int slen, sectors_per_vtrack;
+ int sector_size_bits = log2 (buf_geom.sector_size);
++ int calls = 0;
+
+ if (byte_len <= 0)
+ return 1;
+@@ -206,6 +207,7 @@ rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *bu
+ bufaddr = (char *) BUFFERADDR + byte_offset;
+ }
+
++ calls++;
+ bios_err = biosdisk (BIOSDISK_READ, drive, &buf_geom,
+ read_start, read_len, BUFFERSEG);
+ if (bios_err)
+@@ -225,6 +227,7 @@ rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *bu
+ sector, slen, BUFFERSEG))
+ errnum = ERR_READ;
+
++ calls++;
+ bufaddr = (char *) BUFFERADDR + byte_offset;
+ }
+ }
+@@ -250,6 +253,7 @@ rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *bu
+ if (biosdisk (BIOSDISK_READ, drive, &buf_geom,
+ 1, 1, BUFFERSEG))
+ errnum = ERR_READ;
++ calls++;
+ }
+ }
+ }
+@@ -287,6 +291,10 @@ rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *bu
+ byte_offset = 0;
+ }
+
++#ifndef STAGE1_5
++ if (debug && calls)
++ grub_printf(".");
++#endif
+ return (!errnum);
+ }
+
diff --git a/sys-boot/grub/files/formilux/0011_all_add-a-debug-message-booting-image-now-just-before.patch b/sys-boot/grub/files/formilux/0011_all_add-a-debug-message-booting-image-now-just-before.patch
new file mode 100644
index 00000000..3f8ef860
--- /dev/null
+++ b/sys-boot/grub/files/formilux/0011_all_add-a-debug-message-booting-image-now-just-before.patch
@@ -0,0 +1,12 @@
+diff --git a/stage2/builtins.c b/stage2/builtins.c
+index 9b0cf5e..419f854 100644
+--- a/stage2/builtins.c
++++ b/stage2/builtins.c
+@@ -278,6 +278,7 @@ static struct builtin builtin_blocklist =
+ static int
+ boot_func (char *arg, int flags)
+ {
++ grub_printf ("booting image now.\n");
+ /* Clear the int15 handler if we can boot the kernel successfully.
+ This assumes that the boot code never fails only if KERNEL_TYPE is
+ not KERNEL_TYPE_NONE. Is this assumption is bad? */
diff --git a/sys-boot/grub/files/grub.default b/sys-boot/grub/files/grub.default
new file mode 100644
index 00000000..580d2758
--- /dev/null
+++ b/sys-boot/grub/files/grub.default
@@ -0,0 +1,36 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/files/grub.default,v 1.2 2011/08/30 06:45:04 scarabeus Exp $
+#
+# To populate all changes in this file you need to regenerate your
+# grub configuration file afterwards:
+# 'grub2-mkconfig -o /boot/grub2/grub.cfg'
+#
+# See the grub info page for documentation on possible variables and
+# their associated values.
+
+GRUB_DEFAULT=0
+GRUB_HIDDEN_TIMEOUT=0
+GRUB_HIDDEN_TIMEOUT_QUIET=true
+GRUB_TIMEOUT=10
+
+GRUB_CMDLINE_LINUX_DEFAULT=""
+GRUB_CMDLINE_LINUX=""
+
+# Uncomment to disable graphical terminal (grub-pc only)
+#GRUB_TERMINAL=console
+
+# The resolution used on graphical terminal.
+# Note that you can use only modes which your graphic card supports via VBE.
+# You can see them in real GRUB with the command `vbeinfo'.
+#GRUB_GFXMODE=640x480
+
+# Background image used on graphical terminal.
+# Can be in various bitmap formats.
+#GRUB_BACKGROUND="/boot/grub2/mybackground.png"
+
+# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel
+#GRUB_DISABLE_LINUX_UUID=true
+
+# Uncomment to disable generation of recovery mode menu entries
+#GRUB_DISABLE_RECOVERY=true
diff --git a/sys-boot/grub/grub-0.97-r10.ebuild b/sys-boot/grub/grub-0.97-r10.ebuild
new file mode 100644
index 00000000..474197f5
--- /dev/null
+++ b/sys-boot/grub/grub-0.97-r10.ebuild
@@ -0,0 +1,294 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/grub-0.97-r10.ebuild,v 1.12 2012/01/06 04:57:12 vapier Exp $
+
+# XXX: we need to review menu.lst vs grub.conf handling. We've been converting
+# all systems to grub.conf (and symlinking menu.lst to grub.conf), but
+# we never updated any of the source code (it still all wants menu.lst),
+# and there is no indication that upstream is making the transition.
+
+# If you need to roll a new grub-static distfile, here is how.
+# - Robin H. Johnson <robbat2@gentoo.org> - 29 Nov 2010
+# USE='static -ncurses -netboot -custom-cflags' \
+# GRUB_STATIC_PACKAGE_BUILDING=1 ebuild \
+# grub-${PVR}.ebuild package && \
+# cp -f ${PKGDIR}/${CAT}/${PF}.tbz2 ${DISTDIR}/grub-static-${PVR}.tar.bz2
+
+inherit mount-boot eutils flag-o-matic toolchain-funcs autotools linux-info pax-utils
+
+PATCHVER="1.12" # Should match the revision ideally
+DESCRIPTION="GNU GRUB Legacy boot loader"
+HOMEPAGE="http://www.gnu.org/software/grub/"
+SRC_URI="mirror://gentoo/${P}.tar.gz
+ ftp://alpha.gnu.org/gnu/${PN}/${P}.tar.gz
+ mirror://gentoo/splash.xpm.gz
+ mirror://gentoo/${P}-patches-${PATCHVER}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 x86 ~x86-fbsd"
+IUSE="custom-cflags ncurses netboot static"
+
+RDEPEND="ncurses? (
+ >=sys-libs/ncurses-5.2-r5
+ amd64? ( app-emulation/emul-linux-x86-baselibs )
+ )"
+DEPEND="${RDEPEND}"
+
+pkg_setup() {
+ local arch="$(tc-arch)"
+ case ${arch} in
+ amd64) CONFIG_CHECK='~IA32_EMULATION' check_extra_config ;;
+ esac
+}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ # patch breaks booting for some people #111885
+ rm "${WORKDIR}"/patch/400_*reiser4*
+
+ # Grub will not handle a kernel larger than EXTENDED_MEMSIZE Mb as
+ # discovered in bug 160801. We can change this, however, using larger values
+ # for this variable means that Grub needs more memory to run and boot. For a
+ # kernel of size N, Grub needs (N+1)*2. Advanced users should set a custom
+ # value in make.conf, it is possible to make kernels ~16Mb in size, but it
+ # needs the kitchen sink built-in.
+ local t="custom"
+ if [[ -z ${GRUB_MAX_KERNEL_SIZE} ]] ; then
+ case $(tc-arch) in
+ amd64) GRUB_MAX_KERNEL_SIZE=9 ;;
+ x86) GRUB_MAX_KERNEL_SIZE=5 ;;
+ esac
+ t="default"
+ fi
+ einfo "Grub will support the ${t} maximum kernel size of ${GRUB_MAX_KERNEL_SIZE} Mb (GRUB_MAX_KERNEL_SIZE)"
+
+ sed -i \
+ -e "/^#define.*EXTENDED_MEMSIZE/s,3,${GRUB_MAX_KERNEL_SIZE},g" \
+ "${S}"/grub/asmstub.c \
+ || die "Failed to hack memory size"
+
+ if [[ -n ${PATCHVER} ]] ; then
+ EPATCH_SUFFIX="patch"
+ epatch "${WORKDIR}"/patch
+ fi
+
+ epatch "${FILESDIR}"/formilux
+
+ eautoreconf
+}
+
+src_compile() {
+ filter-flags -fPIE #168834
+
+ use amd64 && multilib_toolchain_setup x86
+
+ unset BLOCK_SIZE #73499
+
+ ### i686-specific code in the boot loader is a bad idea; disabling to ensure
+ ### at least some compatibility if the hard drive is moved to an older or
+ ### incompatible system.
+
+ # grub-0.95 added -fno-stack-protector detection, to disable ssp for stage2,
+ # but the objcopy's (faulty) test fails if -fstack-protector is default.
+ # create a cache telling configure that objcopy is ok, and add -C to econf
+ # to make use of the cache.
+ #
+ # CFLAGS has to be undefined running econf, else -fno-stack-protector detection fails.
+ # STAGE2_CFLAGS is not allowed to be used on emake command-line, it overwrites
+ # -fno-stack-protector detected by configure, removed from netboot's emake.
+ use custom-cflags || unset CFLAGS
+
+ export grub_cv_prog_objcopy_absolute=yes #79734
+ use static && append-ldflags -static
+
+ # Per bug 216625, the emul packages do not provide .a libs for performing
+ # suitable static linking
+ if use amd64 && use static ; then
+ if [ -z "${GRUB_STATIC_PACKAGE_BUILDING}" ]; then
+ die "You must use the grub-static package if you want a static Grub on amd64!"
+ else
+ eerror "You have set GRUB_STATIC_PACKAGE_BUILDING. This"
+ eerror "is specifically intended for building the tarballs for the"
+ eerror "grub-static package via USE='static -ncurses'."
+ eerror "All bets are now off."
+ ebeep 10
+ fi
+ fi
+
+ # build the net-bootable grub first, but only if "netboot" is set
+ if use netboot ; then
+ econf \
+ --libdir=/lib \
+ --datadir=/usr/lib/grub \
+ --exec-prefix=/ \
+ --disable-auto-linux-mem-opt \
+ --enable-diskless \
+ --enable-{3c{5{03,07,09,29,95},90x},cs89x0,davicom,depca,eepro{,100}} \
+ --enable-{epic100,exos205,ni5210,lance,ne2100,ni{50,65}10,natsemi} \
+ --enable-{ne,ns8390,wd,otulip,rtl8139,sis900,sk-g16,smc9000,tiara} \
+ --enable-{tulip,via-rhine,w89c840} || die "netboot econf failed"
+
+ emake w89c840_o_CFLAGS="-O" || die "making netboot stuff"
+
+ mv -f stage2/{nbgrub,pxegrub} "${S}"/
+ mv -f stage2/stage2 stage2/stage2.netboot
+
+ make clean || die "make clean failed"
+ fi
+
+ # Now build the regular grub
+ # Note that FFS and UFS2 support are broken for now - stage1_5 files too big
+ econf \
+ --libdir=/lib \
+ --datadir=/usr/lib/grub \
+ --exec-prefix=/ \
+ --disable-auto-linux-mem-opt \
+ $(use_with ncurses curses) \
+ || die "econf failed"
+
+ # sanity check due to common failure
+ use ncurses && ! grep -qs "HAVE_LIBCURSES.*1" config.h && die "USE=ncurses but curses not found"
+
+ emake || die "making regular stuff"
+}
+
+src_test() {
+ # non-default block size also give false pass/fails.
+ unset BLOCK_SIZE
+ make check || die "make check failed"
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die
+ if use netboot ; then
+ exeinto /usr/lib/grub/${CHOST}
+ doexe nbgrub pxegrub stage2/stage2.netboot || die "netboot install"
+ fi
+
+ # bug 330745
+ pax-mark -m "${D}"/sbin/grub
+
+ dodoc AUTHORS BUGS ChangeLog NEWS README THANKS TODO
+ newdoc docs/menu.lst grub.conf.sample
+ dodoc "${FILESDIR}"/grub.conf.gentoo
+ prepalldocs
+
+ [ -n "${GRUB_STATIC_PACKAGE_BUILDING}" ] && \
+ mv \
+ "${D}"/usr/share/doc/${PF} \
+ "${D}"/usr/share/doc/grub-static-${PF/grub-}
+
+ insinto /usr/share/grub
+ doins "${DISTDIR}"/splash.xpm.gz
+}
+
+setup_boot_dir() {
+ local boot_dir=$1
+ local dir=${boot_dir}
+
+ mkdir -p "${dir}"
+ [[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot"
+ dir="${dir}/grub"
+ if [[ ! -e ${dir} ]] ; then
+ mkdir "${dir}" || die "${dir} does not exist!"
+ fi
+
+ # change menu.lst to grub.conf
+ if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then
+ mv -f "${dir}"/menu.lst "${dir}"/grub.conf
+ ewarn
+ ewarn "*** IMPORTANT NOTE: menu.lst has been renamed to grub.conf"
+ ewarn
+ fi
+
+ if [[ ! -e ${dir}/menu.lst ]]; then
+ einfo "Linking from new grub.conf name to menu.lst"
+ ln -snf grub.conf "${dir}"/menu.lst
+ fi
+
+ if [[ -e ${dir}/stage2 ]] ; then
+ mv "${dir}"/stage2{,.old}
+ ewarn "*** IMPORTANT NOTE: you must run grub and install"
+ ewarn "the new version's stage1 to your MBR. Until you do,"
+ ewarn "stage1 and stage2 will still be the old version, but"
+ ewarn "later stages will be the new version, which could"
+ ewarn "cause problems such as an unbootable system."
+ ewarn "This means you must use either grub-install or perform"
+ ewarn "root/setup manually! For more help, see the handbook:"
+ ewarn "http://www.gentoo.org/doc/en/handbook/handbook-${ARCH}.xml?part=1&chap=10#grub-install-auto"
+ ebeep
+ fi
+
+ einfo "Copying files from /lib/grub, /usr/lib/grub and /usr/share/grub to ${dir}"
+ for x in \
+ "${ROOT}"/lib*/grub/*/* \
+ "${ROOT}"/usr/lib*/grub/*/* \
+ "${ROOT}"/usr/share/grub/* ; do
+ [[ -f ${x} ]] && cp -p "${x}" "${dir}"/
+ done
+
+ if [[ ! -e ${dir}/grub.conf ]] ; then
+ s="${ROOT}/usr/share/doc/${PF}/grub.conf.gentoo"
+ [[ -e "${s}" ]] && cat "${s}" >${dir}/grub.conf
+ [[ -e "${s}.gz" ]] && zcat "${s}.gz" >${dir}/grub.conf
+ [[ -e "${s}.bz2" ]] && bzcat "${s}.bz2" >${dir}/grub.conf
+ fi
+
+ # Per bug 218599, we support grub.conf.install for users that want to run a
+ # specific set of Grub setup commands rather than the default ones.
+ grub_config=${dir}/grub.conf.install
+ [[ -e ${grub_config} ]] || grub_config=${dir}/grub.conf
+ if [[ -e ${grub_config} ]] ; then
+ egrep \
+ -v '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)' \
+ "${grub_config}" | \
+ /sbin/grub --batch \
+ --device-map="${dir}"/device.map \
+ > /dev/null
+ fi
+
+ # the grub default commands silently piss themselves if
+ # the default file does not exist ahead of time
+ if [[ ! -e ${dir}/default ]] ; then
+ grub-set-default --root-directory="${boot_dir}" default
+ fi
+ einfo "Grub has been installed to ${boot_dir} successfully."
+}
+
+pkg_postinst() {
+ mount-boot_mount_boot_partition
+
+ if [[ -n ${DONT_MOUNT_BOOT} ]]; then
+ elog "WARNING: you have DONT_MOUNT_BOOT in effect, so you must apply"
+ elog "the following instructions for your /boot!"
+ elog "Neglecting to do so may cause your system to fail to boot!"
+ elog
+ else
+ setup_boot_dir "${ROOT}"/boot
+ # Trailing output because if this is run from pkg_postinst, it gets mixed into
+ # the other output.
+ einfo ""
+ fi
+ elog "To interactively install grub files to another device such as a USB"
+ elog "stick, just run the following and specify the directory as prompted:"
+ elog " emerge --config =${PF}"
+ elog "Alternately, you can export GRUB_ALT_INSTALLDIR=/path/to/use to tell"
+ elog "grub where to install in a non-interactive way."
+
+ # needs to be after we call setup_boot_dir
+ mount-boot_pkg_postinst
+}
+
+pkg_config() {
+ local dir
+ if [ ! -d "${GRUB_ALT_INSTALLDIR}" ]; then
+ einfo "Enter the directory where you want to setup grub:"
+ read dir
+ else
+ dir="${GRUB_ALT_INSTALLDIR}"
+ fi
+ setup_boot_dir "${dir}"
+}
diff --git a/sys-boot/grub/grub-0.97-r12.ebuild b/sys-boot/grub/grub-0.97-r12.ebuild
new file mode 100644
index 00000000..a37c4701
--- /dev/null
+++ b/sys-boot/grub/grub-0.97-r12.ebuild
@@ -0,0 +1,289 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/grub-0.97-r12.ebuild,v 1.5 2012/08/07 21:00:21 hwoarang Exp $
+
+# XXX: we need to review menu.lst vs grub.conf handling. We've been converting
+# all systems to grub.conf (and symlinking menu.lst to grub.conf), but
+# we never updated any of the source code (it still all wants menu.lst),
+# and there is no indication that upstream is making the transition.
+
+# If you need to roll a new grub-static distfile, here is how.
+# - Robin H. Johnson <robbat2@gentoo.org> - 29 Nov 2010
+# FEATURES='-noauto -noinfo -nodoc -noman -splitdebug nostrip' \
+# USE='static -ncurses -netboot -custom-cflags' \
+# PORTAGE_COMPRESS=true GRUB_STATIC_PACKAGE_BUILDING=1 ebuild \
+# grub-${PVR}.ebuild clean package && \
+# qtbz2 -s -j ${PKGDIR}/${CAT}/${PF}.tbz2 && \
+# mv ${PF}.tar.bz2 ${DISTDIR}/grub-static-${PVR}.tar.bz2
+
+inherit mount-boot eutils flag-o-matic toolchain-funcs autotools linux-info pax-utils
+
+PATCHVER="1.14" # Should match the revision ideally
+DESCRIPTION="GNU GRUB Legacy boot loader"
+HOMEPAGE="http://www.gnu.org/software/grub/"
+SRC_URI="mirror://gentoo/${P}.tar.gz
+ mirror://gnu-alpha/${PN}/${P}.tar.gz
+ mirror://gentoo/splash.xpm.gz
+ mirror://gentoo/${P}-patches-${PATCHVER}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 x86 ~x86-fbsd"
+IUSE="custom-cflags ncurses netboot static"
+
+RDEPEND="ncurses? (
+ >=sys-libs/ncurses-5.2-r5
+ amd64? ( app-emulation/emul-linux-x86-baselibs )
+ )"
+DEPEND="${RDEPEND}"
+
+pkg_setup() {
+ case $(tc-arch) in
+ amd64) CONFIG_CHECK='~IA32_EMULATION' check_extra_config ;;
+ esac
+}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ # Grub will not handle a kernel larger than EXTENDED_MEMSIZE Mb as
+ # discovered in bug 160801. We can change this, however, using larger values
+ # for this variable means that Grub needs more memory to run and boot. For a
+ # kernel of size N, Grub needs (N+1)*2. Advanced users should set a custom
+ # value in make.conf, it is possible to make kernels ~16Mb in size, but it
+ # needs the kitchen sink built-in.
+ local t="custom"
+ if [[ -z ${GRUB_MAX_KERNEL_SIZE} ]] ; then
+ case $(tc-arch) in
+ amd64) GRUB_MAX_KERNEL_SIZE=9 ;;
+ x86) GRUB_MAX_KERNEL_SIZE=5 ;;
+ esac
+ t="default"
+ fi
+ einfo "Grub will support the ${t} maximum kernel size of ${GRUB_MAX_KERNEL_SIZE} Mb (GRUB_MAX_KERNEL_SIZE)"
+
+ sed -i \
+ -e "/^#define.*EXTENDED_MEMSIZE/s,3,${GRUB_MAX_KERNEL_SIZE},g" \
+ "${S}"/grub/asmstub.c \
+ || die
+
+ if [[ -n ${PATCHVER} ]] ; then
+ EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
+ fi
+
+ EPATCH_SUFFIX="patch" epatch "${FILESDIR}"/formilux
+
+ eautoreconf
+}
+
+src_compile() {
+ filter-flags -fPIE #168834
+
+ use amd64 && multilib_toolchain_setup x86
+
+ unset BLOCK_SIZE #73499
+
+ ### i686-specific code in the boot loader is a bad idea; disabling to ensure
+ ### at least some compatibility if the hard drive is moved to an older or
+ ### incompatible system.
+
+ # grub-0.95 added -fno-stack-protector detection, to disable ssp for stage2,
+ # but the objcopy's (faulty) test fails if -fstack-protector is default.
+ # create a cache telling configure that objcopy is ok, and add -C to econf
+ # to make use of the cache.
+ #
+ # CFLAGS has to be undefined running econf, else -fno-stack-protector detection fails.
+ # STAGE2_CFLAGS is not allowed to be used on emake command-line, it overwrites
+ # -fno-stack-protector detected by configure, removed from netboot's emake.
+ use custom-cflags || unset CFLAGS
+
+ export grub_cv_prog_objcopy_absolute=yes #79734
+ use static && append-ldflags -static
+
+ # Per bug 216625, the emul packages do not provide .a libs for performing
+ # suitable static linking
+ if use amd64 && use static ; then
+ if [ -z "${GRUB_STATIC_PACKAGE_BUILDING}" ]; then
+ die "You must use the grub-static package if you want a static Grub on amd64!"
+ else
+ eerror "You have set GRUB_STATIC_PACKAGE_BUILDING. This"
+ eerror "is specifically intended for building the tarballs for the"
+ eerror "grub-static package via USE='static -ncurses'."
+ eerror "All bets are now off."
+ ebeep 10
+ fi
+ fi
+
+ # build the net-bootable grub first, but only if "netboot" is set
+ if use netboot ; then
+ econf \
+ --libdir=/lib \
+ --datadir=/usr/lib/grub \
+ --exec-prefix=/ \
+ --disable-auto-linux-mem-opt \
+ --enable-diskless \
+ --enable-{3c{5{03,07,09,29,95},90x},cs89x0,davicom,depca,eepro{,100}} \
+ --enable-{epic100,exos205,ni5210,lance,ne2100,ni{50,65}10,natsemi} \
+ --enable-{ne,ns8390,wd,otulip,rtl8139,sis900,sk-g16,smc9000,tiara} \
+ --enable-{tulip,via-rhine,w89c840}
+
+ emake w89c840_o_CFLAGS="-O" || die
+
+ mv -f stage2/{nbgrub,pxegrub} "${S}"/
+ mv -f stage2/stage2 stage2/stage2.netboot
+
+ emake -j1 clean || die
+ fi
+
+ # Now build the regular grub
+ # Note that FFS and UFS2 support are broken for now - stage1_5 files too big
+ econf \
+ --libdir=/lib \
+ --datadir=/usr/lib/grub \
+ --exec-prefix=/ \
+ --disable-auto-linux-mem-opt \
+ $(use_with ncurses curses)
+
+ # sanity check due to common failure
+ use ncurses && ! grep -qs "HAVE_LIBCURSES.*1" config.h && die "USE=ncurses but curses not found"
+
+ emake || die "making regular stuff"
+}
+
+src_test() {
+ # non-default block size also give false pass/fails.
+ unset BLOCK_SIZE
+ emake -j1 check || die
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die
+ if use netboot ; then
+ exeinto /usr/lib/grub/${CHOST}
+ doexe nbgrub pxegrub stage2/stage2.netboot || die
+ fi
+
+ # bug 330745
+ pax-mark -m "${D}"/sbin/grub
+
+ dodoc AUTHORS BUGS ChangeLog NEWS README THANKS TODO
+ newdoc docs/menu.lst grub.conf.sample
+ dodoc "${FILESDIR}"/grub.conf.gentoo
+ prepalldocs
+
+ [ -n "${GRUB_STATIC_PACKAGE_BUILDING}" ] && \
+ mv \
+ "${D}"/usr/share/doc/${PF} \
+ "${D}"/usr/share/doc/grub-static-${PF/grub-}
+
+ insinto /usr/share/grub
+ doins "${DISTDIR}"/splash.xpm.gz
+}
+
+setup_boot_dir() {
+ local boot_dir=$1
+ local dir=${boot_dir}
+
+ mkdir -p "${dir}"
+ [[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot"
+ dir="${dir}/grub"
+ if [[ ! -e ${dir} ]] ; then
+ mkdir "${dir}" || die
+ fi
+
+ # change menu.lst to grub.conf
+ if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then
+ mv -f "${dir}"/menu.lst "${dir}"/grub.conf
+ ewarn
+ ewarn "*** IMPORTANT NOTE: menu.lst has been renamed to grub.conf"
+ ewarn
+ fi
+
+ if [[ ! -e ${dir}/menu.lst ]]; then
+ einfo "Linking from new grub.conf name to menu.lst"
+ ln -snf grub.conf "${dir}"/menu.lst
+ fi
+
+ if [[ -e ${dir}/stage2 ]] ; then
+ mv "${dir}"/stage2{,.old}
+ ewarn "*** IMPORTANT NOTE: you must run grub and install"
+ ewarn "the new version's stage1 to your MBR. Until you do,"
+ ewarn "stage1 and stage2 will still be the old version, but"
+ ewarn "later stages will be the new version, which could"
+ ewarn "cause problems such as an unbootable system."
+ ewarn "This means you must use either grub-install or perform"
+ ewarn "root/setup manually! For more help, see the handbook:"
+ ewarn "http://www.gentoo.org/doc/en/handbook/handbook-${ARCH}.xml?part=1&chap=10#grub-install-auto"
+ ebeep
+ fi
+
+ einfo "Copying files from /lib/grub and /usr/share/grub to ${dir}"
+ for x in \
+ "${ROOT}"/lib*/grub/*/* \
+ "${ROOT}"/usr/share/grub/* ; do
+ [[ -f ${x} ]] && cp -p "${x}" "${dir}"/
+ done
+
+ if [[ ! -e ${dir}/grub.conf ]] ; then
+ s="${ROOT}/usr/share/doc/${PF}/grub.conf.gentoo"
+ [[ -e "${s}" ]] && cat "${s}" >${dir}/grub.conf
+ [[ -e "${s}.gz" ]] && zcat "${s}.gz" >${dir}/grub.conf
+ [[ -e "${s}.bz2" ]] && bzcat "${s}.bz2" >${dir}/grub.conf
+ fi
+
+ # Per bug 218599, we support grub.conf.install for users that want to run a
+ # specific set of Grub setup commands rather than the default ones.
+ grub_config=${dir}/grub.conf.install
+ [[ -e ${grub_config} ]] || grub_config=${dir}/grub.conf
+ if [[ -e ${grub_config} ]] ; then
+ egrep \
+ -v '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)' \
+ "${grub_config}" | \
+ /sbin/grub --batch \
+ --device-map="${dir}"/device.map \
+ > /dev/null
+ fi
+
+ # the grub default commands silently piss themselves if
+ # the default file does not exist ahead of time
+ if [[ ! -e ${dir}/default ]] ; then
+ grub-set-default --root-directory="${boot_dir}" default
+ fi
+ einfo "Grub has been installed to ${boot_dir} successfully."
+}
+
+pkg_postinst() {
+ mount-boot_mount_boot_partition
+
+ if [[ -n ${DONT_MOUNT_BOOT} ]]; then
+ elog "WARNING: you have DONT_MOUNT_BOOT in effect, so you must apply"
+ elog "the following instructions for your /boot!"
+ elog "Neglecting to do so may cause your system to fail to boot!"
+ elog
+ else
+ setup_boot_dir "${ROOT}"/boot
+ # Trailing output because if this is run from pkg_postinst, it gets mixed into
+ # the other output.
+ einfo ""
+ fi
+ elog "To interactively install grub files to another device such as a USB"
+ elog "stick, just run the following and specify the directory as prompted:"
+ elog " emerge --config =${PF}"
+ elog "Alternately, you can export GRUB_ALT_INSTALLDIR=/path/to/use to tell"
+ elog "grub where to install in a non-interactive way."
+
+ # needs to be after we call setup_boot_dir
+ mount-boot_pkg_postinst
+}
+
+pkg_config() {
+ local dir
+ if [ ! -d "${GRUB_ALT_INSTALLDIR}" ]; then
+ einfo "Enter the directory where you want to setup grub:"
+ read dir
+ else
+ dir="${GRUB_ALT_INSTALLDIR}"
+ fi
+ setup_boot_dir "${dir}"
+}