The Pedigree Project  0.1
user/applications/tour/main.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #define __STDCPP_WANT_MATH_SPEC_FUNCS__ 0
21 
22 #include <dialog.h>
23 #include <libintl.h>
24 #include <locale.h>
25 #include <stdlib.h>
26 #include <sys/wait.h>
27 #include <unistd.h>
28 
29 int main(int argc, char *argv[])
30 {
31  setlocale(LC_ALL, "");
32  bindtextdomain("tour", "/system/locale");
33  bind_textdomain_codeset("tour", "UTF-8");
34  textdomain("tour");
35 
36  // Undo any silliness.
37  chdir("root»/");
38 
40  init_dialog(stdin, stdout);
41  dialog_vars.colors = TRUE;
42  dialog_vars.ok_label = gettext("OK");
43  dialog_vars.nocancel = 1;
44 
45  dialog_msgbox(
46  gettext("Welcome to Pedigree!"),
47  gettext(
48  "This tour is designed to help you understand how Pedigree "
49  "differs from other UNIX-like systems. It's interactive, so you "
50  "can practice along the way."),
51  0, 0, 1);
52 
53  dlg_clear();
54 
55  dialog_prgbox(
56  gettext("Pedigree Tour"),
57  gettext("Let's run the `ls' command for you:"), "ls root»/", 20, 52, 1);
58 
59  dlg_clear();
60 
61  dialog_msgbox(
62  gettext("Pedigree Tour"),
63  gettext("As you can see, the typical /bin, /lib, /var (and so on) are "
64  "not present. Instead, you find /applications, /libraries, "
65  "/system, /config, and so on. This is designed to be intuitive "
66  "but it can cause problems with some software."),
67  0, 0, 1);
68 
69  dlg_clear();
70 
71  dialog_msgbox(
72  gettext("Pedigree Tour"),
73  gettext("After the tour completes, you can navigate around the "
74  "filesystem to to get a closer look at what each directory "
75  "contains."),
76  0, 0, 1);
77 
78  dlg_clear();
79 
80  dialog_msgbox(
81  gettext("Pedigree Tour"),
82  gettext("Another significant difference in Pedigree is the path "
83  "structure. In Pedigree, paths follow the format "
84  "[mount]»/path/to/file."),
85  0, 0, 1);
86 
87  dlg_clear();
88 
89  dialog_msgbox(
90  gettext("Pedigree Tour"),
91  gettext(
92  "We've switched directory to root»/ if you were elsewhere. "
93  "The root mount always exists; Pedigree will not start without it."
94  " Your applications and configuration exist under root»/."),
95  0, 0, 1);
96 
97  dlg_clear();
98 
99  dialog_msgbox(
100  gettext("Pedigree Tour"),
101  gettext(
102  "Paths that begin with a '/' will always operate in your "
103  "current mount. Because the current working directory is root»/, "
104  "we can simply run `/applications/ls' to run "
105  "`root»/applications/ls'."),
106  0, 0, 1);
107 
108  dlg_clear();
109 
110  while (true)
111  {
112  dlg_clr_result();
113  dialog_inputbox(
114  gettext("Pedigree Tour"),
115  gettext(
116  "Before we dig into what other mounts may exist, it's "
117  "important to know how to type these paths. You can type the "
118  "'»' character in Pedigree by using 'RIGHTALT-.' - try it "
119  "now. If you want to finish the tour, just type 'quit'."),
120  0, 0, "", 0);
121 
122  if (!strcmp(dialog_vars.input_result, "quit"))
123  {
124  end_dialog();
125  return 0;
126  }
127  else if (!strcmp(dialog_vars.input_result, "»"))
128  {
129  break;
130  }
131  }
132 
133  dlg_clear();
134 
135  dialog_msgbox(
136  gettext("Pedigree Tour"),
137  gettext(
138  "Now that you know how to type the paths, here are a "
139  "selection of standard Pedigree mounts."
140  "\n\n"
141  "* dev» provides device access (ala /dev).\n"
142  "* raw» provides access to raw disks and partitions.\n"
143  "* scratch» is an entirely in-memory filesystem.\n"
144  "* runtime» is an in-memory filesystem for runfiles (like /run).\n"
145  " Files here can only be modified by their owning process.\n"
146  "* unix» provides a location for named UNIX sockets."),
147  0, 0, 1);
148 
149  dlg_clear();
150 
151  dialog_msgbox(
152  gettext("Pedigree Tour"),
153  gettext(
154  "Note that there is a significant caveat with respect to the "
155  "$PATH variable with this scheme. If your $PATH does not contain "
156  "absolute paths, you may find that switching working directory to "
157  "a "
158  "different mount point can cause you to be unable to run any "
159  "commands."),
160  0, 0, 1);
161 
162  dlg_clear();
163 
164  dialog_msgbox(
165  gettext("Pedigree Tour"),
166  gettext("This image has been configured such that the default PATH "
167  "does this correctly. There may still be weirdness, and if you "
168  "notice "
169  "things are not quite working correctly, you can always run "
170  "`cd root»/` to return to the root mount."),
171  0, 0, 1);
172 
173  dlg_clear();
174 
175  dialog_msgbox(
176  gettext("Pedigree Tour"),
177  gettext(
178  "If something goes wrong, you may find yourself in the "
179  "Pedigree kernel debugger. This can also be accessed on-demand by "
180  "pressing F12 at any time."),
181  0, 0, 1);
182 
183  dlg_clear();
184 
185  dialog_msgbox(
186  gettext("Pedigree Tour"),
187  gettext("In the debugger, you can read the kernel log, view "
188  "backtraces, and do various other inspections to identify what "
189  "went "
190  "wrong or inspect kernel state."),
191  0, 0, 1);
192 
193  dlg_clear();
194 
195  dialog_msgbox(
196  gettext("Pedigree Tour"),
197  gettext("You can use the `help` command to see what is available in "
198  "the debugger. If you run into an issue that triggers the "
199  "debugger, "
200  "please try and add a serial port log if you report it to us. "
201  "Thanks!"),
202  0, 0, 1);
203 
204  dlg_clear();
205 
206  dialog_msgbox(
207  gettext("Pedigree Tour"),
208  gettext("The tour is now complete, and you are now better-equipped to "
209  "handle Pedigree! "
210  "Join us in #pedigree on Freenode IRC, and raise any issues "
211  "you find "
212  "at https://pedigree-project.org.\n\n"
213  "Thank you for trying out Pedigree!"),
214  0, 0, 1);
215 
216  end_dialog();
217  return 0;
218 }