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