1 /* 2 * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 3 * Copyright 2005, Jérôme DUVAL. 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 7 #include "InstallerApp.h" 8 9 #include <Alert.h> 10 #include <Button.h> 11 #include <GroupLayoutBuilder.h> 12 #include <Locale.h> 13 #include <ScrollView.h> 14 #include <TextView.h> 15 16 17 static const uint32 kMsgAgree = 'agre'; 18 19 //static const char* kEULAText = 20 //"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n" 21 // 22 //"Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights " 23 //"reserved. The copyright to the Haiku code is property of Haiku, Inc. or of " 24 //"the respective authors where expressly noted in the source.\n\n" 25 // 26 //"Permission is hereby granted, free of charge, to any person obtaining a " 27 //"copy of this software and associated documentation files (the \"Software\"), " 28 //"to deal in the Software without restriction, including without limitation " 29 //"the rights to use, copy, modify, merge, publish, distribute, sublicense, " 30 //"and/or sell copies of the Software, and to permit persons to whom the " 31 //"Software is furnished to do so, subject to the following conditions:\n\n" 32 //"The above copyright notice and this permission notice shall be included in " 33 //"all copies or substantial portions of the Software.\n\n" 34 // 35 //"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS " 36 //"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " 37 //"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " 38 //"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " 39 //"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING " 40 //"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS " 41 //"IN THE SOFTWARE."; 42 43 44 #undef B_TRANSLATE_CONTEXT 45 #define B_TRANSLATE_CONTEXT "InstallerApp" 46 47 48 int main(int, char **) 49 { 50 InstallerApp theApp; 51 theApp.Run(); 52 return 0; 53 } 54 55 56 InstallerApp::InstallerApp() 57 : 58 BApplication("application/x-vnd.Haiku-Installer") 59 { 60 } 61 62 63 void 64 InstallerApp::MessageReceived(BMessage* message) 65 { 66 switch (message->what) { 67 case kMsgAgree: 68 fEULAWindow->Lock(); 69 fEULAWindow->Quit(); 70 new InstallerWindow(); 71 break; 72 73 default: 74 BApplication::MessageReceived(message); 75 } 76 } 77 78 79 void 80 InstallerApp::AboutRequested() 81 { 82 BAlert *alert = new BAlert("about", B_TRANSLATE("Installer\n" 83 "\twritten by Jérôme Duval and Stephan Aßmus\n" 84 "\tCopyright 2005-2010, Haiku.\n\n"), B_TRANSLATE("OK")); 85 BTextView *view = alert->TextView(); 86 BFont font; 87 88 view->SetStylable(true); 89 90 view->GetFont(&font); 91 font.SetSize(18); 92 font.SetFace(B_BOLD_FACE); 93 view->SetFontAndColor(0, 9, &font); 94 95 alert->Go(); 96 } 97 98 99 void 100 InstallerApp::ReadyToRun() 101 { 102 BString infoText; 103 infoText << B_TRANSLATE( 104 "Welcome to the Haiku Installer!\n\n"); 105 infoText << B_TRANSLATE( 106 "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n"); 107 infoText << B_TRANSLATE( 108 "This is alpha-quality software! It means there is a high risk of " 109 "losing important data. Make frequent backups! You have been " 110 "warned.\n\n\n"); 111 infoText << B_TRANSLATE( 112 "1) If you are installing Haiku onto real hardware (not inside an " 113 "emulator) it is recommended that you have already prepared a hard " 114 "disk partition. The Installer and the DriveSetup tool offer to " 115 "initialize existing partitions with the Haiku native file system, " 116 "but the options to change the actual partition layout may not have " 117 "been tested on a sufficiently great variety of computer " 118 "configurations so we do not recommend using it.\n"); 119 infoText << B_TRANSLATE( 120 "If you have not created a partition yet, simply reboot, create the " 121 "partition using whatever tool you feel most comfortable with, and " 122 "reboot into Haiku to continue with the installation. You could for " 123 "example use the GParted Live-CD, it can also resize existing " 124 "partitions to make room.\n\n\n"); 125 infoText << B_TRANSLATE( 126 "2) The Installer will make the Haiku partition itself bootable, " 127 "but takes no steps to integrate Haiku into an existing boot menu. " 128 "If you have GRUB already installed, you can add Haiku to its boot " 129 "menu. Depending on what version of GRUB you use, this is done " 130 "differently.\n\n\n"); 131 infoText << B_TRANSLATE( 132 "2.1) GRUB 1\n"); 133 infoText << B_TRANSLATE( 134 "Configure your /boot/grub/menu.lst by launching your favorite " 135 "editor from a Terminal like this:\n\n"); 136 infoText << B_TRANSLATE( 137 "\tsudo <your favorite text editor> /boot/grub/menu.lst\n\n"); 138 infoText << B_TRANSLATE( 139 "You'll note that GRUB uses a different naming strategy for hard " 140 "drives than Linux.\n\n"); 141 infoText << B_TRANSLATE( 142 "With GRUB it's: (hdN,n)\n\n"); 143 infoText << B_TRANSLATE( 144 "All hard disks start with \"hd\".\n"); 145 infoText << B_TRANSLATE( 146 "\"N\" is the hard disk number, starting with \"0\".\n"); 147 infoText << B_TRANSLATE( 148 "\"n\" is the partition number, also starting with \"0\".\n"); 149 infoText << B_TRANSLATE( 150 "The first logical partition always has the number \"4\", regardless " 151 "of the number of primary partitions.\n\n"); 152 infoText << B_TRANSLATE( 153 "So behind the other menu entries towards the bottom of the file, add " 154 "something similar to these lines:\n\n"); 155 infoText << B_TRANSLATE( 156 "\t# Haiku on /dev/sda7\n"); 157 infoText << B_TRANSLATE( 158 "\ttitle\t\t\t\tHaiku\n"); 159 infoText << B_TRANSLATE( 160 "\trootnoverify\t\t(hd0,6)\n"); 161 infoText << B_TRANSLATE( 162 "\tchainloader\t\t+1\n\n"); 163 infoText << B_TRANSLATE( 164 "You can see the correct partition in GParted for example.\n\n\n"); 165 infoText << B_TRANSLATE( 166 "2.2) GRUB 2\n"); 167 infoText << B_TRANSLATE( 168 "Newer versions of GRUB use an extra configuration file to add " 169 "custom entries to the boot menu. To add them to the top, you have " 170 "to create/edit a file by launching your favorite editor from a " 171 "Terminal like this:\n\n"); 172 infoText << B_TRANSLATE( 173 "\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n"); 174 infoText << B_TRANSLATE( 175 "NOTE: While the naming strategy for hard disks is still as described " 176 "under 2.1) the naming scheme for partitions has changed.\n\n"); 177 infoText << B_TRANSLATE( 178 "GRUB's naming scheme is still: (hdN,n)\n\n"); 179 infoText << B_TRANSLATE( 180 "All hard disks start with \"hd\".\n"); 181 infoText << B_TRANSLATE( 182 "\"N\" is the hard disk number, starting with \"0\".\n"); 183 infoText << B_TRANSLATE( 184 "\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n"); 185 infoText << B_TRANSLATE( 186 "With GRUB 2 the first logical partition always has the number \"5\", " 187 "regardless of the number of primary partitions.\n\n"); 188 infoText << B_TRANSLATE( 189 "So below the heading that must not be edited, add something similar " 190 "to these lines:\n\n"); 191 infoText << B_TRANSLATE( 192 "\t# Haiku on /dev/sda7\n"); 193 infoText << B_TRANSLATE( 194 "\tmenuentry \"Haiku Alpha\" {\n"); 195 infoText << B_TRANSLATE( 196 "\t\tset root=(hd0,7)\n"); 197 infoText << B_TRANSLATE( 198 "\t\tchainloader +1\n"); 199 infoText << B_TRANSLATE( 200 "\t}\n\n"); 201 infoText << B_TRANSLATE( 202 "Additionally you have to edit another file to actually display the " 203 "boot menu:\n\n"); 204 infoText << B_TRANSLATE( 205 "\tsudo <your favorite text editor> /etc/default/grub\n\n"); 206 infoText << B_TRANSLATE( 207 "Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by " 208 "putting a \"#\" in front of it in order to actually display the " 209 "boot menu.\n\n"); 210 infoText << B_TRANSLATE( 211 "Finally, you have to update the boot menu by entering:\n\n"); 212 infoText << B_TRANSLATE( 213 "\tsudo update-grub\n\n\n"); 214 infoText << B_TRANSLATE( 215 "3) When you successfully boot into Haiku for the first time, make " 216 "sure to read our \"Welcome\" documentation, there is a link on the " 217 "Desktop.\n\n"); 218 infoText << B_TRANSLATE( 219 "Have fun and thanks a lot for trying out Haiku! We hope you like it!"); 220 221 #if 1 222 // Show the EULA first. 223 BTextView* textView = new BTextView("eula", be_plain_font, NULL, 224 B_WILL_DRAW); 225 textView->SetInsets(10, 10, 10, 10); 226 textView->MakeEditable(false); 227 textView->MakeSelectable(false); 228 textView->SetText(infoText); 229 230 BScrollView* scrollView = new BScrollView("eulaScroll", 231 textView, B_WILL_DRAW, false, true); 232 233 BButton* cancelButton = new BButton(B_TRANSLATE("Quit"), 234 new BMessage(B_QUIT_REQUESTED)); 235 cancelButton->SetTarget(this); 236 237 BButton* continueButton = new BButton(B_TRANSLATE("Continue"), 238 new BMessage(kMsgAgree)); 239 continueButton->SetTarget(this); 240 continueButton->MakeDefault(true); 241 242 BRect eulaFrame = BRect(0, 0, 600, 450); 243 fEULAWindow = new BWindow(eulaFrame, B_TRANSLATE("README"), 244 B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE 245 | B_AUTO_UPDATE_SIZE_LIMITS); 246 247 fEULAWindow->SetLayout(new BGroupLayout(B_HORIZONTAL)); 248 fEULAWindow->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 249 .Add(scrollView) 250 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 251 .AddGlue() 252 .Add(cancelButton) 253 .Add(continueButton) 254 ) 255 .SetInsets(10, 10, 10, 10) 256 ); 257 258 fEULAWindow->CenterOnScreen(); 259 fEULAWindow->Show(); 260 #else 261 // Show the installer window without EULA. 262 new InstallerWindow(); 263 #endif 264 } 265 266