16ffb6a6eSJérôme Duval /* 27ff74a7bSStephan Aßmus * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 37ff74a7bSStephan Aßmus * Copyright 2005, Jérôme DUVAL. 47ff74a7bSStephan Aßmus * All rights reserved. Distributed under the terms of the MIT License. 56ffb6a6eSJérôme Duval */ 66ffb6a6eSJérôme Duval 77ff74a7bSStephan Aßmus #include "InstallerApp.h" 87ff74a7bSStephan Aßmus 96ffb6a6eSJérôme Duval #include <Alert.h> 107ff74a7bSStephan Aßmus #include <Button.h> 117ff74a7bSStephan Aßmus #include <GroupLayoutBuilder.h> 124a2da425SStephan Aßmus #include <Locale.h> 1335d3acb2SJérôme Duval #include <ScrollView.h> 146ffb6a6eSJérôme Duval #include <TextView.h> 156ffb6a6eSJérôme Duval 166ffb6a6eSJérôme Duval 177ff74a7bSStephan Aßmus static const uint32 kMsgAgree = 'agre'; 187ff74a7bSStephan Aßmus 193ac4a739SStephan Aßmus //static const char* kEULAText = 203ac4a739SStephan Aßmus //"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n" 213ac4a739SStephan Aßmus // 223ac4a739SStephan Aßmus //"Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights " 233ac4a739SStephan Aßmus //"reserved. The copyright to the Haiku code is property of Haiku, Inc. or of " 243ac4a739SStephan Aßmus //"the respective authors where expressly noted in the source.\n\n" 253ac4a739SStephan Aßmus // 263ac4a739SStephan Aßmus //"Permission is hereby granted, free of charge, to any person obtaining a " 273ac4a739SStephan Aßmus //"copy of this software and associated documentation files (the \"Software\"), " 283ac4a739SStephan Aßmus //"to deal in the Software without restriction, including without limitation " 293ac4a739SStephan Aßmus //"the rights to use, copy, modify, merge, publish, distribute, sublicense, " 303ac4a739SStephan Aßmus //"and/or sell copies of the Software, and to permit persons to whom the " 313ac4a739SStephan Aßmus //"Software is furnished to do so, subject to the following conditions:\n\n" 323ac4a739SStephan Aßmus //"The above copyright notice and this permission notice shall be included in " 333ac4a739SStephan Aßmus //"all copies or substantial portions of the Software.\n\n" 343ac4a739SStephan Aßmus // 353ac4a739SStephan Aßmus //"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS " 363ac4a739SStephan Aßmus //"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " 373ac4a739SStephan Aßmus //"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " 383ac4a739SStephan Aßmus //"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " 393ac4a739SStephan Aßmus //"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING " 403ac4a739SStephan Aßmus //"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS " 413ac4a739SStephan Aßmus //"IN THE SOFTWARE."; 427ff74a7bSStephan Aßmus 437ff74a7bSStephan Aßmus 444eb0cbb0SMatt Madia #undef B_TRANSLATE_CONTEXT 454eb0cbb0SMatt Madia #define B_TRANSLATE_CONTEXT "InstallerApp" 467ff74a7bSStephan Aßmus 4735d3acb2SJérôme Duval 486ffb6a6eSJérôme Duval int main(int, char **) 496ffb6a6eSJérôme Duval { 506ffb6a6eSJérôme Duval InstallerApp theApp; 516ffb6a6eSJérôme Duval theApp.Run(); 526ffb6a6eSJérôme Duval return 0; 536ffb6a6eSJérôme Duval } 546ffb6a6eSJérôme Duval 557ff74a7bSStephan Aßmus 566ffb6a6eSJérôme Duval InstallerApp::InstallerApp() 574a2da425SStephan Aßmus : 584a2da425SStephan Aßmus BApplication("application/x-vnd.Haiku-Installer") 596ffb6a6eSJérôme Duval { 6053ad1814SJérôme Duval } 6153ad1814SJérôme Duval 627ff74a7bSStephan Aßmus 637ff74a7bSStephan Aßmus void 647ff74a7bSStephan Aßmus InstallerApp::MessageReceived(BMessage* message) 657ff74a7bSStephan Aßmus { 667ff74a7bSStephan Aßmus switch (message->what) { 677ff74a7bSStephan Aßmus case kMsgAgree: 687ff74a7bSStephan Aßmus fEULAWindow->Lock(); 697ff74a7bSStephan Aßmus fEULAWindow->Quit(); 707ff74a7bSStephan Aßmus new InstallerWindow(); 717ff74a7bSStephan Aßmus break; 727ff74a7bSStephan Aßmus 737ff74a7bSStephan Aßmus default: 747ff74a7bSStephan Aßmus BApplication::MessageReceived(message); 756ffb6a6eSJérôme Duval } 767ff74a7bSStephan Aßmus } 777ff74a7bSStephan Aßmus 786ffb6a6eSJérôme Duval 796ffb6a6eSJérôme Duval void 806ffb6a6eSJérôme Duval InstallerApp::AboutRequested() 816ffb6a6eSJérôme Duval { 82e904ecc9SMatt Madia BAlert *alert = new BAlert("about", B_TRANSLATE("Installer\n" 834a2da425SStephan Aßmus "\twritten by Jérôme Duval and Stephan Aßmus\n" 84e904ecc9SMatt Madia "\tCopyright 2005-2010, Haiku.\n\n"), B_TRANSLATE("OK")); 856ffb6a6eSJérôme Duval BTextView *view = alert->TextView(); 866ffb6a6eSJérôme Duval BFont font; 876ffb6a6eSJérôme Duval 886ffb6a6eSJérôme Duval view->SetStylable(true); 896ffb6a6eSJérôme Duval 906ffb6a6eSJérôme Duval view->GetFont(&font); 916ffb6a6eSJérôme Duval font.SetSize(18); 926ffb6a6eSJérôme Duval font.SetFace(B_BOLD_FACE); 9337895b5dSJoachim Seemer view->SetFontAndColor(0, 9, &font); 946ffb6a6eSJérôme Duval 956ffb6a6eSJérôme Duval alert->Go(); 966ffb6a6eSJérôme Duval } 976ffb6a6eSJérôme Duval 986ffb6a6eSJérôme Duval 996ffb6a6eSJérôme Duval void 1006ffb6a6eSJérôme Duval InstallerApp::ReadyToRun() 1016ffb6a6eSJérôme Duval { 102e904ecc9SMatt Madia const char* infoText = B_TRANSLATE( 1034a2da425SStephan Aßmus "Welcome to the Haiku Installer!\n\n" 1044a2da425SStephan Aßmus 1054a2da425SStephan Aßmus "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n" 1064a2da425SStephan Aßmus 1074a2da425SStephan Aßmus "This is alpha-quality software! It means there is a high risk of " 1084a2da425SStephan Aßmus "losing important data. Make frequent backups! You have been " 109*3fa60838SJoachim Seemer "warned.\n\n\n" 1104a2da425SStephan Aßmus 1114a2da425SStephan Aßmus "1) If you are installing Haiku onto real hardware (not inside an " 1124a2da425SStephan Aßmus "emulator) it is recommended that you have already prepared a hard " 1134a2da425SStephan Aßmus "disk partition. The Installer and the DriveSetup tool offer to " 1144a2da425SStephan Aßmus "initialize existing partitions with the Haiku native file system, " 1154a2da425SStephan Aßmus "but the options to change the actual partition layout may not have " 1164a2da425SStephan Aßmus "been tested on a sufficiently great variety of computer " 117*3fa60838SJoachim Seemer "configurations so we do not recommend using it.\n" 1184a2da425SStephan Aßmus "If you have not created a partition yet, simply reboot, create the " 1194a2da425SStephan Aßmus "partition using whatever tool you feel most comfortable with, and " 1204a2da425SStephan Aßmus "reboot into Haiku to continue with the installation. You could for " 1214a2da425SStephan Aßmus "example use the GParted Live-CD, it can also resize existing " 122*3fa60838SJoachim Seemer "partitions to make room.\n\n\n" 1234a2da425SStephan Aßmus 124*3fa60838SJoachim Seemer "2) The Installer will make the Haiku partition itself bootable, " 125*3fa60838SJoachim Seemer "but takes no steps to integrate Haiku into an existing boot menu. " 126*3fa60838SJoachim Seemer "If you have GRUB already installed, you can add Haiku to its boot " 127*3fa60838SJoachim Seemer "menu. Depending on what version of GRUB you use, this is done " 128*3fa60838SJoachim Seemer "differently.\n\n\n" 129*3fa60838SJoachim Seemer 130*3fa60838SJoachim Seemer "2.1) GRUB 1\n" 131*3fa60838SJoachim Seemer "Configure your /boot/grub/menu.lst by launching your favorite " 132*3fa60838SJoachim Seemer "editor from a Terminal like this:\n\n" 1334a2da425SStephan Aßmus 1344a2da425SStephan Aßmus "\tsudo <your favorite text editor> /boot/grub/menu.lst\n\n" 1354a2da425SStephan Aßmus 1364a2da425SStephan Aßmus "You'll note that GRUB uses a different naming strategy for hard " 1374a2da425SStephan Aßmus "drives than Linux.\n\n" 1384a2da425SStephan Aßmus 1394a2da425SStephan Aßmus "With GRUB it's: (hdN,n)\n\n" 1404a2da425SStephan Aßmus 141*3fa60838SJoachim Seemer "All hard disks start with \"hd\".\n" 1424a2da425SStephan Aßmus "\"N\" is the hard disk number, starting with \"0\".\n" 1434a2da425SStephan Aßmus "\"n\" is the partition number, also starting with \"0\".\n" 144*3fa60838SJoachim Seemer "The first logical partition always has the number \"4\", regardless " 145*3fa60838SJoachim Seemer "of the number of primary partitions.\n\n" 1464a2da425SStephan Aßmus 1474a2da425SStephan Aßmus "So behind the other menu entries towards the bottom of the file, add " 1484a2da425SStephan Aßmus "something similar to these lines:\n\n" 1494a2da425SStephan Aßmus 1504a2da425SStephan Aßmus "\t# Haiku on /dev/sda7\n" 1514a2da425SStephan Aßmus "\ttitle\t\t\t\tHaiku\n" 1524a2da425SStephan Aßmus "\trootnoverify\t\t(hd0,6)\n" 1534a2da425SStephan Aßmus "\tchainloader\t\t+1\n\n" 1544a2da425SStephan Aßmus 155*3fa60838SJoachim Seemer "You can see the correct partition in GParted for example.\n\n\n" 156*3fa60838SJoachim Seemer 157*3fa60838SJoachim Seemer "2.2) GRUB 2\n" 158*3fa60838SJoachim Seemer "Newer versions of GRUB use an extra configuration file to add " 159*3fa60838SJoachim Seemer "custom entries to the boot menu. To add them to the top, you have " 160*3fa60838SJoachim Seemer "to create/edit a file by launching your favorite editor from a " 161*3fa60838SJoachim Seemer "Terminal like this:\n\n" 162*3fa60838SJoachim Seemer 163*3fa60838SJoachim Seemer "\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n" 164*3fa60838SJoachim Seemer 165*3fa60838SJoachim Seemer "NOTE: While the naming strategy for hard disks is still as described " 166*3fa60838SJoachim Seemer "under 2.1) the naming scheme for partitions has changed.\n\n" 167*3fa60838SJoachim Seemer 168*3fa60838SJoachim Seemer "GRUB's naming scheme is still: (hdN,n)\n\n" 169*3fa60838SJoachim Seemer 170*3fa60838SJoachim Seemer "All hard disks start with \"hd\".\n" 171*3fa60838SJoachim Seemer "\"N\" is the hard disk number, starting with \"0\".\n" 172*3fa60838SJoachim Seemer "\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n" 173*3fa60838SJoachim Seemer "With GRUB 2 the first logical partition always has the number \"5\", " 174*3fa60838SJoachim Seemer "regardless of the number of primary partitions.\n\n" 175*3fa60838SJoachim Seemer 176*3fa60838SJoachim Seemer "So below the heading that must not be edited, add something similar " 177*3fa60838SJoachim Seemer "to these lines:\n\n" 178*3fa60838SJoachim Seemer 179*3fa60838SJoachim Seemer "\t# Haiku on /dev/sda7\n" 180*3fa60838SJoachim Seemer "\tmenuentry \"Haiku Alpha\" {\n" 181*3fa60838SJoachim Seemer "\t\tset root=(hd0,7)\n" 182*3fa60838SJoachim Seemer "\t\tchainloader +1\n" 183*3fa60838SJoachim Seemer "\t}\n\n" 184*3fa60838SJoachim Seemer 185*3fa60838SJoachim Seemer "Additionally you have to edit another file to actually display the " 186*3fa60838SJoachim Seemer "boot menu:\n\n" 187*3fa60838SJoachim Seemer 188*3fa60838SJoachim Seemer "\tsudo <your favorite text editor> /etc/default/grub\n\n" 189*3fa60838SJoachim Seemer 190*3fa60838SJoachim Seemer "Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by " 191*3fa60838SJoachim Seemer "putting a \"#\" in front of it in order to actually display the " 192*3fa60838SJoachim Seemer "boot menu.\n\n" 193*3fa60838SJoachim Seemer 194*3fa60838SJoachim Seemer "Finally, you have to update the boot menu by entering:\n\n" 195*3fa60838SJoachim Seemer 196*3fa60838SJoachim Seemer "\tsudo update-grub\n\n\n" 1974a2da425SStephan Aßmus 1984a2da425SStephan Aßmus "3) When you successfully boot into Haiku for the first time, make " 1994a2da425SStephan Aßmus "sure to read our \"Welcome\" documentation, there is a link on the " 2004a2da425SStephan Aßmus "Desktop.\n\n" 2014a2da425SStephan Aßmus 2024a2da425SStephan Aßmus "Have fun and thanks a lot for trying out Haiku! We hope you like it!" 2034a2da425SStephan Aßmus ); 2044a2da425SStephan Aßmus 2057ff74a7bSStephan Aßmus #if 1 2067ff74a7bSStephan Aßmus // Show the EULA first. 2077ff74a7bSStephan Aßmus BTextView* textView = new BTextView("eula", be_plain_font, NULL, 2087ff74a7bSStephan Aßmus B_WILL_DRAW); 2097ff74a7bSStephan Aßmus textView->SetInsets(10, 10, 10, 10); 2107ff74a7bSStephan Aßmus textView->MakeEditable(false); 2117ff74a7bSStephan Aßmus textView->MakeSelectable(false); 2124a2da425SStephan Aßmus textView->SetText(infoText); 2136ffb6a6eSJérôme Duval 2147ff74a7bSStephan Aßmus BScrollView* scrollView = new BScrollView("eulaScroll", 2157ff74a7bSStephan Aßmus textView, B_WILL_DRAW, false, true); 2167ff74a7bSStephan Aßmus 217e904ecc9SMatt Madia BButton* cancelButton = new BButton(B_TRANSLATE("Quit"), 2187ff74a7bSStephan Aßmus new BMessage(B_QUIT_REQUESTED)); 2193ac4a739SStephan Aßmus cancelButton->SetTarget(this); 2207ff74a7bSStephan Aßmus 221e904ecc9SMatt Madia BButton* continueButton = new BButton(B_TRANSLATE("Continue"), 2227ff74a7bSStephan Aßmus new BMessage(kMsgAgree)); 2233ac4a739SStephan Aßmus continueButton->SetTarget(this); 2243ac4a739SStephan Aßmus continueButton->MakeDefault(true); 2257ff74a7bSStephan Aßmus 2267ff74a7bSStephan Aßmus BRect eulaFrame = BRect(0, 0, 600, 450); 227e904ecc9SMatt Madia fEULAWindow = new BWindow(eulaFrame, B_TRANSLATE("README"), 2287ff74a7bSStephan Aßmus B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE 2297ff74a7bSStephan Aßmus | B_AUTO_UPDATE_SIZE_LIMITS); 2307ff74a7bSStephan Aßmus 2317ff74a7bSStephan Aßmus fEULAWindow->SetLayout(new BGroupLayout(B_HORIZONTAL)); 2327ff74a7bSStephan Aßmus fEULAWindow->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 2337ff74a7bSStephan Aßmus .Add(scrollView) 2347ff74a7bSStephan Aßmus .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 2357ff74a7bSStephan Aßmus .AddGlue() 2363ac4a739SStephan Aßmus .Add(cancelButton) 2373ac4a739SStephan Aßmus .Add(continueButton) 2387ff74a7bSStephan Aßmus ) 2397ff74a7bSStephan Aßmus .SetInsets(10, 10, 10, 10) 2407ff74a7bSStephan Aßmus ); 2417ff74a7bSStephan Aßmus 242e9953d08SJonas Sundström fEULAWindow->CenterOnScreen(); 2437ff74a7bSStephan Aßmus fEULAWindow->Show(); 2447ff74a7bSStephan Aßmus #else 2457ff74a7bSStephan Aßmus // Show the installer window without EULA. 2467ff74a7bSStephan Aßmus new InstallerWindow(); 2477ff74a7bSStephan Aßmus #endif 2486ffb6a6eSJérôme Duval } 2496ffb6a6eSJérôme Duval 250